Changeset 6417 for code/trunk/src/orxonox/worldentities
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 14 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/worldentities/CMakeLists.txt
r5781 r6417 7 7 8 8 BigExplosion.cc 9 EffectContainer.cc 9 10 ExplosionChunk.cc 10 11 CameraPosition.cc -
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
r5929 r6417 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/trunk/src/orxonox/worldentities/ControllableEntity.h
r5929 r6417 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/trunk/src/orxonox/worldentities/MovableEntity.cc
r5929 r6417 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/trunk/src/orxonox/worldentities/MovableEntity.h
r5929 r6417 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/trunk/src/orxonox/worldentities/StaticEntity.cc
r5781 r6417 42 42 { 43 43 RegisterObject(StaticEntity); 44 44 45 45 this->setPriority(Priority::VeryLow); 46 46 -
code/trunk/src/orxonox/worldentities/WorldEntity.cc
r5929 r6417 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/trunk/src/orxonox/worldentities/WorldEntity.h
r5781 r6417 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/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r5929 r6417 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 this->getPickups().setOwner(this); … … 110 111 XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode); 111 112 XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); 112 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack , getWeaponPack, xmlelement, mode);113 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode); 113 114 } 114 115 … … 119 120 registerVariable(this->initialHealth_, VariableDirection::ToClient); 120 121 registerVariable(this->bReload_, VariableDirection::ToServer); 122 registerVariable(this->aimPosition_, Bidirectionality::ServerMaster, 0, true); 121 123 } 122 124 … … 166 168 void Pawn::hit(Pawn* originator, const Vector3& force, float damage) 167 169 { 168 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) )170 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 169 171 { 170 172 this->damage(damage, originator); … … 175 177 } 176 178 179 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 180 { 181 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 182 { 183 this->damage(damage, originator); 184 185 if ( this->getController() ) 186 this->getController()->hit(originator, contactpoint, damage); 187 188 // play hit effect 189 } 190 } 191 177 192 void Pawn::kill() 178 193 { … … 184 199 { 185 200 // play spawn effect 186 if ( this->spawnparticlesource_ != "")201 if (!this->spawnparticlesource_.empty()) 187 202 { 188 203 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); … … 263 278 } 264 279 265 void Pawn::fire(unsigned int firemode) 266 { 267 this->doFire(firemode); 268 } 269 270 void Pawn::doFire(uint8_t firemode) 271 { 272 if(GameMode::isMaster()) 273 { 274 if (this->weaponSystem_) 275 this->weaponSystem_->fire(firemode); 276 } 277 else 278 { 279 callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode); 280 if (this->weaponSystem_) 281 this->weaponSystem_->fire(firemode); 282 } 280 void Pawn::fired(unsigned int firemode) 281 { 282 if (this->weaponSystem_) 283 this->weaponSystem_->fire(firemode); 283 284 } 284 285 … … 341 342 } 342 343 344 void Pawn::addWeaponPackXML(WeaponPack * wPack) 345 { 346 if (this->weaponSystem_) 347 if (!this->weaponSystem_->addWeaponPack(wPack)) 348 wPack->destroy(); 349 } 350 343 351 WeaponPack * Pawn::getWeaponPack(unsigned int index) const 344 352 { -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r5781 r6417 75 75 { return this->lastHitOriginator_; } 76 76 77 virtual void damage(float damage, Pawn* originator = 0);78 77 virtual void hit(Pawn* originator, const Vector3& force, float damage); 78 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 79 79 virtual void kill(); 80 80 81 virtual void fire (unsigned int firemode);81 virtual void fired(unsigned int firemode); 82 82 virtual void reload(); 83 virtual void doFire(uint8_t firemode);84 83 virtual void postSpawn(); 85 84 … … 89 88 WeaponSet * getWeaponSet(unsigned int index) const; 90 89 void addWeaponPack(WeaponPack * wPack); 90 void addWeaponPackXML(WeaponPack * wPack); 91 91 WeaponPack * getWeaponPack(unsigned int index) const; 92 92 … … 117 117 virtual void startLocalHumanControl(); 118 118 119 void setAimPosition( Vector3 position ) 120 { this->aimPosition_ = position; } 121 Vector3 getAimPosition() 122 { return this->aimPosition_; } 123 119 124 protected: 120 125 virtual void setPlayer(PlayerInfo* player); … … 125 130 virtual void deatheffect(); 126 131 virtual void spawneffect(); 132 133 virtual void damage(float damage, Pawn* originator = 0); 127 134 128 135 bool bAlive_; … … 146 153 inline void setWeaponSystem(WeaponSystem* weaponsystem) 147 154 { this->weaponSystem_ = weaponsystem; } 155 156 Vector3 aimPosition_; 148 157 }; 149 158 } -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r5929 r6417 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/trunk/src/orxonox/worldentities/pawns/Spectator.cc
r5929 r6417 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/trunk/src/orxonox/worldentities/pawns/Spectator.h
r5781 r6417 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.