Transform heightmap to Static Mesh
Posted: Sun Jul 28, 2013 9:08 pm
I've been using a model up till now to create the terrain, but as i've seen that can get troublesome, so i've decided to use a heightmap to generate the map similar to the multitextured one from Riemers, here are the properties i'm using for the construction of the heightmap
And i want to use a StaticMesh because i'm planning to have drastic changes in height. Basically i want to know how can i construct this static mesh?? and i'm using xna draw methods instead of BepuphysicsDrawer
Code: Select all
public struct VertexMultitextured
{
public Vector3 Position;
public Vector3 Normal;
public Vector4 TextureCoordinate;
public Vector4 TexWeights;
public static int SizeInBytes = (3 + 3 + 4 + 4) * sizeof(float);
public static VertexElement[]
VertexElements = new[]
{
new VertexElement(0, VertexElementFormat.Vector3,
VertexElementUsage.Position, 0),
new VertexElement(sizeof (float)*3,
VertexElementFormat.Vector3,
VertexElementUsage.TextureCoordinate, 0),
new VertexElement(sizeof (float)*6,
VertexElementFormat.Vector4,
VertexElementUsage.TextureCoordinate, 1),
new VertexElement(sizeof (float)*10,
VertexElementFormat.Vector4,
VertexElementUsage.TextureCoordinate, 2),
};
}
public int Width { get; private set; }
public int Height { get; private set; }
private Effect effect;
private Texture2D bitmap;
private Texture2D[] textures;
private string asset;
private string[] textureAssets;
private float[,] data;
private int minheight;
private int maxheight;
private VertexMultitextured[] vertices;
private int[] indices;
private VertexDeclaration vertexDeclaration;
private Matrix world;