/** * This source file is part of OgreColladaPlugin * an addon for OGRE (Object-oriented Graphics Rendering Engine) * For the latest info, see http://www.ogre3d.org/ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA, or go to * http://www.gnu.org/copyleft/lesser.txt. * * @author Philipp Hartl * @see README */ #ifndef __COLLADA_LIBRARY_H__ #define __COLLADA_LIBRARY_H__ #include "OgreColladaPrerequisites.h" namespace Ogre { namespace ColladaLibrarySpecific { /** * */ enum Type { ANIMATION = 0, CAMERA, CODE, CONTROLLER, GEOMETRY, IMAGE, LIGHT, MATERIAL, PROGRAM, TEXTURE, UNKNOWN = -1 }; /** * compare the string with collada syntax * * @param s the semantic string we have * @return the corresponding library type */ Type getType(const String &s); } /** * a template libray class * used by all possible library types * holds all entities of the library type T */ template class ColladaLibrary { public: ColladaLibrary(); ~ColladaLibrary(); /** * create new instance of library type * for each instance importId() is called * * @param doc everything belongs to the document * @param node the library node we want to import * @return void */ void initialise(ColladaDocument *doc, xmlNode *node); /** * find library entity by identifier and return a pointer on it * * @param id the string identifier * @return a pointer at existing instance or NULL */ T *getEntity(const String &id) const; private: typedef std::vector ColladaLibraryVector; ColladaLibraryVector mEntities; // a vector with all entities of }; /** * library container * holds all nodes in collada document */ class ColladaLibraryContainer { public: ColladaLibraryContainer(ColladaDocument *doc); ~ColladaLibraryContainer(void); /** * import the node, identified by its id * look in possible library entities, CAMERA, GEOMETRY, LIGHT, ... * * @param id the string identifier * @return a pointer on the successfully imported node, NULL otherwise */ ColladaEntity *importInstance(const String &id); /** * import node and fill up the specific library entity * by the type, which can be: CAMERA, GEOMETRY, LIGHT, MATERIAL, TEXTURE, ... * in first step we only want to know the id and name of the node * * @param node the library node we want to import * @return void */ void doImport(xmlNode *node); /** * find the entity by its identifier * * @param id the string identifier we are looking for * @return a pointer on it, NULL otherwise */ ColladaCamera *getCamera(const String &id) const; ColladaImage *getImage(const String &id) const; ColladaLight *getLight(const String &id) const; ColladaMaterial *getMaterial(const String &id) const; ColladaTexture *getTexture(const String &id) const; private: ColladaDocument *mDoc; // library entities ColladaLibrary *mCameras; ColladaLibrary *mGeometries; ColladaLibrary *mImages; ColladaLibrary *mLights; ColladaLibrary *mMaterials; ColladaLibrary *mTextures; }; } #endif // __COLLADA_LIBRARY_H__