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 / Bouncing off arbitrary objects?

Author
Message
Jason Leigh
23
Years of Service
User Offline
Joined: 7th May 2003
Location: United States
Posted: 1st Sep 2003 20:05
Hi
I am trying to write some code to allow a ball to bounce off arbitrary objects. Basically what I need is to determine the plane of intersection of the collided object, or its normal so I can compute the correct bounce angle.

Does anyone have any ideas on how to approach this- perhaps using a combination of "make object collision box" and "get object collision x()...."

I have tried these calls already but they do not appear to be providing the correct response. Not only that, if the x,y,z returned from "get object collision" is supposed to be the slide direction, then what I've gotten so far doesn't even come close.
I am also experiencing a situation where in some cases collisions are not even detected if the ball impacts the object in a different direction- even though the objects I am using are simple boxes created using the make box call...
(ie I am creating my own 3D objects that may have incorrectly set normal directions..)

Any help or any clue as to how get object collision is supposed to work would be greatly appreciated.

Thanks
Jason
APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 1st Sep 2003 20:25 Edited at: 1st Sep 2003 20:28
I haven't actually done this in code but I was planning on using a method like this. When your ball hits an object, you know it's current position and the location of where the collision occurred, ie. OBJECT COLLISION X/Y/Z. What I would do is use the OBJECT INTERSECT /INTERSECT OBJECT (Haven't got the help on this machine!), to create three intersect lines very close to each other in the direction from the center of your ball to the collision point. Each result would yield three intersect line lengths. Haven't got the math here but if this was converted to a vector, you can compute the surface normal by using the three lengths subtracted from their point of origins. These three new points can be used to compute the normal of the surface that the object collided with.

I haven't explained this very well but try to imagine from the center of your ball, three lines. All three will hit the surface along the vector from the center of your ball to the point of intersection where the collision occured. Each line is slightly offset from this vector. Once you've obtained the INTERSECT OBJECT length, subtract this length from the co-ordinates of where the lines begin, the longest length I think. Use the three points to computer the normal. You may need to play around with the idea and maybe someone else will come up with a different possibility.


Login to post a reply

Server time is: 2026-07-23 15:49:46
Your offset time is: 2026-07-23 15:49:46