you may want to try the camera code in this snippet..
the bottom row of the keyboard ( with and without shift ) manage the camera
c is for rotating around the object
cheers
Rem Project: hilled
rem by Scorpyo
Rem Created: 08/12/03 14.14.03
Rem ***** Main Source File *****
rem ********** INITIALIZATION ****************
set display mode 800,600,16
hide mouse
set global collision off
autocam off
backdrop on
sync on
cls
landsize=20000
grid=40
mtxrandomize=300
x#=10000.0
z#=10000.0
gosub Setupland1
gosub makeplayer
gosub Resetcam
do
oldx#=x#
oldz#=z#
x#=newxvalue(x#,a#,s#)
z#=newzvalue(z#,a#,s#)
h#=get ground height(1,x#,z#)
position object 1,x#,h#,z#
yrotate object 1,a#
gosub Playercontrol
gosub groundalign
gosub camera_controls
gosub update_camera
gosub printdata
sync
loop
rem ****** CREATE LEVEL ******
Setupland1:
rem Load and create images
rem ground textures
rem create texture
cls rgb(0,100,20)
inkcolor#=rgb(255,255,255)
for n=1 to 50 step 10
line n,0,n,50
line 0,n,50,n
next n
get image 2,0,0,50,50
rem Make landscape
make matrix 1,landsize,landsize,grid,grid
rem set matrix 1,1,0,0,1,1,1,1
prepare matrix texture 1,2,1,1
randomize matrix 1,mtxrandomize
rem get ground done
update matrix 1
return
makeplayer:
make object cube 1,100
position object 1,x#,0,z#
rem load object "testbox.x",1
return
groundalign:
rem Calculate four X+Z coordinates for each corner
foot#=100
ta#=wrapvalue(a#-45)
frontleftx#=newxvalue(x#,ta#,foot#) : frontleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+45)
frontrightx#=newxvalue(x#,ta#,foot#) : frontrightz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+225)
backleftx#=newxvalue(x#,ta#,foot#) : backleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+135)
backrightx#=newxvalue(x#,ta#,foot#) : backrightz#=newzvalue(z#,ta#,foot#)
rem Calculate degree of tilting from corner heights
frontlefth#=get ground height(1,frontleftx#,frontleftz#)
frontrighth#=get ground height(1,frontrightx#,frontrightz#)
backlefth#=get ground height(1,backleftx#,backleftz#)
backrighth#=get ground height(1,backrightx#,backrightz#)
across#=((frontrighth#-frontlefth#)+(backrighth#-backlefth#))/2.0
length#=((backlefth#-frontlefth#)+(backrighth#-frontrighth#))/2.0
rem Update active model
remstart
rem DBC code
xrotate object 1,wrapvalue(length#/4.0)
zrotate object 1,wrapvalue(across#/4.0)
remend
rem alternate DBP code
remstart
rem tilt angle correction but jerky
if length#>0 then oax#=wrapvalue(length#/4.0+3.0)
if length#<0 then oax#=wrapvalue(length#/4.0-3.0)
if across#>0 then oaz#=wrapvalue(across#/4.0+3.0)
if across#<0 then oaz#=wrapvalue(across#/4.0-3.0)
remend
oax#=wrapvalue(length#/4.0-3.0)
oaz#=wrapvalue(across#/4.0+3.0)
rem rotation are applied to root object limb
rem to avoid z gimbal lock
rotate limb 1,0,oax#,0,oaz#
return
rem ******* PLAYERCONTROLS *******
Playercontrol:
rem ---- Control Character ----
if upkey()=1 and s#<8 then s#=s#+1
if downkey()=1 and s#>-8 then s#=s#-1
if leftkey()=1 then a#=wrapvalue(a#-4)
if rightkey()=1 then a#=wrapvalue(a#+4)
if inkey$()="ù" then s#=40
return
camera_controls:
if inkey$()="z" then camdist=camdist+2
if inkey$()="Z" then camdist=camdist-2
if inkey$()="x" then camhgt=camhgt+2
if inkey$()="X" then camhgt=camhgt-2
if inkey$()="c" then camrot=wrapvalue(camrot+2)
if inkey$()="C" then camrot=wrapvalue(camrot-2)
if inkey$()="v" then camlen=camlen+2
if inkey$()="V" then camlen=camlen-2
if inkey$()="b" then camrot = 180
if inkey$()="B" then camrot = 0
if inkey$()="n" then camdist=80:camlen=0:camrot=180:camhgt=100:camflag=0:wait 1
if inkey$()="N" then camdist=80:camlen=0:camrot=0:camhgt=100:camflag=1:wait 1
if inkey$()=">" then gosub Resetcam
if inkey$()="m" then camdist=-1000:camhgt=500:set camera range 100,20000
if inkey$()="M" then camdist=-3000:camhgt=1000:set camera range 100,20000
return
rem camera update
update_camera:
rem Position camera to the back of the character
ca#=wrapvalue(a#+camrot)
cx#=newxvalue(x#,ca#,camdist)
cz#=newzvalue(z#,ca#,camdist)
cy#=get ground height(1,x#,z#)
position camera cx#,cy#+camhgt,cz#
rem Point camera at object
point camera x#,cy#+camhgt+camlen,z#
return
Resetcam:
set camera range 20,20000
camdist=-500
camhgt=200
camrot=0
camlen=0
return
printdata:
set cursor 0,0
set text opaque
rem debug check
print "polygons=",statistic(1)
print "Fps=",screen fps()
print "landsize=",landsize
print "grid=",grid
print "x#=",x#
print "z#=",z#
print "h#=",h#
print "a#=",a#
print "across#=",across#
print "lenght#=",length#
print "oax#=",oax#
print "oaz#=",oaz#
return
end