Hello I am new to this forum and relatively new to openGL programming. I have been programming with openGL for about 2 months now with android and I have had a lot of progression in the 2D aspect of it.
I understand the concepts of glRotate and Translate in the 2D worlds but when I add the third Dimension Z things get confusing for me.
Basically what I am trying to accomplish is a 3D scene. I have created my ground plane and a few models using Ogre I converted those models to an XML Mesh and loaded it into my openGL project. I load my models into my 3D environment and they are lying sideways. So I have to rotate them 90 degrees on the x axis to make them stand upright. No problem there, I load my windmill object and rotate it 90 as well, I then rotate that object 45 degrees along the z axis so that from my current view I can see the front and side of it at the same time. Now I load my windmills fan blades. I rotate 90 degrees and then 45 degrees so that it is fitting properly where it should in my windmill object.
The problem starts here. I would like to rotate those windmill fans around as if the wind where blowing them. I tried to rotate it on the y axis like I believe I should but the problem is, it doesn’t rotate it around the models center it rotates completely around the screens as if I was rotating it around a point much below the bottom of my screen.
I was told I need to translate the object, rotate the object then translate it back to accomplish what I need but I cant seem to understand how to do that.
Someone please let me know how I can accomplish this. Thank you.
I have attached my drawing code for the windmill etc please let me know how I can fix this.
I also probably dont have the best setup here in terms of this but I am new to openGL and if you see something in my code that doesn’t look like the best approach please let me know.
glPushMatrix(); glTranslatef(0,-0.95f,1); glScalef(0.015f, 0.015f, 0.015f); glRotatef(0f, 0, 1, 0); glRotatef(-90f, 1, 0, 0); glBindTexture(GL_TEXTURE_2D, textures); ground.draw(gl); glPopMatrix(); glPushMatrix(); glTranslatef(0,-0.95f,1); glScalef(0.0015f, 0.0015f, 0.0015f); glRotatef(-90f, 1, 0, 0); glRotatef(-45f, 0, 0,1); glBindTexture(GL_TEXTURE_2D, textures); windmill.draw(gl); glPopMatrix(); glPushMatrix(); glLoadIdentity(); glTranslatef(0,-0.95f,1); glScalef(0.0015f, 0.0015f, 0.0015f); glRotatef(-90f, 1, 0, 0); glRotatef(angle, 0, 1,0); glBindTexture(GL_TEXTURE_2D, textures); windmillfan.draw(gl); glPopMatrix();