Changeset 6412 for code/branches/pickup2/src/orxonox/worldentities
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 14 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/orxonox/worldentities/CMakeLists.txt
r5781 r6412 7 7 8 8 BigExplosion.cc 9 EffectContainer.cc 9 10 ExplosionChunk.cc 10 11 CameraPosition.cc -
code/branches/pickup2/src/orxonox/worldentities/ControllableEntity.cc
r5929 r6412 36 36 #include "core/GameMode.h" 37 37 #include "core/XMLPort.h" 38 #include "network/NetworkFunction.h" 38 39 39 40 #include "Scene.h" … … 47 48 { 48 49 CreateFactory(ControllableEntity); 50 51 registerMemberNetworkFunction( ControllableEntity, fire ); 52 registerMemberNetworkFunction( ControllableEntity, setTargetInternal ); 49 53 50 54 ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator) … … 62 66 this->camera_ = 0; 63 67 this->xmlcontroller_ = 0; 68 this->controller_ = 0; 64 69 this->reverseCamera_ = 0; 65 70 this->bDestroyWhenPlayerLeft_ = false; 66 71 this->cameraPositionRootNode_ = this->node_->createChildSceneNode(); 72 this->currentCameraPosition_ = 0; 67 73 this->bMouseLook_ = false; 68 74 this->mouseLookSpeed_ = 200; … … 169 175 { 170 176 this->cameraPositions_.front()->attachCamera(this->camera_); 177 this->currentCameraPosition_ = this->cameraPositions_.front().get(); 171 178 } 172 179 else if (this->cameraPositions_.size() > 0) … … 178 185 ++it; 179 186 if (it != this->cameraPositions_.end()) 187 { 180 188 (*it)->attachCamera(this->camera_); 189 this->currentCameraPosition_ = *it; 190 } 181 191 else 192 { 182 193 (*this->cameraPositions_.begin())->attachCamera(this->camera_); 194 this->currentCameraPosition_ = *this->cameraPositions_.begin(); 195 } 183 196 break; 184 197 } … … 188 201 { 189 202 this->camera_->attachToNode(this->cameraPositionRootNode_); 203 this->currentCameraPosition_ = 0; 190 204 } 191 205 } … … 198 212 if (!this->bMouseLook_) 199 213 this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY); 214 if (this->getCamera()) 215 { 216 if (!this->bMouseLook_&& this->currentCameraPosition_->getDrag()) 217 this->getCamera()->setDrag(true); 218 else 219 this->getCamera()->setDrag(false); 220 } 200 221 } 201 222 … … 216 237 if (this->bMouseLook_) 217 238 this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 239 } 240 241 void ControllableEntity::fire(unsigned int firemode) 242 { 243 if(GameMode::isMaster()) 244 { 245 this->fired(firemode); 246 } 247 else 248 { 249 callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode); 250 } 251 } 252 253 void ControllableEntity::setTarget( WorldEntity* target ) 254 { 255 this->target_ = target; 256 if ( !GameMode::isMaster() ) 257 { 258 if ( target != 0 ) 259 { 260 callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, target->getObjectID() ); 261 } 262 else 263 { 264 callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN ); 265 } 266 } 267 } 268 269 void ControllableEntity::setTargetInternal( uint32_t targetID ) 270 { 271 this->setTarget( orxonox_cast<WorldEntity*>(Synchronisable::getSynchronisable(targetID)) ); 218 272 } 219 273 … … 279 333 this->camera_ = new Camera(this); 280 334 this->camera_->requestFocus(); 281 if ( this->cameraPositionTemplate_ != "")335 if (!this->cameraPositionTemplate_.empty()) 282 336 this->addTemplate(this->cameraPositionTemplate_); 283 337 if (this->cameraPositions_.size() > 0) 338 { 284 339 this->cameraPositions_.front()->attachCamera(this->camera_); 340 this->currentCameraPosition_ = this->cameraPositions_.front(); 341 } 285 342 else 343 { 286 344 this->camera_->attachToNode(this->cameraPositionRootNode_); 345 this->currentCameraPosition_ = 0; 346 } 287 347 } 288 348 289 349 if (!this->hud_ && GameMode::showsGraphics()) 290 350 { 291 if ( this->hudtemplate_ != "")351 if (!this->hudtemplate_.empty()) 292 352 { 293 353 this->hud_ = new OverlayGroup(this); -
code/branches/pickup2/src/orxonox/worldentities/ControllableEntity.h
r5929 r6412 84 84 { this->rotateRoll(Vector2(value, 0)); } 85 85 86 virtual void fire(unsigned int firemode) {} 86 void fire(unsigned int firemode); 87 virtual void fired(unsigned int firemode) {} 87 88 virtual void reload() {} 88 89 … … 139 140 inline Controller* getXMLController() const 140 141 { return this->xmlcontroller_; } 142 143 inline Controller* getController() const 144 { return this->controller_; } 145 inline void setController(Controller* val) 146 { this->controller_ = val; } 147 148 virtual void setTarget( WorldEntity* target ); 149 virtual WorldEntity* getTarget() 150 { return this->target_.get(); } 151 void setTargetInternal( uint32_t targetID ); 141 152 142 153 protected: … … 199 210 Ogre::SceneNode* cameraPositionRootNode_; 200 211 std::list<SmartPtr<CameraPosition> > cameraPositions_; 212 CameraPosition* currentCameraPosition_; 201 213 std::string cameraPositionTemplate_; 202 214 Controller* xmlcontroller_; 215 Controller* controller_; 203 216 CameraPosition* reverseCamera_; 217 WeakPtr<WorldEntity> target_; 204 218 }; 205 219 } -
code/branches/pickup2/src/orxonox/worldentities/MovableEntity.cc
r5929 r6412 79 79 if (victim) 80 80 { 81 victim->damage(this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length()); 81 float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length(); 82 victim->hit(0, contactPoint, damage); 82 83 } 83 84 } -
code/branches/pickup2/src/orxonox/worldentities/MovableEntity.h
r5929 r6412 70 70 71 71 inline void setEnableCollisionDamage(bool c) 72 { 73 this->enableCollisionDamage_ = c; 72 { 73 this->enableCollisionDamage_ = c; 74 74 this->enableCollisionCallback(); 75 } 75 } 76 76 77 77 inline bool getEnableCollisionDamage() -
code/branches/pickup2/src/orxonox/worldentities/StaticEntity.cc
r5781 r6412 42 42 { 43 43 RegisterObject(StaticEntity); 44 44 45 45 this->setPriority(Priority::VeryLow); 46 46 -
code/branches/pickup2/src/orxonox/worldentities/WorldEntity.cc
r5929 r6412 472 472 //! Attaches an Ogre::MovableObject to this WorldEntity. 473 473 void WorldEntity::attachOgreObject(Ogre::MovableObject* object) 474 { this->node_->attachObject(object); } 474 { 475 this->node_->attachObject(object); 476 object->setUserObject(this); 477 } 478 475 479 void WorldEntity::attachOgreObject(Ogre::BillboardSet* object) 476 { this-> node_->attachObject(object); }480 { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); } 477 481 void WorldEntity::attachOgreObject(Ogre::Camera* object) 478 { this-> node_->attachObject(object); }482 { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); } 479 483 void WorldEntity::attachOgreObject(Ogre::Entity* object) 480 { this-> node_->attachObject(object); }484 { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); } 481 485 void WorldEntity::attachOgreObject(Ogre::ParticleSystem* object) 482 { this-> node_->attachObject(object); }486 { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); } 483 487 484 488 //! Detaches an Ogre::MovableObject from this WorldEntity. 485 489 void WorldEntity::detachOgreObject(Ogre::MovableObject* object) 486 { this->node_->detachObject(object); } 490 { 491 object->setUserObject(NULL); 492 this->node_->detachObject(object); 493 } 494 487 495 void WorldEntity::detachOgreObject(Ogre::BillboardSet* object) 488 { this-> node_->detachObject(object); }496 { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); } 489 497 void WorldEntity::detachOgreObject(Ogre::Camera* object) 490 { this-> node_->detachObject(object); }498 { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); } 491 499 void WorldEntity::detachOgreObject(Ogre::Entity* object) 492 { this-> node_->detachObject(object); }500 { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); } 493 501 void WorldEntity::detachOgreObject(Ogre::ParticleSystem* object) 494 { this-> node_->detachObject(object); }502 { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); } 495 503 496 504 //! Detaches an Ogre::MovableObject (by string) from this WorldEntity. … … 646 654 /** 647 655 @brief 648 Makes this WorldEntity look a specific target location.656 Makes this WorldEntity look at a specific target location. 649 657 @param relativeTo 650 658 @see WorldEntity::TransformSpace … … 806 814 void WorldEntity::setCollisionTypeStr(const std::string& typeStr) 807 815 { 808 std::stringtypeStrLower = getLowercase(typeStr);816 const std::string& typeStrLower = getLowercase(typeStr); 809 817 CollisionType type; 810 818 if (typeStrLower == "dynamic") … … 913 921 } 914 922 915 //! Copies our own parameters for restitution, angular factor, damping sand friction to the bullet rigid body.923 //! Copies our own parameters for restitution, angular factor, damping and friction to the bullet rigid body. 916 924 void WorldEntity::internalSetPhysicsProps() 917 925 { -
code/branches/pickup2/src/orxonox/worldentities/WorldEntity.h
r5781 r6412 33 33 #include "OrxonoxPrereqs.h" 34 34 35 #include <OgreUserDefinedObject.h> 35 36 #ifdef ORXONOX_RELEASE 36 37 # include <OgreSceneNode.h> … … 55 56 56 57 The basic task of the WorldEntity is provide a location, a direction and a scaling and the possibility 57 to create an entire hierarchy of deriv ated objects.58 to create an entire hierarchy of derived objects. 58 59 It is also the basis for the physics interface to the Bullet physics engine. 59 60 Every WorldEntity can have a specific collision type: @see CollisionType … … 63 64 There is also support for attaching WorldEntities with physics to each other. Currently, the collision shape 64 65 of both objects simply get merged into one larger shape (for static collision type). 65 The phy iscal body that is internally stored and administrated has the following supported properties:66 - Restitution, angular factor, linear damping, angular damping, fric ition, mass and collision shape.66 The physical body that is internally stored and administrated has the following supported properties: 67 - Restitution, angular factor, linear damping, angular damping, friction, mass and collision shape. 67 68 You can get more information at the corresponding set function. 68 69 69 70 Collision shapes: These are controlled by the internal WorldEntityCollisionShape. @see WorldEntityCollisionShape. 70 71 */ 71 class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState 72 class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState, public Ogre::UserDefinedObject 72 73 { 73 74 friend class Scene; … … 318 319 Sets an artificial parameter that tells how much torque is applied when you apply a non-central force. 319 320 320 Normally the angular factor is 1, which means it's physically 'correct'. Howe rver if you have a player321 Normally the angular factor is 1, which means it's physically 'correct'. However if you have a player 321 322 character that should not rotate when hit sideways, you can set the angular factor to 0. 322 323 */ … … 394 395 You can override this function in a derived class to constrain the collision to e.g. None or Dynamic. 395 396 A projectile may not prove very useful if there is no physical body. Simply set the CollisionType 396 in its constructor and override this method. But be careful that a derived class e's virtual functions397 in its constructor and override this method. But be careful that a derived class's virtual functions 397 398 don't yet exist in the constructor if a base class. 398 399 */ -
code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.cc
r6405 r6412 38 38 #include "PawnManager.h" 39 39 #include "infos/PlayerInfo.h" 40 #include "controllers/Controller.h" 40 41 #include "gametypes/Gametype.h" 41 42 #include "graphics/ParticleSpawner.h" … … 52 53 CreateFactory(Pawn); 53 54 54 registerMemberNetworkFunction( Pawn, doFire );55 56 55 Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator) 57 56 { … … 69 68 70 69 this->spawnparticleduration_ = 3.0f; 70 71 this->aimPosition_ = Vector3::ZERO; 71 72 72 73 //TODO: Remove. … … 111 112 XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode); 112 113 XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); 113 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack , getWeaponPack, xmlelement, mode);114 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode); 114 115 } 115 116 … … 120 121 registerVariable(this->initialHealth_, VariableDirection::ToClient); 121 122 registerVariable(this->bReload_, VariableDirection::ToServer); 123 registerVariable(this->aimPosition_, Bidirectionality::ServerMaster, 0, true); 122 124 } 123 125 … … 167 169 void Pawn::hit(Pawn* originator, const Vector3& force, float damage) 168 170 { 169 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) )171 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 170 172 { 171 173 this->damage(damage, originator); … … 176 178 } 177 179 180 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 181 { 182 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 183 { 184 this->damage(damage, originator); 185 186 if ( this->getController() ) 187 this->getController()->hit(originator, contactpoint, damage); 188 189 // play hit effect 190 } 191 } 192 178 193 void Pawn::kill() 179 194 { … … 185 200 { 186 201 // play spawn effect 187 if ( this->spawnparticlesource_ != "")202 if (!this->spawnparticlesource_.empty()) 188 203 { 189 204 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); … … 264 279 } 265 280 266 void Pawn::fire(unsigned int firemode) 267 { 268 this->doFire(firemode); 269 } 270 271 void Pawn::doFire(uint8_t firemode) 272 { 273 if(GameMode::isMaster()) 274 { 275 if (this->weaponSystem_) 276 this->weaponSystem_->fire(firemode); 277 } 278 else 279 { 280 callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode); 281 if (this->weaponSystem_) 282 this->weaponSystem_->fire(firemode); 283 } 281 void Pawn::fired(unsigned int firemode) 282 { 283 if (this->weaponSystem_) 284 this->weaponSystem_->fire(firemode); 284 285 } 285 286 … … 343 344 } 344 345 346 void Pawn::addWeaponPackXML(WeaponPack * wPack) 347 { 348 if (this->weaponSystem_) 349 if (!this->weaponSystem_->addWeaponPack(wPack)) 350 wPack->destroy(); 351 } 352 345 353 WeaponPack * Pawn::getWeaponPack(unsigned int index) const 346 354 { -
code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.h
r6405 r6412 76 76 { return this->lastHitOriginator_; } 77 77 78 virtual void damage(float damage, Pawn* originator = 0);79 78 virtual void hit(Pawn* originator, const Vector3& force, float damage); 79 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 80 80 virtual void kill(); 81 81 82 virtual void fire (unsigned int firemode);82 virtual void fired(unsigned int firemode); 83 83 virtual void reload(); 84 virtual void doFire(uint8_t firemode);85 84 virtual void postSpawn(); 86 85 … … 90 89 WeaponSet * getWeaponSet(unsigned int index) const; 91 90 void addWeaponPack(WeaponPack * wPack); 91 void addWeaponPackXML(WeaponPack * wPack); 92 92 WeaponPack * getWeaponPack(unsigned int index) const; 93 93 … … 119 119 virtual void startLocalHumanControl(); 120 120 121 void setAimPosition( Vector3 position ) 122 { this->aimPosition_ = position; } 123 Vector3 getAimPosition() 124 { return this->aimPosition_; } 125 121 126 protected: 122 127 virtual void setPlayer(PlayerInfo* player); … … 127 132 virtual void deatheffect(); 128 133 virtual void spawneffect(); 134 135 virtual void damage(float damage, Pawn* originator = 0); 129 136 130 137 bool bAlive_; … … 149 156 inline void setWeaponSystem(WeaponSystem* weaponsystem) 150 157 { this->weaponSystem_ = weaponsystem; } 158 159 Vector3 aimPosition_; 151 160 }; 152 161 } -
code/branches/pickup2/src/orxonox/worldentities/pawns/SpaceShip.cc
r5929 r6412 187 187 void SpaceShip::loadEngineTemplate() 188 188 { 189 if ( this->enginetemplate_ != "")189 if (!this->enginetemplate_.empty()) 190 190 { 191 191 Template* temp = Template::getTemplate(this->enginetemplate_); -
code/branches/pickup2/src/orxonox/worldentities/pawns/Spectator.cc
r5929 r6412 189 189 } 190 190 191 void Spectator::fire (unsigned int firemode)191 void Spectator::fired(unsigned int firemode) 192 192 { 193 193 if (this->getPlayer()) -
code/branches/pickup2/src/orxonox/worldentities/pawns/Spectator.h
r5781 r6412 55 55 virtual void rotateRoll(const Vector2& value); 56 56 57 virtual void fire (unsigned int firemode);57 virtual void fired(unsigned int firemode); 58 58 virtual void greet(); 59 59
Note: See TracChangeset
for help on using the changeset viewer.