Generating a curved floor

Jul 22, 2012 at 5:50 AM

Evening,

 

I have a texutre that contains my floor (placed in my scene editor). It's curved however, but I see we can generate polygons based off of textures. is this kind of thing efficiently for normal usage and floors, especially? Is it accurate enough for a sphere to roll along it?

Jul 22, 2012 at 11:25 AM
Edited Jul 22, 2012 at 11:25 AM

Have a look also at MSTerrain in Common\TextureTools which is a helper class for managing terrains.

As for the character movement it's a two-part problem:

- Do the polygons generated provide a "smooth" surface - you must test it. The TextureConverter has a series of undocumented parameters that I suppose can be played with. The usablility will further depend on many other things like scale, time step, solver iterations. I've seen a lot of demos with no issues in that regard. Usually problems lie elsewhere - like excessive forces, for example, can cause the character to bump because the solver cannot reach an optimal solution in a single step.  

- Character shape - a circle "should" be fine. Check this for more info:

http://www.iforce2d.net/b2dtut/ghost-vertices

Jul 22, 2012 at 10:13 PM

So, it's recommendatory I generate my terrain as a MSTerrain then and not an actual body? Is there documentation on this somewhere?

Coordinator
Aug 7, 2012 at 3:03 AM

MSTerrain, where MS stands for Marching Squares, is a class that can be used to create destructible terrains. I would recommend that you only use the texture to vertices tools at compile time instead of at run time. The reason is that there are edge cases that can blow up the engine (I have provided some helpers in the Vertices class to help with this).

For rigid non-destructible terrains, I would recommend using the Edge class as it provides you with some terrain based features such as edge chaining. Take a look at the GameDemo1 from the Simple XNA Samples project on how to use the Edge class for terrain.