1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2011 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGOFPRIMARYRECORDS_H_
40 #define _OSGOFPRIMARYRECORDS_H_
42 #include "OSGFileIODef.h"
43 #include "OSGOFRecords.h"
47 //---------------------------------------------------------------------------
49 //---------------------------------------------------------------------------
51 /*! \ingroup GrpFileIOOpenFlight
55 class OSG_FILEIO_DLLMAPPING OFHeaderRecord
: public OFPrimaryRecord
58 typedef OFPrimaryRecord Inherited
;
60 /*---------------------------------------------------------------------*/
62 OFHeaderRecord(const OFRecordHeader
&oHeader
,
64 virtual ~OFHeaderRecord(void );
68 static const UInt16 OpCode
= 1;
70 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
73 /*---------------------------------------------------------------------*/
75 virtual bool read (std::istream
&is
);
76 virtual NodeTransitPtr
convertToNode(void );
77 virtual bool addChild (OFRecord
*pChild
);
79 /*---------------------------------------------------------------------*/
81 virtual UInt16
getOpCode(void) const;
83 /*---------------------------------------------------------------------*/
85 virtual void dump(UInt32 uiIndent
) const;
87 /*---------------------------------------------------------------------*/
90 /*! \ingroup GrpFileIOOpenFlight
92 typedef RefCountPtr
<OFHeaderRecord
,
93 MemObjRefCountPolicy
> OFHeaderRecordRCPtr
;
96 //---------------------------------------------------------------------------
98 //---------------------------------------------------------------------------
100 /*! \ingroup GrpFileIOOpenFlight
104 class OSG_FILEIO_DLLMAPPING OFGroupRecord
: public OFPrimaryRecord
108 /*---------------------------------------------------------------------*/
110 typedef OFPrimaryRecord Inherited
;
112 /*---------------------------------------------------------------------*/
114 static OFRecordFactoryBase::RegisterRecord _regHelper
;
116 Char8 szASCIIId
[8]; // 4 8 7 char ascii id, 0 terminates
118 /*---------------------------------------------------------------------*/
120 OFGroupRecord(const OFRecordHeader
&oHeader
,
122 virtual ~OFGroupRecord(void );
126 /*---------------------------------------------------------------------*/
128 static const UInt16 OpCode
= 2;
130 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
133 /*---------------------------------------------------------------------*/
135 virtual bool read (std::istream
&is
);
136 virtual NodeTransitPtr
convertToNode(void );
138 /*---------------------------------------------------------------------*/
140 virtual UInt16
getOpCode(void) const;
142 /*---------------------------------------------------------------------*/
144 virtual void dump(UInt32 uiIndent
) const;
146 NodeTransitPtr
convertAncillaryChildren(Node
*pNode
);
149 //---------------------------------------------------------------------------
151 //---------------------------------------------------------------------------
153 /*! \ingroup GrpFileIOOpenFlight
156 /*! \ingroup GrpFileIOOpenFlight
158 typedef RefCountPtr
<OFFaceRecord
, MemObjRefCountPolicy
> OFFaceRecordRCPtr
;
160 /*! \ingroup GrpFileIOOpenFlight
163 /*! \ingroup GrpFileIOOpenFlight
165 typedef RefCountPtr
<OFMeshRecord
, MemObjRefCountPolicy
> OFMeshRecordRCPtr
;
167 /*! \ingroup GrpFileIOOpenFlight
171 class OSG_FILEIO_DLLMAPPING OFObjectRecord
: public OFPrimaryRecord
175 /*---------------------------------------------------------------------*/
177 typedef OFPrimaryRecord Inherited
;
179 typedef std::vector
<OFFaceRecordRCPtr
> FaceStore
;
180 typedef std::vector
<OFMeshRecordRCPtr
> MeshStore
;
182 static OFRecordFactoryBase::RegisterRecord _regHelper
;
184 /*---------------------------------------------------------------------*/
186 OFObjectRecord(const OFRecordHeader
&oHeader
,
188 virtual ~OFObjectRecord(void );
190 Char8 szASCIIId
[8]; // 4 8 7 char ASCII ID, 0 terminates
191 Int32 flags
; // 12 4 flags
192 Int16 relPriority
; // 16 2 relative priority
193 UInt16 transparency
; // 18 2 transparency
194 Int16 specialEffect1
; // 20 2 specialEffect ID 1, application defined
195 Int16 specialEffect2
; // 22 2 specialEffect ID 2, application defined
196 Int16 significance
; // 24 2 significance
197 Int16 reserved
; // 26 2 reserved
204 static const UInt16 OpCode
= 4;
206 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
209 /*---------------------------------------------------------------------*/
211 virtual bool read (std::istream
&is
);
212 virtual NodeTransitPtr
convertToNode(void );
213 virtual bool addChild (OFRecord
*pChild
);
215 /*---------------------------------------------------------------------*/
217 virtual UInt16
getOpCode(void) const;
219 /*---------------------------------------------------------------------*/
221 virtual void dump(UInt32 uiIndent
) const;
223 /*---------------------------------------------------------------------*/
225 void groupFaces(std::vector
< std::vector
<OFFaceRecord
*> > &vFaceGroups
);
227 NodeTransitPtr
convertFaceGroup(std::vector
<OFFaceRecord
*> &vFaceGroup
);
229 NodeTransitPtr
convertGeometry (void);
231 NodeTransitPtr
convertAncillaryChildren(Node
*pNode
);
234 //---------------------------------------------------------------------------
235 // Forward declarations
236 //---------------------------------------------------------------------------
238 /*! \ingroup GrpFileIOOpenFlight
240 class OFMeshPrimitiveRecord
;
241 /*! \ingroup GrpFileIOOpenFlight
243 typedef RefCountPtr
<OFMeshPrimitiveRecord
,
244 MemObjRefCountPolicy
> OFMeshPrimitiveRecordRCPtr
;
246 //---------------------------------------------------------------------------
248 //---------------------------------------------------------------------------
250 /*! \ingroup GrpFileIOOpenFlight
254 class OSG_FILEIO_DLLMAPPING OFLocalVertexPoolRecord
: public OFPrimaryRecord
257 typedef OFPrimaryRecord Inherited
;
259 static OFRecordFactoryBase::RegisterRecord _regHelper
;
261 /*---------------------------------------------------------------------*/
263 UInt32 uiNumVerts
; // 4 4 Number of vertices - number of vertices in the local vertex pool
264 UInt32 uiAttribMask
; // 8 4 Attribute mask - Bit mask indicating what kind of vertex infor-
265 // mation is specified for each vertex in the local vertex pool. Bits
266 // are ordered from left to right as follows:
268 // 0 Has Position - if set, data for each vertex in will include
269 // x, y, and z coordinates (3 doubles)
270 // 1 Has Color Index - if set, data for each vertex will in-
271 // clude a color value that specifies a color table index as
272 // well as an alpha value
273 // 2 Has RGBA Color - if set, data for each vertex will in-
274 // clude a color value that is a packed RGBA color value
275 // Note: Bits 1and 2 are mutually exclusive - a vertex can have ei-
276 // ther color index or RGB color value or neither, but not both.
277 // 3 Has Normal - if set, data for each vertex will include a
279 // 4 Has Base UV - if set, data for each vertex will include
280 // uv texture coordinates for the base texture (2 floats)
281 // 5 Has UV Layer 1 - if set, data for each vertex will include
282 // uv texture coordinates for layer 1 (2 floats)
283 // 6 Has UV Layer 2 - if set, data for each vertex will include
284 // uv texture coordinates for layer 2 (2 floats)
285 // 7 Has UV Layer 3 - if set, data for each vertex will include
286 // uv texture coordinates for layer 3 (2 floats)
287 // 8 Has UV Layer 4 - if set, data for each vertex will include
288 // uv texture coordinates for layer 4 (2 floats)
289 // 9 Has UV Layer 5 - if set, data for each vertex will include
290 // uv texture coordinates for layer 5 (2 floats)
291 // 10 Has UV Layer 6 - if set, data for each vertex will include
292 // uv texture coordinates for layer 6 (2 floats)
293 // 11 Has UV Layer 7 - if set, data for each vertex will include
294 // uv texture coordinates for layer 7 (2 floats)
296 // The following fields (if they are present according to uiAttribMask)
297 // are repeated uiNumVerts times
298 // Double Varies 8*3 CoordinateN - Coordinate of vertex N (x, y, z) - present if At-
299 // tribute mask includes Has Position.
300 // Unsigned Int Varies 4 colorN - Color for vertex N - present if Attribute mask includes
301 // Has Color Index or Has RGBA Color.
302 // If Has Color Index, lower 3 bytes specify color table index,
303 // upper 1 byte is Alpha.
304 // If Has RGBA Color, 4 bytes specify (a, b, g, r) values.
305 // Float Varies 4*3 normalN - Normal for vertex N (i, j, k) - present if Attribute mask
306 // includes Has Normal.
307 // Float Varies 4*2 uvBaseN - Texture coordinates (u, v) for base texture layer of
308 // vertex N - present if Attribute mask includes Has Base UV.
309 // Float Varies 4*2 uv1N - Texture coordinates (u, v) for layer 1 of vertex N -
310 // present if Attribute mask includes Has UV Layer 1.
311 // Float Varies 4*2 uv2N - Texture coordinates (u, v) for layer 2 of vertex N -
312 // present if Attribute mask includes Has UV Layer 2.
313 // Float Varies 4*2 uv3N - Texture coordinates (u, v) for layer 3 of vertex N -
314 // present if Attribute mask includes Has UV Layer 3.
315 // Float Varies 4*2 uv4N - Texture coordinates (u, v) for layer 4 of vertex N -
316 // present if Attribute mask includes Has UV Layer 4.
317 // Float Varies 4*2 uv5N - Texture coordinates (u, v) for layer 5 of vertex N -
318 // present if Attribute mask includes Has UV Layer 5.
319 // Float Varies 4*2 uv6N - Texture coordinates (u, v) for layer 6 of vertex N -
320 // present if Attribute mask includes Has UV Layer 6.
321 // Float Varies 4*2 uv7N - Texture coordinates (u, v) for layer 7 of vertex N -
322 // present if Attribute mask includes Has UV Layer 7.
324 GeoPnt3dPropertyUnrecPtr _pPositions
;
325 GeoColor4ubPropertyUnrecPtr _pColors
;
326 GeoVec3fPropertyUnrecPtr _pNormals
;
327 GeoVec2fPropertyUnrecPtr _texCoords
[8];
329 std::vector
<OFMeshPrimitiveRecordRCPtr
> _vTriStrips
;
330 std::vector
<OFMeshPrimitiveRecordRCPtr
> _vTriFans
;
331 std::vector
<OFMeshPrimitiveRecordRCPtr
> _vQuadStrips
;
332 std::vector
<OFMeshPrimitiveRecordRCPtr
> _vPolygons
;
334 /*---------------------------------------------------------------------*/
336 OFLocalVertexPoolRecord(const OFRecordHeader
&oHeader
,
338 virtual ~OFLocalVertexPoolRecord(void );
341 typedef TransitPtr
<OFLocalVertexPoolRecord
> ObjTransitPtr
;
342 typedef RefCountPtr
<OFLocalVertexPoolRecord
,
343 MemObjRefCountPolicy
> ObjRCPtr
;
345 static const UInt16 OpCode
= 85;
347 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
350 static const UInt32 AMHasPosition
;
351 static const UInt32 AMHasColorIndex
;
352 static const UInt32 AMHasColorValue
;
353 static const UInt32 AMHasNormal
;
354 static const UInt32 AMHasTexCoords
[8];
356 /*---------------------------------------------------------------------*/
358 virtual bool read (std::istream
&is
);
359 virtual bool readContinue(std::istream
&is
,
361 virtual bool addChild (OFRecord
*pChild
);
363 /*---------------------------------------------------------------------*/
365 virtual UInt16
getOpCode(void) const;
367 /*---------------------------------------------------------------------*/
369 virtual void dump(UInt32 uiIndent
) const;
371 /*---------------------------------------------------------------------*/
373 virtual void convertPrimitives(Geometry
*pGeo
);
375 GeoPnt3dProperty
*getPositions(void ) const;
376 GeoColor4ubProperty
*getColors (void ) const;
377 GeoVec3fProperty
*getNormals (void ) const;
378 GeoVec2fProperty
*getTexCoords(UInt32 idx
) const;
381 /*! \ingroup GrpFileIOOpenFlight
383 typedef OFLocalVertexPoolRecord::ObjTransitPtr OFLocalVertexPoolRecordTransitPtr
;
384 /*! \ingroup GrpFileIOOpenFlight
386 typedef OFLocalVertexPoolRecord::ObjRCPtr OFLocalVertexPoolRecordRCPtr
;
388 //---------------------------------------------------------------------------
390 //---------------------------------------------------------------------------
392 /*! \ingroup GrpFileIOOpenFlight
396 class OSG_FILEIO_DLLMAPPING OFMeshPrimitiveRecord
: public OFPrimaryRecord
399 typedef std::vector
<UInt32
> IndexStore
;
402 typedef OFPrimaryRecord Inherited
;
404 static OFRecordFactoryBase::RegisterRecord _regHelper
;
406 /*---------------------------------------------------------------------*/
408 Int16 uiPrimType
; // 4 2 Primitive Type - specifies how the vertices
409 // of the primitive are interpreted
410 // 1 = Triangle Strip
412 // 3 = Quadrilateral Strip
413 // 4 = Indexed Polygon
414 UInt16 uiIndexSize
; // 6 2 Index Size - specifies the length (in bytes)
415 // of each of the vertex indices that follow -
416 // will be either 1, 2, or 4
417 UInt32 uiVertexCount
; // 8 4 Vertex Count- number of vertices contained
418 // in this primitive.
420 IndexStore _vIndices
;
422 /*---------------------------------------------------------------------*/
424 friend class OFLocalVertexPoolRecord
;
426 /*---------------------------------------------------------------------*/
428 OFMeshPrimitiveRecord(const OFRecordHeader
&oHeader
,
430 virtual ~OFMeshPrimitiveRecord(void );
433 typedef TransitPtr
<OFMeshPrimitiveRecord
> ObjTransitPtr
;
434 typedef RefCountPtr
<OFMeshPrimitiveRecord
,
435 MemObjRefCountPolicy
> ObjRCPtr
;
437 static const UInt16 OpCode
= 86;
439 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
442 static const UInt16 PTTriStrip
= 1;
443 static const UInt16 PTTriFan
= 2;
444 static const UInt16 PTQuadStrip
= 3;
445 static const UInt16 PTPolygon
= 4;
447 /*---------------------------------------------------------------------*/
449 virtual bool read (std::istream
&is
);
450 virtual bool readContinue(std::istream
&is
,
453 /*---------------------------------------------------------------------*/
455 virtual UInt16
getOpCode(void) const;
457 /*---------------------------------------------------------------------*/
459 virtual void dump(UInt32 uiIndent
) const;
461 /*---------------------------------------------------------------------*/
463 IndexStore
&editIndices(void);
464 const IndexStore
&getIndices (void) const;
467 /*! \ingroup GrpFileIOOpenFlight
469 typedef OFMeshPrimitiveRecord::ObjTransitPtr OFMeshPrimitiveRecordTransitPtr
;
470 /*! \ingroup GrpFileIOOpenFlight
472 typedef OFMeshPrimitiveRecord::ObjRCPtr OFMeshPrimitiveRecordRCPtr
;
474 //---------------------------------------------------------------------------
476 //---------------------------------------------------------------------------
478 /*! \ingroup GrpFileIOOpenFlight
482 class OSG_FILEIO_DLLMAPPING OFMeshRecord
: public OFPrimaryRecord
485 typedef OFPrimaryRecord Inherited
;
487 static OFRecordFactoryBase::RegisterRecord _regHelper
;
489 /*---------------------------------------------------------------------*/
491 Char8 szASCIIId
[8]; // 4 8 7 char ASCII ID; 0 terminates
492 Int32 iPad1
; // 12 4 Reserved
493 Int32 iIRColorCode
; // 16 4 IR color code
494 Int16 iRelPrio
; // 20 2 Relative priority
495 Int8 iDrawType
; // 22 1 Draw type
496 // 0 = Draw solid with backface culling
498 // 1 = Draw solid, no backface culling
499 // (both sides visible)
500 // 2 = Draw wireframe and close
501 // 3 = Draw wireframe
502 // 4 = Surround with wireframe in alternate color
503 // 8 = Omnidirectional light
504 // 9 = Unidirectional light
505 // 10 = Bidirectional light
506 Int8 iTextureWhite
; // 23 1 Texture white = if TRUE, draw textured face white
507 UInt16 uiColorNameIdx
; // 24 2 Color name index
508 UInt16 uiAltColorNameIdx
; // 26 2 Alternate color name index
509 Int8 iPad2
; // 28 1 Reserved
510 Int8 iTemplate
; // 29 1 Template (billboard)
511 // 0 = Fixed, no alpha blending
512 // 1 = Fixed, alpha blending
513 // 2 = Axial rotate with alpha blending
514 // 4 = Point rotate with alpha blending
515 Int16 iDetailTexIdx
; // 30 2 Detail texture pattern index, -1 if none
516 Int16 iTexIdx
; // 32 2 Texture pattern index, -1 if none
517 Int16 iMatIdx
; // 34 2 Material index, -1 if none
518 Int16 iSurfMatCode
; // 36 2 Surface material code (for DFAD)
519 Int16 iFeatureId
; // 38 2 Feature ID (for DFAD)
520 Int32 iIRMatCode
; // 40 4 IR material code
521 UInt16 uiTransparency
; // 44 2 Transparency
523 // 65535 = Totally clear
524 UInt8 uiLODGenControl
; // 46 1 LOD generation control
525 UInt8 uiLineStyle
; // 47 1 Line style index
526 Int32 iFlags
; // 48 4 Flags (bits from left to right)
529 // 2 = No alternate color
531 // 4 = Terrain culture cutout (footprint)
532 // 5 = Hidden, not drawn
535 UInt8 uiLightMode
; // 52 1 Light mode
536 // 0 = Use mesh color, not illuminated (Flat)
537 // 1 = Use vertex colors, not illuminated (Gouraud)
538 // 2 = Use mesh color and vertex normals (Lit)
539 // 3 = Use vertex colors and vertex normals
541 Char8 szPad3
[7]; // 53 7 Reserved
542 UInt32 uiPackedPrimCol
; // 60 4 Packed color, primary (a, b, g, r)
544 UInt32 uiPackedAltCol
; // 64 4 Packed color, alternate (a, b, g, r)
546 Int16 iTexMapIdx
; // 68 2 Texture mapping index, -1 if none
547 Int16 iPad4
; // 70 2 Reserved
548 Int32 uiPrimColIdx
; // 72 4 Primary color index, -1 if none
549 Int32 uiAltColIdx
; // 76 4 Alternate color index, -1 if none
550 Int16 iPad5
; // 80 2 Reserved
551 Int16 iShaderIdx
; // 82 2 Shader index, -1 if none
553 OFLocalVertexPoolRecordRCPtr _pVertexPool
;
555 /*---------------------------------------------------------------------*/
557 OFMeshRecord(const OFRecordHeader
&oHeader
,
559 virtual ~OFMeshRecord(void );
562 typedef TransitPtr
<OFMeshRecord
> ObjTransitPtr
;
563 typedef RefCountPtr
<OFMeshRecord
,
564 MemObjRefCountPolicy
> ObjRCPtr
;
566 static const UInt16 OpCode
= 84;
568 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
571 /*---------------------------------------------------------------------*/
573 virtual bool read (std::istream
&is
);
574 virtual NodeTransitPtr
convertToNode(void );
575 virtual bool addChild (OFRecord
*pChild
);
577 /*---------------------------------------------------------------------*/
579 virtual UInt16
getOpCode(void) const;
581 /*---------------------------------------------------------------------*/
583 virtual void dump(UInt32 uiIndent
) const;
586 /*! \ingroup GrpFileIOOpenFlight
588 typedef OFMeshRecord::ObjTransitPtr OFMeshRecordTransitPtr
;
589 /*! \ingroup GrpFileIOOpenFlight
591 typedef OFMeshRecord::ObjRCPtr OFMeshRecordRCPtr
;
593 //---------------------------------------------------------------------------
595 //---------------------------------------------------------------------------
597 class OFVertexListRecord
;
599 typedef RefCountPtr
<OFVertexListRecord
,
600 MemObjRefCountPolicy
> OFVertexListRecordRCPtr
;
602 /*! \ingroup GrpFileIOOpenFlight
606 class OSG_FILEIO_DLLMAPPING OFFaceRecord
: public OFPrimaryRecord
610 /*---------------------------------------------------------------------*/
612 typedef OFPrimaryRecord Inherited
;
614 /*---------------------------------------------------------------------*/
616 static OFRecordFactoryBase::RegisterRecord _regHelper
;
618 /*---------------------------------------------------------------------*/
620 Char8 szASCIIId
[8]; // 4 8 7 char ASCII ID; 0 terminates
621 Int32 iIRColorCode
; // 12 4 IR color code
622 Int16 iRelPrio
; // 16 2 Relative priority
623 Int8 iDrawType
; // 18 1 Draw type
624 // 0 = Draw solid with backface culling
626 // 1 = Draw solid, no backface culling
627 // (both sides visible)
628 // 2 = Draw wireframe and close
629 // 3 = Draw wireframe
630 // 4 = Surround with wireframe in alternate color
631 // 8 = Omnidirectional light
632 // 9 = Unidirectional light
633 // 10 = Bidirectional light
634 Int8 iTextureWhite
; // 19 1 Texture white =
635 // if TRUE, draw textured face white
636 UInt16 uiColorNameIdx
; // 20 2 Color name index
637 UInt16 uiAltColorNameIdx
; // 22 2 Alternate color name index
638 Int8 iPad1
; // 24 1 Reserved
639 Int8 iTemplate
; // 25 1 Template (billboard)
640 // 0 = Fixed, no alpha blending
641 // 1 = Fixed, alpha blending
642 // 2 = Axial rotate with alpha blending
643 // 4 = Point rotate with alpha blending
644 Int16 iDetailTexIdx
; // 26 2 Detail texture pattern index, -1 if none
645 Int16 iTexIdx
; // 28 2 Texture pattern index, -1 if none
646 Int16 iMatIdx
; // 30 2 Material index, -1 if none
647 Int16 iSurfMatCode
; // 32 2 Surface material code (for DFAD)
648 Int16 iFeatureId
; // 34 2 Feature ID (for DFAD)
649 Int32 iIRMatCode
; // 36 4 IR material code
650 UInt16 uiTransparency
; // 40 2 Transparency
652 // 65535 = Totally clear
653 UInt8 uiLODGenControl
; // 42 1 LOD generation control
654 UInt8 uiLineStyle
; // 43 1 Line style index
655 Int32 iFlags
; // 44 4 Flags (bits from left to right)
658 // 2 = No alternate color
660 // 4 = Terrain culture cutout (footprint)
661 // 5 = Hidden, not drawn
664 UInt8 uiLightMode
; // 48 1 Light mode
665 // 0 = Use face color, not illuminated (Flat)
666 // 1 = Use vertex colors, not illuminated (Gouraud)
667 // 2 = Use face color and vertex normals (Lit)
668 // 3 = Use vertex colors and vertex normals(Lit
670 Char8 szPad2
[7]; // 49 7 Reserved
671 UInt32 uiPackedPrimCol
; // 56 4 Packed color, primary (a, b, g, r) -
673 UInt32 uiPackedAltCol
; // 60 4 Packed color, alternate (a, b, g, r) -
675 Int16 iTexMapIdx
; // 64 2 Texture mapping index, -1 if none
676 Int16 iPad3
; // 66 2 Reserved
677 Int32 uiPrimColIdx
; // 68 4 Primary color index, -1 if none
678 Int32 uiAltColIdx
; // 72 4 Alternate color index, -1 if none
679 Int16 iPad4
; // 76 2 Reserved
680 Int16 iShaderIdx
; // 78 2 Shader index, -1 if none
682 /*---------------------------------------------------------------------*/
684 OFVertexListRecordRCPtr _pVList
;
686 /*---------------------------------------------------------------------*/
688 OFFaceRecord(const OFRecordHeader
&oHeader
,
690 virtual ~OFFaceRecord(void );
694 static const UInt16 OpCode
= 5;
696 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
699 /*---------------------------------------------------------------------*/
701 virtual bool read (std::istream
&is
);
702 virtual bool addChild(OFRecord
*pChild
);
704 /*---------------------------------------------------------------------*/
706 virtual UInt16
getOpCode(void) const;
708 /*---------------------------------------------------------------------*/
710 virtual void dump(UInt32 uiIndent
) const;
712 /*---------------------------------------------------------------------*/
714 bool operator ==(const OFFaceRecord
&rhs
) const;
716 /*---------------------------------------------------------------------*/
718 OFVertexListRecord
*getVertexList (void);
719 Int8
getDrawType (void) const;
720 Int8
getTextureWhite(void) const;
721 Int16
getTexIdx (void) const;
722 Int16
getMatIdx (void) const;
723 UInt16
getTransparency(void) const;
724 Int32
getFlags (void) const;
725 UInt8
getLightMode (void) const;
726 Color4f
getPrimColor (void) const;
727 Color4f
getAltColor (void) const;
730 /*! \ingroup GrpFileIOOpenFlight
732 typedef RefCountPtr
<OFFaceRecord
, MemObjRefCountPolicy
> OFFaceRecordRCPtr
;
734 //---------------------------------------------------------------------------
736 //---------------------------------------------------------------------------
738 /*! \ingroup GrpFileIOOpenFlight
742 class OSG_FILEIO_DLLMAPPING OFVertexListRecord
: public OFPrimaryRecord
746 /*---------------------------------------------------------------------*/
748 typedef OFPrimaryRecord Inherited
;
750 /*---------------------------------------------------------------------*/
752 static OFRecordFactoryBase::RegisterRecord _regHelper
;
754 /*---------------------------------------------------------------------*/
756 std::vector
<Int32
> _vIndices
;
758 /*---------------------------------------------------------------------*/
760 OFVertexListRecord(const OFRecordHeader
&oHeader
,
762 virtual ~OFVertexListRecord(void );
766 static const UInt16 OpCode
= 72;
768 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
771 /*---------------------------------------------------------------------*/
773 virtual bool read(std::istream
&is
);
775 /*---------------------------------------------------------------------*/
777 virtual UInt16
getOpCode(void) const;
779 /*---------------------------------------------------------------------*/
781 const std::vector
<Int32
> &getIndices(void);
784 //---------------------------------------------------------------------------
786 //---------------------------------------------------------------------------
788 /*! \ingroup GrpFileIOOpenFlight
792 class OSG_FILEIO_DLLMAPPING OFLODRecord
: public OFPrimaryRecord
796 /*---------------------------------------------------------------------*/
798 typedef OFPrimaryRecord Inherited
;
800 /*---------------------------------------------------------------------*/
802 static OFRecordFactoryBase::RegisterRecord _regHelper
;
804 /*---------------------------------------------------------------------*/
806 Char8 szASCIIId
[8]; // 4 8 7 char ASCII ID; 0 terminates
807 Int32 iPad1
; // 12 4 Reserved
808 Real64 rSwitchIn
; // 16 8 Switch-in distance
809 Real64 rSwitchOut
; // 24 8 Switch-out distance
810 Int16 iSpecialEff1
; // 32 2 Special effect ID1 - application defined
811 Int16 iSpecialEff2
; // 34 2 Special effect ID2 - application defined
812 Int32 iFlags
; // 36 4 Flags (bits, from left to right)
813 // 0 = Use previous slant range
815 // 2 = Freeze center (don't recalculate)
817 Real64 rCenterX
; // 40 8 Center coordinate x of LOD
818 Real64 rCenterY
; // 48 8 Center coordinate y of LOD
819 Real64 rCenterZ
; // 56 8 Center coordinate z of LOD
820 Real64 rTransRange
; // 64 8 Transition range
821 Real64 rSigSize
; // 72 8 Significant size
823 /*---------------------------------------------------------------------*/
825 OFLODRecord(const OFRecordHeader
&oHeader
,
827 virtual ~OFLODRecord(void );
831 static const UInt16 OpCode
= 73;
833 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
836 /*---------------------------------------------------------------------*/
838 virtual bool read (std::istream
&is
);
839 virtual NodeTransitPtr
convertToNode(void );
841 /*---------------------------------------------------------------------*/
843 virtual UInt16
getOpCode(void) const;
845 /*---------------------------------------------------------------------*/
847 virtual void dump(UInt32 uiIndent
) const;
849 /*---------------------------------------------------------------------*/
851 Real64
getSwitchIn (void);
852 Real64
getSwitchOut(void);
854 Pnt3f
getCenter (void);
856 NodeTransitPtr
convertAncillaryChildren(Node
*pNode
);
859 //---------------------------------------------------------------------------
861 //---------------------------------------------------------------------------
863 /*! \ingroup GrpFileIOOpenFlight
867 class OSG_FILEIO_DLLMAPPING OFSwitchRecord
: public OFPrimaryRecord
871 /*---------------------------------------------------------------------*/
873 typedef OFPrimaryRecord Inherited
;
875 static OFRecordFactoryBase::RegisterRecord _regHelper
;
877 /*---------------------------------------------------------------------*/
879 typedef std::vector
< std::vector
<UInt32
> > MaskStore
;
881 /*---------------------------------------------------------------------*/
883 Char8 szASCIIID
[8]; // 4 8 7 char ASCII ID; 0 terminates
884 Int32 szPad1
; // 12 4 Reserved
885 Int32 iCurrMask
; // 16 4 Current mask
886 Int32 iNumMask
; // 20 4 Number of masks
887 Int32 iMaskWords
; // 24 4 Number of words per mask -
888 // the number of 32 bit words
889 // required for each mask, calculated as follows:
890 // (number of children / 32) + X
892 // 0 if (number of children modulo 32) is zero
893 // 1 if (number of children modulo 32) is nonzero
894 MaskStore vMask
; // Unsigned Int 28 Variable Mask words.
895 // The length (in bytes) can be calculated as follows:
896 // Number of words per mask * Number of masks * 4 bytes
898 /*---------------------------------------------------------------------*/
900 OFSwitchRecord(const OFRecordHeader
&oHeader
,
902 virtual ~OFSwitchRecord(void );
906 static const UInt16 OpCode
= 96;
908 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
911 /*---------------------------------------------------------------------*/
913 virtual bool read (std::istream
&is
);
914 virtual NodeTransitPtr
convertToNode(void );
916 /*---------------------------------------------------------------------*/
918 virtual UInt16
getOpCode(void) const;
920 /*---------------------------------------------------------------------*/
922 virtual void dump(UInt32 uiIndent
) const;
924 NodeTransitPtr
convertAncillaryChildren(Node
*pNode
);
927 //---------------------------------------------------------------------------
929 //---------------------------------------------------------------------------
931 /*! \ingroup GrpFileIOOpenFlight
935 class OSG_FILEIO_DLLMAPPING OFExternalReferenceRecord
: public OFPrimaryRecord
939 typedef OFPrimaryRecord Inherited
;
941 static OFRecordFactoryBase::RegisterRecord _regHelper
;
943 /*---------------------------------------------------------------------*/
945 Char8 szFilename
[200]; // 4 200 199-char ASCII path; 0 terminates
946 // Format of this string is: filename<node name>
947 // if <node name> absent, references entire file
948 Int32 iPad1
; // 204 4 Reserved
949 Int32 iFlags
; // 208 4 Flags (bits, from left to right)
950 // 0 = Color palette override
951 // 1 = Material palette override
952 // 2 = Texture and texture mapping palette override
953 // 3 = Line style palette override
954 // 4 = Sound palette override
955 // 5 = Light source palette override
956 // 6 = Light point palette override
957 // 7 = Shader palette override
959 Int16 iViewAsBBox
; // 212 2 View as bounding box
960 // 0 = View external reference normally
961 // 1 = View external reference as bounding box
962 Int16 iPad2
; // 214 2 Reserved
964 /*---------------------------------------------------------------------*/
966 OFExternalReferenceRecord(const OFRecordHeader
&oHeader
,
968 virtual ~OFExternalReferenceRecord(void );
972 static const UInt16 OpCode
= 63;
974 static OFRecordTransitPtr
create(const OFRecordHeader
&oHeader
,
977 /*---------------------------------------------------------------------*/
979 virtual bool read (std::istream
&is
);
980 virtual NodeTransitPtr
convertToNode(void );
982 /*---------------------------------------------------------------------*/
984 virtual UInt16
getOpCode(void) const;
986 /*---------------------------------------------------------------------*/
988 virtual void dump(UInt32 uiIndent
) const;
990 NodeTransitPtr
convertAncillaryChildren(Node
*pNode
);
995 #endif /* _OSGOFPRIMARYRECORDS_H_ */