Priyank.Jain2 Posted February 6, 2017 Share Posted February 6, 2017 we want to have 2 exact same dynamic meshes but with different materials. In our existing code we have a wrapper around ObjectMeshDynamic like namespace MeshUtils { class DynamicMesh : ObjectMeshDynamic { /// Construct & set material in one DynamicMesh( string materialName ) : ObjectMeshDynamic() { setMaterial( "materialName", "*" ); setProperty("surface_base","*"); } ....... then we have 2 objects: MeshUtils::DynamicMesh mesh1 = new MeshUtils::DynamicMesh("material_1"); ObjectMeshDynamic mesh2 = new ObjectMeshDynamic(); And With Unigine 1 we were able to clone one to another using mesh2 = mesh1.clone(); mesh2.setMaterial( "material_2", "*" ); In Unigine 2.3.1 its giving error mesh2.setMaterial( "material_2", "*" ); ExternClass::run_function(): can't find "class ObjectMeshDynamic * __ptr64" base class in "class Node * __ptr64" class Link to comment
alexander Posted February 6, 2017 Share Posted February 6, 2017 Hi Priyank, Try to use mesh2 = node_cast(mesh1.clone()); instead of mesh2 = mesh1.clone(); Link to comment
Priyank.Jain2 Posted February 7, 2017 Author Share Posted February 7, 2017 Yes that worked. Can you please describe it a bit to help us understand the internals. Thanks. Link to comment
alexander Posted February 7, 2017 Share Posted February 7, 2017 Clone() method returns reference to the Node instance (base class): https://developer.unigine.com/en/docs/2.3.1/api/library/nodes/class.node?rlang=usc#clone_Node DerivedClass node_cast(Node node) allows you to convert the given base node to its derived type (Node to ObjectMeshDynamic in your case). Link to comment
silent Posted February 7, 2017 Share Posted February 7, 2017 Priyank, Basic usage of node_cast described in our documentation for Memory Management. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts