Changeset 850 for code/branches
- Timestamp:
- Mar 5, 2008, 1:34:34 AM (17 years ago)
- Location:
- code/branches/core/src/orxonox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/orxonox/core/XMLPort.h
r847 r850 31 31 #include "util/XMLIncludes.h" 32 32 #include "util/MultiTypeMath.h" 33 #include "util/TinyXML/ticpp.h" 34 #include "util/SubString.h" 33 35 #include "Functor.h" 36 #include "Debug.h" 34 37 35 38 #include "CorePrereqs.h" … … 97 100 if (loading) 98 101 { 102 std::string attribute = xmlelement.GetAttribute(this->paramname_); 103 if (attribute.size() > 0) 104 { 105 SubString tokens(attribute, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0'); 106 if ((unsigned int)tokens.size() >= (unsigned int)this->loadfunction_->getParamCount()) 107 { 108 MultiTypeMath param1, param2, param3, param4, param5; 109 if (tokens.size() >= 1) param1 = tokens[0]; 110 if (tokens.size() >= 2) param1 = tokens[1]; 111 if (tokens.size() >= 3) param1 = tokens[2]; 112 if (tokens.size() >= 4) param1 = tokens[3]; 113 if (tokens.size() >= 5) param1 = tokens[4]; 114 115 (*this->loadfunction_)(object, param1, param2, param3, param4, param5); 116 } 117 else 118 { 119 COUT(2) << " Warning: Parameter \"" << this->paramname_ << "\" in \"" << this->classname_ << "\" (objectname: " << object->getName() << ") is incomplete and couln't be loaded." << std::endl; 120 } 121 } 99 122 } 100 123 else 101 124 { 125 // xmlelement.SetAttribute(this->paramname_, "..."); 102 126 } 103 127 -
code/branches/core/src/orxonox/objects/WorldEntity.cc
r793 r850 37 37 #include "../Orxonox.h" 38 38 #include "WorldEntity.h" 39 #include "core/XMLPort.h" 39 40 40 41 namespace orxonox … … 86 87 void WorldEntity::loadParams(TiXmlElement* xmlElem) 87 88 { 89 88 90 BaseObject::loadParams(xmlElem); 89 91 /* 90 92 if (xmlElem->Attribute("position")) 91 93 { … … 153 155 154 156 create(); 155 157 */ 158 } 159 160 161 /** 162 @brief XML loading and saving. 163 @param xmlelement The XML-element 164 @param loading Loading (true) or saving (false) 165 @return The XML-element 166 */ 167 Element& WorldEntity::XMLPort(Element& xmlelement, bool loading) 168 { 169 std::cout << "2_1: " << this->getPosition() << std::endl; 170 BaseObject::XMLPort(xmlelement, loading); 171 172 XMLPortParam(WorldEntity, "position", setPosition, getPosition, xmlelement, loading); 173 // XMLPortParam(WorldEntity, "direction", setDirection, getDirection, xmlelement, loading); 174 // XMLPortParam(WorldEntity, "yaw", yaw, getYaw, xmlelement, loading); 175 // XMLPortParam(WorldEntity, "pitch", pitch, getPitch, xmlelement, loading); 176 // XMLPortParam(WorldEntity, "roll", roll, getRoll, xmlelement, loading); 177 XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, loading); 178 XMLPortParam(WorldEntity, "rotationAxis", setRotationAxis, getRotationAxis, xmlelement, loading); 179 XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, loading); 180 std::cout << "2_2: " << this->getPosition() << std::endl; 181 182 return xmlelement; 156 183 } 157 184 -
code/branches/core/src/orxonox/objects/WorldEntity.h
r845 r850 8 8 9 9 #include "util/Math.h" 10 #include "util/XMLIncludes.h" 10 11 #include "network/Synchronisable.h" 11 #include "util/tinyxml/tinyxml.h"12 //#include "util/tinyxml/tinyxml.h" 12 13 #include "../core/CoreIncludes.h" 13 14 #include "core/BaseObject.h" … … 17 18 namespace orxonox 18 19 { 19 class _OrxonoxExport WorldEntity : public BaseObject, public Tickable//, public network::Synchronisable20 {21 public:22 WorldEntity();23 virtual ~WorldEntity();20 class _OrxonoxExport WorldEntity : public BaseObject, public Tickable//, public network::Synchronisable 21 { 22 public: 23 WorldEntity(); 24 virtual ~WorldEntity(); 24 25 25 virtual void tick(float dt); 26 virtual void loadParams(TiXmlElement* xmlElem); 27 bool create(); 26 virtual void tick(float dt); 27 virtual void loadParams(TiXmlElement* xmlElem); 28 virtual Element& XMLPort(Element& xmlelement, bool loading); 29 bool create(); 28 30 29 inline Ogre::SceneNode* getNode()30 { return this->node_; }31 inline Ogre::SceneNode* getNode() 32 { return this->node_; } 31 33 32 inline void setNode(Ogre::SceneNode* node)33 { this->node_ = node; }34 inline void setNode(Ogre::SceneNode* node) 35 { this->node_ = node; } 34 36 35 inline void setPosition(const Vector3& pos)36 { this->node_->setPosition(pos); }37 inline void setPosition(Real x, Real y, Real z)38 { this->node_->setPosition(x, y, z); }39 inline const Vector3& getPosition() const40 { return this->node_->getPosition(); }37 inline void setPosition(const Vector3& pos) 38 { this->node_->setPosition(pos); } 39 // inline void setPosition(Real x, Real y, Real z) 40 // { this->node_->setPosition(x, y, z); } 41 inline const Vector3& getPosition() const 42 { return this->node_->getPosition(); } 41 43 42 inline void translate(const Vector3 &d, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)43 { this->node_->translate(d, relativeTo); }44 inline void translate(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)45 { this->node_->translate(x, y, z, relativeTo); }46 inline void translate(const Matrix3 &axes, const Vector3 &move, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)47 { this->node_->translate(axes, move, relativeTo); }48 inline void translate(const Matrix3 &axes, Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)49 { this->node_->translate(axes, x, y, z, relativeTo); }44 inline void translate(const Vector3 &d, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 45 { this->node_->translate(d, relativeTo); } 46 inline void translate(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 47 { this->node_->translate(x, y, z, relativeTo); } 48 inline void translate(const Matrix3 &axes, const Vector3 &move, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 49 { this->node_->translate(axes, move, relativeTo); } 50 inline void translate(const Matrix3 &axes, Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 51 { this->node_->translate(axes, x, y, z, relativeTo); } 50 52 51 inline void yaw(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)52 { this->node_->yaw(angle, relativeTo); }53 inline void pitch(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)54 { this->node_->pitch(angle, relativeTo); }55 inline void roll(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)56 { this->node_->roll(angle, relativeTo); }53 inline void yaw(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 54 { this->node_->yaw(angle, relativeTo); } 55 inline void pitch(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 56 { this->node_->pitch(angle, relativeTo); } 57 inline void roll(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 58 { this->node_->roll(angle, relativeTo); } 57 59 58 inline const Ogre::Quaternion& getOrientation()59 { return this->node_->getOrientation(); }60 inline void setOrientation(const Ogre::Quaternion& quat)61 { this->node_->setOrientation(quat); }62 inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)63 { this->node_->rotate(axis, angle, relativeTo); }64 inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)65 { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); }66 inline void setDirection(const Vector3 &vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)67 { this->node_->setDirection(vec, relativeTo, localDirectionVector); }68 inline void lookAt(const Vector3 &targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)69 { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); }60 inline const Ogre::Quaternion& getOrientation() 61 { return this->node_->getOrientation(); } 62 inline void setOrientation(const Ogre::Quaternion& quat) 63 { this->node_->setOrientation(quat); } 64 inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 65 { this->node_->rotate(axis, angle, relativeTo); } 66 inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) 67 { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); } 68 inline void setDirection(const Vector3 &vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) 69 { this->node_->setDirection(vec, relativeTo, localDirectionVector); } 70 inline void lookAt(const Vector3 &targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) 71 { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); } 70 72 71 inline void setScale(const Vector3 &scale)72 { this->node_->setScale(scale); }73 inline void setScale(Real x, Real y, Real z)74 { this->node_->setScale(x, y, z); }75 inline void setScale(Real scale)76 { this->node_->setScale(scale, scale, scale); }77 inline const Vector3& getScale(void) const78 { return this->node_->getScale(); }79 inline void scale(const Vector3 &scale)80 { this->node_->scale(scale); }81 inline void scale(Real x, Real y, Real z)82 { this->node_->scale(x, y, z); }83 inline void scale(Real scale)84 { this->node_->scale(scale, scale, scale); }73 inline void setScale(const Vector3 &scale) 74 { this->node_->setScale(scale); } 75 inline void setScale(Real x, Real y, Real z) 76 { this->node_->setScale(x, y, z); } 77 inline void setScale(Real scale) 78 { this->node_->setScale(scale, scale, scale); } 79 inline const Vector3& getScale(void) const 80 { return this->node_->getScale(); } 81 inline void scale(const Vector3 &scale) 82 { this->node_->scale(scale); } 83 inline void scale(Real x, Real y, Real z) 84 { this->node_->scale(x, y, z); } 85 inline void scale(Real scale) 86 { this->node_->scale(scale, scale, scale); } 85 87 86 inline void attachObject(Ogre::MovableObject *obj)87 { this->node_->attachObject(obj); }88 inline void attachObject(Mesh &mesh)89 { this->node_->attachObject(mesh.getEntity()); }90 inline void detachObject(Ogre::MovableObject *obj)91 { this->node_->detachObject(obj); }92 inline void detachAllObjects()93 { this->node_->detachAllObjects(); }88 inline void attachObject(Ogre::MovableObject *obj) 89 { this->node_->attachObject(obj); } 90 inline void attachObject(Mesh &mesh) 91 { this->node_->attachObject(mesh.getEntity()); } 92 inline void detachObject(Ogre::MovableObject *obj) 93 { this->node_->detachObject(obj); } 94 inline void detachAllObjects() 95 { this->node_->detachAllObjects(); } 94 96 95 inline void setVelocity(const Vector3& velocity)96 { this->velocity_ = velocity; }97 inline void setVelocity(Real x, Real y, Real z)98 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }99 inline const Vector3& getVelocity() const100 { return this->velocity_; }97 inline void setVelocity(const Vector3& velocity) 98 { this->velocity_ = velocity; } 99 inline void setVelocity(Real x, Real y, Real z) 100 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; } 101 inline const Vector3& getVelocity() const 102 { return this->velocity_; } 101 103 102 inline void setAcceleration(const Vector3& acceleration)103 { this->acceleration_ = acceleration; }104 inline void setAcceleration(Real x, Real y, Real z)105 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }106 inline const Vector3& getAcceleration() const107 { return this->acceleration_; }104 inline void setAcceleration(const Vector3& acceleration) 105 { this->acceleration_ = acceleration; } 106 inline void setAcceleration(Real x, Real y, Real z) 107 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; } 108 inline const Vector3& getAcceleration() const 109 { return this->acceleration_; } 108 110 109 inline void setRotationAxis(const Vector3& axis)110 { this->rotationAxis_ = axis; }111 inline void setRotationAxis(Real x, Real y, Real z)112 { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; }113 inline const Vector3& getRotationAxis() const114 { return this->rotationAxis_; }111 inline void setRotationAxis(const Vector3& axis) 112 { this->rotationAxis_ = axis; } 113 // inline void setRotationAxis(Real x, Real y, Real z) 114 // { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; } 115 inline const Vector3& getRotationAxis() const 116 { return this->rotationAxis_; } 115 117 116 inline void setRotationRate(const Radian& angle)117 { this->rotationRate_ = angle; }118 inline void setRotationRate(const Degree& angle)119 { this->rotationRate_ = angle; }120 inline const Radian& getRotationRate() const121 { return this->rotationRate_; }118 // inline void setRotationRate(const Radian& angle) 119 // { this->rotationRate_ = angle; } 120 inline void setRotationRate(const Degree& angle) 121 { this->rotationRate_ = angle; } 122 inline const Radian& getRotationRate() const 123 { return this->rotationRate_; } 122 124 123 inline void setMomentum(const Radian& angle)124 { this->momentum_ = angle; }125 inline void setMomentum(const Degree& angle)126 { this->momentum_ = angle; }127 inline const Radian& getMomentum() const128 { return this->momentum_; }125 inline void setMomentum(const Radian& angle) 126 { this->momentum_ = angle; } 127 inline void setMomentum(const Degree& angle) 128 { this->momentum_ = angle; } 129 inline const Radian& getMomentum() const 130 { return this->momentum_; } 129 131 130 inline void setStatic(bool bStatic)131 { this->bStatic_ = bStatic; }132 inline bool isStatic()133 { return this->bStatic_; }132 inline void setStatic(bool bStatic) 133 { this->bStatic_ = bStatic; } 134 inline bool isStatic() 135 { return this->bStatic_; } 134 136 135 protected:136 void registerAllVariables();137 protected: 138 void registerAllVariables(); 137 139 138 Vector3 velocity_;139 Vector3 acceleration_;140 Vector3 rotationAxis_;141 Radian rotationRate_;142 Radian momentum_;140 Vector3 velocity_; 141 Vector3 acceleration_; 142 Vector3 rotationAxis_; 143 Radian rotationRate_; 144 Radian momentum_; 143 145 144 private:145 static unsigned int worldEntityCounter_s;146 Ogre::SceneNode* node_;147 bool bStatic_;148 };146 private: 147 static unsigned int worldEntityCounter_s; 148 Ogre::SceneNode* node_; 149 bool bStatic_; 150 }; 149 151 } 150 152
Note: See TracChangeset
for help on using the changeset viewer.