Topic: materials and meshes

Hi,
I'm asking this question in the forum so other people can benefit.

I'm trying to create a simple c++ app (starting the ManualUse example) to play a little with the physics and investigate on camera manipulators.
The app simply create a bunch of cubes and make them fall into a box
It has been very simple (with your help...) to setup the scene and make it running; but now I tried to assign a different color to each cube, setting the diffuse value

I tried with the following call:
box->getMesh()->getMaterial(0)->setDiffuse(0.6,0.5,0.4));

but this is affecting all the cubes, not only the one referenced by the *box entity pointer; the reason I believe is that one single mesh is used for all the cubes.
Is there a way to assign a different material to each entity, even if the entities refer to the same mesh?

thanks!!

Re: materials and meshes

Hi,

yes, mesh is the same for each cube, materials too,
there is no entities-materials, but you can duplicate the mesh and apply each copy to a different cube.

- or by using a different .mesh file where you can change the material value using a text editor or Blender

- or by code, creating a MMeshRef manually :

MMeshRef * meshRef = MMeshRef::getNew(NULL, filename);
level->getMeshManager()->addRef(meshRef); // force without checking if the mesh already exist
meshRef->update();