Thanks guys.
Quote:
Well, there's a question of whether your Triangle class should actually be a value type
Currently I am importing a model and extracting all the mesh triangles and storing them in a list.
Each time an object is created/spawned using that model, it will require its own copy of the mesh triangles as its transform will be different to the original model transform.
Each time an object is moved, all the triangle vertices that make up the object mesh will have to be transformed by the world transform.
public Matrix World_Transform { get { // Should we recreate the world transform? (Has the entity's properties been updated this frame) if (recreateWorld) { world_Transform = Matrix.CreateScale(scale) * Matrix.CreateFromQuaternion(orientation); world_Transform.Translation = body.Position; // Now the world transform has been recreated flag this property as false recreateWorld = false; for (int i = 0; i < triangles.Count; ++i) { triangles.Transform(world_Transform); } } return world_Transform; } }
I require all these triangles meshes because decal creation requires clipping to triangle meshes.
Am I approaching this in the correct way or can anyone suggest a better method of dealing with model meshes and triangle transformation?
EDIT:
Memberwise cloning (shallow copy) doesn't work:
int totalTriangles = model_Info.Triangles.Count; triangles = new List<CD_Triangle>(totalTriangles); for (int i = 0; i < totalTriangles; ++i) { triangles.Add(model_Info.Triangles.Clone()); }..... public CD_Triangle Clone() { return (CD_Triangle)this.MemberwiseClone(); }
Quote:
or even just allowing the Properties to be set manually.
Something like this, or is that overkill?
int totalTriangles = model_Info.Triangles.Count; triangles = new List<CD_Triangle>(totalTriangles); for (int i = 0; i < totalTriangles; ++i) { CD_Triangle t = model_Info.Triangles; triangles.Add(new CD_Triangle(t.A, t.B, t.C)); }
[Edited by - Spa8nky on April 14, 2010 6:08:13 AM]