- Procedure BuildMD5Mesh(MD5 : TMD5File; Mesh : TMD5Mesh);
- var
- V,W : Integer;
- Pos,Joint : TVector3f;
- TM : TMatrix;
- Weighting : Single;
- begin
- // Build The Vertex's
- For V := 0 to Mesh.Header.NumVerts-1 do
- begin
- Mesh.Verts[v].Position := SetVector(0,0,0);
- Mesh.Verts[v].Colour := TColorToTVector3f(RGB(Random(256),Random(256),Random(256)));
- For W := 0 to Mesh.Verts[v].WeightCount -1 do
- begin
- Joint := MD5.Joints[Mesh.Weights[Mesh.Verts[v].WeightId + W].BoneId].Position;
- TM := MD5.Joints[Mesh.Weights[Mesh.Verts[v].WeightId + W].BoneId].Matrix;
- Weighting := Mesh.Weights[Mesh.Verts[v].WeightId + W].Factor;
- Pos := Mesh.Weights[Mesh.Verts[v].WeightId + W].Position;
- Pos := GetPosWithMatrix(Pos,TM);
- Pos := AddVector(Pos,Joint);
- Pos := ScaleVector(Pos,Weighting);
- Mesh.Verts[v].Position := AddVector(Mesh.Verts[v].Position,Pos);
- end;
- end;
- end;