Commit c8bdc67d authored by hybrid's avatar hybrid

Fixed lighting of the models.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2314 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 316139af
...@@ -155,8 +155,7 @@ int main() ...@@ -155,8 +155,7 @@ int main()
{ {
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator( scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30), selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-10,0), core::vector3df(0,-10,0), core::vector3df(0,30,0));
core::vector3df(0,30,0));
selector->drop(); // As soon as we're done with the selector, drop it. selector->drop(); // As soon as we're done with the selector, drop it.
camera->addAnimator(anim); camera->addAnimator(anim);
anim->drop(); // And likewise, drop the animator when we're done referring to it. anim->drop(); // And likewise, drop the animator when we're done referring to it.
...@@ -178,22 +177,22 @@ int main() ...@@ -178,22 +177,22 @@ int main()
bill->setSize(core::dimension2d<f32>(20.0f, 20.0f)); bill->setSize(core::dimension2d<f32>(20.0f, 20.0f));
bill->setID(ID_IsNotPickable); // This ensures that we don't accidentally ray-pick it bill->setID(ID_IsNotPickable); // This ensures that we don't accidentally ray-pick it
// Add 3 animated hominids, which we can pick using a ray-triangle intersection. /* Add 3 animated hominids, which we can pick using a ray-triangle intersection.
// They all animate quite slowly, to make it easier to see that accurate triangle They all animate quite slowly, to make it easier to see that accurate triangle
// selection is being performed. selection is being performed. */
scene::IAnimatedMeshSceneNode* node = 0; scene::IAnimatedMeshSceneNode* node = 0;
// Add an MD2 node, which uses vertex-based animation. // Add an MD2 node, which uses vertex-based animation.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/faerie.md2"), node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/faerie.md2"),
0, 0, IDFlag_IsPickable | IDFlag_IsHighlightable);
IDFlag_IsPickable | IDFlag_IsHighlightable); node->setPosition(core::vector3df(-70,-15,-120)); // Put its feet on the floor.
node->setPosition(core::vector3df(-70,-25,-120)); // Put its feet on the floor.
node->setScale(core::vector3df(2, 2, 2)); // Make it appear realistically scaled node->setScale(core::vector3df(2, 2, 2)); // Make it appear realistically scaled
node->setMD2Animation(scene::EMAT_RUN); node->setMD2Animation(scene::EMAT_POINT);
node->setAnimationSpeed(20.f); node->setAnimationSpeed(20.f);
video::SMaterial material; video::SMaterial material;
material.setTexture(0, driver->getTexture("../../media/faerie2.bmp")); material.setTexture(0, driver->getTexture("../../media/faerie2.bmp"));
material.Lighting = true; material.Lighting = true;
material.NormalizeNormals = true;
node->getMaterial(0) = material; node->getMaterial(0) = material;
// Now create a triangle selector for it. The selector will know that it // Now create a triangle selector for it. The selector will know that it
...@@ -204,8 +203,7 @@ int main() ...@@ -204,8 +203,7 @@ int main()
// This X files uses skeletal animation, but without skinning. // This X files uses skeletal animation, but without skinning.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/dwarf.x"), node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/dwarf.x"),
0, 0, IDFlag_IsPickable | IDFlag_IsHighlightable);
IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setPosition(core::vector3df(-70,-66,0)); // Put its feet on the floor. node->setPosition(core::vector3df(-70,-66,0)); // Put its feet on the floor.
node->setRotation(core::vector3df(0,-90,0)); // And turn it towards the camera. node->setRotation(core::vector3df(0,-90,0)); // And turn it towards the camera.
node->setAnimationSpeed(20.f); node->setAnimationSpeed(20.f);
...@@ -215,12 +213,12 @@ int main() ...@@ -215,12 +213,12 @@ int main()
// And this B3D file uses skinned skeletal animation. // And this B3D file uses skinned skeletal animation.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"), node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"),
0, 0, IDFlag_IsPickable | IDFlag_IsHighlightable);
IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setScale(core::vector3df(10, 10, 10)); node->setScale(core::vector3df(10, 10, 10));
node->setPosition(core::vector3df(-70,-66,-60)); node->setPosition(core::vector3df(-70,-66,-60));
node->setRotation(core::vector3df(0,90,0)); node->setRotation(core::vector3df(0,90,0));
node->setAnimationSpeed(10.f); node->setAnimationSpeed(10.f);
node->getMaterial(0).NormalizeNormals = true;
// Just do the same as we did above. // Just do the same as we did above.
selector = smgr->createTriangleSelector(node); selector = smgr->createTriangleSelector(node);
node->setTriangleSelector(selector); node->setTriangleSelector(selector);
...@@ -231,8 +229,7 @@ int main() ...@@ -231,8 +229,7 @@ int main()
// Add a light, so that the unselected nodes aren't completely dark. // Add a light, so that the unselected nodes aren't completely dark.
scene::ILightSceneNode * light = smgr->addLightSceneNode(0, core::vector3df(-60,100,400), scene::ILightSceneNode * light = smgr->addLightSceneNode(0, core::vector3df(-60,100,400),
video::SColorf(1.0f,1.0f,1.0f,1.0f), video::SColorf(1.0f,1.0f,1.0f,1.0f), 600.0f);
600.0f);
light->setID(ID_IsNotPickable); // Make it an invalid target for selection. light->setID(ID_IsNotPickable); // Make it an invalid target for selection.
// Remember which scene node is highlighted // Remember which scene node is highlighted
...@@ -272,17 +269,17 @@ int main() ...@@ -272,17 +269,17 @@ int main()
// Irrlicht provides other types of selection, including ray/triangle selector, // Irrlicht provides other types of selection, including ray/triangle selector,
// ray/box and ellipse/triangle selector, plus associated helpers. // ray/box and ellipse/triangle selector, plus associated helpers.
// See the methods of ISceneCollisionManager // See the methods of ISceneCollisionManager
scene::ISceneNode * selectedSceneNode = collMan->getSceneNodeAndCollisionPointFromRay( scene::ISceneNode * selectedSceneNode =
collMan->getSceneNodeAndCollisionPointFromRay(
ray, ray,
intersection, // This will be the position of the collision intersection, // This will be the position of the collision
hitTriangle, // This will be the triangle hit in the collision hitTriangle, // This will be the triangle hit in the collision
IDFlag_IsPickable, // This ensures that only nodes that we have IDFlag_IsPickable, // This ensures that only nodes that we have
// set up to be pickable are considered // set up to be pickable are considered
0 // Check the entire scene (this is actually the implicit default) 0); // Check the entire scene (this is actually the implicit default)
);
// If the ray hit anything, move the billboard to the collision position and draw // If the ray hit anything, move the billboard to the collision position
// the triangle that was hit. // and draw the triangle that was hit.
if(selectedSceneNode) if(selectedSceneNode)
{ {
bill->setPosition(intersection); bill->setPosition(intersection);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment