Changeset 10011 for code/branches/modularships
- Timestamp:
- Apr 2, 2014, 8:38:07 PM (11 years ago)
- Location:
- code/branches/modularships
- Files:
-
- 2 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/data/levels/emptyLevel.oxw
r10003 r10011 16 16 include("templates/spaceshipPirate.oxt") 17 17 include("templates/spaceshipEscort.oxt") 18 include("templates/HeavyCruiser.oxt") 18 19 ?> 19 20 … … 91 92 </Pawn> 92 93 94 <ModularSpaceShip position="0,-100,-200"> 95 <templates> 96 <Template link=spaceshippirate /> 97 </templates> 98 </ModularSpaceShip> 99 100 <ModularSpaceShip position="0,-1000,-200"> 101 <templates> 102 <Template link=HeavyCruiser /> 103 </templates> 104 </ModularSpaceShip> 105 93 106 </Scene> 94 107 </Level> -
code/branches/modularships/data/levels/templates/HeavyCruiser.oxt
r9943 r10011 2 2 3 3 <Template name=HeavyCruiser> 4 <SpaceShip 4 <ModularSpaceShip 5 name = HeavyCruiser 6 5 7 hudtemplate = spaceshiphud 6 8 camerapositiontemplate = heavycruisercameras … … 47 49 <MultiStateEngine position="140,0,308" template=HeavyCruiser_sidearmR_engine1 /> 48 50 </engines> 51 52 <parts> 53 <ShipPart name="part0" /> 54 <ShipPart name="part1" /> 55 </parts> 56 49 57 <attached> 50 51 58 <Model mesh="HeavyCruiser_body.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 52 <Model mesh="HeavyCruiser_frontL.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 53 <Model mesh="HeavyCruiser_frontR.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 54 <Model mesh="HeavyCruiser_partL.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 55 <Model mesh="HeavyCruiser_partR.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 56 <Model mesh="HeavyCruiser_sidearmL.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 57 <Model mesh="HeavyCruiser_sidearmLfront.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 58 <Model mesh="HeavyCruiser_sidearmR.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 59 <Model mesh="HeavyCruiser_sidearmRfront.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 59 60 <StaticEntity name="frontL" position="0,0,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 > 61 <attached> 62 <Model mesh="HeavyCruiser_frontL.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 63 </attached> 64 <collisionShapes> 65 <BoxCollisionShape position="-80,33,-320" halfExtents="7,11,54" info="frontL"/> 66 <BoxCollisionShape position="-79,31,-399" halfExtents="3,6,26" info="frontL"/> 67 </collisionShapes> 68 </StaticEntity> 69 70 <StaticEntity name="frontR" position="0,0,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 > 71 <attached> 72 <Model mesh="HeavyCruiser_frontR.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 73 </attached> 74 <collisionShapes> 75 <BoxCollisionShape position="80,33,-320" halfExtents="7,11,54" info="frontR"/> 76 <BoxCollisionShape position="79,31,-399" halfExtents="3,6,26" info="frontR"/> 77 </collisionShapes> 78 </StaticEntity> 79 80 <StaticEntity name="partL" position="0,0,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 > 81 <attached> 82 <Model mesh="HeavyCruiser_partL.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 83 </attached> 84 <collisionShapes> 85 <BoxCollisionShape position="-94,33,-179" halfExtents="11,13,45" info="partL"/> 86 <BoxCollisionShape position="-96,33,-230" halfExtents="13,17,22" info="partL"/> 87 </collisionShapes> 88 </StaticEntity> 89 90 <StaticEntity name="partR" position="0,0,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 > 91 <attached> 92 <Model mesh="HeavyCruiser_partR.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 93 </attached> 94 <collisionShapes> 95 <BoxCollisionShape position="94,33,-179" halfExtents="11,13,45" info="partR"/> 96 <BoxCollisionShape position="96,33,-230" halfExtents="13,17,22" info="partR"/> 97 </collisionShapes> 98 </StaticEntity> 99 100 <StaticEntity name="sidearmL" position="0,0,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 > 101 <attached> 102 <Model mesh="HeavyCruiser_sidearmL.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 103 </attached> 104 <collisionShapes> 105 <BoxCollisionShape position="-109,47,87" halfExtents="29,8,26" info="sidearmL, upper connection"/> 106 <BoxCollisionShape position="-99,-1,79" roll="15" halfExtents="40,4,9" info="sidearmL, lower connection"/> 107 <BoxCollisionShape position="-145,21,115" roll="15" halfExtents="19,31,105" info="sidearmL, front"/> 108 <BoxCollisionShape position="-140,12,261" roll="15" halfExtents="22,41,43" info="sidearmL, back"/> 109 <BoxCollisionShape position="-145,25,5" roll="15" halfExtents="10,18,5" info="sidearmL, front break"/> 110 <BoxCollisionShape position="-133,-13,29" roll="15" halfExtents="12,6,17" info="sidearmL, bottom cylinder"/> 111 <BoxCollisionShape position="-165,-4,31" roll="15" halfExtents="7,21,13" info="sidearmL, box"/> 112 <BoxCollisionShape position="-153,59,96" roll="15" halfExtents="6,7,60" info="sidearmL, upper beam"/> 113 <BoxCollisionShape position="-143,57,119" roll="15" halfExtents="3,4,85" info="sidearmL, upper inner beam"/> 114 <BoxCollisionShape position="-142,53,212" pitch="21" yaw="5" roll="15" halfExtents="3,4,10" info="sidearmL, upper inner beam"/> 115 <BoxCollisionShape position="-160,52,119" roll="15" halfExtents="3,4,85" info="sidearmL, upper outer beam"/> 116 <BoxCollisionShape position="-159,48,212" pitch="21" yaw="5" roll="15" halfExtents="3,4,10" info="sidearmL, upper outer beam"/> 117 <BoxCollisionShape position="-152,54,34" pitch="-46" yaw="-14" roll="15" halfExtents="6,7,10" info="sidearmL, upper beam front"/> 118 <BoxCollisionShape position="-152,54,162" pitch="30" yaw="9" roll="15" halfExtents="6,7,12" info="sidearmL, upper beam back"/> 119 <BoxCollisionShape position="-168,21,119" roll="15" halfExtents="3,5,109" info="sidearmL, outer beam"/> 120 <BoxCollisionShape position="-134,-10,169" roll="15" halfExtents="6,4,55" info="sidearmL, lower beam front"/> 121 <BoxCollisionShape position="-131,-20,217" pitch="-20" roll="15" yaw="-5" halfExtents="6,12,3" info="sidearmL, lower beam middle"/> 122 <BoxCollisionShape position="-130,-29,233" roll="15" halfExtents="6,3,15" info="sidearmL, lower beam back"/> 123 </collisionShapes> 124 </StaticEntity> 125 126 <StaticEntity name="sidearmLfront" position="0,0,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 > 127 <attached> 128 <Model mesh="HeavyCruiser_sidearmLfront.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 129 </attached> 130 <collisionShapes> 131 <BoxCollisionShape position="-141,15,-53" roll="15" halfExtents="27,44,62" info="sidearmLfront"/> 132 <BoxCollisionShape position="-153,59,-30" roll="15" halfExtents="4,2,38" info="sidearmLfront, top"/> 133 <BoxCollisionShape position="-153,61,-41" roll="15" halfExtents="4,4,11" info="sidearmLfront, top"/> 134 <BoxCollisionShape position="-153,60,-65" roll="15" halfExtents="4,3,4" info="sidearmLfront, top"/> 135 <BoxCollisionShape position="-153,59,-41" roll="15" halfExtents="8,2,11" info="sidearmLfront, top"/> 136 </collisionShapes> 137 </StaticEntity> 138 139 <StaticEntity name="sidearmR" position="0,0,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 > 140 <attached> 141 <Model mesh="HeavyCruiser_sidearmR.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 142 </attached> 143 <collisionShapes> 144 <BoxCollisionShape position="109,47,87" halfExtents="29,8,26" info="sidearmR, upper connection"/> 145 <BoxCollisionShape position="99,-1,79" roll="-15" halfExtents="40,4,9" info="sidearmR, lower connection"/> 146 <BoxCollisionShape position="145,21,115" roll="-15" halfExtents="19,31,105" info="sidearmR, front"/> 147 <BoxCollisionShape position="140,12,261" roll="-15" halfExtents="22,41,43" info="sidearmR, back"/> 148 <BoxCollisionShape position="145,25,5" roll="-15" halfExtents="10,18,5" info="sidearmR, front break"/> 149 <BoxCollisionShape position="133,-13,29" roll="-15" halfExtents="12,6,17" info="sidearmR, bottom cylinder"/> 150 <BoxCollisionShape position="165,-4,31" roll="-15" halfExtents="7,21,13" info="sidearmR, box"/> 151 <BoxCollisionShape position="153,59,96" roll="-15" halfExtents="6,7,60" info="sidearmR, upper beam"/> 152 <BoxCollisionShape position="143,57,119" roll="-15" halfExtents="3,4,85" info="sidearmR, upper inner beam"/> 153 <BoxCollisionShape position="142,53,212" pitch="21" yaw="-5" roll="-15" halfExtents="3,4,10" info="sidearmR, upper inner beam"/> 154 <BoxCollisionShape position="160,52,119" roll="-15" halfExtents="3,4,85" info="sidearmR, upper outer beam"/> 155 <BoxCollisionShape position="159,48,212" pitch="21" yaw="-5" roll="-15" halfExtents="3,4,10" info="sidearmR, upper outer beam"/> 156 <BoxCollisionShape position="152,54,34" pitch="-46" yaw="14" roll="-15" halfExtents="6,7,10" info="sidearmR, upper beam front"/> 157 <BoxCollisionShape position="152,54,162" pitch="30" yaw="-9" roll="-15" halfExtents="6,7,12" info="sidearmR, upper beam back"/> 158 <BoxCollisionShape position="168,21,119" roll="-15" halfExtents="3,5,109" info="sidearmR, outer beam"/> 159 <BoxCollisionShape position="134,-10,169" roll="-15" halfExtents="6,4,55" info="sidearmR, lower beam front"/> 160 <BoxCollisionShape position="131,-20,217" pitch="-20" roll="-15" yaw="5" halfExtents="6,12,3" info="sidearmR, lower beam middle"/> 161 <BoxCollisionShape position="130,-29,233" roll="-15" halfExtents="6,3,15" info="sidearmR, lower beam back"/> 162 </collisionShapes> 163 </StaticEntity> 164 165 <StaticEntity name="sidearmRfront" position="0,0,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 > 166 <attached> 167 <Model mesh="HeavyCruiser_sidearmRfront.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 168 </attached> 169 <collisionShapes> 170 <BoxCollisionShape position="141,15,-53" roll="-15" halfExtents="27,44,62" info="sidearmRfront"/> 171 <BoxCollisionShape position="153,59,-30" roll="-15" halfExtents="4,2,38" info="sidearmRfront, top"/> 172 <BoxCollisionShape position="153,61,-41" roll="-15" halfExtents="4,4,11" info="sidearmRfront, top"/> 173 <BoxCollisionShape position="153,60,-65" roll="-15" halfExtents="4,3,4" info="sidearmRfront, top"/> 174 <BoxCollisionShape position="153,59,-41" roll="-15" halfExtents="8,2,11" info="sidearmRfront, top"/> 175 </collisionShapes> 176 </StaticEntity> 60 177 61 178 <!-- bay1 lights --> … … 79 196 </attached> 80 197 <collisionShapes> 81 <BoxCollisionShape position="80,33,-320" halfExtents="7,11,54" info="frontR"/>82 <BoxCollisionShape position="79,31,-399" halfExtents="3,6,26" info="frontR"/>83 84 85 <BoxCollisionShape position="-80,33,-320" halfExtents="7,11,54" info="frontL"/>86 <BoxCollisionShape position="-79,31,-399" halfExtents="3,6,26" info="frontL"/>87 88 89 <BoxCollisionShape position="94,33,-179" halfExtents="11,13,45" info="partR"/>90 <BoxCollisionShape position="96,33,-230" halfExtents="13,17,22" info="partR"/>91 92 93 <BoxCollisionShape position="-94,33,-179" halfExtents="11,13,45" info="partL"/>94 <BoxCollisionShape position="-96,33,-230" halfExtents="13,17,22" info="partL"/>95 96 97 <BoxCollisionShape position="109,47,87" halfExtents="29,8,26" info="sidearmR, upper connection"/>98 <BoxCollisionShape position="99,-1,79" roll="-15" halfExtents="40,4,9" info="sidearmR, lower connection"/>99 <BoxCollisionShape position="145,21,115" roll="-15" halfExtents="19,31,105" info="sidearmR, front"/>100 <BoxCollisionShape position="140,12,261" roll="-15" halfExtents="22,41,43" info="sidearmR, back"/>101 <BoxCollisionShape position="145,25,5" roll="-15" halfExtents="10,18,5" info="sidearmR, front break"/>102 <BoxCollisionShape position="133,-13,29" roll="-15" halfExtents="12,6,17" info="sidearmR, bottom cylinder"/>103 <BoxCollisionShape position="165,-4,31" roll="-15" halfExtents="7,21,13" info="sidearmR, box"/>104 <BoxCollisionShape position="153,59,96" roll="-15" halfExtents="6,7,60" info="sidearmR, upper beam"/>105 <BoxCollisionShape position="143,57,119" roll="-15" halfExtents="3,4,85" info="sidearmR, upper inner beam"/>106 <BoxCollisionShape position="142,53,212" pitch="21" yaw="-5" roll="-15" halfExtents="3,4,10" info="sidearmR, upper inner beam"/>107 <BoxCollisionShape position="160,52,119" roll="-15" halfExtents="3,4,85" info="sidearmR, upper outer beam"/>108 <BoxCollisionShape position="159,48,212" pitch="21" yaw="-5" roll="-15" halfExtents="3,4,10" info="sidearmR, upper outer beam"/>109 <BoxCollisionShape position="152,54,34" pitch="-46" yaw="14" roll="-15" halfExtents="6,7,10" info="sidearmR, upper beam front"/>110 <BoxCollisionShape position="152,54,162" pitch="30" yaw="-9" roll="-15" halfExtents="6,7,12" info="sidearmR, upper beam back"/>111 <BoxCollisionShape position="168,21,119" roll="-15" halfExtents="3,5,109" info="sidearmR, outer beam"/>112 <BoxCollisionShape position="134,-10,169" roll="-15" halfExtents="6,4,55" info="sidearmR, lower beam front"/>113 <BoxCollisionShape position="131,-20,217" pitch="-20" roll="-15" yaw="5" halfExtents="6,12,3" info="sidearmR, lower beam middle"/>114 <BoxCollisionShape position="130,-29,233" roll="-15" halfExtents="6,3,15" info="sidearmR, lower beam back"/>115 116 117 <BoxCollisionShape position="141,15,-53" roll="-15" halfExtents="27,44,62" info="sidearmRfront"/>118 <BoxCollisionShape position="153,59,-30" roll="-15" halfExtents="4,2,38" info="sidearmRfront, top"/>119 <BoxCollisionShape position="153,61,-41" roll="-15" halfExtents="4,4,11" info="sidearmRfront, top"/>120 <BoxCollisionShape position="153,60,-65" roll="-15" halfExtents="4,3,4" info="sidearmRfront, top"/>121 <BoxCollisionShape position="153,59,-41" roll="-15" halfExtents="8,2,11" info="sidearmRfront, top"/>122 123 124 <BoxCollisionShape position="-109,47,87" halfExtents="29,8,26" info="sidearmL, upper connection"/>125 <BoxCollisionShape position="-99,-1,79" roll="15" halfExtents="40,4,9" info="sidearmL, lower connection"/>126 <BoxCollisionShape position="-145,21,115" roll="15" halfExtents="19,31,105" info="sidearmL, front"/>127 <BoxCollisionShape position="-140,12,261" roll="15" halfExtents="22,41,43" info="sidearmL, back"/>128 <BoxCollisionShape position="-145,25,5" roll="15" halfExtents="10,18,5" info="sidearmL, front break"/>129 <BoxCollisionShape position="-133,-13,29" roll="15" halfExtents="12,6,17" info="sidearmL, bottom cylinder"/>130 <BoxCollisionShape position="-165,-4,31" roll="15" halfExtents="7,21,13" info="sidearmL, box"/>131 <BoxCollisionShape position="-153,59,96" roll="15" halfExtents="6,7,60" info="sidearmL, upper beam"/>132 <BoxCollisionShape position="-143,57,119" roll="15" halfExtents="3,4,85" info="sidearmL, upper inner beam"/>133 <BoxCollisionShape position="-142,53,212" pitch="21" yaw="5" roll="15" halfExtents="3,4,10" info="sidearmL, upper inner beam"/>134 <BoxCollisionShape position="-160,52,119" roll="15" halfExtents="3,4,85" info="sidearmL, upper outer beam"/>135 <BoxCollisionShape position="-159,48,212" pitch="21" yaw="5" roll="15" halfExtents="3,4,10" info="sidearmL, upper outer beam"/>136 <BoxCollisionShape position="-152,54,34" pitch="-46" yaw="-14" roll="15" halfExtents="6,7,10" info="sidearmL, upper beam front"/>137 <BoxCollisionShape position="-152,54,162" pitch="30" yaw="9" roll="15" halfExtents="6,7,12" info="sidearmL, upper beam back"/>138 <BoxCollisionShape position="-168,21,119" roll="15" halfExtents="3,5,109" info="sidearmL, outer beam"/>139 <BoxCollisionShape position="-134,-10,169" roll="15" halfExtents="6,4,55" info="sidearmL, lower beam front"/>140 <BoxCollisionShape position="-131,-20,217" pitch="-20" roll="15" yaw="-5" halfExtents="6,12,3" info="sidearmL, lower beam middle"/>141 <BoxCollisionShape position="-130,-29,233" roll="15" halfExtents="6,3,15" info="sidearmL, lower beam back"/>142 143 144 <BoxCollisionShape position="-141,15,-53" roll="15" halfExtents="27,44,62" info="sidearmLfront"/>145 <BoxCollisionShape position="-153,59,-30" roll="15" halfExtents="4,2,38" info="sidearmLfront, top"/>146 <BoxCollisionShape position="-153,61,-41" roll="15" halfExtents="4,4,11" info="sidearmLfront, top"/>147 <BoxCollisionShape position="-153,60,-65" roll="15" halfExtents="4,3,4" info="sidearmLfront, top"/>148 <BoxCollisionShape position="-153,59,-41" roll="15" halfExtents="8,2,11" info="sidearmLfront, top"/>149 150 151 198 <BoxCollisionShape position="60,35,-310" halfExtents="13,28,60" info="body, bay1, Rwall"/> 152 199 <BoxCollisionShape position="-60,35,-310" halfExtents="13,28,60" info="body, bay1, Lwall"/> … … 293 340 include("../includes/weaponSettingsHeavyCruiser.oxi") 294 341 ?> 295 </ SpaceShip>342 </ModularSpaceShip> 296 343 297 344 </Template> -
code/branches/modularships/src/modules/weapons/projectiles/BasicProjectile.cc
r9995 r10011 78 78 @see Pawn.h 79 79 */ 80 bool BasicProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint )80 bool BasicProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs) 81 81 { 82 82 if (!this->bDestroy_ && GameMode::isMaster()) … … 96 96 if (victim) 97 97 { 98 victim->hit(this->getShooter(), contactPoint, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());98 victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage()); 99 99 victim->startReloadCountdown(); 100 100 } … … 141 141 } 142 142 143 bool BasicProjectile::customProcessCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)144 {145 if (!this->bDestroy_ && GameMode::isMaster())146 {147 if (otherObject == this->getShooter()) // Prevents you from shooting yourself148 return false;149 150 this->bDestroy_ = true; // If something is hit, the object is destroyed and can't hit something else.151 // The projectile is destroyed by its tick()-function (in the following tick).152 153 Pawn* victim = orxonox_cast<Pawn*>(otherObject); // If otherObject isn't a Pawn, then victim is NULL154 155 WorldEntity* entity = orxonox_cast<WorldEntity*>(this);156 assert(entity); // The projectile must not be a WorldEntity.157 158 // If visual effects after destruction cause problems, put this block below the effects code block159 if (victim)160 {161 victim->customHit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());162 victim->startReloadCountdown();163 }164 165 // Visual effects for being hit, depending on whether the shield is hit or not166 if (this->getShooter()) // If the owner does not exist (anymore?), no effects are displayed.167 {168 // Damping and explosion effect is only played if the victim is no Pawn (see cast above)169 // or if the victim is a Pawn, has no shield left, is still alive and any damage goes to the health170 if (!victim || (victim && !victim->hasShield() && victim->getHealth() > 0.0f && (this->getDamage() > 0.0f || this->getHealthDamage() > 0.0f)))171 {172 {173 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());174 effect->setPosition(entity->getPosition());175 effect->setOrientation(entity->getOrientation());176 effect->setDestroyAfterLife(true);177 effect->setSource("Orxonox/explosion3");178 effect->setLifetime(2.0f);179 }180 // Second effect with same condition181 {182 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());183 effect->setPosition(entity->getPosition());184 effect->setOrientation(entity->getOrientation());185 effect->setDestroyAfterLife(true);186 effect->setSource("Orxonox/smoke4");187 effect->setLifetime(3.0f);188 }189 }190 191 // victim->isAlive() is not false until the next tick, so getHealth() > 0 is used instead192 if (victim && victim->hasShield() && (this->getDamage() > 0.0f || this->getShieldDamage() > 0.0f) && victim->getHealth() > 0.0f)193 {194 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());195 effect->setDestroyAfterLife(true);196 effect->setSource("Orxonox/Shield");197 effect->setLifetime(0.5f);198 victim->attach(effect);199 }200 }201 return true;202 }203 return false;204 }205 143 206 144 /** -
code/branches/modularships/src/modules/weapons/projectiles/BasicProjectile.h
r9995 r10011 119 119 120 120 protected: 121 bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint); 122 bool customProcessCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs); 121 bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs); 123 122 void destroyCheck(void); 124 123 -
code/branches/modularships/src/modules/weapons/projectiles/Projectile.cc
r9995 r10011 88 88 } 89 89 90 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)90 bool Projectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 91 91 { 92 return this->processCollision(otherObject, contactPoint); 93 } 94 95 bool Projectile::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 96 { 97 return this->customProcessCollision(otherObject, contactPoint, cs); 92 return this->processCollision(otherObject, contactPoint, cs); 98 93 } 99 94 -
code/branches/modularships/src/modules/weapons/projectiles/Projectile.h
r9995 r10011 64 64 65 65 virtual void tick(float dt); 66 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 67 virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 66 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 68 67 69 68 private: -
code/branches/modularships/src/modules/weapons/projectiles/Rocket.cc
r9995 r10011 191 191 } 192 192 193 bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 194 { 195 return this->processCollision(otherObject, contactPoint); 196 } 197 198 bool Rocket::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 199 { 200 return this->customProcessCollision(otherObject, contactPoint, cs); 193 bool Rocket::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 194 { 195 return this->processCollision(otherObject, contactPoint, cs); 201 196 } 202 197 -
code/branches/modularships/src/modules/weapons/projectiles/Rocket.h
r9995 r10011 64 64 virtual void tick(float dt); //!< Defines which actions the Rocket has to take in each tick. 65 65 66 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 67 virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 66 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 68 67 virtual void destroyObject(void); 69 68 void destructionEffect(); -
code/branches/modularships/src/modules/weapons/projectiles/SimpleRocket.cc
r9995 r10011 172 172 } 173 173 174 bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 175 { 176 return this->processCollision(otherObject, contactPoint); 177 } 178 179 bool SimpleRocket::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 180 { 181 return this->customProcessCollision(otherObject, contactPoint, cs); 174 bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 175 { 176 return this->processCollision(otherObject, contactPoint, cs); 182 177 } 183 178 -
code/branches/modularships/src/modules/weapons/projectiles/SimpleRocket.h
r9995 r10011 64 64 virtual void tick(float dt); 65 65 66 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 67 virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 66 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 68 67 69 68 void disableFire(); //!< Method to disable the fire and stop all acceleration -
code/branches/modularships/src/orxonox/CMakeLists.txt
r9348 r10011 32 32 PlayerManager.cc 33 33 Radar.cc 34 ShipPart.cc 34 35 # Test.cc 35 36 -
code/branches/modularships/src/orxonox/Scene.cc
r9996 r10011 201 201 // Note: This is a global variable which we assign a static function. 202 202 // TODO: Check whether this (or anything about Bullet) works with multiple physics engine instances. 203 gContactAddedCallback = &Scene::c ustomCollisionCallback;203 gContactAddedCallback = &Scene::collisionCallback; 204 204 } 205 205 else if (!wantPhysics && hasPhysics()) … … 349 349 SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer()); 350 350 351 // get the CollisionShape pointers 352 const btCollisionShape* cs0 = colObj0->getCollisionShape(); 353 const btCollisionShape* cs1 = colObj1->getCollisionShape(); 354 351 355 // false means that bullet will assume we didn't modify the contact 352 356 bool modified = false; 353 357 if (object0->isCollisionCallbackActive()) 354 modified |= object0->collidesAgainst(object1, c p);358 modified |= object0->collidesAgainst(object1, cs1, cp); 355 359 if (object1->isCollisionCallbackActive()) 356 modified |= object1->collidesAgainst(object0, c p);360 modified |= object1->collidesAgainst(object0, cs0, cp); 357 361 358 362 return modified; 359 363 } 360 361 /* ADDED static*/ bool Scene::customCollisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,362 int index0, const btCollisionObject* colObj1, int partId1, int index1)363 {364 // get the WorldEntity pointers365 SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());366 SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());367 368 // get the CollisionShape pointers369 const btCollisionShape* cs0 = colObj0->getCollisionShape();370 const btCollisionShape* cs1 = colObj1->getCollisionShape();371 372 // false means that bullet will assume we didn't modify the contact373 bool modified = false;374 if (object0->isCollisionCallbackActive())375 modified |= object0->customCollidesAgainst(object1, cs1, cp);376 if (object1->isCollisionCallbackActive())377 modified |= object1->customCollidesAgainst(object0, cs0, cp);378 379 return modified;380 }381 364 } -
code/branches/modularships/src/orxonox/ShipPart.cc
r10007 r10011 35 35 #include "core/XMLPort.h" 36 36 #include "network/NetworkFunction.h" 37 #include "items/Item.h" 38 #include "worldentities/pawns/Pawn.h" 39 #include "gametypes/Gametype.h" 40 #include "worldentities/pawns/ModularSpaceShip.h" 37 41 38 42 … … 42 46 43 47 ShipPart::ShipPart(Context* context) 48 : Item(context) 44 49 { 45 //RegisterObject(ShipPart);50 RegisterObject(ShipPart); 46 51 } 47 52 … … 51 56 } 52 57 58 59 /** 60 @brief 61 Add a StaticEntity to the ShipPart. 62 @param engine 63 A pointer to the StaticEntity to be added. 64 */ 65 void ShipPart::addEntity(StaticEntity* entity) 66 { 67 OrxAssert(entity != NULL, "The Entity cannot be NULL."); 68 this->entityList_.push_back(entity); 69 //part->addToSpaceShip(this); //FIXME: (noep) add 70 } 71 72 /** 73 @brief 74 Get the i-th StaticEntity of the ShipPart. 75 @return 76 Returns a pointer to the i-the StaticEntity. NULL if there is no StaticEntity with that index. 77 */ 78 StaticEntity* ShipPart::getEntity(unsigned int index) 79 { 80 if(this->entityList_.size() >= index) 81 return NULL; 82 else 83 return this->entityList_[index]; 84 } 85 86 void ShipPart::setDamageAbsorption(float value) 87 { 88 this->damageAbsorption_ = value; 89 } 90 91 /** 92 @brief 93 Sets the health of the ShipPart. 94 */ 95 void ShipPart::setHealth(float health) 96 { 97 this->health_ = health; 98 } 99 100 /** 101 @brief 102 Handles a received hit. 103 */ 104 void ShipPart::handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator) 105 { 106 if (parent_->getGametype() && parent_->getGametype()->allowPawnDamage(parent_, originator)) 107 { 108 if (shielddamage >= parent_->getShieldHealth()) 109 { 110 parent_->setShieldHealth(0); 111 this->setHealth(this->health_ - (healthdamage + damage) * this->damageAbsorption_); 112 parent_->setHealth(parent_->getHealth() - (healthdamage + damage) * (1 - this->damageAbsorption_)); 113 } 114 else 115 { 116 parent_->setShieldHealth(parent_->getShieldHealth() - shielddamage); 117 118 // remove remaining shieldAbsorpton-Part of damage from shield 119 shielddamage = damage * parent_->getShieldAbsorption(); 120 shielddamage = std::min(parent_->getShieldHealth(),shielddamage); 121 parent_->setShieldHealth(parent_->getShieldHealth() - shielddamage); 122 123 // set remaining damage to health 124 this->setHealth(this->health_ - ((damage - shielddamage) - healthdamage) * this->damageAbsorption_); 125 parent_->setHealth(parent_->getHealth() - ((damage - shielddamage) - healthdamage) * (1- this->damageAbsorption_)); 126 } 127 } 128 } 129 130 131 /** 132 @brief 133 Adds the ShipPart to the input SpaceShip. 134 @param ship 135 A pointer to the SpaceShip to which the ShipPart is added. 136 */ 137 /*void ShipPart::addToSpaceShip(ModularSpaceShip* ship) 138 { 139 this->parent_ = ship; 140 141 if (ship) 142 { 143 this->parentID_ = ship->getObjectID(); 144 if (!ship->hasShipPart(this)) 145 ship->addShipPart(this); 146 } 147 }*/ 148 53 149 } -
code/branches/modularships/src/orxonox/ShipPart.h
r10007 r10011 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include "items/Item.h" 33 34 34 35 #include <string> … … 38 39 { // tolua_export 39 40 class _OrxonoxExport ShipPart // tolua_export 41 : public Item 40 42 { // tolua_export 41 43 … … 44 46 virtual ~ShipPart(); 45 47 48 //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 50 virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator); 51 52 //virtual void attachTo(Pawn* newParent); 53 //virtual void detach(); 54 55 void addEntity(StaticEntity* entity); 56 StaticEntity* getEntity(unsigned int index); 57 58 virtual void setDamageAbsorption(float value); 59 inline float getDamageAbsorption() 60 { return this->damageAbsorption_; } 61 62 virtual void setHealth(float health); 63 inline void addHealth(float health) 64 { this->setHealth(this->health_ + health); } 65 inline void removeHealth(float health) 66 { this->setHealth(this->health_ - health); } 67 inline float getHealth() const 68 { return this->health_; } 69 70 // FIXME: (noep) Why doesn't this work? Works fine in Engine.h 71 //void addToSpaceShip(ModularSpaceShip* ship); 72 46 73 protected: 74 Pawn* parent_; 75 unsigned int parentID_; // Object ID of the SpaceShip the Part is mounted on. 47 76 77 float damageAbsorption_; 78 float health_; 48 79 49 80 private: 50 81 std::vector<StaticEntity*> entityList_; // list of all entities which belong to this part 51 82 52 83 }; // tolua_export -
code/branches/modularships/src/orxonox/worldentities/MovableEntity.cc
r9995 r10011 72 72 } 73 73 74 bool MovableEntity::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)74 bool MovableEntity::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 75 75 { 76 76 if (GameMode::isMaster() && enableCollisionDamage_) … … 80 80 { 81 81 float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length(); 82 victim->hit(0, contactPoint, damage);82 victim->hit(0, contactPoint, ownCollisionShape, damage); 83 83 } 84 84 } … … 86 86 return false; 87 87 } 88 89 bool MovableEntity::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)90 {91 if (GameMode::isMaster() && enableCollisionDamage_)92 {93 Pawn* victim = orxonox_cast<Pawn*>(otherObject);94 if (victim)95 {96 float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length();97 victim->customHit(0, contactPoint, ownCollisionShape, damage);98 }99 }100 101 return false;102 }103 104 88 105 89 void MovableEntity::registerVariables() -
code/branches/modularships/src/orxonox/worldentities/MovableEntity.h
r9995 r10011 47 47 48 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 50 virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 49 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 51 50 52 51 using WorldEntity::setPosition; -
code/branches/modularships/src/orxonox/worldentities/WorldEntity.h
r9997 r10011 374 374 Condition is that enableCollisionCallback() was called. 375 375 */ 376 virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 377 { return false; } /* With false, Bullet assumes no modification to the collision objects. */ 378 379 virtual inline bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 376 virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 380 377 { return false; } /* With false, Bullet assumes no modification to the collision objects. */ 381 378 -
code/branches/modularships/src/orxonox/worldentities/pawns/CMakeLists.txt
r7163 r10011 4 4 Pawn.cc 5 5 SpaceShip.cc 6 ModularSpaceShip.cc 6 7 TeamBaseMatchBase.cc 7 8 Destroyer.cc -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc
r10007 r10011 250 250 } 251 251 252 void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator) 253 { 252 void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) 253 { 254 orxout() << "damage(): Collision detected on " << this->getName() << ", btCS*: " << cs << endl; 255 256 int collisionShapeIndex = this->isMyCollisionShape(cs); 257 orxout() << collisionShapeIndex << endl; 258 254 259 // Applies multiplier given by the DamageBoost Pickup. 255 260 if (originator) … … 280 285 } 281 286 282 void Pawn::customDamage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)283 {284 orxout() << "damage(): Collision detected on " << this->getRadarName() << ", btCS*: " << cs << endl;285 286 int collisionShapeIndex = this->isMyCollisionShape(cs);287 orxout() << collisionShapeIndex << endl;288 289 // Applies multiplier given by the DamageBoost Pickup.290 if (originator)291 damage *= originator->getDamageMultiplier();292 293 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))294 {295 if (shielddamage >= this->getShieldHealth())296 {297 this->setShieldHealth(0);298 this->setHealth(this->health_ - (healthdamage + damage));299 }300 else301 {302 this->setShieldHealth(this->shieldHealth_ - shielddamage);303 304 // remove remaining shieldAbsorpton-Part of damage from shield305 shielddamage = damage * this->shieldAbsorption_;306 shielddamage = std::min(this->getShieldHealth(),shielddamage);307 this->setShieldHealth(this->shieldHealth_ - shielddamage);308 309 // set remaining damage to health310 this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);311 }312 313 this->lastHitOriginator_ = originator;314 }315 }316 317 287 // TODO: Still valid? 318 288 /* HIT-Funktionen … … 320 290 321 291 */ 322 void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage)292 void Pawn::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 323 293 { 324 294 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 325 295 { 326 this->damage(damage, healthdamage, shielddamage, originator );296 this->damage(damage, healthdamage, shielddamage, originator, cs); 327 297 this->setVelocity(this->getVelocity() + force); 328 298 } 329 299 } 330 300 331 void Pawn:: customHit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)301 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 332 302 { 333 303 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 334 304 { 335 this->customDamage(damage, healthdamage, shielddamage, originator, cs); 336 this->setVelocity(this->getVelocity() + force); 337 } 338 } 339 340 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) 341 { 342 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 343 { 344 this->damage(damage, healthdamage, shielddamage, originator); 345 346 if ( this->getController() ) 347 this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage? 348 } 349 } 350 351 void Pawn::customHit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 352 { 353 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 354 { 355 this->customDamage(damage, healthdamage, shielddamage, originator, cs); 305 this->damage(damage, healthdamage, shielddamage, originator, cs); 356 306 357 307 if ( this->getController() ) … … 620 570 } 621 571 622 // WIP function that (once I get it working) determines to which attached entity a collisionshape belongs. 623 // Shame that this doesn't seem to work as intended. It behaves differently (different number of childshapes) every reload. D: 572 624 573 int Pawn::isMyCollisionShape(const btCollisionShape* cs) 625 574 { … … 628 577 629 578 // e.g. "Box 4: Searching for CS 0x1ad49200" 630 orxout() << this->get RadarName() << ": Searching for btCS* " << cs << endl;579 orxout() << this->getName() << ": Searching for btCS* " << cs << endl; 631 580 // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060" 632 orxout() << " " << this->get RadarName() << " is WorldEntityCollisionShape* " << ownWECS << endl;581 orxout() << " " << this->getName() << " is WorldEntityCollisionShape* " << ownWECS << endl; 633 582 // e.g. "Box 4 is WorldEntity 0x126dd060" 634 orxout() << " " << this->get RadarName() << " is WorldEntity* " << this << endl;583 orxout() << " " << this->getName() << " is WorldEntity* " << this << endl; 635 584 // e.g. "Box 4 is objectID 943" 636 orxout() << " " << this->get RadarName() << " is objectID " << this->getObjectID() << endl;585 orxout() << " " << this->getName() << " is objectID " << this->getObjectID() << endl; 637 586 638 587 // List all attached Objects 639 orxout() << " " << this->get RadarName() << " has the following Objects attached:" << endl;588 orxout() << " " << this->getName() << " has the following Objects attached:" << endl; 640 589 for (int i=0; i<10; i++) 641 590 { 642 591 if (this->getAttachedObject(i)==NULL) 643 592 break; 644 orxout() << " " << i << ": " << this->getAttachedObject(i) ;593 orxout() << " " << i << ": " << this->getAttachedObject(i) << " (" << this->getAttachedObject(i)->getName() << ")"; 645 594 if(!orxonox_cast<Model*>(this->getAttachedObject(i))) 646 595 orxout() << " (SE)"; … … 648 597 } 649 598 650 if (this->health_ < 800)651 this->detach(this->getAttachedObject(2));652 599 653 600 // print child shapes of this WECS … … 656 603 int temp = entityOfCollisionShape(cs); 657 604 if (temp==0) 658 orxout() << this->get RadarName() << " has been hit on it's main body." << endl;659 else 660 orxout() << this->get RadarName() << " has been hit on the attached entity no. " << temp << endl;605 orxout() << this->getName() << " has been hit on it's main body." << endl; 606 else 607 orxout() << this->getName() << " has been hit on the attached entity no. " << temp << endl; 661 608 662 609 // end … … 680 627 681 628 // pointer to the btCollisionShape 682 printSpaces(indent+2); orxout() << "m_userPointer*: " << cs->getChildShape(i)->getUserPointer() << endl;629 printSpaces(indent+2); orxout() << "m_userPointer*: " << cs->getChildShape(i)->getUserPointer() << " (name_: " << ((BaseObject*)(cs->getChildShape(i)->getUserPointer()))->getName() << ")" << endl; 683 630 } 684 631 -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h
r10007 r10011 126 126 //virtual void hit(Pawn* originator, const Vector3& force, float damage); 127 127 //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 128 virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 129 virtual void customHit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 130 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 131 virtual void customHit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 128 virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 129 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 132 130 133 131 virtual void kill(); … … 198 196 199 197 //virtual void damage(float damage, Pawn* originator = 0); 200 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL); 201 virtual void customDamage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL); 198 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL); 202 199 203 200 bool bAlive_;
Note: See TracChangeset
for help on using the changeset viewer.