Chipmunk with OpenGL

Official forum for the Chipmunk2D Physics Library.
Post Reply
budhest
Posts: 1
Joined: Mon Dec 31, 2007 5:44 pm
Contact:

Chipmunk with OpenGL

Post by budhest »

Hey what's up, I'm new to chipmunk! I have a project I've been working on that uses OpenGL for all of its rendering, and I want to incorporate chipmunk into it just to see how things work. I was pretty surprised to find how easy it was to compile chipmunk as a DLL/LIB with MSVC++ EE 2005. After looking at the moon buggy code, I added in a static body with a single line (as a ground plane) and a body (a box) to fall onto the line segment.

Now, I can get a representation on the screen by drawing a quad at the "p" component of the box's cpBody. This doesn't include rotation information obviously, and I'm hesitant to start applying a mathematical rotation to my quad since it seems like that data must already be present somewhere. The readme that comes with the moon buggy tutorial states: "you should use the rigid bodies to determine where to draw your sprites." What does this mean exactly?

What is the best way (most efficient, least computationally expensive) to draw my quads based on the chipmunk physics data?
X-0ut
Posts: 28
Joined: Tue Oct 02, 2007 5:02 am
Contact:

Re: Chipmunk with OpenGL

Post by X-0ut »

Full example is in the demo src.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Chipmunk with OpenGL

Post by slembcke »

The cpBody struct has both a position vector (.p) and a rotation value in a radians (.a). Use those to apply a transformation to the quad.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests