Jump to content
  • Advertisement
Sign in to follow this  
MiltonPlotkin

Problem with 3D edge collision

This topic is 2568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, first time posting, but here it is.

I have recently gone from programming in 2D Allegro to programming 3D DirectX. I have been trying to get a simple collision engine running for quite some time, my primary goal to make a sphere smoothly travel over angled terrain. So far, I have been mildly successful, and this works:
diagram.png

The ball successfully checks for the intersection of the planes normal from it's center, and slides down accordingly. No problem there.

However, I cannot get the ball to move accordingly when moving over the seam of two triangles, since it can no longer use the planes normal as calculation. I have tried this, but all it has accomplished is making the ball "spaz" whenever it gets near a seam and clip through:

diagram2.png

The above diagram depicts the ball outside of a triangles area (the triangle is facing directly towards the screen). A vector is made from each of the points of the triangle to the sphere (only one is shown), and projected on the corresponding edge. If the vector from the end of the edge projection to the sphere (blue vector) is smaller than the radius of the Sphere, move it by the amount of the intersection multiplied by the unit vector of blue.

I have managed to implement the above method in 2D, and it works fine, however, in 3D, the ball doesn't even need to be anywhere near the edge before it begins to "spaz" out. I'm wondering if it's a mathematical error rather than a coding one, would I be correct? Or is there an easier/different method I could use for this.

I understand this is asking for a lot. Thankyou very much for your help.

Share this post


Link to post
Share on other sites
Advertisement
As far as I understand, Bullet requires the user to explicitly mark shared edges for improved processing. Odds are the solution might be more involved than I could possibly understand. Perhaps have a look at its code, they call them "internal edges".

Share this post


Link to post
Share on other sites

As far as I understand, Bullet requires the user to explicitly mark shared edges for improved processing. Odds are the solution might be more involved than I could possibly understand. Perhaps have a look at its code, they call them "internal edges".


.........uh oh. I feel pretty awkward now... eh, heh, uh... am I on the wrong forum/thread? I'm not using bullet physics, I'm trying to make an engine from scratch.

Share this post


Link to post
Share on other sites
Let me elaborate.
You want to do that yourself.
This is clear.
But I'm warning you: the people behind one of the major physics implementations around thinks the problem you're trying to solve is not trivial.
Therefore, I expect your simple solutions won't work OR won't scale.
I guess I should have been more explicit.

Share this post


Link to post
Share on other sites
When it moves over the seam I think you need to detect that it is sharing collision with both triangles and average them. Imagine a mountain peak. A ball hits the peak, it should bounce up (the average normal) and not left or right of the peak. Maybe that helps. I have not done much physics but that should be what you need.

This video shows that there is a case when an edge hits that I just found, so I assume the above I posted would work. Or send him a youtube message.
http://www.youtube.c...h?v=pEftJ1Rv9PE

Share this post


Link to post
Share on other sites
Do you ensure that the edge/sphere checks to see if the collision happens between the endpoints of the line? If not edges nowhere near the sphere may be colliding with it because it is actually a line going infinitely in both directions. You also would need to check the corners of the triangle against the sphere as well, but you can handle that when you come to it.

Share this post


Link to post
Share on other sites
Hm...

Thanks everybody for the help. I'll write back when/if I figure out what I'm doing wrong.

EDIT: You were right. I do have to average the two triangles lines. Thanks!!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!