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()
{
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-10,0),
core::vector3df(0,30,0));
core::vector3df(0,-10,0), core::vector3df(0,30,0));
selector->drop(); // As soon as we're done with the selector, drop it.
camera->addAnimator(anim);
anim->drop(); // And likewise, drop the animator when we're done referring to it.
......@@ -178,22 +177,22 @@ int main()
bill->setSize(core::dimension2d<f32>(20.0f, 20.0f));
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.
// They all animate quite slowly, to make it easier to see that accurate triangle
// selection is being performed.
/* 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
selection is being performed. */
scene::IAnimatedMeshSceneNode* node = 0;
// Add an MD2 node, which uses vertex-based animation.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/faerie.md2"),
0,
IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setPosition(core::vector3df(-70,-25,-120)); // Put its feet on the floor.
0, IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setPosition(core::vector3df(-70,-15,-120)); // Put its feet on the floor.
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);
video::SMaterial material;
material.setTexture(0, driver->getTexture("../../media/faerie2.bmp"));
material.Lighting = true;
material.NormalizeNormals = true;
node->getMaterial(0) = material;
// Now create a triangle selector for it. The selector will know that it
......@@ -204,8 +203,7 @@ int main()
// This X files uses skeletal animation, but without skinning.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/dwarf.x"),
0,
IDFlag_IsPickable | IDFlag_IsHighlightable);
0, IDFlag_IsPickable | IDFlag_IsHighlightable);
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->setAnimationSpeed(20.f);
......@@ -215,12 +213,12 @@ int main()
// And this B3D file uses skinned skeletal animation.
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"),
0,
IDFlag_IsPickable | IDFlag_IsHighlightable);
0, IDFlag_IsPickable | IDFlag_IsHighlightable);
node->setScale(core::vector3df(10, 10, 10));
node->setPosition(core::vector3df(-70,-66,-60));
node->setRotation(core::vector3df(0,90,0));
node->setAnimationSpeed(10.f);
node->getMaterial(0).NormalizeNormals = true;
// Just do the same as we did above.
selector = smgr->createTriangleSelector(node);
node->setTriangleSelector(selector);
......@@ -231,8 +229,7 @@ int main()
// Add a light, so that the unselected nodes aren't completely dark.
scene::ILightSceneNode * light = smgr->addLightSceneNode(0, core::vector3df(-60,100,400),
video::SColorf(1.0f,1.0f,1.0f,1.0f),
600.0f);
video::SColorf(1.0f,1.0f,1.0f,1.0f), 600.0f);
light->setID(ID_IsNotPickable); // Make it an invalid target for selection.
// Remember which scene node is highlighted
......@@ -272,17 +269,17 @@ int main()
// Irrlicht provides other types of selection, including ray/triangle selector,
// ray/box and ellipse/triangle selector, plus associated helpers.
// See the methods of ISceneCollisionManager
scene::ISceneNode * selectedSceneNode = collMan->getSceneNodeAndCollisionPointFromRay(
scene::ISceneNode * selectedSceneNode =
collMan->getSceneNodeAndCollisionPointFromRay(
ray,
intersection, // This will be the position of the collision
hitTriangle, // This will be the triangle hit in the collision
IDFlag_IsPickable, // This ensures that only nodes that we have
// 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
// the triangle that was hit.
// If the ray hit anything, move the billboard to the collision position
// and draw the triangle that was hit.
if(selectedSceneNode)
{
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