Page 1 of 1

load a mesh once and display it many times?

Posted: Sat Apr 23, 2005 4:43 pm
by markus
Hi,
a silly question:
Is it possible to load a mesh once but display it many times at different locations?

The background of my question:
I want ot write a 3d text class, where each character is represented via a mesh. So i want to load the whole alphabet into the application and whenever i want to display an "A" for instance use the loaded A.3ds.

normaly i would have a node of the loaded mesh but each node can be at one place at a distinct time not at two ore more.

I hope i was able to make my problem clear. :oops:

Greetings
Markus

Posted: Sat Apr 23, 2005 5:14 pm
by Guest
I think it is the usual way. Loading the mesh again for every model needs a lot of extra memory.

Code: Select all

	// Load mesh once
	scene::IAnimatedMesh* letterAmesh =
			smgr->getMesh("data/A.3ds");

	// Use it a lot of times (lot of nodes, the same mesh)
        scene::IAnimatedMeshSceneNode* node1 = 
		smgr->addAnimatedMeshSceneNode(letterAmesh);

        scene::IAnimatedMeshSceneNode* node2 = 
		smgr->addAnimatedMeshSceneNode(letterAmesh);

Posted: Sat Apr 23, 2005 5:16 pm
by Warchief
And then use:

Code: Select all

node1.setPosition (const core::vector3df &newpos)
node2.setPosition (const core::vector3df &newpos)
to place nodes over the world.

Posted: Sat Apr 23, 2005 5:21 pm
by Warchief
For 3ds,
maybe you cannot use IAnimatedMesh & IAnimatedMeshSceneNode. You should use IMesh & ISceneNode instead.

Isn't it?

Posted: Sat Apr 23, 2005 6:25 pm
by SARIN
there are two ways, u could
1) have two nodes assigned to the one mesh
2) use the render() function as many times as u need, each time setting a new position to the node, and later resseting the nodes position

Posted: Sun Apr 24, 2005 8:53 am
by markus
Great! :D
that was what i've searched.

Thanks to all of you!
I was not aware of the fact that loading a mesh an creating a scenenode can be done separately.

Until now i always did both steps in one by using a custom function "loadModelAtPos".

If i had looked into it i could have find it out on my own. :oops:

Thanks again for routing me in the right direction.

Happy coding
Markus