First off, you have your camera positioning and rotation in an IF argument. That's a no-no.
So far, this is what I've come up with. Just give me a little while to complete it:
set display mode 800,600,16
sync on
hide mouse
backdrop on
color backdrop rgb(255,255,255)
make object cube 1,10.0
color object 1,rgb(0,255,0)
position object 1,-10,-10,20
do
controlChar(1)
controlCamFree(1)
` set camera to follow cx#,cy#,cz#,angle#,camdist#,camhigh#,camfade#,1
sync
loop
function controlChar(obj)
if upkey() = 1
move object 1,5.0
endif
if downkey() = 1
move object 1,-5.0
endif
endfunction
function controlCamFree(obj)
xv# = object position x(obj)
yv# = object position y(obj)
zv# = object position z(obj)
if mouseclick() = 2
ready = 1
else
ready = 0
camx# = ocx#
camy# = ocy#
camz# = ocz#
endif
if ready = 1
camx# = mousemovex()
camy# = mousemovey()
else
ocx# = camx#
ocy# = camy#
ocz# = camz#
ready = 0
endif
remstart
if mouseclick() = 3
mmy# = mousemovey()
cza# = wrapvalue(cza# + mmy#)
endif
if mouseclick() = 2
hide mouse
ready = 1
else
ready = 0
show mouse
endif
if ready = 1
mmx# = mousemovex()
mmy# = mousemovey()
cxa# = wrapvalue(cxa# + mmx#)
cya# = wrapvalue(cya# + mmy#)
endif
point camera object position x(obj),object position y(obj),object position z(obj)
position camera newxvalue(object position x(obj),cxa#,cx#),newyvalue(object position y(obj),cya#,cy#),newzvalue(object position z(obj),cza#,cz#)
remend
position camera camx#,camy#,camz#
point camera xv#,yv#,zv#
endfunction
Bear with me, I've never really taken on a post this challenging cause I don't like messing our in the 3D part of DBC. Others may reply, but I'll still be tweaking this until I post it on the Code Snippets forum.
Post again soon.
a.k.a. "flockhound"