movement facing climbs and slopes

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
crivipro
Posts: 20
Joined: Tue Nov 25, 2008 7:17 pm

movement facing climbs and slopes

Post by crivipro »

Hello, I have a terrain with climbs and slopes and a ant character that moves straight between diferent points randomly. Well, I am using this code:

Code: Select all

vector3df CAntCharacter::faceTarget(vector3df targetpos, vector3df nodepos)
{
  core::vector3df posDiff = targetpos - nodepos;
  f32 degree = nodepos.Y; //keep current rotation if nothing to do
  posDiff.normalize();

  if (posDiff.X != 0.0f || posDiff.Z != 0.0f)
    degree = atan2(posDiff.X,posDiff.Z) * core::RADTODEG;

  f32 degreeX = 0;
  //for example:
  //if degreeX is -40 the ant bends over up
  //if degreeX is 40 the ant bends over downwards
  //I need to detect a climb or slope to set the value of degreeX

  return vector3df(degreeX,degree,0);
}

void CAntCharacter::moveto(ISceneNode *node, vector3df vel)
{
    irr::core::matrix4 m;
    m.setRotationDegrees(node->getRotation());
    m.transformVect(vel);
    vector3df nodePosition = node->getPosition();
    node->setPosition(nodePosition + vel);
    node->updateAbsolutePosition();
}

But the thing is when the ant rises a climb I can´t do that the ant bend over up and when the ant descend a slope bend over downwards.

In the code I explain this...
Someone have any idea?

Thanks in advance.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

If it's a terrain node, you can use node->getHeight(x,y) at the front and back, then calculate the angle of the slope.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
crivipro
Posts: 20
Joined: Tue Nov 25, 2008 7:17 pm

thanks man

Post by crivipro »

Thanks for the answer, I will try it...

Greetings!
crivipro
Posts: 20
Joined: Tue Nov 25, 2008 7:17 pm

Post by crivipro »

My terrain is a irr file loaded with

Code: Select all

smgr->loadScene("media/terrain.irr");
What I can do?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Find the terrain node (see the loadIrrFile example) and save a pointer to it.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
crivipro
Posts: 20
Joined: Tue Nov 25, 2008 7:17 pm

What physic engine to use?

Post by crivipro »

Hello, I need to know what is the better physic engine to use following the next points:
- Easy to use
- No extra installations for distribution
- As I am using a terrain loaded from irr file I need to collide with it using the physic engine.

Thanks in advance
Post Reply