Jump to content

Node not added to world during runtime


photo

Recommended Posts

Hi (again),

In my project, during runtime I'm loading a world containing objects like sun, then also during runtime I'm creating dynamically a mountPoint with the functions addBlobFile and createMount.
Then i'm adding in the world a node that is in my mountPoint.
Everything seems to be loaded correctly, my paths for the mountPoint are good but when the simulation start there isn't the node I added from the mountPoint. Instead I have this type of errors

image.thumb.png.04fbea4c2c983d0c102e40a95d0a1d0c.png

I'm sure this has something to do with this error, do you have any suggestion?

Thanks!

Pierre

Link to comment

Hi Silent,

Here is a .zip with 3 minimal unigine project to reproduce my problem.

The project "test_mout" is the main project that you have to launch.
The project "test_mount2" is a project included in the first one thanks to a .umount file.
The project "test_mount3" is the project that I dynamically include during runtime with a mountPoint created in the code.

In fact I don't have the same error, but the same result. For both case I have a node containing a mesh with a custom material, but the node from the the dynamic mountPoint doesn't appear. 

Note : In "test_mount3" the custom material doesn't seem to be loaded (the purple cylinder is not visible)

Thanks!

Pierre

test_mount.zip

Link to comment

Hello Pierre,

I have modified your code and now it works. 

When you create dynamically a mount point during runtime, materials or properties are not added automatically from this new mount point, how it happens on the launch. In this case you need to do it yourself.

You should load materials before nodes loading.

int AppWorldLogic::init()
{
	//// Add Node from Mount 2
	std::string path2 = "test_mount2/node_mount2.node";
	Unigine::NodeReferencePtr newRef2 = Unigine::NodeReference::create(path2.c_str());
	newRef2->setPosition(Unigine::Math::Vec3(-3.0f, -3.0f, 0.0f));
	newRef2->setOwner(false);

	//// Load Mount 3
	auto absolute_path = std::string(Unigine::Engine::get()->getDataPath()) + "../../test_mount3/data/";
	auto blob = Unigine::FileSystem::addBlobFile("test_mount3.umount");
	auto mount = Unigine::FileSystem::createMount(absolute_path.c_str(), "test_mount3", Unigine::FileSystemMount::ACCESS_READONLY);
	mount->setOwner(false);

	//// Add Material from Mount 3
	auto mat = Unigine::Materials::loadMaterial("test_mount3/Materials/mesh_base_0.mat");
	assert(mat);

	//// Add Node from Mount 3
	std::string path3 = "test_mount3/node_mount3.node";
	Unigine::NodeReferencePtr newRef3 = Unigine::NodeReference::create(path3.c_str());
	newRef2->setPosition(Unigine::Math::Vec3(3.0f, 3.0f, 0.0f));
	newRef3->setOwner(false);

	return 1;
}

 

  • Like 1
Link to comment
×
×
  • Create New...