Ok well we all know sparky's dll, so lets get to the point. The SC_SphereSlide command in my code (in the snippet below) allows nice sliding collision with objects such as cubes, but as soon as I use it on a loaded .x model the collision only occurs in the very center of the loaded object in a sphere with the given radius.
REM ----------------------------------------------------------------------------------------------------------------------------- REM
REM INITIALIZATION REM
REM ----------------------------------------------------------------------------------------------------------------------------- REM
set display mode 1366, 768, 32
sync on
sync rate 60
autocam off
hide mouse
set ambient light 100
REM ----------------------------------------------------------------------------------------------------------------------------- REM
REM VARIABLES REM
REM ----------------------------------------------------------------------------------------------------------------------------- REM
ox# = 0 `old position of player
oy# = 0
oz# = 0
x# = 0 `new position of player
y# = 0
z# = 0
cx# = 0 `position of player after collision
cy# = 0
cz# = 0
xa# = 0 `angle of player
ya# = 0
za# = 0
speed# = 0.2 `speed of player
rot# = 3 `speed of rotation
I$ = "" `input variable
C = 0 `collision flag
dist# = 10 `camera follow distance
yint# = 0 `intersection with the terrain
REM ----------------------------------------------------------------------------------------------------------------------------- REM
REM LOAD MEDIA REM
REM ----------------------------------------------------------------------------------------------------------------------------- REM
objPlayer = 1
load object "chaon.x", objPlayer
objTerrain = 2
load object "terrain_002.x", objTerrain
scale object objTerrain, 10000, 10000, 10000
objHouse001 = 3
load object "house_002.x", objHouse001
yint# = 10000 - intersect object(objTerrain, 0, 10000, 100, 0, -10000, 100)
position object objHouse001, 0, yint#, 100
scale object objHouse001, 500, 500, 500
SC_SetupComplexObject objHouse001, 0, 0
REM ----------------------------------------------------------------------------------------------------------------------------- REM
REM MAIN LOOP REM
REM ----------------------------------------------------------------------------------------------------------------------------- REM
do
ox# = object position x(objPlayer)
oy# = object position y(objPlayer)
oz# = object position z(objPlayer)
`------------------------------- MOVEMENT ---------------------------------
if upper$(inkey$()) = "W" or upkey() = 1
move object objPlayer, speed#
endif
if upper$(inkey$()) = "S" or downkey() = 1
move object objPlayer, -speed#
endif
if upper$(inkey$()) = "A" or leftkey() = 1
ya# = ya# - rot#
yrotate object objPlayer, ya#
endif
if upper$(inkey$()) = "D" or rightkey() = 1
ya# = ya# + rot#
yrotate object objPlayer, ya#
endif
`----------------------------- TERRAIN WALKING -----------------------------
x# = object position x(objPlayer)
y# = object position y(objPlayer)
z# = object position z(objPlayer)
yint# = 10000 - intersect object(objTerrain, x#, 10000, z#, x#, -10000, z#)
position object objPlayer, x#, yint#, z#
`------------------------------- COLLISION ---------------------------------
x# = object position x(objPlayer)
y# = object position y(objPlayer)
z# = object position z(objPlayer)
C = SC_SphereSlide(objHouse, ox#, oy#, oz#, x#, y#, z#, 1, 0)
if C > 0
cx# = SC_GetCollisionSlideX()
cy# = SC_GetCollisionSlideY()
cz# = SC_GetCollisionSlideZ()
position object objPlayer, cx#, cy#, cz#
endif
`----------------------------- CAMERA MOVEMENT -----------------------------
x# = object position x(objPlayer)
y# = object position y(objPlayer)
z# = object position z(objPlayer)
set camera to follow x#, y#, z#, ya#, dist#, 5, 5, 1
sync
loop
If you don't understand what I mean, here is a diagram.
key:
O = collision
* = object
cube:
OOOOO
O***O
O***O
O***O
OOOOO
loaded model:
*****
**O**
*****
EDIT: Ahh sorry I was wrong. The cube doesn't work either. Looking at the diagram though, the cube diagram is how the collision should work, and the loaded model diagram is what is happening.
EDIT2: It would seem that it doesn't like the "scale object" command. I use it before SC_SetupObject but if the object is scaled the collision won't work how it is meant to.