hmm, i think i understand it. Well i have been working on a little polygon collision routine using intersect object and memblocks. Heres my current work if you are intrested:
Sync Rate 0
Sync On
Autocam Off
Make Object sphere 1, 5
Make Object Cube 2, 5
Position Object 1, 0, 0, 0
Position Object 2, 40, 0, 40
Do
If Upkey() then move object 1, 0.5
If Downkey() then move object 1, -0.5
If leftkey() then turn object left 1, 0.5
if rightkey() then turn object right 1, 0.5
set camera to follow Object Position X(1), Object Position Y(1), Object Position Z(1), Object Angle Y(1), 8, 5, 1, 0
Col = PolyCol(1, 2, Object Position X(2), Object Position Y(2), Object Position Z(2))
If Col = 1 then Text 0, 0, "Collision" else Text 0, 0, "No Collision"
Text Screen Width() - 25, 0, Str$(Screen Fps())
Sync
Loop
Function PolyCol(Obj1, Obj2, x as float, y as float, z as float)
Make Mesh From Object 1, Obj1
Make Memblock From Mesh 1, 1
FVF = Memblock Dword(1, 0)
FVFS = Memblock Dword(1, 4)
NVTX = Memblock Dword(1, 8)
VDS = NVTX * FVFS
PCol = 0
For CurrentMem = 12 to (VDS - FVFS) Step FVFS
VTXX = Memblock Float (1, CurrentMem)
VTXY = Memblock Float (1, CurrentMem + 4)
VTXZ = Memblock Float (1, CurrentMem + 8)
IntS = Intersect Object (Obj2, VTXX + Object Position X(Obj1), VTXY + Object Position Y(Obj1), VTXZ + Object Position Z(Obj1), x, y, z)
If IntS =< 0 Then PCol = 1
Next CurrentMem
Close File 1
Delete Memblock 1
Delete Mesh 1
EndFunction PCol
Its is unfortunatly not very fast (i get 72 fps doing it against a cube as the player (i dont think the target object polycount really matters that much) and around 105fps with both objects as cubes) and not as accurate as i hoped it would be :/ Although, reading your post i think that accuracey issue is because of the distance going back up again - i was relying on it returning a minus number, but, doh me, of course it doesnt! your right it does make sense. Im not entirly sure how to account for that though, subtracting the radius of the object yes.. but how to know wether to subtract the width, height or length is currently baffling me a little as i think about it whilst writing this. it all depends on which side you just went through at what angle? I dont know, am i even making sense?
But i guess this is a little futile anyway unless i speed up this function somehow.. considering if i rem out the polycol() line in my code i get a nice 400fps and with it on i get between 75 and 105 depending on wether im checking with a cube a sphere.. thats a hefty frame loss -_- Although, as im intersecting against the world position of each of the models vertex's i guess its vertex collision and not poly
Ahh, what do you think? You reckon theres hope for this function? The only reason im trying to write it is because in my game your a tank, and theres trees. These trees have leafs n whatever. Dbp's polygon collision only checks against one objects polys and the other seems to be treated as a spherical collision.. well basically that meant that i couldnt drive *under* my tree leafs/branches ect without it causing a collision.. and suddenly stopping because you got too close to an tree leaf which is in actual fact 1 meter or two above your tank isnt very good for a fast paced tank deathmatch XD
p4 2.4ghz, 256ddr ram, Geforce4 MX 440
Innovate, redefine, recreate whats in your mind. It isnt fate, you decide, only you can cross that line.