rolling ball

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

rolling ball

Post by xtravanta »

Hi,

iam trying to rotate a ball in the direction the ball is going..
but iam not sure how to do this..

maby you guys can help me out a little :)

ball positioning is done with

Code: Select all


vector3df pos = vector3df(x,y,z);

ball_node->setPosition(pos);

And also iam wondering if the ball rolls off a curtain angled wall.. that its speed increases.. does it have something to do with the animator velocity ?

Greets Xtravanta
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

Maybe its not the best suggestion, but maybe you would like to use physics engine? You would get realistic physics with little effort. http://irrlicht.sourceforge.net/tut_newton.html
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

If you just need to animate your ball without a physic engine that's simple. The ball is rolling, so the collision point between the ball and the ground have the same velocity from the ball moving space and from world space (floor space).
So linearVelocity=angularVelocity*radius.

for exemple if you want to move your ball with a constant x speed, rolling on the z axis you will do like that :

Code: Select all

//init
float linearSpeed=2.0;
float radius=10.0;

//each update :
now=getTime();
timeFactor=(now-lastTime)/1000;
lastTime=now;

myBall.x+=linearSpeed*timeFactor;
myBall.rotationZ+=linearSpeed*timefactor/radius;
:wink:
xtravanta
Posts: 9
Joined: Tue Nov 09, 2010 11:18 am

Post by xtravanta »

Thanks for the response guys.. :) iam going to try it as soon as i'm home :)
xtravanta
Posts: 9
Joined: Tue Nov 09, 2010 11:18 am

Post by xtravanta »

@roxaz
I looks like newton isn't compatible with irrlicht 1.7.1 :( correct me if iam wrong...

@stefbuet
it needs physics... it rolls over many obstacles with all kind of degrees..
But does this code work to make it look like the ball is rolling in a curtain direction ?
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

xtravanta wrote:@roxaz
I looks like newton isn't compatible with irrlicht 1.7.1 :( correct me if iam wrong...
tutorial is a bit outdated, but i got it running, there is no reason why it would not work with 1.7.1. check out official tutorial http://www.newtondynamics.com/wiki/inde ... _tutorial)
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

@roxaz
I looks like newton isn't compatible with irrlicht 1.7.1 Sad correct me if iam wrong...
tutorial is a bit outdated, but i got it running, there is no reason why it would not work with 1.7.1. check out official tutorial http://www.newtondynamics.com/wiki/inde ... _tutorial)
xtravanta you know that newton isn't the only (or the best) physics engine out there. :wink: You also might want to consider using a wrapper.
multum in parvo
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

Adler1337 wrote:
@roxaz
I looks like newton isn't compatible with irrlicht 1.7.1 Sad correct me if iam wrong...
tutorial is a bit outdated, but i got it running, there is no reason why it would not work with 1.7.1. check out official tutorial http://www.newtondynamics.com/wiki/inde ... _tutorial)
xtravanta you know that newton isn't the only (or the best) physics engine out there. :wink: You also might want to consider using a wrapper.
with that said existing alternatives to newton are:
http://www.ode.org/
http://www.bulletphysics.com/
http://developer.nvidia.com/object/physx.html

and this is probably not all, but these are most famous ones
also it is probably fair to say that newton even if its not the best one on the scene - it is fairly easy to use.
Post Reply