Right now, I'm using Sparky's DLL to build collision for models. What I do is build collision points around the .x model and use the intersectobject command. I actually have NGC, but this does this same thing and is faster.
The very first thing that you do is establish the current coordinates as the last known good ones.
char(1).oldx=object position x(char(1).object)
char(1).oldy=object position y(char(1).object)
char(1).oldz=object position z(char(1).object)
Then I test for y feet and y head collision.
rem ******************* Head collision ***************************
if intersectobject(0, 1, char(1).x,char(1).y+object size y(char(1).object)/2,char(1).z,char(1).x,char(1).y+object size y(char(1).object),char(1).z,0)
collisionY=1: collision=1
grav#=0
char(1).y=getstaticcollisiony()-object size y(char(1).object) `+.25 `-object size y(char(1).object)
char(1).x=char(1).oldx
char(1).z=char(1).oldz
text 200,120, "Collision Y head"
endif
rem ******************* Feet collision ***************************
position object ball(1),char(1).x,char(1).y+object size y(char(1).object)/2,char(1).z
position object ball(2),char(1).x,char(1).y,char(1).z
if intersectobject(0, 1, char(1).x,char(1).y+object size y(char(1).object)/2,char(1).z,char(1).x,char(1).y,char(1).z,0)
collisionY=1: collision=1
grav#=0
char(1).y=getstaticcollisiony()
text 200,120, "Collision Y feet"
endif
Then I apply basic physics and place the model.
char(1).y=char(1).y-grav#
if spacekey()
char(1).y=char(1).y+.5
endif
x#=char(1).x
y#=char(1).y
z#=char(1).z
inc grav#,gravity#
newy#=y#-grav#
rem if the camera doesn't collide from gravity, position it at its new location
position object char(1).object,x#,newy#,z#
setDataChar(i)
Then I test for x and z collision.
if intersectobject (0, 1, char(1).x,char(1).y+1,char(1).z,char(1).x,char(1).y+1,char(1).z+object size z(char(1).object),0) then collision=1:collisionZ=1
if intersectobject (0, 1, char(1).x,char(1).y+1,char(1).z,char(1).x,char(1).y+1,char(1).z-object size z(char(1).object),0) then collision=1:collisionZ=1
if intersectobject (0, 1, char(1).x,char(1).y+1,char(1).z,char(1).x+object size z(char(1).object),char(1).y+1,char(1).z,0) then collision=1:collisionX=1
if intersectobject (0, 1, char(1).x,char(1).y+1,char(1).z,char(1).x-object size z(char(1).object),char(1).y+1,char(1).z,0) then collision=1:collisionX=1
if collision=1
if collisionX then text 200,100, "Collision X"
if collisionY then text 200,120, "Collision Y"
if collisionZ then text 200,140, "Collision Z"
`walk through walls
if controlkey() then collisionX=0:collisionY=0:collisionZ=0
if collisionX=1 then char(1).x=char(1).oldx
if collisionZ=1 then char(1).z=char(1).oldz
endif
charX=char(1).x
charY=char(1).y
charZ=char(1).z
position object charNumber, charX,charY,charZ
`remend
collisionX=0
collisionY=0
collisionZ=0
collision=0
This handles x y and z collision separately. It then limits movement on the plain of collision, giving sliding collision. It is very fast. There are plenty of great collision routines on these boards, but none of them did quite what I wanted.
The x and z collision should be done at about the knees. Otherwise, your guy will be colliding with the terrain when he walks. This way, he'll automatically climb slopes that aren't too steep, and stairs if the distance between steps isn't too big.
You can build the x and z collision up more, doing the same checks at several y intervals up the height of the model.
The only way to improve it is to rotate the collision points based on the y-angle of the model. I've halfway implemented this, so it needs a bit of work...
function rotatePoints(obj as integer, angleY as float, x# as float,y# as float,z# as float)
for i=1 to 150
x#=(x#*cos(angleY))+(z#*sin(angleY))
z#=(z#*cos(angleY))+(z#*sin(-angleY))
position object obj,x#,y#,z#
next i
endfunction
The thing with this though is that the output points cannot be the literal points. You have to track the real point locations with an entity system, pass these values to the function, and the points will be rotated correctly. My games are all set up this way, so it's no big deal for me. It might be a headache for you.
Anyway, this was the first collision system I developed, and I'm working on something much much better. Development has been slow lately, but it's coming...
Hope this all help. It was a lot of typing