@SMD_3D Interactive ...Nice to see you are still around here
You are right, about INTERSECT OBJECT command, I've used just to show somehow how to determine it vertex where infront or behind the camera, that could be ok for ten enemies in a game. There are a lot of ways to check distance, and yours works better. We can adjust the ...let say "camera fov" just playing with
if dis#<dis2#+1...- 1.1 or - 1.2 or - 5 etc.
Rem Project: Dark Basic Pro Project
Rem Created: Tuesday, June 11, 2013
Rem ***** Main Source File *****
autocam off
sync on
` making the camera
make object box 5000,2,2,5
make object sphere 5001,3,5,5
scale object 5001,2,100,100
make mesh from object 1,5001
delete object 5001
add limb 5000,1,1
add limb 5000,2,1
offset limb 5000,1,0,2.5,0.5
offset limb 5000,2,0,2.5,-2
` grid of 1000 objects( posible vertex into screen )
for i= 1 to 10
for a= 1 to 10
for c= 1 to 10
inc ob
make object box ob,1,1,1
position object ob,i*3,a*3,c*3
next c
next a
next i
position object 5000,10,10,0
position camera -40,50,-40
point camera 0,0,0
do
`camera movements
a#=wrapvalue(a#+mousemovex()/2)-leftkey()*10+rightkey()*10
cam#=wrapvalue(cam#+mousemovey()/2)
rotate object 5000, cam#,a#,0
`starting position of CAMERA OBJECT
x#=object position x(5000)
y#=object position y(5000)
z#=object position z(5000)
move object 5000,-10
`new camera after moving
lx#=object position x(5000)
ly#=object position y(5000)
lz#=object position z(5000)
move object 5000,10
`getting distance of every object (VERTEX) to the camera and comparing both distances
for i= 1 to 1000
obx#=object position x(i)
oby#=object position y(i)
obz#=object position z(i)
//dis#=intersect object(5000,x#,y#,z#,obx#,oby#,obz#)
//dis2#=intersect object(5000,lx#,ly#,lz#,obx#,oby#,obz#)
dis#=distance#(x#,y#,z#,obx#,oby#,obz#)
dis2#=distance#(lx#,ly#,lz#,obx#,oby#,obz#)
if dis#<dis2#-7 then color object i,rgb(0,255,0) else color object i,rgb(255,0,0)
if dis#<dis2#-7 then scale object i,100,100,100 else scale object i,20,20,20
next i
if upkey() then move object 5000,1
if downkey() then move object 5000,-1
set cursor 5,400
print "Move camera with arrowkeys"
print " Rotate camera with Mouse "
print "FPS ",screen fps()
sync
loop
function distance#(x1#,y1#,z1#,x2#,y2#,z2#)
value#=sqrt(((x2#-(x1#))^2)+((y2#-(y1#))^2)+((z2#-(z1#))^2))
ENDFUNCTION value#
@Kevin Picone
I will have a look at this, thanks.
I'm not a grumpy grandpa
