Jump to content

[SOLVED] Object Id


photo

Recommended Posts

Hi there

 

Why is the editor changing the node's id always to some number. We would like to have some of the id's fixed to certain object. And by working on it in the editor, f.ex. load it as reference, save the altered coordinates/attitude, mats or what ever, but leaving the id as they are.

 

Kind regards,

Renato

Link to comment

Hi Renato,

 

I've created small test scene with single NodeReference object. I can move, rotate, edit NodeRefrence conents, doing the undo-redo operations without the Node ID changes. I'm using the latest RC SDK. Behavior can be slighlty differen in older Unigine versions.

 

Could you please check the attached test scene with latest SDK and try to reproduce such behavior? Maybe some additional steps are required?

Thank you!

 

noderef_id.zip

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hi Andrey

 

Right. But if I dont' want the random set ID and change it in the node file. F.ex. I'm changing the artillery_shot Id to be 1, the next time I open the reference in the editor it changes back to what it was.

 

The point, why I need fixed ID's is that from the C++ API, I only can access the node by knowing its ID. And therefore, I want self defined ID's which don't change. Or is there an other way getting the access to the node?

 

Kind regards,

Renato

Link to comment

Hi Renato,

 

A better aproach is to add nodes to editor (Unigine::Editor::addNode) and get instances by name (Editor::getNodeByName). Node ids are not supposed to be manually changed(but you can change it in file while node is not loaded, and it will load and saved with this id except this id is already taken)

Link to comment

Hi Maxim

 

Thanks a lot for your answer. Yes, in our dev code we are using getNode and not node_editor. But since we are accessing the nodes from the C++ API, we don't have a getNodeByName method. So we have to use the ID's. Or is there a way to use the names? Would be very nice! =)

 

We made sure that the newly set ID's are not already used. You can reproduce this behavior in the above provided test scene by Andrey. If you change the ID of the node "artillery_shot" into a new one, which is unused. The next time you open adjust this node, the ID will be changed from the engine.

 

Kind regards,

Renato

Link to comment

Hi Maxim

 

Sorry to bother you again.

nodeRef = Unigine::NodeReference::create(path.c_str());
nodeRef->releaseNodeReference();
ownshipNode = engine->getEditor()->getNodeByName("OwnshipEyepoint");

This is my code to create a new reference with its path. Than I'm releasing the reference to be handled by the engine and finally I'm looking for the node by its name.

 

But the engine get's me always the error message "can't find "OwnshipEyepoint" node.

 

Any ideas?

 

Kind regards,

Renato

Link to comment

If you are creating node in code (not in editor) you have to add it to editor by Unigine::Editor::addNode.

nodeRef = Unigine::NodeReference::create(path.c_str());
Editor::get()->addNode(nodeRef);
nodeRef->releaseNodeReference();
ownshipNode = Editor::get()->getNodeByName("OwnshipEyepoint");
Link to comment

Somewhat, I don't get... Also adding the nodeRef to the editor, actually the nodeRef.getNode() since nodeRef is a NodeReferencePtr. But even so the engine doesn't find the dummynode "ownshipEyepoint"

Link to comment

Sorry for the wrong example.

 

Here is working code how to create and get node references.

	// we have "some.node" file, where ObjectMeshDynamic with name "Cuboid_0" is located
	
	// add to editor as a noderef
	{
		Unigine::NodeReferencePtr nodeRef = Unigine::NodeReference::create("some.node");
		Unigine::NodePtr node = nodeRef->getNode();
		node->setName("noderef_name"); // name of noderef is different from name in some.node
		Unigine::Editor::get()->addNode(node);
		nodeRef->release();
	}
	
	// add to editor as a node
	{
		Unigine::NodeReferencePtr nodeRef = Unigine::NodeReference::create("some.node");
		Unigine::Editor::get()->addNode(nodeRef->getNodeReference());
		nodeRef->releaseNodeReference();
	}
	
	// get a noderef instance
	{
		Unigine::NodePtr node= Unigine::Editor::get()->getNodeByName("noderef_name");
 		Unigine::NodeReferencePtr nodeRef = Unigine::NodeReference::create(node);
		Unigine::ObjectMeshDynamicPtr dynamic = Unigine::ObjectMeshDynamic::create(nodeRef->getNodeReference());
		dynamic->setMaterial("mesh_lut_reflection_cube_base","*");
	}
	
	// get a node instance
	{
		Unigine::NodePtr node= Unigine::Editor::get()->getNodeByName("Cuboid_0");
		Unigine::ObjectMeshDynamicPtr dynamic = Unigine::ObjectMeshDynamic::create(node);
		dynamic->setMaterial("mesh_lut_reflection_cube_base","*");
	}
Link to comment
×
×
  • Create New...