Changeset 7163 for code/trunk/src/modules/objects
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/objects/CMakeLists.txt
r5781 r7163 15 15 PCH_FILE 16 16 ObjectsPrecompiledHeaders.h 17 DEFINE_SYMBOL18 "OBJECTS_SHARED_BUILD"19 17 LINK_LIBRARIES 20 18 orxonox -
code/trunk/src/modules/objects/ObjectsPrereqs.h
r6906 r7163 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(O RXONOX_STATIC_BUILD)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(OBJECTS_STATIC_BUILD) 46 46 # ifdef OBJECTS_SHARED_BUILD 47 47 # define _ObjectsExport __declspec(dllexport) -
code/trunk/src/modules/objects/Planet.cc
r6501 r7163 70 70 { 71 71 Camera* activeCamera = CameraManager::getInstance().getActiveCamera(); 72 if (activeCamera )72 if (activeCamera && this->billboard_.getBillboardSet()) 73 73 { 74 74 float distance = this->getPosition().distance( activeCamera->getWorldPosition() ); … … 89 89 void Planet::init() 90 90 { 91 float scaleFactor = this->getScale();92 93 #if OGRE_VERSION >= 0x01070094 Ogre::Mesh::LodValueList distList;95 #else96 Ogre::Mesh::LodDistanceList distList;97 #endif98 99 distList.push_back(10.0f*scaleFactor);100 distList.push_back(19.0f*scaleFactor);101 distList.push_back(27.0f*scaleFactor);102 distList.push_back(34.0f*scaleFactor);103 distList.push_back(40.0f*scaleFactor);104 distList.push_back(45.0f*scaleFactor);105 distList.push_back(49.0f*scaleFactor);106 distList.push_back(52.0f*scaleFactor);107 distList.push_back(54.0f*scaleFactor);108 distList.push_back(55.0f*scaleFactor);109 110 float reductionValue = 0.2f;111 112 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);113 billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));114 115 this->attachOgreObject(this->billboard_.getBillboardSet());116 this->billboard_.getBillboardSet()->setUseAccurateFacing(true);117 this->setCastShadows(true);118 this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup());119 this->mesh_.setCastShadows(true);120 91 } 121 92 122 93 void Planet::changedMesh() 123 94 { 124 if (this->mesh_.getEntity()) 125 this->detachOgreObject(this->mesh_.getEntity()); 95 if( GameMode::showsGraphics() ) 96 { 97 if (this->mesh_.getEntity()) 98 this->detachOgreObject(this->mesh_.getEntity()); 126 99 127 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);100 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 128 101 129 if (this->mesh_.getEntity()) 130 { 131 this->attachOgreObject(this->mesh_.getEntity()); 132 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 133 this->mesh_.setVisible(this->isVisible()); 102 if (this->mesh_.getEntity()) 103 { 104 this->attachOgreObject(this->mesh_.getEntity()); 105 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 106 this->mesh_.setVisible(this->isVisible()); 107 108 float scaleFactor = this->getScale(); 109 110 #if OGRE_VERSION >= 0x010700 111 Ogre::Mesh::LodValueList distList; 112 #else 113 Ogre::Mesh::LodDistanceList distList; 114 #endif 115 116 distList.push_back(10.0f*scaleFactor); 117 distList.push_back(19.0f*scaleFactor); 118 distList.push_back(27.0f*scaleFactor); 119 distList.push_back(34.0f*scaleFactor); 120 distList.push_back(40.0f*scaleFactor); 121 distList.push_back(45.0f*scaleFactor); 122 distList.push_back(49.0f*scaleFactor); 123 distList.push_back(52.0f*scaleFactor); 124 distList.push_back(54.0f*scaleFactor); 125 distList.push_back(55.0f*scaleFactor); 126 127 float reductionValue = 0.2f; 128 129 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 130 billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0)); 131 132 this->attachOgreObject(this->billboard_.getBillboardSet()); 133 this->billboard_.getBillboardSet()->setUseAccurateFacing(true); 134 this->setCastShadows(true); 135 this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup()); 136 this->mesh_.setCastShadows(true); 137 } 134 138 } 135 this->init();136 139 } 137 140 … … 151 154 SUPER(Planet, XMLPort, xmlelement, mode); 152 155 153 if (GameMode::showsGraphics()) 154 { 155 XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere"); 156 XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode); 157 XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode); 158 XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 159 XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); 160 } 156 XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere"); 157 XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode); 158 XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode); 159 XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 160 XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); 161 161 } 162 162 … … 164 164 { 165 165 registerVariable(this->atmosphere_, VariableDirection::ToClient); 166 registerVariable(this->atmosphereSize, VariableDirection::ToClient); 167 registerVariable(this->imageSize, VariableDirection::ToClient); 168 // Note: the meshSrc should be synchronised after atmosphere and other values, because the meshSrc callback setts the atmosphere billboards 166 169 registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh)); 167 170 registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows)); 168 registerVariable(this->atmosphereSize, VariableDirection::ToClient);169 registerVariable(this->imageSize, VariableDirection::ToClient);170 171 } 171 172 -
code/trunk/src/modules/objects/Planet.h
r6501 r7163 94 94 95 95 protected: 96 void registerVariables();97 96 98 97 private: 98 void registerVariables(); 99 99 100 100 void changedMesh(); -
code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h
r5781 r7163 43 43 virtual ~BoxCollisionShape(); 44 44 45 void registerVariables();46 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 46 … … 67 66 68 67 private: 68 void registerVariables(); 69 69 70 btCollisionShape* createNewShape() const; 70 71 -
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h
r5781 r7163 41 41 virtual ~ConeCollisionShape(); 42 42 43 void registerVariables();44 43 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 44 … … 55 54 56 55 private: 56 void registerVariables(); 57 57 58 btCollisionShape* createNewShape() const; 58 59 -
code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h
r5781 r7163 43 43 virtual ~PlaneCollisionShape(); 44 44 45 void registerVariables();46 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 46 … … 57 56 58 57 private: 58 void registerVariables(); 59 59 60 btCollisionShape* createNewShape()const; 60 61 -
code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h
r5781 r7163 41 41 virtual ~SphereCollisionShape(); 42 42 43 void registerVariables();44 43 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 44 … … 50 49 51 50 private: 51 void registerVariables(); 52 52 53 btCollisionShape* createNewShape() const; 53 54 -
code/trunk/src/modules/objects/eventsystem/EventListener.cc
r6856 r7163 61 61 return; 62 62 } 63 63 64 64 COUT(4) << "EventListener, processing event: originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << ")" << ", activate: " << event.activate_ << ", name: " << event.name_ << std::endl; 65 65 -
code/trunk/src/modules/objects/triggers/CheckPoint.cc
r5929 r7163 38 38 CreateFactory(CheckPoint); 39 39 40 CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator) 40 CheckPoint::CheckPoint(BaseObject* creator) 41 : DistanceTrigger(creator) 42 , RadarViewable(creator, static_cast<WorldEntity*>(this)) 41 43 { 42 44 RegisterObject(CheckPoint); -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
- Property svn:eol-style set to native
r6906 r7163 40 40 namespace orxonox 41 41 { 42 42 43 43 CreateFactory(DistanceMultiTrigger); 44 44 45 45 /** 46 46 @brief 47 Default Constructor. Registers the object and initializes default values. 47 Default Constructor. Registers the object and initializes default values. 48 48 */ 49 49 DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator) 50 50 { 51 51 RegisterObject(DistanceMultiTrigger); 52 52 53 53 this->distance_ = 100.0f; 54 54 this->targetName_ = BLANKSTRING; … … 98 98 continue; 99 99 } 100 100 101 101 Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition(); 102 102 // If the object is no longer in range. … … 154 154 if(this->singleTargetMode_) 155 155 entity = entity->getParent(); 156 156 157 157 // If no queue has been created, yet. 158 158 if(queue == NULL) … … 166 166 } 167 167 } 168 168 169 169 return queue; 170 170 } 171 171 172 172 } -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
- Property svn:eol-style set to native
r6906 r7163 56 56 class _ObjectsExport DistanceMultiTrigger : public MultiTrigger 57 57 { 58 58 59 59 public: 60 60 DistanceMultiTrigger(BaseObject* creator); //!< Default Constructor. Registers the object and initializes default values. 61 61 ~DistanceMultiTrigger(); //!< Destructor. 62 62 63 63 void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML. 64 64 … … 75 75 inline const std::string& getTargetName(void) 76 76 { return this->targetName_; } 77 77 78 78 /** 79 79 @brief Set the distance at which the DistanceMultiTrigger triggers. … … 88 88 inline float getDistance() const 89 89 { return this->distance_; } 90 90 91 91 protected: 92 92 virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at. … … 106 106 inline bool removeFromRange(WorldEntity* entity) 107 107 { WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second; bool erased = this->range_.erase(entity) > 0; if(erased) delete weakptr; return erased; } 108 108 109 109 private: 110 110 float distance_; //!< The distance at which the DistanceMultiTrigger triggers. 111 111 std::string targetName_; //!< The target name, used in singleTargetMode. 112 112 bool singleTargetMode_; //!< To indicate whe the MultiDistanceTrigger is in single-target-mode. 113 113 114 114 std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger. 115 115 116 116 }; 117 117 118 118 } 119 119 -
code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
r6906 r7163 136 136 continue; 137 137 } 138 138 139 139 Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition(); 140 140 if (distanceVec.length() < this->distance_) … … 155 155 } 156 156 } 157 157 158 return false; 158 159 } -
code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.cc
- Property svn:eol-style set to native
r6906 r7163 35 35 36 36 CreateFactory(DistanceTriggerBeacon); 37 37 38 38 DistanceTriggerBeacon::DistanceTriggerBeacon(BaseObject* creator) : StaticEntity(creator) 39 39 { 40 40 RegisterObject(DistanceTriggerBeacon); 41 41 } 42 42 43 43 } -
code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.h
- Property svn:eol-style set to native
r6906 r7163 39 39 class _ObjectsExport DistanceTriggerBeacon : public StaticEntity 40 40 { 41 41 42 42 public: 43 43 -
code/trunk/src/modules/objects/triggers/EventMultiTrigger.cc
- Property svn:eol-style set to native
r6864 r7163 52 52 EventMultiTrigger::~EventMultiTrigger() 53 53 { 54 54 55 55 } 56 56 … … 61 61 this->setBroadcast(true); 62 62 } 63 63 64 64 void EventMultiTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 65 65 { -
code/trunk/src/modules/objects/triggers/EventMultiTrigger.h
- Property svn:eol-style set to native
r6864 r7163 44 44 class _ObjectsExport EventMultiTrigger : public MultiTrigger 45 45 { 46 46 47 47 public: 48 48 EventMultiTrigger(BaseObject* creator); -
code/trunk/src/modules/objects/triggers/MultiTrigger.cc
- Property svn:eol-style set to native
r6864 r7163 47 47 /*static*/ const std::string MultiTrigger::or_s = "or"; 48 48 /*static*/ const std::string MultiTrigger::xor_s = "xor"; 49 49 50 50 CreateFactory(MultiTrigger); 51 51 … … 65 65 this->bSwitch_ = false; 66 66 this->bStayActive_ = false; 67 67 68 68 this->remainingActivations_ = INF_s; 69 69 this->maxNumSimultaniousTriggerers_ = INF_s; … … 75 75 76 76 this->parentTrigger_ = NULL; 77 77 78 78 this->targetMask_.exclude(Class(BaseObject)); 79 79 80 80 this->setSyncMode(0x0); 81 81 } 82 82 83 83 /** 84 84 @brief … … 95 95 } 96 96 } 97 97 98 98 /** 99 99 @brief … … 117 117 //TODO: Maybe nicer with explicit subgroup, e.g. triggers 118 118 XMLPortObject(MultiTrigger, MultiTrigger, "", addTrigger, getTrigger, xmlelement, mode); 119 119 120 120 COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") created." << std::endl; 121 121 } 122 122 123 123 124 124 /** … … 131 131 { 132 132 // If this is the first tick. 133 //TODO: Determine need for this, else kick it out. 133 //TODO: Determine need for this, else kick it out. 134 134 if(this->bFirstTick_) 135 135 { … … 174 174 delete state; 175 175 } 176 176 177 177 queue->pop(); 178 178 } … … 185 185 MultiTriggerState* state; 186 186 float timeRemaining; 187 187 188 188 // Go through all pending states. 189 189 for(int size = this->stateQueue_.size(); size >= 1; size--) … … 212 212 this->triggered_.erase(state->originator); 213 213 } 214 214 215 215 bStateChanged = true; 216 216 } … … 229 229 230 230 bool bFire = true; 231 231 232 232 // Add the originator to the objects activating this MultiTrigger. 233 233 if(bActive == true) … … 266 266 else 267 267 this->fire(bActive, state->originator); 268 268 269 269 bStateChanged = true; 270 270 } … … 289 289 } 290 290 } 291 291 292 292 // Remove the state from the state queue. 293 293 this->stateQueue_.pop_front(); … … 509 509 return returnVal; 510 510 } 511 511 512 512 return true; 513 513 } 514 514 515 515 /** 516 516 @brief … … 547 547 return; 548 548 } 549 549 550 550 MultiTriggerContainer* container = new MultiTriggerContainer(this, this, originator); 551 551 this->fireEvent(status, container); … … 563 563 { 564 564 ClassTreeMask& targetMask = this->getTargetMask(); 565 565 566 566 for(ClassTreeMaskObjectIterator it = targetMask.begin(); it != targetMask.end(); ++it) 567 567 { … … 580 580 { 581 581 assert(state); 582 582 583 583 // If the originator is no target of this MultiTrigger. 584 584 if(!this->isTarget(state->originator)) 585 585 return false; 586 586 587 587 // Add it ot the state queue. 588 588 this->stateQueue_.push_back(std::pair<float, MultiTriggerState*>(this->delay_, state)); -
code/trunk/src/modules/objects/triggers/MultiTrigger.h
- Property svn:eol-style set to native
r6864 r7163 94 94 MultiTrigger(BaseObject* creator); //!< Constructor. Registers the objects and initializes default values. 95 95 ~MultiTrigger(); //!< Destructor. 96 96 97 97 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a MultiTrigger object through XML. 98 98 virtual void tick(float dt); //!< A method that is executed each tick. 99 99 100 100 bool isActive(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is active for a given object. 101 101 … … 215 215 void addTargets(const std::string& targets); //!< Add some target to the MultiTrigger. 216 216 void removeTargets(const std::string& targets); //!< Remove some target from the MultiTrigger. 217 217 218 218 void addTrigger(MultiTrigger* trigger); //!< Adds a MultiTrigger as a sub-trigger to the trigger. 219 219 const MultiTrigger* getTrigger(unsigned int index) const; //!< Get the sub-trigger of this MultiTrigger at the given index. 220 220 221 221 protected: 222 222 virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at. 223 223 224 224 void changeTriggered(BaseObject* originator = NULL); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator. 225 225 226 226 bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whetherx the MultiTrigger is triggered concerning it's sub-triggers. 227 227 bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object. … … 236 236 inline void addParentTrigger(MultiTrigger* parent) 237 237 { this->parentTrigger_ = parent; } 238 238 239 239 /** 240 240 @brief Get the target mask used to identify the targets of this MultiTrigger. … … 248 248 //TODO: Check if something mus be done here. 249 249 virtual void notifyMaskUpdate(void) {} 250 250 251 251 private: 252 252 static const int INF_s; //!< Magic number for infinity. … … 257 257 258 258 void subTrigggerActivityChanged(BaseObject* originator); //!< This method is called by any sub-trigger to advertise changes in it's state to it's parent-trigger. 259 259 260 260 bool addState(MultiTriggerState* state); //!< Helper method. Adds a state to the state queue, where the state will wait to become active. 261 261 262 262 bool checkAnd(BaseObject* triggerer); //!< Checks whether the sub-triggers amount to true for the 'and' mode for a given object. 263 263 bool checkOr(BaseObject* triggerer); //!< Checks whether the sub-triggers amount to true for the 'or' mode for a given object. … … 276 276 bool bSwitch_; //!< Bool for the switch-mode, if true the MultiTrigger behaves like a switch. 277 277 bool bStayActive_; //!< Bool for the stay-active-mode, if true the MultiTrigger stays active after its last activation.; 278 278 279 279 int remainingActivations_; //!< The remaining activations of this MultiTrigger. 280 280 int maxNumSimultaniousTriggerers_; //!< The maximum number of objects simultaniously trigggering this MultiTrigger. … … 287 287 MultiTrigger* parentTrigger_; 288 288 std::set<MultiTrigger*> subTriggers_; //!< The sub-triggers of this MultiTrigger. 289 289 290 290 std::set<BaseObject*> active_; //!< The set of all objects the MultiTrigger is active for. 291 291 std::set<BaseObject*> triggered_; //!< The set of all objects the MultiTrigger is triggered for. 292 292 293 293 std::deque< std::pair<float, MultiTriggerState*> > stateQueue_; //!< The queue of states waiting to become active. 294 294 295 295 ClassTreeMask targetMask_; //!< The target mask, masking all objects that can trigger this MultiTrigger. 296 296 297 297 }; 298 298 -
code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc
- Property svn:eol-style set to native
r6859 r7163 40 40 41 41 CreateUnloadableFactory(MultiTriggerContainer); 42 42 43 43 /** 44 44 @brief … … 73 73 MultiTriggerContainer::~MultiTriggerContainer() 74 74 { 75 75 76 76 } 77 77 -
code/trunk/src/modules/objects/triggers/MultiTriggerContainer.h
- Property svn:eol-style set to native
r6856 r7163 50 50 class _ObjectsExport MultiTriggerContainer : public BaseObject 51 51 { 52 52 53 53 public: 54 54 MultiTriggerContainer(BaseObject* creator); //!< Default constructor. Registers the object and creates an empty container. … … 68 68 inline BaseObject* getData(void) 69 69 { return this->data_; } 70 70 71 71 private: 72 72 MultiTrigger* originator_; //!< The originator. 73 73 BaseObject* data_; //!< The data. 74 74 }; 75 75 76 76 } 77 77
Note: See TracChangeset
for help on using the changeset viewer.