diff options
author | Dahlia Trimble | 2008-11-29 11:02:14 +0000 |
---|---|---|
committer | Dahlia Trimble | 2008-11-29 11:02:14 +0000 |
commit | fdd238833163eb947986bfcdd09da82f6949a5f2 (patch) | |
tree | 6b90177758405f6106f4f5d4d75e3b98bf08053c /OpenSim/Region/Physics/Meshing/PrimMesher.cs | |
parent | Comment the ScriptSponsor and restore the indefinite lifetime for (diff) | |
download | opensim-SC_OLD-fdd238833163eb947986bfcdd09da82f6949a5f2.zip opensim-SC_OLD-fdd238833163eb947986bfcdd09da82f6949a5f2.tar.gz opensim-SC_OLD-fdd238833163eb947986bfcdd09da82f6949a5f2.tar.bz2 opensim-SC_OLD-fdd238833163eb947986bfcdd09da82f6949a5f2.tar.xz |
Update meshing code to sync with current PrimMesher.cs on forge.
Migrate sculpt meshing code to primMesher version. This should result in more accurate physical sculpted prim proxies.
Remove much obsolete code from Region/Physics/Meshing
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/PrimMesher.cs')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/PrimMesher.cs | 163 |
1 files changed, 131 insertions, 32 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 282bbd5..d79a480 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
@@ -243,10 +243,11 @@ namespace PrimMesher | |||
243 | public int n2; | 243 | public int n2; |
244 | public int n3; | 244 | public int n3; |
245 | 245 | ||
246 | //// UVs | 246 | // uvs |
247 | //public int uv1; | 247 | public int uv1; |
248 | //public int uv2; | 248 | public int uv2; |
249 | //public int uv3; | 249 | public int uv3; |
250 | |||
250 | 251 | ||
251 | public Face(int v1, int v2, int v3) | 252 | public Face(int v1, int v2, int v3) |
252 | { | 253 | { |
@@ -260,9 +261,10 @@ namespace PrimMesher | |||
260 | this.n2 = 0; | 261 | this.n2 = 0; |
261 | this.n3 = 0; | 262 | this.n3 = 0; |
262 | 263 | ||
263 | //this.uv1 = 0; | 264 | this.uv1 = 0; |
264 | //this.uv2 = 0; | 265 | this.uv2 = 0; |
265 | //this.uv3 = 0; | 266 | this.uv3 = 0; |
267 | |||
266 | } | 268 | } |
267 | 269 | ||
268 | public Face(int v1, int v2, int v3, int n1, int n2, int n3) | 270 | public Face(int v1, int v2, int v3, int n1, int n2, int n3) |
@@ -277,9 +279,21 @@ namespace PrimMesher | |||
277 | this.n2 = n2; | 279 | this.n2 = n2; |
278 | this.n3 = n3; | 280 | this.n3 = n3; |
279 | 281 | ||
280 | //this.uv1 = 0; | 282 | this.uv1 = 0; |
281 | //this.uv2 = 0; | 283 | this.uv2 = 0; |
282 | //this.uv3 = 0; | 284 | this.uv3 = 0; |
285 | } | ||
286 | |||
287 | public Coord SurfaceNormal(List<Coord> coordList) | ||
288 | { | ||
289 | Coord c1 = coordList[this.v1]; | ||
290 | Coord c2 = coordList[this.v2]; | ||
291 | Coord c3 = coordList[this.v3]; | ||
292 | |||
293 | Coord edge1 = new Coord(c2.X - c1.X, c2.Y - c1.Y, c2.Z - c1.Z); | ||
294 | Coord edge2 = new Coord(c3.X - c1.X, c3.Y - c1.Y, c3.Z - c1.Z); | ||
295 | |||
296 | return Coord.Cross(edge1, edge2).Normalize(); | ||
283 | } | 297 | } |
284 | } | 298 | } |
285 | 299 | ||
@@ -560,7 +574,7 @@ namespace PrimMesher | |||
560 | /// <summary> | 574 | /// <summary> |
561 | /// generates a profile for extrusion | 575 | /// generates a profile for extrusion |
562 | /// </summary> | 576 | /// </summary> |
563 | public class Profile | 577 | internal class Profile |
564 | { | 578 | { |
565 | private const float twoPi = 2.0f * (float)Math.PI; | 579 | private const float twoPi = 2.0f * (float)Math.PI; |
566 | 580 | ||
@@ -569,6 +583,7 @@ namespace PrimMesher | |||
569 | internal List<Coord> vertexNormals; | 583 | internal List<Coord> vertexNormals; |
570 | internal List<float> us; | 584 | internal List<float> us; |
571 | internal List<UVCoord> faceUVs; | 585 | internal List<UVCoord> faceUVs; |
586 | internal List<int> faceNumbers; | ||
572 | 587 | ||
573 | internal Coord faceNormal = new Coord(0.0f, 0.0f, 1.0f); | 588 | internal Coord faceNormal = new Coord(0.0f, 0.0f, 1.0f); |
574 | internal Coord cutNormal1 = new Coord(); | 589 | internal Coord cutNormal1 = new Coord(); |
@@ -578,6 +593,8 @@ namespace PrimMesher | |||
578 | internal int numHollowVerts = 0; | 593 | internal int numHollowVerts = 0; |
579 | 594 | ||
580 | internal bool calcVertexNormals = false; | 595 | internal bool calcVertexNormals = false; |
596 | internal int bottomFaceNumber = 0; | ||
597 | internal int numPrimFaces = 0; | ||
581 | 598 | ||
582 | internal Profile() | 599 | internal Profile() |
583 | { | 600 | { |
@@ -586,9 +603,10 @@ namespace PrimMesher | |||
586 | this.vertexNormals = new List<Coord>(); | 603 | this.vertexNormals = new List<Coord>(); |
587 | this.us = new List<float>(); | 604 | this.us = new List<float>(); |
588 | this.faceUVs = new List<UVCoord>(); | 605 | this.faceUVs = new List<UVCoord>(); |
606 | this.faceNumbers = new List<int>(); | ||
589 | } | 607 | } |
590 | 608 | ||
591 | public Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides, bool createFaces, bool calcVertexNormals) | 609 | internal Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides, bool createFaces, bool calcVertexNormals) |
592 | { | 610 | { |
593 | this.calcVertexNormals = calcVertexNormals; | 611 | this.calcVertexNormals = calcVertexNormals; |
594 | this.coords = new List<Coord>(); | 612 | this.coords = new List<Coord>(); |
@@ -596,6 +614,8 @@ namespace PrimMesher | |||
596 | this.vertexNormals = new List<Coord>(); | 614 | this.vertexNormals = new List<Coord>(); |
597 | this.us = new List<float>(); | 615 | this.us = new List<float>(); |
598 | this.faceUVs = new List<UVCoord>(); | 616 | this.faceUVs = new List<UVCoord>(); |
617 | this.faceNumbers = new List<int>(); | ||
618 | |||
599 | Coord center = new Coord(0.0f, 0.0f, 0.0f); | 619 | Coord center = new Coord(0.0f, 0.0f, 0.0f); |
600 | 620 | ||
601 | List<Coord> hollowCoords = new List<Coord>(); | 621 | List<Coord> hollowCoords = new List<Coord>(); |
@@ -674,7 +694,7 @@ namespace PrimMesher | |||
674 | hollowCoords.Add(newVert); | 694 | hollowCoords.Add(newVert); |
675 | if (this.calcVertexNormals) | 695 | if (this.calcVertexNormals) |
676 | { | 696 | { |
677 | if (sides < 5) | 697 | if (hollowSides < 5) |
678 | hollowNormals.Add(hollowAngles.normals[i].Invert()); | 698 | hollowNormals.Add(hollowAngles.normals[i].Invert()); |
679 | else | 699 | else |
680 | hollowNormals.Add(new Coord(-angle.X, -angle.Y, 0.0f)); | 700 | hollowNormals.Add(new Coord(-angle.X, -angle.Y, 0.0f)); |
@@ -689,7 +709,7 @@ namespace PrimMesher | |||
689 | 709 | ||
690 | for (int i = 0; i < numAngles; i++) | 710 | for (int i = 0; i < numAngles; i++) |
691 | { | 711 | { |
692 | //int iNext = i == numAngles ? i + 1 : 0; | 712 | int iNext = i == numAngles ? i + 1 : 0; |
693 | angle = angles.angles[i]; | 713 | angle = angles.angles[i]; |
694 | newVert.X = angle.X * xScale; | 714 | newVert.X = angle.X * xScale; |
695 | newVert.Y = angle.Y * yScale; | 715 | newVert.Y = angle.Y * yScale; |
@@ -884,21 +904,46 @@ namespace PrimMesher | |||
884 | hollowNormals = null; | 904 | hollowNormals = null; |
885 | hollowUs = null; | 905 | hollowUs = null; |
886 | 906 | ||
907 | if (calcVertexNormals) | ||
908 | { // calculate prim face numbers | ||
909 | // I know it's ugly but so is the whole concept of prim face numbers | ||
910 | int faceNum = 1; | ||
911 | int startVert = hasProfileCut && !hasHollow ? 1 : 0; | ||
912 | if (startVert > 0) | ||
913 | this.faceNumbers.Add(0); | ||
914 | for (int i = 0; i < numOuterVerts; i++) | ||
915 | this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum); | ||
916 | if (sides > 4) | ||
917 | faceNum++; | ||
918 | if (hasProfileCut) | ||
919 | this.faceNumbers.Add(0); | ||
920 | for (int i = 0; i < numHollowVerts; i++) | ||
921 | this.faceNumbers.Add(faceNum++); | ||
922 | this.bottomFaceNumber = faceNum++; | ||
923 | if (hasHollow && hasProfileCut) | ||
924 | this.faceNumbers.Add(faceNum++); | ||
925 | for (int i = 0; i < this.faceNumbers.Count; i++) | ||
926 | if (this.faceNumbers[i] == 0) | ||
927 | this.faceNumbers[i] = faceNum++; | ||
928 | |||
929 | this.numPrimFaces = faceNum; | ||
930 | } | ||
931 | |||
887 | } | 932 | } |
888 | 933 | ||
889 | public void MakeFaceUVs() | 934 | internal void MakeFaceUVs() |
890 | { | 935 | { |
891 | this.faceUVs = new List<UVCoord>(); | 936 | this.faceUVs = new List<UVCoord>(); |
892 | foreach (Coord c in this.coords) | 937 | foreach (Coord c in this.coords) |
893 | this.faceUVs.Add(new UVCoord(1.0f - (0.5f + c.X), 1.0f - (0.5f - c.Y))); | 938 | this.faceUVs.Add(new UVCoord(1.0f - (0.5f + c.X), 1.0f - (0.5f - c.Y))); |
894 | } | 939 | } |
895 | 940 | ||
896 | public Profile Clone() | 941 | internal Profile Clone() |
897 | { | 942 | { |
898 | return this.Clone(true); | 943 | return this.Clone(true); |
899 | } | 944 | } |
900 | 945 | ||
901 | public Profile Clone(bool needFaces) | 946 | internal Profile Clone(bool needFaces) |
902 | { | 947 | { |
903 | Profile clone = new Profile(); | 948 | Profile clone = new Profile(); |
904 | 949 | ||
@@ -914,6 +959,7 @@ namespace PrimMesher | |||
914 | clone.cutNormal1 = this.cutNormal1; | 959 | clone.cutNormal1 = this.cutNormal1; |
915 | clone.cutNormal2 = this.cutNormal2; | 960 | clone.cutNormal2 = this.cutNormal2; |
916 | clone.us.AddRange(this.us); | 961 | clone.us.AddRange(this.us); |
962 | clone.faceNumbers.AddRange(this.faceNumbers); | ||
917 | } | 963 | } |
918 | clone.numOuterVerts = this.numOuterVerts; | 964 | clone.numOuterVerts = this.numOuterVerts; |
919 | clone.numHollowVerts = this.numHollowVerts; | 965 | clone.numHollowVerts = this.numHollowVerts; |
@@ -921,12 +967,12 @@ namespace PrimMesher | |||
921 | return clone; | 967 | return clone; |
922 | } | 968 | } |
923 | 969 | ||
924 | public void AddPos(Coord v) | 970 | internal void AddPos(Coord v) |
925 | { | 971 | { |
926 | this.AddPos(v.X, v.Y, v.Z); | 972 | this.AddPos(v.X, v.Y, v.Z); |
927 | } | 973 | } |
928 | 974 | ||
929 | public void AddPos(float x, float y, float z) | 975 | internal void AddPos(float x, float y, float z) |
930 | { | 976 | { |
931 | int i; | 977 | int i; |
932 | int numVerts = this.coords.Count; | 978 | int numVerts = this.coords.Count; |
@@ -942,7 +988,7 @@ namespace PrimMesher | |||
942 | } | 988 | } |
943 | } | 989 | } |
944 | 990 | ||
945 | public void AddRot(Quat q) | 991 | internal void AddRot(Quat q) |
946 | { | 992 | { |
947 | int i; | 993 | int i; |
948 | int numVerts = this.coords.Count; | 994 | int numVerts = this.coords.Count; |
@@ -963,7 +1009,7 @@ namespace PrimMesher | |||
963 | } | 1009 | } |
964 | } | 1010 | } |
965 | 1011 | ||
966 | public void Scale(float x, float y) | 1012 | internal void Scale(float x, float y) |
967 | { | 1013 | { |
968 | int i; | 1014 | int i; |
969 | int numVerts = this.coords.Count; | 1015 | int numVerts = this.coords.Count; |
@@ -981,7 +1027,7 @@ namespace PrimMesher | |||
981 | /// <summary> | 1027 | /// <summary> |
982 | /// Changes order of the vertex indices and negates the center vertex normal. Does not alter vertex normals of radial vertices | 1028 | /// Changes order of the vertex indices and negates the center vertex normal. Does not alter vertex normals of radial vertices |
983 | /// </summary> | 1029 | /// </summary> |
984 | public void FlipNormals() | 1030 | internal void FlipNormals() |
985 | { | 1031 | { |
986 | int i; | 1032 | int i; |
987 | int numFaces = this.faces.Count; | 1033 | int numFaces = this.faces.Count; |
@@ -1021,7 +1067,7 @@ namespace PrimMesher | |||
1021 | } | 1067 | } |
1022 | } | 1068 | } |
1023 | 1069 | ||
1024 | public void AddValue2FaceVertexIndices(int num) | 1070 | internal void AddValue2FaceVertexIndices(int num) |
1025 | { | 1071 | { |
1026 | int numFaces = this.faces.Count; | 1072 | int numFaces = this.faces.Count; |
1027 | Face tmpFace; | 1073 | Face tmpFace; |
@@ -1036,7 +1082,7 @@ namespace PrimMesher | |||
1036 | } | 1082 | } |
1037 | } | 1083 | } |
1038 | 1084 | ||
1039 | public void AddValue2FaceNormalIndices(int num) | 1085 | internal void AddValue2FaceNormalIndices(int num) |
1040 | { | 1086 | { |
1041 | if (this.calcVertexNormals) | 1087 | if (this.calcVertexNormals) |
1042 | { | 1088 | { |
@@ -1054,7 +1100,7 @@ namespace PrimMesher | |||
1054 | } | 1100 | } |
1055 | } | 1101 | } |
1056 | 1102 | ||
1057 | public void DumpRaw(String path, String name, String title) | 1103 | internal void DumpRaw(String path, String name, String title) |
1058 | { | 1104 | { |
1059 | if (path == null) | 1105 | if (path == null) |
1060 | return; | 1106 | return; |
@@ -1113,6 +1159,12 @@ namespace PrimMesher | |||
1113 | private bool normalsProcessed = false; | 1159 | private bool normalsProcessed = false; |
1114 | public bool viewerMode = false; | 1160 | public bool viewerMode = false; |
1115 | 1161 | ||
1162 | public int numPrimFaces = 0; | ||
1163 | |||
1164 | /// <summary> | ||
1165 | /// Human readable string representation of the parameters used to create a mesh. | ||
1166 | /// </summary> | ||
1167 | /// <returns></returns> | ||
1116 | public string ParamsToDisplayString() | 1168 | public string ParamsToDisplayString() |
1117 | { | 1169 | { |
1118 | string s = ""; | 1170 | string s = ""; |
@@ -1141,7 +1193,14 @@ namespace PrimMesher | |||
1141 | return s; | 1193 | return s; |
1142 | } | 1194 | } |
1143 | 1195 | ||
1144 | 1196 | /// <summary> | |
1197 | /// Constructs a PrimMesh object and creates the profile for extrusion. | ||
1198 | /// </summary> | ||
1199 | /// <param name="sides"></param> | ||
1200 | /// <param name="profileStart"></param> | ||
1201 | /// <param name="profileEnd"></param> | ||
1202 | /// <param name="hollow"></param> | ||
1203 | /// <param name="hollowSides"></param> | ||
1145 | public PrimMesh(int sides, float profileStart, float profileEnd, float hollow, int hollowSides) | 1204 | public PrimMesh(int sides, float profileStart, float profileEnd, float hollow, int hollowSides) |
1146 | { | 1205 | { |
1147 | this.coords = new List<Coord>(); | 1206 | this.coords = new List<Coord>(); |
@@ -1174,6 +1233,9 @@ namespace PrimMesher | |||
1174 | this.hasHollow = (this.hollow > 0.001f); | 1233 | this.hasHollow = (this.hollow > 0.001f); |
1175 | } | 1234 | } |
1176 | 1235 | ||
1236 | /// <summary> | ||
1237 | /// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism. | ||
1238 | /// </summary> | ||
1177 | public void ExtrudeLinear() | 1239 | public void ExtrudeLinear() |
1178 | { | 1240 | { |
1179 | this.coords = new List<Coord>(); | 1241 | this.coords = new List<Coord>(); |
@@ -1248,6 +1310,7 @@ namespace PrimMesher | |||
1248 | hollow *= 1.414f; | 1310 | hollow *= 1.414f; |
1249 | 1311 | ||
1250 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true, calcVertexNormals); | 1312 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true, calcVertexNormals); |
1313 | this.numPrimFaces = profile.numPrimFaces; | ||
1251 | 1314 | ||
1252 | int cut1Vert = -1; | 1315 | int cut1Vert = -1; |
1253 | int cut2Vert = -1; | 1316 | int cut2Vert = -1; |
@@ -1398,7 +1461,7 @@ namespace PrimMesher | |||
1398 | if (u2 < 0.1f) | 1461 | if (u2 < 0.1f) |
1399 | u2 = 1.0f; | 1462 | u2 = 1.0f; |
1400 | 1463 | ||
1401 | newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; | 1464 | //newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; |
1402 | } | 1465 | } |
1403 | 1466 | ||
1404 | newViewerFace1.uv1.U = u1; | 1467 | newViewerFace1.uv1.U = u1; |
@@ -1462,6 +1525,8 @@ namespace PrimMesher | |||
1462 | } | 1525 | } |
1463 | } | 1526 | } |
1464 | 1527 | ||
1528 | newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = newLayer.faceNumbers[whichVert]; | ||
1529 | |||
1465 | this.viewerFaces.Add(newViewerFace1); | 1530 | this.viewerFaces.Add(newViewerFace1); |
1466 | this.viewerFaces.Add(newViewerFace2); | 1531 | this.viewerFaces.Add(newViewerFace2); |
1467 | 1532 | ||
@@ -1492,7 +1557,7 @@ namespace PrimMesher | |||
1492 | // add the top faces to the viewerFaces list here | 1557 | // add the top faces to the viewerFaces list here |
1493 | Coord faceNormal = newLayer.faceNormal; | 1558 | Coord faceNormal = newLayer.faceNormal; |
1494 | ViewerFace newViewerFace = new ViewerFace(); | 1559 | ViewerFace newViewerFace = new ViewerFace(); |
1495 | newViewerFace.primFaceNumber = 0; | 1560 | newViewerFace.primFaceNumber = newLayer.bottomFaceNumber; |
1496 | foreach (Face face in newLayer.faces) | 1561 | foreach (Face face in newLayer.faces) |
1497 | { | 1562 | { |
1498 | newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; | 1563 | newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; |
@@ -1513,6 +1578,9 @@ namespace PrimMesher | |||
1513 | } | 1578 | } |
1514 | } | 1579 | } |
1515 | 1580 | ||
1581 | /// <summary> | ||
1582 | /// Extrude a profile into a circular path prim mesh. Used for prim types torus, tube, and ring. | ||
1583 | /// </summary> | ||
1516 | public void ExtrudeCircular() | 1584 | public void ExtrudeCircular() |
1517 | { | 1585 | { |
1518 | this.coords = new List<Coord>(); | 1586 | this.coords = new List<Coord>(); |
@@ -1615,6 +1683,7 @@ namespace PrimMesher | |||
1615 | needEndFaces = true; | 1683 | needEndFaces = true; |
1616 | 1684 | ||
1617 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, needEndFaces, calcVertexNormals); | 1685 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, needEndFaces, calcVertexNormals); |
1686 | this.numPrimFaces = profile.numPrimFaces; | ||
1618 | 1687 | ||
1619 | int cut1Vert = -1; | 1688 | int cut1Vert = -1; |
1620 | int cut2Vert = -1; | 1689 | int cut2Vert = -1; |
@@ -1787,7 +1856,7 @@ namespace PrimMesher | |||
1787 | if (u2 < 0.1f) | 1856 | if (u2 < 0.1f) |
1788 | u2 = 1.0f; | 1857 | u2 = 1.0f; |
1789 | 1858 | ||
1790 | newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; | 1859 | //newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; |
1791 | } | 1860 | } |
1792 | 1861 | ||
1793 | newViewerFace1.uv1.U = u1; | 1862 | newViewerFace1.uv1.U = u1; |
@@ -1865,6 +1934,7 @@ namespace PrimMesher | |||
1865 | } | 1934 | } |
1866 | } | 1935 | } |
1867 | 1936 | ||
1937 | newViewerFace1.primFaceNumber = newViewerFace2.primFaceNumber = newLayer.faceNumbers[whichVert]; | ||
1868 | this.viewerFaces.Add(newViewerFace1); | 1938 | this.viewerFaces.Add(newViewerFace1); |
1869 | this.viewerFaces.Add(newViewerFace2); | 1939 | this.viewerFaces.Add(newViewerFace2); |
1870 | 1940 | ||
@@ -1894,7 +1964,7 @@ namespace PrimMesher | |||
1894 | // add the bottom faces to the viewerFaces list here | 1964 | // add the bottom faces to the viewerFaces list here |
1895 | Coord faceNormal = newLayer.faceNormal; | 1965 | Coord faceNormal = newLayer.faceNormal; |
1896 | ViewerFace newViewerFace = new ViewerFace(); | 1966 | ViewerFace newViewerFace = new ViewerFace(); |
1897 | newViewerFace.primFaceNumber = 0; | 1967 | newViewerFace.primFaceNumber = newLayer.bottomFaceNumber; |
1898 | foreach (Face face in newLayer.faces) | 1968 | foreach (Face face in newLayer.faces) |
1899 | { | 1969 | { |
1900 | newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; | 1970 | newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; |
@@ -1932,6 +2002,11 @@ namespace PrimMesher | |||
1932 | return SurfaceNormal(this.coords[face.v1], this.coords[face.v2], this.coords[face.v3]); | 2002 | return SurfaceNormal(this.coords[face.v1], this.coords[face.v2], this.coords[face.v3]); |
1933 | } | 2003 | } |
1934 | 2004 | ||
2005 | /// <summary> | ||
2006 | /// Calculate the surface normal for a face in the list of faces | ||
2007 | /// </summary> | ||
2008 | /// <param name="faceIndex"></param> | ||
2009 | /// <returns></returns> | ||
1935 | public Coord SurfaceNormal(int faceIndex) | 2010 | public Coord SurfaceNormal(int faceIndex) |
1936 | { | 2011 | { |
1937 | int numFaces = this.faces.Count; | 2012 | int numFaces = this.faces.Count; |
@@ -1941,6 +2016,9 @@ namespace PrimMesher | |||
1941 | return SurfaceNormal(this.faces[faceIndex]); | 2016 | return SurfaceNormal(this.faces[faceIndex]); |
1942 | } | 2017 | } |
1943 | 2018 | ||
2019 | /// <summary> | ||
2020 | /// Calculate surface normals for all of the faces in the list of faces in this mesh | ||
2021 | /// </summary> | ||
1944 | public void CalcNormals() | 2022 | public void CalcNormals() |
1945 | { | 2023 | { |
1946 | if (normalsProcessed) | 2024 | if (normalsProcessed) |
@@ -1968,6 +2046,12 @@ namespace PrimMesher | |||
1968 | } | 2046 | } |
1969 | } | 2047 | } |
1970 | 2048 | ||
2049 | /// <summary> | ||
2050 | /// Adds a value to each XYZ vertex coordinate in the mesh | ||
2051 | /// </summary> | ||
2052 | /// <param name="x"></param> | ||
2053 | /// <param name="y"></param> | ||
2054 | /// <param name="z"></param> | ||
1971 | public void AddPos(float x, float y, float z) | 2055 | public void AddPos(float x, float y, float z) |
1972 | { | 2056 | { |
1973 | int i; | 2057 | int i; |
@@ -1984,9 +2068,12 @@ namespace PrimMesher | |||
1984 | } | 2068 | } |
1985 | } | 2069 | } |
1986 | 2070 | ||
2071 | /// <summary> | ||
2072 | /// Rotates the mesh | ||
2073 | /// </summary> | ||
2074 | /// <param name="q"></param> | ||
1987 | public void AddRot(Quat q) | 2075 | public void AddRot(Quat q) |
1988 | { | 2076 | { |
1989 | Console.WriteLine("AddRot(" + q.ToString() + ")"); | ||
1990 | int i; | 2077 | int i; |
1991 | int numVerts = this.coords.Count; | 2078 | int numVerts = this.coords.Count; |
1992 | 2079 | ||
@@ -2020,6 +2107,12 @@ namespace PrimMesher | |||
2020 | 2107 | ||
2021 | } | 2108 | } |
2022 | 2109 | ||
2110 | /// <summary> | ||
2111 | /// Scales the mesh | ||
2112 | /// </summary> | ||
2113 | /// <param name="x"></param> | ||
2114 | /// <param name="y"></param> | ||
2115 | /// <param name="z"></param> | ||
2023 | public void Scale(float x, float y, float z) | 2116 | public void Scale(float x, float y, float z) |
2024 | { | 2117 | { |
2025 | int i; | 2118 | int i; |
@@ -2046,6 +2139,12 @@ namespace PrimMesher | |||
2046 | 2139 | ||
2047 | } | 2140 | } |
2048 | 2141 | ||
2142 | /// <summary> | ||
2143 | /// Dumps the mesh to a Blender compatible "Raw" format file | ||
2144 | /// </summary> | ||
2145 | /// <param name="path"></param> | ||
2146 | /// <param name="name"></param> | ||
2147 | /// <param name="title"></param> | ||
2049 | public void DumpRaw(String path, String name, String title) | 2148 | public void DumpRaw(String path, String name, String title) |
2050 | { | 2149 | { |
2051 | if (path == null) | 2150 | if (path == null) |