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

Collision with a terrain mesh.

8 posts in this topic

Hello!

 

I know how to collide objects against a terrain heightfield, or a uniform triangle grid.

But how would I go about implementing collision detection with a terrain as an arbitrary triangle mesh?

For example with a height field you can't have tunnels or any kind of 'depth' to your scene.

One way I can think of is to use some sort of octree and split all the triangles. This should be fast, but for detailed terrain the size would get very big quickly.

 

 

Thanks!

0

Share this post


Link to post
Share on other sites

Get a the min/max bounding box of the object you want to collide with the terrain. Now get all terrain triangles between those two points. Then you can do a per-triangle collision with them. Thats the very basic, non-optimized algorythm, but at least it works unaffected by the terrain size. Its a bit too late for me to show you any example code, I hope you can follow...?

0

Share this post


Link to post
Share on other sites

Get a the min/max bounding box of the object you want to collide with the terrain. Now get all terrain triangles between those two points. Then you can do a per-triangle collision with them. Thats the very basic, non-optimized algorythm, but at least it works unaffected by the terrain size. Its a bit too late for me to show you any example code, I hope you can follow...?

 

"Now get all terrain triangles between those two points. " This is really where the complexity comes in, right? There needs to be some kind of spatial hierarchy to get the triangles.

0

Share this post


Link to post
Share on other sites

"Now get all terrain triangles between those two points. " This is really where the complexity comes in, right? There needs to be some kind of spatial hierarchy to get the triangles.

 

Well, you can pre-sort the triangles in a 2d array like structure on the xz-plane (in dx, that is, xy in opengl if I'm not confused; its as if you where looking from above). Then you simply take the min-point as the index of the first triangle, and iteratively add +1 on both the x and z axis until you are at the max point, adding each triangle at the next point to the potential collision list. Whereas 1 is the density of your terrain, if its more dense you need more steps, though I quess you'd want to use a less dense approximation, seeing how the graphical representation of a terrain can get quite complicated in the nearest LOD. Does it appear more clear now?

Edited by Juliean
0

Share this post


Link to post
Share on other sites

Yes it does. So if I have a tunnel or a cave or whatever, I could have multiple triangles under the same terrain "cell"?

0

Share this post


Link to post
Share on other sites


So if I have a tunnel or a cave or whatever, I could have multiple triangles under the same terrain "cell"?

 

Thats a little off my expertise, but from what I've heard and what I'd do is, that there is hole in the terrain where a cave entrance is, and the cave itself is a seperate mesh, not related to the terrain directly... Cliffs, overhangs, caves etc... are however a topic I haven't dealt with myself, so there might be different solutions there.

0

Share this post


Link to post
Share on other sites

I'm not sure it's okay to bump this, but what about using multiple heightmaps stacked onto each other?

Also, maybe instead of using uniform grids, use a uniform voxel 'box" where each triangle is put into it's own voxel?  Also I'm not even concerned about using LOD right now, first I wanna just get collision going in the case with overhangs/ cliffs etc

0

Share this post


Link to post
Share on other sites

Just a note: It is also common to use Octree or BVH to quickly get a list of nearby triangles you need to test against ~ these are better than using just grid (especially if your terrain is more complex somewhere and less complex somewhere else.

0

Share this post


Link to post
Share on other sites

I use a uniform grid. I mainly develop racing games and found that since the world is largely all on one plane, a grid works perfectly. It's very fast, minimal overhead for lookups etc, and I use the same grid for moving object collision detection.

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