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 \*---------------------------------------------------------------------------*/
30 #include "OSGOFAncillaryRecords.h"
32 #include "OSGImageFileHandler.h"
33 #include "OSGNameAttachment.h"
34 #include "OSGTransform.h"
35 #include "OSGOFDatabase.h"
36 #include "OSGOpenFlightLog.h"
37 #include "OSGPathHandler.h"
41 //---------------------------------------------------------------------
42 // OFColorPaletteRecord
43 //---------------------------------------------------------------------
46 OFRecordTransitPtr
OFColorPaletteRecord::create(const OFRecordHeader
&oHeader
,
49 return OFRecordTransitPtr(new OFColorPaletteRecord(oHeader
, oDB
));
52 OFColorPaletteRecord::OFColorPaletteRecord(const OFRecordHeader
&oHeader
,
54 Inherited (oHeader
, oDB
),
61 OFColorPaletteRecord::~OFColorPaletteRecord(void)
66 bool OFColorPaletteRecord::read(std::istream
&is
)
68 OSG_OPENFLIGHT_LOG(("OFColorPaletteRecord::read len [%u]\n", _sLength
));
71 Inherited::readChar8(is
, reserved1
, 128);
73 bool bHasNames
= _sLength
> 4228;
74 UInt32 numColors
= 1024;
76 if(bHasNames
== false)
78 // number of colors derived from record size
79 UInt32 numColors2
= (_sLength
- 132) / 4;
81 numColors
= osgMin(numColors
, numColors2
);
84 for(UInt32 i
= 0; i
< numColors
; ++i
)
91 Inherited::readVal(is
, alpha
);
92 Inherited::readVal(is
, blue
);
93 Inherited::readVal(is
, green
);
94 Inherited::readVal(is
, red
);
96 colors
.push_back(Color4f(red
/ 255.f
, green
/ 255.f
,
97 blue
/ 255.f
, alpha
/ 255.f
));
100 if(bHasNames
== true)
102 colorNames
.resize(numColors
);
105 Inherited::readVal(is
, numNames
);
107 for(Int32 i
= 0; i
< numNames
; ++i
)
115 Inherited::readVal (is
, nameLen
);
116 Inherited::readVal (is
, reserved2
);
117 Inherited::readVal (is
, colorIdx
);
118 Inherited::readVal (is
, reserved3
);
119 Inherited::readChar8(is
, name
, 80);
121 colorNames
[colorIdx
] = std::string(name
);
129 UInt16
OFColorPaletteRecord::getOpCode(void) const
135 void OFColorPaletteRecord::dump(UInt32 uiIndent
) const
137 indentLog(uiIndent
, PLOG
);
138 PLOG
<< "ColorPaletteRecord" << std::endl
;
140 indentLog(uiIndent
, PLOG
);
141 PLOG
<< "{" << std::endl
;
145 for(UInt32 i
= 0; i
< colors
.size(); ++i
)
147 indentLog(uiIndent
, PLOG
);
148 PLOG
<< "Color " << colors
[i
];
150 if(colorNames
.empty() == false)
151 PLOG
<< " name " << colorNames
[i
];
158 indentLog(uiIndent
, PLOG
);
159 PLOG
<< "}" << std::endl
;
162 Color4f
OFColorPaletteRecord::getColor(UInt32 uiIdx
) const
165 UInt32 uiRealIdx
= uiIdx
>> 7;
166 Real32 intensity
= (uiIdx
& 0x7f) / 127.f
;
168 OSG_ASSERT(uiRealIdx
< colors
.size());
170 returnValue
= colors
[uiRealIdx
];
171 returnValue
[0] *= intensity
;
172 returnValue
[1] *= intensity
;
173 returnValue
[2] *= intensity
;
178 bool OFColorPaletteRecord::hasNames(void) const
180 return !colorNames
.empty();
183 std::string
const &OFColorPaletteRecord::getName(UInt32 uiIdx
) const
185 return colorNames
[uiIdx
];
188 OFRecordFactoryBase::RegisterRecord
OFColorPaletteRecord::_regHelper(
189 &OFColorPaletteRecord::create
,
190 OFColorPaletteRecord::OpCode
);
192 //---------------------------------------------------------------------
193 // OFTexturePaletteRecord
194 //---------------------------------------------------------------------
196 GLenum
OFTexturePaletteRecord::TexAttr::getMinFilter(void)
198 GLenum returnValue
= GL_NEAREST
;
202 case 0: returnValue
= GL_NEAREST
; break; // point
203 case 1: returnValue
= GL_LINEAR
; break; // bilinear
204 case 3: returnValue
= GL_NEAREST_MIPMAP_NEAREST
; break; // mipmap point
205 case 4: returnValue
= GL_NEAREST_MIPMAP_LINEAR
; break; // mipmap linear
206 case 5: returnValue
= GL_LINEAR_MIPMAP_NEAREST
; break; // mipmap bilinear
207 case 7: returnValue
= GL_LINEAR_MIPMAP_LINEAR
; break; // mipmap trilinear
210 case 10: // bilinear GEQ
211 case 11: // bilinear LEQ
212 case 12: // bicubic GEQ
213 case 13: // bicubic LEQ
214 returnValue
= GL_LINEAR_MIPMAP_NEAREST
;
217 default: returnValue
= GL_LINEAR_MIPMAP_LINEAR
; break;
223 GLenum
OFTexturePaletteRecord::TexAttr::getMagFilter(void)
225 GLenum returnValue
= GL_NEAREST
;
229 case 0: returnValue
= GL_NEAREST
; break; // point
234 case 5: // add detail
235 case 6: // modulate detail
236 case 7: // bilinear GEQ
237 case 8: // bilinear LEQ
238 case 9: // bicubic GEQ
239 case 10: // bicubic LEQ
240 returnValue
= GL_LINEAR
;
247 GLenum
OFTexturePaletteRecord::TexAttr::getWrapU(void)
249 return getWrap(wrapU
);
252 GLenum
OFTexturePaletteRecord::TexAttr::getWrapV(void)
254 return getWrap(wrapV
);
257 GLenum
OFTexturePaletteRecord::TexAttr::getEnvMode(void)
259 GLenum returnValue
= GL_MODULATE
;
263 case 0: returnValue
= GL_MODULATE
; break; // modulate
264 case 1: returnValue
= GL_BLEND
; break; // blend
265 case 2: returnValue
= GL_DECAL
; break; // decal
266 case 3: returnValue
= GL_REPLACE
; break; // replace
267 case 4: returnValue
= GL_ADD
; break; // add
273 GLenum
OFTexturePaletteRecord::TexAttr::getWrap(Int32 wrap
)
275 GLenum returnValue
= GL_REPEAT
;
279 case 0: returnValue
= GL_REPEAT
; break; // repeat
280 case 1: returnValue
= GL_CLAMP_TO_EDGE
; break; // clamp
281 case 4: returnValue
= GL_REPEAT
; break; // mirror
288 OFRecordTransitPtr
OFTexturePaletteRecord::create(const OFRecordHeader
&oHeader
,
291 return OFRecordTransitPtr(new OFTexturePaletteRecord(oHeader
, oDB
));
294 bool OFTexturePaletteRecord::readTexAttr(TexAttr
&attr
)
296 bool returnValue
= false;
297 PathHandler
*ph
= ImageFileHandler::the()->getPathHandler();
301 std::string imgFile
= szFilename
;
302 std::string attrFile
= imgFile
+ ".attr";
304 attrFile
= ph
->findFile(attrFile
.c_str());
306 if(attrFile
.empty() == false)
308 OSG_OPENFLIGHT_LOG(("OFTexturePaletteRecord::readTexAttr: [%s]\n",
312 ifs
.open(attrFile
.c_str(), std::ios::in
| std::ios::binary
);
314 Inherited::readVal(ifs
, attr
.numTexelU
);
315 Inherited::readVal(ifs
, attr
.numTexelV
);
316 Inherited::readVal(ifs
, attr
.realSizeU
);
317 Inherited::readVal(ifs
, attr
.realSizeV
);
318 Inherited::readVal(ifs
, attr
.upX
);
319 Inherited::readVal(ifs
, attr
.upY
);
320 Inherited::readVal(ifs
, attr
.fileFormat
);
321 Inherited::readVal(ifs
, attr
.minFilter
);
322 Inherited::readVal(ifs
, attr
.magFilter
);
323 Inherited::readVal(ifs
, attr
.wrapUV
);
324 Inherited::readVal(ifs
, attr
.wrapU
);
325 Inherited::readVal(ifs
, attr
.wrapV
);
326 Inherited::readVal(ifs
, attr
.modified
);
327 Inherited::readVal(ifs
, attr
.pivotX
);
328 Inherited::readVal(ifs
, attr
.pivotY
);
329 Inherited::readVal(ifs
, attr
.envMode
);
332 attr
.wrapU
= attr
.wrapUV
;
334 attr
.wrapV
= attr
.wrapUV
;
343 OFTexturePaletteRecord::OFTexturePaletteRecord(const OFRecordHeader
&oHeader
,
355 OFTexturePaletteRecord::~OFTexturePaletteRecord(void)
361 bool OFTexturePaletteRecord::read(std::istream
&is
)
363 Inherited::readChar8(is
, szFilename
, 200);
364 Inherited::readVal (is
, iPatternIdx
);
365 Inherited::readVal (is
, iPatternX
);
366 Inherited::readVal (is
, iPatternY
);
368 OSG_OPENFLIGHT_LOG(("OFTexturePaletteRecord::read len "
369 "[%u] file [%s] idx [%d]\n",
370 _sLength
, szFilename
, iPatternIdx
));
372 ImageUnrecPtr pImage
= ImageFileHandler::the()->read(szFilename
);
376 pTexObj
= TextureObjChunk::create();
378 pTexObj
->setImage(pImage
);
382 std::string szTmp
= szFilename
;
384 std::string::size_type uiPos
= szTmp
.rfind('/');
386 if(uiPos
!= std::string::npos
)
388 pImage
= ImageFileHandler::the()->read(
389 &(szFilename
[uiPos
+ 1]));
393 pTexObj
= TextureObjChunk::create();
395 pTexObj
->setImage(pImage
);
399 FWARNING(("OFTexturePaletteRecord::read: Could not read image "
400 "[%s].\n", &(szFilename
[uiPos
+ 1])));
405 FWARNING(("OFTexturePaletteRecord::read: Could not read image "
406 "[%s].\n", szFilename
));
413 if(readTexAttr(attr
) == true)
415 pTexObj
->setMinFilter(attr
.getMinFilter());
416 pTexObj
->setMagFilter(attr
.getMagFilter());
417 pTexObj
->setWrapS (attr
.getWrapU ());
418 pTexObj
->setWrapT (attr
.getWrapV ());
420 pTexEnv
= TextureEnvChunk::create();
421 pTexEnv
->setEnvMode(attr
.getEnvMode());
429 UInt16
OFTexturePaletteRecord::getOpCode(void) const
434 void OFTexturePaletteRecord::dump(UInt32 uiIndent
) const
436 indentLog(uiIndent
, PLOG
);
437 PLOG
<< "TexturePaletteRecord" << std::endl
;
439 indentLog(uiIndent
, PLOG
);
440 PLOG
<< "{" << std::endl
;
444 indentLog(uiIndent
, PLOG
);
445 PLOG
<< "Filename : " << szFilename
<< std::endl
;
447 indentLog(uiIndent
, PLOG
);
448 PLOG
<< "PatternIdx : " << iPatternIdx
<< std::endl
;
450 indentLog(uiIndent
, PLOG
);
451 PLOG
<< "PatternX : " << iPatternX
<< std::endl
;
453 indentLog(uiIndent
, PLOG
);
454 PLOG
<< "PatternY : " << iPatternY
<< std::endl
;
458 indentLog(uiIndent
, PLOG
);
459 PLOG
<< "}" << std::endl
;
462 Int32
OFTexturePaletteRecord::getPatternIdx(void)
467 TextureObjChunk
*OFTexturePaletteRecord::getTexObj(void) const
472 TextureEnvChunk
*OFTexturePaletteRecord::getTexEnv(void) const
477 OFRecordFactoryBase::RegisterRecord
OFTexturePaletteRecord::_regHelper(
478 &OFTexturePaletteRecord::create
,
479 OFTexturePaletteRecord::OpCode
);
481 //---------------------------------------------------------------------
482 // OFVertexPaletteRecord
483 //---------------------------------------------------------------------
485 OFRecordTransitPtr
OFVertexPaletteRecord::create(const OFRecordHeader
&oHeader
,
488 return OFRecordTransitPtr(new OFVertexPaletteRecord(oHeader
, oDB
));
491 OFVertexPaletteRecord::OFVertexPaletteRecord(const OFRecordHeader
&oHeader
,
502 OFVertexPaletteRecord::~OFVertexPaletteRecord(void)
506 bool OFVertexPaletteRecord::read(std::istream
&is
)
508 OSG_OPENFLIGHT_LOG(("OFVertexPaletteRecord::read len [%u]\n",
511 static std::vector
<char> tmpBuf
;
514 Inherited::readVal(is
, iFullLength
);
518 OFRecordHeader oRHeader
;
525 while(iRead
< iFullLength
- 8 && is
.good() == true)
527 rc
= oRHeader
.read(is
);
534 tmpInfo
.uiType
= HasPos
| HasCol
;
535 tmpInfo
.uiOffset
= iRead
+ 8;
537 tmpInfo
.uiIdx
[ColIdx
] = -1;
538 tmpInfo
.uiIdx
[NormIdx
] = -1;
539 tmpInfo
.uiIdx
[TexCoordIdx
] = -1;
543 uiSize
+= Inherited::readVal(is
, tmpInfo
.uiColNameIdx
);
544 uiSize
+= Inherited::readVal(is
, tmpInfo
.iFlags
);
546 uiSize
+= Inherited::readVal(is
, tmpPos
[0]);
547 uiSize
+= Inherited::readVal(is
, tmpPos
[1]);
548 uiSize
+= Inherited::readVal(is
, tmpPos
[2]);
550 tmpPos
*= _oDB
.getUnitScale();
552 tmpInfo
.uiIdx
[PosIdx
] = UInt32(vPositions
.size());
554 vPositions
.push_back(Pnt3f(tmpPos
));
556 if(oRHeader
.sOpCode
== 69 || oRHeader
.sOpCode
== 70)
558 uiSize
+= Inherited::readVal(is
, tmpNorm
[0]);
559 uiSize
+= Inherited::readVal(is
, tmpNorm
[1]);
560 uiSize
+= Inherited::readVal(is
, tmpNorm
[2]);
562 tmpInfo
.uiIdx
[NormIdx
] = UInt32(vNormals
.size());
563 tmpInfo
.uiType
|= HasNorm
;
565 vNormals
.push_back(tmpNorm
);
568 if(oRHeader
.sOpCode
== 70 || oRHeader
.sOpCode
== 71)
570 uiSize
+= Inherited::readVal(is
, tmpTexCoord
[0]);
571 uiSize
+= Inherited::readVal(is
, tmpTexCoord
[1]);
573 tmpInfo
.uiIdx
[TexCoordIdx
] = UInt32(vTexCoords
.size());
574 tmpInfo
.uiType
|= HasTexCoord
;
576 vTexCoords
.push_back(tmpTexCoord
);
579 uiSize
+= Inherited::readVal(is
, tmpInfo
.iPackedCol
);
580 uiSize
+= Inherited::readVal(is
, tmpInfo
.iColIdx
);
582 if(oRHeader
.sOpCode
== 69 || oRHeader
.sOpCode
== 70)
584 if(uiSize
< oRHeader
.sLength
- 4)
586 uiSize
+= Inherited::readVal(is
, tmpInfo
.iPad1
);
590 vVertexInfo
.push_back(tmpInfo
);
592 iRead
+= oRHeader
.sLength
;
596 fprintf(stderr
, "Got %d vertices\n",
603 UInt16
OFVertexPaletteRecord::getOpCode(void) const
608 const OFVertexPaletteRecord::VertexInfo
*
609 OFVertexPaletteRecord::getVertexInfo(UInt32 uiOff
) const
611 std::vector
<VertexInfo
>::const_iterator iLBound
=
612 std::lower_bound(vVertexInfo
.begin(),
616 if(iLBound
!= vVertexInfo
.end())
624 const Pnt3f
&OFVertexPaletteRecord::getPos(UInt32 uiIdx
) const
626 OSG_ASSERT(uiIdx
< vPositions
.size());
628 return vPositions
[uiIdx
];
631 const Vec3f
&OFVertexPaletteRecord::getNormal(UInt32 uiIdx
) const
633 OSG_ASSERT(uiIdx
< vNormals
.size());
635 return vNormals
[uiIdx
];
638 const Vec2f
&OFVertexPaletteRecord::getTexCoord(UInt32 uiIdx
) const
640 OSG_ASSERT(uiIdx
< vTexCoords
.size());
642 return vTexCoords
[uiIdx
];
645 bool OFVertexPaletteRecord::VertexInfo::operator <(const UInt32 uiOff
) const
647 return this->uiOffset
< uiOff
;
650 bool OFVertexPaletteRecord::VertexInfo::operator <(
651 const VertexInfo
&vInfo
) const
653 return this->uiOffset
< vInfo
.uiOffset
;
656 bool operator <(const UInt32 uiOff
,
657 const OFVertexPaletteRecord::VertexInfo
&vInfo
)
659 return uiOff
< vInfo
.uiOffset
;
662 OFRecordFactoryBase::RegisterRecord
OFVertexPaletteRecord::_regHelper(
663 &OFVertexPaletteRecord::create
,
664 OFVertexPaletteRecord::OpCode
);
667 //---------------------------------------------------------------------
668 // OFMaterialPaletteRecord
669 //---------------------------------------------------------------------
671 OFMaterialPaletteRecord::OFMaterialPaletteRecord(
672 const OFRecordHeader
&oHeader
,
693 OFMaterialPaletteRecord::~OFMaterialPaletteRecord(void)
698 OFRecordTransitPtr
OFMaterialPaletteRecord::create(
699 const OFRecordHeader
&oHeader
, OFDatabase
&oDB
)
701 return OFRecordTransitPtr(new OFMaterialPaletteRecord(oHeader
, oDB
));
704 bool OFMaterialPaletteRecord::read(std::istream
&is
)
706 OSG_OPENFLIGHT_LOG(("OFMaterialPaletteRecord::read len [%u]\n",
709 Inherited::readVal (is
, iMaterialIdx
);
710 Inherited::readChar8(is
, szMaterialName
, 12);
711 Inherited::readVal (is
, iFlags
);
712 Inherited::readVal (is
, colAmbient
[0] );
713 Inherited::readVal (is
, colAmbient
[1] );
714 Inherited::readVal (is
, colAmbient
[2] );
715 Inherited::readVal (is
, colDiffuse
[0] );
716 Inherited::readVal (is
, colDiffuse
[1] );
717 Inherited::readVal (is
, colDiffuse
[2] );
718 Inherited::readVal (is
, colSpecular
[0] );
719 Inherited::readVal (is
, colSpecular
[1] );
720 Inherited::readVal (is
, colSpecular
[2] );
721 Inherited::readVal (is
, colEmissive
[0] );
722 Inherited::readVal (is
, colEmissive
[1] );
723 Inherited::readVal (is
, colEmissive
[2] );
724 Inherited::readVal (is
, fShininess
);
725 Inherited::readVal (is
, fAlpha
);
726 Inherited::readVal (is
, iPad
);
731 UInt16
OFMaterialPaletteRecord::getOpCode(void) const
736 void OFMaterialPaletteRecord::dump(UInt32 uiIndent
) const
738 indentLog(uiIndent
, PLOG
);
739 PLOG
<< "OFMaterialPaletteRecord : " << std::endl
;
741 indentLog(uiIndent
, PLOG
);
742 PLOG
<< "{" << std::endl
;
746 indentLog(uiIndent
, PLOG
);
747 PLOG
<< "MaterialIdx : " << iMaterialIdx
<< std::endl
;
749 indentLog(uiIndent
, PLOG
);
750 PLOG
<< "MaterialName : " << szMaterialName
<< std::endl
;
752 indentLog(uiIndent
, PLOG
);
753 PLOG
<< "ColAmbient : " << colAmbient
<< std::endl
;
755 indentLog(uiIndent
, PLOG
);
756 PLOG
<< "ColDiffuse : " << colDiffuse
<< std::endl
;
758 indentLog(uiIndent
, PLOG
);
759 PLOG
<< "ColSpecular : " << colSpecular
<< std::endl
;
761 indentLog(uiIndent
, PLOG
);
762 PLOG
<< "ColEmissive : " << colEmissive
<< std::endl
;
764 indentLog(uiIndent
, PLOG
);
765 PLOG
<< "Shininess : " << fShininess
<< std::endl
;
767 indentLog(uiIndent
, PLOG
);
768 PLOG
<< "Alpha : " << fAlpha
<< std::endl
;
772 indentLog(uiIndent
, PLOG
);
773 PLOG
<< "}" << std::endl
;
776 Int32
OFMaterialPaletteRecord::getMaterialIdx(void)
781 const Color4f
&OFMaterialPaletteRecord::getAmbient(void) const
786 const Color4f
&OFMaterialPaletteRecord::getDiffuse(void) const
791 const Color4f
&OFMaterialPaletteRecord::getSpecular(void) const
796 const Color4f
&OFMaterialPaletteRecord::getEmissive(void) const
801 Real32
OFMaterialPaletteRecord::getShininess(void) const
806 Real32
OFMaterialPaletteRecord::getAlpha(void) const
811 OFRecordFactoryBase::RegisterRecord
OFMaterialPaletteRecord::_regHelper(
812 &OFMaterialPaletteRecord::create
,
813 OFMaterialPaletteRecord::OpCode
);
815 //---------------------------------------------------------------------
817 //---------------------------------------------------------------------
820 OFRecordTransitPtr
OFMatrixRecord::create(const OFRecordHeader
&oHeader
,
823 return OFRecordTransitPtr(new OFMatrixRecord(oHeader
, oDB
));
826 OFMatrixRecord::OFMatrixRecord(const OFRecordHeader
&oHeader
,
828 Inherited(oHeader
, oDB
),
834 OFMatrixRecord::~OFMatrixRecord(void)
839 bool OFMatrixRecord::read(std::istream
&is
)
841 OSG_OPENFLIGHT_LOG(("OFMatrixRecord::read len [%u]\n", _sLength
));
843 Inherited::readVal(is
, matrix
[0][0]);
844 Inherited::readVal(is
, matrix
[0][1]);
845 Inherited::readVal(is
, matrix
[0][2]);
846 Inherited::readVal(is
, matrix
[0][3]);
848 Inherited::readVal(is
, matrix
[1][0]);
849 Inherited::readVal(is
, matrix
[1][1]);
850 Inherited::readVal(is
, matrix
[1][2]);
851 Inherited::readVal(is
, matrix
[1][3]);
853 Inherited::readVal(is
, matrix
[2][0]);
854 Inherited::readVal(is
, matrix
[2][1]);
855 Inherited::readVal(is
, matrix
[2][2]);
856 Inherited::readVal(is
, matrix
[2][3]);
858 Inherited::readVal(is
, matrix
[3][0]);
859 Inherited::readVal(is
, matrix
[3][1]);
860 Inherited::readVal(is
, matrix
[3][2]);
861 Inherited::readVal(is
, matrix
[3][3]);
863 matrix
[3][0] *= _oDB
.getUnitScale();
864 matrix
[3][1] *= _oDB
.getUnitScale();
865 matrix
[3][2] *= _oDB
.getUnitScale();
871 UInt16
OFMatrixRecord::getOpCode(void) const
877 void OFMatrixRecord::dump(UInt32 uiIndent
) const
879 indentLog(uiIndent
, PLOG
);
880 PLOG
<< "MatrixRecord" << std::endl
;
882 indentLog(uiIndent
, PLOG
);
883 PLOG
<< "{" << std::endl
;
887 indentLog(uiIndent
, PLOG
);
888 PLOG
<< matrix
[0][0] << " " << matrix
[1][0] << " "
889 << matrix
[2][0] << " " << matrix
[3][0] << std::endl
;
891 indentLog(uiIndent
, PLOG
);
892 PLOG
<< matrix
[0][1] << " " << matrix
[1][1] << " "
893 << matrix
[2][1] << " " << matrix
[3][1] << std::endl
;
895 indentLog(uiIndent
, PLOG
);
896 PLOG
<< matrix
[0][2] << " " << matrix
[1][2] << " "
897 << matrix
[2][2] << " " << matrix
[3][2] << std::endl
;
899 indentLog(uiIndent
, PLOG
);
900 PLOG
<< matrix
[0][3] << " " << matrix
[1][3] << " "
901 << matrix
[2][3] << " " << matrix
[3][3] << std::endl
;
905 indentLog(uiIndent
, PLOG
);
906 PLOG
<< "}" << std::endl
;
908 Inherited::dump(uiIndent
);
912 NodeTransitPtr
OFMatrixRecord::convert(Node
*pNode
)
914 NodeUnrecPtr
returnValue(NULL
);
918 TransformUnrecPtr pXform
= Transform::create();
919 pXform
->setMatrix(matrix
);
921 returnValue
= makeNodeFor(pXform
);
922 returnValue
->addChild(pNode
);
925 return NodeTransitPtr(returnValue
);
928 OFRecordFactoryBase::RegisterRecord
OFMatrixRecord::_regHelper(
929 &OFMatrixRecord::create
,
930 OFMatrixRecord::OpCode
);
932 //---------------------------------------------------------------------
933 // OFIgnoredTransformRecord
934 //---------------------------------------------------------------------
937 OFRecordTransitPtr
OFIgnoredTransformRecord::create(
938 const OFRecordHeader
&oHeader
,
941 return OFRecordTransitPtr(new OFIgnoredTransformRecord(oHeader
, oDB
));
944 OFIgnoredTransformRecord::OFIgnoredTransformRecord(
945 const OFRecordHeader
&oHeader
,
948 Inherited(oHeader
, oDB
),
949 _sOpCode (oHeader
.sOpCode
)
954 OFIgnoredTransformRecord::~OFIgnoredTransformRecord(void)
959 bool OFIgnoredTransformRecord::read(std::istream
&is
)
961 OSG_OPENFLIGHT_LOG(("OFIgnoredTransformRecord::read op [%u][%s] len [%u]\n",
962 _sOpCode
, getOpCodeString(_sOpCode
), _sLength
));
964 static std::vector
<char> tmpBuf
;
968 tmpBuf
.resize(_sLength
);
970 is
.read(&(tmpBuf
.front()), _sLength
- 4);
977 NodeTransitPtr
OFIgnoredTransformRecord::convert(Node
*pNode
)
979 return NodeTransitPtr(pNode
);
983 UInt16
OFIgnoredTransformRecord::getOpCode(void) const
989 void OFIgnoredTransformRecord::dump(UInt32 uiIndent
) const
991 indentLog(uiIndent
, PLOG
);
992 PLOG
<< "OFIgnoredTransformRecord - " << _sOpCode
993 << " - " << getOpCodeString(_sOpCode
)
997 OFRecordFactoryBase::RegisterRecord
998 OFIgnoredTransformRecord::_regHelperRotateAboutEdge(
999 &OFIgnoredTransformRecord::create
,
1000 OFIgnoredTransformRecord::OpCodeRotateAboutEdge
);
1002 OFRecordFactoryBase::RegisterRecord
1003 OFIgnoredTransformRecord::_regHelperTranslate(
1004 &OFIgnoredTransformRecord::create
,
1005 OFIgnoredTransformRecord::OpCodeTranslate
);
1007 OFRecordFactoryBase::RegisterRecord
1008 OFIgnoredTransformRecord::_regHelperScale(
1009 &OFIgnoredTransformRecord::create
,
1010 OFIgnoredTransformRecord::OpCodeScale
);
1012 OFRecordFactoryBase::RegisterRecord
1013 OFIgnoredTransformRecord::_regHelperRotateAboutPoint(
1014 &OFIgnoredTransformRecord::create
,
1015 OFIgnoredTransformRecord::OpCodeRotateAboutPoint
);
1017 OFRecordFactoryBase::RegisterRecord
1018 OFIgnoredTransformRecord::_regHelperRotateScaleToPoint(
1019 &OFIgnoredTransformRecord::create
,
1020 OFIgnoredTransformRecord::OpCodeRotateScaleToPoint
);
1022 OFRecordFactoryBase::RegisterRecord
1023 OFIgnoredTransformRecord::_regHelperPut(
1024 &OFIgnoredTransformRecord::create
,
1025 OFIgnoredTransformRecord::OpCodePut
);
1027 OFRecordFactoryBase::RegisterRecord
1028 OFIgnoredTransformRecord::_regHelperGeneralMatrix(
1029 &OFIgnoredTransformRecord::create
,
1030 OFIgnoredTransformRecord::OpCodeGeneralMatrix
);
1032 //---------------------------------------------------------------------
1034 //---------------------------------------------------------------------
1037 OFRecordTransitPtr
OFLongIDRecord::create(const OFRecordHeader
&oHeader
,
1040 return OFRecordTransitPtr(new OFLongIDRecord(oHeader
, oDB
));
1043 OFLongIDRecord::OFLongIDRecord(const OFRecordHeader
&oHeader
,
1045 Inherited(oHeader
, oDB
),
1051 OFLongIDRecord::~OFLongIDRecord(void)
1056 bool OFLongIDRecord::read(std::istream
&is
)
1058 OSG_OPENFLIGHT_LOG(("OFLongIDRecord::read len [%u]\n", _sLength
));
1060 longId
.resize(_sLength
- 4);
1061 is
.read(reinterpret_cast<Char8
*>(&(*longId
.begin())), _sLength
- 4);
1067 UInt16
OFLongIDRecord::getOpCode(void) const
1073 void OFLongIDRecord::dump(UInt32 uiIndent
) const
1075 indentLog(uiIndent
, PLOG
);
1076 PLOG
<< "LongIDRecord" << std::endl
;
1078 indentLog(uiIndent
, PLOG
);
1079 PLOG
<< "{" << std::endl
;
1083 indentLog(uiIndent
, PLOG
);
1084 PLOG
<< "longId: '" << longId
<< "'" << std::endl
;
1088 indentLog(uiIndent
, PLOG
);
1089 PLOG
<< "}" << std::endl
;
1091 Inherited::dump(uiIndent
);
1095 NodeTransitPtr
OFLongIDRecord::convert(Node
*pNode
)
1097 NodeUnrecPtr
returnValue(pNode
);
1101 setName(pNode
, longId
);
1104 return NodeTransitPtr(returnValue
);
1107 OFRecordFactoryBase::RegisterRecord
OFLongIDRecord::_regHelper(
1108 &OFLongIDRecord::create
,
1109 OFLongIDRecord::OpCode
);