Artic_Ice83
23-02-2008 15:08:51
Hi! i want to change the colour of a body when it sleeps, but if i try this code it doesn't change the colour...
what is wrong?
NxOgre::Body *cube, *sphere;
cube = mScene->createBody("cube;cube.1m.mesh", new CubeShape(1,1,1,"material: defaultMaterial"), Vector3(1.0f,5.0f,1.0f), "mass: 5");
sphere = mScene->createBody("sphere;sphere.50cm.mesh",new NxOgre::SphereShape(0.5,"material: defaultMaterial"),Vector3(4.0f,0.0f,1.0f), "mass: 5");
cube->setSleepLinearVelocity(0.15*0.15);
cube->setSleepAngularVelocity(0.14*0.14);
/*CREATE THE SLEEPING MATERIAL*/
Ogre::MaterialPtr mp = Ogre::MaterialManager::getSingleton().create("sleep",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Pass *p = mp->getTechnique(0)->getPass(0);
p->setAmbient(ColourValue(0.8,0.4,0.5));
p->setDiffuse(ColourValue(0.4,0.5,0.6));
p->setLightingEnabled(true);
p->setCullingMode(Ogre::CULL_CLOCKWISE);
mp->load();
if(cube->isSleeping())
{
Entity *ent = cube->getEntity();
ent->setMaterialName("sleep");
}
what is wrong?