Page 1 of 1

rolling ball

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

Posted: Tue Nov 09, 2010 3:35 pm
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

Posted: Tue Nov 09, 2010 10:30 pm
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:

Posted: Wed Nov 10, 2010 1:58 pm
by xtravanta
Thanks for the response guys.. :) iam going to try it as soon as i'm home :)

Posted: Wed Nov 10, 2010 5:29 pm
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 ?

Posted: Wed Nov 10, 2010 5:50 pm
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)

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

Posted: Thu Nov 11, 2010 6:33 am
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.