Setting Initial Rotation

Official forum for the Chipmunk2D Physics Library.
Post Reply
optimisticmonkey
Posts: 6
Joined: Sat May 17, 2008 1:03 pm
Contact:

Setting Initial Rotation

Post by optimisticmonkey »

I am trying to set set the initial rotation of a body before beginning a simulation.

It seems after the first step, the rotation is reset to 1,0. The attached shape is a ball, and is not in contact with anything at start.

Is there any reason that the rotation should be being reset?

Once running, the rotation changes caused by collisions work fine.

Thanks for any feedback
ker
Posts: 56
Joined: Tue Jul 15, 2008 4:13 am
Contact:

Re: Setting Initial Rotation

Post by ker »

This should not happen, are you sure you aren't doing anything after the first step? 1.0 is a very weird value since chipmunk uses radians (so 1.0 is like 70 odd degrees or something)

have you checked if setting the rotation after the first step will cause everything to work? (increases probability you are doing something to the ball)
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Setting Initial Rotation

Post by slembcke »

Are you talking about the rotation vector and mean you are setting it to the vector (1,0)?

There are several linked values in cpBody for optimization purposes. i/i_inv, m/m_inv, a/rot. You must use the setter function to set these values or you will get weird behavior.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
optimisticmonkey
Posts: 6
Joined: Sat May 17, 2008 1:03 pm
Contact:

Re: Setting Initial Rotation

Post by optimisticmonkey »

Thanks for the quick reply -

I was setting the body->rot directly....and leaving body->a unmodifed.

I will try using cpBodySetAngle instead.
Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests