- Timestamp:
- Mar 19, 2008, 12:38:32 AM (17 years ago)
- Location:
- code/branches/core2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/bin/levels/sample.oxw
r871 r901 1 <Namespace name="test" /> 2 <Namespace name="blub" /> 3 <Namespace name="rofl" /> 4 5 <Namespace name="ns1"> 6 <Namespace name="ns11"> 7 <Namespace name="ns111"> 8 </Namespace> 9 <Namespace name="ns112"> 10 </Namespace> 11 </Namespace> 12 <Namespace name="ns12"> 13 <Namespace name="ns121"> 14 </Namespace> 15 <Namespace name="ns122"> 16 </Namespace> 17 </Namespace> 18 </Namespace> 19 20 <Namespace name="ns1::ns12::ns121"> 21 <Namespace name="ns1211"> 22 </Namespace> 23 </Namespace> 24 <Namespace name="ns1::ns12::ns122::ns1221" /> 25 1 26 <!-- 2 27 <audio> … … 23 48 <NPC position="100,0,400" scale="1" mesh="razor.mesh"/> 24 49 25 <Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" /> 26 <Model name="drone" position="-200,0,500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0"> 27 <attached> 28 <Model name="drone2" position="200,-100,-500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0"> 29 <attached> 30 <Model name="starship2" position="500,200,-500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" /> 31 </attached> 32 </Model> 33 </attached> 34 </Model> 50 <Namespace name="starshipanddrone"> 51 <Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" /> 52 <Model name="drone" position="-200,0,500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0"> 53 <attached> 54 <Model name="drone2" position="200,-100,-500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0"> 55 <attached> 56 <Model name="starship2" position="500,200,-500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" /> 57 </attached> 58 </Model> 59 </attached> 60 </Model> 61 </Namespace> 35 62 36 63 <Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" /> … … 40 67 <Model position="-200,1000,500" scale="10" mesh="hoover_turbine.mesh" yawpitchroll="-90,-90,0" /> 41 68 69 <Namespace name="test" /> 70 <Namespace name="blub"> 71 </Namespace> 72 <Namespace name="rofl"> 73 <Namespace name="lol"> 74 </Namespace> 75 </Namespace> 76 77 <Namespace name="ns1"> 78 <Namespace name="ns11"> 79 <Namespace name="ns111"> 80 <Namespace name="ns1111"> 81 </Namespace> 82 </Namespace> 83 </Namespace> 84 <Namespace name="ns13"> 85 </Namespace> 86 </Namespace> 87 88 <Namespace name="ns1 ns2"> 89 <Namespace name="abc" /> 90 </Namespace> 91 92 <Namespace name="ns1::ns11 ns1::ns12 ns1::ns12::ns121"> 93 <Namespace name="muhahaha" /> 94 </Namespace> 95 96 <Namespace name="test"> 97 <Namespace name="test" /> 98 </Namespace> 99 100 <Namespace name="ns1::ns13"> 101 <Namespace name="..::ns14" /> 102 <Namespace name="..::..::ns3" /> 103 </Namespace> 104 105 <Namespace name="AAA::BBB::..::CCC::..::DDD::..::BBB::BBBBBB::..::BBBBBBBBBBBBBBBBBBB::..::..::EEE" /> 106 107 <Namespace name="..::justatest" /> 108 109 <Namespace name="@file.oxw::anothertest" /> 110 111 <Namespace name="justonemoretest::@file.oxw::gagagaga" /> 112 113 <Namespace name="AAA::BBB, AAA::CCC; AAA::DDD,AAA::EEE"> 114 <Namespace name="hax" /> 115 </Namespace> 116 42 117 <Model position="-16779,42,11043" scale="95" mesh="ast2.mesh" rotationAxis="0.281711,0.152518,0" rotationRate="27" /> 43 118 <Model position="12893,-1583,-17939" scale="48" mesh="ast1.mesh" rotationAxis="0.0597998,0.923364,0" rotationRate="36" /> … … 45 120 <Model position="-9583,-2284,-19904" scale="33" mesh="ast5.mesh" rotationAxis="0,0.675659,0.0196445" rotationRate="44" /> 46 121 <Model position="-19597,-15494,3163" scale="37" mesh="ast5.mesh" rotationAxis="0.477996,0,0.048639" rotationRate="23" /> 47 < Model position="-182,6442,-4496" scale="25" mesh="ast5.mesh" rotationAxis="0.142225,0,0.154393" rotationRate="37" />122 <!--Model position="-182,6442,-4496" scale="25" mesh="ast5.mesh" rotationAxis="0.142225,0,0.154393" rotationRate="37" /> 48 123 <Model position="1004,-19639,-13744" scale="21" mesh="ast1.mesh" rotationAxis="0.974865,0.299775,0" rotationRate="29" /> 49 124 <Model position="-13204,-10191,-1555" scale="31" mesh="ast1.mesh" rotationAxis="0.41675,0,0.385001" rotationRate="42" /> … … 266 341 <Model position="1991,-11949,-15733" scale="68" mesh="ast1.mesh" rotationAxis="0,0.390655,0.623811" rotationRate="41" /> 267 342 <Model position="-6787,1792,287" scale="71" mesh="ast6.mesh" rotationAxis="0.161019,0.130015,0" rotationRate="36" /> 268 <Model position="-7223,-13574,-11873" scale="24" mesh="ast4.mesh" rotationAxis="0.792203,0,0.177188" rotationRate="38" / >343 <Model position="-7223,-13574,-11873" scale="24" mesh="ast4.mesh" rotationAxis="0.792203,0,0.177188" rotationRate="38" /--> -
code/branches/core2/src/orxonox/core/Loader.cc
r899 r901 115 115 ticpp::Document xmlfile(level->getFile()); 116 116 xmlfile.LoadFile(); 117 117 118 ticpp::Element rootElement; 118 119 rootElement.SetAttribute("name", "root"); 120 rootElement.SetAttribute("bAutogenerated", true); 119 121 120 122 for (ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++) … … 126 128 rootNamespace->setLevel(level); 127 129 rootNamespace->setNamespace(rootNamespace); 128 rootNamespace-> deleteNamespaceNodesAfterDestruction(true);130 rootNamespace->setRoot(true); 129 131 rootNamespace->XMLPort(rootElement, true); 130 132 131 133 COUT(0) << "Finished loading " << level->getFile() << "." << std::endl; 134 135 COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString(" ") << std::endl; 132 136 133 137 return true; -
code/branches/core2/src/orxonox/core/Namespace.cc
r898 r901 41 41 42 42 this->bAutogeneratedFileRootNamespace_ = false; 43 this->b DeleteNamespaceNodesAfterDestruction_ = false;43 this->bRoot_ = false; 44 44 this->operator_ = "or"; 45 45 } … … 47 47 Namespace::~Namespace() 48 48 { 49 if (this->b DeleteNamespaceNodesAfterDestruction_)49 if (this->bRoot_) 50 50 for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it) 51 51 delete (*it); … … 73 73 name.replace(pos, 1, " "); 74 74 SubString tokens(name, " ", "", false, '\\', '"', '\0', '\0', '\0'); 75 for (unsigned int i = 0; i < tokens.size(); i++)75 if (this->bRoot_) 76 76 { 77 for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it) 77 this->representingNamespaces_.insert(new NamespaceNode(this->getName())); 78 } 79 else 80 { 81 for (unsigned int i = 0; i < tokens.size(); i++) 78 82 { 79 std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]); 80 this->representingNamespaces_.insert(temp.begin(), temp.end()); 83 for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it) 84 { 85 std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]); 86 this->representingNamespaces_.insert(temp.begin(), temp.end()); 87 } 81 88 } 82 89 } … … 138 145 return false; 139 146 } 147 148 std::string Namespace::toString() const 149 { 150 std::string output; 151 152 int i = 0; 153 for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it) 154 { 155 if (i > 0) 156 output += " / "; 157 158 output += (*it)->toString(); 159 } 160 161 return output; 162 } 163 164 std::string Namespace::toString(const std::string& indentation) const 165 { 166 std::string output; 167 168 int i = 0; 169 for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it) 170 { 171 if (i > 0) 172 output += "\n"; 173 174 output += (*it)->toString(indentation); 175 } 176 177 return output; 178 } 140 179 } -
code/branches/core2/src/orxonox/core/Namespace.h
r896 r901 59 59 { return this->operator_; } 60 60 61 void setRoot(bool bRoot) 62 { this->bRoot_ = bRoot; } 63 61 64 bool includes(const Namespace* ns) const; 62 65 bool isIncludedIn(const Namespace* ns) const { return ns->includes(this); } 63 66 64 void deleteNamespaceNodesAfterDestruction(bool bDelete)65 { this->bDeleteNamespaceNodesAfterDestruction_ = bDelete; }67 std::string toString() const; 68 std::string toString(const std::string& indentation) const; 66 69 67 70 private: 68 71 std::set<NamespaceNode*> representingNamespaces_; 69 72 bool bAutogeneratedFileRootNamespace_; 70 bool b DeleteNamespaceNodesAfterDestruction_;73 bool bRoot_; 71 74 std::string operator_; 72 75 }; -
code/branches/core2/src/orxonox/core/NamespaceNode.cc
r895 r901 49 49 std::set<NamespaceNode*> nodes; 50 50 51 if ( name == "")51 if ((name.size() == 0) || (name == "")) 52 52 { 53 53 nodes.insert(this); … … 56 56 { 57 57 unsigned int pos = name.find("::"); 58 std::string firstPart = name.substr(0, pos); 59 std::string secondPart = name.substr(pos + 2, std::string::npos); 58 std::string firstPart = name; 59 std::string secondPart; 60 61 if (pos != std::string::npos) 62 { 63 firstPart = name.substr(0, pos); 64 secondPart = name.substr(pos + 2, std::string::npos); 65 } 60 66 61 67 if (firstPart == "..") … … 64 70 { 65 71 COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << std::endl; 72 nodes = this->getNodeRelative(secondPart); 73 } 74 else if (!this->parent_) 75 { 76 COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << std::endl; 66 77 nodes = this->getNodeRelative(secondPart); 67 78 } … … 78 89 79 90 if ((*it).second->isHidden()) 91 { 80 92 COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl; 93 nodes.insert(this); 94 } 81 95 else 96 { 82 97 nodes = (*it).second->getNodeRelative(secondPart); 98 } 83 99 } 84 100 else 85 101 { 102 bool bFoundMatchingNamespace = false; 103 86 104 for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it) 87 105 { … … 90 108 std::set<NamespaceNode*> temp2 = (*it).second->getNodeRelative(secondPart); 91 109 nodes.insert(temp2.begin(), temp2.end()); 110 bFoundMatchingNamespace = true; 92 111 } 112 } 113 114 if (!bFoundMatchingNamespace) 115 { 116 COUT(2) << "Warning: No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << std::endl; 117 nodes = this->getNodeRelative(secondPart); 93 118 } 94 119 } … … 113 138 return false; 114 139 } 140 141 std::string NamespaceNode::toString() const 142 { 143 std::string output = this->name_; 144 145 if (this->subnodes_.size() > 0) 146 { 147 output += " ("; 148 149 int i = 0; 150 for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); i++, ++it) 151 { 152 if (i > 0) 153 output += ", "; 154 155 output += (*it).second->toString(); 156 } 157 158 output += ")"; 159 } 160 161 return output; 162 } 163 164 std::string NamespaceNode::toString(const std::string& indentation) const 165 { 166 std::string output = (indentation + this->name_ + "\n"); 167 168 for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it) 169 output += (*it).second->toString(indentation + " "); 170 171 return output; 172 } 115 173 } -
code/branches/core2/src/orxonox/core/NamespaceNode.h
r895 r901 53 53 bool includes(const NamespaceNode*) const; 54 54 55 std::string toString() const; 56 std::string toString(const std::string& indentation) const; 57 55 58 private: 56 59 std::string name_; -
code/branches/core2/src/orxonox/core/XMLPort.h
r898 r901 256 256 newObject->setNamespace(object->getNamespace()); 257 257 if (this->bLoadBefore_) 258 { 258 259 newObject->XMLPort(*child, true); 259 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->classname_ << " (objectname " << object->getName() << ")" << std::endl; 260 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->classname_ << " (objectname " << object->getName() << ")" << std::endl; 261 } 262 else 263 { 264 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->classname_ << " (objectname " << object->getName() << ")" << std::endl; 265 } 260 266 (*object.*this->loadfunction_)(newObject); 261 267 if (!this->bLoadBefore_)
Note: See TracChangeset
for help on using the changeset viewer.