changed: gcc8 base update
[opensg.git] / Source / System / FileIO / OpenFlight / OSGOFAncillaryRecords.h
blob314d708e3119b4ee19cf51738c9f46d6c72fbe7d
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2011 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 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGOFANCILLARYRECORDS_H_
40 #define _OSGOFANCILLARYRECORDS_H_
42 #include "OSGFileIODef.h"
43 #include "OSGOFRecords.h"
45 #include "OSGTextureEnvChunk.h"
46 #include "OSGTextureObjChunk.h"
48 OSG_BEGIN_NAMESPACE
50 //---------------------------------------------------------------------------
51 // Class
52 //---------------------------------------------------------------------------
54 /*! \ingroup GrpFileIOOpenFlight
55 \nohierarchy
58 class OSG_FILEIO_DLLMAPPING OFColorPaletteRecord : public OFAncillaryRecord
60 protected:
62 typedef OFAncillaryRecord Inherited;
64 typedef std::vector<Color4f > ColorStore;
65 typedef std::vector<std::string> ColorNameStore;
67 /*---------------------------------------------------------------------*/
69 static OFRecordFactoryBase::RegisterRecord _regHelper;
71 /*---------------------------------------------------------------------*/
73 ColorStore colors;
74 ColorNameStore colorNames;
76 /*---------------------------------------------------------------------*/
78 OFColorPaletteRecord(const OFRecordHeader &oHeader,
79 OFDatabase &oDB );
80 virtual ~OFColorPaletteRecord(void );
82 public:
84 static const UInt16 OpCode = 32;
86 static OFRecordTransitPtr create(const OFRecordHeader &oHeader,
87 OFDatabase &oDB );
89 /*---------------------------------------------------------------------*/
91 virtual bool read(std::istream &is);
93 /*---------------------------------------------------------------------*/
95 virtual UInt16 getOpCode(void) const;
97 /*---------------------------------------------------------------------*/
99 virtual void dump(UInt32 uiIndent) const;
101 /*---------------------------------------------------------------------*/
103 Color4f getColor(UInt32 uiIdx) const;
105 bool hasNames(void ) const;
106 std::string const &getName (UInt32 uiIdx) const;
109 /*! \ingroup GrpFileIOOpenFlight
111 typedef RefCountPtr<OFColorPaletteRecord,
112 MemObjRefCountPolicy > OFColorPaletteRecordRCPtr;
114 //---------------------------------------------------------------------------
115 // Class
116 //---------------------------------------------------------------------------
118 /*! \ingroup GrpFileIOOpenFlight
119 \nohierarchy
122 class OSG_FILEIO_DLLMAPPING OFTexturePaletteRecord : public OFAncillaryRecord
124 protected:
126 typedef OFAncillaryRecord Inherited;
128 struct TexAttr
130 Int32 numTexelU; // 0 4 number of texels in u direction
131 Int32 numTexelV; // 4 8 number of texels in v direction
132 Int32 realSizeU; // 8 4 obsolete
133 Int32 realSizeV; // 12 4 obsolete
134 Int32 upX; // 16 4 x component of up vector
135 Int32 upY; // 20 4 y component of up vector
136 Int32 fileFormat; // 24 4 file format type
137 // 0 AT&T image 8 pattern
138 // 1 AT&T image 8 template
139 // 2 SGI itensity modulation
140 // 3 SGI inensity w/alpha
141 // 4 SGI RGB
142 // 5 SGI RGB w/alpha
143 Int32 minFilter; // 28 4 minifiaction filter
144 // 0 point
145 // 1 bilinear
146 // 2 mipmap (obsolete)
147 // 3 mipmap point
148 // 4 mipmap linear
149 // 5 mipmap bilinear
150 // 7 mipmap trilinear
151 // 8 none
152 // 9 bicubic
153 // 10 bilinear GEQ
154 // 11 bilinear LEQ
155 // 12 bicubic GEQ
156 // 13 bicubic LEQ
157 Int32 magFilter; // 32 4 magnification filter
158 // 0 point
159 // 1 bilinear
160 // 2 none
161 // 3 bicubic
162 // 4 sharpen
163 // 5 add detail
164 // 6 modulate detail
165 // 7 bilinear GEQ
166 // 8 bilinear LEQ
167 // 9 bicubic GEQ
168 // 10 bicubic LEQ
169 Int32 wrapUV; // 36 4 wrap u,v
170 // 0 repeat
171 // 1 clamp
172 // 4 mirror repeat
173 Int32 wrapU; // 40 4 wrap u
174 // 0 repeat
175 // 1 clamp
176 // 3 none - use wrapUV
177 // 4 mirror repeat
178 Int32 wrapV; // 44 4 wrap v
179 // 0 repeat
180 // 1 clamp
181 // 3 none - use wrapUV
182 // 4 mirror repeat
183 Int32 modified; // 48 4 modified flag (internal use only)
184 Int32 pivotX; // 52 4 x pivot for rotating textures
185 Int32 pivotY; // 56 4 y pivot for rotating textures
186 Int32 envMode; // 60 4 environment mode
187 // 0 modulate
188 // 1 blend
189 // 2 decal
190 // 3 replace
191 // 4 add
193 // many more that are not read at this point.
195 GLenum getMinFilter(void);
196 GLenum getMagFilter(void);
198 GLenum getWrapU (void);
199 GLenum getWrapV (void);
201 GLenum getEnvMode (void);
203 protected:
204 GLenum getWrap(Int32 wrap);
207 bool readTexAttr(TexAttr &attr);
209 /*---------------------------------------------------------------------*/
211 static OFRecordFactoryBase::RegisterRecord _regHelper;
213 /*---------------------------------------------------------------------*/
215 Char8 szFilename[200]; // 4 200 File name of texture pattern
216 Int32 iPatternIdx; // 204 4 Texture pattern index
217 Int32 iPatternX; // 208 4*2 Location in the texture palette (x, y)
218 Int32 iPatternY;
220 /*---------------------------------------------------------------------*/
222 TextureObjChunkUnrecPtr pTexObj;
223 TextureEnvChunkUnrecPtr pTexEnv;
225 /*---------------------------------------------------------------------*/
227 OFTexturePaletteRecord(const OFRecordHeader &oHeader,
228 OFDatabase &oDB );
229 virtual ~OFTexturePaletteRecord(void );
231 public:
233 static const UInt16 OpCode = 64;
235 static OFRecordTransitPtr create(const OFRecordHeader &oHeader,
236 OFDatabase &oDB );
238 /*---------------------------------------------------------------------*/
240 virtual bool read(std::istream &is);
242 /*---------------------------------------------------------------------*/
244 virtual UInt16 getOpCode(void) const;
246 /*---------------------------------------------------------------------*/
248 virtual void dump(UInt32 uiIndent) const;
250 /*---------------------------------------------------------------------*/
252 Int32 getPatternIdx(void);
253 TextureObjChunk *getTexObj (void) const;
254 TextureEnvChunk *getTexEnv (void) const;
257 /*! \ingroup GrpFileIOOpenFlight
259 typedef RefCountPtr<OFTexturePaletteRecord,
260 MemObjRefCountPolicy > OFTexturePaletteRecordRCPtr;
262 //---------------------------------------------------------------------------
263 // Class
264 //---------------------------------------------------------------------------
266 /*! \ingroup GrpFileIOOpenFlight
267 \nohierarchy
270 class OSG_FILEIO_DLLMAPPING OFVertexPaletteRecord : public OFAncillaryRecord
272 public:
274 /*---------------------------------------------------------------------*/
276 /*! \nohierarchy
278 struct VertexInfo
280 UInt16 uiColNameIdx; // 4 2 Color name index
281 Int16 iFlags; // 6 2 Flags (bits, from left to right)
282 // 0 = Start hard edge
283 // 1 = Normal frozen
284 // 2 = No color
285 // 3 = Packed color
286 // 4-15 = Spare
288 Int32 iPackedCol; // 32 4 Packed color (a, b, g, r) - always
289 // specified when the vertex has color
290 UInt32 iColIdx; // 36 4 Vertex color index - valid only if vertex
291 // has color and Packed color flag is not set
292 Int32 iPad1; // 52 4 Reserved
294 UInt16 uiType;
295 UInt32 uiOffset;
296 Int32 uiIdx[4];
298 bool operator <(const UInt32 uiOff) const;
299 bool operator <(const VertexInfo &vInfo) const;
302 /*---------------------------------------------------------------------*/
304 static const UInt8 PosIdx = 0;
305 static const UInt8 ColIdx = 1;
306 static const UInt8 NormIdx = 2;
307 static const UInt8 TexCoordIdx = 3;
309 static const UInt8 HasPos = 0x01;
310 static const UInt8 HasCol = 0x02;
311 static const UInt8 HasNorm = 0x04;
312 static const UInt8 HasTexCoord = 0x08;
314 protected:
316 typedef OFAncillaryRecord Inherited;
318 /*---------------------------------------------------------------------*/
320 static OFRecordFactoryBase::RegisterRecord _regHelper;
322 /*---------------------------------------------------------------------*/
324 std::vector<Pnt3f> vPositions;
325 std::vector<Vec3f> vNormals;
326 std::vector<Vec2f> vTexCoords;
327 std::vector<VertexInfo> vVertexInfo;
329 /*---------------------------------------------------------------------*/
331 OFVertexPaletteRecord(const OFRecordHeader &oHeader,
332 OFDatabase &oDB );
334 virtual ~OFVertexPaletteRecord(void);
336 public:
338 static const UInt16 OpCode = 67;
340 /*---------------------------------------------------------------------*/
342 static OFRecordTransitPtr create(const OFRecordHeader &oHeader,
343 OFDatabase &oDB );
345 virtual bool read(std::istream &is);
347 /*---------------------------------------------------------------------*/
349 virtual UInt16 getOpCode(void) const;
351 /*---------------------------------------------------------------------*/
353 const VertexInfo *getVertexInfo(UInt32 uiOffset) const;
355 const Pnt3f &getPos (UInt32 uiIdx ) const;
356 const Vec3f &getNormal (UInt32 uiIdx ) const;
357 const Vec2f &getTexCoord (UInt32 uiIdx ) const;
360 bool operator <(const UInt32 uiOff,
361 const OFVertexPaletteRecord::VertexInfo &vInfo );
363 /*! \ingroup GrpFileIOOpenFlight
365 typedef RefCountPtr<OFVertexPaletteRecord,
366 MemObjRefCountPolicy > OFVertexPaletteRecordRCPtr;
368 //---------------------------------------------------------------------------
369 // Class
370 //---------------------------------------------------------------------------
372 /*! \ingroup GrpFileIOOpenFlight
373 \nohierarchy
376 class OSG_FILEIO_DLLMAPPING OFMaterialPaletteRecord : public OFAncillaryRecord
378 protected:
380 typedef OFAncillaryRecord Inherited;
382 /*---------------------------------------------------------------------*/
384 static OFRecordFactoryBase::RegisterRecord _regHelper;
386 /*---------------------------------------------------------------------*/
388 Int32 iMaterialIdx; // 4 4 Material index
389 Char8 szMaterialName[12]; // 8 12 Material name
390 Int32 iFlags; // 20 4 Flags
391 // 0 = Material is used
392 // 1-31 = Spare
393 Color4f colAmbient; // 24 4*3 Ambient component of material (r, g, b)
394 Color4f colDiffuse; // 36 4*3 Diffuse component of material (r, g, b)
395 Color4f colSpecular; // 48 4*3 Specular component of material (r, g, b)
396 Color4f colEmissive; // 60 4*3 Emissive component of material (r, g, b)
397 Real32 fShininess; // 72 4 Shininess - (0.0-128.0)
398 Real32 fAlpha; // 76 4 Alpha - (0.0-1.0) where 1.0 is opaque
399 Int32 iPad; // 80 4 Reserved
401 /*---------------------------------------------------------------------*/
403 OFMaterialPaletteRecord(const OFRecordHeader &oHeader,
404 OFDatabase &oDB );
405 virtual ~OFMaterialPaletteRecord(void );
407 public:
409 static const UInt16 OpCode = 113;
411 static OFRecordTransitPtr create(const OFRecordHeader &oHeader,
412 OFDatabase &oDB );
414 static const Int32 FlagMaterialUsed = 0x80000000;
416 /*---------------------------------------------------------------------*/
418 virtual bool read(std::istream &is);
420 /*---------------------------------------------------------------------*/
422 virtual UInt16 getOpCode(void) const;
424 /*---------------------------------------------------------------------*/
426 virtual void dump(UInt32 uiIndent) const;
428 /*---------------------------------------------------------------------*/
430 Int32 getMaterialIdx(void);
432 const Color4f &getAmbient (void) const;
433 const Color4f &getDiffuse (void) const;
434 const Color4f &getSpecular (void) const;
435 const Color4f &getEmissive (void) const;
436 Real32 getShininess (void) const;
437 Real32 getAlpha (void) const;
440 /*! \ingroup GrpFileIOOpenFlight
442 typedef RefCountPtr<OFMaterialPaletteRecord,
443 MemObjRefCountPolicy > OFMaterialPaletteRecordRCPtr;
445 //---------------------------------------------------------------------------
446 // Class
447 //---------------------------------------------------------------------------
449 /*! \ingroup GrpFileIOOpenFlight
450 \nohierarchy
453 class OSG_FILEIO_DLLMAPPING OFMatrixRecord : public OFAncillaryRecord
455 protected:
456 /*---------------------------------------------------------------------*/
458 typedef OFAncillaryRecord Inherited;
460 /*---------------------------------------------------------------------*/
462 static OFRecordFactoryBase::RegisterRecord _regHelper;
464 /*---------------------------------------------------------------------*/
466 Matrix matrix; // 4 64 4x4 matrix, row major
468 /*---------------------------------------------------------------------*/
470 OFMatrixRecord(const OFRecordHeader &oHeader,
471 OFDatabase &oDB );
472 virtual ~OFMatrixRecord(void );
474 public:
476 static const UInt16 OpCode = 49;
478 static OFRecordTransitPtr create(const OFRecordHeader &oHeader,
479 OFDatabase &oDB );
481 /*---------------------------------------------------------------------*/
483 virtual bool read (std::istream &is );
484 virtual NodeTransitPtr convert(Node *pNode);
486 /*---------------------------------------------------------------------*/
488 virtual UInt16 getOpCode(void) const;
490 /*---------------------------------------------------------------------*/
492 virtual void dump(UInt32 uiIndent) const;
494 /*---------------------------------------------------------------------*/
497 //---------------------------------------------------------------------------
498 // Class
499 //---------------------------------------------------------------------------
501 /*! \ingroup GrpFileIOOpenFlight
502 \nohierarchy
505 class OSG_FILEIO_DLLMAPPING OFIgnoredTransformRecord : public OFAncillaryRecord
507 protected:
509 typedef OFAncillaryRecord Inherited;
511 /*---------------------------------------------------------------------*/
513 static OFRecordFactoryBase::RegisterRecord _regHelperRotateAboutEdge;
514 static OFRecordFactoryBase::RegisterRecord _regHelperTranslate;
515 static OFRecordFactoryBase::RegisterRecord _regHelperScale;
516 static OFRecordFactoryBase::RegisterRecord _regHelperRotateAboutPoint;
517 static OFRecordFactoryBase::RegisterRecord _regHelperRotateScaleToPoint;
518 static OFRecordFactoryBase::RegisterRecord _regHelperPut;
519 static OFRecordFactoryBase::RegisterRecord _regHelperGeneralMatrix;
521 /*---------------------------------------------------------------------*/
523 UInt16 _sOpCode;
525 /*---------------------------------------------------------------------*/
527 OFIgnoredTransformRecord(const OFRecordHeader &oHeader,
528 OFDatabase &oDB );
529 virtual ~OFIgnoredTransformRecord(void );
531 public:
533 static const UInt16 OpCodeRotateAboutEdge = 76;
534 static const UInt16 OpCodeTranslate = 78;
535 static const UInt16 OpCodeScale = 79;
536 static const UInt16 OpCodeRotateAboutPoint = 80;
537 static const UInt16 OpCodeRotateScaleToPoint = 81;
538 static const UInt16 OpCodePut = 82;
539 static const UInt16 OpCodeGeneralMatrix = 94;
541 /*---------------------------------------------------------------------*/
543 static OFRecordTransitPtr create(const OFRecordHeader &oHeader,
544 OFDatabase &oDB );
546 /*---------------------------------------------------------------------*/
548 virtual bool read (std::istream &is );
549 virtual NodeTransitPtr convert(Node *pNode);
551 /*---------------------------------------------------------------------*/
553 virtual UInt16 getOpCode(void) const;
555 /*---------------------------------------------------------------------*/
557 virtual void dump(UInt32 uiIndent) const;
559 /*---------------------------------------------------------------------*/
562 //---------------------------------------------------------------------------
563 // Class
564 //---------------------------------------------------------------------------
566 /*! \ingroup GrpFileIOOpenFlight
567 \nohierarchy
570 class OSG_FILEIO_DLLMAPPING OFLongIDRecord : public OFAncillaryRecord
572 protected:
573 /*---------------------------------------------------------------------*/
575 typedef OFAncillaryRecord Inherited;
577 /*---------------------------------------------------------------------*/
579 static OFRecordFactoryBase::RegisterRecord _regHelper;
581 /*---------------------------------------------------------------------*/
583 std::string longId; // 4 len-4 ASCIIId of node, 0 terminates
585 /*---------------------------------------------------------------------*/
587 OFLongIDRecord(const OFRecordHeader &oHeader,
588 OFDatabase &oDB );
589 virtual ~OFLongIDRecord(void );
591 public:
593 static const UInt16 OpCode = 33;
595 static OFRecordTransitPtr create(const OFRecordHeader &oHeader,
596 OFDatabase &oDB );
598 /*---------------------------------------------------------------------*/
600 virtual bool read (std::istream &is );
601 virtual NodeTransitPtr convert(Node *pNode);
603 /*---------------------------------------------------------------------*/
605 virtual UInt16 getOpCode(void) const;
607 /*---------------------------------------------------------------------*/
609 virtual void dump(UInt32 uiIndent) const;
611 /*---------------------------------------------------------------------*/
614 OSG_END_NAMESPACE
616 #endif /* _OSGOFANCILLARYRECORDS_H_ */