Python OpenGL glRotatef – looking for the correct multiplier

Question:

I am using gluLookAt with a camera whose coordinates are xCam, yCam and zCam. The coordinates of the object the camera is looking at are xPos, yPos, and zPos. There are variables named mouseturnX and mouseturnY, which measure the deviation of the mouse from the middle of the screen in the x-axis and the y-axis. The variable camdist describes the distance between camera and the object it looks at.

The code of the cameraposition is this:

xCam = sin(mouseturnX)*camdist+xPos
yCam = mouseturnY+yPos
zCam = cos(mouseturnX)*camdist+zPos

I now made a polygon object, which I rotate with:

glRotatef(mouseturnX,0,1,0)

Usually it should only show me the backside of the object, it does not matter which position the camera has. But now it does not turn correctly. I tried it with other rotation-axises, there it works fine, but with the y-axis it just does not want to work. I tried changing the camdist from positive to negative, the mouseturnX in the glRotatef function from positive to negative and back to positive again. It just does not work. I used glPushMatrix before the rotation command and glPopMatrix after it. One line before the rotation command I used the translate function to set a fixpoint for the polygon.

Edit: The polygon actually spins, but not in the right amount. It seems like I have to multiply the rotation of the polygon with something.

Asked By: programming_noob

||

Answers:

I found the multiplicator by trying. It is 56.5. It is not perfect, but it works.

Answered By: programming_noob
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.