void ofxFlashXFLBuilder :: buildLayers () { int numOfLayers; numOfLayers = getNumTags( "DOMLayer" ); for( int i=numOfLayers-1; i>=0; i-- ) // work backwards through layers. so when adding to stage, objects sit in right order. { DOMLayer dom; dom.name = getAttribute( "DOMLayer", "name", "", i ); dom.color = getAttribute( "DOMLayer", "color", 0, i ); dom.locked = getAttribute( "DOMLayer", "locked", false, i ); dom.current = getAttribute( "DOMLayer", "current", false, i ); dom.isSelected = getAttribute( "DOMLayer", "isSelected", false, i ); dom.autoNamed = getAttribute( "DOMLayer", "autoNamed", false, i ); dom.layerType = getAttribute( "DOMLayer", "layerType", "", i ); domLayer = dom; if( domLayer.layerType == "guide" ) // skip guide layers. continue; pushTag( "DOMLayer", i ); pushTag( "frames", 0 ); buildFrames(); popTag(); popTag(); } }
int MD5Model::loadAnim(const char *filename) { // attempt to open file for reading std::ifstream fin(filename, std::ifstream::in); if (!fin.is_open()) { std::string msg = std::string("MD5Model::loadAnim(): unable to open ") + std::string(filename) + std::string(" for reading"); throw Exception(msg); } // read in file version std::string str; getNextToken(fin, &str); // token must read "MD5Version" if (str != "MD5Version") throw Exception("MD5Model::loadAnim(): expected 'MD5Version'"); // get version # int ver = readInt(fin); // must be version 10 if (ver != 10) throw Exception("MD5Model::loadAnim(): MD5Version must be 10"); Anim *anim = new Anim; if (!anim) throw Exception("MD5Model::loadAnim(): could not allocate storage for animation"); readAnimElements(fin, *anim); // close file (should be done by destructor anyway) fin.close(); // add to array of animations int animIndex = (int)anims.size(); anims.push_back(anim); // build frames for this animation buildFrames(*anim); // make this the current animation setAnim(animIndex, 0); return animIndex; }
Assets::EntityModel* Md2Parser::buildModel(const Md2SkinList& skins, const Md2FrameList& frames, const Md2MeshList& meshes) { const Assets::TextureList modelTextures = loadTextures(skins); const Assets::Md2Model::FrameList modelFrames = buildFrames(frames, meshes); return new Assets::Md2Model(m_name, modelTextures, modelFrames); }