osg::Real32 FieldAnimationAdvancer::getValue(void) const { if(getFieldId() == 0) { //Check if the Field Container is defined if(getContainer() == osg::NullFC) { SWARNING << "There is no Field Container defined to get Field Advancer" << std::endl; return 0.0f; } //Check if the field in this container is defined FieldDescription * f = getContainer()->getType().findFieldDescription(getFieldName().c_str()); if( f == NULL ) { SWARNING << "Could not find Field "<< getFieldName() << " in Field Container " << getContainer()->getTypeName() << std::endl; return 0.0f; } //Found the Field so set my Field Id beginEditCP(FieldAnimationAdvancerPtr(this), FieldIdFieldMask); const_cast<SFUInt32*>(&_sfFieldId)->setValue(f->getFieldId()); endEditCP(FieldAnimationAdvancerPtr(this), FieldIdFieldMask); //The Field was not found if(getFieldId() == 0) { SWARNING << "Could not find Field "<< getFieldName() << " in Field Container " << getContainer()->getTypeName() << std::endl; return 0.0f; } //Check if the field is a Real32 if(getContainer()->getField( getFieldId() )->getType() != SFReal32::getClassType()) { SWARNING << "Field "<< getFieldName() << " in Field Container " << getContainer()->getTypeName() << "Is not a SFReal32 Field." << std::endl; return 0.0f; } } return static_cast<SFReal32*>(getContainer()->getField( getFieldId() ))->getValue(); }
Action::ResultE NFIOBase::clearAttachmentParent(NodePtr &node) { if(node == NullFC) return Action::Continue; FieldContainerPtr fc = node->getCore(); if(fc == NullFC) return Action::Continue; // the core could be shared this would lead to duplicated parent entries. if(_added_cores.count(fc) == 1) return Action::Continue; _added_cores.insert(fc); FieldContainerType &fcType = fc->getType(); //go through all fields for(UInt32 i = 1; i <= fcType.getNumFieldDescs(); ++i) { FieldDescription *fDesc = fcType.getFieldDescription(i); Field *fieldPtr = fc->getField(i); const FieldType &fType = fieldPtr->getType(); std::string fieldType = fType.getCName(); BitVector mask = fDesc->getFieldMask(); if(fDesc->isInternal()) { continue; } if(strstr(fieldType.c_str(), "Ptr") != NULL) { if(fieldType[0] == 'S' && fieldType[1] == 'F') // single field { AttachmentPtr attachment = AttachmentPtr:: dcast(static_cast<SFFieldContainerPtr *>(fieldPtr) ->getValue()); if(attachment != NullFC) { fc.setParentFieldPos(fDesc->getFieldId()); beginEditCP(attachment, Attachment::ParentsFieldMask); attachment->getParents().clear(); endEditCP(attachment, Attachment::ParentsFieldMask); } } else if(fieldType[0] == 'M' && fieldType[1] == 'F') // multi field { MFFieldContainerPtr *mfield = static_cast<MFFieldContainerPtr *>(fieldPtr); UInt32 noe = mfield->size(); for(UInt32 j = 0; j < noe; ++j) { AttachmentPtr attachment = AttachmentPtr::dcast((*(mfield))[j]); if(attachment != NullFC) { fc.setParentFieldPos(fDesc->getFieldId()); beginEditCP(attachment, Attachment::ParentsFieldMask); attachment->getParents().clear(); endEditCP(attachment, Attachment::ParentsFieldMask); } } } } } return Action::Continue; }