• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
pondwater

Penetration depth and direction

13 posts in this topic

So i've finished up my GJK algorithm and now im attempting to implement the EPA algorithm to determine penetration depth. From what i understand it returns a vector representing the direction and magnitude of the smallest penetration.

For me this isnt exactly what i want. I need an algorithm that would return the penetration depth for a specific direction. For example:

[img]http://i.imgur.com/hBGsm.png[/img]
Lets says i have an object moving in a particular direction, i want to determine the penetration depth in that direction so i can rectify the proper position as seen in A, verses B which gives the minimum penetration depth.

I assume this would be simpler than the typical EPA algorithm in that it only needs to search in a particular direction to find the distance from the origin to the hull of the minkowski difference. Any suggestions about finding the distance as precisely as possible?

Im thinking something along the lines of searching for the farthest point in the opposite direction the object is travelling in. However that is confined to vertices and wont be too accurate in some cases. Any ideas?
1

Share this post


Link to post
Share on other sites
It sounds like using a portion of Minkowski Portal Refinement/XenoCollide would get you what you want.

The core of the algorithm is basically a ray cast from inside the minkowski difference to the surface in some given direction. For intersection queries, it checks to see if the ray hits the surface or the origin first. Adapting it to find penetration depths in arbitrary directions by casting from the origin is pretty simple.
1

Share this post


Link to post
Share on other sites
[quote name='Norbo' timestamp='1312408470' post='4844225']
It sounds like using a portion of Minkowski Portal Refinement/XenoCollide would get you what you want.

The core of the algorithm is basically a ray cast from inside the minkowski difference to the surface in some given direction. For intersection queries, it checks to see if the ray hits the surface or the origin first. Adapting it to find penetration depths in arbitrary directions by casting from the origin is pretty simple.
[/quote]

hmm i remember looking at the MPR example on the XenoCollide website and never really understood its benefits over GJK. Then again, i'm a complete noob.

My knowledge of ray casting is quite limited. Lets say i cast from the origin outwards to an edge:

[img]http://i.imgur.com/uoUT1.png[/img]
How do i determine the magnitude of the ray to the edge when i only have vertex data?
0

Share this post


Link to post
Share on other sites
MPR works on the extreme points of objects, just like GJK. The general idea of a surface cast in MPR is that you create a triangle from support maps through which the ray passes, then incrementally refine that triangle until you reach the surface.

The incremental refinement process finds the extreme point along the current triangle's normal. That point, combined with the three vertices of the previous triangle, forms three new triangles. The outer face of that tetrahedron which contains the ray is picked as the new triangle, and the process continues.

A more detailed explanation can be found in the Game Programming Gems 7 book where XenoCollide was published. The XenoCollide website also has some code samples I believe. Some other open source engines have implementations that you could look at too (including mine, [url="http://bepuphysics.codeplex.com/"]BEPUphysics[/url]).
1

Share this post


Link to post
Share on other sites
[quote name='Norbo' timestamp='1312414213' post='4844256']
MPR works on the extreme points of objects, just like GJK. The general idea of a surface cast in MPR is that you create a triangle from support maps through which the ray passes, then incrementally refine that triangle until you reach the surface.

The incremental refinement process finds the extreme point along the current triangle's normal. That point, combined with the three vertices of the previous triangle, forms three new triangles. The outer face of that tetrahedron which contains the ray is picked as the new triangle, and the process continues.

A more detailed explanation can be found in the Game Programming Gems 7 book where XenoCollide was published. The XenoCollide website also has some code samples I believe. Some other open source engines have implementations that you could look at too (including mine, [url="http://bepuphysics.codeplex.com/"]BEPUphysics[/url]).
[/quote]

okay that makes a little more sense.

Sorry the question above about the ray casting was about your comment in the first post [quote] Adapting it to find penetration depths in arbitrary directions by casting from the origin is pretty simple. [/quote]

Lets say my GJK returns true, so i know the objects are intersecting, now to find the penetration depth i a particular direction all i need to do is find the distance from the origin to the farthest 'point' in the minkowski difference in that particular direction (or possibly the opposite direction, not sure yet). So for the the example below, considering that i onyl have vertex data, what would be the steps to get the magnitude of the vector from the origin to the hull of the minkowski difference?

[img]http://i.imgur.com/ddFoT.png[/img]
0

Share this post


Link to post
Share on other sites
That distance is obtained from the process I described in my previous post.

The triangle ("portal") is refined until it reaches the surface. Once you find the surface, you have a plane (from the portal) and a ray. Intersect the ray with that plane.
1

Share this post


Link to post
Share on other sites
[quote name='Norbo' timestamp='1312417808' post='4844275']
That distance is obtained from the process I described in my previous post.

The triangle ("portal") is refined until it reaches the surface. Once you find the surface, you have a plane (from the portal) and a ray. Intersect the ray with that plane.
[/quote]

well i figure if i know the direction im casting, i can find the plane by seaching for the 3 points on the minkowski difference farthest in the direction. I guess what im asking is how do i intersect the ray with that plane.
0

Share this post


Link to post
Share on other sites
[quote name='pondwater' timestamp='1312418904' post='4844282']
well i figure if i know the direction im casting, i can find the plane by seaching for the 3 points on the minkowski difference farthest in the direction.
[/quote]
That will not work in general. Consider this 2d example:
[img]http://i.imgur.com/xwGwy.jpg[/img]

[quote name='pondwater' timestamp='1312418904' post='4844282']
I guess what im asking is how do i intersect the ray with that plane.
[/quote]
It's just a regular old geometry test. Googling ray-plane intersection or line-plane intersection should come up with plenty of resources.
1

Share this post


Link to post
Share on other sites
[quote name='Norbo' timestamp='1312419719' post='4844284']
[quote name='pondwater' timestamp='1312418904' post='4844282']
well i figure if i know the direction im casting, i can find the plane by seaching for the 3 points on the minkowski difference farthest in the direction.
[/quote]
That will not work in general. Consider this 2d example:
[img]http://i.imgur.com/xwGwy.jpg[/img]

[quote name='pondwater' timestamp='1312418904' post='4844282']
I guess what im asking is how do i intersect the ray with that plane.
[/quote]
It's just a regular old geometry test. Googling ray-plane intersection or line-plane intersection should come up with plenty of resources.
[/quote]

bugger... just when i thought it was going to be easy...

Im trying to think of a way to find the plane that would be intersected for my arbitrary direction. From what i understand MPR would give me a plane closests to the origin on the outside of the minkowski difference.

But in my case where i simply want to intersect the farthest plane in a certain direction, it wont necessarily be the plane given by MPR, because it may not be the closest plane to the origin, for example:
[img]http://i.imgur.com/lQ2o5.png[/img]
In this case i would still need to determine which plane would be intersected.

I guess what im trying to ask is a) can i use my boolean GJK test to first determine whether a intersection has occuredand then go about ray casting and determining the plane that will be intersected? Do i have to use an MPR implementation?

Is there a way to find which plane it would be intersecting wittout MPR?
1

Share this post


Link to post
Share on other sites
A surface cast with MPR will give you the correct surface plane. Keep in mind when I'm talking about MPR, I am not talking about the specific implementation which computes boolean intersection.

I am referring to the slightly modified form which starts the ray at the origin (known to be in the minkowski difference if GJK returns intersection, barring numerical issues) and ray casts in an arbitrary direction. The portal is refined based on the ray direction you pick. Since the portals are incrementally refined based on the ray's direction, the final surface plane it finds will be the correct surface plane.

So:
[quote][color="#1C2837"][size="2"]can i use my boolean GJK test to first determine whether a intersection has occuredand then go about ray casting and determining the plane that will be intersected?[/size][/color][/quote]
Yes, the GJK test can be used to determine the containment of the origin.

[quote][color="#1C2837"][size="2"]Do i have to use an MPR implementation?[/size][/color]
[color="#1C2837"][size="2"]Is there a way to find which plane it would be intersecting wittout MPR?[/size][/color][/quote]

Off the top of my head, I can't think of another alternative which is as simple/fast as MPR while still giving correct results. There probably exists something out there in undiscovered (or at least unknown to me at the moment) algorithm space, and you could look for that if you really wanted :)

However, there are probably a lot of workarounds- algorithms which may not be quite as direct, simple, or fast, but should do the trick. Here's one I just thought up- haven't implemented anything like it, but I don't see a reason why it wouldn't work:

If you have GJK ray casting implementation, you should be able to do a similar, reversed operation. Pick a ray origin using direction * X, where X is a number large enough to guarantee that the ray origin is outside of the convex shape. Then, for the ray direction, use the negative direction you would have used for an MPR cast since we're pointing back at the shape. The distance from the minkowski space origin and the surface of the minkowski difference is then X - T, where T is the distance along the GJK ray direction to the impact location.
1

Share this post


Link to post
Share on other sites
ahh i kept thinking you were talking about using MPR to determine if there is a collision.

Using the MPR this way seems very similar to the EPA, if it were given a arbitrary search direction, i guess ill have to fish around to figure out how the algortihm determines which plane is the correct plane.

Thank you for all of your time and help, its is greatly appretiated!
0

Share this post


Link to post
Share on other sites
Is this in 2d?

If so, I would just compute the full minkowski difference and have done with it - it will end up being faster and more robust in the long run :)

[url="http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/"]http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/[/url]

Cheers, Paul.
0

Share this post


Link to post
Share on other sites
[quote name='wildbunny' timestamp='1313161904' post='4848251']
Is this in 2d?

If so, I would just compute the full minkowski difference and have done with it - it will end up being faster and more robust in the long run :)

[url="http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/"]http://www.wildbunny...on-for-dummies/[/url]

Cheers, Paul.
[/quote]

Unfortunately it;s in 3D :(
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0