Frage

Ich möchte ein Licht in meine 3D-Welt einstellen, in einer Ecke positioniert, und wenn ich mit meiner Maus bewegt, möchte ich, dass ich dort bleibt und einfach nur ist.

Wenn ich die Funktion von Glut nütze: glutolidsphäre, sieht alles in Ordnung aus. Aber wenn ich ein Quad in meiner Welt hinzufüge, und ich wechsle mit meiner Maus, die Beleuchtung auf den Quad ändert sich.Jede Idee, wie man das lösen soll? generasacodicetagpre.

, also hat ich den leichten Anruf nach dem camera_setup () eingestellt Aber jetzt funktioniert der Quad immer noch nicht, da ich es will.Das Licht ändert sich immer noch und ich bin mir ziemlich sicher, dass meine Normalen korrekt sind (zweimal geprüft).

Ich dachte, ist das möglich, weil ich meine _camposx nicht y, z-Werte ändere, wenn ich mich bewegt / drehe?

War es hilfreich?

Lösung

Calling gluLookAt before glRotate / glTranslate should help...

Other thoughts :

  • call glMatrixMode and glLoadIdentity only once, in camera::setup.
  • don't call glRotate and glTranslate in camera::setup. This has nothing to do with the camera. This is your object's tranformation
  • Wrap glRotate and glTranslate inside glPushMatrix/glPopMatrix. This way, the next time you draw an object, transformations won't be cummulated.
  • glTranslatef(0.0f, 0.0f, 0.0f) is useless. It means : add a null displacement to the current matrix. In other words: don't do anything
  • wrapping pushmatrix/popmatrix around this is thus useless
  • As datenwolf said, I don't see where you actually indicate the light's position

Andere Tipps

You must set the lights' positions after moving the world / setting the camera i.e. add

glLightfv(GL_LIGHT0+n, GL_POSITION, light_position)

calls right after

camera->setup();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top