I'm just starting with Sparky's collision DLL V2.
But I have a problem with it.
When I run the examples they all work.
But when I use it in my code it always crashes.
So I made a little test program which you can see here, and have the same problem with it.
sync on
Backdrop on
set window on
SET DISPLAY MODE 1024,768,32
autocam off
Set camera range 1,10000
position camera 2000,500,100
LoadTerrain()
do
MoveCamera()
PrintData()
sync
loop
end
function LoadTerrain()
rem Load object
Load object "terrain5001dm/00000_00000_000.x",12
scale object 12,1,1,1
position object 12,0,0,0
SC_setupComplexObject 12,0,2
endfunction
function MoveCamera()
Rem Control the camera
If SPACEKEY()=1
Move camera 2
endif
if leftkey()=1
turn camera left 0.5
endif
if rightkey()=1
turn camera right 0.5
endif
endfunction
function PrintData()
rem print FPS
set cursor 0,0
print "FPS: ",str$(screen fps())
rem print polys
set cursor 0,15
print "POLY: ",statistic(1)
rem print groundheight
set cursor 0,30
print "GroundHeight: ",GetObjectHeight(12,camera position x(),camera position z())
endfunction
Function GetObjectHeight(id as integer, x as float, z as float)
pHeight as float
rem the DBP command
pHeight = 100000 - intersect object(id, x,100000,z, x, -100000, z)
rem Sparky's command
`pHeight = 100000 - sc_intersectobject(id, x,100000,z, x, -100000, z)
endfunction pHeight
delete memblock 1
I have attached the program with resources.
Can it be because the terrain has to many polygons?
It has 33000 poly's.
It crashes when I call my "GetObjectHeight" function, which uses "sc_intersectobject", if I replace it with the command of DBP it works.
Or is it because I use the trail version of DBP.