This project is read-only.

JigLibX sample is missing some code?

Jan 2, 2008 at 5:26 AM
Edited Jan 2, 2008 at 5:37 AM
I was looking at the TriangleMeshObject in the JigLibX sample, and was wondering why it was taking in two parameters in its constructor that it did'nt use. The first parameter is a Matrix, and the other one is a Vector3. I don't know what the Vector3 is for, but I think the matrix SHOULD transform the mesh vertices, so that you could rotate, scale and position your mesh anywhere in the game world. I don't know why this part is not finished, but I can help by posting my version of the class, witch supports matrix transform:
class TriangleMeshObject : PhysicObject
TriangleMesh triangleMesh;

public TriangleMeshObject(Game game, Model model, Matrix orientation)
: base(game, model)
body = new Body();
body.Position = orientation.Translation;
collision = new CollisionSkin(null);

triangleMesh = new TriangleMesh();

Dictionary<string, object> tagData = model.Tag as Dictionary<string, object>;
Vector3[] vertices = tagData"Vertices" as Vector3[];
int[] indices = tagData"Indices" as int[];

List<Vector3> vertexList = new List<Vector3>();
List<TriangleVertexIndices> indexList = new List<TriangleVertexIndices>();

for (int i = 0; i < indices.Length / 3; i++)
indexList.Add(new TriangleVertexIndices(indicesi * 3 + 2, indicesi * 3 + 1, indicesi * 3 + 0));

for (int i = 0; i < vertices.Length; i++)
vertexList.Add(Vector3.Transform(verticesi, orientation));

triangleMesh.CreateMesh(vertexList, indexList, 4, 1.0f);
collision.AddPrimitive(triangleMesh, 1, new MaterialProperties(0.1f, 0.7f, 0.6f));

public override void ApplyEffects(BasicEffect effect)
effect.DiffuseColor = Vector3.One * 0.8f;
Jan 4, 2008 at 5:18 PM
Thank you for your code. I was just to lazy to add this to the samples :) The Matrix just gives the orientation - not the position. (Only the 3x3 are used - we will change the code later to use quaternion for orientation and the vector for position)