Page 1 of 1

collision on animated mesh loaded with coppercube

Posted: Tue Nov 09, 2010 11:33 am
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

Posted: Tue Nov 09, 2010 3:39 pm
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();

Posted: Wed Nov 10, 2010 3:22 pm
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