Jump to content

[SOLVED] How to cast Node to Object?


photo

Recommended Posts

Posted

I have a Node variable that has been loaded via node_load. The node contains a single ObjectMesh (with no body). I want to call Object.setMaterialParameter but casting directly using Object(node) doesn't work because it says Object isn't a base class of Node. In the past I've done this via Body.getObject but this time I don't have a body so I'm stuck.

So how can I cast the Node to Object (or ObjectMesh)? Or is there another way to set material parameters on a node that I'm missing?

Posted

Use node_cast() function from the core/unigine.h file.

  • Like 1
Posted
Object object_cast(Node node) { return ((node != NULL) && (node.isObject()))? class_cast("Object",node) : NULL; }

Posted

Thanks guys. Both useful responses. class_cast is the one I was really missing, but node_cast does the job fine in this case.

×
×
  • Create New...