Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht Das deutsche QBasic- und FreeBASIC-Forum
Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
 
FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   BenutzergruppenBenutzergruppen  RegistrierenRegistrieren
ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin
Zur Begleitseite des Forums / Chat / Impressum
Aktueller Forenpartner:

Probleme mit OpenGL
Gehe zu Seite Zurück  1, 2
 
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Allgemeine Fragen zu FreeBASIC.
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
atari
gesperrt


Anmeldungsdatum: 26.08.2007
Beiträge: 144

BeitragVerfasst am: 28.08.2007, 16:30    Titel: Antworten mit Zitat

caran, hier ist eine camerafahrt zum umändern nach belieben !


Code:


const false = 0
const true  = not false
const null = 0

#include once "GL/gl.bi"
#include once "GL/glu.bi"
#include once "fbgfx.bi"             
#include once "milkshapemodel.bi"
#include once "bmpload.bi"

Type typcam
        x               as single
        y               as single
        z               as single
        b               as single
        h               as single
end Type

declare sub InitGL()
declare sub INIT_cam ()
declare sub eingabe ()
declare sub draw_scene()

const degrad = atn(1) / 45
 
dim shared MilkShapeModel as MODEL   
dim shared as typcam cam
       
Dim Shared As Single v_cam,d_vy, o_rotate
                     
   Model_Init varptr(MilkShapeModel)
   Model_LoadModelData (varptr(MilkShapeModel), exepath + "/data/dein-modell.ms3d")
   windowtitle "opengl 3d" 
   screen 19, 16, , 2

   glViewport 0, 0, 800,600                 
   glMatrixMode GL_PROJECTION                 
   glLoadIdentity                             
   gluPerspective 45.0, 800/600, 1.0, 1000.0 
   glMatrixMode GL_MODELVIEW                 
   glLoadIdentity                           

   InitGL()   
   INIT_cam()   
   
   v_cam=0.05
   d_vy=20.0
                          
   do
       eingabe
       draw_scene
       
   loop until multikey(fb.SC_Escape)

   end

Sub draw_scene() 
   
   glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT 
   glLoadIdentity   
   
   glRotatef cam.h-90 , 1, 0, 0
   glRotatef cam.b , 0, 1, 0
   glTranslatef -cam.x, -cam.y, -cam.z
   
   glPushMatrix
   glRotatef o_rotate,0,1,0
   
   glPushMatrix                   
   
         Model_Draw (@MilkShapeModel)   'hier dein modell rein!!!!!!!!!!!!!!!!!!
   
   glPopMatrix 
  glPopMatrix                                                       
                               
   glFlush
   flip
   
End Sub

sub InitGL()

   Model_ReloadTextures (@MilkShapeModel)               

   glEnable GL_TEXTURE_2D                               
   glShadeModel GL_SMOOTH                               
   glClearColor 0.0, 1.0, 0.0, 0.5                     
   glClearDepth 1.0                                     
   glEnable GL_DEPTH_TEST                               
   glDepthFunc GL_LEQUAL                               
   glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST     
   
end sub

sub INIT_cam ()
   
    cam.x = 0
    cam.y = 25
    cam.z = 200
    cam.h = 90
    cam.b = 0
   
end Sub

sub eingabe()

    dim as Integer vy
    dim as single dify
   
    If MultiKey(fb.SC_w) Then
       vy=vy+d_vy
    End if
   
    If MultiKey(FB.SC_s) Then
       vy=vy-d_vy
    End if
   
    If MultiKey(fb.SC_q) Then
        cam.b = cam.b + v_cam
    End if
   
    If MultiKey(fb.SC_e) Then
        cam.b = cam.b - v_cam
    End if
   
    If MultiKey(FB.SC_f) Then     
        cam.h = cam.h + v_cam
    End if
   
    If MultiKey(fb.SC_v) Then
        cam.h = cam.h - v_cam
    End If
   
    If MultiKey(FB.SC_a) Then     
       o_rotate=o_rotate+0.1
    End if
   
    If MultiKey(fb.SC_d) Then
       o_rotate=o_rotate-0.1 
    End if
     
    dify = vy/80

    cam.x += dify * sin(degrad * cam.b)
           
    cam.y += dify * cos(degrad * cam.b) * cos(degrad * cam.h)
                   
    cam.z += - dify * Sin(degrad * cam.h)   
   
end sub

Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Allgemeine Fragen zu FreeBASIC. Alle Zeiten sind GMT + 1 Stunde
Gehe zu Seite Zurück  1, 2
Seite 2 von 2

 
Gehe zu:  
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.

 Impressum :: Datenschutz