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

Fragmenting a mesh using csg operations

3 posts in this topic

HI I'm considering different ways to implementing mesh fragmentation. One example would be fracture in the unreal engine. I've found a few interesting reads about this using vornoi.

 

http://www.joesfer.com/?p=60

https://sites.google.com/site/shusenliuspage/course-work/voronoi-based-shatter-effects

 

One approach was intersecting the object with a plane, displace a few vertexes on the plane and cut the mesh using it. Creating multiple planes and rotating them would resulting in several fragments.

 

I'm not very well traversed in graphics but I also came upon constructive solid geometry and figured that using intersection operations could result in a fragmented mesh.

 

I was something something along the lines that first you separate all/some of the faces of the mesh from each other or rather create copies of these. Then you extrude these inwards. Then using different CSG operations you create the fragments using intersection operations and kinda carve out the original mesh. And to avoid too much fragmentation you only carve from the original and not the fragments so that even if the extruded faces would overlap at times this would not result in extra fragmentation.

 

I'm curious if this could work? One problem I foresee is if you have a rectangle mesh it wouldn't produce very interesting results but if you subdivided the mesh first and then pick the order of faces to intersect at random it could produce better results.

 

 

 

0

Share this post


Link to post
Share on other sites

ON CSG

 

I looked into CSG a couple of years ago as I wanted to write my own implementation. In retrospect, in terms of time, I would've been far better off using a library. However, after doing a fair amount of research, the simplest approach turned out to be the most stable in terms of cost and flexibility; most importantly, it was the most suitable for me. The paper on the Laidlaw approach can be found here.

 

Mind you that debugging CSG code takes a lot of time and testing - you can't just assume that when you try one boundary case (eg vertex-edge) it'll work if you swap the meshes. Also, due to raycasting, Laidlaw's approach limits you to closed meshes (which is what you generally want, but not always). As far as I remember the paper has a small mistake in it, but I can't recall what it was. In any case, be ready to have to write plenty of additional code from a custom memory manager to your own triangulator (in the very least you'll need to perform convex primitive decomposition) and merger (to re-create mesh faces after CSG), which in and of themselves will take lot of time and testing. I found writing the merger probably the hardest to do so it wouldn't be dead slow, seeing as you're going to want to minimized overlapping edges and you'll be working with annoyances like T-junctions. The triangulator can be really tricky as well (I ended up implementing the slowest, but simplest approach - ear clipping) as you'll need to manage things like vertex ordering, repeated/collinear vertices, etc.

 

Overall, if you really want to implement your own CSG routine, be really methodical about it from get-go: index your vertices, pre-decompose everything into triangles for speed and thoroughly test everything at every step. The sad thing about the CSG procedure itself is that you can't really test it until you've written the bulk of it, which in Laidlaw's case is a lot of if statements, which need to be painstakingly correct.

 

If you're not absolutely bent on writing your own code, I heartily suggest you make use of a library. Ironically, since I was stubborn to write my own, I never actually compared all the different libraries out there...

 

PS - I never put enough effort into getting this working properly, but once you've done your initial decomposition, Laidlaw's approach is separable and can be extended to two threads (one per mesh), which I find to be of great value compared to other methods. Do not go with the BSP approach - it'll be dead slow as soon as the meshes have any decent number of polygons.

 

I ended up getting my code working at real-time framerates for box-cylinder (20 sides) intersection. I'm sure it can be further optimized to get real-time performance out of 40 + 40 tri meshes.

 

ON FRAGMENTING

 

I never did this, but overall I would consider three ways:

 

1) create a number of outlines of various shapes in any 3D modeling software that form a single whole. When fragmenting, simply run CSG on the object. I'm not sure how to avoid things like a chair's legs ending up in a single fragment, though (you'd probably need to scale the fragment meshes to best fit the size of the fragmented object). You could pre-rotate the fracture meshes to create fake variations of it.

 

2) pre-fracture the mesh manually (in most cases the fracturing is an offline process anyway)

 

3) consider a voxelization approach: voxelize the object when loading it and split off arbitrary "chunks" as needed; I'm not sure how to perform hole capping right off the bat, though

 

4) I wanted to find a link I saw a couple of years back regarding a pretty cool destructible material system, but couldn't find it. It was closed and still in beta AFAIR, but it handled stuff like wood chipping, etc. I did come across this, however (haven't read it yet, but hopefully it helps)

2

Share this post


Link to post
Share on other sites

Interesting. At first I thought using csg for this would be a good idea but as it would seem that implementing csg from scratch would be out of the question because it would probably take too much time. But experimenting with this using a ready made library might be a fun thing to do if I have the time sometime.

 

That last article was really interesting and took up several interesting topics, thanks!

1

Share this post


Link to post
Share on other sites

I should probably have mentioned these before, but there are two more options, although not really suitable for fragmenting geometry per se: CSG via the stencil buffer and the way Valve does rendering wounds in L4D2. The latter actually relates to subtractive CSG and uses projection to fill the hole. It's an interesting read, even if it's not directly applicable to standard geometry.

1

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