Jump to content

[SOLVED] How to hold a Object?


photo

Recommended Posts

Hi~

 

I create a Object like this code:

 

ObjectMesh *pMesh = new ObjecMesh("XXX");

 

engine.editor->addNode(pMesh);

 

I edit this ObjectMesh in Unigine Editor,like move,scale and so on,when I press "Press+Z" for undo,the pMesh pointer is point to an unable memory space.

 

And when I change this ObjectMesh's mesh in Unigine Editor,the pMesh pointer is also point to an unable memory space.

 

So, I guess Unigine Editor how to process like this thing:

 

1.delete old node;

2.create new node have old node's properties.

 

So, how to hold a Object? the pointer is unstable.

 

By node name?if I rename the Node in Unigine Editor,how can I do?

Edited by trouble3524
Link to comment

If a node is passed to the engine.editor this node can be deleted on undo action or you can manually remove this node in the editor. Moreover this node will be destroyed on world quit.

After passing a node to the editor forget about it. Use engine.editor->getNumNodes() and engine.editor->getNode() functions to get edited nodes back.

Link to comment
If a node is passed to the engine.editor this node can be deleted on undo action or you can manually remove this node in the editor. Moreover this node will be destroyed on world quit. After passing a node to the editor forget about it. Use engine.editor->getNumNodes() and engine.editor->getNode() functions to get edited nodes back.

 

I am sorry,it is not my mean.

 

I want to control a ObjectMesh in C++ all the time.

 

So I saved the ObjectMesh's pointer or ID.

 

but if my users moved/scaled the ObjectMesh in Unigine Editor and undo,the ObjectMesh's memory space or ID is changed.

 

So I can NOT get the ObjectMesh now,because the ID and pointer was invalidated.

Link to comment

A node can either belong to the editor (to be edited by a user) or controlled via scripts. (See Memory Mangement article for more details.)

This emans, after you add a node to the editor, the editor owns a pointer to it and rewrites it whenever its logic requires rewriting (for example, on the Undo action). Get your editor node via engine.editor.getNode() or engine.editor.getNodeByName() as Frustum advised.

Link to comment
×
×
  • Create New...