1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 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 // AMZ disabled for now.
44 #include "OSGConfig.h"
48 #include "OSGVRMLFile.h"
50 #include "OSGFieldType.h"
51 #include "OSGMathMFields.h"
52 #include "OSGMathSFields.h"
53 #include "OSGVecMFields.h"
54 #include "OSGVecSFields.h"
57 #include "OSGAction.h"
58 #include "OSGMaterial.h"
59 #include "OSGMaterialGroup.h"
60 #include "OSGNameAttachment.h"
64 #include "OSGBlendChunk.h"
65 #include "OSGTextureObjChunk.h"
66 #include "OSGTextureEnvChunk.h"
67 #include "OSGFieldConnector.h"
70 #include "OSGSceneFileHandler.h"
72 //#define OSG_DEBUG_VRML
76 /*! \class OSG::VRMLFile
79 /*! \var OSG::VRMLFile::PushNames
80 Option to push the name attachments for entities that can not have a
81 NameAttachment in OpenSG to their respective parent.
83 This is currently only implemented for MaterialChunks and only sets the
84 name on the containing ChunkMaterial if that does not have a name of its
88 OSG::Time startTime
= 0.;
89 OSG::Time useTime
= 0.;
90 OSG::Time findTime
= 0.;
92 /*-------------------------------------------------------------------------*/
95 VRMLFile::VRMLFile(void) :
98 _pSceneRootNode (NULL
),
100 _pCurrNodeHelper(NULL
),
104 _pCurrentFieldFC (NULL
),
106 _pCurrentFieldDesc(NULL
),
114 Self::setReferenceHeader("#VRML V2.0 ");
116 initIntExtFieldTypeMapper();
117 initExtIntFieldTypeMapper();
120 /*-------------------------------------------------------------------------*/
123 VRMLFile::~VRMLFile(void)
127 /*-------------------------------------------------------------------------*/
128 /* Skel Replacements */
130 NodeTransitPtr
VRMLFile::scanStream(std::istream
&iStream
)
132 startTime
= getSystemTime();
134 _pSceneRootNode
= NULL
;
139 #ifdef OSG_DEBUG_VRML
140 VRMLNodeHelper::resetIndent();
145 Inherited::scanStream(iStream
);
148 SceneFileHandler::the()->updateReadProgress(100);
150 NodeTransitPtr
returnValue(_pSceneRootNode
);
152 _pSceneRootNode
= NULL
;
155 FINFO(("Full Time : %lf | Use Time %lf\n",
156 getSystemTime() - startTime
,
162 bool VRMLFile::checkHeader(void)
167 void VRMLFile::handleError(void *pSelf
, const Char8
*szErrorText
)
169 Inherited::handleError(pSelf
, szErrorText
);
170 // on an error we destroy the incomplete scene.
173 if(_pSceneRootNode
!= NULL
)
175 _pSceneRootNode
= NULL
;
180 void VRMLFile::beginNode(const Char8
*szNodeTypename
,
181 const Char8
*szNodename
,
182 const BitVector bvLocalFlags
)
184 SceneFileHandler::the()->updateReadProgress();
186 FieldContainerUnrecPtr pNewNode
;
188 #ifdef OSG_DEBUG_VRML
189 indentLog(VRMLNodeHelper::getIndent(), PINFO
);
190 PINFO
<< "Begin Node " << szNodeTypename
<< std::endl
;
192 VRMLNodeHelper::incIndent();
195 VRMLNodeHelper
*pOldHelper
= _pCurrNodeHelper
;
197 _pCurrNodeHelper
= findNodeHelper(szNodeTypename
);
199 _sNodeHelpers
.push(_pCurrNodeHelper
);
201 if(_pCurrNodeHelper
== NULL
)
203 std::string szTmp
= "Unknow node type '#";
205 szTmp
+= szNodeTypename
;
208 Inherited::handleError(this, szTmp
.c_str());
213 _pCurrNodeHelper
->reset();
215 pNewNode
= _pCurrNodeHelper
->beginNode( szNodeTypename
,
220 if(szNodename
!= NULL
)
224 std::string szKey
= szNodename
;
226 AttachmentContainer
*pAttC
=
227 dynamic_pointer_cast
<AttachmentContainer
>(pNewNode
);
231 setName(pAttC
, szKey
);
234 // amz - I removed the map checks that's more spec conform.
236 // If multiple nodes are given the same name,
237 // each USE statement refers to the closest node with the given
239 // in either the VRML file or prototype definition.
241 //NameContainerMap::iterator mIt = _nameFCMap.find(szKey);
242 //if(mIt == _nameFCMap.end())
244 _nameFCMap
[szKey
] = pNewNode
;
248 // PWARNING << "Did not add fieldContainer with name "
250 // << " a second time"
257 if(pOldHelper
!= NULL
)
259 pOldHelper
->setContainerFieldValue( pNewNode
,
264 _pCurrentFC
= pNewNode
;
266 _fcStack
.push(_pCurrentFC
);
268 if(_fcStack
.size() == 1)
270 Node
*pNode
= dynamic_cast<Node
*>(_pCurrentFC
.get());
274 if(_pSceneRootNode
== NULL
)
276 _pSceneRootNode
= Node::create();
278 _pSceneRootNode
->setCore(Group::create());
281 _pSceneRootNode
->addChild(pNode
);
286 void VRMLFile::endNode(void)
288 SceneFileHandler::the()->updateReadProgress();
290 if(_pCurrNodeHelper
== NULL
)
292 #ifdef OSG_DEBUG_VRML
293 VRMLNodeHelper::decIndent();
295 indentLog(VRMLNodeHelper::getIndent(), PINFO
);
296 PINFO
<< "End Node " << std::endl
;
301 if(_sNodeHelpers
.size() != 0)
303 _pCurrNodeHelper
= _sNodeHelpers
.top();
307 _pCurrNodeHelper
= NULL
;
313 _pCurrNodeHelper
->endNode(_pCurrentFC
);
317 if(_sNodeHelpers
.size() != 0)
319 _pCurrNodeHelper
= _sNodeHelpers
.top();
323 _pCurrNodeHelper
= NULL
;
326 if(_pCurrentFC
!= NULL
)
328 if(_pCurrentFC
->getType().isNode() == true)
330 Node
*pNode
= dynamic_cast<Node
*>(_pCurrentFC
.get());
332 if(pNode
->getCore() == NULL
)
334 pNode
->setCore(Group::create());
341 if(_fcStack
.size() != 0)
343 _pCurrentFC
= _fcStack
.top();
350 if(_pCurrentFieldDesc
!= NULL
)
352 _pCurrentFieldFC
= _pCurrentFC
;
354 #ifdef OSG_DEBUG_VRML
355 VRMLNodeHelper::decIndent();
357 indentLog(VRMLNodeHelper::getIndent(), PINFO
);
358 PINFO
<< "End Node " << std::endl
;
362 void VRMLFile::beginScript(const Char8
*szNodename
)
364 beginNode("Script", szNodename
, TypeTraits
<BitVector
>::BitsClear
);
367 void VRMLFile::endScript(void)
372 void VRMLFile::beginField(const Char8
*szFieldname
,
373 const UInt32
OSG_VRML_ARG(uiFieldTypeId
))
375 if(szFieldname
== NULL
)
378 #ifdef OSG_DEBUG_VRML
379 indentLog(VRMLNodeHelper::getIndent(), PINFO
);
380 PINFO
<< "VRMLFile::beginField : looking for "
387 << _pCurrentFieldDesc
389 << ScanParseSkel::OSGmfNode
392 VRMLNodeHelper::incIndent();
395 _fStack
.push(_pCurrentField
);
396 _fdStack
.push(_pCurrentFieldDesc
);
399 void VRMLFile::endField(void)
403 if(_fStack
.size() != 0)
405 _pCurrentField
= _fStack
.top();
409 _pCurrentField
.reset();
415 if(_fdStack
.size() != 0)
417 _pCurrentFieldDesc
= _fdStack
.top();
421 _pCurrentFieldDesc
= NULL
;
424 #ifdef OSG_DEBUG_VRML
425 VRMLNodeHelper::decIndent();
427 indentLog(VRMLNodeHelper::getIndent(), PINFO
);
428 PINFO
<< "VRMLFile::endField " << std::endl
;
433 void VRMLFile::addFieldValue(const Char8
*szFieldVal
)
435 if(_pCurrNodeHelper
!= NULL
)
437 _pCurrNodeHelper
->addFieldValue(_pCurrentField
,
443 void VRMLFile::addImageValue(Image
*pImage
)
445 if(_pCurrNodeHelper
!= NULL
)
447 _pCurrNodeHelper
->addImageValue(_pCurrentField
,
453 void VRMLFile::beginProto(const Char8
*szProtoname
)
455 Inherited::beginProto(szProtoname
);
457 _pCurrNodeHelper
= Inherited::_pCurrentHelper
;
460 void VRMLFile::endProtoInterface(void)
462 Inherited::endProtoInterface();
465 void VRMLFile::endProto(void)
467 Inherited::endProto();
469 if(_sNodeHelpers
.size() != 0)
471 _pCurrNodeHelper
= _sNodeHelpers
.top();
476 void VRMLFile::beginFieldDecl(const Char8
*szFieldType
,
477 const UInt32 uiFieldTypeId
,
478 const Char8
*szFieldName
)
480 Inherited::beginFieldDecl(szFieldType
, uiFieldTypeId
, szFieldName
);
482 getFieldType(szFieldName
);
484 beginField(szFieldName
, uiFieldTypeId
);
487 void VRMLFile::endFieldDecl(void)
489 Inherited::endFieldDecl();
495 UInt32
VRMLFile::getFieldType(const Char8
*szFieldname
)
497 UInt32 returnValue
= 0;
499 if(_pCurrNodeHelper
== NULL
)
502 if(szFieldname
== NULL
)
505 _pCurrentFieldFC
= NULL
;
506 _pCurrentField
.reset();
507 _pCurrentFieldDesc
= NULL
;
509 _pCurrNodeHelper
->getFieldAndDesc(_pCurrentFC
,
515 if(_pCurrentFieldDesc
!= NULL
)
516 returnValue
= _pCurrentFieldDesc
->getFieldType().getId();
518 #ifdef OSG_DEBUG_VRML
519 indentLog(VRMLNodeHelper::getIndent(), PINFO
);
520 PINFO
<< "VRMLFile::getFieldType : Got Field and type "
521 << returnValue
<< " "
522 << _pCurrentField
<< " "
523 << _pCurrentFieldDesc
<< " ";
525 if(_pCurrentFieldDesc
!= NULL
)
526 PINFO
<< _pCurrentFieldDesc
->getFieldType().getName() << std::endl
;
534 void VRMLFile::use(const Char8
*szName
)
536 SceneFileHandler::the()->updateReadProgress();
537 Time beginUse
= getSystemTime();
539 FieldContainerUnrecPtr pUsedFC
;
541 // try to find a container with the given name attachment
543 #ifdef OSG_DEBUG_VRML
544 indentLog(VRMLNodeHelper::getIndent(), PINFO
);
545 PINFO
<< "VRMLFile::use : looking for "
549 VRMLNodeHelper::incIndent();
552 pUsedFC
= findReference(szName
);
556 PWARNING
<< "No fieldContainer with name found to use"
562 // assign nodepointer to current sf|mf field
564 if(_pCurrNodeHelper
!= NULL
)
566 if(pUsedFC
->getType().isNode())
568 Node
*pRootNode
= dynamic_pointer_cast
<Node
>(pUsedFC
);
570 pUsedFC
= cloneTree(pRootNode
);
573 _pCurrNodeHelper
->setContainerFieldValue( pUsedFC
,
579 #ifdef OSG_DEBUG_VRML
580 VRMLNodeHelper::decIndent();
583 useTime
+= (getSystemTime() - beginUse
);
586 void VRMLFile::addRoute(const Char8
*szOutNodename
,
587 const Char8
*szOutFieldname
,
588 const Char8
*szInNodename
,
589 const Char8
*szInFieldname
)
591 if(szOutNodename
== NULL
|| szOutFieldname
== NULL
||
592 szInNodename
== NULL
|| szInFieldname
== NULL
)
594 FWARNING(("addRoute missing params\n"));
597 FieldContainer
*pSrcNode
= findReference(szOutNodename
);
598 FieldContainer
*pDstNode
= findReference(szInNodename
);
600 AttachmentContainer
*pSrc
= dynamic_cast<AttachmentContainer
*>(pSrcNode
);
601 AttachmentContainer
*pDst
= dynamic_cast<AttachmentContainer
*>(pDstNode
);
605 FWARNING(("Unknow src node %s\n", szOutNodename
));
611 FWARNING(("Unknow dst node %s\n", szInNodename
));
615 VRMLGenericAtt
*pSrcAtt
= dynamic_cast<VRMLGenericAtt
*>(
616 pSrc
->findAttachment(VRMLGenericAtt::getClassType()));
618 VRMLGenericAtt
*pDstAtt
= NULL
;
622 pDstAtt
= dynamic_cast<VRMLGenericAtt
*>(
623 pDst
->findAttachment(VRMLGenericAtt::getClassType()));
628 Node
*pNode
= dynamic_cast<Node
*>(pSrc
);
630 if(pNode
!= NULL
&& pNode
->getCore() != NULL
)
632 pSrcAtt
= dynamic_cast<VRMLGenericAtt
*>(
633 pNode
->getCore()->findAttachment(
634 VRMLGenericAtt::getClassType()));
640 Node
*pNode
= dynamic_cast<Node
*>(pDst
);
642 if(pNode
!= NULL
&& pNode
->getCore() != NULL
)
644 pDstAtt
= dynamic_cast<VRMLGenericAtt
*>(
645 pNode
->getCore()->findAttachment(
646 VRMLGenericAtt::getClassType()));
651 std::string szOutFName
= szOutFieldname
;
652 std::string szInFName
= szInFieldname
;
655 std::string::size_type uiPos
= szOutFName
.rfind(std::string("_changed"));
658 if(uiPos
!= std::string::npos
)
660 szOutFName
.erase(uiPos
, std::string::npos
);
663 uiPos
= szInFName
.find(std::string("set_"));
665 if(uiPos
!= std::string::npos
)
667 szInFName
.erase(uiPos
, uiPos
+ 4);
673 VRMLNodeHelper
*pHelper
= findNodeHelper(
674 pSrcAtt
->getVrmlNodeTypename().c_str());
678 pHelper
->mapFieldname(pSrcAtt
->getVrmlNodeTypename(), szOutFName
);
684 VRMLNodeHelper
*pHelper
= findNodeHelper(
685 pDstAtt
->getVrmlNodeTypename().c_str());
689 pHelper
->mapFieldname(pDstAtt
->getVrmlNodeTypename(), szInFName
);
693 addConnection(pSrc
, szOutFName
.c_str(),
694 pDstNode
, szInFName
.c_str());
697 /*-------------------------------------------------------------------------*/
700 void VRMLFile::scanStandardPrototypes(const Char8
*szFilename
)
702 #ifdef OSG_DEBUG_VRML
703 VRMLNodeHelper::resetIndent();
707 scanFile(szFilename
);
708 postStandardProtos();
712 static Action::ResultE
modifyMaterial(Node
* const node
)
714 MaterialGroup
*mg
= dynamic_cast<MaterialGroup
*>(node
->getCore());
717 return Action::Continue
;
719 ChunkMaterial
*cmat
= dynamic_cast<ChunkMaterial
*>(mg
->getMaterial());
722 return Action::Continue
;
724 TextureObjChunk
*texc
=
725 dynamic_cast<TextureObjChunk
*>(
726 cmat
->find(TextureObjChunk::getClassType()));
729 return Action::Continue
;
731 MaterialChunk
*matc
=
732 dynamic_cast<MaterialChunk
*>(
733 cmat
->find(MaterialChunk::getClassType()));
735 TextureEnvChunkUnrecPtr texe
=
736 dynamic_cast<TextureEnvChunk
*>(
737 cmat
->find(TextureEnvChunk::getClassType()));
741 texe
= TextureEnvChunk::create();
742 cmat
->addChunk(texe
);
747 // no material chunk so we use the replace mode.
748 texe
->setEnvMode(GL_REPLACE
);
749 return Action::Continue
;
754 Image
*img
= texc
->getImage();
756 texe
->setEnvMode(GL_MODULATE
);
758 if(img
!= NULL
&& img
->getBpp() > 2)
760 // for color textures the texture replaces only the diffuse part.
761 matc
->setDiffuse(Color4f(1.0f
, 1.0f
, 1.0f
, 1.0f
));
765 // check for textures with alpha
766 if(!matc
->isTransparent() &&
770 BlendChunkUnrecPtr blendc
=
771 dynamic_cast<BlendChunk
*>(
772 cmat
->find(BlendChunk::getClassType()));
776 blendc
= OSG::BlendChunk::create();
778 blendc
->setSrcFactor (GL_SRC_ALPHA
);
779 blendc
->setDestFactor(GL_ONE_MINUS_SRC_ALPHA
);
781 cmat
->addChunk(blendc
);
786 return Action::Continue
;
790 /*-------------------------------------------------------------------------*/
793 void VRMLFile::initIntExtFieldTypeMapper(void)
795 Self::setIntExtMapping(SFBool::getClassType().getId(),
796 ScanParseSkel::OSGsfBool
);
798 Self::setIntExtMapping(SFColor3f::getClassType().getId(),
799 ScanParseSkel::OSGsfColor
);
801 Self::setIntExtMapping(SFReal32::getClassType().getId(),
802 ScanParseSkel::OSGsfFloat
);
804 Self::setIntExtMapping(SFUnrecImagePtr::getClassType().getId(),
805 ScanParseSkel::OSGsfImage
);
807 Self::setIntExtMapping(SFInt32::getClassType().getId(),
808 ScanParseSkel::OSGsfInt32
);
810 Self::setIntExtMapping(SFGLenum::getClassType().getId(),
811 ScanParseSkel::OSGsfString
);
814 Self::setIntExtMapping(SFQuaternion::getClassType().getId(),
815 ScanParseSkel::OSGsfRotation
);
817 Self::setIntExtMapping(SFString::getClassType().getId(),
818 ScanParseSkel::OSGsfString
);
820 Self::setIntExtMapping(SFTime::getClassType().getId(),
821 ScanParseSkel::OSGsfTime
);
823 Self::setIntExtMapping(SFVec2f::getClassType().getId(),
824 ScanParseSkel::OSGsfVec2f
);
826 Self::setIntExtMapping(SFVec2s::getClassType().getId(),
827 ScanParseSkel::OSGsfVec2i
);
829 Self::setIntExtMapping(SFVec3f::getClassType().getId(),
830 ScanParseSkel::OSGsfVec3f
);
834 Self::setIntExtMapping(MFColor3f::getClassType().getId(),
835 ScanParseSkel::OSGmfColor
);
837 Self::setIntExtMapping(MFReal32::getClassType().getId(),
838 ScanParseSkel::OSGmfFloat
);
840 Self::setIntExtMapping(MFInt32::getClassType().getId(),
841 ScanParseSkel::OSGmfInt32
);
843 Self::setIntExtMapping(MFGLenum::getClassType().getId(),
844 ScanParseSkel::OSGmfString
);
846 Self::setIntExtMapping(MFQuaternion::getClassType().getId(),
847 ScanParseSkel::OSGmfRotation
);
849 Self::setIntExtMapping(MFString::getClassType().getId(),
850 ScanParseSkel::OSGmfString
);
852 Self::setIntExtMapping(MFTime::getClassType().getId(),
853 ScanParseSkel::OSGmfTime
);
855 Self::setIntExtMapping(MFVec3f::getClassType().getId(),
856 ScanParseSkel::OSGmfVec3f
);
858 Self::setIntExtMapping(MFVec2f::getClassType().getId(),
859 ScanParseSkel::OSGmfVec2f
);
862 Self::setIntExtMapping(SFUnrecFieldContainerPtr::getClassType().getId(),
863 ScanParseSkel::OSGsfNode
);
865 Self::setIntExtMapping(MFUnrecFieldContainerPtr::getClassType().getId(),
866 ScanParseSkel::OSGmfNode
);
868 Self::setIntExtMapping(SFUnrecNodePtr::getClassType().getId(),
869 ScanParseSkel::OSGsfNode
);
871 Self::setIntExtMapping(MFUnrecChildNodePtr::getClassType().getId(),
872 ScanParseSkel::OSGmfNode
);
874 /* To Base Type Mappings */
876 Self::setIntExtMapping(SFUInt8::getClassType().getId(),
877 ScanParseSkel::OSGsfInt32
);
879 Self::setIntExtMapping(MFUInt8::getClassType().getId(),
880 ScanParseSkel::OSGmfInt32
);
882 Self::setIntExtMapping(SFUInt32::getClassType().getId(),
883 ScanParseSkel::OSGsfInt32
);
885 Self::setIntExtMapping(MFUInt32::getClassType().getId(),
886 ScanParseSkel::OSGmfInt32
);
888 /* To Node Mappings */
890 Self::setIntExtMapping(SFUnrecNodeCorePtr::getClassType().getId(),
891 ScanParseSkel::OSGsfNode
);
893 Self::setIntExtMapping(SFUnrecMaterialPtr::getClassType().getId(),
894 ScanParseSkel::OSGsfNode
);
898 Self::setIntExtMapping(SFGeoPTypesPtr::getClassType().getId(),
899 ScanParseSkel::OSGsfNode
);
901 Self::setIntExtMapping(SFGeoIndicesPtr::getClassType().getId(),
902 ScanParseSkel::OSGsfNode
);
904 Self::setIntExtMapping(SFGeoPLengthsPtr::getClassType().getId(),
905 ScanParseSkel::OSGsfNode
);
907 Self::setIntExtMapping(SFGeoColorsPtr::getClassType().getId(),
908 ScanParseSkel::OSGsfNode
);
910 Self::setIntExtMapping(SFGeoPositionsPtr::getClassType().getId(),
911 ScanParseSkel::OSGsfNode
);
913 Self::setIntExtMapping(SFGeoNormalsPtr::getClassType().getId(),
914 ScanParseSkel::OSGsfNode
);
916 Self::setIntExtMapping(SFGeoTexCoordsPtr::getClassType().getId(),
917 ScanParseSkel::OSGsfNode
);
919 Self::setIntExtMapping(MFUnrecStateChunkPtr::getClassType().getId(),
920 ScanParseSkel::OSGmfNode
);
923 Self::setIntExtMapping(SFAttachmentPtrMap::getClassType().getId(),
924 ScanParseSkel::OSGmfNode
);
928 Self::setIntExtMapping(SFMatrix::getClassType().getId(),
929 ScanParseSkel::OSGsfMatrix
);
931 Self::setIntExtMapping(SFPnt3f::getClassType().getId(),
932 ScanParseSkel::OSGsfPnt3f
);
934 Self::setIntExtMapping(MFPnt3f::getClassType().getId(),
935 ScanParseSkel::OSGmfPnt3f
);
939 void VRMLFile::initExtIntFieldTypeMapper(void)
941 Self::setExtIntMapping(ScanParseSkel::OSGsfBool
,
942 SFBool::getClassType().getId());
944 Self::setExtIntMapping(ScanParseSkel::OSGsfColor
,
945 SFColor3f::getClassType().getId());
947 Self::setExtIntMapping(ScanParseSkel::OSGsfFloat
,
948 SFReal32::getClassType().getId());
951 Self::setExtIntMapping(SFImage::getClassType().getId(),
952 ScanParseSkel::OSGsfInt32);
955 Self::setExtIntMapping(ScanParseSkel::OSGsfImage
,
956 SFUnrecImagePtr::getClassType().getId());
958 Self::setExtIntMapping(ScanParseSkel::OSGsfInt32
,
959 SFInt32::getClassType().getId());
962 Self::setExtIntMapping(ScanParseSkel::OSGsfRotation
,
963 SFQuaternion::getClassType().getId());
965 Self::setExtIntMapping(ScanParseSkel::OSGsfString
,
966 SFString::getClassType().getId());
968 Self::setExtIntMapping(ScanParseSkel::OSGsfTime
,
969 SFTime::getClassType().getId());
971 Self::setExtIntMapping(ScanParseSkel::OSGsfVec2f
,
972 SFVec2f::getClassType().getId());
974 Self::setExtIntMapping(ScanParseSkel::OSGsfVec2i
,
975 SFVec2s::getClassType().getId());
977 Self::setExtIntMapping(ScanParseSkel::OSGsfVec3f
,
978 SFVec3f::getClassType().getId());
982 Self::setExtIntMapping(ScanParseSkel::OSGmfColor
,
983 MFColor3f::getClassType().getId());
985 Self::setExtIntMapping(ScanParseSkel::OSGmfFloat
,
986 MFReal32::getClassType().getId());
988 Self::setExtIntMapping(ScanParseSkel::OSGmfInt32
,
989 MFInt32::getClassType().getId());
991 Self::setExtIntMapping(ScanParseSkel::OSGmfRotation
,
992 MFQuaternion::getClassType().getId());
994 Self::setExtIntMapping(ScanParseSkel::OSGmfString
,
995 MFString::getClassType().getId());
997 Self::setExtIntMapping(ScanParseSkel::OSGmfTime
,
998 MFTime::getClassType().getId());
1001 Self::setExtIntMapping(ScanParseSkel::OSGmfVec3f
,
1002 MFVec3f::getClassType().getId());
1004 Self::setExtIntMapping(ScanParseSkel::OSGmfVec2f
,
1005 MFVec2f::getClassType().getId());
1008 Self::setExtIntMapping(ScanParseSkel::OSGsfNode
,
1009 SFUnrecFieldContainerPtr::getClassType().getId());
1011 Self::setExtIntMapping(ScanParseSkel::OSGmfNode
,
1012 MFUnrecFieldContainerPtr::getClassType().getId());
1015 /* extended types */
1017 Self::setExtIntMapping(ScanParseSkel::OSGsfMatrix
,
1018 SFMatrix::getClassType().getId());
1020 Self::setExtIntMapping(ScanParseSkel::OSGsfPnt3f
,
1021 SFPnt3f::getClassType().getId());
1023 Self::setExtIntMapping(ScanParseSkel::OSGmfPnt3f
,
1024 MFPnt3f::getClassType().getId());
1027 /* remove this, if there is a general methode to find containers */
1028 FieldContainer
*VRMLFile::findFCByName(const Char8
*szName
,
1031 MFUnrecNodePtr::const_iterator i
;
1033 FieldContainer
*pFC
= NULL
;
1036 Name
*pNodename
= NULL
;
1037 NodeCore
*pCore
= NULL
;
1038 // check if name matches nodename
1041 dynamic_cast<NamePtr
>(
1042 pNode
->findAttachment(Name::getClassType().getGroupId()));
1044 if(pNodename
!= NullFC
)
1046 if(strcmp(szName
, pNodename
->getFieldPtr()->getValue().c_str())==0)
1049 // check if name matches corename
1051 pCore
= pNode
->getCore();
1055 pNodename
= dynamic_cast<NamePtr
>(
1056 pCore
->findAttachment(Name::getClassType().getGroupId()));
1058 if(pNodename
!= NullFC
)
1060 if(strcmp(szName
, pNodename
->getFieldPtr()->getValue().c_str())==0)
1065 // matching for children
1066 for(i
= pNode
->getMFChildren()->begin();
1067 i
!= pNode
->getMFChildren()->end();
1070 pFC
= findFCByName(szName
, *i
);
1082 FieldContainer
*VRMLFile::findReference(const Char8
*szName
)
1084 // search reference in this file
1085 FieldContainer
*returnValue
= NULL
;
1087 std::string szKey
= szName
;
1089 NameContainerMap::iterator mIt
= _nameFCMap
.find(szKey
);
1091 if(mIt
!= _nameFCMap
.end())
1093 returnValue
= mIt
->second
;
1097 returnValue
= findFCByName(szName
, _pSceneRootNode
);
1104 #include "OSGVRMLProtos.inl"