public void BuildBasicCollision(Lod model) { nxs = Convert.ToString(22239310); mesh = Convert.ToString(1213416781); num1 = 1; num2 = 3; unkSmall = 0.001f; num3 = 255; num4 = 0; List <Int3> ltriangles = new List <Int3>(); List <CollisionMaterials> lmatTypes = new List <CollisionMaterials>(); for (int i = 0; i != model.Parts.Length; i++) { model.Parts[i].Material = ConvertCollisionMats(model.Parts[i].Material).ToString(); for (int x = 0; x != model.Parts[i].Indices.Length; x++) { ltriangles.Add(new Int3(model.Parts[i].Indices[x])); lmatTypes.Add((CollisionMaterials)Enum.Parse(typeof(CollisionMaterials), model.Parts[i].Material)); } } nPoints = model.Vertices.Length; nTriangles = ltriangles.Count; if (num2 == 3) { num5 = nTriangles - 1; if (nTriangles <= 256) { UnkData = new byte[nTriangles]; } else { unkBytes = new short[nTriangles]; } } points = new Vector3[nPoints]; for (int i = 0; i != points.Length; i++) { points[i] = model.Vertices[i].Position; } triangles = ltriangles.ToArray(); unkShorts = lmatTypes.ToArray(); unk0 = 1; unk1 = 1; unkShortSectorData = new short[nTriangles]; unkByteSectorData = new byte[nTriangles]; opcHbmData = new HBMOPCDataClass(); opcHbmData.BuildBasicOPCHBM(); boundingBox = new BoundingBox(); unkFloats = new float[14]; //sort out bounding box/sphere List <Vertex[]> data = new List <Vertex[]>(); data.Add(model.Vertices); boundingBox = new BoundingBox(); boundingSphere = new BoundingSphere(new Vector3(0), 0); boundingBox.CalculateBounds(data); boundingSphere.CreateFromBoundingBox(boundingBox); unkSize = nTriangles; unkSizeData = new byte[unkSize]; for (int i = 0; i != unkSizeData.Length; i++) { unkSizeData[i] = 0; } }
public void BuildBasicCollision(Lod model) { nxs = Convert.ToString(22239310); mesh = Convert.ToString(1213416781); ver = 1; flags = MeshSerialFlags.MSF_MATERIALS; convexEdgeThreshold = 0.001f; maxVertices = 255; num4 = 0; nPoints = model.Vertices.Length; nTriangles = model.Indices.Length / 3; points = new Vector3[nPoints]; indices = new uint[model.Indices.Length]; materials = new CollisionMaterials[model.Indices.Length]; int idx = 0; for (int i = 0; i != model.Parts.Length; i++) { ModelPart part = model.Parts[i]; for (int x = (int)part.StartIndex; x < part.StartIndex + part.NumFaces * 3; x++) { indices[x] = model.Indices[x]; Enum.TryParse(model.Parts[i].Material, true, out materials[x]); } } for (int i = 0; i != points.Length; i++) { points[i] = model.Vertices[i].Position; } numConvexParts = 0; numFlatParts = 0; convexParts = new short[nTriangles]; flatParts = new short[nTriangles]; opcHbmData = new HBMOPCDataClass(); opcHbmData.BuildBasicOPCHBM(); boundingBox = new BoundingBox(); unkFloats = new float[14]; //sort out bounding box/sphere List <Vertex[]> data = new List <Vertex[]>(); data.Add(model.Vertices); boundingBox = new BoundingBox(); boundingSphere = new BoundingSphere(); boundingBox = BoundingBoxExtenders.CalculateBounds(data); boundingSphere = BoundingSphereExtenders.CalculateFromBBox(boundingBox); unkSize = nTriangles; unkSizeData = new byte[unkSize]; for (int i = 0; i != unkSizeData.Length; i++) { unkSizeData[i] = 0; } }