 |
Das deutsche QBasic- und FreeBASIC-Forum Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
|
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
Autor |
Nachricht |
Löwenherz

Anmeldungsdatum: 25.08.2008 Beiträge: 86 Wohnort: auf einer sonnigen Insel :)
|
Verfasst am: 27.07.2009, 00:00 Titel: zweiter würfel mit translate? |
|
|
hi, habe eine Frage zum Thema Open GL und Würfel:
besteht eine einfache Möglichkeit einen Würfel mit einer einzigen Befehlszeile zu kopieren (ich nenne es einfach mal " objekt translate") ?
also ich habe eine Würfel erstellt (nach Vorbild eastler!) und dann einen zweiten mit einer zweiten Sub, aber eigentlich frage ich mich, warum das nicht alles in einer Sub geschehen kann ?
Mein Ergebnis liefert zwei Würfel, aber der gute zweite Würfel ist erst nach Schließung des Fensters zu sehen...
gibt bestimmt eine einfachere Lösung, aber ich will halt nicht einen zweiten Würfel einbinden mit neuen x,y,z koordinaten... vielleicht hat jemand so etwas schon einmal ausprobiert... wäre schön...
mein Beispiel:
beste Grüße, löwenherz Code: |
DIM AS DOUBLE Pi, DrehgradZaehler
Pi = 3.14159265358979323846
#include "fbgfx.bi"
#include once "GL/gl.bi"
#include once "GL/glu.bi"
#include once "vbcompat.bi"
DECLARE SUB Wuerfel()
DECLARE SUB Wuerfel1()
screen 19, 16, , 2
glViewport 0, 0, 800, 600
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 45.0, 800.0/600.0, 0.1, 100.0
glMatrixMode GL_MODELVIEW
glLoadIdentity
glClearColor 0.75, 0.75, 0.60, 0.0
glClearDepth 1.0
glEnable GL_DEPTH_TEST
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
DO WHILE INKEY=""
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glPushMatrix
glTranslatef 0, -1, -3
glRotatef DrehgradZaehler, 0, 1, 0
glRotatef 45, 0, 0, 1 '1,0,1
glRotatef 35.28, 1,0,0
wuerfel()
flip
glPopMatrix
DrehgradZaehler = DrehgradZaehler + 1
LOOP
DO WHILE INKEY=""
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glPushMatrix
glTranslatef 0, -0.5, -2
glRotatef DrehgradZaehler, 0, 1, 0
glRotatef 48, 0, 0, 1 '1,0,1
glRotatef 36.28, 1,0,0
Wuerfel1()
flip
glPopMatrix
DrehgradZaehler = DrehgradZaehler + 0.5
LOOP
'---------------------------
SUB Wuerfel()
glBegin GL_QUADS
glColor3f 0 , 1 , 0
glVertex3f 1 , 0 , 0
glVertex3f 0 , 0 , 0
glVertex3f 0 , 0 , -1
glVertex3f 1 , 0 , -1
' top
glColor3f 1 , 1 , 0
glVertex3f 1 , 1 , 0
glVertex3f 1 , 1 , -1
glVertex3f 0 , 1 , -1
glVertex3f 0 , 1 , 0
' front
glColor3f 0 , 0 , 1
glVertex3f 1 , 1 , 0
glVertex3f 0 , 1 , 0
glVertex3f 0 , 0 , 0
glVertex3f 1 , 0 , 0
' back
glVertex3f 1 , 1 , -1
glVertex3f 1 , 0 , -1
glVertex3f 0 , 0 , -1
glVertex3f 0 , 1 , -1
' left
glColor3f 1 , 0 , 0
glVertex3f 0 , 1 , 0
glVertex3f 0 , 1 , -1
glVertex3f 0 , 0 , -1
glVertex3f 0 , 0 , 0
' right
glVertex3f 1 , 1 , 0
glVertex3f 1 , 0 , 0
glVertex3f 1 , 0 , -1
glVertex3f 1 , 1 , -1
glEnd
END SUB
'---------------------------
SUB Wuerfel1()
glBegin GL_QUADS
glColor3f 0 , 1 , 0
glVertex3f 1 , 0 , 0
glVertex3f 0 , 0 , 0
glVertex3f 0 , 0 , -1
glVertex3f 1 , 0 , -1
' top
glColor3f 1 , 1 , 0
glVertex3f 1 , 1 , 0
glVertex3f 1 , 1 , -1
glVertex3f 0 , 1 , -1
glVertex3f 0 , 1 , 0
' front
glColor3f 0 , 0 , 1
glVertex3f 1 , 1 , 0
glVertex3f 0 , 1 , 0
glVertex3f 0 , 0 , 0
glVertex3f 1 , 0 , 0
' back
glVertex3f 1 , 1 , -1
glVertex3f 1 , 0 , -1
glVertex3f 0 , 0 , -1
glVertex3f 0 , 1 , -1
' left
glColor3f 1 , 0 , 0
glVertex3f 0 , 1 , 0
glVertex3f 0 , 1 , -1
glVertex3f 0 , 0 , -1
glVertex3f 0 , 0 , 0
' right
glVertex3f 1 , 1 , 0
glVertex3f 1 , 0 , 0
glVertex3f 1 , 0 , -1
glVertex3f 1 , 1 , -1
glEnd
END SUB
|
_________________ Das Leben ist wie eine Pralinenschachtel, man weiß nie, was dort drinnen für tolle wie böse Überraschungen stecken |
|
Nach oben |
|
 |
Caran

Anmeldungsdatum: 11.03.2007 Beiträge: 290 Wohnort: Lörrach
|
Verfasst am: 27.07.2009, 08:49 Titel: |
|
|
Kopieren kannst du das Teil nicht, außer wenn du es zuerst in einer glList oder so speicherst.
Um zwei Würfel aus der gleichen Sub anzuzeigen musst du den Würfel einfach zwei mal, an zwei Verschiedenen stellen rendern. Das erreichst du mit glTranslate und glRotate.
Code: |
DIM AS DOUBLE Pi, DrehgradZaehler,DrehgradZaehler1
Pi = 3.14159265358979323846
#INCLUDE "fbgfx.bi"
#INCLUDE ONCE "GL/gl.bi"
#INCLUDE ONCE "GL/glu.bi"
#INCLUDE ONCE "vbcompat.bi"
DECLARE SUB Wuerfel()
SCREEN 19, 16, , 2
glViewport 0, 0, 800, 600
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 45.0, 800.0/600.0, 0.1, 100.0
glMatrixMode GL_MODELVIEW
glLoadIdentity
glClearColor 0.75, 0.75, 0.60, 0.0
glClearDepth 1.0
glEnable GL_DEPTH_TEST
glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT
DO WHILE INKEY=""
glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT
glLoadIdentity()
glPushMatrix
glTranslatef -1, -0.5, -6
glRotatef DrehgradZaehler, 0, 1, 0
glRotatef 45, 0, 0, 1 '1,0,1
glRotatef 35.28, 1,0,0
wuerfel()
glPopMatrix
glPushMatrix
glTranslatef 1, -0.5, -6
glRotatef DrehgradZaehler1, 1, 0, 0
wuerfel()
glPopMatrix
FLIP
DrehgradZaehler += 1
DrehgradZaehler1 += 1
LOOP
'---------------------------
SUB Wuerfel()
glBegin GL_QUADS
glColor3f 0 , 1 , 0
glVertex3f 1 , 0 , 0
glVertex3f 0 , 0 , 0
glVertex3f 0 , 0 , -1
glVertex3f 1 , 0 , -1
' top
glColor3f 1 , 1 , 0
glVertex3f 1 , 1 , 0
glVertex3f 1 , 1 , -1
glVertex3f 0 , 1 , -1
glVertex3f 0 , 1 , 0
' front
glColor3f 0 , 0 , 1
glVertex3f 1 , 1 , 0
glVertex3f 0 , 1 , 0
glVertex3f 0 , 0 , 0
glVertex3f 1 , 0 , 0
' back
glVertex3f 1 , 1 , -1
glVertex3f 1 , 0 , -1
glVertex3f 0 , 0 , -1
glVertex3f 0 , 1 , -1
' LEFT
glColor3f 1 , 0 , 0
glVertex3f 0 , 1 , 0
glVertex3f 0 , 1 , -1
glVertex3f 0 , 0 , -1
glVertex3f 0 , 0 , 0
' RIGHT
glVertex3f 1 , 1 , 0
glVertex3f 1 , 0 , 0
glVertex3f 1 , 0 , -1
glVertex3f 1 , 1 , -1
glEnd
END SUB |
Viel Spaß beim rumexperimentieren _________________ Eine Erkenntnis von heute kann die Tochter eines Irrtums von gestern sein. |
|
Nach oben |
|
 |
Löwenherz

Anmeldungsdatum: 25.08.2008 Beiträge: 86 Wohnort: auf einer sonnigen Insel :)
|
Verfasst am: 27.07.2009, 09:50 Titel: |
|
|
hi caran, besten Dank, hat geklappt
habe als Versuch einen neuen Würfel eingebaut, ich habs kapiert.
Sieht zum Glück auch nicht so kompliziert aus mit ...
Code: | wuerfel()
glPopMatrix
glPushMatrix
glTranslatef 1, -1.5, -6
glRotatef DrehgradZaehler1, 1, 0, 0
wuerfel()
glPopMatrix
glTranslatef 1.5, 1.25, -6
glRotatef DrehgradZaehler2, 0, 0.5, 0.5
wuerfel()
glPopMatrix |
beste Grüße, Spass am Experimentieren habe ich immer, schönen Tag noch!
löwenherz _________________ Das Leben ist wie eine Pralinenschachtel, man weiß nie, was dort drinnen für tolle wie böse Überraschungen stecken |
|
Nach oben |
|
 |
|
|
Du kannst keine Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum nicht antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen.
|
|