Hope this is useful to somebody. Probably won't work in DBC since i used instance object.
Rem Project: my radar code snippet
Rem Created: 25/09/2007 16:43:48
Rem ***** Main Source File *****
#constant playerobjnum 1
#constant radarobjnum 2
#constant radcircleobjnum 3
#constant radcircleimgnum 3
#constant temp_meshnum 1
radscale#=0.01
sync on:sync rate 60
hide mouse
set camera range 10,5000
`make a matrix so can see the ground
make matrix 1,1000,1000,20,20
`make some objects that will be shown on radar. instance them for speed..
objnum0=10:make object cube objnum0,10
for n=1 to 100:instance object objnum0+n,objnum0:next n
`randomise object positions
dim objposx(100):dim objposz(100)
for n=0 to 100
objposx(n)=rnd(1000):objposz(n)=rnd(1000)
position object objnum0+n,objposx(n),0,objposz(n)
next n
`make a player object
make object cube playerobjnum,10:color object 1, rgb(250,0,0)
`make a radar object - a limb for each object shown on radar- including limb 0
make object plain radarobjnum,0.1,0.1
make mesh from object temp_meshnum,radarobjnum
for n=1 to 100
add limb radarobjnum,n,temp_meshnum
next n
lock object on radarobjnum `lock to screen. object position coordinates now refer to coordinates in frame of camera..
set object radarobjnum,1,0,0,0,0,0,0 `make fully lit. also culling on is wasteful
`make a textured object to show where radar centre etc is
create bitmap 1,256,256 `pixels range from 0-255 if i remember right
ink rgb(255,255,255),0:circle 128,128,126:line 0,128,256,128:line 128,0,128,256 `circle and lines
get image radcircleimgnum ,0,0,256,256:delete bitmap 1
make object plain radcircleobjnum,10,10:texture object radcircleobjnum,radcircleimgnum
lock object on radcircleobjnum
set object radcircleobjnum,1,0,0,1,0,0,0
ghost object on radcircleobjnum:disable object zwrite radcircleobjnum
`mess around with these values to move the radar around.
`make sure the two objects have the same position.
`the radar can be made to look smaller by moving it forwards
position object radarobjnum, -7,-7.5, 15 `x is to the right of centre, y is above centre, z is how far into screen..
position object radcircleobjnum, -7,-7.5, 15
do
`player movement
objangy=wrapvalue(objangy+rightkey()-leftkey())
yrotate object playerobjnum,objangy
move object playerobjnum,upkey()-downkey()
plyposx#=object position x(playerobjnum)
plyposz#=object position z(playerobjnum)
`get the positions of things relative to player and convert to radar positions..
for n=0 to 100
radar_x#=0.0-radscale#*(objposx(n)-plyposx#):radar_y#=radscale#*(objposz(n)-plyposz#)
distsq#=radar_x#*radar_x#+radar_y#*radar_y#
if distsq#<25.0 `radar circle object is diameter 10, ie radius 5, so if radar_x^2+radar_y^2>5*2, is outside circle..
offset limb radarobjnum,n,radar_x#,radar_y#,0
show limb radarobjnum,n
else
hide limb radarobjnum,n
endif
next n
zrotate object radarobjnum,objangy
`3rd person camera
position camera plyposx#,0.0,plyposz#
set camera to object orientation playerobjnum
pitch camera down 30.0:move camera -100.0
sync:loop
end