glRotatef does not what it should, if the y-axis is selected

Hello, I have a problem with the function glRotatef in Python. You can see in the following code, that the class Testy decribes a red triangular object which has a camera, that rotates around it with an angle that is defined in the method mouseturn(). Shortly said, the angle is called mouseturnX. The object rotates around its own axis with an angle called remindturn. In the method remindtheturn() it is defined, that remindturn is equivalent to mouseturnX, when the key ‘w’ is pressed. If the key is not pressed, reminturn remembers the last angle of mouseturnX from back when ‘w’ was pressed. In that way, if ‘w’ is pressed, the object should alway point towards the camera with its back. Here comes the problem: It does not do so. The strange thing is, that this method of reminturn remembering mouseturnX seems to work fine if I select the x-axis or the z-axis at glRotatef. But as soon as I select the y-axis, it does not work. What am I doing wrong? I am pretty desperate for an answer.
I additionally use pygame, sys and math as libraries.

class Testy :
    def __init__(self):
        self.xPos = 0
        self.yPos = 0
        self.zPos = 0
        self.xCam = 0
        self.yCam = 0
        self.zCam = 0
        self.camdist = -400
        self.keypressed = False
        self.mouseturnX = 0
        self.mouseturnY = 0
        self.remindturn = 0
    def draw(self):
        OpenGL.GL.glTranslate(self.xPos, self.yPos, self.zPos)
        OpenGL.GL.glRotatef(self.remindturn, 0, 1, 0)
        OpenGL.GL.glVertex3f(self.xPos-100, self.yPos+50, self.zPos)
        OpenGL.GL.glVertex3f(self.xPos + 100, self.yPos + 50, self.zPos)
        OpenGL.GL.glVertex3f(self.xPos, self.yPos -50, self.zPos)
    def feel(self , event):
        if event.type == pygame.KEYDOWN :
            if event.key == pygame.K_w :
                self.keypressed = True
        if event.type == pygame.KEYUP :
            if event.key == pygame.K_w :
                self.keypressed = False
    def mouseturn(self):
        mouse_pos = pygame.mouse.get_pos()
        if mouse_pos[0] > 250 :
            self.mouseturnX = (mouse_pos[0] - 250) * 0.1
        if mouse_pos[0] < 250 :
            self.mouseturnX = (-250 + mouse_pos[0])*0.1
        if mouse_pos[1] > 250 :
            self.mouseturnY = -(mouse_pos[1] -250) *0.5
        if mouse_pos[1] < 250 :
            self.mouseturnY = -(-250 + mouse_pos[1])*0.5
    def remindtheturn(self):
        if self.keypressed == True :
            self.remindturn = self.mouseturnX
            print("Does what it should")
            print(f"This is the turn{self.remindturn}")
    def camera(self):
        self.xCam = math.sin(self.mouseturnX) * self.camdist + self.xPos
        self.yCam = self.yPos + self.mouseturnY
        self.zCam = math.cos(self.mouseturnX) *self.camdist + self.zPos
        OpenGL.GL.glViewport(0,0, 500, 500)
        OpenGL.GLU.gluPerspective(60, (500/500), 0.1, 10000.0)
        OpenGL.GLU.gluLookAt(self.xCam, self.yCam, self.zCam, self.xPos, self.yPos, self.zPos, 0, 1, 0)

Thank you for reading, thank you for your time.

Edit: The polygon actually does spin, but not in the right amount. It seems like I need a multiplier for remindturn, but I do not know how to find it.

I found a multiplicator for the formula. It is now remindturn = mouseturnX*multiplicator. The Mmultiplicator is 56.5. It is not perfect, but it works.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.