Hi Lazy,
I think that the BrumeSquareMeshTextured object is good for terrains and triangles but if you wants something more specific there is another good solution.
Just take the class below (it's the current BrumeTriangleMeshTextured class) and modify it to meet your needs. It's the best sample for a triangle list.
- Code: Select all
using System;
using System.Collections;
using System.Drawing;
using System.Text;
namespace Lazy
{
public class BrumeTriangleMeshTextured : BrumeSimpleMesh
{
public BrumeVertex_PosNormTex1[] vertices = null;
public BrumeTriangleMeshTextured(Brume brume, string name, BrumeVector pt1, BrumeVector pt2, BrumeVector pt3)
: base(brume, name)
{
this.NbrVertices = 3;
VertexDeclaration = brume.GraphicApi.CreateVertexDeclaration();
this.VertexDeclaration.AddElement(0, BrumeVertexElementType.Position);
this.VertexDeclaration.AddElement(0, BrumeVertexElementType.Normal);
this.VertexDeclaration.AddElement(0, BrumeVertexElementType.TexCoords, 0);
this.PrimitiveType = BrumePrimitiveType.TriangleList;
this.PrimitiveCount = 1;
brume.Meshes.Add(name,this);
if (vertices == null)
{
vertices = new BrumeVertex_PosNormTex1[NbrVertices];
vertices[0].Position = pt1;
vertices[0].Normal = new BrumeVector(0, 0, -1.0f);
vertices[0].Tu = 0.0f;
vertices[0].Tv = 1.0f;
vertices[1].Position = pt2;
vertices[1].Normal = new BrumeVector(0, 0, -1.0f);
vertices[1].Tu = 0.5f;
vertices[1].Tv = 0.0f;
vertices[2].Position = pt3;
vertices[2].Normal = new BrumeVector(0, 0, -1.0f);
vertices[2].Tu = 1.0f;
vertices[2].Tv = 1.0f;
}
}
// TODO: à descendre dans la mesh générique (les vertices statiques seront à passer en variables d'instance ou creer globalVertices/vertices)
public override void Init()
{
Init(vertices, null);
}
}
}
You will notice that the constructor takes 3 points : you will have to change it in order to pass an array of vertices (your triangles).
NbrVertices should also be updated.
The PrimitiveCount is also set to 1 : you will have to modify that too.
Adding indexes is up to you depending on your triangle list (are all triangles different or are they sharing some vertices)
Hope it helped.