rotation in 3d
Well, the past hour or so has been a very exciting time for me.
I managed to get texture mapping for my 3d models to work, and not only that, I am now able to move my models around the screen using my wrapper class MODEL_DTP.
However, there is still one function I am working on implementing, and it has me baffled.
The function is RotateMesh ( ). It is a function that I am trying to write for my wrapper class.
The objective of RotateMesh is to rotate a certain mesh specified by a variable meshID a certain number of radians on an axis specified by axisID.
Now, this function has a larger scope than rotating a single mesh. It is also called by the RotateModel function. The RotateModel function rotates the entire 3d model a certain amount of radians on a certain axis specified by axisID.
I am unsure of how to implement the RotateMesh function.
I cannot use glRotatef() because that rotates the entire scene, does it not?
Therefore, I would be rotating my entire landscape in the process of doing a glRotatef().
I just want to rotate each single individual mesh, and in some cases, the entire model, but never the entire scene.
Anybody have any idea how I would accomplish this?
youd need to do something like this:
// draw everything else
// rotation here
// drawing here
the rotation done after the push matrix would only apply to the objects within that push/pop block
You need to rotate your model in local space realtive to the x,y,z axes. This must be done prior to transforming your vertexes to world and view space.
I'm not sure how to do it in OpenGL because I don't use it. But your rotational matrices should not change - what they hold will.
First rotate, scale, and translate your model in local space. Transform it to world space. Rotate, scale, and translate in world space and then clear all matrices back to the indentity matrix. Now rotate, scale, and translate into view space. Perform perspective transformation on the view space vertexes to get screen space.
...'s reply was exactly what i needed. :)