• Advertisement

Taming procedural mesh generation

Recommended Posts

I'm trying to generate a mesh for my game and I'm being overwhelmed by all the tricky details. I keep simplifying my goals to try to make it easier, but it's still a struggle. Soon I'll have nothing but a Tomb Raider grid, but I desperately want to find a design pattern or a trick of some sort to make the whole thing more manageable.

The game level is represented by a 2D array, like a height map, but I very much want vertical cliffs, so each corner of each cell has its own height, allowing it to be discontinuous with neighboring cells. That's good, but I very much want more than just axis-aligned cliffs; that would never look natural. I used to try to have cliffs at arbitrary angles, but I've since abandoned that ambition, and now I just want diagonal cliffs, so each cell can be divided into two triangles along one of the two diagonals, with each corner of each triangle getting its own height.

That's the vertical element. Horizontally I want to use Marching Squares to define various regions in the level, like desert, forest, lake, and so on. We just have to create fields of values across the corners of all the cells, then linearly interpolate between the corners to determine which field has the greatest value at any point. So, if value of the desert field is greater than value of the forest field, then that point is part of the desert, and so on. The beauty of Marching Squares is that it meshes each cell independently, so if we can just mesh a single cell, we can mesh the whole level. Unfortunately, the cliffs turn some of the squares of marching squares into triangles, as well as creating other complications.

The usual advice for marching squares is to have a lookup table filled with predefined meshes, but thanks to the cliffs the number of possibilities is exploding and the lookup table seems awkward. Now I'm thinking that we should generate a half-edge data structure from the grid to represent all the squares and triangles of the cells, then procedurally construct the game mesh from that.

I feel like I'm missing something and that this is all much harder than it should be. Is there some book I should read, or some algorithm I should be using? Is there some data structure that would solve all my problems?

Share this post


Link to post
Share on other sites
Advertisement

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


  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By regnar
      Hi!
      I've been trying to implement simple virtual globe rendering system using "3D Engine Design for Virtual Globes" book as a reference.  What I do is I use 6 planes to form a cube, send it to GPU and use vertex shader to form a sphere and add random noise to simulate surface of the planet. The problem is how do I do CPU work on the vertex data from now on - how do I get world space coordinates of a terrain patch to perform LOD techniques, how do I do camera-terrain collision detection etc. ?
    • By Gabriel Gonzalez
      Hi everyone, my name is Gabriel and this is my first post here. I graduated from college over three years ago with a degree in Physics and now I want to start a career as a gameplay programmer. Besides a single C++ programming class in college I have not had any prior experience programming. What I have done to learn until now is to use SFML to recreate Arkanoid and Space Invaders. My question is, am I on the right track if I just continue creating games from scratch using libraries such as SFML or would I benefit more if I move on to using an engine such as Unreal or Unity? Also, of how much help (if any) would my degree be when trying to join a team? I live in San Diego, CA if that matters at all.   I do appreciate in advance any guidance anyone could offer me.
    • By MidnightFoxGaming
      Hi, I’m starting out in game development as a whole and while I have some experience with programming in the past with small things like mods and a single byond game that I took over for a previous person I’m rather new to the start from the ground up thing.
      im looking to get some advice on where to start for tools/material/resources for such. I already have the core concept for the game hashed out, this has been a relitivly solo thing so far so any help is appreciated thank you.
    • By Caleb Adam
      I want to make a html5 canvas / javascript game, similar to agar.io. I know a little node.js, and I think I understand the way online multiplayer works, but now that I do understand I realize it's gonna be a ton of work if I want to do it from the ground up with something like socket.io. My question is: are there libraries that can help with the multiplayer aspects of my game (sending game packets, etc.), and if so, is the performance for that library fast enough to run my game? (has a latency at least as low as agar.io)
       
    • By Bakkerbaard
      I'm kinda stuck on a puzzle. Usually I'd now tell you what the puzzle was and ask for a walkthrough, but my problem is that the puzzle doesn't even exist yet. Been googling around a bit for helpful info, but I mainly end up on Ron Gilbert's site and he isn't helping much either on this specific point and I'm wasting valuable writing time looking for a solution.
      Problem is that I don't wanna do another "get item here/use item there" puzzle. I've got enough of that and there will be more. To add some variation I wanna try and do a different style of puzzle, a lever puzzle, or a mechanical puzzle, but that leads me to a way of thinking I can't seem to do. Here's the specific situation:
      I need a bunch of ostriches out of my way. They're on an ostrich farm and they get fed every day at five pm exactly. So I'll need to head into the church tower and make the bell ring five times. I'm thinking this needs to be done with a mechanism I could manipulate in a puzzly manner. Getting a hammer and banging the bell is too easy. The game doesn't work with actual time, so going all Medjay and meditate till five o' clock isn't an option. That bell's gonna need to ring five times, wether it's three or not.
      I already have access to the church tower, so that can't be puzzlefied and I can bullshit my way through most incosistencies, so adding a space age computer to a medieval belltower is actually an option if need be.
      I'm looking for someone who can point me to either a useful resource or someone who imagines stuff like this better than I do. 
      Oh, and pretending there will actually some day be a point that credits will roll: You will be credited if you please.
  • Advertisement