Autor Beitrag
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Fr 09.09.05 19:58 
Hallo,

ich hätte hier ne' Frage an die OpenGL Leute.
Ich habe mehrere Objekte, die möchte ich jetzt unabhängig voneinander Drehen.
Also etwa so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
glBegin(GL_QUADS);
  ...
glEnd;
glRotate3f(4110);

glBegin(GL_TRIANGELS);
  ...
glEnd;
glRotate3f(2010);


Leider funktioniert das nicht so, wie ich's mir eben vorgestellt habe :evil:
Müsste das nicht irgendwie mit den Matrizen gehen?


Danke schon mal im voraus! :D
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Fr 09.09.05 20:02 
du kannst die Matrix vor dem verändern "pushen" und danach wieder "poppen", dann ist sie wie im Ausgangszustand für die nächsten Matrixoperationen:
wiki.delphigl.com/index.php/GlPushMatrix
Chryzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Fr 09.09.05 20:09 
Also irgendwie geht's bei mir nicht.
Mein Code sieht jetzt so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
  glPushMatrix;

         glRotatef(1010);

  glBegin(GL_QUADS);
  glVertex3f(-500, -50);
  glVertex3f(-50070);
  glVertex3f(60070);
  glVertex3f(600, -50);
  glEnd;

  glPopMatrix;

  glColor3f(0.90.90.9);
  glBegin(GL_QUADS);
  glVertex3f(000);
  glVertex3f(090);
  glVertex3f(1090);
  glVertex3f(1000);
  glEnd;


dann dürfte doch eigentlich nur der erste Quader gedreht werden, oder :?:
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 09.09.05 20:15 
Probier mal kurz das hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
glPushMatrix;
glPushMatrix;
glRotate4f(1,0,1,.2);
glBegin(GL_SOMETHING);
glEnd;
glPopMatrix;
glPushMatrix;
glRotate4f(0.9,0.9,0.9,.5);
glBegin(GL_SOMETHING);
glEnd;
glPopMatrix;
glPopMatrix;

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Fr 09.09.05 20:18 
user profile iconBenBE hat folgendes geschrieben:
Probier mal kurz das hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
glPushMatrix;
glPushMatrix;
glRotate4f(1,0,1,.2);
glBegin(GL_SOMETHING);
glEnd;
glPopMatrix;
glPushMatrix;
glRotate4f(0.9,0.9,0.9,.5);
glBegin(GL_SOMETHING);
glEnd;
glPopMatrix;
glPopMatrix;

die markierten BEfehle dürften dabei aber garnicht nötig sein :-)
Chryzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Fr 09.09.05 20:25 
danke erst mal für die schnelle Hilfe, aber :cry:
geht immer noch nicht bzw. dreht sich überhaupt nichts.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
glPushMatrix;
glRotatef(1,0,10.2);
glColor3f(100);
glBegin(GL_QUADS);
...
glEnd;
glPopMatrix;
glPushMatrix;
glRotatef(0.9,0.9,0.90.5);
glColor3f(010);
glBegin(GL_TRIANGLES);
...
glEnd;
glPopMatrix;


glRotate4f gibt's nicht --> glRotatef
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Fr 09.09.05 20:38 
das man nichts sieht könnte daran liegen, dass du nur sehr geringe Drehungen durchführst (1 Grad)
wenn sich die Objekte fortwährend drehen sollen, dann müsstest du den ersten Parameter von glRotatef als variable nehmen und beim rendern immer erhöhen, oder für eine statische drehung des objekts zu den achsen einfach einen größeren Wert wie bspw 120

weitere Infos: wiki.delphigl.com/index.php/GlRotatef
Chryzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Fr 09.09.05 20:45 
das Drehen funktioniert:
wenn ich die PushMatrix und PopMatrix fur das 2. Obj entferne, gehts!
Allerdings wieder beide Objekte zusammen :cry:
die erste Drehung wird sozusagen nicht beachtet.
Erst die 2. dreht dann beide zusammen :oops:
NeoInDerMATRIX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 09.09.05 23:55 
Hi,

hier so sollte es ungefair gehen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  glClearColor(0000); 
  glClear(gl_Color_Buffer_Bit or gl_Depth_Buffer_Bit);

  glLoadIdentity;

   glPushMatrix();
    glRotateF(CamAngX, 100);
    glRotateF(CamAngY, 010);
    glRotateF(CamAngZ, 001);
 
    glTranslateF(CamPosX, CamPosY, CamPosZ);
    
    glBegin(gl_BlaBla);

    glEnd();
   glPopMatrix();
   
   dann der rest ...


Wenn ich mich jetzt irre, dann koriergt mich. ;-)

Cu
Neo
Chryzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Sa 10.09.05 13:55 
Super :D ,
funktioniert einwandfrei!

Thnks :beer:
NeoInDerMATRIX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Sa 10.09.05 16:37 
Hi,

welcher source hat jetzt funktioniert?

Cu
Neo
Chryzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Sa 10.09.05 17:13 
Hi,

der von dem Außerwählten in der Matrix :D
an dem glLoadIdentity hat's gelegen :autsch:
SnuffMaster23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Sa 01.10.05 02:22 
Hi Burschi,

du kannst dir auch einfach für jedes Objekt das du drehen willst eine eigene Matrix-Variable anlegen
(Bezeichner: array[0..15] of glFloat).

Mit glGetFloatv(@Bezeichner, GL_MODELVIEWMATRIX) kannst du die aktuelle Matrix in der Variablen speichern und
mit glLoadMatrixf(Bezeichner) kannst die Matrix im nächsten Frame wiederverwenden also:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
  glLoadMatrixf(Bezeichner1);
  .
  . // RenderBefehle für Objekt1
  .
  glGetFloatv(@Bezeichner1, GL_MODELVIEWMATRIX);

  glLoadMatrixf(Bezeichner2);
  .
  . // RenderBefehle für Objekt2
  .
  glGetFloatv(@Bezeichner2, GL_MODELVIEWMATRIX);


Natürlich solltest du zuerst die Identitätsmatrix in die Variablen speichern, da sonst glaube ich NIX sinnvolles passiert (zumindest im ersten Frame).

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.

_________________
Nichts ist wahr - Alles ist erlaubt
NeoInDerMATRIX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Sa 01.10.05 17:14 
Hi,

@SnufMaster23: Ich möchte dir ja jetzt nicht zu nahe treten, aber die Version die du hier aufzeigen tust, ist erstens nicht die beste (schnelligkeit) und zweitens auch nicht das einfachste (Mathe). Desweiteren war die frage bereits beantwortet, woraus sich dann nicht erkennen läst wozu du das hier schreibst. Vor allem da deine source ansätze auch nicht ganz koreckt sind.

Cu
Neo
Chryzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Sa 01.10.05 17:19 
glPushMatrix und glPopMatrix sind da wesentlich einfacher und kompakter vom Code her.