Does exactly what the title says
This does require Sparky's dll. It's almost poly to poly collision (practically as good),

but it only checks the edges of one object against the polies of the other.
sync on
`sync rate 40
null=make vector3(1)
null=make vector3(2)
rem make the cone
cone=1
make object cone cone,1
setupcomplexobject cone,0,10.0
position object cone,0,0,0
rotatespeed#=0.1
rem make the player
player=2
position camera 10,10,10
point camera 0,0,0
make object cube player,0.5
color object player,rgb(255,0,0)
setupcomplexobject player,0,2
movespeed#=0.01
camdist#=2.0
do
rem rotate and update the cone
rotate object cone,object angle x(1)+rotatespeed#,object angle y(1)+rotatespeed#,object angle z(1)+rotatespeed#
updateobject cone
rem rotate the player
inc rx#,mousemovey()*0.5
inc ry#,mousemovex()*0.5
rotate object player,rx#,ry#,0
rem move the player
if keystate(17) then move object player,movespeed#
updateobject player
x#=object position x(player)
y#=object position y(player)
z#=object position z(player)
rem rotate the camera
if leftkey()=1 then inc cy#,1
if rightkey()=1 then dec cy#,1
if upkey() then inc cx#,1
if downkey() then dec cx#,1
position camera camdist#*cos(cx#)*sin(cy#)+x#,camdist#*sin(cx#)+y#,camdist#*cos(cx#)*cos(cy#)+z#
point camera x#,y#,z#
rem print outputs
set cursor 0,5
print "fps: "+str$(screen fps())
print "colliding: "+str$(colliding(player,cone))
sync
loop
rem gets a vertex from a memblock and stores it to a certain vector
function getvertex(number,vector)
set vector3 vector,memblock float(1,12+(number*32-32)),memblock float(1,16+(number*32-32)),memblock float(1,20+(number*32-32))
endfunction
rem returns if two vertices are the same
function samevertex(vert1,vert2)
if x vector3(vert1)=x vector3(vert2)
if y vector3(vert1)=y vector3(vert2)
if z vector3(vert1)=z vector3(vert2) then same=1
endif
endif
endfunction same
rem returns if object is colliding or not
function colliding(object,target)
rem set up vars
dim vertex() as integer
empty array vertex()
x#=object position x(object)
y#=object position y(object)
z#=object position z(object)
rem convert object to memblock
make mesh from object 1,object
make memblock from mesh 1,1
rem throw out similar vertices
for x=1 to memblock dword(1,8)
same=0
getvertex(x,1)
for y=0 to array count(vertex(0))
getvertex(vertex(y),2)
if samevertex(1,2) then same=1
if same then exit
next y
if same=0
array insert at bottom vertex(0)
vertex(array count(vertex(0)))=x
endif
next x
rem perform ray casts between vertices
for x=0 to array count(vertex(0))
getvertex(vertex(x),1)
for y=0 to array count(vertex(0))
getvertex(vertex(y),2)
if samevertex(1,2)=0
if intersectobject(0,0,x#+x vector3(1),y#+y vector3(1),z#+z vector3(1),x#+x vector3(2),y#+y vector3(2),z#+z vector3(2),object)
if getobjecthit()=target then collision=1
endif
endif
if collision then exit
next y
if collision then exit
next x
rem clean up
delete mesh 1
delete memblock 1
endfunction collision
Made for DBP, not sure if it will work with DBC
formerly xMik
