Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Can anyone assist with some collision code on un-uniform path objects

Author
Message
Matto
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 16th Nov 2002 03:29
I am trying to get a collision system in place to handle roads/paths in a 3ds format, therefore I can't use a get ground height to drop the object in place on the road or path, the closest I have got is with an inc and dec of the objects y position every turn but it is making a jumpy picture as I have to check if the player object is colliding with the road all the time, if it is the player object gets raised and if it is not the the player object gets dropped, as you can imagine there is lots of up and down movement causing the jumpy picture. Also when the drop is too hard for the allowed increment or decrement the object either floats or goes under ground.. not so handy really..

So would anyone know of a good workaround or fix to the height problem of a player object on an uneven road or path that is not a matrix using polygonal collision?

thanks for any help.
1ghz Cel,512 sdram 133,Gf2 MX 400 64,SBL 5.1,Win98
Best Upcoming MMOG - http://WWW.Atriarch.com
Project: Card Game with No Name
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 16th Nov 2002 03:45
I remember we set up our own get ground height functions based on our own array of data. It's not 100% accurate, but if you're going to do your landscape/ground this way, it's hard for you to get it 100% accurate without serious speed loss.

The method we used was this. Say your object is about 1000x1000 in size (x,z). You move systematically along the object, firing an object down onto the object using polygon collision, and when it colides, you store the object height.
eg:
'object 1 is terrain object
for x=0 to 100
for z=0 to 100
height = 1000
repeat
position object 2,x*10,height,z*10
dec height,1
until object collision(2,1) = 1
heightmap(x,z) = height
next z
next y

Basically, this moves 10x10 across your object, firing an object onto its surface, recording the height and saving this information to an array. Using this array height map you can make a function to return the height of the object at any x,z value.

A fairly decent method would be to take the four array height points around the x,z of where you want to check the height. And simply work out the ratio of displacement in the y from the points and derive a value for x,z.

The closer the measurements in your initial array, the more accurage your bump map is. If for a 1000x1000 object you stored a floating point height for every 1 unit of space, you're probably looking at a 4MB heightmap array which isn't too huge by todays memory standards and would be damn accuate. Seeing as the initial height checking is done when the program is first run (or stored in a file), the only speed limitations you're looking at is your formula to check ground height and 4MB array access times. Still a hundred times faster than polygon collision.

You final problem is that polygon collision doesnt work properly, as agreed to by Lee, so you'd have to test it very carefully.

Machine: P4 2200, 512MB, GeForce4 64MB, Audigy Platinum

There's a junglist inside every coder. http://www.kontact-kru.com for my own personal breakbeat terrorism.
Matto
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 16th Nov 2002 05:09
yes thanks for that info I appreciate your help very much, I will get working on it asap, I am doing preliminary work in DB1 for anything I can't get to work in DBP so it will prove usefull anyway thank you

1ghz Cel,512 sdram 133,Gf2 MX 400 64,SBL 5.1,Win98
Best Upcoming MMOG - http://WWW.Atriarch.com
Project: Card Game with No Name
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 16th Nov 2002 13:17
No probs. Just remember the actual function that calculates the height using data from the array is the key speed and accuracy issue. Also, seeing as polygon collision is buggy, you would be well advised to put sync statements inside your "object firing into the surface of the other object" routine, just so you can watch the first time to make sure the collisions are working correctly.

Machine: P4 2200, 512MB, GeForce4 64MB, Audigy Platinum

There's a junglist inside every coder. http://www.kontact-kru.com for my own personal breakbeat terrorism.
Matto
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 17th Nov 2002 02:54
Yes I will do that thankyou..

1ghz Cel,512 sdram 133,Gf2 MX 400 64,SBL 5.1,Win98
Best Upcoming MMOG - http://WWW.Atriarch.com
Project: Card Game with No Name

Login to post a reply

Server time is: 2024-04-25 17:18:52
Your offset time is: 2024-04-25 17:18:52