Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGOBJSceneFileType.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011  \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  * 2002/10/16: added transparency path. Thanks to Franck Sourdin             *
00033  *            (sourdin@ai.cluny.ensam.fr) for it!                            *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _OSGOBJSCENEFILETYPE_H_
00040 #define _OSGOBJSCENEFILETYPE_H_
00041 #ifdef  __sgi
00042 #pragma  once
00043 #endif
00044 
00045 #include <OSGBaseTypes.h>
00046 
00047 #include "OSGSceneFileType.h"
00048 
00049 #include <map>
00050 
00051 
00052 OSG_BEGIN_NAMESPACE
00053 
00057 class OSG_SYSTEMLIB_DLLMAPPING OBJSceneFileType : public SceneFileType
00058 {
00059     /*==========================  PUBLIC  =================================*/
00060   public:
00061 
00062     /*---------------------------------------------------------------------*/
00066     static OBJSceneFileType &the(void);
00067 
00069     /*---------------------------------------------------------------------*/
00073     virtual ~OBJSceneFileType(void);
00074 
00076     /*---------------------------------------------------------------------*/
00080     virtual const Char8 *getName(void) const;
00081 
00083     /*---------------------------------------------------------------------*/
00087     virtual NodePtr read(std::istream &is,
00088                          const Char8 *fileNameOrExtension) const;
00089 
00091     /*=========================  PROTECTED  ===============================*/
00092   protected:
00093 
00094     /*---------------------------------------------------------------------*/
00098     static const Char8            *_suffixA[];
00099     static       OBJSceneFileType  _the;
00100 
00102     /*---------------------------------------------------------------------*/
00106     OBJSceneFileType(const Char8  *suffixArray[],
00107                            UInt16  suffixByteCount,
00108                            bool    override,
00109                            UInt32  overridePriority,
00110                            UInt32  flags);
00111 
00112     OBJSceneFileType(const OBJSceneFileType &obj);
00113 
00115     /*==========================  PRIVATE  ================================*/
00116   private:
00117 
00118     typedef SceneFileType Inherited;
00119 
00120     enum DataElem
00121     {
00122       UNKNOWN_DE = 0,
00123 
00124       VERTEX_DE, VERTEX_TEXTURECOORD_DE, VERTEX_NORMAL_DE,
00125       FACE_DE,
00126 
00127       LIB_MTL_DE,
00128       USE_MTL_DE,
00129 
00130       GROUP_DE, SMOOTHING_GROUP_DE, OBJECT_DE
00131     };
00132 
00133     std::map<std::string, DataElem> _dataElemMap;
00134 
00135     enum MaterialElem
00136     {
00137       UNKNOWN_ME = 0,
00138 
00139       NEW_MTL_ME,
00140       MTL_DIFFUSE_ME, MTL_AMBIENT_ME, MTL_SPECULAR_ME,
00141       MTL_SHININESS_ME, MTL_ILLUM_ME,
00142       MTL_TRANSPARENCY_ME,
00143       MTL_MAP_KD_ME, MTL_MAP_KA_ME, MTL_MAP_KS_ME,
00144       MTL_REFL_ME
00145     };
00146 
00147     std::map<std::string, MaterialElem> _mtlElemMap;
00148 
00149     void initElemMap(void);
00150 
00151     class Mesh;
00152     friend class Mesh;
00153 
00154     class Face;
00155     friend class Face;
00156 
00157     struct TiePoint
00158     {
00159         Int32 index[3];
00160         TiePoint( Int32 v = -1, Int32 vt = -1, Int32 vn = -1 )
00161             { index[0] = v; index[1] = vt; index[2] = vn; }
00162         inline void set ( Int32 v = -1, Int32 vt = -1, Int32 vn = -1 )
00163             { index[0] = v; index[1] = vt; index[2] = vn; }
00164     };
00165 
00166     struct Face
00167     {
00168         std::vector<TiePoint> tieVec;
00169     };
00170 
00171     struct Mesh {
00172       std::string name;
00173       std::list<Face> faceList;
00174       SimpleMaterialPtr mtlPtr;
00175     };
00176 
00177 
00178     Int32 readMTL (const Char8 *fileName,
00179                    std::map<std::string,
00180                    SimpleTexturedMaterialPtr> &mtlMap  ) const;
00181 
00182     /* prohibit default function (move to 'public' if needed) */
00183     void operator =(const OBJSceneFileType &source);
00184 };
00185 
00186 typedef OBJSceneFileType* OBJSceneFileTypeP;
00187 
00188 OSG_END_NAMESPACE
00189 
00190 #define OSGOBJSCENEFILETYPE_HEADER_CVSID "@(#)$Id: OSGOBJSceneFileType.h,v 1.12 2002/02/04 16:08:09 dirk Exp $"
00191 
00192 #endif // _OSGOBJSCENEFILETYPE_H_
00193 

Generated on Thu Aug 25 04:07:58 2005 for OpenSG by  doxygen 1.4.3