The collisions is worked.
need Dark Occlusion
Rem --------------------------------------------------------------
Rem Dark Occlusion Example
Rem --------------------------------------------------------------
SET CAMERA RANGE 1, 50
// Enable syncing
Sync on
Sync rate 60
autocam off
make object sphere 2,0.5
position object 2,-80,15,-20
MAKE OBJECT COLLISION BOX 2, -0.3, -0.3, -0.3, 0.3, 0.3, 0.3, 0
rem sET OBJECT COLLISION TO SPHERES 2
aUTOMATIC OBJECT COLLISION 2, 0.4, 0
rem sc_setupObject 2,0,1
rem set alpha mapping on 2,50
rem disable object zwrite 2
// Set the general occlusion settings: PixelError=4, Fps=every frame
set occlusion settings 4, 0
i=20000
for x=1 to 100
for z=1 to 100
objectID = i
// Create the cube
make object cube objectID, 1
sc_setupObject objectID,1,2
// Position the cube at a random position
position object objectID, x, -1, z
MAKE OBJECT COLLISION BOX objectID, -0.6, -0.6, -0.6, 0.6, 0.6, 0.6, 0
// Enable occlusion culling for the cube
set object occlusion cull objectID, 1, objectID
i=i+1
next z
next x
// Create 100 randomly placed cubes
for i=100 to 10000
objectID = i
// Create the cube
make object cube objectID, 1
sc_setupObject objectID,1,2
// Position the cube at a random position
xxx=rnd(200)
zzz=rnd(200)
position object objectID, xxx, 0, zzz
MAKE OBJECT COLLISION BOX objectID, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0
// Enable occlusion culling for the cube
set object occlusion cull objectID, 1, objectID
// Draw the cube as a wireframe so the occlusion culling is visible
rem set object wireframe objectID, 1
next i
position camera -5,5,-5
point camera 0,0,0
// Reset the mouse movement
null# = mousemovex()
null# = mousemovey()
position object 2,-5,5,-5
point object 2,0,0,0
// Main loop
Do
// Print the frames per second to the screen
text 10, 10, "Fps: "+str$( screen fps() )
// Print the number of static occluders checked in the last update call (These are grouped, so this will not match the actual number of objects)
text 10, 30, "Static: "+str$( get static occluders() )
// Print the number of dynamic occluders checked in the last update call
text 10, 50, "Dynamic: "+str$( get dynamic occluders() )
// Print the number of visible objects on the screen
text 10, 70, "Visible: "+str$( get visible objects() )
// Print the id's of the visible objects
text 10, 90, "---"
// Create a memblock holding the id's of all the visible objects on the screen
make memblock from visible objects 1
// Loop through the memblock and print the id's
for i=0 to get visible objects()-1
text 10, 100 + i*20, str$( memblock dword(1, i*4) )
next i
// Delete the temporary memblock
delete memblock 1
// Rotate the camera with the mouse
rem rotate player with mouse
yrotate object 2,object angle y(2)+mousemovex()/3.0
xrotate object 2,object angle x(2)+mousemovey()/3.0
oldx# = object position x(2)
oldy# = object position y(2)
oldz# = object position z(2)
if keystate(17)=1 then move object 2,0.1
if keystate(31)=1 then move object 2,-0.1
if keystate(30)=1 then move object left 2,0.1
if keystate(32)=1 then move object right 2,0.1
x# = object position x(2)
y# = object position y(2)
z# = object position z(2)
remstart
rem player only collides with group 1 (level) objs and moves freely through others
collide = sc_SphereSlideGroup(1,oldx#,oldy#,oldz#,x#,y#,z#,0.5,0)
if collide>0
rem if hit, reposition player, halt movement vector
x# = sc_getCollisionSlideX()
y# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
rem re-position the player
position object 2,x#,y#,z#
endif
remend
position camera object position x(2),object position y(2),object position z(2)
rotate camera object angle x(2),object angle y(2),object angle z(2)
pitch camera down 0
move camera -5
rem sc_updateObject 2
// Update dark occlusion for camera 0, all occluded objects will be culled
Update Dark Occlusion 0
// Sync the screen
Sync
rem sc_updateObject 2
Loop
// This function should be ignored
// Includes all the libraries (3D, Camera, Memblock) for Dark Occlusion
Function IncludeLibraries()
make object cube 1, 1
make camera 1
delete camera 1
delete object 1
make memblock 1, 1
delete memblock 1
endfunction