Autor Beitrag
Pascal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Mi 10.12.03 20:45 
Ich möchte, wie der Titel schon sagt, ein Licht in eine Opengl Scene einfügen. Dabei sind mir Schatten(,die von Objekten auf andere geworfen werden,) nicht so wichtig, sondern vor allem, dass man gleichfarbige Rechtecke durch unterschiedliche Sichtwinkel unterscheiden kann. Ich suche eine möglichst einfache Methode, die zusammen mit Opengl12.pas funktioniert.

Kann mir da jemand einen Tip geben wie das am besten geht?
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Fr 12.12.03 22:20 
Hallo,

1) Licht-Unterstützung aktivieren:
ausblenden Delphi-Quelltext
1:
glEnable(GL_LIGHTING);					

2) Einzelnes Licht aktivieren
ausblenden Delphi-Quelltext
1:
glEnable(GL_LIGHT0 + n); // n = Licht-Index, 0 = erstes Licht usw.					

3) mit glLight() die Parameter setzen (Position, Farbe, Art). Onlinehilfe lesen, da gibt es dutzende von Möglichkeiten, wie Spotlights, Ambient-Licht (Hintergrundlicht), Diffuse-Licht (Steulicht), verscheidene Richtungen und Winkel, usw.

PS: Einfach zu implementieren, aber Hardwarehungirg! Geeignet für CAD oder so was, abr in Spielen bitte Lightmaps (oder Vertexlight) verwenden!

_________________
Life is a bad adventure, but the graphic is really good!
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 13.12.03 15:30 
Pascal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Sa 13.12.03 15:54 
Danke!
Werde ich beides mal ausprobieren.
Pascal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Mo 15.12.03 17:51 
Danke.
Bei Modellen funktioniert es jetzt.

Aber andere Polygons wie z.B.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
  glBegin(GL_POLYGON);
    glColor4f(0, 1, 0, 0.5);
    glVertex3f(-1.0,  1.0, -1.0);
    glVertex3f(-1.0,  1.0,  1.0);
    glVertex3f( 1.0,  1.0,  1.0);
    glVertex3f( 1.0,  1.0, -1.0); 
  glEnd;
werden dadurch dunkel und gleichfarbig. Muss ich da noch was hinzufügen, damit die auch normal beleuchtet werden?
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mo 15.12.03 19:09 
du musst damit es richtig beleuchtet wird noch die Normale angeben :
ausblenden Delphi-Quelltext
1:
glNormal3f(x,y,z);					
Pascal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Mo 15.12.03 19:33 
Danke