Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Fake 3D Würfel (https://www.delphipraxis.net/129629-fake-3d-wuerfel.html)

Hybrid666 22. Feb 2009 23:04


Fake 3D Würfel
 
Servus,

ich hab beschlossen das ich mit Delphi nun mal die Wege des Allmächtigen OpenGLs beschreiten will und werd das Forum hier nun mit Anfängerfragen löchern *miesgrins*.

Naja wie auch immer, ich mach das ganze mit den Tuts aus dem DGL Wiki, ich denke das ist nicht die schlechteste Wahl.

Nun hab ich grade das Quickstart Tutorial durchgemacht und an einer stelle wird ein Quadrat gezeichnet.

Delphi-Quellcode:
    glColor3f (Random, Random, Random); glVertex3f (0,0,0);
    glColor3f (Random, Random, Random); glVertex3f (1,0,0);
    glColor3f (Random, Random, Random); glVertex3f (1,1,0);
    glColor3f (Random, Random, Random); glVertex3f (0,1,0);
Nun wollte ich das ganze erweitern und einen Fake 3d Würfel zeichnen (also praktisch so wie mans in der schule immer an der tafel gezeichnet hat).

Hier mal mein Code:
Delphi-Quellcode:
  glBegin (GL_QUADS);
    glColor3f (Random, Random, Random); glVertex3f (0,0,0);
    glColor3f (Random, Random, Random); glVertex3f (1,0,0);
    glColor3f (Random, Random, Random); glVertex3f (1,1,0);
    glColor3f (Random, Random, Random); glVertex3f (0,1,0);
  glEnd;

  glBegin (GL_QUADS);
    glColor3f (Random, Random, Random); glVertex3f (0,1,0);
    glColor3f (Random, Random, Random); glVertex3f (1,1,0);
    glColor3f (Random, Random, Random); glVertex3f (1,1,1);
    glColor3f (Random, Random, Random); glVertex3f (0,1,1);
  glEnd;

  glBegin (GL_QUADS);
    glColor3f (Random, Random, Random); glVertex3f (1,1,0);
    glColor3f (Random, Random, Random); glVertex3f (1,0,0);
    glColor3f (Random, Random, Random); glVertex3f (1,0,1);
    glColor3f (Random, Random, Random); glVertex3f (1,1,1);
  glEnd;
Allerdings ist das kein, wie von mit erwünschter "fake würfel" sondern sieht etwas stark verzogen aus.

Geh ich nicht richtig in der annahme, das die koordinaten in glVertex3f X, Y und Z sind? also müsste das hier doch eigentlich den gewünschten würfel geben :(

Warum tut er das aber nicht?

MfG Hybrid666

mr_emre_d 22. Feb 2009 23:12

Re: Fake 3D Würfel
 
Ein Würfel / Quader hat 6 Seiten mein Lieber ;)

Wie es ausschaut, zeichnest du die..
vordere-, obere - und rechte Seite

Satty67 22. Feb 2009 23:14

Re: Fake 3D Würfel
 
Deshalb ja Fake-Würfel... denke er will nur die sichtbaren Seiten zeichnen

mr_emre_d 22. Feb 2009 23:15

Re: Fake 3D Würfel
 
:oops:

EDIT : --MÜLL--

"sieht etwas stark verzogen aus."

hast du das ganze auch richtig gedreht ?

Schau dir zuerst einmal glTranslateF, glRotateF, glScaleF an und anschließend
probierst du folgendes:

Delphi-Quellcode:
  glClear( gl_Depth_Buffer_Bit or gl_Color_Buffer_Bit );
  glClearCOlor( 0, 0, 0, 0 );

  glMatrixMode( gl_Projection );
  glLoadIdentity();
  glUPerspective( 45.0, ClientWidth/ClientHeight, 1, 100 );

  glTranslateF( 1, 0, -5 );
  glRotateF( 30, 1, 0, 0 );
  glRotateF( -120, 0, 1, 0 );

  glMatrixMode( gl_ModelView );
  glLoadIdentity();

  glBegin (GL_QUADS);
    glColor3f (0.5, 0.5, 1); glVertex3f (0,0,0);
    glColor3f (0.5, 0.5, 1); glVertex3f (1,0,0);
    glColor3f (0.5, 0.5, 1); glVertex3f (1,1,0);
    glColor3f (0.5, 0.5, 1); glVertex3f (0,1,0);
  glEnd;
//
  glBegin (GL_QUADS);
    glColor3f (0.8, 1, 0.8); glVertex3f (0,1,0);
    glColor3f (0.8, 1, 0.8); glVertex3f (1,1,0);
    glColor3f (0.8, 1, 0.8); glVertex3f (1,1,1);
    glColor3f (0.8, 1, 0.8); glVertex3f (0,1,1);
  glEnd;

  glBegin (GL_QUADS);
    glColor3f (1, 0, 0); glVertex3f (1,1,0);
    glColor3f (1, 0, 0); glVertex3f (1,0,0);
    glColor3f (1, 0, 0); glVertex3f (1,0,1);
    glColor3f (1, 0, 0); glVertex3f (1,1,1);
  glEnd;

  SwapBuffers( DC );
  Sleep( $10 );
  Done := not Application.Active;
MfG

turboPASCAL 23. Feb 2009 06:34

Re: Fake 3D Würfel
 
Liste der Anhänge anzeigen (Anzahl: 1)
Recht einfach, einen normalen OpenGL-3D-Würfel erstellen und per Backface Culling nur die forderen sichtbaren Linien
zeichnen lassen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:28 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz