collision on animated mesh loaded with coppercube

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
xtravanta
Posts: 9
Joined: Tue Nov 09, 2010 11:18 am

collision on animated mesh loaded with coppercube

Post by xtravanta »

Hi,,

iam trying to get a collision on a animated mesh format ".x"

iam getting the node like this..

Code: Select all

smgr->getSceneNodeFromName("AnimatedMesh1");
and if iam correct you need to make a triangle selector

Code: Select all

ITriangleSelector* selector=0;

selector = smgr->createTriangleSelectorFromBoundingBox(smgr->getSceneNodeFromName("AnimatedMesh1"));
But i think iam forgetting something..

Any suggetions?

Greets Xtravanta
RuggJack93
Posts: 39
Joined: Mon Sep 06, 2010 5:09 pm
Location: Italy

Post by RuggJack93 »

You also have to create a collision response animator and add it to the node you want to collide:

Code: Select all

scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
			selector, node, core::vector3df(30,50,30),
			core::vector3df(0,-10,0), core::vector3df(0,30,0));
		selector->drop();  it.
		node->addAnimator(anim);
		anim->drop();
xtravanta
Posts: 9
Joined: Tue Nov 09, 2010 11:18 am

Post by xtravanta »

i finaly got it working..

i needed to @ it to my meta selector.. because i already added a animator to my player node..

so now it is working

Code: Select all


// loop over all of the nodes
// then in a switch
case ESNT_ANIMATED_MESH:
                selector = smgr->createTriangleSelector(((IAnimatedMeshSceneNode*)node)->getMesh(), node);
            break;


// after that

if(selector)
        {
            // Add it to the meta selector, which will take a reference to it
            meta->addTriangleSelector(selector);
            // And drop my reference to it, so that the meta selector owns it.
            selector->drop();
        }

// after adding the selector to the meta

anim = smgr->createCollisionResponseAnimator(meta, player_node, vector3df(10,10,10), vector3df(vx,vy,vz));
    player_node->addAnimator(anim);

so thanks for the help guys
Post Reply