I have been experimenting with the method I am thinking of. Can you tell me whether this bears any resemblence to the way the camera in DB works?
Thanks
rem Mouse position to 3D position demo
rem Lines go wierd when they are positioned behind camera
rem Data for the grid lines
data 200.0,-200.0,-200.0,-200.0,200.0,-160.0,-200.0,-160.0,200.0,-120.0,-200.0,-120.0,200.0,-80.0,-200.0,-80.0,200.0,-40.0,-200.0,-40.0,200.0,0.0,-200.0,0.0
data 200.0,200.0,-200.0,200.0,200.0,160.0,-200.0,160.0,200.0,120.0,-200.0,120.0,200.0,80.0,-200.0,80.0,200.0,40.0,-200.0,40.0
data 200.0,-200.0,-200.0,-200.0,200.0,-160.0,-200.0,-160.0,200.0,-120.0,-200.0,-120.0,200.0,-80.0,-200.0,-80.0,200.0,-40.0,-200.0,-40.0,200.0,0.0,-200.0,0.0
data 200.0,200.0,-200.0,200.0,200.0,160.0,-200.0,160.0,200.0,120.0,-200.0,120.0,200.0,80.0,-200.0,80.0,200.0,40.0,-200.0,40.0
sync on
dim lines#(2,11,2,2)
dim eye#(1)
dim gridz#(1)
dim gridx#(1)
rem Set camera view width
eye#(1)=201
rem Original grid coordinates
gridz#(1)=150.01
gridx#(1)=0.01
rem Read data for grid lines into arrays
for x=1 to 11
read lines#(1,x,1,1)
read lines#(1,x,1,2)
read lines#(1,x,2,1)
read lines#(1,x,2,2)
next x
for x=1 to 11
read lines#(2,x,1,2)
read lines#(2,x,1,1)
read lines#(2,x,2,2)
read lines#(2,x,2,1)
next x
rem Main loop
do
rem Messages
ink rgb(200,200,255),0
text 10,20,"Arrow keys = Move Grid"
text 10,40,"a = Increase camera lens angle"
text 10,60,"z = Decrease camera lens angle"
rem Change grid position using arrow keys
if upkey()=1 then gridz#(1)=gridz#(1)+3
if downkey()=1 then gridz#(1)=gridz#(1)-3
if leftkey()=1 then gridx#(1)=gridx#(1)-3
if rightkey()=1 then gridx#(1)=gridx#(1)+3
rem Change lens width using a and z
if inkey$()="z" then eye#(1)=eye#(1)+3
if inkey$()="a" then eye#(1)=eye#(1)-3
rem Draw grid
ink rgb(255,255,255),0
for x=1 to 2
for y=1 to 11
line p_x(lines#(x,y,1,1),lines#(x,y,1,2)),p_y(-100.0,lines#(x,y,1,2)),p_x(lines#(x,y,2,1),lines#(x,y,2,2)),p_y(-100.0,lines#(x,y,2,2))
next y
next x
rem Store adjusted mouse positions to make stuff draw in centre of screen
`0.01 is to stop "can't devide by zero" thing
mx#=mousex()-320
my#=240-mousey()+0.01
rem Work out the 3D coordinates of lines using -100 as the y coordinate
tx#=mx#*(eye#(1)+(((-100/my#)*eye#(1))-eye#(1)))/eye#(1)-gridx#(1)
tz#=(-100/my#)*eye#(1)-eye#(1)-gridz#(1)
rem Draw position lines
ink rgb(255,255,0),0
line p_x(tx#,-200.0),p_y(-100.0,-200.0),p_x(tx#,200.0),p_y(-100.0,200.0)
line p_x(-200.0,tz#),p_y(-100.0,tz#),p_x(200.0,tz#),p_y(-100.0,tz#)
sync
cls
loop
rem Find 2D screen x position of 3D coordinated
function p_x(x#,z#)
value=320+(x#+gridx#(1))/((eye#(1)+z#+gridz#(1))/eye#(1))
endfunction value
rem Find 2D screen y position of 3D coordinated
function p_y(y#,z#)
value=240-y#/((eye#(1)+z#+gridz#(1))/eye#(1))
endfunction value
Why the hell'd you ask me for crying out loud!?!
Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM