B@z wrote:well i looked at this and searched again for a few hours but i dont seem to get this code to work in my project or find a other code that i could use
could someone put his code in my code(first post)??
i hope someone can help me further
spearfire
i think this should work
Code: Select all
scene::IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();
scene::ITriangleSelector * selector;
AnimatedMesh* indu = smgr->getMesh("c:/irrlicht-1.4/media/indus.X");
IAnimatedMeshSceneNode* s = smgr->addAnimatedMeshSceneNode( indu );
if (s)
{
s = smgr->addAnimatedMeshSceneNode(indu); // you should delete it. it creates the same model twice..
s->setMaterialFlag(EMF_LIGHTING, true);
s->setPosition(core::vector3df(2150*10,30*2,3650*2));
s->setScale(core::vector3df(8,8,8));
s->setRotation(core::vector3df(-90,0,0));
s->addShadowVolumeSceneNode();
smgr->setShadowColor(video::SColor(220,0,0,0));
selector = smgr->createTriangleSelector(s->getMesh(),s);
meta->addTriangleSelector(selector);
selector->drop();
}
my camera only with collisions for my terrain
//my camera
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,45.0f,650.0f);
camera->setPosition(core::vector3df(1900*10,255*2,3700*2));
camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
camera->setFarValue(12000.0f);
scene::ISceneNodeAnimator* anim =
smgr->createCollisionResponseAnimator(meta, camera, core::vector3df(30,30,30),core::vector3df(0,-3,0),core::vector3df(0,50,0));
meta->drop();
camera->addAnimator(anim);
anim->drop();
Thank you verry much i changed your code a bit becaus at first it did not work
but now it finaly WORKS!!! (if you enter the object i gets a bit buggy) i got collisions with my terrain and my model
now i can finaly continue my project
again thank you very much and every one else who helped me
here is my working code for if someone else doesnt get his collisions right
Code: Select all
IAnimatedMesh* indu = smgr->getMesh("c:/irrlicht-1.4/media/waren.X");
IAnimatedMeshSceneNode* s = smgr->addAnimatedMeshSceneNode( indu );
scene::IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();
scene::ITriangleSelector * selector1;
if (s)
{
s->setMaterialFlag(EMF_LIGHTING, true);
s->setPosition(core::vector3df(2000*10,30*2,3650*2));
s->setScale(core::vector3df(8,8,8));
s->setRotation(core::vector3df(-90,-90,0));
s->addShadowVolumeSceneNode();
smgr->setShadowColor(video::SColor(220,0,0,0));
selector1 = smgr->createTriangleSelector(s->getMesh(),s);
meta->addTriangleSelector(selector1);
selector1->drop();
}
//my camera
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,45.0f,650.0f);
{
if(camera)
camera->setPosition(core::vector3df(1900*10,255*2,3700*2));
camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
camera->setFarValue(12000.0f);
scene::ISceneNodeAnimator* anim =
smgr->createCollisionResponseAnimator(meta, camera, core::vector3df(30,30,30),core::vector3df(0,-3,0),core::vector3df(0,50,0));
meta->drop();
camera->addAnimator(anim);
anim->drop();
scene::ISceneNodeAnimator* an =
smgr->createCollisionResponseAnimator(selector, camera, core::vector3df(30,30,30),core::vector3df(0,0,0),core::vector3df(0,50,0));
selector->drop();
camera->addAnimator(an);
an->drop();
}