// Add at the end .......................................................... FileName FileName::addExtension(const String &ext) const { if (ext == "") return *this; else { FileName retval = *this; retval = retval.append((String) "." + ext); return retval; } }
vector<KeyFrame> ModelLoaderMD3::buildKeyFrame(Surface * surfaces, const FileName &fileName, const FileName &skinName, const Header &header, TextureFactory &textureFactory) { vector<KeyFrame> keyFrames; const FileName directory = fileName.getPath(); /* Only the first frame loads texture files. The other frames use a copy of the handles and that copy is stored in here. */ Material md3Material; // Take the all the surfaces and push each frame into the mesh manager for (int i=0; i<surfaces[0].header.numFrames; ++i) { string name = fileName.str() + "#" + itos(i); // Create a mesh from the surface Mesh *mesh = surfaces[0].getObject(i); // Load a material for the first mesh in the first model. // First model only! Ignored for subsequent models if (i==0) { if (header.numSurfaces > 0) { mesh->material.clear(); #if 0 if (surfaces[0].header.numShaders > 0) { const char *shaderName=(char*)surfaces[0].shaders[0].name; FileName skin = directory.append(FileName(shaderName)); mesh->material.setTexture(textureFactory.load(skin)); } else { mesh->material.setTexture(textureFactory.load(skinName)); } #else mesh->material.setTexture(textureFactory.load(skinName)); #endif // Keep a copy of the material to propagate to the subsequent frames md3Material = mesh->material; } } else { mesh->material = md3Material; // shallow copy } keyFrames.push_back(KeyFrame(mesh)); } return keyFrames; }
/*! Injects the info gathered by the XML parser into the Entry tree. * This tree contains the information extracted from the input in a * "unrelated" form. */ void TagFileParser::buildLists(Entry *root) { // build class list TagClassInfo *tci = m_tagFileClasses.first(); while (tci) { Entry *ce = new Entry; ce->section = Entry::CLASS_SEC; switch (tci->kind) { case TagClassInfo::Class: break; case TagClassInfo::Struct: ce->spec = Entry::Struct; break; case TagClassInfo::Union: ce->spec = Entry::Union; break; case TagClassInfo::Interface: ce->spec = Entry::Interface; break; case TagClassInfo::Exception: ce->spec = Entry::Exception; break; case TagClassInfo::Protocol: ce->spec = Entry::Protocol; break; case TagClassInfo::Category: ce->spec = Entry::Category; break; } ce->name = tci->name; if (tci->kind==TagClassInfo::Protocol) { ce->name+="-p"; } addDocAnchors(ce,tci->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tci->filename; ce->tagInfo = ti; ce->lang = tci->isObjC ? SrcLangExt_ObjC : SrcLangExt_Unknown; // transfer base class list if (tci->bases) { delete ce->extends; ce->extends = tci->bases; tci->bases = 0; } if (tci->templateArguments) { if (ce->tArgLists==0) { ce->tArgLists = new QList<ArgumentList>; ce->tArgLists->setAutoDelete(TRUE); } ArgumentList *al = new ArgumentList; ce->tArgLists->append(al); QListIterator<QCString> sli(*tci->templateArguments); QCString *argName; for (;(argName=sli.current());++sli) { Argument *a = new Argument; a->type = "class"; a->name = *argName; al->append(a); } } buildMemberList(ce,tci->members); root->addSubEntry(ce); tci = m_tagFileClasses.next(); } // build file list TagFileInfo *tfi = m_tagFileFiles.first(); while (tfi) { Entry *fe = new Entry; fe->section = guessSection(tfi->name); fe->name = tfi->name; addDocAnchors(fe,tfi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tfi->filename; fe->tagInfo = ti; QCString fullName = m_tagName+":"+tfi->path+stripPath(tfi->name); fe->fileName = fullName; //printf("new FileDef() filename=%s\n",tfi->filename.data()); FileDef *fd = new FileDef(m_tagName+":"+tfi->path, tfi->name,m_tagName, tfi->filename ); FileName *mn; if ((mn=Doxygen::inputNameDict->find(tfi->name))) { mn->append(fd); } else { mn = new FileName(fullName,tfi->name); mn->append(fd); Doxygen::inputNameList->inSort(mn); Doxygen::inputNameDict->insert(tfi->name,mn); } buildMemberList(fe,tfi->members); root->addSubEntry(fe); tfi = m_tagFileFiles.next(); } // build namespace list TagNamespaceInfo *tni = m_tagFileNamespaces.first(); while (tni) { Entry *ne = new Entry; ne->section = Entry::NAMESPACE_SEC; ne->name = tni->name; addDocAnchors(ne,tni->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tni->filename; ne->tagInfo = ti; buildMemberList(ne,tni->members); root->addSubEntry(ne); tni = m_tagFileNamespaces.next(); } // build package list TagPackageInfo *tpgi = m_tagFilePackages.first(); while (tpgi) { Entry *pe = new Entry; pe->section = Entry::PACKAGE_SEC; pe->name = tpgi->name; addDocAnchors(pe,tpgi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tpgi->filename; pe->tagInfo = ti; buildMemberList(pe,tpgi->members); root->addSubEntry(pe); tpgi = m_tagFilePackages.next(); } // build group list, but only if config file says to include it //if (Config_getBool("EXTERNAL_GROUPS")) //{ TagGroupInfo *tgi = m_tagFileGroups.first(); while (tgi) { Entry *ge = new Entry; ge->section = Entry::GROUPDOC_SEC; ge->name = tgi->name; ge->type = tgi->title; addDocAnchors(ge,tgi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tgi->filename; ge->tagInfo = ti; buildMemberList(ge,tgi->members); root->addSubEntry(ge); tgi = m_tagFileGroups.next(); } //} // build page list TagPageInfo *tpi = m_tagFilePages.first(); while (tpi) { Entry *pe = new Entry; pe->section = Entry::PAGEDOC_SEC; pe->name = tpi->name; pe->args = tpi->title; addDocAnchors(pe,tpi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tpi->filename; pe->tagInfo = ti; root->addSubEntry(pe); tpi = m_tagFilePages.next(); } }
AnimationController* ModelLoaderSingle::loadFromFile(const FileName &fileName, TextureFactory &textureFactory) const { PropertyBag xml = PropertyBag::fromFile(fileName); const FileName directory = fileName.getPath(); // Winding of polygons, either "CCW" or "CW" string polygonWinding = "CW"; xml.get("polygonWinding", polygonWinding); // Allocate a blank animation controller AnimationController *controller = new AnimationController(); // Get key frames from the first source PropertyBag fileBag = xml.getBag("model", 0); const FileName file = directory.append(fileBag.getFileName("file")); FileName skinName; if(fileBag.get("skin", skinName)) { skinName = directory.append(skinName); } vector<KeyFrame> keyFrames = loadKeyFrames(file, skinName, textureFactory); // Get the rest of the key frames for(size_t i = 1, numMD3 = xml.getNumInstances("model"); i<numMD3; ++i) { PropertyBag fileBag = xml.getBag("model", i); const FileName file = directory.append(fileBag.getFileName("file")); FileName skinName; if(fileBag.get("skin", skinName)) { skinName = directory.append(skinName); } vector<KeyFrame> k = loadKeyFrames(file, skinName, textureFactory); for(size_t i=0; i<k.size(); ++i) { KeyFrame &keyFrame = keyFrames[i]; keyFrame.merge(k[i]); // set polygon windings according to data file setPolygonWinding(keyFrame, polygonWinding); } } // Build the animations from these keyframes for(size_t i = 0, numAnimations = xml.getNumInstances("animation"); i<numAnimations; ++i) { PropertyBag animation; string name; bool looping=false; int start=0; float priority=0; int length=0; float fps=0; xml.get("animation", animation, i); animation.get("name", name); animation.get("priority", priority); animation.get("looping", looping); animation.get("start", start); animation.get("length", length); animation.get("fps", fps); // Add it to the controller AnimationSequence animationSequence(keyFrames, name, priority, looping, start, length, fps); controller->addAnimation(animationSequence); } return controller; }
// Insert before extension ................................................. FileName FileName::insertBeforeExtension(const String &str) const { FileName retval = *this; size_t pos = find_last_of('.'); return pos != npos ? retval.insert(pos, str) : retval.append(str); }