[B3D] CameraZoom -> FOV / FOV -> CameraZoom

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

 

ChristianK

Betreff: [B3D] CameraZoom -> FOV / FOV -> CameraZoom

BeitragSa, Jun 23, 2007 15:22
Antworten mit Zitat
Benutzer-Profile anzeigen
Zwei Funktionen zum Umrechnen von CameraZoom und Field of View:

Code: [AUSKLAPPEN]
Function CameraZoomToFOV#( zoom# )
   Return ( 2 * ATan( 1 / zoom# ) )
End Function

Function FOVToCameraZoom#( fov# )
   Return( 1.0 / Tan( fov# / 2.0 ) )
End Function

; Beispiel

Graphics3D 800, 600, 32, 2
SetBuffer BackBuffer( )

Local fov# = 90

Local cam = CreateCamera( )
   PositionEntity( cam, 0, 0, -10 )
   
Local light = CreateLight( )
   LightColor( light, 100, 100, 100 )
   
Local cube = CreateCube( )
   RotateEntity( cube, 45, 45, 0 )

While Not KeyDown( 1 )

   If KeyDown( 200 )
      fov# = fov# + 1
   EndIf
   
   If KeyDown( 208 )
      fov# = fov# - 1
   EndIf
   
   CameraZoom( cam, FOVToCameraZoom( fov# ) )

   RenderWorld
   
   Text 10, 10, "Field of View: " + fov#
   Text 10, 30, "CameraZoom: " + FOVToCameraZoom( fov )
   
   Flip
Wend

End

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group