load a mesh once and display it many times?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
markus
Posts: 23
Joined: Tue Mar 01, 2005 9:01 pm
Location: Germany

load a mesh once and display it many times?

Post 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
Guest

Post 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);
Warchief

Post 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.
Warchief

Post by Warchief »

For 3ds,
maybe you cannot use IAnimatedMesh & IAnimatedMeshSceneNode. You should use IMesh & ISceneNode instead.

Isn't it?
SARIN
Posts: 139
Joined: Fri Oct 29, 2004 3:53 am

Post 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
markus
Posts: 23
Joined: Tue Mar 01, 2005 9:01 pm
Location: Germany

Post 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
Post Reply