Topic: different materials on several instances of a mesh

Hi Maratis users,

I don't remember if the subject was already covered, but what is the simple way to assign different materials on several instance of the same mesh ?

for example here, all of the instance of the mesh "point" created in the scene should have differents materials.

getGlobalFilename(filename, workingDir, "meshs/point.mesh");
ptMesh = level->loadMesh(filename);

_points.resize(nbPoint);

for(i=0; i<nbPoint; i++){
        ent = scene->addNewEntity(ptMesh);
    ent->createPhysicsProperties();
}

Last edited by Alinor (2013-11-14 21:07:48)

Re: different materials on several instances of a mesh

Hi,

there is no mechanism right now to apply different materials to a mesh instance,
it should be added, but right now you have to duplicate the mesh, for example by creating meshRefs manually :

getGlobalFilename(filename, workingDir, "meshs/point.mesh");

for(i=0; i<nbPoint; i++)
{
    MMeshRef * meshRef = MMeshRef::getNew(NULL, filename);
    level->getMeshManager()->addRef(meshRef); // manually add the mesh ref to the level
    meshRef->update(); // actually load the mesh
    ent = scene->addNewEntity(meshRef);
    // change the material here
}

Re: different materials on several instances of a mesh

okay, thanks for your quick answer wink