• 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
lastcodewarrior

collision detection w/compenetration

6 posts in this topic

Dear sirs,
I have a (hopefully very silly) question about a collision detection problem that I'm unable to solve myself [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img]

I need to check collisions between a (well, some) tri-mesh based moving object and a very simple fixed 3d "dungeon". The "dungeon" has a flat floor (a simple plane, trivial to check collisions there) and some tri-mesh walls around (walls can be very long and complex, however their triangles are mostly oriented in vertical). There are plenty of examples about reducing the complexity of collision checks (through trees and so) and I've already cut the problem down to just checking some (few) triangles of my 3d object against some (few) triangle candidates of the wall.

Again, checking triangle-triangle collisions is quite trivial (there are plenty of examples and algorithms around), but my problem is that my physics engine needs compenetration to calculate collision forces so I need to know not only where collision points are (easy), but also "how deep" the collision is and the collision "normals" in order to apply collision forces that "bounce" the object off the wall.

Now, this is a bit of a problem because if I cut down the problem to just a triangle-triangle collision it becomes difficult to get the right amount of compenetration and, most important of all, the right colliding "normal"; as an example, in a triangle that belongs to a perfectly flat wall surface I can get (depending on how the triangles of the object mesh are compenetrating the wall) a triangle side-to-triangle side collision, with a collision "normal" pointing in an "impossible" physical direction. In such a collision the only "right" normal would be the wall triangle normal, because the triangle is part of a wider flat surface and its sides cannot "generate" collision points, but how can I avoid this in the last, triangle-triangle collision detection step?

I've tried to investigate the gjk method but this only works for convex shapes and my walls are too complex to be reduced to convex pieces (they may be long and very twisty, with a complex local surface), so a triangle-triangle based algorithm would be preferable; anyone has any idea on how to solve this problem?

Thank you very much for any help!
0

Share this post


Link to post
Share on other sites
I can't quite envision the situation where this happens. There is probably a fundamental flaw with how you're doing it. Anyway, if it is indeed happening perhaps you could check for potentially "bad" collisions, e.g. very minimal contact area or odd angles of contact, and if so use the triangle's neighbouring triangles to create a pseudo-plane to get a normal from? I say pseudo-plane because I doubt all points will be co-planar.
0

Share this post


Link to post
Share on other sites
[quote name='lastcodewarrior' timestamp='1335956000' post='4936721']I've tried to investigate the gjk method but this only works for convex shapes and my walls are too complex to be reduced to convex pieces (they may be long and very twisty, with a complex local surface), so a triangle-triangle based algorithm would be preferable; anyone has any idea on how to solve this problem?[/quote]This is nontrivial to say the best, you might want to look at [url="http://gimpact.sourceforge.net/"]gimpact[/url], I've been told it works fine with arbitrary meshes. Or at Bullet, which integrates gimpact as well as far as I've understood.

Also consider separate collision geometry. Graphic meshes build up in complexity much faster than collision can handle. Edited by Krohm
0

Share this post


Link to post
Share on other sites
[quote name='jefferytitan' timestamp='1335997290' post='4936903']
I can't quite envision the situation where this happens
[/quote]
Well, look at the picture attached. The grey triangles are part of the wall, and the red one is part of the object. The red triangle is colliding with the wall (the 'c' vertex is penetrating the wall with a penetretation depth showed by the green arrows). Problem is that the red triangle is in collision with two wall triangles, both sharing the a-b side, and when the narrow-phase triangle-to-triangle collider calculates the penetration depth it will report a side-to-side collision between one (well, both) of the grey (wall) triangles a-b side and the red (object) triangle c-d side (showed by the blue arrows), because maybe the "blue" penetration depth is smaller than the "green" one. So, the collision normal will be reported along the blue line, whereas it's quite obvious that this is a "wrong" collision normal and that in that case the only "right" collision normal should be along the green line. Any subsequent penalty force applied to the red object, of course, will be wrong and the object will rebounce in a "wrong" way (which is, btw, exactly what is happening to me...) [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='Krohm' timestamp='1336025583' post='4936981']
Also consider separate collision geometry. Graphic meshes build up in complexity much faster than collision can handle.
[/quote]
Yes, you are right, but from my previous example you can see that I'm having problems even with a very very simple geometry (a perfectly flat wall made by a simple triangle strip). Thank you, however, for the gimpact link, I'll give it a look!
0

Share this post


Link to post
Share on other sites
[quote name='lastcodewarrior' timestamp='1336039856' post='4937046']
Well, look at the picture attached. The grey triangles are part of the wall, and the red one is part of the object. The red triangle is colliding with the wall (the 'c' vertex is penetrating the wall with a penetretation depth showed by the green arrows). Problem is that the red triangle is in collision with two wall triangles, both sharing the a-b side, and when the narrow-phase triangle-to-triangle collider calculates the penetration depth it will report a side-to-side collision between one (well, both) of the grey (wall) triangles a-b side and the red (object) triangle c-d side (showed by the blue arrows), because maybe the "blue" penetration depth is smaller than the "green" one. So, the collision normal will be reported along the blue line, whereas it's quite obvious that this is a "wrong" collision normal and that in that case the only "right" collision normal should be along the green line. Any subsequent penalty force applied to the red object, of course, will be wrong and the object will rebounce in a "wrong" way (which is, btw, exactly what is happening to me...)
[/quote]

I see. It seems to me that you need to make some assumption to resolve this. For example, if you assume that all meshes are closed, it is impossible for a triangle to collide with the edge of another triangle. Therefore you can either assume the collision is in the direction that the object is moving, or that it's in the direction of the normal of the triangle, depending upon which assumption works out better. If you draw a line from point c in the direction of either of the grey triangles' normals until it hits the plane of either grey triangle, it will be roughly the green line.
0

Share this post


Link to post
Share on other sites
Looks like the best thing to do here is to use bounding spheres. It is easy to calculate bounce with spheres. This should help
[url="http://www.gamasutra.com/view/feature/3015/pool_hall_lessons_fast_accurate_.php"]http://www.gamasutra.com/view/feature/3015/pool_hall_lessons_fast_accurate_.php[/url]
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