Kamera in y richtig mit der Maus bewegen (Glut, C++)

Pansa

Mitglied
Hey Leute :)
Ich habe mal wieder ein kleines problemchen: Ich versuche mit der Maus meine Kamera zu bewegen.Die Kamera in richtung x-Achse zu bewegen funktioniert schon einwandfrei, aber auf der Y Achse will sie sich garnicht bewegen.
Hier mal der Quellcode für die Rotation:
Java:
oldmousex = mousex;
oldmousey = mousey;

  mousex = mousexpos;
  mousey = mouseypos;

  glTranslatef(xpos, ypos, zpos);


  if ((mousex - oldmousex) > 0)  {
	  angle += 1.0f;
  }

  else if ((mousex - oldmousex) < 0) {
      angle -= 1.0f;
  }


 rotx = lookx + sin(3.14)* mousex;
 roty = looky + -cos(3.14)* mousey ;


    glRotatef(angle, rotx, roty, 0);

Ich hoffe ihr könnt mir weiter helfen ^^.
LG Pansa
 

Pansa

Mitglied
Okay, ich bin selber drauf gekommen :)
Falls es wen interessiert, hier mal die Lösung(vllt nicht perfekt ^^):
Java:
if ((mousex - oldmousex) > 0)  {          //Für Y
	  anglex += 0.7f;
	  rotatey = true;
  }

  else if ((mousex - oldmousex) < 0) {     //Für Y
      anglex -= 0.7f;
      rotatey = true;
  }

  if ((mousey - oldmousey) > 0)  {          //Für X
	  angley += 0.7f;
	  rotatex = true;
  }

  else if ((mousey - oldmousey) < 0) {     //Für X
      angley -= 0.7f;
      rotatex = true;
  }

  glutSolidCube(2);

  if(rotatey == true){
 glRotatef(angley, 1, 0, 0);

  }

  if(rotatex == true){
 glRotatef(anglex, 0, 1, 0);

  }

LG Pansa
 

Neue Themen


Oben