I like my code, as it's just toggling some camera variables to get the desired effect.
REMstart
Burningfeetman presents: Orthographic camera thingy.
TO DO list;
Source optimization
Pick Object interaction
Y Axis Shading
There was talk of using this variable;
ortho = 361.45
But it causes graphical glitches, as opposed to;
ortho = 1.00
Which seems to give a good result...
Remend
Type tMouse
X as Integer
Y as Integer
Z as Integer
move_X as Integer
move_Y as Integer
move_Z as Integer
endtype
Mouse as tMouse
Mouse.X = mousex()
Mouse.Y = mousey()
Mouse.Z = mousez()
Mouse.move_X = mousemovex()
Mouse.move_Y = mousemovey()
Mouse.move_Z = mousemovez()
Global Angle as Float
PosX = 50
PosY = 50
PosZ = 50
FOV# = 90
Range_Min = 10
Range_Max = 2000
Scale# = 100
AutoCam off
Position Camera 0, PosX, PosX, PosX
Point Camera 0, 0,0,0
rem Static cube
Make Object Cube 1, 10
Position Object 1, 0,0,0
rem horizontal cube
Make Object Cube 2, 10
Position Object 2, 0,0,0
rem vertical cube
Make Object Cube 3, 10
Position Object 3, 0,0,0
rem horizontal cube
Make Object Cube 4, 10
Position Object 4, 0,0,0
rem horizontal cube
Make Object Cube 5, 10
Position Object 5, 0,0,0
Sync on
sync rate 60
backdrop on
sync
do
set cursor 0,0
Mouse.X = mousex()
Mouse.Y = mousey()
Mouse.Z = mousez()
Mouse.move_X = mousemovex()
Mouse.move_Y = mousemovey()
Mouse.move_Z = mousemovez()
Set Camera Range 0, Range_Min, Range_Max
Set Camera FOV 0, FOV#
Position Camera 0, PosX, PosX, PosX
Scale Object 1, Scale#, Scale#,Scale#
Scale Object 2, Scale#, Scale#,Scale#
Scale Object 3, Scale#, Scale#,Scale#
Oscillate_Object(3,"x",50)
Oscillate_Object(2,"y",100)
Oscillate_Object(4,"z",50)
Oscillate_Object(5,"x",100)
Oscillate_Object(5,"y",50)
Oscillate_Object(5,"z",25)
If Rightkey() = 1
Inc FOV#, 0.25
endif
If Leftkey()
Dec FOV#, 0.25
endif
If Upkey() = 1
dec PosX, 10
endif
If Downkey() = 1
inc PosX, 10
endif
If keystate(13) = 1
Inc Scale#, 5
endif
If keystate(12) = 1
Dec Scale#, 5
endif
If keystate(16) = 1
Inc Range_Min, 5
Inc Range_Max, 5
endif
If keystate(30) = 1
Dec Range_Min, 5
Dec Range_Max, 5
endif
If keystate(24) = 1
Range_Min = 5000
Range_Max = 10000
FOV# = 1
PosX = 5000
Scale# = 100
endif
If keystate(25) = 1
Rem Range_Min = 0 will cause graphical glitches!
Range_Min = 10
Range_Max = 2000
FOV# = 90
PosX = 50
Scale# = 100
endif
Print "How to shot web: DarkBASIC PRo Camera Control"
Print ""
Rem Pythagoras theorem!! Aww yer...
Distance# = SQRT((PosX^2)+(PosX^2))
Print "Controls & Toggle"
Print "O & P for Orthographic & Perspective Defaults"
Print "Left/Right FOV: " ; FOV#
Print ""
Print "Num Pad +/- Scale: " ; Scale#
Print ""
Print "Up/Down Camera Distance: " ; Distance#
Print ""
Print "Q/A Camera Range Min/Max: " ; Range_Min ;" "; Range_Max
Print ""
Print "Mouse X/Y: " ; Mouse.X ; " " ; Mouse.Y
Print "Mouse move X/Y: " ; Mouse.move_X ; " " ; Mouse.move_Y
sync
loop
end
Function Oscillate_Object(Object_No, Axis$, Max_Distance)
Rem Sin Wave forumla
Value#=SIN(Angle)*Max_Distance
inc Angle,0.1
Angle = WRAPVALUE(Angle)
Select Axis$
Case "x":
Position object Object_No,Value#,Object Position Y(Object_No),Object Position Z(Object_No)
endcase
Case "y":
Position object Object_No,Object Position X(Object_No),Value#,Object Position Z(Object_No)
Fade Object Object_No, (Object Position Y(Object_No) + 100)
endcase
Case "z":
Position object Object_No,Object Position X(Object_No),Object Position Y(Object_No),Value#
endcase
endselect
endfunction
From memory I preferred my code over other solutions, primarily because you can still interact the mouse with 3D objects with minimum effort. All the other methods that I tried caused mouse interaction issues very early on.
I'm very keen to discuss this topic, so please, do experiment.