void OSBShaderParameterMIntElement::read(const std::string &typeName) { OSG_OSB_LOG(("OSBShaderParameterMIntElement::read: [%s]\n", typeName.c_str())); BinaryReadHandler *rh = editRoot()->getReadHandler(); UInt8 ptrTypeId; UInt16 version; rh->getValue(ptrTypeId); rh->getValue(version ); OSG_OSB_LOG(("OSBShaderParameterMIntElement::read: version: [%u]\n", version)); std::string fieldName; std::string fieldTypeName; UInt32 fieldSize; PtrFieldListIt ptrFieldIt; while(readFieldHeader("", fieldName, fieldTypeName, fieldSize)) { if(fieldName == "name") { _name.copyFromBin(*rh); } else if(fieldName == "value") { _value.copyFromBin(*rh); } else { OSG_OSB_LOG(("Skipping [%d] bytes for field [%s]\n", fieldSize, fieldName.c_str())); rh->skip(fieldSize); } } // no container is created for this element, which means the root does // not automatically insert it into the IdElemMap - do it manually editRoot()->editIdElemMap().insert( OSBRootElement::IdElemMap::value_type(getFCIdFile(), this)); }
void OSBTextureChunkElement::postRead(void) { OSG_OSB_LOG(("OSBTextureChunkElement::postRead:\n")); OSBRootElement *pRoot = editRoot(); // for the id remapping TexEnv needs an id that is not used in the file UInt32 texEnvIdFile = pRoot->getIdMap().rbegin()->first; while(pRoot->getIdMap().find(texEnvIdFile) != pRoot->getIdMap().end()) { ++texEnvIdFile; } // add mapping entry for TexEnv pRoot->editIdMap()[texEnvIdFile] = _pTexEnv->getId(); PtrFieldListIt ptrFieldIt = pRoot->editPtrFieldList().begin(); PtrFieldListIt ptrFieldEnd = pRoot->editPtrFieldList().end (); for(; ptrFieldIt != ptrFieldEnd; ++ptrFieldIt) { ChunkMaterial *chkMat = dynamic_cast<ChunkMaterial *>(ptrFieldIt->getContainer()); if(chkMat != NULL) { // OSBChunkMaterialElement takes care of handling the two chunks // replacing TextureChunk continue; } else { UInt32 numIds = ptrFieldIt->getIdStore ().size(); UInt32 numBind = ptrFieldIt->getBindingStore().size(); if(numBind > 0) { // TextureChunk is pointed to from an attachment map for(UInt32 i = 0; (i < numIds) && (i < numBind); ++i) { if(ptrFieldIt->getIdStore()[i] == getFCIdFile()) { // insert a pointer to TexEnv right after the TexObj ptrFieldIt->editIdStore().insert( ptrFieldIt->editIdStore().begin() + i + 1, texEnvIdFile ); // duplicate the binding of the TexObj ptrFieldIt->editBindingStore().insert( ptrFieldIt->editBindingStore().begin() + i + 1, ptrFieldIt->getBindingStore()[i] ); ++numIds; ++numBind; } } } else { for(UInt32 i = 0; i < numIds; ++i) { if(ptrFieldIt->getIdStore()[i] == getFCIdFile()) { // insert a pointer to TexEnv right after the TexObj ptrFieldIt->editIdStore().insert( ptrFieldIt->editIdStore().begin() + i + 1, texEnvIdFile ); ++numIds; } } } } } }