Adding a bump map to an animated scene node?
Posted: Sun Mar 13, 2011 12:52 am
Tutorial 11 shows how to add a bump map to a regular scene node, but what is the best way to add a bump map to an animated scene node?
Here's my code:
Edit: the following makes a black node.
Edit 2:
I almost entirely copied the tutorial code. All I get is a white rectangle.
Here's my code:
Code: Select all
void IrrSetAndAddBumpMap (IAnimatedMeshSceneNode* node, irr::video::ITexture* texture) {
driver->makeNormalMapTexture (texture, 20.0f);
node->setMaterialTexture (1, texture);
node->setMaterialType (video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA);
IMesh* oldMesh = node->getMesh()->getMesh(0);
IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents( node->getMesh()->getMesh(0));
SAnimatedMesh* sanimmesh = new SAnimatedMesh;
sanimmesh->addMesh(oldMesh);
sanimmesh->addMesh(tangentMesh);
node->setMesh(sanimmesh);
}
Code: Select all
void IrrSetAndAddBumpMap (IAnimatedMeshSceneNode* node, irr::video::ITexture* texture) {
driver->makeNormalMapTexture (texture, 1.0f);
irr::video::ITexture* oldTexture = node->getMaterial(0).getTexture(0);
IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(node->getMesh()->getMesh(0));
SAnimatedMesh* sanimmesh = new SAnimatedMesh;
sanimmesh->addMesh(tangentMesh);
node->drop();
node = smgr->addAnimatedMeshSceneNode(sanimmesh);
node->setMaterialTexture (0, oldTexture);
node->setMaterialTexture (1, texture);
node->setMaterialType(video::EMT_NORMAL_MAP_SOLID);
tangentMesh->drop();
}
I almost entirely copied the tutorial code. All I get is a white rectangle.
Code: Select all
ISceneNode* IrrSetAndAddBumpMap () {
scene::IAnimatedMesh* roomMesh = smgr->getMesh("models/rectangle.obj");
scene::ISceneNode* room = 0;
smgr->getMeshManipulator()->makePlanarTextureMapping(roomMesh->getMesh(0), 0.003f);
video::ITexture* normalMap = driver->getTexture("models/common_textures/waterbump_0.png");
driver->makeNormalMapTexture(normalMap, 9.0f);
scene::IMesh* tangentMesh = smgr->getMeshManipulator()-> createMeshWithTangents(roomMesh->getMesh(0));
room = smgr->addMeshSceneNode(tangentMesh);
room->setMaterialTexture(0, driver->getTexture("models/common_textures/water.png"));
room->setMaterialTexture(1, normalMap);
room->getMaterial(0).SpecularColor.set(0,0,0,0);
room->setMaterialFlag(video::EMF_FOG_ENABLE, true);
room->setMaterialType(video::EMT_PARALLAX_MAP_SOLID);
// adjust height for parallax effect
room->getMaterial(0).MaterialTypeParam = 0.035f;
// drop mesh because we created it with a create.. call.
tangentMesh->drop();
return room;
}