Changeset 869 for code/branches/core/src
- Timestamp:
- Mar 9, 2008, 4:04:23 AM (17 years ago)
- Location:
- code/branches/core/src
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/orxonox/CMakeLists.txt
r852 r869 6 6 # SpaceshipSteering.cc 7 7 # hud/HUD.cc 8 #particle/ParticleInterface.cc9 #tools/BillboardSet.cc8 particle/ParticleInterface.cc 9 tools/BillboardSet.cc 10 10 # tools/Light.cc 11 11 tools/Mesh.cc 12 12 tools/Timer.cc 13 #objects/Ambient.cc13 objects/Ambient.cc 14 14 # objects/Camera.cc 15 #objects/Explosion.cc15 objects/Explosion.cc 16 16 # objects/Fighter.cc 17 17 objects/Model.cc 18 18 # objects/NPC.cc 19 #objects/Projectile.cc20 #objects/Skybox.cc21 #objects/SpaceShip.cc19 objects/Projectile.cc 20 objects/Skybox.cc 21 objects/SpaceShip.cc 22 22 # objects/SpaceshipSteeringObject.cc 23 23 objects/test1.cc -
code/branches/core/src/orxonox/Orxonox.cc
r852 r869 209 209 { 210 210 //TODO: start modules 211 //ogre_->startRender();211 ogre_->startRender(); 212 212 //TODO: run engine 213 213 Factory::createClassHierarchy(); 214 //createScene();215 //setupScene();216 //setupInputSystem();214 createScene(); 215 setupScene(); 216 setupInputSystem(); 217 217 if(mode_!=CLIENT){ // remove this in future ---- presentation hack 218 218 } … … 1146 1146 std::cout << "2\n"; 1147 1147 1148 //startRenderLoop();1148 startRenderLoop(); 1149 1149 } 1150 1150 -
code/branches/core/src/orxonox/core/XMLPort.cc
r856 r869 28 28 #include "XMLPort.h" 29 29 #include "Language.h" 30 #include "Loader.h" 30 31 31 32 namespace orxonox … … 82 83 return GetLocalisation(this->description_); 83 84 } 85 86 bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier) 87 { 88 return Loader::currentMask_s.isIncluded(identifier); 89 } 84 90 } -
code/branches/core/src/orxonox/core/XMLPort.h
r858 r869 37 37 #include "CoreIncludes.h" 38 38 #include "BaseObject.h" 39 #include "Loader.h"40 39 41 40 #include "CorePrereqs.h" … … 142 141 { 143 142 COUT(5) << tokens.size() << " parameter (using MultiTypeMath)." << std::endl; 144 MultiTypeMath param1 , param2, param3, param4, param5;143 MultiTypeMath param1 = MT_null, param2 = MT_null, param3 = MT_null, param4 = MT_null, param5 = MT_null; 145 144 if (tokens.size() >= 1) param1 = tokens[0]; 146 if (tokens.size() >= 2) param 1= tokens[1];147 if (tokens.size() >= 3) param 1= tokens[2];148 if (tokens.size() >= 4) param 1= tokens[3];149 if (tokens.size() >= 5) param 1= tokens[4];145 if (tokens.size() >= 2) param2 = tokens[1]; 146 if (tokens.size() >= 3) param3 = tokens[2]; 147 if (tokens.size() >= 4) param4 = tokens[3]; 148 if (tokens.size() >= 5) param5 = tokens[4]; 150 149 COUT(5) << object->getLoaderIndentation() << " " << attribute << std::endl; 151 COUT(5) << object->getLoaderIndentation() << " " << tokens[0] << " -> " << param1 << ", " << tokens[1] << " -> " << param2 << ", " << tokens[2] << " -> " << param3 << ", " << tokens[3] << " -> " << param4 << ", " << tokens[4] << " ->" << param5 << std::endl;150 COUT(5) << object->getLoaderIndentation() << " " << param1 << ", " << param2 << ", " << param3 << ", " << param4 << ", " << param5 << std::endl; 152 151 153 152 (*this->loadfunction_)(object, param1, param2, param3, param4, param5); … … 197 196 XMLPortObjectContainer& description(const std::string description); 198 197 const std::string& getDescription(); 198 static bool identifierIsIncludedInLoaderMask(const Identifier* identifier); 199 199 200 200 protected: … … 236 236 if (identifier->isA(Class(O))) 237 237 { 238 if ( Loader::currentMask_s.isIncluded(identifier))238 if (this->identifierIsIncludedInLoaderMask(identifier)) 239 239 { 240 240 COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; -
code/branches/core/src/orxonox/objects/Ambient.cc
r845 r869 40 40 #include "../core/CoreIncludes.h" 41 41 #include "../Orxonox.h" 42 #include "core/XMLPort.h" 42 43 43 44 #include "Ambient.h" … … 58 59 void Ambient::loadParams(TiXmlElement* xmlElem) 59 60 { 60 Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();61 62 61 if (xmlElem->Attribute("colourvalue")) 63 62 { … … 69 68 String2Number<float>(b, colourvalues[2]); 70 69 71 mgr->setAmbientLight(ColourValue(r,g,b));70 this->setAmbientLight(ColourValue(r, g, b)); 72 71 73 72 COUT(4) << "Loader: Set ambient light: "<<r<<" " << g << " " << b << std::endl << std::endl; 74 73 } 75 74 } 75 76 void Ambient::setAmbientLight(const ColourValue& colour) 77 { 78 Orxonox::getSingleton()->getSceneManager()->setAmbientLight(colour); 79 } 80 81 /** 82 @brief XML loading and saving. 83 @param xmlelement The XML-element 84 @param loading Loading (true) or saving (false) 85 @return The XML-element 86 */ 87 Element& Ambient::XMLPort(Element& xmlelement, bool loading) 88 { 89 BaseObject::XMLPort(xmlelement, loading); 90 91 XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, loading); 92 93 return xmlelement; 94 } 76 95 } -
code/branches/core/src/orxonox/objects/Ambient.h
r845 r869 14 14 virtual ~Ambient(); 15 15 16 17 16 void loadParams(TiXmlElement* xmlElem); 17 virtual Element& XMLPort(Element& xmlelement, bool loading); 18 void setAmbientLight(const ColourValue& colour); 18 19 19 20 private: -
code/branches/core/src/orxonox/objects/Model.cc
r793 r869 33 33 #include "../core/CoreIncludes.h" 34 34 #include "../Orxonox.h" 35 #include "core/XMLPort.h" 35 36 36 37 #include "Model.h" … … 60 61 } 61 62 63 /** 64 @brief XML loading and saving. 65 @param xmlelement The XML-element 66 @param loading Loading (true) or saving (false) 67 @return The XML-element 68 */ 69 Element& Model::XMLPort(Element& xmlelement, bool loading) 70 { 71 WorldEntity::XMLPort(xmlelement, loading); 72 73 XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, loading); 74 75 create(); 76 77 return xmlelement; 78 } 79 80 void Model::setMesh(const std::string& meshname) 81 { 82 this->meshSrc_ = meshname; 83 } 84 62 85 bool Model::create(){ 63 86 if(meshSrc_.compare("")!=0){ -
code/branches/core/src/orxonox/objects/Model.h
r845 r869 18 18 virtual ~Model(); 19 19 virtual void loadParams(TiXmlElement* xmlElem); 20 virtual Element& XMLPort(Element& xmlelement, bool loading); 21 void setMesh(const std::string& meshname); 20 22 bool create(); 21 23 -
code/branches/core/src/orxonox/objects/Skybox.cc
r790 r869 38 38 #include "../core/CoreIncludes.h" 39 39 #include "../core/Debug.h" 40 #include "core/XMLPort.h" 40 41 41 42 #include "Skybox.h" … … 56 57 void Skybox::loadParams(TiXmlElement* xmlElem) 57 58 { 58 Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();59 60 59 if (xmlElem->Attribute("src")) 61 60 { 62 61 std::string skyboxSrc = xmlElem->Attribute("src"); 63 mgr->setSkyBox(true,skyboxSrc);62 this->setSkybox(skyboxSrc); 64 63 65 64 COUT(4) << "Loader: Set skybox: "<< skyboxSrc << std::endl << std::endl; 66 65 } 67 66 } 67 68 void Skybox::setSkybox(const std::string& skyboxname) 69 { 70 Orxonox::getSingleton()->getSceneManager()->setSkyBox(true, skyboxname); 71 } 72 73 /** 74 @brief XML loading and saving. 75 @param xmlelement The XML-element 76 @param loading Loading (true) or saving (false) 77 @return The XML-element 78 */ 79 Element& Skybox::XMLPort(Element& xmlelement, bool loading) 80 { 81 BaseObject::XMLPort(xmlelement, loading); 82 83 XMLPortParamLoadOnly(Skybox, "src", setSkybox, xmlelement, loading); 84 85 return xmlelement; 86 } 68 87 } -
code/branches/core/src/orxonox/objects/Skybox.h
r845 r869 16 16 virtual ~Skybox(); 17 17 18 19 18 void loadParams(TiXmlElement* xmlElem); 19 virtual Element& XMLPort(Element& xmlelement, bool loading); 20 void setSkybox(const std::string& skyboxname); 20 21 21 22 private: -
code/branches/core/src/orxonox/objects/SpaceShip.cc
r790 r869 44 44 #include "../particle/ParticleInterface.h" 45 45 #include "Projectile.h" 46 #include "core/XMLPort.h" 46 47 47 48 #include "SpaceShip.h" … … 123 124 this->brakeLoop(loop); 124 125 */ 126 this->init(); 127 125 128 COUT(3) << "Info: SpaceShip was loaded" << std::endl; 126 129 } … … 132 135 } 133 136 134 void SpaceShip::setConfigValues() 135 { 136 SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down)."); 137 SetConfigValue(reloadTime_, 0.125).description("The reload time of the weapon in seconds"); 138 SetConfigValue(testvector_, Vector3()).description("asdfblah"); 139 } 140 141 void SpaceShip::loadParams(TiXmlElement* xmlElem) 142 { 143 Model::loadParams(xmlElem); 144 145 137 void SpaceShip::init() 138 { 146 139 // START CREATING THRUSTER 147 140 this->tt_ = new ParticleInterface(Orxonox::getSingleton()->getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow"); … … 197 190 198 191 // END of testing crosshair 199 192 } 193 194 void SpaceShip::setConfigValues() 195 { 196 SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down)."); 197 SetConfigValue(reloadTime_, 0.125).description("The reload time of the weapon in seconds"); 198 SetConfigValue(testvector_, Vector3()).description("asdfblah"); 199 } 200 201 void SpaceShip::loadParams(TiXmlElement* xmlElem) 202 { 203 Model::loadParams(xmlElem); 200 204 /* 201 205 if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft")) … … 242 246 if (xmlElem->Attribute("camera")) 243 247 { 244 Ogre::Camera *cam = Orxonox::getSingleton()->getSceneManager()->createCamera("ShipCam"); 245 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 246 /* 247 // node->setInheritOrientation(false); 248 cam->setPosition(Vector3(0,50,-150)); 249 cam->lookAt(Vector3(0,20,0)); 250 cam->roll(Degree(0)); 251 */ 252 253 cam->setPosition(Vector3(-200,0,35)); 254 // cam->setPosition(Vector3(0,-350,0)); 255 cam->lookAt(Vector3(0,0,35)); 256 cam->roll(Degree(-90)); 257 258 this->camNode_->attachObject(cam); 259 Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam); 248 this->setCamera(); 260 249 } 250 } 251 252 void SpaceShip::setCamera(const std::string& camera) 253 { 254 Ogre::Camera *cam = Orxonox::getSingleton()->getSceneManager()->createCamera("ShipCam"); 255 this->camNode_ = this->getNode()->createChildSceneNode("CamNode"); 256 /* 257 // node->setInheritOrientation(false); 258 cam->setPosition(Vector3(0,50,-150)); 259 cam->lookAt(Vector3(0,20,0)); 260 cam->roll(Degree(0)); 261 */ 262 263 cam->setPosition(Vector3(-200,0,35)); 264 // cam->setPosition(Vector3(0,-350,0)); 265 cam->lookAt(Vector3(0,0,35)); 266 cam->roll(Degree(-90)); 267 268 this->camNode_->attachObject(cam); 269 Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam); 270 } 271 272 void SpaceShip::setMaxSpeed(float value) 273 { this->maxSpeed_ = value; } 274 void SpaceShip::setMaxSideAndBackSpeed(float value) 275 { this->maxSideAndBackSpeed_ = value; } 276 void SpaceShip::setMaxRotation(float value) 277 { this->maxRotation_ = value; this->maxRotationRadian_ = Radian(value); } 278 void SpaceShip::setTransAcc(float value) 279 { this->translationAcceleration_ = value; } 280 void SpaceShip::setRotAcc(float value) 281 { this->rotationAcceleration_ = value; this->rotationAccelerationRadian_ = Radian(value); } 282 void SpaceShip::setTransDamp(float value) 283 { this->translationDamping_ = value; } 284 void SpaceShip::setRotDamp(float value) 285 { this->rotationDamping_ = value; this->rotationDampingRadian_ = Radian(value); } 286 287 /** 288 @brief XML loading and saving. 289 @param xmlelement The XML-element 290 @param loading Loading (true) or saving (false) 291 @return The XML-element 292 */ 293 Element& SpaceShip::XMLPort(Element& xmlelement, bool loading) 294 { 295 Model::XMLPort(xmlelement, loading); 296 297 XMLPortParamLoadOnly(SpaceShip, "camera", setCamera, xmlelement, loading); 298 XMLPortParamLoadOnly(SpaceShip, "maxSpeed", setMaxSpeed, xmlelement, loading); 299 XMLPortParamLoadOnly(SpaceShip, "maxSideAndBackSpeed", setMaxSideAndBackSpeed, xmlelement, loading); 300 XMLPortParamLoadOnly(SpaceShip, "maxRotation", setMaxRotation, xmlelement, loading); 301 XMLPortParamLoadOnly(SpaceShip, "transAcc", setTransAcc, xmlelement, loading); 302 XMLPortParamLoadOnly(SpaceShip, "rotAcc", setRotAcc, xmlelement, loading); 303 XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, loading); 304 XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, loading); 305 306 return xmlelement; 261 307 } 262 308 -
code/branches/core/src/orxonox/objects/SpaceShip.h
r845 r869 21 21 SpaceShip(); 22 22 ~SpaceShip(); 23 void init(); 23 24 void setConfigValues(); 24 25 virtual void loadParams(TiXmlElement* xmlElem); 26 virtual Element& XMLPort(Element& xmlelement, bool loading); 25 27 virtual void tick(float dt); 28 29 void setCamera(const std::string& camera = ""); 30 void setMaxSpeed(float value); 31 void setMaxSideAndBackSpeed(float value); 32 void setMaxRotation(float value); 33 void setTransAcc(float value); 34 void setRotAcc(float value); 35 void setTransDamp(float value); 36 void setRotDamp(float value); 26 37 27 38 bool mouseMoved(const OIS::MouseEvent &e); -
code/branches/core/src/orxonox/objects/WorldEntity.cc
r856 r869 158 158 } 159 159 160 void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll) 161 { 162 this->yaw(yaw); 163 this->pitch(pitch); 164 this->roll(roll); 165 } 160 166 161 167 /** … … 169 175 BaseObject::XMLPort(xmlelement, loading); 170 176 171 XMLPortParam(WorldEntity, "position", setPosition, getPosition, xmlelement, loading); 172 // XMLPortParam(WorldEntity, "direction", setDirection, getDirection, xmlelement, loading); 173 XMLPortParamLoadOnly(WorldEntity, "yaw", setYaw, xmlelement, loading); 174 XMLPortParamLoadOnly(WorldEntity, "pitch", setPitch, xmlelement, loading); 175 XMLPortParamLoadOnly(WorldEntity, "roll", setRoll, xmlelement, loading); 177 XMLPortParam(WorldEntity, "position", setPositionLoader2, getPosition, xmlelement, loading); 178 XMLPortParamLoadOnly(WorldEntity, "direction", setDirectionLoader, xmlelement, loading); 179 XMLPortParamLoadOnly(WorldEntity, "yawpitchroll", setYawPitchRoll, xmlelement, loading); 176 180 XMLPortParam(WorldEntity, "scale", setTotalScale, getScale, xmlelement, loading); 177 XMLPortParam(WorldEntity, "rotationAxis", setRotationAxis , getRotationAxis, xmlelement, loading);181 XMLPortParam(WorldEntity, "rotationAxis", setRotationAxisLoader, getRotationAxis, xmlelement, loading); 178 182 XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, loading); 179 183 -
code/branches/core/src/orxonox/objects/WorldEntity.h
r856 r869 39 39 inline void setPosition(const Vector3& pos) 40 40 { this->node_->setPosition(pos); } 41 // inline void setPosition(Real x, Real y, Real z) 42 // { this->node_->setPosition(x, y, z); } 41 inline void setPositionLoader1(const Vector3& pos) 42 { this->node_->setPosition(pos); } 43 inline void setPositionLoader2(Real x, Real y, Real z) 44 { this->node_->setPosition(x, y, z); } 45 inline void setPosition(Real x, Real y, Real z) 46 { this->node_->setPosition(x, y, z); } 43 47 inline const Vector3& getPosition() const 44 48 { return this->node_->getPosition(); } … … 59 63 inline void roll(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 60 64 { this->node_->roll(angle, relativeTo); } 65 void setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll); 61 66 62 67 inline void setYaw(const Degree &angle) … … 73 78 inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 74 79 { this->node_->rotate(axis, angle, relativeTo); } 80 inline void setDirectionLoader(Real x, Real y, Real z) 81 { this->setDirection(x, y, z); } 75 82 inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z) 76 83 { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); } … … 120 127 { return this->acceleration_; } 121 128 129 inline void setRotationAxisLoader(const Vector3& axis) 130 { this->rotationAxis_ = axis; } 122 131 inline void setRotationAxis(const Vector3& axis) 123 132 { this->rotationAxis_ = axis; } 124 //inline void setRotationAxis(Real x, Real y, Real z)125 //{ this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; }133 inline void setRotationAxis(Real x, Real y, Real z) 134 { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; } 126 135 inline const Vector3& getRotationAxis() const 127 136 { return this->rotationAxis_; } … … 130 139 // { this->rotationRate_ = angle; } 131 140 inline void setRotationRate(const Degree& angle) 132 { this->rotationRate_ = angle; }141 { this->rotationRate_ = angle; this->setStatic(angle == Degree(0)); } 133 142 inline const Radian& getRotationRate() const 134 143 { return this->rotationRate_; } -
code/branches/core/src/util/MultiTypeMath.cc
r855 r869 88 88 } 89 89 90 MultiTypeMath::operator int() const 91 { return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeMath, int>(*this); } 92 MultiTypeMath::operator unsigned int() const 93 { return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeMath, unsigned int>(*this); } 94 MultiTypeMath::operator char() const 95 { return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeMath, char>(*this); } 96 MultiTypeMath::operator unsigned char() const 97 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeMath, unsigned char>(*this); } 98 MultiTypeMath::operator short() const 99 { return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeMath, short>(*this); } 100 MultiTypeMath::operator unsigned short() const 101 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeMath, unsigned short>(*this); } 102 MultiTypeMath::operator long() const 103 { return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeMath, long>(*this); } 104 MultiTypeMath::operator unsigned long() const 105 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeMath, unsigned long>(*this); } 106 MultiTypeMath::operator float() const 107 { return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeMath, float>(*this); } 108 MultiTypeMath::operator double() const 109 { return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeMath, double>(*this); } 110 MultiTypeMath::operator long double() const 111 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeMath, long double>(*this); } 112 MultiTypeMath::operator bool() const 113 { return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeMath, bool>(*this); } 114 MultiTypeMath::operator std::string() const 115 { return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeMath, std::string>(*this); } 116 MultiTypeMath::operator const char*() const 117 { return ((this->type_ == MT_constchar) ? this->string_ : ConvertValueAndReturn<MultiTypeMath, std::string>(*this)).c_str(); } 90 118 MultiTypeMath::operator orxonox::Vector2() const 91 { 92 return (this->type_ == MT_vector2) ? this->vector2_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector2>(*this); 93 } 94 119 { return (this->type_ == MT_vector2) ? this->vector2_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector2>(*this); } 95 120 MultiTypeMath::operator orxonox::Vector3() const 96 { 97 return (this->type_ == MT_vector3) ? this->vector3_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector3>(*this); 98 } 99 121 { return (this->type_ == MT_vector3) ? this->vector3_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector3>(*this); } 100 122 MultiTypeMath::operator orxonox::Quaternion() const 101 { 102 return (this->type_ == MT_quaternion) ? this->quaternion_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Quaternion>(*this); 103 } 104 123 { return (this->type_ == MT_quaternion) ? this->quaternion_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Quaternion>(*this); } 105 124 MultiTypeMath::operator orxonox::ColourValue() const 106 { 107 return (this->type_ == MT_colourvalue) ? this->colourvalue_ : ConvertValueAndReturn<MultiTypeMath, orxonox::ColourValue>(*this); 108 } 109 125 { return (this->type_ == MT_colourvalue) ? this->colourvalue_ : ConvertValueAndReturn<MultiTypeMath, orxonox::ColourValue>(*this); } 110 126 MultiTypeMath::operator orxonox::Radian() const 111 { 112 return (this->type_ == MT_radian) ? this->radian_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Radian>(*this); 113 } 114 127 { return (this->type_ == MT_radian) ? this->radian_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Radian>(*this); } 115 128 MultiTypeMath::operator orxonox::Degree() const 116 { 117 return (this->type_ == MT_degree) ? this->degree_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Degree>(*this); 118 } 129 { return (this->type_ == MT_degree) ? this->degree_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Degree>(*this); } 119 130 120 131 void MultiTypeMath::setValue(const MultiTypeMath& mtm) … … 171 182 std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm) 172 183 { 173 if (mtm.isA(MT_vector2)) 174 out << mtm.getVector2(); 175 else if (mtm.isA(MT_vector3)) 176 out << mtm.getVector3(); 177 else if (mtm.isA(MT_colourvalue)) 178 out << mtm.getColourValue(); 179 else if (mtm.isA(MT_quaternion)) 180 out << mtm.getQuaternion(); 181 else if (mtm.isA(MT_radian)) 182 out << mtm.getRadian(); 183 else if (mtm.isA(MT_degree)) 184 out << mtm.getDegree(); 185 else 186 out << ((MultiTypeString)mtm); 187 184 out << mtm.toString(); 188 185 return out; 189 186 } -
code/branches/core/src/util/MultiTypeMath.h
r854 r869 60 60 inline MultiTypeMath(const orxonox::Degree& value) { this->setValue(value); } 61 61 inline MultiTypeMath(const MultiTypeMath& mtm) { this->setValue(mtm); } 62 virtual inline ~MultiTypeMath() {} 62 63 63 64 using MultiTypeString::operator=; … … 88 89 bool operator!=(const MultiTypeMath& mtm) const; 89 90 90 operator orxonox::Vector2() const; 91 operator orxonox::Vector3() const; 92 operator orxonox::ColourValue() const; 93 operator orxonox::Quaternion() const; 94 operator orxonox::Radian() const; 95 operator orxonox::Degree() const; 91 virtual operator int() const; 92 virtual operator unsigned int() const; 93 virtual operator char() const; 94 virtual operator unsigned char() const; 95 virtual operator short() const; 96 virtual operator unsigned short() const; 97 virtual operator long() const; 98 virtual operator unsigned long() const; 99 virtual operator float () const; 100 virtual operator double () const; 101 virtual operator long double() const; 102 virtual operator bool() const; 103 virtual operator std::string() const; 104 virtual operator const char*() const; 105 virtual operator orxonox::Vector2() const; 106 virtual operator orxonox::Vector3() const; 107 virtual operator orxonox::ColourValue() const; 108 virtual operator orxonox::Quaternion() const; 109 virtual operator orxonox::Radian() const; 110 virtual operator orxonox::Degree() const; 96 111 97 112 using MultiTypeString::setValue; … … 126 141 inline void getValue(orxonox::Degree* variable) const { (*variable) = orxonox::Degree (this->degree_); } 127 142 128 std::string toString() const;129 bool fromString(const std::string value);143 virtual std::string toString() const; 144 virtual bool fromString(const std::string value); 130 145 131 146 protected: -
code/branches/core/src/util/MultiTypePrimitive.cc
r854 r869 129 129 130 130 MultiTypePrimitive::operator int() const 131 { 132 return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypePrimitive, int>(*this); 133 } 134 131 { return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypePrimitive, int>(*this); } 135 132 MultiTypePrimitive::operator unsigned int() const 136 { 137 return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned int>(*this); 138 } 139 133 { return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned int>(*this); } 140 134 MultiTypePrimitive::operator char() const 141 { 142 return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypePrimitive, char>(*this); 143 } 144 135 { return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypePrimitive, char>(*this); } 145 136 MultiTypePrimitive::operator unsigned char() const 146 { 147 return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned char>(*this); 148 } 149 137 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned char>(*this); } 150 138 MultiTypePrimitive::operator short() const 151 { 152 return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypePrimitive, short>(*this); 153 } 154 139 { return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypePrimitive, short>(*this); } 155 140 MultiTypePrimitive::operator unsigned short() const 156 { 157 return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned short>(*this); 158 } 159 141 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned short>(*this); } 160 142 MultiTypePrimitive::operator long() const 161 { 162 return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypePrimitive, long>(*this); 163 } 164 143 { return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypePrimitive, long>(*this); } 165 144 MultiTypePrimitive::operator unsigned long() const 166 { 167 return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned long>(*this); 168 } 169 145 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned long>(*this); } 170 146 MultiTypePrimitive::operator float() const 171 { 172 return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypePrimitive, float>(*this); 173 } 174 147 { return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypePrimitive, float>(*this); } 175 148 MultiTypePrimitive::operator double() const 176 { 177 return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypePrimitive, double>(*this); 178 } 179 149 { return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypePrimitive, double>(*this); } 180 150 MultiTypePrimitive::operator long double() const 181 { 182 return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypePrimitive, long double>(*this); 183 } 184 151 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypePrimitive, long double>(*this); } 185 152 MultiTypePrimitive::operator bool() const 186 { 187 return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypePrimitive, bool>(*this); 188 } 153 { return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypePrimitive, bool>(*this); } 189 154 190 155 void MultiTypePrimitive::setValue(const MultiTypePrimitive& mtp) … … 258 223 std::ostream& operator<<(std::ostream& out, const MultiTypePrimitive& mtp) 259 224 { 260 if (mtp.isA(MT_int)) 261 out << mtp.getInt(); 262 else if (mtp.isA(MT_uint)) 263 out << mtp.getUnsignedInt(); 264 else if (mtp.isA(MT_char)) 265 out << mtp.getChar(); 266 else if (mtp.isA(MT_uchar)) 267 out << mtp.getUnsignedChar(); 268 else if (mtp.isA(MT_short)) 269 out << mtp.getShort(); 270 else if (mtp.isA(MT_ushort)) 271 out << mtp.getUnsignedShort(); 272 else if (mtp.isA(MT_long)) 273 out << mtp.getLong(); 274 else if (mtp.isA(MT_ulong)) 275 out << mtp.getUnsignedLong(); 276 else if (mtp.isA(MT_float)) 277 out << mtp.getFloat(); 278 else if (mtp.isA(MT_double)) 279 out << mtp.getDouble(); 280 else if (mtp.isA(MT_longdouble)) 281 out << mtp.getLongDouble(); 282 else if (mtp.isA(MT_bool)) 283 out << mtp.getBool(); 284 225 out << mtp.toString(); 285 226 return out; 286 227 } -
code/branches/core/src/util/MultiTypePrimitive.h
r853 r869 53 53 inline MultiTypePrimitive(bool value) { this->setValue(value); } 54 54 inline MultiTypePrimitive(const MultiTypePrimitive& mtp) { this->setValue(mtp); } 55 virtual inline ~MultiTypePrimitive() {} 55 56 56 57 inline MultiTypePrimitive& operator=(MultiType value) { this->type_ = MT_null; return *this; } … … 97 98 bool operator!=(const MultiTypePrimitive& mtp) const; 98 99 99 operator int() const;100 operator unsigned int() const;101 operator char() const;102 operator unsigned char() const;103 operator short() const;104 operator unsigned short() const;105 operator long() const;106 operator unsigned long() const;107 operator float () const;108 operator double () const;109 operator long double() const;110 operator bool() const;100 virtual operator int() const; 101 virtual operator unsigned int() const; 102 virtual operator char() const; 103 virtual operator unsigned char() const; 104 virtual operator short() const; 105 virtual operator unsigned short() const; 106 virtual operator long() const; 107 virtual operator unsigned long() const; 108 virtual operator float () const; 109 virtual operator double () const; 110 virtual operator long double() const; 111 virtual operator bool() const; 111 112 112 113 inline void setValue(int value) { this->type_ = MT_int; this->value_.int_ = value; } … … 166 167 inline bool isA(MultiType type) const { return (this->type_ == type); } 167 168 168 std::string toString() const;169 bool fromString(const std::string value);169 virtual std::string toString() const; 170 virtual bool fromString(const std::string value); 170 171 171 172 protected: -
code/branches/core/src/util/MultiTypeString.cc
r853 r869 64 64 } 65 65 66 MultiTypeString::operator int() const 67 { return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeString, int>(*this); } 68 MultiTypeString::operator unsigned int() const 69 { return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeString, unsigned int>(*this); } 70 MultiTypeString::operator char() const 71 { return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeString, char>(*this); } 72 MultiTypeString::operator unsigned char() const 73 { return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeString, unsigned char>(*this); } 74 MultiTypeString::operator short() const 75 { return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeString, short>(*this); } 76 MultiTypeString::operator unsigned short() const 77 { return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeString, unsigned short>(*this); } 78 MultiTypeString::operator long() const 79 { return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeString, long>(*this); } 80 MultiTypeString::operator unsigned long() const 81 { return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeString, unsigned long>(*this); } 82 MultiTypeString::operator float() const 83 { return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeString, float>(*this); } 84 MultiTypeString::operator double() const 85 { return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeString, double>(*this); } 86 MultiTypeString::operator long double() const 87 { return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeString, long double>(*this); } 88 MultiTypeString::operator bool() const 89 { return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeString, bool>(*this); } 66 90 MultiTypeString::operator std::string() const 67 { 68 return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this); 69 } 70 91 { return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this); } 71 92 MultiTypeString::operator const char*() const 72 { 73 return ((this->type_ == MT_constchar) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this)).c_str(); 74 } 93 { return ((this->type_ == MT_constchar) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this)).c_str(); } 75 94 76 95 void MultiTypeString::setValue(const MultiTypeString& mts) … … 104 123 std::ostream& operator<<(std::ostream& out, MultiTypeString& mts) 105 124 { 106 if (mts.isA(MT_constchar)) 107 out << mts.getConstChar(); 108 else if (mts.isA(MT_string)) 109 out << mts.getString(); 110 else 111 out << ((MultiTypePrimitive)mts); 112 125 out << mts.toString(); 113 126 return out; 114 127 } -
code/branches/core/src/util/MultiTypeString.h
r854 r869 55 55 inline MultiTypeString(const std::string& value) { this->setValue(value); } 56 56 inline MultiTypeString(const MultiTypeString& mts) { this->setValue(mts); } 57 virtual inline ~MultiTypeString() {} 57 58 58 59 using MultiTypePrimitive::operator=; … … 71 72 bool operator!=(const MultiTypeString& mts) const; 72 73 73 operator std::string() const; 74 operator const char*() const; 74 virtual operator int() const; 75 virtual operator unsigned int() const; 76 virtual operator char() const; 77 virtual operator unsigned char() const; 78 virtual operator short() const; 79 virtual operator unsigned short() const; 80 virtual operator long() const; 81 virtual operator unsigned long() const; 82 virtual operator float () const; 83 virtual operator double () const; 84 virtual operator long double() const; 85 virtual operator bool() const; 86 virtual operator std::string() const; 87 virtual operator const char*() const; 75 88 76 89 using MultiTypePrimitive::setValue; … … 89 102 inline void getValue(const char** variable) const { (*variable) = this->string_.c_str(); } 90 103 91 std::string toString() const;92 bool fromString(const std::string value);104 virtual std::string toString() const; 105 virtual bool fromString(const std::string value); 93 106 94 107 protected:
Note: See TracChangeset
for help on using the changeset viewer.