00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #define OSG_COMPILEVRMLNODEDESCINST
00040
00041 #include <stdlib.h>
00042 #include <stdio.h>
00043
00044 #include "OSGConfig.h"
00045
00046 #include <iostream>
00047 #include <fstream>
00048
00049 #include "OSGVRMLNodeDescs.h"
00050 #include <OSGLog.h>
00051
00052 #include <OSGNode.h>
00053 #include <OSGNodeCore.h>
00054 #include <OSGGroup.h>
00055 #include <OSGComponentTransform.h>
00056 #include <OSGGeometry.h>
00057 #include <OSGMaterialGroup.h>
00058 #include <OSGSimpleGeometry.h>
00059 #include <OSGExtrusionGeometry.h>
00060 #include <OSGTextureChunk.h>
00061 #include <OSGTextureTransformChunk.h>
00062 #include <OSGGeoFunctions.h>
00063 #include <OSGDistanceLOD.h>
00064 #include <OSGSwitch.h>
00065 #include <OSGInline.h>
00066 #include <OSGImage.h>
00067 #include <OSGSceneFileHandler.h>
00068 #include <OSGImageFileHandler.h>
00069 #include <OSGZStream.h>
00070
00071 #include <OSGVRMLFile.h>
00072
00073 #ifndef OSG_LOG_MODULE
00074 #define OSG_LOG_MODULE "VRMLLoader"
00075 #endif
00076
00077
00078
00079 #ifndef OSG_DO_DOC
00080 # ifdef OSG_DEBUG_VRML
00081 # define OSG_VRML_ARG(ARG) ARG
00082 # else
00083 # define OSG_VRML_ARG(ARG)
00084 # endif
00085 #else
00086 # define OSG_VRML_ARG(ARG) ARG
00087 #endif
00088
00089 OSG_USING_NAMESPACE
00090
00091
00092
00101 #ifdef WIN32
00102 OSG_FC_ST_TYPE_FUNCTIONS_INL_TMPL_DEF(GenericAttDesc,
00103 DynFieldAttachment)
00104 #endif
00105
00106 OSG_DYNFIELD_FC_DLLEXPORT_DEF(DynFieldAttachment,
00107 GenericAttDesc,
00108 OSG_SYSTEMLIB_DLLTMPLMAPPING);
00109
00110 #if defined(OSG_WIN32_ICL) && !defined(OSG_CHECK_FIELDSETARG)
00111 #pragma warning (disable : 383)
00112 #endif
00113
00114
00115
00116
00117
00123 UInt32 VRMLNodeDesc::_uiIndent = 0;
00124
00125
00126
00127
00128 UInt32 VRMLNodeDesc::getIndent(void)
00129 {
00130 return _uiIndent;
00131 }
00132
00133 void VRMLNodeDesc::incIndent(void)
00134 {
00135 _uiIndent += 4;
00136 }
00137
00138 void VRMLNodeDesc::decIndent(void)
00139 {
00140 if(_uiIndent < 4)
00141 {
00142 PWARNING << "Indent smaller 4 decremented" << std::endl;
00143
00144 _uiIndent = 4;
00145 }
00146
00147 _uiIndent -= 4;
00148 }
00149
00150 void VRMLNodeDesc::resetIndent(void)
00151 {
00152 _uiIndent = 0;
00153 }
00154
00155
00156
00157
00158 VRMLNodeDesc::VRMLNodeDesc(void) :
00159 _mFieldTypes (),
00160
00161 _pGenAtt (NullFC),
00162
00163 _pNodeProto (NullFC),
00164 _pNodeCoreProto(NullFC),
00165
00166 _pCurrField (NULL),
00167
00168 _szCurrentName (),
00169 _bSaveOnEnd (false)
00170 {
00171 }
00172
00173
00174
00175
00176 VRMLNodeDesc::~VRMLNodeDesc(void)
00177 {
00178 }
00179
00180
00181
00182
00183 void VRMLNodeDesc::init(const Char8 *szName)
00184 {
00185 if(szName == NULL)
00186 {
00187 _pNodeCoreProto = Group::create();
00188 }
00189 else if(stringcasecmp(szName, "Transform") == 0)
00190 {
00191 _pNodeCoreProto = ComponentTransform::create();
00192 }
00193 else
00194 {
00195 _pNodeCoreProto = Group::create();
00196 }
00197
00198 _pNodeProto = Node::create();
00199
00200 _pGenAtt = GenericAtt::create();
00201 _pGenAtt->setInternal(true);
00202 }
00203
00204
00205 void VRMLNodeDesc::reset(void)
00206 {
00207 }
00208
00209 void VRMLNodeDesc::setOnEndSave(const Char8 *szName)
00210 {
00211 _szCurrentName = szName;
00212 _bSaveOnEnd = true;
00213 }
00214
00215 void VRMLNodeDesc::clearOnEndSave(void)
00216 {
00217 _bSaveOnEnd = false;
00218 }
00219
00220 bool VRMLNodeDesc::getOnEndSave(void)
00221 {
00222 return _bSaveOnEnd;
00223 }
00224
00225 const Char8 *VRMLNodeDesc::getSavename(void)
00226 {
00227 return _szCurrentName.c_str();
00228 }
00229
00230 FieldContainerPtr VRMLNodeDesc::getSaveFieldContainer(void)
00231 {
00232 return NullFC;
00233 }
00234
00235
00236
00237
00238 Field *VRMLNodeDesc::getField(const Char8 *szFieldname)
00239 {
00240 return getField(_pNodeProto, _pNodeCoreProto, _pGenAtt, szFieldname);
00241 }
00242
00243 void VRMLNodeDesc::getFieldAndDesc(
00244 FieldContainerPtr pFC,
00245 const Char8 * szFieldname,
00246 Field *&pField,
00247 const FieldDescription *&pDesc)
00248 {
00249 FieldContainerPtr pTmpFC = NullFC;
00250 NodePtr pNode = NullFC;
00251 NodeCorePtr pNodeCore = NullFC;
00252
00253 pField = NULL;
00254 pDesc = NULL;
00255
00256 if(pFC == NullFC)
00257 return;
00258
00259 #ifdef OSG_DEBUG_VRML
00260 indentLog(getIndent(), PINFO);
00261 PINFO << "VRMLNodeDesc::getFieldAndDesc : looking for "
00262 << szFieldname
00263 << std::endl;
00264
00265 incIndent();
00266 #endif
00267
00268 pField = pFC->getField(szFieldname);
00269
00270 #ifdef OSG_DEBUG_VRML
00271 indentLog(getIndent(), PINFO);
00272 PINFO << "Got this from fieldcontainer : " << pField << std::endl;
00273 #endif
00274
00275 if(pField != NULL)
00276 {
00277 pDesc = pFC->getType().findFieldDescription(szFieldname);
00278
00279 #ifdef OSG_DEBUG_VRML
00280 decIndent();
00281 #endif
00282
00283 return;
00284 }
00285
00286 if(pFC->getType().isNode() == true)
00287 {
00288 pNode = NodePtr::dcast(pFC);
00289
00290 pNodeCore = pNode->getCore();
00291
00292 if(pNodeCore != NullFC)
00293 {
00294 pField = pNodeCore->getField(szFieldname);
00295
00296 #ifdef OSG_DEBUG_VRML
00297 indentLog(getIndent(), PINFO);
00298 PINFO << "Got this from nodecore : " << pField << std::endl;
00299 #endif
00300 }
00301
00302 if(pField != NULL)
00303 {
00304 pDesc = pNodeCore->getType().findFieldDescription(szFieldname);
00305 }
00306 else
00307 {
00308 pTmpFC = pNode->findAttachment(
00309 GenericAtt::getClassType().getGroupId());
00310
00311 if(pTmpFC != NullFC)
00312 {
00313 pField = pTmpFC->getField(szFieldname);
00314 }
00315
00316 #ifdef OSG_DEBUG_VRML
00317 indentLog(getIndent(), PINFO);
00318 PINFO << "Got this from node attachment : " << pField << std::endl;
00319 #endif
00320 if(pField == NULL)
00321 {
00322 pTmpFC =
00323 pNodeCore->findAttachment(
00324 GenericAtt::getClassType().getGroupId());
00325
00326 if(pTmpFC != NullFC)
00327 {
00328 pField = pTmpFC->getField(szFieldname);
00329 }
00330
00331 #ifdef OSG_DEBUG_VRML
00332 indentLog(getIndent(), PINFO);
00333 PINFO << "Got this from nodecore attachment : "
00334 << pField << std::endl;
00335 #endif
00336 }
00337
00338 if(pField != NULL)
00339 {
00340 pDesc = pTmpFC->getType().findFieldDescription(szFieldname);
00341 }
00342 }
00343 }
00344 else if(pFC->getType().isNodeCore() == true)
00345 {
00346 pNodeCore = NodeCorePtr::dcast(pFC);
00347
00348 pTmpFC = pNodeCore->findAttachment(
00349 GenericAtt::getClassType().getGroupId());
00350
00351 if(pTmpFC != NullFC)
00352 {
00353 pField = pTmpFC->getField(szFieldname);
00354 }
00355
00356 if(pField != NULL)
00357 {
00358 pDesc = pTmpFC->getType().findFieldDescription(szFieldname);
00359 }
00360
00361 #ifdef OSG_DEBUG_VRML
00362 indentLog(getIndent(), PINFO);
00363 PINFO << "Got this from nodecore attachment : "
00364 << pField << std::endl;
00365 #endif
00366 }
00367
00368 #ifdef OSG_DEBUG_VRML
00369 decIndent();
00370 #endif
00371 }
00372
00373
00374
00375
00376 bool VRMLNodeDesc::prototypeAddField(const Char8 *OSG_VRML_ARG(szFieldType),
00377 const UInt32 uiFieldTypeId,
00378 const Char8 *szFieldName)
00379 {
00380 FieldDescription *pDesc = NULL;
00381 FieldType *pType = NULL;
00382
00383 Field *pField = getField(_pNodeProto,
00384 _pNodeCoreProto,
00385 _pGenAtt,
00386 szFieldName);
00387
00388
00389 #ifdef OSG_DEBUG_VRML
00390 indentLog(getIndent(), PINFO);
00391 PINFO << "VRMLNodeDesc::prototypeAddField | getField "
00392 << szFieldName
00393 << " returned : "
00394 << pField
00395 << std::endl;
00396 #endif
00397
00398 if(pField == NULL)
00399 {
00400 pType = FieldFactory::the().getFieldType(uiFieldTypeId);
00401
00402 if(pType == NULL)
00403 {
00404 PWARNING << "VRMLNodeDesc::prototypeAddField "
00405 << "Could not get fieldtype "
00406 << uiFieldTypeId << " "
00407 << szFieldName << " "
00408 << std::endl;
00409
00410 return false;
00411 }
00412
00413 #ifdef OSG_DEBUG_VRML
00414 indentLog(getIndent(), PINFO);
00415 PINFO << "VRMLNodeDesc::prototypeAddField | got fieldtype : "
00416 << uiFieldTypeId
00417 << " "
00418 << pType->getName()
00419 << " "
00420 << pType->getId()
00421 << std::endl;
00422 #endif
00423
00424 if(_pGenAtt != NullFC)
00425 {
00426 pDesc = new FieldDescription(*pType,
00427 szFieldName,
00428 0, 0,
00429 false,
00430 (FieldIndexAccessMethod)
00431 &GenericAtt::getDynamicField);
00432
00433 _pGenAtt->addField(*pDesc);
00434
00435 _pCurrField = getField(_pNodeProto,
00436 _pNodeCoreProto,
00437 _pGenAtt,
00438 szFieldName);
00439
00440 delete pDesc;
00441 }
00442
00443 #ifdef OSG_DEBUG_VRML
00444 indentLog(getIndent(), PINFO);
00445 PINFO << "VRMLNodeDesc::prototypeAddField | field added : "
00446 << szFieldType
00447 << " "
00448 << uiFieldTypeId
00449 << " "
00450 << szFieldName
00451 << " "
00452 << _pCurrField
00453 << std::endl;
00454 #endif
00455
00456 if(_pCurrField != NULL)
00457 return true;
00458 else
00459 return false;
00460 }
00461 else
00462 {
00463 if((_pGenAtt != NullFC ) &&
00464 (_pGenAtt->getField(szFieldName) != NULL))
00465 {
00466 PWARNING << "VRMLNodeDesc::prototypeAddField | "
00467 << "Could not add field "
00468 << szFieldName
00469 << " a second time"
00470 << std::endl;
00471 }
00472
00473 return false;
00474 }
00475 }
00476
00477 void VRMLNodeDesc::prototypeAddFieldValue(const Char8 *szFieldVal)
00478 {
00479 if(_pCurrField != NULL)
00480 {
00481 _pCurrField->pushValueByStr(szFieldVal);
00482 }
00483 }
00484
00485 void VRMLNodeDesc::endProtoInterface(void)
00486 {
00487 }
00488
00489
00490
00491
00492 FieldContainerPtr VRMLNodeDesc::beginNode(const Char8 *,
00493 const Char8 *,
00494 FieldContainerPtr)
00495 {
00496 FieldContainerPtr returnValue = NullFC;
00497 NodePtr pNode = NullFC;
00498 NodeCorePtr pCore = NullFC;
00499 GenericAttPtr pAtt = NullFC;
00500
00501 if(_pNodeProto != NullFC)
00502 {
00503 returnValue = _pNodeProto->shallowCopy();
00504
00505 if(_pNodeCoreProto != NullFC)
00506 {
00507 FieldContainerPtr pCoreClone = _pNodeCoreProto->shallowCopy();
00508
00509 pNode = NodePtr ::dcast(returnValue);
00510 pCore = NodeCorePtr::dcast(pCoreClone );
00511
00512 beginEditCP(pNode, Node::CoreFieldMask);
00513 {
00514 pNode->setCore(pCore);
00515 }
00516 endEditCP (pNode, Node::CoreFieldMask);
00517 }
00518
00519 if(_pGenAtt != NullFC)
00520 {
00521 FieldContainerPtr pAttClone = _pGenAtt->emptyCopy();
00522
00523 pAtt = GenericAttPtr::dcast(pAttClone);
00524
00525 if(pAtt != NullFC)
00526 {
00527 pAtt->setInternal(true);
00528 }
00529
00530 if(pCore != NullFC)
00531 {
00532 pCore->addAttachment(pAtt);
00533 }
00534 else
00535 {
00536 pNode->addAttachment(pAtt);
00537 }
00538 }
00539 }
00540
00541 return returnValue;
00542 }
00543
00544 void VRMLNodeDesc::endNode(FieldContainerPtr)
00545 {
00546 }
00547
00548
00549
00550
00551 void VRMLNodeDesc::addFieldValue( Field *pField,
00552 const Char8 *szFieldVal)
00553 {
00554 if(pField != NULL)
00555 {
00556 pField->pushValueByStr(szFieldVal);
00557 }
00558 }
00559
00560 bool VRMLNodeDesc::use(FieldContainerPtr)
00561 {
00562 return false;
00563 }
00564
00565
00566
00567
00568
00569 void VRMLNodeDesc::dump(const Char8 *szNodeName)
00570 {
00571 fprintf(stderr, "\tDefault %s\n", szNodeName);
00572
00573 fprintf(stderr, "\t\tGenAtt %p\n", &(*_pGenAtt));
00574 fprintf(stderr, "\t\tNodeProto %p\n", &(*_pNodeProto));
00575 fprintf(stderr, "\t\tNodeCoreProto %p\n", &(*_pNodeCoreProto));
00576
00577 std::string stringVal;
00578
00579 if(_pGenAtt != NullFC)
00580 {
00581 fprintf(stderr, "\t\t%u Desc\n",
00582 _pGenAtt->getType().getNumFieldDescs());
00583
00584 for(UInt32 i = 2; i <= _pGenAtt->getType().getNumFieldDescs(); i++)
00585 {
00586 FieldDescription *pFieldDesc =
00587 _pGenAtt->getType().getFieldDescription(i);
00588 Field *pField =
00589 _pGenAtt->getDynamicField(i);
00590
00591 stringVal.erase(stringVal.begin(),
00592 stringVal.end());
00593
00594 pField->getValueByStr(stringVal);
00595
00596 fprintf(stderr, "\t\t%s %s %s\n",
00597 pFieldDesc->getCName(),
00598 pFieldDesc->getFieldType().getCName(),
00599 stringVal.c_str());
00600 }
00601 }
00602 }
00603
00604
00605
00606
00607 Field *VRMLNodeDesc::getField( FieldContainerPtr pFC1,
00608 FieldContainerPtr pFC2,
00609 GenericAttPtr pGenAtt,
00610 const Char8 *szFieldname)
00611 {
00612 Field *returnValue = NULL;
00613
00614 if(szFieldname == NULL)
00615 {
00616 return returnValue;
00617 }
00618
00619 #ifdef OSG_DEBUG_VRML
00620 indentLog(getIndent(), PINFO);
00621 PINFO << "VRMLNodeDesc::getField " << std::endl;
00622
00623 incIndent();
00624
00625 indentLog(getIndent(), PINFO);
00626 PINFO << "Trying to find field : " << szFieldname << std::endl;
00627 #endif
00628
00629 if(pFC1 != NullFC)
00630 {
00631 returnValue = pFC1->getField(szFieldname);
00632 }
00633
00634 #ifdef OSG_DEBUG_VRML
00635 incIndent();
00636
00637 indentLog(getIndent(), PINFO);
00638 PINFO << "Got this from node : " << returnValue << std::endl;
00639 #endif
00640
00641 if(returnValue != NULL)
00642 return returnValue;
00643
00644 if(pFC2 != NullFC)
00645 {
00646 returnValue = pFC2->getField(szFieldname);
00647
00648 #ifdef OSG_DEBUG_VRML
00649 indentLog(getIndent(), PINFO);
00650 PINFO << "Got this from nodecore : " << returnValue << std::endl;
00651 #endif
00652 }
00653 else
00654 {
00655 #ifdef OSG_DEBUG_VRML
00656 indentLog(getIndent(), PINFO);
00657 PINFO << "No core to check" << std::endl;
00658 #endif
00659 }
00660
00661
00662 if(returnValue != NULL)
00663 return returnValue;
00664
00665 if(pGenAtt != NullFC)
00666 {
00667 returnValue = pGenAtt->getField(szFieldname);
00668 }
00669
00670 #ifdef OSG_DEBUG_VRML
00671 indentLog(getIndent(), PINFO);
00672 PINFO << "Got this from attachment : " << returnValue << std::endl;
00673
00674 decIndent();
00675 decIndent();
00676 #endif
00677
00678 return returnValue;
00679 }
00680
00681
00682
00683
00684
00685
00686
00687
00693
00694
00695
00696 VRMLShapeDesc::VRMLShapeDesc(void) :
00697 Inherited (),
00698
00699 _pMaterialDesc(NULL)
00700 {
00701 }
00702
00703
00704
00705
00706 VRMLShapeDesc::~VRMLShapeDesc(void)
00707 {
00708 }
00709
00710
00711
00712
00713 void VRMLShapeDesc::init(const Char8 *OSG_VRML_ARG(szName))
00714 {
00715 #ifdef OSG_DEBUG_VRML
00716 indentLog(getIndent(), PINFO);
00717 PINFO << "ShapeDesc::init : " << szName << std::endl;
00718 #endif
00719
00720 _pNodeProto = Node::create();
00721 _pNodeCoreProto = MaterialGroup::create();
00722
00723 _pGenAtt = GenericAtt::create();
00724 _pGenAtt->setInternal(true);
00725 }
00726
00727 void VRMLShapeDesc::setMaterialDesc(VRMLMaterialDesc *pMaterialDesc)
00728 {
00729 _pMaterialDesc = pMaterialDesc;
00730 }
00731
00732
00733
00734
00735 bool VRMLShapeDesc::prototypeAddField(const Char8 *szFieldType,
00736 const UInt32 uiFieldTypeId,
00737 const Char8 *szFieldname)
00738 {
00739 bool returnValue = false;
00740
00741 #ifdef OSG_DEBUG_VRML
00742 indentLog(getIndent(), PINFO);
00743 PINFO << "VRMLShapeDesc::prototypeAddField | add request : "
00744 << szFieldname
00745 << std::endl;
00746 #endif
00747
00748 _pCurrField = NULL;
00749
00750 if(szFieldname == NULL)
00751 return false;
00752
00753 incIndent();
00754
00755 if(stringcasecmp("geometry", szFieldname) == 0)
00756 {
00757 _pCurrField = _pNodeProto->getField("children");
00758 returnValue = true;
00759
00760 #ifdef OSG_DEBUG_VRML
00761 indentLog(getIndent(), PINFO);
00762 PINFO << "VRMLShapeDesc::prototypeAddField | request internal : "
00763 << szFieldname
00764 << " "
00765 << _pCurrField
00766 << std::endl;
00767 #endif
00768 }
00769
00770 if(stringcasecmp("appearance", szFieldname) == 0)
00771 {
00772 _pCurrField = _pNodeCoreProto->getField("material");
00773 returnValue = true;
00774
00775 #ifdef OSG_DEBUG_VRML
00776 indentLog(getIndent(), PINFO);
00777
00778 PINFO << "VRMLShapeDesc::prototypeAddField | request internal : "
00779 << szFieldname
00780 << " "
00781 << _pCurrField
00782 << std::endl;
00783 #endif
00784 }
00785
00786 if(_pCurrField == NULL)
00787 {
00788 returnValue = Inherited::prototypeAddField(szFieldType,
00789 uiFieldTypeId,
00790 szFieldname);
00791 }
00792
00793 #ifdef OSG_DEBUG_VRML
00794 decIndent();
00795 #endif
00796
00797 return returnValue;
00798 }
00799
00800 void VRMLShapeDesc::getFieldAndDesc(
00801 FieldContainerPtr pFC,
00802 const Char8 * szFieldname,
00803 Field *&pField,
00804 const FieldDescription *&pDesc)
00805 {
00806 if(szFieldname == NULL)
00807 return;
00808
00809 if(pFC == NullFC)
00810 return;
00811
00812 #ifdef OSG_DEBUG_VRML
00813 indentLog(getIndent(), PINFO);
00814 PINFO << "VRMLShapeDesc::getFieldAndDesc : looking for "
00815 << szFieldname
00816 << std::endl;
00817
00818 incIndent();
00819 #endif
00820
00821 if(stringcasecmp("geometry", szFieldname) == 0)
00822 {
00823 #ifdef OSG_DEBUG_VRML
00824 indentLog(getIndent(), PINFO);
00825 PINFO << "VRMLShapeDesc::getFieldAndDesc : request internal "
00826 << szFieldname
00827 << std::endl;
00828 #endif
00829
00830 pField = pFC->getField("children");
00831
00832 if(pField != NULL)
00833 pDesc = pFC->getType().findFieldDescription("children");
00834 }
00835 else if(stringcasecmp("appearance", szFieldname) == 0)
00836 {
00837 #ifdef OSG_DEBUG_VRML
00838 indentLog(getIndent(), PINFO);
00839 PINFO << "VRMLShapeDesc::getFieldAndDesc : request internal "
00840 << szFieldname
00841 << std::endl;
00842 #endif
00843
00844 NodePtr pNode = NodePtr::dcast(pFC);
00845
00846 if(pNode != NullFC)
00847 {
00848 if(pNode->getCore() != NullFC)
00849 {
00850 pField = pNode->getCore()->getField("material");
00851
00852 if(pField != NULL)
00853 {
00854 pDesc =
00855 pNode->getCore()->getType().findFieldDescription(
00856 "material");
00857 }
00858 }
00859 }
00860 else
00861 {
00862 VRMLNodeDesc::getFieldAndDesc(pFC,
00863 szFieldname,
00864 pField,
00865 pDesc);
00866 }
00867 }
00868 else
00869 {
00870 VRMLNodeDesc::getFieldAndDesc(pFC,
00871 szFieldname,
00872 pField,
00873 pDesc);
00874 }
00875
00876 #ifdef OSG_DEBUG_VRML
00877 decIndent();
00878 #endif
00879 }
00880
00881
00882
00883
00884 FieldContainerPtr VRMLShapeDesc::beginNode(const Char8 *,
00885 const Char8 *,
00886 FieldContainerPtr)
00887 {
00888 NodePtr pNode = NullFC;
00889 NodeCorePtr pNodeCore = NullFC;
00890
00891 if(_pNodeProto != NullFC)
00892 {
00893 pNode = NodePtr::dcast(_pNodeProto->shallowCopy());
00894
00895 if(_pNodeCoreProto != NullFC)
00896 {
00897 pNodeCore = NodeCorePtr::dcast(_pNodeCoreProto->shallowCopy());
00898
00899 beginEditCP(pNode, Node::CoreFieldMask);
00900 {
00901 pNode->setCore(pNodeCore);
00902 }
00903 endEditCP (pNode, Node::CoreFieldMask);
00904 }
00905 }
00906
00907 #ifdef OSG_DEBUG_VRML
00908 indentLog(getIndent(), PINFO);
00909 PINFO << "Begin Shape " << &(*pNode) << std::endl;
00910
00911 incIndent();
00912 #endif
00913
00914 return pNode;
00915 }
00916
00917 void VRMLShapeDesc::endNode(FieldContainerPtr pFC)
00918 {
00919 if(pFC != NullFC)
00920 {
00921 NodePtr pNode = NodePtr::dcast(pFC);
00922
00923 if(pNode != NullFC && pNode->getCore() == NullFC)
00924 {
00925 PWARNING << "warning empty material, using default\n" << std::endl;
00926
00927 MaterialGroupPtr pMatGroup = MaterialGroup::create();
00928
00929 beginEditCP(pMatGroup);
00930 {
00931 pMatGroup->setMaterial(_pMaterialDesc->getDefaultMaterial());
00932 }
00933 endEditCP(pMatGroup);
00934
00935 beginEditCP(pNode, Node::CoreFieldMask);
00936 {
00937 pNode->setCore(pMatGroup);
00938 }
00939 endEditCP (pNode, Node::CoreFieldMask);
00940 }
00941 else
00942 {
00943 MaterialGroupPtr pMatGroup;
00944
00945 pMatGroup = MaterialGroupPtr::dcast(pNode->getCore());
00946
00947 if(pMatGroup != NullFC)
00948 {
00949 if(pMatGroup->getMaterial() == NullFC)
00950 {
00951 pMatGroup->setMaterial(
00952 _pMaterialDesc->getDefaultMaterial());
00953 }
00954 }
00955 }
00956 }
00957
00958 #ifdef OSG_DEBUG_VRML
00959 decIndent();
00960
00961 indentLog(getIndent(), PINFO);
00962 PINFO << "End Shape " << &(*pFC) << std::endl;
00963 #endif
00964 }
00965
00966
00967
00968
00969 void VRMLShapeDesc::dump(const Char8 *)
00970 {
00971 }
00972
00973
00974
00975
00976
00977
00978
00979
00985
00986
00987
00988 VRMLGeometryDesc::VRMLGeometryDesc(bool bIsFaceSet) :
00989 Inherited (),
00990
00991 _bIsFaceSet (bIsFaceSet),
00992
00993 _bInIndex (false),
00994 _uiNumVertices(0),
00995
00996 _pTypeField (NullFC ),
00997 _pLengthField (NullFC )
00998 {
00999 }
01000
01001
01002
01003
01004 VRMLGeometryDesc::~VRMLGeometryDesc(void)
01005 {
01006 }
01007
01008
01009
01010
01011 void VRMLGeometryDesc::init(const Char8 *OSG_VRML_ARG(szName))
01012 {
01013 #ifdef OSG_DEBUG_VRML
01014 indentLog(getIndent(), PINFO);
01015 PINFO << "GeoDesc::init : " << szName << std::endl;
01016 #endif
01017
01018 _pNodeProto = Node::create();
01019 _pNodeCoreProto = Geometry::create();
01020
01021 _pGenAtt = GenericAtt::create();
01022 _pGenAtt->setInternal(true);
01023 }
01024
01025
01026
01027
01028 bool VRMLGeometryDesc::prototypeAddField(const Char8 *szFieldType,
01029 const UInt32 uiFieldTypeId,
01030 const Char8 *szFieldname)
01031 {
01032 bool bFound = false;
01033
01034 _pCurrField = NULL;
01035
01036 if(szFieldname == NULL)
01037 return false;
01038
01039 if(stringcasecmp("coord", szFieldname) == 0)
01040 {
01041 bFound = true;
01042 }
01043 else if(stringcasecmp("normal", szFieldname) == 0)
01044 {
01045 bFound = true;
01046 }
01047 else if(stringcasecmp("color", szFieldname) == 0)
01048 {
01049 bFound = true;
01050 }
01051 else if(stringcasecmp("texCoord", szFieldname) == 0)
01052 {
01053 bFound = true;
01054 }
01055
01056 if(bFound == true)
01057 {
01058 #ifdef OSG_DEBUG_VRML
01059 indentLog(getIndent(), PINFO);
01060 PINFO << "GeoDesc::prototypeAddField : internal "
01061 << szFieldname << std::endl;
01062 #endif
01063
01064 return true;
01065 }
01066 else
01067 {
01068 return Inherited::prototypeAddField(szFieldType,
01069 uiFieldTypeId,
01070 szFieldname);
01071 }
01072 }
01073
01074
01075 void VRMLGeometryDesc::getFieldAndDesc(
01076 FieldContainerPtr pFC,
01077 const Char8 * szFieldname,
01078 Field *&pField,
01079 const FieldDescription *&pDesc)
01080 {
01081 #ifdef OSG_DEBUG_VRML
01082 indentLog(getIndent(), PINFO);
01083 PINFO << "GeoDesc::getFieldAndDesc : request "
01084 << szFieldname
01085 << std::endl;
01086 #endif
01087
01088 if(szFieldname == NULL)
01089 return;
01090
01091 if(pFC == NullFC)
01092 return;
01093
01094 NodePtr pNode = NodePtr::dcast(pFC);
01095
01096 if(pNode == NullFC)
01097 {
01098 PWARNING << "GeoDesc::getFieldAndDesc : No Node" << std::endl;
01099 return;
01100 }
01101
01102 NodeCorePtr pNodeCore = pNode->getCore();
01103
01104 GeometryPtr pGeo = GeometryPtr::dcast(pNodeCore);
01105
01106 if(pGeo == NullFC)
01107 {
01108 PWARNING << "GeoDesc::getFieldAndDesc : No Geo" << std::endl;
01109 return;
01110 }
01111
01112 _bInIndex = false;
01113
01114 if(stringcasecmp("coord", szFieldname) == 0)
01115 {
01116 #ifdef OSG_DEBUG_VRML
01117 indentLog(getIndent(), PINFO);
01118 PINFO << "GeoDesc::getFieldAndDesc : internal "
01119 << szFieldname << std::endl;
01120 #endif
01121 pField = pGeo->getField("positions");
01122
01123 if(pField != NULL)
01124 pDesc = pGeo->getType().findFieldDescription("positions");
01125 }
01126 else if(stringcasecmp("normal", szFieldname) == 0)
01127 {
01128 #ifdef OSG_DEBUG_VRML
01129 indentLog(getIndent(), PINFO);
01130 PINFO << "GeoDesc::getFieldAndDesc : internal "
01131 << szFieldname << std::endl;
01132 #endif
01133
01134 pField = pGeo->getField("normals");
01135
01136 if(pField != NULL)
01137 pDesc = pGeo->getType().findFieldDescription("normals");
01138 }
01139 else if(stringcasecmp("color", szFieldname) == 0)
01140 {
01141 #ifdef OSG_DEBUG_VRML
01142 indentLog(getIndent(), PINFO);
01143 PINFO << "GeoDesc::getFieldAndDesc : internal "
01144 << szFieldname << std::endl;
01145 #endif
01146
01147 pField = pGeo->getField("colors");
01148
01149 if(pField != NULL)
01150 pDesc = pGeo->getType().findFieldDescription("colors");
01151 }
01152 else if(stringcasecmp("texCoord", szFieldname) == 0)
01153 {
01154 #ifdef OSG_DEBUG_VRML
01155 indentLog(getIndent(), PINFO);
01156 PINFO << "GeoDesc::getFieldAndDesc : internal "
01157 << szFieldname << std::endl;
01158 #endif
01159
01160 pField = pGeo->getField("texCoords");
01161
01162 if(pField != NULL)
01163 pDesc = pGeo->getType().findFieldDescription("texCoords");
01164 }
01165 else
01166 {
01167 VRMLNodeDesc::getFieldAndDesc(pGeo,
01168 szFieldname,
01169 pField,
01170 pDesc);
01171 }
01172 }
01173
01174
01175
01176
01177 FieldContainerPtr VRMLGeometryDesc::beginNode(
01178 const Char8 *,
01179 const Char8 *,
01180 FieldContainerPtr)
01181 {
01182 FieldContainerPtr pFC = NullFC;
01183 NodePtr pNode = NullFC;
01184 NodeCorePtr pNodeCore = NullFC;
01185 GenericAttPtr pAtt = NullFC;
01186
01187 if(_pNodeProto != NullFC)
01188 {
01189 FieldContainerPtr pAttClone = _pGenAtt->clone();
01190
01191 pAtt = GenericAttPtr::dcast(pAttClone);
01192
01193 if(pAtt != NullFC)
01194 {
01195 pAtt->setInternal(true);
01196 }
01197
01198 pFC = _pNodeProto->shallowCopy();
01199
01200 pNode = NodePtr::dcast(pFC);
01201
01202 pFC = _pNodeCoreProto->shallowCopy();
01203
01204 pNodeCore = NodeCorePtr::dcast(pFC);
01205
01206 beginEditCP(pNode);
01207 {
01208 pNode ->setCore (pNodeCore);
01209 pNodeCore->addAttachment(pAtt);
01210 }
01211 endEditCP (pNode);
01212 }
01213
01214 #ifdef OSG_DEBUG_VRML
01215 indentLog(getIndent(), PINFO);
01216 PINFO << "Begin Geo " << &(*pNode) << std::endl;
01217
01218 incIndent();
01219 #endif
01220
01221 return pNode;
01222 }
01223
01224 void VRMLGeometryDesc::endNode(FieldContainerPtr pFC)
01225 {
01226 NodePtr pNode = NullFC;
01227 GeometryPtr pGeo = NullFC;
01228
01229 if(pFC == NullFC)
01230 {
01231 return;
01232 }
01233
01234 pNode = NodePtr::dcast(pFC);
01235
01236 if(pNode == NullFC)
01237 {
01238 return;
01239 }
01240
01241 pGeo = GeometryPtr::dcast(pNode->getCore());
01242
01243 if(pGeo == NullFC)
01244 {
01245 return;
01246 }
01247
01248 Field *pField = NULL;
01249 const FieldDescription *pDesc = NULL;
01250
01251 MFInt32 *pCoordIndex = NULL;
01252 MFInt32 *pNormalIndex = NULL;
01253 MFInt32 *pColorIndex = NULL;
01254 MFInt32 *pTexCoordIndex = NULL;
01255 SFBool *pConvex = NULL;
01256 SFBool *pCcw = NULL;
01257 SFBool *pNormalPerVertex = NULL;
01258 SFBool *pColorPerVertex = NULL;
01259 SFReal32 *pCreaseAngle = NULL;
01260
01261 Inherited::getFieldAndDesc(pFC,
01262 "coordIndex",
01263 pField,
01264 pDesc);
01265
01266 if(pField != NULL)
01267 {
01268 pCoordIndex = static_cast<MFInt32 *>(pField);
01269 }
01270
01271 Inherited::getFieldAndDesc(pFC,
01272 "normalIndex",
01273 pField,
01274 pDesc);
01275
01276 if(pField != NULL)
01277 {
01278 pNormalIndex = static_cast<MFInt32 *>(pField);
01279 }
01280
01281 Inherited::getFieldAndDesc(pFC,
01282 "colorIndex",
01283 pField,
01284 pDesc);
01285
01286 if(pField != NULL)
01287 {
01288 pColorIndex = static_cast<MFInt32 *>(pField);
01289 }
01290
01291 Inherited::getFieldAndDesc(pFC,
01292 "texCoordIndex",
01293 pField,
01294 pDesc);
01295
01296 if(pField != NULL)
01297 {
01298 pTexCoordIndex = static_cast<MFInt32 *>(pField);
01299 }
01300
01301
01302
01303 Inherited::getFieldAndDesc(pFC,
01304 "convex",
01305 pField,
01306 pDesc);
01307
01308 if(pField != NULL)
01309 {
01310 pConvex = static_cast<SFBool *>(pField);
01311 }
01312
01313 Inherited::getFieldAndDesc(pFC,
01314 "ccw",
01315 pField,
01316 pDesc);
01317
01318 if(pField != NULL)
01319 {
01320 pCcw = static_cast<SFBool *>(pField);
01321 }
01322
01323 Inherited::getFieldAndDesc(pFC,
01324 "normalPerVertex",
01325 pField,
01326 pDesc);
01327
01328 if(pField != NULL)
01329 {
01330 pNormalPerVertex = static_cast<SFBool *>(pField);
01331 }
01332
01333 Inherited::getFieldAndDesc(pFC,
01334 "colorPerVertex",
01335 pField,
01336 pDesc);
01337
01338 if(pField != NULL)
01339 {
01340 pColorPerVertex = static_cast<SFBool *>(pField);
01341 }
01342
01343 Inherited::getFieldAndDesc(pFC,
01344 "creaseAngle",
01345 pField,
01346 pDesc);
01347
01348 if(pField != NULL)
01349 {
01350 pCreaseAngle = static_cast<SFReal32 *>(pField);
01351 }
01352
01353 if(_bIsFaceSet == true)
01354 {
01355 if(pCoordIndex != NULL &&
01356 pCoordIndex->size() > 2 &&
01357 pNormalIndex != NULL &&
01358 pColorIndex != NULL &&
01359 pTexCoordIndex != NULL &&
01360 pConvex != NULL &&
01361 pCcw != NULL &&
01362 pNormalPerVertex != NULL &&
01363 pColorPerVertex != NULL &&
01364 pCreaseAngle != NULL)
01365 {
01366 beginEditCP(pGeo);
01367 #ifdef OSG_DEBUG_VRML
01368 indentLog(getIndent(), PINFO);
01369 PINFO << "Geo create faceset " << &(*pNode) << std::endl;
01370 #endif
01371
01372 setIndexFromVRMLData(pGeo,
01373 pCoordIndex ->getValues(),
01374 pNormalIndex ->getValues(),
01375 pColorIndex ->getValues(),
01376 pTexCoordIndex ->getValues(),
01377 pConvex ->getValue() ,
01378 pCcw ->getValue() ,
01379 pNormalPerVertex->getValue() ,
01380 pColorPerVertex ->getValue() ,
01381 false,
01382 true);
01383
01384 if (pConvex->getValue() == false)
01385 createConvexPrimitives( pGeo );
01386
01387
01388 createSharedIndex( pGeo);
01389
01390
01391
01392
01393 if(pGeo->getNormals() == NullFC)
01394 {
01395 #ifdef OSG_DEBUG_VRML
01396 indentLog(getIndent(), PINFO);
01397 PINFO << "Geo create normals " << &(*pNode) << std::endl;
01398 #endif
01399
01400 OSG::calcVertexNormals(pGeo, pCreaseAngle->getValue());
01401 }
01402 }
01403 else
01404 {
01405 #if 0 // What's the point of doing that?
01406 PWARNING << "Invalid geometry replaced by a group" << std::endl;
01407
01408 GroupPtr pGr = Group::create();
01409
01410 MFNodePtr pGeoParents = pGeo->getParents ();
01411 MFNodePtr::iterator parentsIt = pGeoParents.begin();
01412 MFNodePtr::iterator endParents = pGeoParents.end ();
01413
01414
01415 while(parentsIt != endParents)
01416 {
01417 beginEditCP(*parentsIt, Node::CoreFieldMask);
01418 (*parentsIt)->setCore(pGr);
01419 endEditCP(*parentsIt, Node::CoreFieldMask);
01420
01421 ++parentsIt;
01422 }
01423 pGeo = NullFC;
01424 #endif
01425 }
01426 }
01427 else
01428 {
01429 std::vector<Int32> dummyVec;
01430 bool dummybool = false;
01431
01432 if(pCoordIndex != NULL &&
01433 pCoordIndex->size() > 1 &&
01434 pColorIndex != NULL &&
01435 pColorPerVertex != NULL)
01436 {
01437 beginEditCP(pGeo);
01438 #ifdef OSG_DEBUG_VRML
01439 indentLog(getIndent(), PINFO);
01440 PINFO << "Geo create lineset " << &(*pNode) << std::endl;
01441 #endif
01442
01443 setIndexFromVRMLData(pGeo,
01444 pCoordIndex ->getValues(),
01445 dummyVec ,
01446 pColorIndex ->getValues(),
01447 dummyVec ,
01448 dummybool,
01449 dummybool,
01450 dummybool,
01451 pColorPerVertex->getValue() ,
01452 false,
01453 false);
01454 }
01455 else
01456 {
01457 #if 0 // What's the point of doing that?
01458 PWARNING << "Invalid geometry replaced by a group" << std::endl;
01459
01460 GroupPtr pGr = Group::create();
01461
01462 MFNodePtr pGeoParents = pGeo->getParents ();
01463 MFNodePtr::iterator parentsIt = pGeoParents.begin();
01464 MFNodePtr::iterator endParents = pGeoParents.end ();
01465
01466
01467 while(parentsIt != endParents)
01468 {
01469 beginEditCP(*parentsIt, Node::CoreFieldMask);
01470 (*parentsIt)->setCore(pGr);
01471 endEditCP(*parentsIt, Node::CoreFieldMask);
01472
01473 ++parentsIt;
01474 }
01475 pGeo = NullFC;
01476 #endif
01477 }
01478 }
01479
01480
01481 if(pGeo != NullFC)
01482 endEditCP(pGeo);
01483
01484 #ifdef OSG_DEBUG_VRML
01485 decIndent();
01486
01487 indentLog(getIndent(), PINFO);
01488 PINFO << "End Geo " << &(*pNode) << std::endl;
01489 #endif
01490 }
01491
01492 void VRMLGeometryDesc::addFieldValue( Field *pField,
01493 const Char8 *szFieldVal)
01494 {
01495 if(pField != NULL)
01496 {
01497 pField->pushValueByStr(szFieldVal);
01498 }
01499 }
01500
01501
01502
01503
01504 void VRMLGeometryDesc::dump(const Char8 *)
01505 {
01506 }
01507
01508
01509
01510
01511
01512
01513
01519
01520
01521
01522 VRMLGeometryPointSetDesc::VRMLGeometryPointSetDesc(void) :
01523 Inherited (),
01524
01525 _bInIndex (false),
01526 _uiNumVertices(0),
01527
01528 _pTypeField (NullFC ),
01529 _pLengthField (NullFC )
01530 {
01531 }
01532
01533
01534
01535
01536 VRMLGeometryPointSetDesc::~VRMLGeometryPointSetDesc(void)
01537 {
01538 }
01539
01540
01541
01542
01543 void VRMLGeometryPointSetDesc::init(const Char8 *OSG_VRML_ARG(szName))
01544 {
01545 #ifdef OSG_DEBUG_VRML
01546 indentLog(getIndent(), PINFO);
01547 PINFO << "GeoDesc::init : " << szName << std::endl;
01548 #endif
01549
01550 _pNodeProto = Node::create();
01551 _pNodeCoreProto = Geometry::create();
01552
01553 _pGenAtt = GenericAtt::create();
01554 _pGenAtt->setInternal(true);
01555 }
01556
01557
01558
01559
01560 bool VRMLGeometryPointSetDesc::prototypeAddField(const Char8 *szFieldType,
01561 const UInt32 uiFieldTypeId,
01562 const Char8 *szFieldname)
01563 {
01564 bool bFound = false;
01565
01566 _pCurrField = NULL;
01567
01568 if(szFieldname == NULL)
01569 return false;
01570
01571 if(stringcasecmp("coord", szFieldname) == 0)
01572 {
01573 bFound = true;
01574 }
01575 else if(stringcasecmp("color", szFieldname) == 0)
01576 {
01577 bFound = true;
01578 }
01579
01580 if(bFound == true)
01581 {
01582 #ifdef OSG_DEBUG_VRML
01583 indentLog(getIndent(), PINFO);
01584 PINFO << "GeoDesc::prototypeAddField : internal "
01585 << szFieldname << std::endl;
01586 #endif
01587
01588 return true;
01589 }
01590 else
01591 {
01592 return Inherited::prototypeAddField(szFieldType,
01593 uiFieldTypeId,
01594 szFieldname);
01595 }
01596 }
01597
01598
01599 void VRMLGeometryPointSetDesc::getFieldAndDesc(
01600 FieldContainerPtr pFC,
01601 const Char8 * szFieldname,
01602 Field *&pField,
01603 const FieldDescription *&pDesc)
01604 {
01605 #ifdef OSG_DEBUG_VRML
01606 indentLog(getIndent(), PINFO);
01607 PINFO << "GeoDesc::getFieldAndDesc : request "
01608 << szFieldname
01609 << std::endl;
01610 #endif
01611
01612 if(szFieldname == NULL)
01613 return;
01614
01615 if(pFC == NullFC)
01616 return;
01617
01618 NodePtr pNode = NodePtr::dcast(pFC);
01619
01620 if(pNode == NullFC)
01621 {
01622 PWARNING << "GeoDesc::getFieldAndDesc : No Node" << std::endl;
01623 return;
01624 }
01625
01626 NodeCorePtr pNodeCore = pNode->getCore();
01627
01628 GeometryPtr pGeo = GeometryPtr::dcast(pNodeCore);
01629
01630 if(pGeo == NullFC)
01631 {
01632 PWARNING << "GeoDesc::getFieldAndDesc : No Geo" << std::endl;
01633 return;
01634 }
01635
01636 _bInIndex = false;
01637
01638 if(stringcasecmp("coord", szFieldname) == 0)
01639 {
01640 #ifdef OSG_DEBUG_VRML
01641 indentLog(getIndent(), PINFO);
01642 PINFO << "GeoDesc::getFieldAndDesc : internal "
01643 << szFieldname << std::endl;
01644 #endif
01645 pField = pGeo->getField("positions");
01646
01647 if(pField != NULL)
01648 pDesc = pGeo->getType().findFieldDescription("positions");
01649 }
01650 else if(stringcasecmp("color", szFieldname) == 0)
01651 {
01652 #ifdef OSG_DEBUG_VRML
01653 indentLog(getIndent(), PINFO);
01654 PINFO << "GeoDesc::getFieldAndDesc : internal "
01655 << szFieldname << std::endl;
01656 #endif
01657
01658 pField = pGeo->getField("colors");
01659
01660 if(pField != NULL)
01661 pDesc = pGeo->getType().findFieldDescription("colors");
01662 }
01663 else
01664 {
01665 VRMLNodeDesc::getFieldAndDesc(pGeo,
01666 szFieldname,
01667 pField,
01668 pDesc);
01669 }
01670 }
01671
01672
01673
01674
01675 FieldContainerPtr VRMLGeometryPointSetDesc::beginNode(
01676 const Char8 *,
01677 const Char8 *,
01678 FieldContainerPtr)
01679 {
01680 FieldContainerPtr pFC = NullFC;
01681 NodePtr pNode = NullFC;
01682 NodeCorePtr pNodeCore = NullFC;
01683 GenericAttPtr pAtt = NullFC;
01684
01685 if(_pNodeProto != NullFC)
01686 {
01687 FieldContainerPtr pAttClone = _pGenAtt->clone();
01688
01689 pAtt = GenericAttPtr::dcast(pAttClone);
01690
01691 if(pAtt != NullFC)
01692 {
01693 pAtt->setInternal(true);
01694 }
01695
01696 pFC = _pNodeProto->shallowCopy();
01697
01698 pNode = NodePtr::dcast(pFC);
01699
01700 pFC = _pNodeCoreProto->shallowCopy();
01701
01702 pNodeCore = NodeCorePtr::dcast(pFC);
01703
01704 beginEditCP(pNode);
01705 {
01706 pNode ->setCore (pNodeCore);
01707 pNodeCore->addAttachment(pAtt);
01708 }
01709 endEditCP (pNode);
01710 }
01711
01712 #ifdef OSG_DEBUG_VRML
01713 indentLog(getIndent(), PINFO);
01714 PINFO << "Begin Geo " << &(*pNode) << std::endl;
01715
01716 incIndent();
01717 #endif
01718
01719 return pNode;
01720 }
01721
01722 void VRMLGeometryPointSetDesc::endNode(FieldContainerPtr pFC)
01723 {
01724 NodePtr pNode = NullFC;
01725 GeometryPtr pGeo = NullFC;
01726
01727 if(pFC == NullFC)
01728 {
01729 return;
01730 }
01731
01732 pNode = NodePtr::dcast(pFC);
01733
01734 if(pNode == NullFC)
01735 {
01736 return;
01737 }
01738
01739 pGeo = GeometryPtr::dcast(pNode->getCore());
01740
01741 if(pGeo == NullFC)
01742 {
01743 return;
01744 }
01745
01746 GeoPLengthsUI32Ptr pLengths = GeoPLengthsUI32::create();
01747 GeoPTypesUI8Ptr pTypes = GeoPTypesUI8::create();
01748
01749 GeoPositionsPtr pPos = pGeo->getPositions();
01750 GeoPositions3fPtr pCoords = GeoPositions3fPtr::dcast(pPos);
01751
01752 if(pCoords == NullFC)
01753 return;
01754
01755 GeoPLengthsUI32::StoredFieldType *pLenField =
01756 pLengths->getFieldPtr();
01757
01758 GeoPTypesUI8 ::StoredFieldType *pTypeField =
01759 pTypes ->getFieldPtr();
01760
01761 beginEditCP(pLengths);
01762 {
01763 pLenField->push_back(pCoords->getFieldPtr()->size());
01764 }
01765 endEditCP (pLengths);
01766
01767 beginEditCP(pTypes);
01768 {
01769 pTypeField->push_back(GL_POINTS);
01770 }
01771 endEditCP (pTypes);
01772
01773 beginEditCP(pGeo,
01774 Geometry::TypesFieldMask |
01775 Geometry::LengthsFieldMask);
01776 {
01777 pGeo->setLengths(pLengths);
01778 pGeo->setTypes (pTypes );
01779 }
01780 endEditCP (pGeo,
01781 Geometry::TypesFieldMask |
01782 Geometry::LengthsFieldMask);
01783
01784 #if 0
01785 Field *pField = NULL;
01786 const FieldDescription *pDesc = NULL;
01787
01788 MFInt32 *pCoordIndex = NULL;
01789 MFInt32 *pNormalIndex = NULL;
01790 MFInt32 *pColorIndex = NULL;
01791 MFInt32 *pTexCoordIndex = NULL;
01792 SFBool *pConvex = NULL;
01793 SFBool *pCcw = NULL;
01794 SFBool *pNormalPerVertex = NULL;
01795 SFBool *pColorPerVertex = NULL;
01796 SFReal32 *pCreaseAngle = NULL;
01797
01798 Inherited::getFieldAndDesc(pFC,
01799 "coordIndex",
01800 pField,
01801 pDesc);
01802
01803 if(pField != NULL)
01804 {
01805 pCoordIndex = static_cast<MFInt32 *>(pField);
01806 }
01807
01808 Inherited::getFieldAndDesc(pFC,
01809 "normalIndex",
01810 pField,
01811 pDesc);
01812
01813 if(pField != NULL)
01814 {
01815 pNormalIndex = static_cast<MFInt32 *>(pField);
01816 }
01817
01818 Inherited::getFieldAndDesc(pFC,
01819 "colorIndex",
01820 pField,
01821 pDesc);
01822
01823 if(pField != NULL)
01824 {
01825 pColorIndex = static_cast<MFInt32 *>(pField);
01826 }
01827
01828 Inherited::getFieldAndDesc(pFC,
01829 "texCoordIndex",
01830 pField,
01831 pDesc);
01832
01833 if(pField != NULL)
01834 {
01835 pTexCoordIndex = static_cast<MFInt32 *>(pField);
01836 }
01837
01838
01839
01840 Inherited::getFieldAndDesc(pFC,
01841 "convex",
01842 pField,
01843 pDesc);
01844
01845 if(pField != NULL)
01846 {
01847 pConvex = static_cast<SFBool *>(pField);
01848 }
01849
01850 Inherited::getFieldAndDesc(pFC,
01851 "ccw",
01852 pField,
01853 pDesc);
01854
01855 if(pField != NULL)
01856 {
01857 pCcw = static_cast<SFBool *>(pField);
01858 }
01859
01860 Inherited::getFieldAndDesc(pFC,
01861 "normalPerVertex",
01862 pField,
01863 pDesc);
01864
01865 if(pField != NULL)
01866 {
01867 pNormalPerVertex = static_cast<SFBool *>(pField);
01868 }
01869
01870 Inherited::getFieldAndDesc(pFC,
01871 "colorPerVertex",
01872 pField,
01873 pDesc);
01874
01875 if(pField != NULL)
01876 {
01877 pColorPerVertex = static_cast<SFBool *>(pField);
01878 }
01879
01880 Inherited::getFieldAndDesc(pFC,
01881 "creaseAngle",
01882 pField,
01883 pDesc);
01884
01885 if(pField != NULL)
01886 {
01887 pCreaseAngle = static_cast<SFReal32 *>(pField);
01888 }
01889
01890 beginEditCP(pGeo);
01891
01892 if(_bIsFaceSet == true)
01893 {
01894 if(pCoordIndex != NULL &&
01895 pCoordIndex->size() > 2 &&
01896 pNormalIndex != NULL &&
01897 pColorIndex != NULL &&
01898 pTexCoordIndex != NULL &&
01899 pConvex != NULL &&
01900 pCcw != NULL &&
01901 pNormalPerVertex != NULL &&
01902 pColorPerVertex != NULL &&
01903 pCreaseAngle != NULL)
01904 {
01905 #ifdef OSG_DEBUG_VRML
01906 indentLog(getIndent(), PINFO);
01907 PINFO << "Geo create faceset " << &(*pNode) << std::endl;
01908 #endif
01909
01910 setIndexFromVRMLData(pGeo,
01911 pCoordIndex ->getValues(),
01912 pNormalIndex ->getValues(),
01913 pColorIndex ->getValues(),
01914 pTexCoordIndex ->getValues(),
01915 pConvex ->getValue() ,
01916 pCcw ->getValue() ,
01917 pNormalPerVertex->getValue() ,
01918 pColorPerVertex ->getValue() ,
01919 false,
01920 true);
01921
01922
01923
01924 if(pGeo->getNormals() == NullFC)
01925 {
01926 #ifdef OSG_DEBUG_VRML
01927 indentLog(getIndent(), PINFO);
01928 PINFO << "Geo create normals " << &(*pNode) << std::endl;
01929 #endif
01930
01931 OSG::calcVertexNormals(pGeo, pCreaseAngle->getValue());
01932 }
01933 }
01934 else
01935 {
01936 #if 0 // What's the point of doing that?
01937 PWARNING << "Invalid geometry replaced by a group" << std::endl;
01938
01939 GroupPtr pGr = Group::create();
01940
01941 MFNodePtr pGeoParents = pGeo->getParents ();
01942 MFNodePtr::iterator parentsIt = pGeoParents.begin();
01943 MFNodePtr::iterator endParents = pGeoParents.end ();
01944
01945 while(parentsIt != endParents)
01946 {
01947 (*parentsIt)->setCore(pGr);
01948
01949 ++parentsIt;
01950 }
01951 #endif
01952 }
01953 }
01954 else
01955 {
01956 vector<Int32> dummyVec;
01957 bool dummybool = false;
01958
01959 if(pCoordIndex != NULL &&
01960 pCoordIndex->size() > 1 &&
01961 pColorIndex != NULL &&
01962 pColorPerVertex != NULL)
01963 {
01964 #ifdef OSG_DEBUG_VRML
01965 indentLog(getIndent(), PINFO);
01966 PINFO << "Geo create lineset " << &(*pNode) << std::endl;
01967 #endif
01968
01969 setIndexFromVRMLData(pGeo,
01970 pCoordIndex ->getValues(),
01971 dummyVec ,
01972 pColorIndex ->getValues(),
01973 dummyVec ,
01974 dummybool,
01975 dummybool,
01976 dummybool,
01977 pColorPerVertex->getValue() ,
01978 false,
01979 false);
01980 }
01981 else
01982 {
01983 #if 0 // What's the point of doing that?
01984
01985 PWARNING << "Invalid geometry replaced by a group" << std::endl;
01986
01987 GroupPtr pGr = Group::create();
01988
01989 MFNodePtr pGeoParents = pGeo->getParents ();
01990 MFNodePtr::iterator parentsIt = pGeoParents.begin();
01991 MFNodePtr::iterator endParents = pGeoParents.end ();
01992
01993 while(parentsIt != endParents)
01994 {
01995 (*parentsIt)->setCore(pGr);
01996
01997 ++parentsIt;
01998 }
01999 #endif
02000 }
02001 }
02002
02003 endEditCP(pGeo);
02004
02005 #ifdef OSG_DEBUG_VRML
02006 decIndent();
02007
02008 indentLog(getIndent(), PINFO);
02009 PINFO << "End Geo " << &(*pNode) << std::endl;
02010 #endif
02011 #endif
02012 }
02013
02014 void VRMLGeometryPointSetDesc::addFieldValue( Field *pField,
02015 const Char8 *szFieldVal)
02016 {
02017 if(pField != NULL)
02018 {
02019 pField->pushValueByStr(szFieldVal);
02020 }
02021 }
02022
02023
02024
02025
02026 void VRMLGeometryPointSetDesc::dump(const Char8 *)
02027 {
02028 }
02029
02030
02031
02032
02033
02034
02035
02036
02042
02043
02044
02045 VRMLGeometryPartDesc::VRMLGeometryPartDesc(Char8 *szVRMLPartname,
02046 Char8 *szOSGPartname,
02047 Char8 *szOSGProtoname) :
02048 Inherited(),
02049
02050 _szVRMLPartname(NULL),
02051 _szOSGPartname (NULL),
02052 _szOSGProtoname(NULL)
02053 {
02054 stringDup(szVRMLPartname, _szVRMLPartname);
02055 stringDup(szOSGPartname, _szOSGPartname );
02056 stringDup(szOSGProtoname, _szOSGProtoname);
02057 }
02058
02059
02060
02061
02062 VRMLGeometryPartDesc::~VRMLGeometryPartDesc(void)
02063 {
02064 }
02065
02066
02067
02068
02069 void VRMLGeometryPartDesc::init(const Char8 *OSG_VRML_ARG(szName))
02070 {
02071 #ifdef OSG_DEBUG_VRML
02072 indentLog(getIndent(), PINFO);
02073 PINFO << "GeoPartDesc::init : "
02074 << szName << " "
02075 << _szVRMLPartname << " "
02076 << _szOSGPartname << " "
02077 << _szOSGProtoname << " "
02078 << std::endl;
02079 #endif
02080
02081 _pNodeProto =
02082 FieldContainerFactory::the()->createFieldContainer(_szOSGProtoname);
02083
02084 if(_pNodeProto == NullFC)
02085 {
02086 PWARNING << "ERROR no prototype available for "
02087 << _szOSGProtoname
02088 << std::endl;
02089 }
02090
02091 _pGenAtt = GenericAtt::create();
02092 _pGenAtt->setInternal(true);
02093 }
02094
02095
02096
02097
02098 bool VRMLGeometryPartDesc::prototypeAddField(const Char8 *szFieldType,
02099 const UInt32 uiFieldTypeId,
02100 const Char8 *szFieldname)
02101 {
02102 bool bFound = false;
02103
02104 _pCurrField = NULL;
02105
02106 if(stringcasecmp(_szVRMLPartname, szFieldname) == 0)
02107 {
02108 #ifdef OSG_DEBUG_VRML
02109 indentLog(getIndent(), PINFO);
02110 PINFO << "GeoPartDesc::prototypeAddField : add part "
02111 << szFieldname
02112 << std::endl;
02113 #endif
02114
02115 bFound = true;
02116 }
02117
02118
02119 if(bFound == true)
02120 {
02121 return true;
02122 }
02123 else
02124 {
02125 return VRMLNodeDesc::prototypeAddField(szFieldType,
02126 uiFieldTypeId,
02127 szFieldname);
02128 }
02129 }
02130
02131 void VRMLGeometryPartDesc::getFieldAndDesc(
02132 FieldContainerPtr pFC,
02133 const Char8 * szFieldname,
02134 Field *&pField,
02135 const FieldDescription *&pDesc)
02136 {
02137 #ifdef OSG_DEBUG_VRML
02138 indentLog(getIndent(), PINFO);
02139 PINFO << "VRMLGeometryPartDesc::getFieldAndDesc : looking for "
02140 << szFieldname
02141 << std::endl;
02142 #endif
02143
02144 if(szFieldname == NULL)
02145 return;
02146
02147 if(pFC == NullFC)
02148 return;
02149
02150 incIndent();
02151
02152 if(stringcasecmp(_szVRMLPartname, szFieldname) == 0)
02153 {
02154 #ifdef OSG_DEBUG_VRML
02155 indentLog(getIndent(), PINFO);
02156 PINFO << "VRMLGeometryPartDesc::getFieldAndDesc : request internal "
02157 << szFieldname
02158 << " return "
02159 << _szOSGPartname
02160 << std::endl;
02161 #endif
02162
02163 pField = pFC->getField(_szOSGPartname);
02164
02165 if(pField != NULL)
02166 pDesc = pFC->getType().findFieldDescription(_szOSGPartname);
02167
02168 if(pField == NULL)
02169 {
02170 PWARNING << "VRMLGeometryPartDesc::getFieldAndDesc : could not"
02171 << " map : "
02172 << szFieldname
02173 << " to "
02174 << _szOSGPartname
02175 << std::endl;
02176 }
02177 }
02178 else
02179 {
02180 Inherited::getFieldAndDesc(pFC,
02181 szFieldname,
02182 pField,
02183 pDesc);
02184 }
02185
02186 #ifdef OSG_DEBUG_VRML
02187 decIndent();
02188 #endif
02189 }
02190
02191
02192
02193
02194 FieldContainerPtr VRMLGeometryPartDesc::beginNode(
02195 const Char8 *,
02196 const Char8 *,
02197 FieldContainerPtr)
02198 {
02199 FieldContainerPtr returnValue = NullFC;
02200
02201 if(_pNodeProto != NullFC)
02202 returnValue = _pNodeProto->shallowCopy();
02203
02204 return returnValue;
02205 }
02206
02207
02208
02209
02210 void VRMLGeometryPartDesc::dump(const Char8 *)
02211 {
02212 }
02213
02214
02215
02216
02217
02218
02219
02225
02226
02227
02228 VRMLGeometryObjectDesc::VRMLGeometryObjectDesc(Char8 *szVRMLObjectname) :
02229 Inherited(),
02230
02231 _szVRMLObjectname(NULL)
02232 {
02233 stringDup(szVRMLObjectname, _szVRMLObjectname);
02234 }
02235
02236
02237
02238
02239 VRMLGeometryObjectDesc::~VRMLGeometryObjectDesc(void)
02240 {
02241 }
02242
02243
02244
02245
02246 void VRMLGeometryObjectDesc::init(const Char8 *OSG_VRML_ARG(szName))
02247 {
02248 #ifdef OSG_DEBUG_VRML
02249 indentLog(getIndent(), PINFO);
02250 PINFO << "GeoObjDesc::init : "
02251 << szName << " "
02252 << _szVRMLObjectname
02253 << std::endl;
02254 #endif
02255
02256 _pNodeProto = Node::create();
02257
02258 if(_pNodeProto == NullFC)
02259 {
02260 PWARNING << "GeoObjDesc::init : no prototype available" << std::endl;
02261 }
02262
02263 _pGenAtt = GenericAtt::create();
02264 _pGenAtt->setInternal(true);
02265 }
02266
02267
02268
02269
02270 bool VRMLGeometryObjectDesc::prototypeAddField(const Char8 *szFieldType,
02271 const UInt32 uiFieldTypeId,
02272 const Char8 *szFieldname)
02273 {
02274 _pCurrField = NULL;
02275
02276 bool rc = VRMLNodeDesc::prototypeAddField(szFieldType,
02277 uiFieldTypeId,
02278 szFieldname);
02279
02280 return rc;
02281 }
02282
02283 void VRMLGeometryObjectDesc::getFieldAndDesc(
02284 FieldContainerPtr pFC,
02285 const Char8 * szFieldname,
02286 Field *&pField,
02287 const FieldDescription *&pDesc)
02288 {
02289 #ifdef OSG_DEBUG_VRML
02290 indentLog(getIndent(), PINFO);
02291 PINFO << "VRMLGeometryObjectDesc::getFieldAndDesc : looking for "
02292 << szFieldname
02293 << std::endl;
02294 #endif
02295
02296 if(szFieldname == NULL)
02297 return;
02298
02299 if(pFC == NullFC)
02300 return;
02301
02302 incIndent();
02303
02304 Inherited::getFieldAndDesc(pFC,
02305 szFieldname,
02306 pField,
02307 pDesc);
02308
02309 #ifdef OSG_DEBUG_VRML
02310 decIndent();
02311 #endif
02312 }
02313
02314
02315
02316
02317 FieldContainerPtr VRMLGeometryObjectDesc::beginNode(
02318 const Char8 *,
02319 const Char8 *,
02320 FieldContainerPtr)
02321 {
02322 FieldContainerPtr returnValue = NullFC;
02323 NodePtr pNode = NullFC;
02324 GenericAttPtr pAtt = NullFC;
02325
02326 if(_pNodeProto != NullFC)
02327 {
02328 FieldContainerPtr pAttClone = _pGenAtt->clone();
02329
02330 pAtt = GenericAttPtr::dcast(pAttClone);
02331
02332 if(pAtt != NullFC)
02333 {
02334 pAtt->setInternal(true);
02335 }
02336
02337 returnValue = _pNodeProto->shallowCopy();
02338
02339 pNode = NodePtr::dcast(returnValue);
02340
02341 pNode->addAttachment(pAtt);
02342 }
02343
02344 return returnValue;
02345 }
02346
02347 void VRMLGeometryObjectDesc::endNode(FieldContainerPtr pFC)
02348 {
02349 Field *pField = NULL;
02350 const FieldDescription *pDesc = NULL;
02351 NodePtr pNode = NullFC;
02352
02353 if(pFC == NullFC)
02354 return;
02355
02356 pNode = NodePtr::dcast(pFC);
02357
02358 if(pNode == NullFC)
02359 return;
02360
02361 if( stringcasecmp("Box", _szVRMLObjectname) == 0)
02362 {
02363 Inherited::getFieldAndDesc(pFC,
02364 "size",
02365 pField,
02366 pDesc);
02367
02368 if(pField != NULL)
02369 {
02370 SFVec3f *pVec = static_cast<SFVec3f *>(pField);
02371
02372 #ifdef OSG_DEBUG_VRML
02373 indentLog(getIndent(), PINFO);
02374 PINFO << "VRMLGeometryObjectDesc::endNode : Create box"
02375 << std::endl;
02376 #endif
02377
02378 GeometryPtr pGeo = makeBoxGeo(pVec->getValue()[0],
02379 pVec->getValue()[1],
02380 pVec->getValue()[2],
02381 1,1,1);
02382
02383 beginEditCP(pNode, Node::CoreFieldMask);
02384 {
02385 pNode->setCore(pGeo);
02386 }
02387 endEditCP (pNode, Node::CoreFieldMask);
02388 }
02389 }
02390 else if(stringcasecmp("Cone", _szVRMLObjectname) == 0)
02391 {
02392 SFReal32 *pBotRad = NULL;
02393 SFReal32 *pHeight = NULL;
02394 SFBool *pSide = NULL;
02395 SFBool *pBottom = NULL;
02396
02397 Inherited::getFieldAndDesc(pFC,
02398 "bottomRadius",
02399 pField,
02400 pDesc);
02401
02402 if(pField != NULL)
02403 {
02404 pBotRad = static_cast<SFReal32 *>(pField);
02405 }
02406
02407 Inherited::getFieldAndDesc(pFC,
02408 "height",
02409 pField,
02410 pDesc);
02411
02412 if(pField != NULL)
02413 {
02414 pHeight = static_cast<SFReal32 *>(pField);
02415 }
02416
02417 Inherited::getFieldAndDesc(pFC,
02418 "side",
02419 pField,
02420 pDesc);
02421
02422 if(pField != NULL)
02423 {
02424 pSide = static_cast<SFBool *>(pField);
02425 }
02426
02427 Inherited::getFieldAndDesc(pFC,
02428 "bottom",
02429 pField,
02430 pDesc);
02431
02432 if(pField != NULL)
02433 {
02434 pBottom = static_cast<SFBool *>(pField);
02435 }
02436
02437 if(pBotRad != NULL &&
02438 pHeight != NULL &&
02439 pSide != NULL &&
02440 pBottom != NULL)
02441 {
02442 #ifdef OSG_DEBUG_VRML
02443 indentLog(getIndent(), PINFO);
02444 PINFO << "VRMLGeometryObjectDesc::endNode : Create cone"
02445 << std::endl;
02446 #endif
02447
02448 GeometryPtr pGeo = makeConeGeo(pHeight->getValue(),
02449 pBotRad->getValue(),
02450 32,
02451 pSide ->getValue(),
02452 pBottom->getValue());
02453
02454 beginEditCP(pNode, Node::CoreFieldMask);
02455 {
02456 pNode->setCore(pGeo);
02457 }
02458 endEditCP (pNode, Node::CoreFieldMask);
02459 }
02460 }
02461 else if(stringcasecmp("Cylinder", _szVRMLObjectname) == 0)
02462 {
02463 SFBool *pBottom = NULL;
02464 SFReal32 *pHeight = NULL;
02465 SFReal32 *pRadius = NULL;
02466 SFBool *pSide = NULL;
02467 SFBool *pTop = NULL;
02468
02469 Inherited::getFieldAndDesc(pFC,
02470 "bottom",
02471 pField,
02472 pDesc);
02473
02474 if(pField != NULL)
02475 {
02476 pBottom = static_cast<SFBool *>(pField);
02477 }
02478
02479 Inherited::getFieldAndDesc(pFC,
02480 "height",
02481 pField,
02482 pDesc);
02483
02484 if(pField != NULL)
02485 {
02486 pHeight = static_cast<SFReal32 *>(pField);
02487 }
02488
02489 Inherited::getFieldAndDesc(pFC,
02490 "radius",
02491 pField,
02492 pDesc);
02493
02494 if(pField != NULL)
02495 {
02496 pRadius = static_cast<SFReal32 *>(pField);
02497 }
02498
02499 Inherited::getFieldAndDesc(pFC,
02500 "side",
02501 pField,
02502 pDesc);
02503
02504 if(pField != NULL)
02505 {
02506 pSide = static_cast<SFBool *>(pField);
02507 }
02508
02509 Inherited::getFieldAndDesc(pFC,
02510 "top",
02511 pField,
02512 pDesc);
02513
02514 if(pField != NULL)
02515 {
02516 pTop = static_cast<SFBool *>(pField);
02517 }
02518
02519
02520 if(pBottom != NULL &&
02521 pHeight != NULL &&
02522 pRadius != NULL &&
02523 pSide != NULL &&
02524 pTop != NULL)
02525 {
02526 #ifdef OSG_DEBUG_VRML
02527 indentLog(getIndent(), PINFO);
02528 PINFO << "VRMLGeometryObjectDesc::endNode : Create cylinder"
02529 << std::endl;
02530 #endif
02531
02532 GeometryPtr pGeo = makeCylinderGeo(pHeight->getValue(),
02533 pRadius->getValue(),
02534 32,
02535 pSide ->getValue(),
02536 pTop ->getValue(),
02537 pBottom->getValue());
02538
02539 beginEditCP(pNode, Node::CoreFieldMask);
02540 {
02541 pNode->setCore(pGeo);
02542 }
02543 endEditCP (pNode, Node::CoreFieldMask);
02544 }
02545 }
02546 else if(stringcasecmp("Sphere", _szVRMLObjectname) == 0)
02547 {
02548 Inherited::getFieldAndDesc(pFC,
02549 "radius",
02550 pField,
02551 pDesc);
02552
02553 if(pField != NULL)
02554 {
02555 SFReal32 *pValue = static_cast<SFReal32 *>(pField);
02556
02557 #ifdef OSG_DEBUG_VRML
02558 indentLog(getIndent(), PINFO);
02559 PINFO << "VRMLGeometryObjectDesc::endNode : Create sphere"
02560 << std::endl;
02561 #endif
02562
02563 GeometryPtr pGeo = makeLatLongSphereGeo(8, 16, pValue->getValue());
02564
02565 beginEditCP(pNode, Node::CoreFieldMask);
02566 {
02567 pNode->setCore(pGeo);
02568 }
02569 endEditCP (pNode, Node::CoreFieldMask);
02570 }
02571
02572 }
02573 }
02574
02575
02576
02577
02578 void VRMLGeometryObjectDesc::dump(const Char8 *)
02579 {
02580 }
02581
02582
02583
02584
02585
02586
02587
02588
02594
02595
02596
02597 VRMLAppearanceDesc::VRMLAppearanceDesc(void) :
02598 Inherited (),
02599
02600 _pMaterialDesc (NULL)
02601 {
02602 }
02603
02604
02605
02606
02607 VRMLAppearanceDesc::~VRMLAppearanceDesc(void)
02608 {
02609 }
02610
02611
02612
02613
02614 void VRMLAppearanceDesc::init(const Char8 *OSG_VRML_ARG(szName))
02615 {
02616 #ifdef OSG_DEBUG_VRML
02617 indentLog(getIndent(), PINFO);
02618 PINFO << "ApperanceDesc::init : " << szName << std::endl;
02619 #endif
02620
02621 _pNodeProto = ChunkMaterial::create();
02622 addRefCP(_pNodeProto);
02623
02624 _pGenAtt = GenericAtt::create();
02625 _pGenAtt->setInternal(true);
02626 }
02627
02628 void VRMLAppearanceDesc::setMaterialDesc(VRMLMaterialDesc *pMaterialDesc)
02629 {
02630 _pMaterialDesc = pMaterialDesc;
02631 }
02632
02633 FieldContainerPtr VRMLAppearanceDesc::getSaveFieldContainer(void)
02634 {
02635 return NullFC;
02636 }
02637
02638
02639
02640
02641 bool VRMLAppearanceDesc::prototypeAddField(const Char8 *szFieldType,
02642 const UInt32 uiFieldTypeId,
02643 const Char8 *szFieldname)
02644 {
02645 _pCurrField = NULL;
02646
02647 if(szFieldname == NULL)
02648 return false;
02649
02650 if(stringcasecmp("material", szFieldname) == 0)
02651 {
02652 return true;
02653 }
02654 else if(stringcasecmp("texture", szFieldname) == 0)
02655 {
02656 return true;
02657 }
02658 else if(stringcasecmp("textureTransform", szFieldname) == 0)
02659 {
02660 return true;
02661 }
02662 else
02663 {
02664 return VRMLNodeDesc::prototypeAddField(szFieldType,
02665 uiFieldTypeId,
02666 szFieldname);
02667 }
02668 }
02669
02670 void VRMLAppearanceDesc::getFieldAndDesc(
02671 FieldContainerPtr pFC,
02672 const Char8 * szFieldname,
02673 Field *&pField,
02674 const FieldDescription *&pDesc)
02675 {
02676
02677 #ifdef OSG_DEBUG_VRML
02678 indentLog(getIndent(), PINFO);
02679 PINFO << "VRMLAppearanceDesc::getFieldAndDesc : looking for "
02680 << szFieldname
02681 << std::endl;
02682 #endif
02683
02684 if(pFC == NullFC)
02685 return;
02686
02687 if(szFieldname == NULL)
02688 return;
02689
02690 incIndent();
02691
02692 if(stringcasecmp("material", szFieldname) == 0)
02693 {
02694 #ifdef OSG_DEBUG_VRML
02695 indentLog(getIndent(), PINFO);
02696 PINFO << "VRMLAppearanceDesc::getFieldAndDesc : request internal "
02697 << szFieldname
02698 << std::endl;
02699 #endif
02700
02701 pField = pFC->getField("chunks");
02702
02703 if(pField != NULL)
02704 pDesc = pFC->getType().findFieldDescription("chunks");
02705 }
02706 else if(stringcasecmp("texture", szFieldname) == 0)
02707 {
02708 #ifdef OSG_DEBUG_VRML
02709 indentLog(getIndent(), PINFO);
02710 PINFO << "VRMLAppearanceDesc::getFieldAndDesc : request internal "
02711 << szFieldname
02712 << std::endl;
02713 #endif
02714
02715 pField = pFC->getField("chunks");
02716
02717 if(pField != NULL)
02718 pDesc = pFC->getType().findFieldDescription("chunks");
02719 }
02720 else if(stringcasecmp("textureTransform", szFieldname) == 0)
02721 {
02722 #ifdef OSG_DEBUG_VRML
02723 indentLog(getIndent(), PINFO);
02724 PINFO << "VRMLAppearanceDesc::getFieldAndDesc : request internal "
02725 << szFieldname
02726 << std::endl;
02727 #endif
02728
02729 pField = pFC->getField("chunks");
02730
02731 if(pField != NULL)
02732 pDesc = pFC->getType().findFieldDescription("chunks");
02733 }
02734 else
02735 {
02736 Inherited::getFieldAndDesc(_pGenAtt,
02737 szFieldname,
02738 pField,
02739 pDesc);
02740 }
02741
02742 #ifdef OSG_DEBUG_VRML
02743 decIndent();
02744 #endif
02745 }
02746
02747
02748
02749
02750 FieldContainerPtr VRMLAppearanceDesc::beginNode(
02751 const Char8 *,
02752 const Char8 *,
02753 FieldContainerPtr )
02754 {
02755 FieldContainerPtr returnValue = NullFC;
02756
02757 returnValue = _pNodeProto->shallowCopy();
02758
02759 #ifdef OSG_DEBUG_VRML
02760 indentLog(getIndent(), PINFO);
02761 PINFO << "Begin Appearance " << &(*returnValue) << std::endl;
02762
02763 incIndent();
02764 #endif
02765
02766 return returnValue;
02767 }
02768
02769 void VRMLAppearanceDesc::endNode(FieldContainerPtr pFC)
02770 {
02771 if(pFC != NullFC)
02772 {
02773 ChunkMaterialPtr pChunkMat = ChunkMaterialPtr::dcast(pFC);
02774
02775 if(pChunkMat != NullFC)
02776 {
02777 StateChunkPtr cp = pChunkMat->find(TextureChunk::getClassType());
02778
02779 TextureChunkPtr tex = NullFC;
02780
02781 if(cp != NullFC)
02782 tex = TextureChunkPtr::dcast(cp);
02783
02784 if (pChunkMat->isTransparent() == true ||
02785 ( tex != NullFC && tex->getImage() != NullFC &&
02786 tex->getImage()->hasAlphaChannel()
02787 ))
02788 {
02789 BlendChunkPtr pBlendChunk = OSG::BlendChunk::create();
02790
02791 beginEditCP(pBlendChunk);
02792 {
02793 if(tex != NullFC && tex->getImage() != NullFC &&
02794 tex->getImage()->isAlphaBinary())
02795 {
02796 pBlendChunk->setAlphaFunc(GL_NOTEQUAL);
02797 pBlendChunk->setAlphaValue(0);
02798 }
02799 else
02800 {
02801 pBlendChunk->setSrcFactor (GL_SRC_ALPHA);
02802 pBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
02803 }
02804 }
02805 endEditCP(pBlendChunk);
02806
02807 beginEditCP(pChunkMat, ChunkMaterial::ChunksFieldMask);
02808 {
02809 pChunkMat->addChunk(pBlendChunk);
02810 }
02811 endEditCP (pChunkMat, ChunkMaterial::ChunksFieldMask);
02812 }
02813 }
02814 }
02815
02816 #if 0
02817 TextureChunkPtr pTexture =
02818 TextureChunkPtr::dcast(_sfTexture.getValue());
02819
02820 if(pChunkMat != NullFC)
02821 {
02822 if(pTexture != NullFC)
02823 {
02824 beginEditCP(pChunkMat);
02825 {
02826 pChunkMat->addChunk(pTexture);
02827 }
02828 endEditCP(pChunkMat);
02829 }
02830 }
02831 else
02832 {
02833 if(pTexture != NullFC)
02834 {
02835 FieldContainerPtr pMat =
02836 _pMaterialDesc->getDefaultMaterial()->shallowCopy();
02837
02838 ChunkMaterialPtr pChunkMat =
02839 ChunkMaterialPtr::dcast(pMat);
02840
02841 if(pChunkMat != NullFC)
02842 {
02843 if(pTexture != NullFC)
02844 {
02845 beginEditCP(pChunkMat);
02846 {
02847 pChunkMat->addChunk(pTexture);
02848 }
02849 endEditCP(pChunkMat);
02850 }
02851
02852 beginEditCP(pMatGroup);
02853 {
02854 pMatGroup->setMaterial(pChunkMat);
02855 }
02856 endEditCP(pMatGroup);
02857 }
02858 }
02859 else
02860 {
02861 PWARNING << "No material, adding default" << std::endl;
02862 beginEditCP(pMatGroup);
02863 {
02864 pMatGroup->setMaterial(
02865 _pMaterialDesc->getDefaultMaterial());
02866 }
02867 endEditCP(pMatGroup);
02868 }
02869 }
02870 #endif
02871
02872 #ifdef OSG_DEBUG_VRML
02873 decIndent();
02874
02875 indentLog(getIndent(), PINFO);
02876 PINFO << "End Appearance " << std::endl;
02877 #endif
02878 }
02879
02880
02881
02882
02883 bool VRMLAppearanceDesc::use(FieldContainerPtr)
02884 {
02885 return false;
02886 }
02887
02888
02889
02890
02891 void VRMLAppearanceDesc::dump(const Char8 *)
02892 {
02893 }
02894
02895
02896
02897
02898
02899
02900
02906
02907
02908
02909 VRMLMaterialDesc::VRMLMaterialDesc(void) :
02910 Inherited(),
02911
02912 _defaultAmbientIntensity(),
02913 _defaultDiffuseColor (),
02914 _defaultEmissiveColor (),
02915 _defaultShininess (),
02916 _defaultSpecularColor (),
02917 _defaultTransparency (),
02918
02919 _ambientIntensity (),
02920 _diffuseColor (),
02921 _emissiveColor (),
02922 _shininess (),
02923 _specularColor (),
02924 _transparency (),
02925
02926 _pDefMat (NullFC),
02927 _pMat (NullFC)
02928 {
02929 }
02930
02931
02932
02933
02934 VRMLMaterialDesc::~VRMLMaterialDesc(void)
02935 {
02936 subRefCP(_pDefMat);
02937 }
02938
02939
02940
02941
02942 void VRMLMaterialDesc::init(const Char8 *OSG_VRML_ARG(szName))
02943 {
02944 #ifdef OSG_DEBUG_VRML
02945 indentLog(getIndent(), PINFO);
02946 PINFO << "MaterialDesc::init : " << szName << std::endl;
02947 #endif
02948 }
02949
02950 void VRMLMaterialDesc::reset(void)
02951 {
02952 _pMat = NullFC;
02953
02954 _ambientIntensity.setValue(_defaultAmbientIntensity);
02955 _diffuseColor .setValue(_defaultDiffuseColor);
02956 _emissiveColor .setValue(_defaultEmissiveColor);
02957 _shininess .setValue(_defaultShininess);
02958 _specularColor .setValue(_defaultSpecularColor);
02959 _transparency .setValue(_defaultTransparency);
02960 }
02961
02962 MaterialPtr VRMLMaterialDesc::getDefaultMaterial(void)
02963 {
02964 return _pDefMat;
02965 }
02966
02967
02968
02969
02970 bool VRMLMaterialDesc::prototypeAddField(const Char8 *,
02971 const UInt32 ,
02972 const Char8 *szFieldname)
02973 {
02974 bool bFound = false;
02975
02976 _pCurrField = NULL;
02977
02978 if(stringcasecmp("ambientIntensity", szFieldname) == 0)
02979 {
02980 _pCurrField = &_defaultAmbientIntensity;
02981
02982 bFound = true;
02983 }
02984 else if(stringcasecmp("diffuseColor", szFieldname) == 0)
02985 {
02986 _pCurrField = &_defaultDiffuseColor;
02987
02988 bFound = true;
02989 }
02990 else if(stringcasecmp("emissiveColor", szFieldname) == 0)
02991 {
02992 _pCurrField = &_defaultEmissiveColor;
02993
02994 bFound = true;
02995 }
02996 else if(stringcasecmp("shininess", szFieldname) == 0)
02997 {
02998 _pCurrField = &_defaultShininess;
02999
03000 bFound = true;
03001 }
03002 else if(stringcasecmp("specularColor", szFieldname) == 0)
03003 {
03004 _pCurrField = &_defaultSpecularColor;
03005
03006 bFound = true;
03007 }
03008 else if(stringcasecmp("transparency", szFieldname) == 0)
03009 {
03010 _pCurrField = &_defaultTransparency;
03011
03012 bFound = true;
03013 }
03014
03015 if(bFound == true)
03016 {
03017 #ifdef OSG_DEBUG_VRML
03018 indentLog(getIndent(), PINFO);
03019 PINFO << "MaterialDesc::prototypeAddField : add part "
03020 << szFieldname
03021 << std::endl;
03022 #endif
03023 return true;
03024 }
03025 else
03026 {
03027 return false;
03028 }
03029 }
03030
03031 void VRMLMaterialDesc::endProtoInterface(void)
03032 {
03033 Color4f cCol;
03034 MaterialChunkPtr pMatChunk;
03035
03036 cCol.setValuesRGBA(_defaultDiffuseColor .getValue().red() *
03037 _defaultAmbientIntensity.getValue(),
03038 _defaultDiffuseColor .getValue().green() *
03039 _defaultAmbientIntensity.getValue(),
03040 _defaultDiffuseColor .getValue().blue() *
03041 _defaultAmbientIntensity.getValue(),
03042 1.f - _defaultTransparency .getValue());
03043
03044 _pDefMat = ChunkMaterial::create();
03045 addRefCP(_pDefMat);
03046
03047 pMatChunk = MaterialChunk::create();
03048
03049 pMatChunk->setAmbient(cCol);
03050
03051 cCol.setValuesRGBA (_defaultDiffuseColor.getValue()[0],
03052 _defaultDiffuseColor.getValue()[1],
03053 _defaultDiffuseColor.getValue()[2],
03054 1.f - _defaultTransparency.getValue());
03055
03056 pMatChunk->setDiffuse(cCol);
03057
03058 cCol.setValuesRGBA (_defaultSpecularColor.getValue()[0],
03059 _defaultSpecularColor.getValue()[1],
03060 _defaultSpecularColor.getValue()[2],
03061 1.f - _defaultTransparency.getValue());
03062 pMatChunk->setSpecular(cCol);
03063
03064 pMatChunk->setShininess(_defaultShininess.getValue() * 128.f);
03065
03066 cCol.setValuesRGBA (_defaultEmissiveColor.getValue()[0],
03067 _defaultEmissiveColor.getValue()[1],
03068 _defaultEmissiveColor.getValue()[2],
03069 1.f - _defaultTransparency.getValue());
03070 pMatChunk->setEmission(cCol);
03071
03072 _pDefMat->addChunk(pMatChunk);
03073 }
03074
03075 void VRMLMaterialDesc::getFieldAndDesc(
03076 FieldContainerPtr ,
03077 const Char8 * szFieldname,
03078 Field *&pField,
03079 const FieldDescription *&pDesc)
03080 {
03081 if(stringcasecmp("ambientIntensity", szFieldname) == 0)
03082 {
03083 pField = &_ambientIntensity;
03084 }
03085 else if(stringcasecmp("diffuseColor", szFieldname) == 0)
03086 {
03087 pField = &_diffuseColor;
03088 }
03089 else if(stringcasecmp("emissiveColor", szFieldname) == 0)
03090 {
03091 pField = &_emissiveColor;
03092 }
03093 else if(stringcasecmp("shininess", szFieldname) == 0)
03094 {
03095 pField = &_shininess;
03096 }
03097 else if(stringcasecmp("specularColor", szFieldname) == 0)
03098 {
03099 pField = &_specularColor;
03100 }
03101 else if(stringcasecmp("transparency", szFieldname) == 0)
03102 {
03103 pField = &_transparency;
03104 }
03105
03106 pDesc = NULL;
03107 }
03108
03109
03110
03111
03112 FieldContainerPtr VRMLMaterialDesc::beginNode(
03113 const Char8 *,
03114 const Char8 *,
03115 FieldContainerPtr )
03116 {
03117 reset();
03118
03119 _pMat = MaterialChunk::create();
03120
03121 return _pMat;
03122 }
03123
03124 void VRMLMaterialDesc::endNode(FieldContainerPtr)
03125 {
03126 if(_pMat != NullFC)
03127 {
03128 Color4f cCol;
03129
03130 cCol.setValuesRGBA (_diffuseColor .getValue().red() *
03131 _ambientIntensity.getValue(),
03132 _diffuseColor .getValue().green() *
03133 _ambientIntensity.getValue(),
03134 _diffuseColor .getValue().blue() *
03135 _ambientIntensity.getValue(),
03136 1.f - _transparency.getValue());
03137
03138 beginEditCP(_pMat);
03139
03140 _pMat->setAmbient (cCol);
03141
03142 cCol.setValuesRGBA (_diffuseColor.getValue()[0],
03143 _diffuseColor.getValue()[1],
03144 _diffuseColor.getValue()[2],
03145 1.f - _transparency.getValue());
03146 _pMat->setDiffuse (cCol);
03147
03148 cCol.setValuesRGBA (_specularColor.getValue()[0],
03149 _specularColor.getValue()[1],
03150 _specularColor.getValue()[2],
03151 1.f - _transparency.getValue());
03152 _pMat->setSpecular (cCol);
03153
03154 _pMat->setShininess(_shininess.getValue() * 128.f );
03155
03156 cCol.setValuesRGBA (_emissiveColor.getValue()[0],
03157 _emissiveColor.getValue()[1],
03158 _emissiveColor.getValue()[2],
03159 1.f - _transparency.getValue());
03160 _pMat->setEmission (cCol);
03161
03162 endEditCP(_pMat);
03163 }
03164 }
03165
03166
03167
03168
03169 void VRMLMaterialDesc::dump(const Char8 *)
03170 {
03171 }
03172
03173
03174
03175
03176
03182
03183
03184
03185 VRMLTextureTransformDesc::VRMLTextureTransformDesc(void) :
03186 Inherited(),
03187 _defaultCenter(),
03188 _defaultRotation(),
03189 _defaultScale(),
03190 _defaultTranslation(),
03191
03192 _center(),
03193 _rotation(),
03194 _scale(),
03195 _translation()
03196 {
03197 }
03198
03199
03200
03201
03202 VRMLTextureTransformDesc::~VRMLTextureTransformDesc(void)
03203 {
03204 }
03205
03206
03207
03208
03209 void VRMLTextureTransformDesc::init(const Char8 *OSG_VRML_ARG(szName))
03210 {
03211 #ifdef OSG_DEBUG_VRML
03212 indentLog(getIndent(), PINFO);
03213 PINFO << "TextureTransformDesc::init : " << szName << std::endl;
03214 #endif
03215 }
03216
03217 void VRMLTextureTransformDesc::reset(void)
03218 {
03219 }
03220
03221
03222
03223
03224 bool VRMLTextureTransformDesc::prototypeAddField(const Char8 *,
03225 const UInt32 ,
03226 const Char8 *szFieldname)
03227 {
03228 bool bFound =false;
03229
03230 _pCurrField = NULL;
03231
03232 if(stringcasecmp("center", szFieldname) == 0)
03233 {
03234 _pCurrField = &_defaultCenter;
03235
03236 bFound = true;
03237 }
03238 else if(stringcasecmp("rotation", szFieldname) == 0)
03239 {
03240 _pCurrField = &_defaultRotation;
03241
03242 bFound = true;
03243 }
03244 else if(stringcasecmp("scale", szFieldname) == 0)
03245 {
03246 _pCurrField = &_defaultScale;
03247
03248 bFound = true;
03249 }
03250 else if(stringcasecmp("translation", szFieldname) == 0)
03251 {
03252 _pCurrField = &_defaultTranslation;
03253
03254 bFound = true;
03255 }
03256
03257 if(bFound == true)
03258 {
03259 #ifdef OSG_DEBUG_VRML
03260 indentLog(getIndent(), PINFO);
03261 PINFO << "TextureTransformDesc::prototypeAddField : add part "
03262 << szFieldname
03263 << std::endl;
03264 #endif
03265
03266 return true;
03267 }
03268 else
03269 {
03270 return false;
03271 }
03272 }
03273
03274 void VRMLTextureTransformDesc::endProtoInterface(void)
03275 {
03276 }
03277
03278 void VRMLTextureTransformDesc::getFieldAndDesc(
03279 FieldContainerPtr ,
03280 const Char8 * szFieldname,
03281 Field *&pField,
03282 const FieldDescription *&pDesc)
03283 {
03284 if(stringcasecmp("center", szFieldname) == 0)
03285 {
03286 pField = &_center;
03287 }
03288 else if(stringcasecmp("rotation", szFieldname) == 0)
03289 {
03290 pField = &_rotation;
03291 }
03292 else if(stringcasecmp("scale", szFieldname) == 0)
03293 {
03294 pField = &_scale;
03295 }
03296 else if(stringcasecmp("translation", szFieldname) == 0)
03297 {
03298 pField = &_translation;
03299 }
03300
03301 pDesc = NULL;
03302 }
03303
03304
03305
03306
03307 FieldContainerPtr VRMLTextureTransformDesc::beginNode(
03308 const Char8 *,
03309 const Char8 *,
03310 FieldContainerPtr )
03311 {
03312 TextureTransformChunkPtr returnValue = TextureTransformChunk::create();
03313
03314 #ifdef OSG_DEBUG_VRML
03315 indentLog(getIndent(), PINFO);
03316 PINFO << "Begin TextureTransform " << &(*returnValue) << std::endl;
03317
03318 incIndent();
03319 #endif
03320
03321 _center = _defaultCenter;
03322 _rotation = _defaultRotation;
03323 _scale = _defaultScale;
03324 _translation = _defaultTranslation;
03325
03326 return returnValue;
03327 }
03328
03329 void VRMLTextureTransformDesc::endNode(FieldContainerPtr pFC)
03330 {
03331 TextureTransformChunkPtr pTexTrans = NullFC;
03332
03333 pTexTrans = TextureTransformChunkPtr::dcast(pFC);
03334
03335 if(pTexTrans != NullFC)
03336 {
03337 Matrix m;
03338
03339 Vec3f center(_center.getValue()[0],
03340 _center.getValue()[1], 0.0f);
03341
03342 Quaternion rotation;
03343 rotation.setValueAsAxisRad(0.0f, 0.0f, 1.0f, _rotation.getValue());
03344
03345 Vec3f scale(_scale.getValue()[0],
03346 _scale.getValue()[1], 1.0f);
03347
03348 Vec3f translation(_translation.getValue()[0],
03349 _translation.getValue()[1], 0.0f);
03350
03351 m.setTransform(translation,
03352 rotation,
03353 scale,
03354 Quaternion::identity(),
03355 center);
03356
03357 beginEditCP(pTexTrans);
03358 {
03359 pTexTrans->setMatrix(m);
03360 }
03361 endEditCP (pTexTrans);
03362 }
03363 else
03364 {
03365 PWARNING << "VRMLTextureTransformDesc::endNode : Invalid texture transform ptr"
03366 << std::endl;
03367 }
03368
03369 #ifdef OSG_DEBUG_VRML
03370 decIndent();
03371
03372 indentLog(getIndent(), PINFO);
03373 PINFO << "End TextureTransform "
03374 << _center.getValue() << " "
03375 << _rotation.getValue() << " "
03376 << _scale.getValue() << " "
03377 << _translation.getValue() << " "
03378 << &(*pFC) << std::endl;
03379 #endif
03380 }
03381
03382
03383
03384
03385 void VRMLTextureTransformDesc::dump(const Char8 *)
03386 {
03387 }
03388
03389
03390
03391
03392
03393
03399
03400
03401
03402 VRMLImageTextureDesc::VRMLImageTextureDesc(void) :
03403 Inherited(),
03404
03405 _defaultURL (),
03406 _defaultRepeatS(),
03407 _defaultRepeatT(),
03408
03409 _url (),
03410 _repeatS (),
03411 _repeatT ()
03412 {
03413 }
03414
03415
03416
03417
03418 VRMLImageTextureDesc::~VRMLImageTextureDesc(void)
03419 {
03420 }
03421
03422
03423
03424
03425 void VRMLImageTextureDesc::init(const Char8 *OSG_VRML_ARG(szName))
03426 {
03427 #ifdef OSG_DEBUG_VRML
03428 indentLog(getIndent(), PINFO);
03429 PINFO << "ImageTextureDesc::init : " << szName << std::endl;
03430 #endif
03431 }
03432
03433 void VRMLImageTextureDesc::reset(void)
03434 {
03435 }
03436
03437
03438
03439
03440 bool VRMLImageTextureDesc::prototypeAddField(const Char8 *,
03441 const UInt32 ,
03442 const Char8 *szFieldname)
03443 {
03444 bool bFound = false;
03445
03446 _pCurrField = NULL;
03447
03448 if(stringcasecmp("url", szFieldname) == 0)
03449 {
03450 _pCurrField = &_defaultURL;
03451
03452 bFound = true;
03453 }
03454 else if(stringcasecmp("repeatS", szFieldname) == 0)
03455 {
03456 _pCurrField = &_defaultRepeatS;
03457
03458 bFound = true;
03459 }
03460 else if(stringcasecmp("repeatT", szFieldname) == 0)
03461 {
03462 _pCurrField = &_defaultRepeatT;
03463
03464 bFound = true;
03465 }
03466
03467 if(bFound == true)
03468 {
03469 #ifdef OSG_DEBUG_VRML
03470 indentLog(getIndent(), PINFO);
03471 PINFO << "ImageTextureDesc::prototypeAddField : add part "
03472 << szFieldname
03473 << std::endl;
03474 #endif
03475
03476 return true;
03477 }
03478 else
03479 {
03480 return false;
03481 }
03482 }
03483
03484 void VRMLImageTextureDesc::endProtoInterface(void)
03485 {
03486 }
03487
03488 void VRMLImageTextureDesc::getFieldAndDesc(
03489 FieldContainerPtr ,
03490 const Char8 * szFieldname,
03491 Field *&pField,
03492 const FieldDescription *&pDesc)
03493 {
03494 if(stringcasecmp("url", szFieldname) == 0)
03495 {
03496 pField = &_url;
03497 }
03498 else if(stringcasecmp("repeatS", szFieldname) == 0)
03499 {
03500 pField = &_repeatS;
03501 }
03502 else if(stringcasecmp("repeatT", szFieldname) == 0)
03503 {
03504 pField = &_repeatT;
03505 }
03506
03507 pDesc = NULL;
03508 }
03509
03510
03511
03512
03513 FieldContainerPtr VRMLImageTextureDesc::beginNode(
03514 const Char8 *,
03515 const Char8 *,
03516 FieldContainerPtr )
03517 {
03518 TextureChunkPtr returnValue = TextureChunk::create();
03519
03520 #ifdef OSG_DEBUG_VRML
03521 indentLog(getIndent(), PINFO);
03522 PINFO << "Begin ImageTexture " << &(*returnValue) << std::endl;
03523
03524 incIndent();
03525 #endif
03526
03527 _url.clear();
03528
03529 _repeatS = _defaultRepeatS;
03530 _repeatT = _defaultRepeatT;
03531
03532 return returnValue;
03533 }
03534
03535 void VRMLImageTextureDesc::endNode(FieldContainerPtr pFC)
03536 {
03537 TextureChunkPtr pTexture = NullFC;
03538
03539 pTexture = TextureChunkPtr::dcast(pFC);
03540
03541
03542 if(pTexture != NullFC)
03543 {
03544 #ifdef OSG_DEBUG_VRML
03545 PNOTICE << "VRMLImageTextureDesc::endNode : Reading texture "
03546 << _url[0].c_str() << std::endl;
03547 #endif
03548
03549 ImagePtr pImage = ImageFileHandler::the().read(_url[0].c_str());
03550
03551 if(pImage != NullFC)
03552 {
03553 beginEditCP(pImage, Image::ForceAlphaBinaryFieldMask);
03554 pImage->setForceAlphaBinary(pImage->calcIsAlphaBinary());
03555 endEditCP(pImage, Image::ForceAlphaBinaryFieldMask);
03556
03557 beginEditCP(pTexture);
03558 pTexture->setImage(pImage);
03559
03560 if(_repeatS.getValue() == true)
03561 {
03562 pTexture->setWrapS(GL_REPEAT);
03563 }
03564 else
03565 {
03566 pTexture->setWrapS(GL_CLAMP);
03567 }
03568 if(_repeatT.getValue() == true)
03569 {
03570 pTexture->setWrapT(GL_REPEAT);
03571 }
03572 else
03573 {
03574 pTexture->setWrapT(GL_CLAMP);
03575 }
03576 pTexture->setEnvMode(GL_MODULATE);
03577 endEditCP(pTexture);
03578 }
03579 else
03580 {
03581 PWARNING << "VRMLImageTextureDesc::endNode : "
03582 << "Couldn't read texture "
03583 << _url[0].c_str()
03584 << " !!!"
03585 << std::endl;
03586 }
03587 }
03588 else
03589 {
03590 PWARNING << "VRMLImageTextureDesc::endNode : Invalid texture ptr"
03591 << std::endl;
03592 }
03593
03594 #ifdef OSG_DEBUG_VRML
03595 decIndent();
03596
03597 indentLog(getIndent(), PINFO);
03598 PINFO << "End ImageTexture "
03599 << _url[0].c_str() << " "
03600 << _repeatS.getValue() << " "
03601 << _repeatT.getValue() << " "
03602 << &(*pFC) << std::endl;
03603 #endif
03604 }
03605
03606
03607
03608
03609 void VRMLImageTextureDesc::dump(const Char8 *)
03610 {
03611 }
03612
03613
03614
03615
03616
03617
03618
03624
03625
03626
03627 VRMLPixelTextureDesc::VRMLPixelTextureDesc(void) :
03628 Inherited(),
03629
03630 _defaultImage (),
03631 _defaultRepeatS(),
03632 _defaultRepeatT(),
03633
03634 _image (),
03635 _repeatS (),
03636 _repeatT ()
03637 {
03638 }
03639
03640
03641
03642
03643 VRMLPixelTextureDesc::~VRMLPixelTextureDesc(void)
03644 {
03645 }
03646
03647
03648
03649
03650 void VRMLPixelTextureDesc::init(const Char8 *OSG_VRML_ARG(szName))
03651 {
03652 #ifdef OSG_DEBUG_VRML
03653 indentLog(getIndent(), PINFO);
03654 PINFO << "PixelTextureDesc::init : " << szName << std::endl;
03655 #endif
03656 }
03657
03658 void VRMLPixelTextureDesc::reset(void)
03659 {
03660 }
03661
03662
03663
03664
03665 bool VRMLPixelTextureDesc::prototypeAddField(const Char8 *,
03666 const UInt32 ,
03667 const Char8 *szFieldname)
03668 {
03669 bool bFound = false;
03670
03671 _pCurrField = NULL;
03672
03673 if(stringcasecmp("image", szFieldname) == 0)
03674 {
03675 _pCurrField = &_defaultImage;
03676
03677 bFound = true;
03678 }
03679 else if(stringcasecmp("repeatS", szFieldname) == 0)
03680 {
03681 _pCurrField = &_defaultRepeatS;
03682
03683 bFound = true;
03684 }
03685 else if(stringcasecmp("repeatT", szFieldname) == 0)
03686 {
03687 _pCurrField = &_defaultRepeatT;
03688
03689 bFound = true;
03690 }
03691
03692 if(bFound == true)
03693 {
03694 #ifdef OSG_DEBUG_VRML
03695 indentLog(getIndent(), PINFO);
03696 PINFO << "PixelTextureDesc::prototypeAddField : add part "
03697 << szFieldname
03698 << std::endl;
03699 #endif
03700
03701 return true;
03702 }
03703 else
03704 {
03705 return false;
03706 }
03707 }
03708
03709 void VRMLPixelTextureDesc::endProtoInterface(void)
03710 {
03711 }
03712
03713 void VRMLPixelTextureDesc::getFieldAndDesc(
03714 FieldContainerPtr ,
03715 const Char8 * szFieldname,
03716 Field *&pField,
03717 const FieldDescription *&pDesc)
03718 {
03719 if(stringcasecmp("image", szFieldname) == 0)
03720 {
03721 pField = &_image;
03722 }
03723 else if(stringcasecmp("repeatS", szFieldname) == 0)
03724 {
03725 pField = &_repeatS;
03726 }
03727 else if(stringcasecmp("repeatT", szFieldname) == 0)
03728 {
03729 pField = &_repeatT;
03730 }
03731
03732 pDesc = NULL;
03733 }
03734
03735
03736
03737
03738 FieldContainerPtr VRMLPixelTextureDesc::beginNode(
03739 const Char8 *,
03740 const Char8 *,
03741 FieldContainerPtr )
03742 {
03743 TextureChunkPtr returnValue = TextureChunk::create();
03744
03745 ImagePtr iPtr=Image::create();
03746 _image.setValue(iPtr);
03747
03748 _repeatS = _defaultRepeatS;
03749 _repeatT = _defaultRepeatT;
03750
03751 #ifdef OSG_DEBUG_VRML
03752 indentLog(getIndent(), PINFO);
03753 PINFO << "Begin PixelTexture " << &(*returnValue) << std::endl;
03754
03755 incIndent();
03756 #endif
03757
03758 return returnValue;
03759 }
03760
03761 void VRMLPixelTextureDesc::endNode(FieldContainerPtr pFC)
03762 {
03763 TextureChunkPtr pTexture = NullFC;
03764
03765 pTexture = TextureChunkPtr::dcast(pFC);
03766
03767 if(pTexture != NullFC)
03768 {
03769 if(_image.getValue() != NullFC)
03770 {
03771 pTexture->setImage(_image.getValue());
03772
03773 if(_repeatS.getValue() == true)
03774 {
03775 pTexture->setWrapS(GL_REPEAT);
03776 }
03777 else
03778 {
03779 pTexture->setWrapS(GL_CLAMP);
03780 }
03781
03782 if(_repeatT.getValue() == true)
03783 {
03784 pTexture->setWrapT(GL_REPEAT);
03785 }
03786 else
03787 {
03788 pTexture->setWrapT(GL_CLAMP);
03789 }
03790 }
03791 }
03792 else
03793 {
03794 PWARNING << "VRMLPixelTextureDesc::endNode : Invalid texture ptr"
03795 << std::endl;
03796 }
03797
03798 #ifdef OSG_DEBUG_VRML
03799 decIndent();
03800
03801 indentLog(getIndent(), PINFO);
03802 PINFO << "End PixelTexture "
03803 << _repeatS.getValue() << " "
03804 << _repeatT.getValue() << " "
03805 << &(*pFC) << std::endl;
03806 #endif
03807 }
03808
03809
03810
03811
03812 void VRMLPixelTextureDesc::addFieldValue( Field *pField,
03813 const Char8 *szFieldVal)
03814 {
03815 if(pField != NULL)
03816 {
03817 if( (pField == &_image) && (_image.getValue() != NullFC) )
03818 {
03819 _image.getValue()->addValue(szFieldVal);
03820 }
03821 else
03822 {
03823 pField->pushValueByStr(szFieldVal);
03824 }
03825 }
03826 }
03827
03828
03829
03830
03831 void VRMLPixelTextureDesc::dump(const Char8 *)
03832 {
03833 }
03834
03835
03836
03837
03838
03839
03840
03841
03847
03848
03849
03850 VRMLLODDesc::VRMLLODDesc(void) :
03851 Inherited()
03852 {
03853 }
03854
03855
03856
03857
03858 VRMLLODDesc::~VRMLLODDesc(void)
03859 {
03860 }
03861
03862
03863
03864
03865 void VRMLLODDesc::init(const Char8 *OSG_VRML_ARG(szName))
03866 {
03867 #ifdef OSG_DEBUG_VRML
03868 indentLog(getIndent(), PINFO);
03869 PINFO << "LODDesc::init : " << szName << std::endl;
03870 #endif
03871
03872 _pNodeProto = Node::create();
03873 _pNodeCoreProto = DistanceLOD::create();
03874
03875 _pGenAtt = GenericAtt::create();
03876 _pGenAtt->setInternal(true);
03877 }
03878
03879
03880
03881
03882 bool VRMLLODDesc::prototypeAddField(const Char8 *szFieldType,
03883 const UInt32 uiFieldTypeId,
03884 const Char8 *szFieldname)
03885 {
03886 bool bFound = false;
03887
03888 _pCurrField = NULL;
03889
03890 if(stringcasecmp("level", szFieldname) == 0)
03891 {
03892 bFound = true;
03893 }
03894 else if(stringcasecmp("center", szFieldname) == 0)
03895 {
03896 bFound = true;
03897 }
03898 else if(stringcasecmp("range", szFieldname) == 0)
03899 {
03900 bFound = true;
03901 }
03902
03903 if(bFound == true)
03904 {
03905 return true;
03906 }
03907 else
03908 {
03909 return Inherited::prototypeAddField(szFieldType,
03910 uiFieldTypeId,
03911 szFieldname);
03912 }
03913 }
03914
03915 void VRMLLODDesc::endProtoInterface(void)
03916 {
03917 }
03918
03919 void VRMLLODDesc::getFieldAndDesc(
03920 FieldContainerPtr pFC,
03921 const Char8 * szFieldname,
03922 Field *&pField,
03923 const FieldDescription *&pDesc)
03924 {
03925 if(szFieldname == NULL)
03926 return;
03927
03928 if(pFC == NullFC)
03929 return;
03930
03931 NodePtr pNode = NodePtr::dcast(pFC);
03932
03933 #ifdef OSG_DEBUG_VRML
03934 indentLog(getIndent(), PINFO);
03935 PINFO << "VRMLLODDesc::getFieldAndDesc : looking for "
03936 << szFieldname
03937 << std::endl;
03938 #endif
03939
03940 if(pNode == NullFC)
03941 {
03942 PWARNING << "VRMLLODDesc::getFieldAndDesc : No Node" << std::endl;
03943 return;
03944 }
03945
03946 NodeCorePtr pNodeCore = pNode->getCore();
03947
03948 DistanceLODPtr pLOD = DistanceLODPtr::dcast(pNodeCore);
03949
03950 if(pLOD == NullFC)
03951 {
03952 PWARNING << "VRMLLODDesc::getFieldAndDesc : No LOD" << std::endl;
03953 return;
03954 }
03955
03956 incIndent();
03957
03958 if(stringcasecmp("level", szFieldname) == 0)
03959 {
03960 #ifdef OSG_DEBUG_VRML
03961 indentLog(getIndent(), PINFO);
03962 PINFO << "VRMLLODDesc::getFieldAndDesc : : request internal "
03963 << szFieldname
03964 << std::endl;
03965 #endif
03966
03967 pField = pNode->getField("children");
03968
03969 if(pField != NULL)
03970 pDesc = pNode->getType().findFieldDescription("children");
03971 }
03972 else if(stringcasecmp("center", szFieldname) == 0)
03973 {
03974 #ifdef OSG_DEBUG_VRML
03975 indentLog(getIndent(), PINFO);
03976 PINFO << "VRMLLODDesc::getFieldAndDesc : : request internal "
03977 << szFieldname
03978 << std::endl;
03979 #endif
03980
03981 pField = pLOD->getField("center");
03982
03983 if(pField != NULL)
03984 pDesc = pLOD->getType().findFieldDescription("children");
03985 }
03986 else if(stringcasecmp("range", szFieldname) == 0)
03987 {
03988 #ifdef OSG_DEBUG_VRML
03989 indentLog(getIndent(), PINFO);
03990 PINFO << "VRMLLODDesc::getFieldAndDesc : : request internal "
03991 << szFieldname
03992 << std::endl;
03993 #endif
03994
03995 pField = pLOD->getField("range");
03996
03997 if(pField != NULL)
03998 pDesc = pLOD->getType().findFieldDescription("range");
03999 }
04000 else
04001 {
04002 VRMLNodeDesc::getFieldAndDesc(pLOD,
04003 szFieldname,
04004 pField,
04005 pDesc);
04006 }
04007
04008 #ifdef OSG_DEBUG_VRML
04009 decIndent();
04010 #endif
04011 }
04012
04013
04014
04015
04016 FieldContainerPtr VRMLLODDesc::beginNode(
04017 const Char8 *,
04018 const Char8 *,
04019 FieldContainerPtr )
04020 {
04021 FieldContainerPtr pFC = NullFC;
04022 NodePtr pNode = NullFC;
04023 NodeCorePtr pNodeCore = NullFC;
04024 GenericAttPtr pAtt = NullFC;
04025
04026 if(_pNodeProto != NullFC)
04027 {
04028 FieldContainerPtr pAttClone = _pGenAtt->emptyCopy();
04029
04030 pAtt = GenericAttPtr::dcast(pAttClone);
04031
04032 if(pAtt != NullFC)
04033 {
04034 pAtt->setInternal(true);
04035 }
04036
04037 pFC = _pNodeProto->shallowCopy();
04038
04039 pNode = NodePtr::dcast(pFC);
04040
04041 pFC = _pNodeCoreProto->shallowCopy();
04042
04043 pNodeCore = NodeCorePtr::dcast(pFC);
04044
04045 beginEditCP(pNode);
04046 {
04047 pNode ->setCore (pNodeCore);
04048 pNodeCore->addAttachment(pAtt);
04049 }
04050 endEditCP (pNode, Node::CoreFieldMask);
04051 }
04052
04053 #ifdef OSG_DEBUG_VRML
04054 indentLog(getIndent(), PINFO);
04055 PINFO << "Begin LOD " << &(*pNode) << std::endl;
04056
04057 incIndent();
04058 #endif
04059
04060 return pNode;
04061 }
04062
04063 void VRMLLODDesc::endNode(FieldContainerPtr OSG_VRML_ARG(pFC))
04064 {
04065 #ifdef OSG_DEBUG_VRML
04066 decIndent();
04067
04068 indentLog(getIndent(), PINFO);
04069 PINFO << "End LOD "
04070 << &(*pFC) << std::endl;
04071 #endif
04072 }
04073
04074
04075
04076
04077 void VRMLLODDesc::dump(const Char8 *)
04078 {
04079 }
04080
04081
04082
04083
04084
04085
04086
04092
04093
04094
04095 VRMLSwitchDesc::VRMLSwitchDesc(void) :
04096 Inherited()
04097 {
04098 }
04099
04100
04101
04102
04103 VRMLSwitchDesc::~VRMLSwitchDesc(void)
04104 {
04105 }
04106
04107
04108
04109
04110 void VRMLSwitchDesc::init(const Char8 *OSG_VRML_ARG(szName))
04111 {
04112 #ifdef OSG_DEBUG_VRML
04113 indentLog(getIndent(), PINFO);
04114 PINFO << "SwitchDesc::init : " << szName << std::endl;
04115 #endif
04116
04117 _pNodeProto = Node::create();
04118 _pNodeCoreProto = Switch::create();
04119
04120 _pGenAtt = GenericAtt::create();
04121 _pGenAtt->setInternal(true);
04122 }
04123
04124
04125
04126
04127 bool VRMLSwitchDesc::prototypeAddField(const Char8 *szFieldType,
04128 const UInt32 uiFieldTypeId,
04129 const Char8 *szFieldname)
04130 {
04131 bool bFound = false;
04132
04133 _pCurrField = NULL;
04134
04135 if(stringcasecmp("choice", szFieldname) == 0)
04136 {
04137 bFound = true;
04138 }
04139 else if(stringcasecmp("whichChoice", szFieldname) == 0)
04140 {
04141 bFound = true;
04142 }
04143
04144 if(bFound == true)
04145 {
04146 return true;
04147 }
04148 else
04149 {
04150 return Inherited::prototypeAddField(szFieldType,
04151 uiFieldTypeId,
04152 szFieldname);
04153 }
04154 }
04155
04156 void VRMLSwitchDesc::endProtoInterface(void)
04157 {
04158 }
04159
04160 void VRMLSwitchDesc::getFieldAndDesc(
04161 FieldContainerPtr pFC,
04162 const Char8 * szFieldname,
04163 Field *&pField,
04164 const FieldDescription *&pDesc)
04165 {
04166 if(szFieldname == NULL)
04167 return;
04168
04169 if(pFC == NullFC)
04170 return;
04171
04172 NodePtr pNode = NodePtr::dcast(pFC);
04173
04174 #ifdef OSG_DEBUG_VRML
04175 indentLog(getIndent(), PINFO);
04176 PINFO << "VRMLSwitchDesc::getFieldAndDesc : looking for "
04177 << szFieldname
04178 << std::endl;
04179 #endif
04180
04181 if(pNode == NullFC)
04182 {
04183 PWARNING << "VRMLSwitchDesc::getFieldAndDesc : No Node" << std::endl;
04184 return;
04185 }
04186
04187 NodeCorePtr pNodeCore = pNode->getCore();
04188
04189 SwitchPtr pSwitch = SwitchPtr::dcast(pNodeCore);
04190
04191 if(pSwitch == NullFC)
04192 {
04193 PWARNING << "VRMLSwitchDesc::getFieldAndDesc : No Switch" << std::endl;
04194 return;
04195 }
04196
04197 incIndent();
04198
04199 if(stringcasecmp("choice", szFieldname) == 0)
04200 {
04201 #ifdef OSG_DEBUG_VRML
04202 indentLog(getIndent(), PINFO);
04203 PINFO << "VRMLSwitchDesc::getFieldAndDesc : : request internal "
04204 << szFieldname
04205 << std::endl;
04206 #endif
04207
04208 pField = pNode->getField("children");
04209
04210 if(pField != NULL)
04211 pDesc = pNode->getType().findFieldDescription("children");
04212 }
04213 else if(stringcasecmp("whichChoice", szFieldname) == 0)
04214 {
04215 #ifdef OSG_DEBUG_VRML
04216 indentLog(getIndent(), PINFO);
04217 PINFO << "VRMLSwitchDesc::getFieldAndDesc : : request internal "
04218 << szFieldname
04219 << std::endl;
04220 #endif
04221
04222 pField = pSwitch->getField("choice");
04223
04224 if(pField != NULL)
04225 pDesc = pSwitch->getType().findFieldDescription("whichChoice");
04226 }
04227 else
04228 {
04229 VRMLNodeDesc::getFieldAndDesc(pSwitch,
04230 szFieldname,
04231 pField,
04232 pDesc);
04233 }
04234
04235 #ifdef OSG_DEBUG_VRML
04236 decIndent();
04237 #endif
04238 }
04239
04240
04241
04242
04243 FieldContainerPtr VRMLSwitchDesc::beginNode(
04244 const Char8 *,
04245 const Char8 *,
04246 FieldContainerPtr )
04247 {
04248 FieldContainerPtr pFC = NullFC;
04249 NodePtr pNode = NullFC;
04250 NodeCorePtr pNodeCore = NullFC;
04251 GenericAttPtr pAtt = NullFC;
04252
04253 if(_pNodeProto != NullFC)
04254 {
04255 FieldContainerPtr pAttClone = _pGenAtt->emptyCopy();
04256
04257 pAtt = GenericAttPtr::dcast(pAttClone);
04258
04259 if(pAtt != NullFC)
04260 {
04261 pAtt->setInternal(true);
04262 }
04263
04264 pFC = _pNodeProto->shallowCopy();
04265
04266 pNode = NodePtr::dcast(pFC);
04267
04268 pFC = _pNodeCoreProto->shallowCopy();
04269
04270 pNodeCore = NodeCorePtr::dcast(pFC);
04271
04272 beginEditCP(pNode);
04273 {
04274 pNode ->setCore (pNodeCore);
04275 pNodeCore->addAttachment(pAtt);
04276 }
04277 endEditCP (pNode);
04278 }
04279
04280 #ifdef OSG_DEBUG_VRML
04281 indentLog(getIndent(), PINFO);
04282 PINFO << "Begin Switch " << &(*pNode) << std::endl;
04283
04284 incIndent();
04285 #endif
04286
04287 return pNode;
04288 }
04289
04290 void VRMLSwitchDesc::endNode(FieldContainerPtr OSG_VRML_ARG(pFC))
04291 {
04292 #ifdef OSG_DEBUG_VRML
04293 decIndent();
04294
04295 indentLog(getIndent(), PINFO);
04296 PINFO << "End Switch "
04297 << &(*pFC) << std::endl;
04298 #endif
04299 }
04300
04301
04302
04303
04304 void VRMLSwitchDesc::dump(const Char8 *)
04305 {
04306 }
04307
04308
04309
04310
04311
04312
04313
04319
04320
04321
04322 VRMLGroupDesc::VRMLGroupDesc(void) :
04323 Inherited(),
04324
04325 _defaultBoxCenter(),
04326 _defaultBoxSize (),
04327
04328 _boxCenter (),
04329 _boxSize ()
04330 {
04331 }
04332
04333
04334
04335
04336 VRMLGroupDesc::~VRMLGroupDesc(void)
04337 {
04338 }
04339
04340
04341
04342
04343 void VRMLGroupDesc::init(const Char8 *OSG_VRML_ARG(szName))
04344 {
04345 #ifdef OSG_DEBUG_VRML
04346 indentLog(getIndent(), PINFO);
04347 PINFO << "GroupDesc::init : " << szName << std::endl;
04348 #endif
04349
04350 _pNodeProto = Node::create();
04351 _pNodeCoreProto = Group::create();
04352
04353 _pGenAtt = GenericAtt::create();
04354 _pGenAtt->setInternal(true);
04355 }
04356
04357
04358
04359
04360 bool VRMLGroupDesc::prototypeAddField(const Char8 *szFieldType,
04361 const UInt32 uiFieldTypeId,
04362 const Char8 *szFieldname)
04363 {
04364 bool bFound = false;
04365
04366 _pCurrField = NULL;
04367
04368 if(stringcasecmp("bboxCenter", szFieldname) == 0)
04369 {
04370 _pCurrField = &_defaultBoxCenter;
04371 bFound = true;
04372 }
04373 else if(stringcasecmp("bboxSize", szFieldname) == 0)
04374 {
04375 _pCurrField = &_defaultBoxSize;
04376 bFound = true;
04377 }
04378 else if(stringcasecmp("children", szFieldname) == 0)
04379 {
04380 bFound = true;
04381 }
04382
04383 if(bFound == true)
04384 {
04385 return true;
04386 }
04387 else
04388 {
04389 return Inherited::prototypeAddField(szFieldType,
04390 uiFieldTypeId,
04391 szFieldname);
04392 }
04393 }
04394
04395 void VRMLGroupDesc::endProtoInterface(void)
04396 {
04397 }
04398
04399 void VRMLGroupDesc::getFieldAndDesc(
04400 FieldContainerPtr pFC,
04401 const Char8 * szFieldname,
04402 Field *&pField,
04403 const FieldDescription *&pDesc)
04404 {
04405 if(szFieldname == NULL)
04406 return;
04407
04408 if(pFC == NullFC)
04409 return;
04410
04411 NodePtr pNode = NodePtr::dcast(pFC);
04412
04413 #ifdef OSG_DEBUG_VRML
04414 indentLog(getIndent(), PINFO);
04415 PINFO << "VRMLGroupDesc::getFieldAndDesc : looking for "
04416 << szFieldname
04417 << std::endl;
04418 #endif
04419
04420 if(pNode == NullFC)
04421 {
04422 PWARNING << "VRMLGroupDesc::getFieldAndDesc : No Node" << std::endl;
04423 return;
04424 }
04425
04426 NodeCorePtr pNodeCore = pNode->getCore();
04427
04428 GroupPtr pGroup = GroupPtr::dcast(pNodeCore);
04429
04430 if(pGroup == NullFC)
04431 {
04432 PWARNING << "VRMLGroupDesc::getFieldAndDesc : No Group" << std::endl;
04433 return;
04434 }
04435
04436 incIndent();
04437
04438 if(stringcasecmp("bboxCenter", szFieldname) == 0)
04439 {
04440 #ifdef OSG_DEBUG_VRML
04441 indentLog(getIndent(), PINFO);
04442 PINFO << "VRMLGroupDesc::getFieldAndDesc : : request internal "
04443 << szFieldname
04444 << std::endl;
04445 #endif
04446
04447 pField = &_boxCenter;
04448 pDesc = NULL;
04449 }
04450 else if(stringcasecmp("bboxSize", szFieldname) == 0)
04451 {
04452 #ifdef OSG_DEBUG_VRML
04453 indentLog(getIndent(), PINFO);
04454 PINFO << "VRMLGroupDesc::getFieldAndDesc : : request internal "
04455 << szFieldname
04456 << std::endl;
04457 #endif
04458
04459 pField = &_boxSize;
04460 pDesc = NULL;
04461 }
04462 else if(stringcasecmp("children", szFieldname) == 0)
04463 {
04464 #ifdef OSG_DEBUG_VRML
04465 indentLog(getIndent(), PINFO);
04466 PINFO << "VRMLGroupDesc::getFieldAndDesc : : request internal "
04467 << szFieldname
04468 << std::endl;
04469 #endif
04470
04471 pField = pNode->getField("children");
04472
04473 if(pField != NULL)
04474 pDesc = pNode->getType().findFieldDescription("children");
04475 }
04476 else
04477 {
04478 VRMLNodeDesc::getFieldAndDesc(pGroup,
04479 szFieldname,
04480 pField,
04481 pDesc);
04482 }
04483
04484 #ifdef OSG_DEBUG_VRML
04485 decIndent();
04486 #endif
04487 }
04488
04489
04490
04491
04492 FieldContainerPtr VRMLGroupDesc::beginNode(
04493 const Char8 *,
04494 const Char8 *,
04495 FieldContainerPtr )
04496 {
04497 FieldContainerPtr pFC = NullFC;
04498 NodePtr pNode = NullFC;
04499 NodeCorePtr pNodeCore = NullFC;
04500 GenericAttPtr pAtt = NullFC;
04501
04502 if(_pNodeProto != NullFC)
04503 {
04504 FieldContainerPtr pAttClone = _pGenAtt->emptyCopy();
04505
04506 pAtt = GenericAttPtr::dcast(pAttClone);
04507
04508 if(pAtt != NullFC)
04509 {
04510 pAtt->setInternal(true);
04511 }
04512
04513 pFC = _pNodeProto->shallowCopy();
04514
04515 pNode = NodePtr::dcast(pFC);
04516
04517 pFC = _pNodeCoreProto->shallowCopy();
04518
04519 pNodeCore = NodeCorePtr::dcast(pFC);
04520
04521 beginEditCP(pNode);
04522 {
04523 pNode ->setCore (pNodeCore);
04524 pNodeCore->addAttachment(pAtt);
04525 }
04526 endEditCP (pNode);
04527 }
04528
04529 #ifdef OSG_DEBUG_VRML
04530 indentLog(getIndent(), PINFO);
04531 PINFO << "Begin Group " << &(*pNode) << std::endl;
04532
04533 incIndent();
04534 #endif
04535
04536 return pNode;
04537 }
04538
04539 void VRMLGroupDesc::endNode(FieldContainerPtr OSG_VRML_ARG(pFC))
04540 {
04541 #ifdef OSG_DEBUG_VRML
04542 decIndent();
04543
04544 indentLog(getIndent(), PINFO);
04545 PINFO << "End Group "
04546 << &(*pFC) << std::endl;
04547 #endif
04548 }
04549
04550
04551
04552
04553 void VRMLGroupDesc::dump(const Char8 *)
04554 {
04555 }
04556
04557
04558
04559
04560
04561
04562
04568
04569
04570
04571 VRMLExtrusionDesc::VRMLExtrusionDesc(void) :
04572 Inherited()
04573 {
04574 }
04575
04576
04577
04578
04579 VRMLExtrusionDesc::~VRMLExtrusionDesc(void)
04580 {
04581 }
04582
04583
04584
04585
04586 void VRMLExtrusionDesc::init(const Char8 *OSG_VRML_ARG(szName))
04587 {
04588 #ifdef OSG_DEBUG_VRML
04589 indentLog(getIndent(), PINFO);
04590 PINFO << "ExtrusionDesc::init : " << szName << std::endl;
04591 #endif
04592
04593 _pNodeProto = Node::create();
04594
04595
04596 _pGenAtt = GenericAtt::create();
04597 _pGenAtt->setInternal(true);
04598 }
04599
04600
04601
04602
04603 bool VRMLExtrusionDesc::prototypeAddField(const Char8 *szFieldType,
04604 const UInt32 uiFieldTypeId,
04605 const Char8 *szFieldname)
04606 {
04607 _pCurrField = NULL;
04608
04609 return Inherited::prototypeAddField(szFieldType,
04610 uiFieldTypeId,
04611 szFieldname);
04612 }
04613
04614 void VRMLExtrusionDesc::endProtoInterface(void)
04615 {
04616 }
04617
04618 void VRMLExtrusionDesc::getFieldAndDesc(
04619 FieldContainerPtr pFC,
04620 const Char8 * szFieldname,
04621 Field *&pField,
04622 const FieldDescription *&pDesc)
04623 {
04624 #ifdef OSG_DEBUG_VRML
04625 indentLog(getIndent(), PINFO);
04626 PINFO << "VRMLExtrusionDesc::getFieldAndDesc : looking for "
04627 << szFieldname
04628 << std::endl;
04629 #endif
04630
04631 if(szFieldname == NULL)
04632 return;
04633
04634 if(pFC == NullFC)
04635 return;
04636
04637 incIndent();
04638
04639 Inherited::getFieldAndDesc(pFC,
04640 szFieldname,
04641 pField,
04642 pDesc);
04643
04644 #ifdef OSG_DEBUG_VRML
04645 decIndent();
04646 #endif
04647 }
04648
04649
04650
04651
04652 FieldContainerPtr VRMLExtrusionDesc::beginNode(
04653 const Char8 *,
04654 const Char8 *,
04655 FieldContainerPtr )
04656 {
04657 FieldContainerPtr returnValue = NullFC;
04658 NodePtr pNode = NullFC;
04659 GenericAttPtr pAtt = NullFC;
04660
04661 if(_pNodeProto != NullFC)
04662 {
04663 FieldContainerPtr pAttClone = _pGenAtt->clone();
04664
04665 pAtt = GenericAttPtr::dcast(pAttClone);
04666
04667 if(pAtt != NullFC)
04668 {
04669 pAtt->setInternal(true);
04670 }
04671
04672 returnValue = _pNodeProto->shallowCopy();
04673
04674 pNode = NodePtr::dcast(returnValue);
04675
04676 pNode->addAttachment(pAtt);
04677 }
04678
04679 return returnValue;
04680 }
04681
04682 void VRMLExtrusionDesc::endNode(FieldContainerPtr pFC)
04683 {
04684 Field *pField = NULL;
04685 const FieldDescription *pDesc = NULL;
04686 NodePtr pNode = NullFC;
04687
04688 FLOG (("Run VRMLExtrusionDesc::endNode()\n"));
04689
04690 if(pFC == NullFC)
04691 return;
04692
04693 pNode = NodePtr::dcast(pFC);
04694
04695 if(pNode == NullFC)
04696 return;
04697
04698 SFBool *pBeginCap = NULL;
04699 SFBool *pCcw = NULL;
04700 SFBool *pConvex = NULL;
04701 SFReal32 *pCreaseAngle = NULL;
04702 MFPnt2f *pCrossSection = NULL;
04703 SFBool *pEndCap = NULL;
04704 MFQuaternion *pOrientation = NULL;
04705 MFVec2f *pScale = NULL;
04706 SFBool *pSolid = NULL;
04707 MFPnt3f *pSpine = NULL;
04708
04709 Inherited::getFieldAndDesc(pFC,
04710 "beginCap",
04711 pField,
04712 pDesc);
04713
04714 if(pField != NULL)
04715 {
04716 pBeginCap = static_cast<SFBool *>(pField);
04717 }
04718
04719
04720 Inherited::getFieldAndDesc(pFC,
04721 "ccw",
04722 pField,
04723 pDesc);
04724
04725 if(pField != NULL)
04726 {
04727 pCcw = static_cast<SFBool *>(pField);
04728 }
04729
04730
04731 Inherited::getFieldAndDesc(pFC,
04732 "convex",
04733 pField,
04734 pDesc);
04735
04736 if(pField != NULL)
04737 {
04738 pConvex = static_cast<SFBool *>(pField);
04739 }
04740
04741
04742 Inherited::getFieldAndDesc(pFC,
04743 "creaseAngle",
04744 pField,
04745 pDesc);
04746
04747 if(pField != NULL)
04748 {
04749 pCreaseAngle = static_cast<SFReal32 *>(pField);
04750 }
04751
04752
04753 Inherited::getFieldAndDesc(pFC,
04754 "crossSection",
04755 pField,
04756 pDesc);
04757
04758 if(pField != NULL)
04759 {
04760 pCrossSection = static_cast<MFPnt2f *>(pField);
04761 }
04762
04763
04764 Inherited::getFieldAndDesc(pFC,
04765 "endCap",
04766 pField,
04767 pDesc);
04768
04769 if(pField != NULL)
04770 {
04771 pEndCap = static_cast<SFBool *>(pField);
04772 }
04773
04774
04775 Inherited::getFieldAndDesc(pFC,
04776 "orientation",
04777 pField,
04778 pDesc);
04779
04780 if(pField != NULL)
04781 {
04782 pOrientation = static_cast<MFQuaternion *>(pField);
04783 }
04784
04785
04786 Inherited::getFieldAndDesc(pFC,
04787 "scale",
04788 pField,
04789 pDesc);
04790
04791 if(pField != NULL)
04792 {
04793 pScale = static_cast<MFVec2f *>(pField);
04794 }
04795
04796
04797 Inherited::getFieldAndDesc(pFC,
04798 "solid",
04799 pField,
04800 pDesc);
04801
04802 if(pField != NULL)
04803 {
04804 pSolid = static_cast<SFBool *>(pField);
04805 }
04806
04807
04808 Inherited::getFieldAndDesc(pFC,
04809 "spine",
04810 pField,
04811 pDesc);
04812
04813 if(pField != NULL)
04814 {
04815 pSpine = static_cast<MFPnt3f *>(pField);
04816 }
04817
04818
04819
04820 if(pBeginCap != NULL &&
04821 pCcw != NULL &&
04822 pConvex != NULL &&
04823 pCreaseAngle != NULL &&
04824 pCrossSection != NULL &&
04825 pEndCap != NULL &&
04826 pOrientation != NULL &&
04827 pScale != NULL &&
04828 pSolid != NULL &&
04829 pSpine != NULL)
04830 {
04831 #ifdef OSG_DEBUG_VRML
04832 indentLog(getIndent(), PINFO);
04833 PINFO << "VRMLExtrusionDesc::endNode"
04834 << std::endl;
04835 #endif
04836
04837
04838
04839 GeometryPtr pGeo = makeExtrusionGeo ( pCrossSection->getValues(),
04840 pOrientation ->getValues(),
04841 pScale ->getValues(),
04842 pSpine ->getValues(),
04843 pCreaseAngle ->getValue (),
04844 pBeginCap ->getValue (),
04845 pEndCap ->getValue (),
04846 pCcw ->getValue (),
04847 pConvex ->getValue (),
04848 true,
04849 true,
04850 0
04851 );
04852
04853
04854
04855
04856
04857
04858
04859
04860
04861
04862
04863
04864
04865
04866
04867
04868
04869
04870
04871 beginEditCP(pNode, Node::CoreFieldMask);
04872 {
04873 pNode->setCore(pGeo);
04874 }
04875 endEditCP (pNode, Node::CoreFieldMask);
04876 }
04877 else
04878 {
04879 FWARNING(("\n\nExtrusion parameter missing\n"));
04880 }
04881 }
04882
04883
04884
04885
04886 void VRMLExtrusionDesc::dump(const Char8 *)
04887 {
04888 }
04889
04890
04891
04892
04893
04894
04895
04901
04902
04903
04904 VRMLInlineDesc::VRMLInlineDesc(void) :
04905 Inherited(),
04906
04907 _defaultBoxCenter(),
04908 _defaultBoxSize (),
04909
04910 _boxCenter (),
04911 _boxSize ()
04912 {
04913 }
04914
04915
04916
04917
04918 VRMLInlineDesc::~VRMLInlineDesc(void)
04919 {
04920 }
04921
04922
04923
04924
04925 void VRMLInlineDesc::init(const Char8 *OSG_VRML_ARG(szName))
04926 {
04927 #ifdef OSG_DEBUG_VRML
04928 indentLog(getIndent(), PINFO);
04929 PINFO << "InlineDesc::init : " << szName << std::endl;
04930 #endif
04931
04932 _pNodeProto = Node::create();
04933 _pNodeCoreProto = Inline::create();
04934
04935 _pGenAtt = GenericAtt::create();
04936 _pGenAtt->setInternal(true);
04937 }
04938
04939
04940
04941
04942 bool VRMLInlineDesc::prototypeAddField(const Char8 *szFieldType,
04943 const UInt32 uiFieldTypeId,
04944 const Char8 *szFieldname)
04945 {
04946 bool bFound = false;
04947
04948 _pCurrField = NULL;
04949
04950 if(stringcasecmp("bboxCenter", szFieldname) == 0)
04951 {
04952 _pCurrField = &_defaultBoxCenter;
04953 bFound = true;
04954 }
04955 else if(stringcasecmp("bboxSize", szFieldname) == 0)
04956 {
04957 _pCurrField = &_defaultBoxSize;
04958 bFound = true;
04959 }
04960 else if(stringcasecmp("url", szFieldname) == 0)
04961 {
04962 bFound = true;
04963 }
04964
04965 if(bFound == true)
04966 {
04967 return true;
04968 }
04969 else
04970 {
04971 return Inherited::prototypeAddField(szFieldType,
04972 uiFieldTypeId,
04973 szFieldname);
04974 }
04975 }
04976
04977 void VRMLInlineDesc::endProtoInterface(void)
04978 {
04979 }
04980
04981 void VRMLInlineDesc::getFieldAndDesc(
04982 FieldContainerPtr pFC,
04983 const Char8 * szFieldname,
04984 Field *&pField,
04985 const FieldDescription *&pDesc)
04986 {
04987 if(szFieldname == NULL)
04988 return;
04989
04990 if(pFC == NullFC)
04991 return;
04992
04993 NodePtr pNode = NodePtr::dcast(pFC);
04994
04995 #ifdef OSG_DEBUG_VRML
04996 indentLog(getIndent(), PINFO);
04997 PINFO << "VRMLInlineDesc::getFieldAndDesc : looking for "
04998 << szFieldname
04999 << std::endl;
05000 #endif
05001
05002 if(pNode == NullFC)
05003 {
05004 PWARNING << "VRMLInlineDesc::getFieldAndDesc : No Node" << std::endl;
05005 return;
05006 }
05007
05008 NodeCorePtr pNodeCore = pNode->getCore();
05009
05010 InlinePtr pInline = InlinePtr::dcast(pNodeCore);
05011
05012 if(pInline == NullFC)
05013 {
05014 PWARNING << "VRMLInlineDesc::getFieldAndDesc : No Inline" << std::endl;
05015 return;
05016 }
05017
05018 incIndent();
05019
05020 if(stringcasecmp("bboxCenter", szFieldname) == 0)
05021 {
05022 #ifdef OSG_DEBUG_VRML
05023 indentLog(getIndent(), PINFO);
05024 PINFO << "VRMLInlineDesc::getFieldAndDesc : : request internal "
05025 << szFieldname
05026 << std::endl;
05027 #endif
05028
05029 pField = &_boxCenter;
05030 pDesc = NULL;
05031 }
05032 else if(stringcasecmp("bboxSize", szFieldname) == 0)
05033 {
05034 #ifdef OSG_DEBUG_VRML
05035 indentLog(getIndent(), PINFO);
05036 PINFO << "VRMLInlineDesc::getFieldAndDesc : : request internal "
05037 << szFieldname
05038 << std::endl;
05039 #endif
05040
05041 pField = &_boxSize;
05042 pDesc = NULL;
05043 }
05044 else
05045 {
05046 VRMLNodeDesc::getFieldAndDesc(pInline,
05047 szFieldname,
05048 pField,
05049 pDesc);
05050 }
05051
05052 #ifdef OSG_DEBUG_VRML
05053 decIndent();
05054 #endif
05055 }
05056
05057
05058
05059
05060 FieldContainerPtr VRMLInlineDesc::beginNode(
05061 const Char8 *,
05062 const Char8 *,
05063 FieldContainerPtr )
05064 {
05065 FieldContainerPtr pFC = NullFC;
05066 NodePtr pNode = NullFC;
05067 NodeCorePtr pNodeCore = NullFC;
05068 GenericAttPtr pAtt = NullFC;
05069
05070 if(_pNodeProto != NullFC)
05071 {
05072 FieldContainerPtr pAttClone = _pGenAtt->emptyCopy();
05073
05074 pAtt = GenericAttPtr::dcast(pAttClone);
05075
05076 if(pAtt != NullFC)
05077 {
05078 pAtt->setInternal(true);
05079 }
05080
05081 pFC = _pNodeProto->shallowCopy();
05082
05083 pNode = NodePtr::dcast(pFC);
05084
05085 pFC = _pNodeCoreProto->shallowCopy();
05086
05087 pNodeCore = NodeCorePtr::dcast(pFC);
05088
05089 beginEditCP(pNode);
05090 {
05091 pNode ->setCore (pNodeCore);
05092 pNodeCore->addAttachment(pAtt);
05093 }
05094 endEditCP (pNode);
05095 }
05096
05097 #ifdef OSG_DEBUG_VRML
05098 indentLog(getIndent(), PINFO);
05099 PINFO << "Begin Inline" << &(*pNode) << std::endl;
05100
05101 incIndent();
05102 #endif
05103
05104 return pNode;
05105 }
05106
05107 void VRMLInlineDesc::endNode(FieldContainerPtr pFC)
05108 {
05109 Field *pField;
05110 const FieldDescription *pFieldDesc;
05111
05112 NodePtr pNode = NodePtr::dcast(pFC);
05113
05114 VRMLNodeDesc::getFieldAndDesc(pFC,
05115 "url",
05116 pField,
05117 pFieldDesc);
05118
05119 MFString *pUrl = dynamic_cast<MFString *>(pField);
05120
05121 FDEBUG(("Inline : %s\n", (*pUrl)[0].c_str()));
05122
05123 std::string filename =
05124 SceneFileHandler::the().getPathHandler()->findFile((*pUrl)[0].c_str());
05125
05126
05127 if(filename.empty())
05128 filename = (*pUrl)[0];
05129
05130 std::string path = SceneFileHandler::the().getPathHandler()->
05131 extractPath(filename.c_str());
05132 SceneFileHandler::the().getPathHandler()->push_backPath(path.c_str());
05133 ImageFileHandler::the().getPathHandler()->push_backPath(path.c_str());
05134 NodePtr pFile = SceneFileHandler::the().read(filename.c_str());
05135 ImageFileHandler::the().getPathHandler()->subPath(path.c_str());
05136 SceneFileHandler::the().getPathHandler()->subPath(path.c_str());
05137
05138 if(pFile != NullFC)
05139 {
05140 beginEditCP(pNode, Node::ChildrenFieldMask);
05141 {
05142 pNode->addChild(pFile);
05143 }
05144 endEditCP (pNode, Node::ChildrenFieldMask);
05145 }
05146
05147 #ifdef OSG_DEBUG_VRML
05148 decIndent();
05149
05150 indentLog(getIndent(), PINFO);
05151 PINFO << "End Inline "
05152 << &(*pFC) << std::endl;
05153 #endif
05154 }
05155
05156
05157
05158
05159 void VRMLInlineDesc::dump(const Char8 *)
05160 {
05161 }
05162
05163
05164
05165
05166
05167
05168
05174
05175
05176
05177 VRMLViewpointDesc::VRMLViewpointDesc(void) :
05178 Inherited()
05179 {
05180 }
05181
05182
05183
05184
05185 VRMLViewpointDesc::~VRMLViewpointDesc(void)
05186 {
05187 }
05188
05189
05190
05191
05192 void VRMLViewpointDesc::init(const Char8 *OSG_VRML_ARG(szName))
05193 {
05194 #ifdef OSG_DEBUG_VRML
05195 PINFO << "Viewpoint init : " << szName << std::endl;
05196 #endif
05197
05198 _pNodeProto = Node::create();
05199 _pNodeCoreProto = ComponentTransform::create();
05200 _pGenAtt = GenericAtt::create();
05201 _pGenAtt->setInternal(true);
05202
05203 FieldDescription *pDesc =
05204 new FieldDescription(SFBool::getClassType(),
05205 "isViewpoint",
05206 0, 0,
05207 false,
05208 (FieldIndexAccessMethod)
05209 &GenericAtt::getDynamicField);
05210
05211
05212 _pGenAtt->addField(*pDesc);
05213 }
05214
05215 void VRMLViewpointDesc::reset(void)
05216 {
05217
05218
05219
05221
05222
05223
05224
05225 }
05226
05227 ComponentTransformPtr VRMLViewpointDesc::getDefaultBeacon(void)
05228 {
05229 return NullFC;
05230 }
05231
05232
05233
05234
05235
05236
05237
05238
05239
05240
05241
05242 bool VRMLViewpointDesc::prototypeAddField(const Char8 *szFieldType,
05243 const UInt32 uiFieldTypeId,
05244 const Char8 *szFieldname)
05245 {
05246 bool bFound = false;
05247
05248 _pCurrField = NULL;
05249
05250 if(stringcasecmp("orientation", szFieldname) == 0)
05251 {
05252 _pCurrField = _pNodeCoreProto->getField("rotation");
05253
05254 bFound = true;
05255 }
05256 else if(stringcasecmp("position", szFieldname) == 0)
05257 {
05258 _pCurrField = _pNodeCoreProto->getField("translation");
05259
05260 bFound = true;
05261 }
05262
05263 if(bFound == true)
05264 {
05265 return true;
05266 }
05267 else
05268 {
05269 return Inherited::prototypeAddField(szFieldType,
05270 uiFieldTypeId,
05271 szFieldname);
05272 }
05273 }
05274
05275 void VRMLViewpointDesc::endProtoInterface(void)
05276 {
05277 }
05278
05279 void VRMLViewpointDesc::getFieldAndDesc(
05280 FieldContainerPtr pFC,
05281 const Char8 * szFieldname,
05282 Field *&pField,
05283 const FieldDescription *&pDesc)
05284 {
05285 #ifdef OSG_DEBUG_VRML
05286 indentLog(getIndent(), PINFO);
05287 PINFO << "ViewpointDesc::getFieldAndDesc : request "
05288 << szFieldname
05289 << std::endl;
05290 #endif
05291
05292 if(szFieldname == NULL)
05293 return;
05294
05295 if(pFC == NullFC)
05296 return;
05297
05298 NodePtr pNode = NodePtr::dcast(pFC);
05299
05300 if(pNode == NullFC)
05301 {
05302 PWARNING << "ViewpointDesc::getFieldAndDesc : No Node" << std::endl;
05303 return;
05304 }
05305
05306 NodeCorePtr pNodeCore = pNode->getCore();
05307
05308 ComponentTransformPtr pTransform = ComponentTransformPtr::dcast(pNodeCore);
05309
05310 if(pTransform == NullFC)
05311 {
05312 PWARNING << "ViewpointDesc::getFieldAndDesc : No Geo" << std::endl;
05313 return;
05314 }
05315
05316 if(stringcasecmp("orientation", szFieldname) == 0)
05317 {
05318 #ifdef OSG_DEBUG_VRML
05319 indentLog(getIndent(), PINFO);
05320 PINFO << "ViewpointDesc::getFieldAndDesc : internal "
05321 << szFieldname << std::endl;
05322 #endif
05323
05324 pField = pTransform->getField("rotation");
05325
05326 if(pField != NULL)
05327 pDesc = pTransform->getType().findFieldDescription("rotation");
05328 }
05329 else if(stringcasecmp("position", szFieldname) == 0)
05330 {
05331 #ifdef OSG_DEBUG_VRML
05332 indentLog(getIndent(), PINFO);
05333 PINFO << "ViewpointDesc::getFieldAndDesc : internal "
05334 << szFieldname << std::endl;
05335 #endif
05336
05337 pField = pTransform->getField("translation");
05338
05339 if(pField != NULL)
05340 pDesc = pTransform->getType().findFieldDescription("translation");
05341 }
05342 else
05343 {
05344 VRMLNodeDesc::getFieldAndDesc(pTransform,
05345 szFieldname,
05346 pField,
05347 pDesc);
05348 }
05349 }
05350
05351
05352
05353
05354 FieldContainerPtr VRMLViewpointDesc::beginNode(
05355 const Char8 *,
05356 const Char8 *,
05357 FieldContainerPtr )
05358 {
05359 FieldContainerPtr pFC = NullFC;
05360 NodePtr pNode = NullFC;
05361 NodeCorePtr pNodeCore = NullFC;
05362 GenericAttPtr pAtt = NullFC;
05363
05364 if(_pNodeProto != NullFC)
05365 {
05366 FieldContainerPtr pAttClone = _pGenAtt->clone();
05367
05368 pAtt = GenericAttPtr::dcast(pAttClone);
05369
05370 if(pAtt != NullFC)
05371 {
05372 pAtt->setInternal(true);
05373 }
05374
05375 pFC = _pNodeProto->shallowCopy();
05376
05377 pNode = NodePtr::dcast(pFC);
05378
05379 pFC = _pNodeCoreProto->shallowCopy();
05380
05381 pNodeCore = NodeCorePtr::dcast(pFC);
05382
05383 beginEditCP(pNode);
05384 {
05385 pNode ->setCore (pNodeCore);
05386 pNodeCore->addAttachment(pAtt);
05387 }
05388 endEditCP (pNode);
05389 }
05390
05391 #ifdef OSG_DEBUG_VRML
05392 indentLog(getIndent(), PINFO);
05393 PINFO << "Begin Viewpoint " << &(*pNode) << std::endl;
05394
05395 incIndent();
05396 #endif
05397
05398 return pNode;
05399 }
05400
05401 void VRMLViewpointDesc::endNode(FieldContainerPtr OSG_VRML_ARG(pFC))
05402 {
05403 #ifdef OSG_DEBUG_VRML
05404 decIndent();
05405
05406 indentLog(getIndent(), PINFO);
05407 PINFO << "End Viewpoint " << &(*pFC) << std::endl;
05408 #endif
05409 }
05410
05411
05412
05413
05414 void VRMLViewpointDesc::dump(const Char8 *)
05415 {
05416 }
05417
05418
05419 #include <OSGMFieldTypeDef.inl>
05420 #include <OSGSFieldTypeDef.inl>
05421
05422 OSG_BEGIN_NAMESPACE
05423
05424 DataType FieldDataTraits<GenericAttPtr>::_type("GenericAttPtr",
05425 "AttachmentPtr");
05426
05427 #if defined(OSG_SGI_EXPLICIT_INSTANTIATION)
05428
05429 #pragma instantiate DynFieldAttachment<GenericAttDesc>::_type
05430
05431 #pragma instantiate SField<GenericAttPtr>::_fieldType
05432 #pragma instantiate MField<GenericAttPtr>::_fieldType
05433
05434 #else
05435
05436 OSG_DLLEXPORT_SFIELD_DEF1(GenericAttPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
05437 OSG_DLLEXPORT_MFIELD_DEF1(GenericAttPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING);
05438
05439 #endif
05440 OSG_END_NAMESPACE
05441
05442
05443
05444
05445 #ifdef __sgi
05446 #pragma set woff 1174
05447 #endif
05448
05449 #ifdef OSG_LINUX_ICC
05450 #pragma warning( disable : 177 )
05451 #endif
05452
05453 namespace
05454 {
05455 static Char8 cvsid_cpp[] = "@(#)$Id: $";
05456 static Char8 cvsid_hpp[] = OSGVRMLNODEDESCS_HEADER_CVSID;
05457 }