Code: Select all
// Add triangle selector
scene::ITriangleSelector* selector = 0;
selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 128);
// add a user controlled camera
scene::ICameraSceneNode* camera =
camera = smgr->addCameraSceneNode(0);
camera->setPosition(core::vector3df(-20,20,-20));
// add animated hero.
video::SMaterial material;
material.Textures[0] = driver->getTexture("characters/sydney/texture.bmp");
material.Lighting = true;
//scene::IAnimatedMeshSceneNode* node = 0;
scene::IAnimatedMesh* heromesh = smgr->getMesh("characters/sydney/amesh.md2");
if (heromesh)
{
hero = smgr->addAnimatedMeshSceneNode(heromesh);
hero->setPosition(core::vector3df(20,-15,20));
hero->setMD2Animation(scene::EMAT_STAND);
hero->setScale(core::vector3df(1.5,1.5,1.5));
hero->getMaterial(0) = material;
}
// Hero collision detection.
if (selector)
{
scene::ISceneNodeAnimator* anim =
smgr->createCollisionResponseAnimator(
selector, hero,
core::vector3df(17,25,20),
core::vector3df(0,-3,0),
core::vector3df(0,8,0));
hero->addAnimator(anim);
anim->drop();
selector->drop();
}
// Camera collision detection.
if (selector)
{
scene::ISceneNodeAnimator* cameraanim =
smgr->createCollisionResponseAnimator(
selector, camera,
core::vector3df(15,25,5),
core::vector3df(0,3,0),
core::vector3df(0,5,0));
camera->addAnimator(cameraanim);
cameraanim->drop();
selector->drop();
}