joseph.howell Posted July 8, 2016 Share Posted July 8, 2016 Hi I have a simple question. I'm not sure what is the best way to typecast in Unigine. Searching through the list of nodes, I found the ObjectTerrain, but it gives me a NodePtr and I want to typecast it to be a ObjectTerrainPtr. I tried something like this, but it causes a crash. ObjectTerrainPtr terrain = ObjectTerrainPtr(reinterpret_cast<ObjectTerrain*>(node.operator->())); Thanks Link to comment
ataylor Posted July 10, 2016 Share Posted July 10, 2016 I believe you should use the static create(NodePtr) function found in each node-derived class to effectively cast up to the type you want. In your case, you probably want something like the following: Unigine::NodePtr node; ... if(node->getType()==Unigine::Node::OBJECT_TERRAIN){ Unigine::ObjectTerrainPtr terrain=Unigine::ObjectTerrain::create(node); // do stuff with terrain } Link to comment
joseph.howell Posted July 11, 2016 Author Share Posted July 11, 2016 Thanks, yes that was what I needed. Link to comment
Recommended Posts