Object transforms using getOpenGLMatrix

jammiedodger
Posts: 4
Joined: Tue Jul 12, 2011 11:42 am

Object transforms using getOpenGLMatrix

Post by jammiedodger »

I've successfully tied together my physics world with my custom-built Open GL ES 2 renderer. The objects in my physics world pass a transformation from getOpenGLMatrix via a user pointer packed into the object.

My problem now is rendering my objects - at the moment I have to make sure that the position/scale etc of the physics object matches the rendered object exactly. This is all fine until I want to add a modelview matrix - I want to be able to move my camera around, and I'm not sure how to proceed.

It seems wrong to have to pass my modelview matrix into the physics world - and I can't figure out how to add/multiply or otherwise use the getOpenGLMatrix matrix with my modelview matrix.

Apologies if this is really basic, my knowledge of matrix operations ain't great...

Thanks.
tea
Posts: 6
Joined: Mon Jul 18, 2011 6:42 pm

Re: Object transforms using getOpenGLMatrix

Post by tea »

Do you still need help with that?

Normally your rendering loop should look like this (schematically)

1) do some open gl setup (includes the projection matrix, model view matrix, camera setup...)
2) render your objects
3) display the result.

The only point here being, you setup your camera in step 1 so you don't need to involve any 'physics code'. Also you don't need glMultMatrix, you could uses glRotatef, glTranslatef, or gluLookAt.

I got sample code to setup a camera using btTransform and glMultMatrix; this can be used if your camera uses a btTransform for whatever reason (e.g, you have a rigid body that represents the camera in the physics world).
Is it what you're actually looking for?