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 Discussion / Math Collision Tutorial - Finished

Author
Message
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 18th Apr 2004 18:50 Edited at: 18th Apr 2004 18:52
Here's the finished tutorial:
http://www.geocities.com/hatesurvivor/MathColl.htm

It covers:
-3D space basics
-3D movement basics

-Box Collision
-Sphere Collision
-Character / ellipsoid Collision

-Rooms

-Stairs
-Slopes

-Jumping
-Gravity

Free ofcourse I tried my best to explain everything, but im dutch so it was a little difficult for me

If you want to see more tutorials/chapters then email me (email adres is at the bottom of the tutorial page) or post here.

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Neofish
21
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 18th Apr 2004 19:54
does this have any relevance to Pro, which bits work, which dont etc, im asking cos im upgrading to pro in 4 days

Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 18th Apr 2004 21:09
Im sure it would work. The commands are not removed in PRO.

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
sadsack
21
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 18th Apr 2004 23:35
thank You, I been looking for something like that I can sink my teeth into. renny
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Apr 2004 19:43
Very nice work. The added illustrations will definately help out some people.

"eureka" - Archimedes
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 20th Apr 2004 12:16
Thanks. Any suggestions?

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Apr 2004 05:05
Well I just kinda skimmed through it, but did you mention anything about sliding collision? I just assumed it was in there.

"eureka" - Archimedes
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 21st Apr 2004 08:17
This ought to be stickied. That would save lots of space by keeping all those collision requests away.

Oh, and you should definitely add sliding collision. I just slipped through it, but did you put anything regarding collision with rotated collision boxes/spheres/etc? That would solve lots of problems.


"Story in a game is like story in a porn movie. It's expected to be there, but it's not that important." - John Carmack
Lukas W
21
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 21st Apr 2004 14:55
this is what I needed (i think, just looked throught it and copied it) for my world maker.. when you go into preview mode
-thanx man

Thief 3 : Deadly Shadows, The BEST game in the WORLD!
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 21st Apr 2004 14:58 Edited at: 21st Apr 2004 18:21
"uhm..." it explains sliding collision

Rotated boxes is thing im still working on. I've got a method, but it's still not bug free..

This is the rotated box collision method (so far so good)


This is not the result of 4 distance checks, but the result of a very big calculation...

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 21st Apr 2004 19:22
I recoded the whole function, take a look now



Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Apr 2004 09:31
i've done rotate box collision. only problem i had was the "sliding" part.

"eureka" - Archimedes
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 22nd Apr 2004 09:43
Thats because you are checking for it the wrong way, my tutorial explains the right way.

-Store X Y Z of object
-Move object on X-axis
-Check for collision and reposition object back if necessary

-Store X Y Z of object
-Move object on Z-axis
-Check for collision and reposition object back if necessary

-Store X Y Z of object
-Move object on Y-axis
-Check for collision and reposition object back if necessary

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 22nd Apr 2004 15:57
Quote: "Thats because you are checking for it the wrong way, my tutorial explains the right way."


Not really "right" or perfect, actually. From the example (the one with only 1 cube and sphere in it), it almost treats the sphere like a "pixellated" sphere because instead of checking for the "correct" new x and z positions, you just returned them to the old positions.

http://darkbasic.thegamecreators.com/?m=forum_view&t=23579&b=6

It's 3D sphere to sphere, but essentially the same since they're both math. The difference in mine is instead of repositioning it back to the original x, y, or z position, I crudely "calculated" where the supposed new position should be, so it looks more accurate (I said crudely because I used point object then move object to get the new x,y,and z pos instead of using actual maths. I had problems with the math so I rushed it into this). I think you can modify the repositioning part to use pure maths because I'm not that well acquainted with sin and cos in 3 dimensions

I'm not bashing you, but there is a potential of having a full math collision library if this is done right. So it needs rigorous testing and feedback


"Story in a game is like story in a porn movie. It's expected to be there, but it's not that important." - John Carmack
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 22nd Apr 2004 17:27 Edited at: 22nd Apr 2004 17:31
Well, if I use this method:


for a=1 to 1000

move object sphere,0.001 on x-axis
if collision then reposition

same for z-axis
same for y-axis
next a


Then its very accurate, but it will take some time.

example:





Another method is to check for the distance, if the distance is bigger than 0.0 then move the object using some limitations:

Moveable object's max speed = 1.0

And using this if-statement you can move it:

if distance > 0.0
speed# = distance
if speed# > max speed# (1.0) then speed# = max speed#
endif

and move the object by using speed#


But I won't change my tutorial. It's made for beginners, not for experts. They will never understand a function that contains 100+ calculations just for moving 1 object

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Apr 2004 22:49
I didn't use distance for my collision checks, just bounding boxes. Less intensive calculation. But EB, you've given my an idea on how to do the sliding for rotated boxes. Its so simple, and basically what I did for non-rotated. I feel dumb for not seeing that.

"eureka" - Archimedes
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 23rd Apr 2004 22:57
Not too sure If anyone's interested, but I just coded a Rotated Rectangle function, if you wanna have a look at it, jump over to:
http://darkbasic.thegamecreators.com/?m=forum_view&t=30313&b=6

It's not sliding, but It's extremely accurate, and Extrememly fast

Thanks.
Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 23rd Apr 2004 23:18
umh, jessticular, you are using the same method as I do (take a look at my code in the snippet forum and codebase)



Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 24th Apr 2004 03:49
Yeah, I got the idea for the little sphere's going at the rectangle from you And you're collision Routine was what inspired me to write mine, that's why I thought it relevant to post it here too .

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 24th Apr 2004 04:08
Funny, JessT's is actually faster and more accurate I converted it to DBC already.


"Story in a game is like story in a porn movie. It's expected to be there, but it's not that important." - John Carmack
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 24th Apr 2004 04:41
Funny, JessT's is actually faster

Im not sure if it's faster, how did you measure the speed anyway?

but anyway, ive begun writing code for a real rotated rectangle (size doesnt matter)

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 24th Apr 2004 04:58
Just eyeballed the fps. Or maybe he just had less polys. It was more accurate though.


"Story in a game is like story in a porn movie. It's expected to be there, but it's not that important." - John Carmack
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 24th Apr 2004 05:04
@Emperor Baal;
I didn't mean to put you down or anything, lol...

I'm sorry if you feel as though I have upstaged you at all, honestly, that was not my intention...

With my function, size is also irrelevant, you just have to pass it the x and z lengths, and it works it all out from there. And if you wanted to, you could quite easily modify it so that you pass it the cordinates of the four corners and work out the lengths from that...

My calculation simply boils down to a circle check, which you can see if you do not randomize the balls and continue to rotate the rectangle ( though I suspect that might happen for any rectangle collision )...

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 24th Apr 2004 14:44
No, I am not angry.

But my new method can calculate collision for X+Y+Z rotated shapes (rectangles, ellipsoids, etc)

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
nuclear glory
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 14th May 2004 04:35
Are you still working on this? The page is missing when I try to pull it up.

I should be able to provide you with webspace to setup your tutorial(s) up on now. You'll have FTP access to your own part of the server where you can upload and manage your content.

I'd also like to link to your tutorial as a "3rd party tutorial" from the "Tutorials" section of the Nuclear Glory website.

Would all of the above be okay with you?

I'm waiting for a few things to finalize with the host and then I can set you up. Should only be a day or so.

Lead Programmer/Director
Powerful Collision DLL for DBPro and DBC: http://www.nuclearglory.com
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 14th May 2004 10:25
My tutorial is up. But I got a little stuck with XYZ rotated shapes :S

But I will add a new chapter this week

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 15th May 2004 03:34 Edited at: 15th May 2004 03:35
this is a good job! Can u make one for pathfinding something like the A* thingie????

CURRENT PROJECT: RETRO PAC-MAN
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 15th May 2004 12:21
thats not quite math collision ey? But I could make one, if I knew how to code A-star effeciently.

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
nuclear glory
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 15th May 2004 21:26
Okay, we have hosting space setup for you now.

You can FTP in and upload and build as you see fit.

Email me for info: [email protected]

In the email, please provide the username and password you want.

I'll get you setup right away.

Lead Programmer/Director
Powerful Collision DLL for DBPro and DBC: http://www.nuclearglory.com
nuclear glory
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 18th May 2004 08:26
I sent the access info and haven't heard back. Let me know if you didn't get the email.

Lead Programmer/Director
Powerful Collision DLL for DBPro and DBC: http://www.nuclearglory.com

Login to post a reply

Server time is: 2025-05-23 20:20:31
Your offset time is: 2025-05-23 20:20:31