Just a little off track but if you want to try a total re-write try this code, its what I use for my 3d mouse.
Any questions or requests just ask !
WARNING
You will need sparkys collision Dll installed for this to work, its free and very useful, you can find it here:
http://forum.thegamecreators.com/?m=forum_view&t=31051&b=5
Rem Project: Cursor to Object
Rem Created: 02/10/2004 16:22:02
Rem ***** Main Source File *****
`Controls are up for forewards, down for backwards, left rotate left, right rotate right, shift=move up, control=move down
`Move the cursor over the cubes and a sphere will be placed at that point `
cls
sync on
sync rate 60
`========================================================`
` You can remove this bit and replace with your own level`
For i=3 to 60
make object cube i,35+rnd(30)
position object i,(rnd(100)*10),(rnd(100)*10),(rnd(100)*10)
setupobject i,0,0
color object i,RGB(rnd(254),rnd(254),rnd(254))
next i
`=========================================================`
rotate camera 0,0,0
make memblock 99,2
make object sphere 2,10
do
MouseCam()
ScreentoReal()
sync
loop
` this is the command in question `
Function ScreentoReal()
Pick Screen mousex(), mousey(), 4000
nx#=(camera position x()+GET PICK VECTOR x())
ny#=(camera position y()+GET PICK VECTOR y())
nz#=(camera position z()+GET PICK VECTOR z())
Obnum=IntersectObject(0,0,camera position x(),camera position y(),camera position z(),nx#,ny#,nz#,0)
Rx#=GetStaticCollisionX()
Ry#=GetStaticCollisionY()
Rz#=GetStaticCollisionZ()
` rx#, ry# and rz# are the real world values, extract them as you wish
position object 2,rx#,ry#,rz#
endfunction
Function MouseCam()
y#=camera angle y()
h#=camera position y()
if upkey()=1 then move camera 1
if downkey()=1 then move camera -1
if leftkey()=1 then yrotate camera y#-1
if rightkey()=1 then yrotate camera y#+1
if shiftkey()=1 then position camera camera position x(),camera position y()+1,camera position z()
if controlkey()=1 then position camera camera position x(),camera position y()-1,camera position z()
endfunction
Hope this helps, although if its not your cup-o-tea then no worries !