|
Alex-Crafter, Newbie
Posted: 06 October 2012 12:16 AM Total Posts: 28
Hi there.
Can anyone advise me what is the best way to use several mesh instances, bu giving each one a different material?
Is there a way to make it without creating a new mesh (thus adding to memory more geometry)?
If i use a reference from the geometry of a mesh to a new mesh, is this geometry instanced, or is it created anew?
Thanks for any reply.
|
Richard Olsson, Administrator
Posted: 06 October 2012 08:42 AM Total Posts: 1192
[ # 1 ]
If you use the same Geometry object, there will only be one instance of that geometry in memory (on the CPU and on the GPU). This is what some 3D applications call “instancing”, correct!
The mesh class exists for that very purpose which you outline—to be able to uniquely position and shade (set materials on) the same geometry over and over again, without duplicating the geometry data.
|
Alex-Crafter, Newbie
Posted: 06 October 2012 12:07 PM Total Posts: 28
[ # 2 ]
Many thanks for your response, Richard.
So, what would be the best method, to instance the same mesh, for different models, while using different materials?
newmesh=mesh.clone()?
or
newmesh=new Mesh(mesh.geometry)?
Brgds.
|
Richard Olsson, Administrator
Posted: 06 October 2012 12:09 PM Total Posts: 1192
[ # 3 ]
It doesn’t matter. They do essentially the same thing, as you can see if you look inside the Mesh.clone() method.
|
Alex-Crafter, Newbie
Posted: 06 October 2012 12:27 PM Total Posts: 28
[ # 4 ]
You made my day a happy one. Many thanks, Richard.
|