Hi, I am using an API that depends on osg 2.8.1, and have been asked to finally attempt to upgrade to the latest development release (3.1.1).
The SDK currently makes a few customization to osg, mainly adding user data to osgPlugins::osg::Node. The following 2 functions are changed in the file: $OSG/src/osgPlugins/osg/Node.cpp Code: #include "osg/AcousticPropertyData.h" bool Node_readLocalData(Object& obj, Input& fr) { ... // change user data to read in acoustic properties if (fr.matchSequence("user_data {")) { int entry = fr[0].getNoNestedBrackets(); fr += 2; while (!fr.eof() && fr[0].getNoNestedBrackets() > entry) { std::string str = fr[0].getStr(); if (str.length()>0) { std::string type = str.substr(0, str.find_first_of(' ')); const char *cStr = str.c_str(); if (type == "RoomData") { RoomData* roomData = new RoomData(); char type[256]; int isActive; sscanf(cStr, "%s %lf %lf %lf %lf %d %ld %ld %lf %s", &(type), &(roomData->m_WetMix), &(roomData->m_Diffusion), &(roomData->m_T60Low), &(roomData->m_T60High), &(isActive), &(roomData->m_DefaultPartitionId), &(roomData->m_DefaultReflectorId), &(roomData->m_DefaultFlankingBoost), &(roomData->m_RoomID)); roomData->m_IsActive = (isActive != 0); node.setUserData(roomData); } else if (type == "SurfaceData") { SurfaceData* surfaceData = new SurfaceData(); char type[256]; int isActive; sscanf(cStr, "%s %lf %lf %lf %lf %d", &(type), &(surfaceData->m_ReflectorId), &(surfaceData->m_PartitionId), &(surfaceData->m_FlankingBoost), &(isActive)); surfaceData->m_IsActive = (isActive != 0); node.setUserData(surfaceData); } ++fr; } } iteratorAdvanced = true; } ... } bool Node_writeLocalData(const Object& obj, Output& fw) { ... // change user data to become acoustic property if (!strcmp(node.className(), "Geode") || !strcmp(node.className(), "Group")) { const Referenced* _userData = NULL; _userData = node.getUserData(); if (_userData) { AcousticPropertyData* object = NULL; object = dynamic_cast<AcousticPropertyData*>(const_cast< Referenced* >(_userData)); if (object) { fw.indent() << "user_data {"<< std::endl; fw.moveIn(); char tempCStr[2048]; if (object->m_AcousticDataType == kRoomData) { RoomData* roomData = dynamic_cast<RoomData*>(object); strncpy(roomData->m_RoomID, node.getName().c_str(), sizeof(roomData->m_RoomID)); sprintf(tempCStr, "%s %lf %lf %lf %lf %d %d %d %lf %s", "RoomData", roomData->m_WetMix, roomData->m_Diffusion, roomData->m_T60Low, roomData->m_T60High, (roomData->m_IsActive ? 1 : 0), roomData->m_DefaultPartitionId, roomData->m_DefaultReflectorId, roomData->m_DefaultFlankingBoost, roomData->m_RoomID); } else if (object->m_AcousticDataType == kSurfaceData) { SurfaceData* surfaceData = dynamic_cast<SurfaceData*>(object); sprintf(tempCStr, "%s %ld %ld %lf %d", "SurfaceData", surfaceData->m_PartitionId, surfaceData->m_ReflectorId, surfaceData->m_FlankingBoost, (surfaceData->m_IsActive ? 1 : 0)); } std::string str; str.assign(tempCStr); fw.indent() << fw.wrapString(str) << std::endl; fw.moveOut(); fw.indent() << "}"<< std::endl; } } } ... } "AccousticPropertyData.h" basically contains definitions of the classes "RoomData" and "SurfaceData". Code: class AcousticPropertyData : public Referenced { public: AcousticPropertyData(AcousticDataType type): m_AcousticDataType(type), Referenced() { m_Version = 3; m_IsActive = true; } virtual ~AcousticPropertyData() {} int m_Version; bool m_IsActive; AcousticDataType m_AcousticDataType; }; class SurfaceData : public AcousticPropertyData { public: SurfaceData(): AcousticPropertyData(kSurfaceData) { m_ReflectorId = 0; m_PartitionId = 0; m_FlankingBoost = 0; } const SurfaceData& operator=(const SurfaceData& src) { m_ReflectorId = src.m_ReflectorId; m_PartitionId = src.m_PartitionId; m_FlankingBoost = src.m_FlankingBoost; m_IsActive = src.m_IsActive; return *this; } long m_ReflectorId; long m_PartitionId; double m_FlankingBoost; }; The problem is that in 3.1.1 osgPlugins osg has been deprecated. So using the above code wouldn't be possible without using deprecated code, which I would rather not do. My question is, how can I add user data to osg node? Preferably without making any changes to osg, but rather through my app/sdk. Any sample that does that? Thank you! Cheers, Tamer ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48887#48887 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org