I have a 3D world that works well with a camera and game objects. When the camera 'renders' it positions the matrix in the location of the camera. To do this, I call the following code:
gl.glMultMatrixf(rotationArray,0);
gl.glTranslatef(position.getX(), position.getY(), position.getZ());
Now when each object gets rendered, I call this for each object. (Note that I push and pop the matrices appropriately)
gl.glTranslatef(position.getX(), position.getY(), position.getZ());
gl.glMultMatrixf(rotationArray,0);
Now my question comes into play of when I bring models into the world, I need certain Meshes to pivot not around the 0,0,0 point, but around a different point. I have an object called Mesh that has an ArrayList of submeshes. Each mesh (and submesh) have a pivot point location. (an x,y and z float).
Where do I translate the matricies so I pivot around the designated point? I've tried all sorts of combinations and nothing works!
Example:
gl.glTranslatef(position.getX(), position.getY(), position.getZ());
gl.glMultMatrixf(rotationArray,0);
gl.glTranslatef(pivotPoint.getX(),pivotPoint.getY(),pivotPoint.getZ());
and I've tried
gl.glTranslatef(pivotPoint.getX(),pivotPoint.getY(),pivotPoint.getZ());
gl.glMultMatrixf(rotationArray,0);
gl.glTranslatef(position.getX(), position.getY(), position.getZ());