fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / OBJ / OSGOBJSceneFileType.h
blob8293b38a1ceddb56b97b7c7eac918a7d6f4cb241
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * 2002/10/16: added transparency path. Thanks to Franck Sourdin *
33 * (sourdin@ai.cluny.ensam.fr) for it! *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGOBJSCENEFILETYPE_H_
40 #define _OSGOBJSCENEFILETYPE_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGFileIODef.h"
46 #include "OSGBaseTypes.h"
47 #include "OSGSceneFileType.h"
49 #include <map>
52 OSG_BEGIN_NAMESPACE
54 /*! \brief OBJSceneFileType
55 \ingroup GrpFileIOOBJ
56 \ingroup GrpLibOSGFileIO
59 class OSG_FILEIO_DLLMAPPING OBJSceneFileType : public SceneFileType
61 /*========================== PUBLIC =================================*/
63 public:
65 /*---------------------------------------------------------------------*/
66 /*! \name Class Get */
67 /*! \{ */
69 static OBJSceneFileType &the(void);
71 /*! \} */
72 /*---------------------------------------------------------------------*/
73 /*! \name Destructors */
74 /*! \{ */
76 virtual ~OBJSceneFileType(void);
78 /*! \} */
79 /*---------------------------------------------------------------------*/
80 /*! \name Get */
81 /*! \{ */
83 virtual const Char8 *getName(void) const;
85 /*! \} */
86 /*---------------------------------------------------------------------*/
87 /*! \name Read */
88 /*! \{ */
90 virtual
91 NodeTransitPtr read( std::istream &is,
92 const Char8 *fileNameOrExtension,
93 Resolver resolver = NULL ) const;
95 /*! \} */
96 /*---------------------------------------------------------------------*/
97 /*! \name Write */
98 /*! \{ */
100 virtual bool write(Node * const node,
101 std::ostream &os,
102 Char8 const *fileNameOrExtension) const;
104 /*! \} */
105 /*========================= PROTECTED ===============================*/
107 protected:
109 /*---------------------------------------------------------------------*/
110 /*! \name Member */
111 /*! \{ */
113 static const Char8 *_suffixA[];
114 static OBJSceneFileType _the;
116 /*! \} */
117 /*---------------------------------------------------------------------*/
118 /*! \name Constructors */
119 /*! \{ */
121 OBJSceneFileType(const Char8 *suffixArray[],
122 UInt16 suffixByteCount,
123 bool override,
124 UInt32 overridePriority,
125 UInt32 flags);
127 OBJSceneFileType(const OBJSceneFileType &obj);
129 /*! \} */
130 /*========================== PRIVATE ================================*/
132 private:
134 typedef SceneFileType Inherited;
136 enum DataElem
138 UNKNOWN_DE = 0,
140 VERTEX_DE, VERTEX_TEXTURECOORD_DE, VERTEX_NORMAL_DE,
141 FACE_DE,
143 LIB_MTL_DE,
144 USE_MTL_DE,
146 GROUP_DE, SMOOTHING_GROUP_DE, OBJECT_DE
149 std::map<std::string, DataElem> _dataElemMap;
151 enum MaterialElem
153 UNKNOWN_ME = 0,
155 NEW_MTL_ME,
156 MTL_DIFFUSE_ME, MTL_AMBIENT_ME, MTL_SPECULAR_ME,
157 MTL_SHININESS_ME, MTL_ILLUM_ME,
158 MTL_TRANSPARENCY_ME, MTL_DISSOLVE_ME,
159 MTL_MAP_KD_ME, MTL_MAP_KA_ME, MTL_MAP_KS_ME,
160 MTL_REFL_ME
163 std::map<std::string, MaterialElem> _mtlElemMap;
165 void initElemMap(void);
167 struct Mesh;
168 friend struct Mesh;
170 struct Face;
171 friend struct Face;
173 /*! \nohierarchy
175 struct TiePoint
177 Int32 index[3];
178 TiePoint( Int32 v = -1, Int32 vt = -1, Int32 vn = -1 )
179 { index[0] = v; index[1] = vt; index[2] = vn; }
180 inline void set ( Int32 v = -1, Int32 vt = -1, Int32 vn = -1 )
181 { index[0] = v; index[1] = vt; index[2] = vn; }
184 /*! \nohierarchy
186 struct Face
188 std::vector<TiePoint> tieVec;
190 Face(void) : tieVec() {}
193 /*! \nohierarchy
195 struct Mesh
197 std::string name;
198 std::list<Face> faceList;
199 SimpleMaterialUnrecPtr mtlPtr;
201 Mesh(void) : name(), faceList(), mtlPtr(NULL) {}
205 Int32 readMTL (const Char8 *fileName,
206 std::map<std::string,
207 SimpleTexturedMaterialUnrecPtr> &mtlMap ) const;
209 void write(Node * const node,
210 std::ostream &os,
211 UInt32 &pIndex,
212 UInt32 &nIndex,
213 UInt32 &tIndex) const;
215 /* prohibit default function (move to 'public' if needed) */
216 void operator =(const OBJSceneFileType &source);
219 typedef OBJSceneFileType* OBJSceneFileTypeP;
221 OSG_END_NAMESPACE
223 #endif // _OSGOBJSCENEFILETYPE_H_