You must use
Set Camera Fov, Set Camera Range
`*******************************************************************************
`* Free License Agreement. *
`* *
`* The user/developer agrees to include a visible credit to "Dmitry Kuschev" *
`* within your programs documentation and or web site. *
`* *
`* The user/developer agrees to NOT offer the this source code for Sale. *
`* *
`* Providing the user/Developer agrees in full to the previous Free *
`* License Agreement clauses, the user/developer may use this source *
`* code FREELY in all their products, commercial or otherwise. *
`* *
`*******************************************************************************
Dim Matrix4(16) As Float
Randomize Timer()
FOV#=RND(3600)/10.0
Near#=RND(1000)-RND(1000)
Far#=RND(5000)-RND(5000)
BuildProjectionMatrix(FOV#, (Screen Width()*1.0)/(Screen Height()*1.0), Near#, Far#)
Sync Rate 0
Sync On
Do
Set Cursor 0, 0
Print "Accessing/Modifying the Projection Matrix by Dmitry K"
Print
Print "FOV# = ", FOV#
Print "Near# = ", Near#
Print "Far# = ", Far#
Print
Print "GetFOVFromProjectionMatrix() = ", GetFOVFromProjectionMatrix()
Print "GetNearFromProjectionMatrix() = ", GetNearFromProjectionMatrix()
Print "GetFarFromProjectionMatrix() = ", GetFarFromProjectionMatrix()
Print
SetViewPortProjectionMatrix(GetFOVFromProjectionMatrix(), GetNearFromProjectionMatrix(), GetFarFromProjectionMatrix())
Print "GetFOVFromViewPort() = ", GetFOVFromViewPort()
Sync
Loop
Function SetViewPortProjectionMatrix(FOV#, Near#, Far#)
Set Camera FOV FOV#
Set Camera Range Near#, Far#
EndFunction
Function BuildProjectionMatrix(FOV#, AspectRatio#, Near#, Far#)
BuildFOVLHMatrix4(FOV#, AspectRatio#, Near#, Far#)
EndFunction
Function BuildFOVLHMatrix4(FOV#, Aspect#, Near#, Far#)
Height#=1.0/Tan(FOV#/2.0)
Width#=Height#/Aspect#
Matrix4(1)=Width#
Matrix4(2)=0.0
Matrix4(3)=0.0
Matrix4(4)=0.0
Matrix4(5)=0.0
Matrix4(6)=Height#
Matrix4(7)=0.0
Matrix4(8)=0.0
Matrix4(9)=0.0
Matrix4(10)=0.0
Matrix4(11)=Far#/(Far#-Near#)
Matrix4(12)=1.0
Matrix4(13)=0.0
Matrix4(14)=0.0
Matrix4(15)=-1.0*Near#*(Far#/(Far#-Near#))
Matrix4(16)=0.0
EndFunction
Function GetFOVFromViewPort()
r=Make Matrix4(100)
Projection Matrix4 100
GetFOVResult#=Atan(1.0/(X Vector2(100)*((Screen Width()*1.0)/(Screen Height()*1.0))))*2.0
If GetFOVResult# <= 0.0 Then Inc GetFOVResult#, 360.0
EndFunction GetFOVResult#
Function GetFOVFromProjectionMatrix()
GetFOVResult#=Atan(1.0/(Matrix4(1)*((Screen Width()*1.0)/(Screen Height()*1.0))))*2.0
If GetFOVResult# <= 0.0 Then Inc GetFOVResult#, 360.0
EndFunction GetFOVResult#
Function GetNearFromProjectionMatrix()
NearResult#=-1.0*Matrix4(15)/Matrix4(11)
EndFunction NearResult#
Function GetFarFromProjectionMatrix()
Near#=-1.0*Matrix4(15)/Matrix4(11)
FarResult#=Near#/(1.0-1.0/Matrix4(11))
EndFunction FarResult#
Specs: P4 2.4GHz, DIMM 256 266Mhz, 60GB HD 7200rpm ATA-133, GeForce 4 MX440, CD-RW+DVD, WinXP