Changeset 599 for code/branches/FICN/src/orxonox/objects
- Timestamp:
- Dec 17, 2007, 9:56:47 PM (17 years ago)
- Location:
- code/branches/FICN/src/orxonox/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/objects/SceneNode.cc
r590 r599 25 25 void SceneNode::loadParams(TiXmlElement* xmlElem) 26 26 { 27 Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();28 29 27 if (xmlElem->Attribute("name") && xmlElem->Attribute("pos")) 30 28 { 31 std::string name= xmlElem->Attribute("name");29 name_ = xmlElem->Attribute("name"); 32 30 33 31 std::vector<std::string> pos = tokenize(xmlElem->Attribute("pos"),","); 34 float x, y, z;35 String2Number<float>(x , pos[0]);36 String2Number<float>(y , pos[1]);37 String2Number<float>(z , pos[2]);32 //float x, y, z_; 33 String2Number<float>(x_, pos[0]); 34 String2Number<float>(y_, pos[1]); 35 String2Number<float>(z_, pos[2]); 38 36 39 float sx = 1, sy = 1, sz= 1;37 sx_ = 1; sy_ = 1; sz_ = 1; 40 38 if (xmlElem->Attribute("scale")) 41 39 { 42 40 pos = tokenize(xmlElem->Attribute("scale"),","); 43 String2Number<float>(sx, pos[0]); 44 String2Number<float>(sy, pos[1]); 45 String2Number<float>(sz, pos[2]); 41 String2Number<float>(sx_, pos[0]); 42 String2Number<float>(sy_, pos[1]); 43 String2Number<float>(sz_, pos[2]); 44 } 45 yaw_ = 0.0; 46 if (xmlElem->Attribute("yaw")) 47 { 48 String2Number<float>(yaw_,xmlElem->Attribute("yaw")); 49 } 50 pitch_ = 0.0; 51 if (xmlElem->Attribute("pitch")) 52 { 53 String2Number<float>(pitch_,xmlElem->Attribute("pitch")); 54 } 55 roll_ = 0.0; 56 if (xmlElem->Attribute("roll")) 57 { 58 String2Number<float>(roll_,xmlElem->Attribute("roll")); 46 59 } 47 60 48 float yaw = 0.0; 49 if (xmlElem->Attribute("yaw")) 50 { 51 String2Number<float>(yaw,xmlElem->Attribute("yaw")); 52 } 53 float pitch = 0.0; 54 if (xmlElem->Attribute("pitch")) 55 { 56 String2Number<float>(pitch,xmlElem->Attribute("pitch")); 57 } 58 float roll = 0.0; 59 if (xmlElem->Attribute("roll")) 60 { 61 String2Number<float>(roll,xmlElem->Attribute("roll")); 62 } 61 if(xmlElem->Attribute("node")) 62 nodeName_ = xmlElem->Attribute("node"); 63 else 64 nodeName_ = ""; 65 66 create(); 63 67 64 Ogre::SceneNode *parentNode; 65 if (xmlElem->Attribute("node")) 66 parentNode = mgr->getSceneNode(xmlElem->Attribute("node")); 67 else 68 parentNode = mgr->getRootSceneNode(); 69 70 Ogre::SceneNode* node = parentNode->createChildSceneNode(name, Vector3(x,y,z)); 71 node->scale(sx,sy,sz); 72 node->yaw(Ogre::Degree(yaw)); 73 node->pitch(Ogre::Degree(pitch)); 74 node->roll(Ogre::Degree(roll)); 75 76 COUT(4) << "Loader: Created node "<< name <<" : "<<x<<" " << y << " " << z << std::endl << std::endl; 68 COUT(4) << "Loader: loaded node "<< name_ <<" : "<< x_ <<" " << y_ << " " << z_ << std::endl << std::endl; 77 69 } 78 70 } 79 71 80 72 void SceneNode::registerAllVariables(){ 81 73 registerVar(&x_, sizeof(float), network::DATA); 74 registerVar(&y_, sizeof(float), network::DATA); 75 registerVar(&z_, sizeof(float), network::DATA); 76 registerVar(&sx_, sizeof(float), network::DATA); 77 registerVar(&sy_, sizeof(float), network::DATA); 78 registerVar(&sz_, sizeof(float), network::DATA); 79 registerVar(&yaw_, sizeof(float), network::DATA); 80 registerVar(&pitch_, sizeof(float), network::DATA); 81 registerVar(&roll_, sizeof(float), network::DATA); 82 registerVar(&name_, sizeof(float), network::STRING); 83 registerVar(&nodeName_, sizeof(float), network::STRING); 82 84 } 83 85 84 86 bool SceneNode::create(){ 87 Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager(); 88 89 Ogre::SceneNode *parentNode; 90 if (nodeName_.compare("")!=0) 91 parentNode = mgr->getSceneNode(nodeName_); 92 else 93 parentNode = mgr->getRootSceneNode(); 94 95 Ogre::SceneNode* node = parentNode->createChildSceneNode(name_, Vector3(x_,y_,z_)); 96 node->scale(sx_,sy_,sz_); 97 node->yaw(Ogre::Degree(yaw_)); 98 node->pitch(Ogre::Degree(pitch_)); 99 node->roll(Ogre::Degree(roll_)); 85 100 return true; 86 101 } -
code/branches/FICN/src/orxonox/objects/SceneNode.h
r590 r599 23 23 float sx_, sy_, sz_; 24 24 float yaw_, pitch_, roll_; 25 std::string node_; 25 std::string name_; 26 std::string nodeName_; 26 27 27 28 };
Note: See TracChangeset
for help on using the changeset viewer.