本文整理汇总了C++中ChunkList::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ChunkList::get方法的具体用法?C++ ChunkList::get怎么用?C++ ChunkList::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChunkList
的用法示例。
在下文中一共展示了ChunkList::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert
void convert(const std::string& pInFileName, const std::string& pOutFileName) {
ChunkList* root = ChunkReader::loadFile(pInFileName);
for(ChunksResult res = root->get("scene"); res != root->end(); ++res) {
if( res->first != "scene" ) break;
const ChildList& scene = res->second->getChildList();
const std::string title = asStringChild(scene.childAt(0))->value();
cout << "Converting " << title << ": " << endl;
TiXmlDocument doc;
doc.LinkEndChild( new TiXmlDeclaration( "1.0", "", "" ) );
TiXmlElement* level = new TiXmlElement("level");
for(unsigned long childIndex=0; childIndex < scene.count(); ++childIndex) {
const Child* baseChild = scene.childAt(childIndex);
if( baseChild->getType() == CCT_CHILD ) {
const Chunk* chunk = asChunkChild( baseChild )->getChild();
// is chunk an "entity"
if( chunk->getName().getName() == "objectelement" ) {
const ChildList& entity = chunk->getChildList();
// name
const std::string name = asStringChild(entity.childAt(0))->value();
// type
const std::string type = asStringChild(entity.childAt(1))->value();
TiXmlElement* object = new TiXmlElement("entity");
object->SetAttribute("name", name);
object->SetAttribute("type", type);
TiXmlElement* position = new TiXmlElement("position");
TiXmlElement* rotation = new TiXmlElement("rotation");
{
float x=0, y=0, z=0;
if( entity.has("loc") ) {
const CompoundChild* location = asCompoundChild(entity.at("loc")->getChildList().childAt(0));
x = getRealValue(location->at(0));
y = getRealValue(location->at(1));
z = getRealValue(location->at(2));
}
position->SetAttribute("x", asString(x));
position->SetAttribute("y", asString(y));
position->SetAttribute("z", asString(z));
}
{
float x=0, y=0, z=0, w=1;
if( entity.has("orientation") ) {
const CompoundChild* location = asCompoundChild(entity.at("orientation")->getChildList().childAt(0));
x = getRealValue(location->at(0));
y = getRealValue(location->at(1));
z = getRealValue(location->at(2));
w = getRealValue(location->at(3));
}
rotation->SetAttribute("x", asString(x));
rotation->SetAttribute("y", asString(y));
rotation->SetAttribute("z", asString(z));
rotation->SetAttribute("w", asString(w));
}
object->LinkEndChild(position);
object->LinkEndChild(rotation);
level->LinkEndChild(object);
}
}
}
doc.LinkEndChild( level );
const string saveFile = pOutFileName + title + ".lvl";
cout << "Saving to " << saveFile << endl;
doc.SaveFile( saveFile );
}
}