dongju.jeong Posted October 22, 2018 Share Posted October 22, 2018 { NodeReferencePtr node_ref = NodeReference::create(NodeRef); // NodeRef is file parameter (.node) node_ref->setName("NodeReference_0"); node_ref->release(); Editor::get()->addNode(node_ref->getNode()); NodePtr node = Editor::get()->getNodeByName("NodeReference_0"); ObjectMeshStaticPtr node1 = ObjectMeshStatic::cast(node); //return null ObjectMeshStaticPtr node2 = ObjectMeshStatic::cast(node); //return null } NodeRef is material_ball.node(material_ball's nodeReference). material_ball's Original type is ObjectMeshStatic. So I thought that I can cast to ObjectMeshStatic. but That casting return null. How do I cast to ObjectMeshStatic? Link to comment
fox Posted October 22, 2018 Share Posted October 22, 2018 Hi dongju.jeong, You cannot downcast the node to ObjectMeshStatic this way, as it's original type is NodeReference, not ObjectMeshStatic. Guess in your case you should use the NodeReference::getReference() method (follow the link to see the related code-snippet in the doc). Hope this helps! Thank you! Link to comment
dongju.jeong Posted October 22, 2018 Author Share Posted October 22, 2018 (edited) Ok, that link have something wrong ( 404 forbidden). but I understand getReference() function. and I get a workaround. ObjectMeshStaticPtr node1 = ObjectMeshStatic::cast(NodeReference::cast(node)->getReference()); Thank you If I editing node1 for something related to the ObjectMeshStatic class, would it apply to the node (NodeReference)? Edited October 22, 2018 by dongju.jeong Link to comment
fox Posted October 22, 2018 Share Posted October 22, 2018 Right, that's the way it should work! Sorry, the link is fixed now. As for your second question, please see the Editing a Node Reference chapter in the NodeReference Class article. Thank you! Link to comment
Recommended Posts