/// <summary> /// Write points of a plane. /// </summary> /// <param name="subMeshIndex">Index of the submesh (texture group) to work with.</param> /// <param name="planeIn">Source plane.</param> private int WritePlane(int subMeshIndex, ref PurePlane planeIn) { // Handle planes with greater than 3 points if (planeIn.Points.Length > 3) { return(WriteVariablePlane(subMeshIndex, ref planeIn)); } // Add new point buffer to submesh buffer int planeIndex = subMeshBuffer[subMeshIndex].planeCount; subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex].PointBuffer = new DFMesh.DFPoint[pointBufferLength]; subMeshBuffer[subMeshIndex].planeCount++; // Calculate UV coordinates for points 1, 2 (points 1 & 2 are deltas that are added to the previous point) planeIn.Points[1].u += planeIn.Points[0].u; planeIn.Points[1].v += planeIn.Points[0].v; planeIn.Points[2].u += planeIn.Points[1].u; planeIn.Points[2].v += planeIn.Points[1].v; // Write the 3 points WritePoint(ref planeIn.Points[0], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); WritePoint(ref planeIn.Points[1], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); WritePoint(ref planeIn.Points[2], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); // Store UV generation method of this plane subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex].UVGenerationMethod = DFMesh.UVGenerationMethods.TriangleOnly; return(planeIndex); }
/// <summary> /// Write a N-point triangle fan to buffer by finding corners. /// </summary> /// <param name="subMeshIndex">Index of the submesh (texture group) to work with.</param> /// <param name="planeIn">Source plane.</param> private int WriteVariablePlane(int subMeshIndex, ref PurePlane planeIn) { // Add new point buffer to submesh buffer int planeIndex = subMeshBuffer[subMeshIndex].planeCount; subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex].PointBuffer = new DFMesh.DFPoint[pointBufferLength]; subMeshBuffer[subMeshIndex].planeCount++; // Find corner points int cornerCount = GetCornerPoints(ref planeIn.Points); // Calculate UV coordinates of all points if (faceUVTool.ComputeFaceUVCoordinates(ref planeIn.Points, ref calculatedUVBuffer)) { // Copy calculated UV coordinates for (int pt = 0; pt < planeIn.Points.Length; pt++) { planeIn.Points[pt].u = calculatedUVBuffer[pt].u; planeIn.Points[pt].v = calculatedUVBuffer[pt].v; } // Store UV generation method of this plane subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex].UVGenerationMethod = DFMesh.UVGenerationMethods.ModifedMatrixGenerator; } // Write first 3 points int cornerPos = 0; WritePoint(ref planeIn.Points[cornerPointBuffer[cornerPos++]], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); WritePoint(ref planeIn.Points[cornerPointBuffer[cornerPos++]], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); WritePoint(ref planeIn.Points[cornerPointBuffer[cornerPos++]], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); // Write remaining points while (cornerPos < cornerCount) { WritePoint(ref planeIn.Points[cornerPointBuffer[cornerPos++]], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); } return(planeIndex); }
/// <summary> /// Write a N-point triangle fan to buffer by finding corners. /// </summary> /// <param name="subMeshIndex">Index of the submesh (texture group) to work with.</param> /// <param name="planeIn">Source plane.</param> private int WriteVariablePlane(int subMeshIndex, ref PurePlane planeIn) { // Add new point buffer to submesh buffer int planeIndex = subMeshBuffer[subMeshIndex].planeCount; subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex].PointBuffer = new DFMesh.DFPoint[pointBufferLength]; subMeshBuffer[subMeshIndex].planeCount++; // Find corner points int cornerCount = GetCornerPoints(ref planeIn.Points); // Calculate UV coordinates of all points if (faceUVTool.ComputeFaceUVCoordinates(ref planeIn.Points, ref calculatedUVBuffer)) { // Copy calculated UV coordinates for (int pt = 0; pt < planeIn.Points.Length; pt++) { planeIn.Points[pt].u = calculatedUVBuffer[pt].u; planeIn.Points[pt].v = calculatedUVBuffer[pt].v; } // Store UV generation method of this plane subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex].UVGenerationMethod = DFMesh.UVGenerationMethods.ModifedMatrixGenerator; } // Write first 3 points int cornerPos = 0; WritePoint(ref planeIn.Points[cornerPointBuffer[cornerPos++]], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); WritePoint(ref planeIn.Points[cornerPointBuffer[cornerPos++]], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); WritePoint(ref planeIn.Points[cornerPointBuffer[cornerPos++]], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); // Write remaining points while (cornerPos < cornerCount) { WritePoint(ref planeIn.Points[cornerPointBuffer[cornerPos++]], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); } return planeIndex; }
/// <summary> /// Write points of a plane. /// </summary> /// <param name="subMeshIndex">Index of the submesh (texture group) to work with.</param> /// <param name="planeIn">Source plane.</param> private int WritePlane(int subMeshIndex, ref PurePlane planeIn) { // Handle planes with greater than 3 points if (planeIn.Points.Length > 3) return WriteVariablePlane(subMeshIndex, ref planeIn); // Add new point buffer to submesh buffer int planeIndex = subMeshBuffer[subMeshIndex].planeCount; subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex].PointBuffer = new DFMesh.DFPoint[pointBufferLength]; subMeshBuffer[subMeshIndex].planeCount++; // Calculate UV coordinates for points 1, 2 (points 1 & 2 are deltas that are added to the previous point) planeIn.Points[1].u += planeIn.Points[0].u; planeIn.Points[1].v += planeIn.Points[0].v; planeIn.Points[2].u += planeIn.Points[1].u; planeIn.Points[2].v += planeIn.Points[1].v; // Write the 3 points WritePoint(ref planeIn.Points[0], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); WritePoint(ref planeIn.Points[1], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); WritePoint(ref planeIn.Points[2], ref subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex]); // Store UV generation method of this plane subMeshBuffer[subMeshIndex].PlaneBuffer[planeIndex].UVGenerationMethod = DFMesh.UVGenerationMethods.TriangleOnly; return planeIndex; }