dai.yuqi Posted March 31, 2011 Share Posted March 31, 2011 How to create a object and set the position without using unigine script? I have read some exampls all of which need unigine script. Could anyone give an example ? thanks very much. Link to comment
luke.errington Posted June 28, 2011 Share Posted June 28, 2011 BUMP :rolleyes: The fact that we don't seem to be able to create nodes from C++ is a real issue for us. To help the original post, we can quite successfully move existing objects with ... Unigine::Node::setWorldTransform(const Unigine::mat4 &transform) ... although you need to be careful how you create the world transform matrix. However, we are still unsure how to create an object from C++. Sure, there is ... Unigine::ObjectMeshDynamic::create(Unigine::NodePtr node) ... but you still need to have a node already created to use this. This leaves us having to write a wrapper function in script just so that we can call it from C++ ... Node LoadNode(string node_name) { return engine.world.loadNode(node_name); } ... and it is disappointing, but seemingly necessary, to have to do something like this ... Unigine::Variable new_node = engine->runWorld("LoadNode", node_name); loaded_nodes.push_back(new_node.getNode()); Have we missed a way to do this solely from C++? We need C++ control because the Unigine engine is being plugged into an existing GUI that builds content and thus we need to dynamically create, destroy and modify objects/nodes. It appears that the C++ API is quite restricted compared to that for the UnigineScript. This results in us having to write the sort of code shown above for many of the missing functions, which is not only laborious but concerns us as being undesirably expensive at run-time. Does anybody know if there is a reason why the C++ API needs to be so minimal? Is it possible to expand this API to provide all functionality that is available from within the script? This would be really appreciated. Link to comment
manguste Posted June 28, 2011 Share Posted June 28, 2011 Does anybody know if there is a reason why the C++ API needs to be so minimal? The reason is that Unigine uses its own allocator. Memory Management article explains it in detail. Also take a look at Extern C++ Module Ownership part that contains variants how to create and handle objects by a custom C++ module. Link to comment
Recommended Posts