Climbing walls

redhead

29-06-2009 11:52:22

Hi,
I am trying to create mech-spider thing, that can climb walls. Does anybody know how to to do that?? I dont want any kind of dynamic animation system like in other threat about spider dynamic animations. What I need is a simple ellipsoid collision, whose y-axes points in the same direction as normal vector of surface his crawling on. But I dont know how to "get" surface normal, nor how to handle (vertical) corners where it can touch 2 (or more) surfaces at a time.

Any suggestion is welcome.
thanks

koirat

29-06-2009 22:32:42

Newton returns normal to surface when raycasting as i remember correctly.

redhead

30-06-2009 09:59:14

I was thinking of Collision Callback, isnt there a normal vector too?? The problem is I have to create that callback for every material pair, which is very exhausting. Isnt there some option to call the callback for any collision for any material?

Raycasting is, I thing, very expensive, I would have to create more than one cast, because I need to track the surface it is crawling on and a surface in front of it (ie. from horizontal surface to vertical surface, corners...).
But I dont know it that well, so if you can help me little further with this, it would be great!

thanks

Virginie

30-06-2009 10:57:27

When a collision is detected the function onAABBOverlap is called. In this function you can choose to call or no the real callback for collision : contactsProcess (return 1 to continue and 0 to stop callback for the pair of bodies).
In contactsProcess you can take the type of you body and doing somthing different in function of type.

For exemple :

CallbackCollision::contactsProcess( OgreNewt::ContactJoint &p_ContactJoint, Ogre::Real p_TimeStep, int p_ThreadIndex)
{

if((p_Body0->getType()==2) || (p_Body1->getType()==2))
return 1;
else
return 0;

}

CallbackCollision::contactsProcess( OgreNewt::ContactJoint &p_ContactJoint, Ogre::Real p_TimeStep, int p_ThreadIndex)
{

if((p_ContactJoint.getBody0()->getType()==2) && (p_ContactJoint.getBody1()->getType()==2))
{
// do something
}

if((p_ContactJoint.getBody0()->getType()==2) && (p_ContactJoint.getBody1()->getType()==0))
{
// do something else
}
...
}

redhead

30-06-2009 15:13:38

This is featured in Newton 2.0, am I not right?
Damn, I got to upgrade it...

thanks, I will look into it

Virginie

01-07-2009 12:21:31

Yes it's in Newton 2.0 but they are an equivalent in 1.53 version :

ContactCallback::userBegin() equivalent to onAABBOverlap
and ContactCallback::userProcess() equivalent to contactsPorcess

but I don't use this version so I don't know how to keep bodies in functions.

And I see I've done an error in the precedent exemple the first function is :
CallbackCollision::onAABBOverlap( OgreNewt::Body* p_Body0, OgreNewt::Body* p_Body1, int p_ThreadIndex)
{

if((p_Body0->getType()==2) || (p_Body1->getType()==2))
return 1;
else
return 0;

}

and the second :
CallbackCollision::contactsProcess( OgreNewt::ContactJoint &p_ContactJoint, Ogre::Real p_TimeStep, int p_ThreadIndex)
{

if((p_ContactJoint.getBody0()->getType()==2) && (p_ContactJoint.getBody1()->getType()==2))
{
// do something
}

if((p_ContactJoint.getBody0()->getType()==2) && (p_ContactJoint.getBody1()->getType()==0))
{
// do something else
}
...
}

redhead

01-07-2009 12:30:51

ok, I got it.
But those callbacks are possible to create only with material pairs, no?
I have to do it for all material pairs (but that means I have to specify this callbacks for all pairs - coded one by one)

Isnt there possibility to create callback for all collisions for all materials with one call??

Virginie

01-07-2009 13:22:57

Yes, you can call the same callback for all your material pair and do in the function like my exemple a switch on types of bodies.
But you must indicate for each materalPair the new Callback even it's the same for all. But it's just a much line by materialPair :)

Excuse me for my english and if I don't understand sometimes that you wants :)