aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/Meshing/PrimMesher.cs102
1 files changed, 68 insertions, 34 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
index 527bf88..df1d932 100644
--- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs
+++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
@@ -96,6 +96,11 @@ namespace PrimMesher
96 96
97 return this; 97 return this;
98 } 98 }
99
100 public override string ToString()
101 {
102 return "< X: " + this.X.ToString() + ", Y: " + this.Y.ToString() + ", Z: " + this.Z.ToString() + ", W: " + this.W.ToString() + ">";
103 }
99 } 104 }
100 105
101 public struct Coord 106 public struct Coord
@@ -153,6 +158,16 @@ namespace PrimMesher
153 ); 158 );
154 } 159 }
155 160
161 public static Coord operator +(Coord v, Coord a)
162 {
163 return new Coord(v.X + a.X, v.Y + a.Y, v.Z + a.Z);
164 }
165
166 public static Coord operator *(Coord v, Coord m)
167 {
168 return new Coord(v.X * m.X, v.Y * m.Y, v.Z * m.Z);
169 }
170
156 public static Coord operator *(Coord v, Quat q) 171 public static Coord operator *(Coord v, Quat q)
157 { 172 {
158 // From http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/ 173 // From http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/
@@ -895,36 +910,20 @@ namespace PrimMesher
895 { 910 {
896 int i; 911 int i;
897 int numVerts = this.coords.Count; 912 int numVerts = this.coords.Count;
898 Coord c;
899 913
900 for (i = 0; i < numVerts; i++) 914 for (i = 0; i < numVerts; i++)
901 { 915 this.coords[i] *= q;
902 c = this.coords[i];
903 Coord v = new Coord(c.X, c.Y, c.Z) * q;
904
905 c.X = v.X;
906 c.Y = v.Y;
907 c.Z = v.Z;
908 this.coords[i] = c;
909 }
910 916
911 if (this.calcVertexNormals) 917 if (this.calcVertexNormals)
912 { 918 {
913 int numNormals = this.vertexNormals.Count; 919 int numNormals = this.vertexNormals.Count;
914 for (i = 0; i < numNormals; i++) 920 for (i = 0; i < numNormals; i++)
915 { 921 this.vertexNormals[i] *= q;
916 c = this.vertexNormals[i];
917 Coord n = new Coord(c.X, c.Y, c.Z) * q;
918
919 c.X = n.X;
920 c.Y = n.Y;
921 c.Z = n.Z;
922 this.vertexNormals[i] = c;
923 }
924 922
925 this.faceNormal *= q; 923 this.faceNormal *= q;
926 this.cutNormal1 *= q; 924 this.cutNormal1 *= q;
927 this.cutNormal2 *= q; 925 this.cutNormal2 *= q;
926
928 } 927 }
929 } 928 }
930 929
@@ -1298,7 +1297,7 @@ namespace PrimMesher
1298 this.normals.AddRange(newLayer.vertexNormals); 1297 this.normals.AddRange(newLayer.vertexNormals);
1299 } 1298 }
1300 1299
1301 if (percentOfPath <= this.pathCutBegin || percentOfPath >= this.pathCutEnd) 1300 if (percentOfPath < this.pathCutBegin + 0.01f || percentOfPath > this.pathCutEnd - 0.01f)
1302 this.faces.AddRange(newLayer.faces); 1301 this.faces.AddRange(newLayer.faces);
1303 1302
1304 // fill faces between layers 1303 // fill faces between layers
@@ -1485,7 +1484,7 @@ namespace PrimMesher
1485 1484
1486 if (done && viewerMode) 1485 if (done && viewerMode)
1487 { 1486 {
1488 // add the bottom faces to the viewerFaces list here 1487 // add the top faces to the viewerFaces list here
1489 Coord faceNormal = newLayer.faceNormal; 1488 Coord faceNormal = newLayer.faceNormal;
1490 ViewerFace newViewerFace = new ViewerFace(); 1489 ViewerFace newViewerFace = new ViewerFace();
1491 newViewerFace.primFaceNumber = 0; 1490 newViewerFace.primFaceNumber = 0;
@@ -2023,36 +2022,71 @@ namespace PrimMesher
2023 2022
2024 public void AddRot(Quat q) 2023 public void AddRot(Quat q)
2025 { 2024 {
2025 Console.WriteLine("AddRot(" + q.ToString() + ")");
2026 int i; 2026 int i;
2027 int numVerts = this.coords.Count; 2027 int numVerts = this.coords.Count;
2028 Coord vert;
2029 2028
2030 for (i = 0; i < numVerts; i++) 2029 for (i = 0; i < numVerts; i++)
2030 this.coords[i] *= q;
2031
2032 if (this.normals != null)
2031 { 2033 {
2032 vert = this.coords[i]; 2034 int numNormals = this.normals.Count;
2033 Coord v = new Coord(vert.X, vert.Y, vert.Z) * q; 2035 for (i = 0; i < numNormals; i++)
2036 this.normals[i] *= q;
2037 }
2034 2038
2035 vert.X = v.X; 2039 if (this.viewerFaces != null)
2036 vert.Y = v.Y; 2040 {
2037 vert.Z = v.Z; 2041 int numViewerFaces = this.viewerFaces.Count;
2038 this.coords[i] = vert; 2042
2043 for (i = 0; i < numViewerFaces; i++)
2044 {
2045 ViewerFace v = this.viewerFaces[i];
2046 v.v1 *= q;
2047 v.v2 *= q;
2048 v.v3 *= q;
2049
2050 v.n1 *= q;
2051 v.n2 *= q;
2052 v.n3 *= q;
2053 this.viewerFaces[i] = v;
2054 }
2039 } 2055 }
2056
2040 } 2057 }
2041 2058
2042 public void Scale(float x, float y, float z) 2059 public void Scale(float x, float y, float z)
2043 { 2060 {
2044 int i; 2061 int i;
2045 int numVerts = this.coords.Count; 2062 int numVerts = this.coords.Count;
2046 Coord vert; 2063 //Coord vert;
2047 2064
2065 Coord m = new Coord(x, y, z);
2048 for (i = 0; i < numVerts; i++) 2066 for (i = 0; i < numVerts; i++)
2067 this.coords[i] *= m;
2068 //{
2069 // vert = this.coords[i];
2070 // vert.X *= x;
2071 // vert.Y *= y;
2072 // vert.Z *= z;
2073 // this.coords[i] = vert;
2074 //}
2075
2076 if (this.viewerFaces != null)
2049 { 2077 {
2050 vert = this.coords[i]; 2078 int numViewerFaces = this.viewerFaces.Count;
2051 vert.X *= x; 2079 for (i = 0; i < numViewerFaces; i++)
2052 vert.Y *= y; 2080 {
2053 vert.Z *= z; 2081 ViewerFace v = this.viewerFaces[i];
2054 this.coords[i] = vert; 2082 v.v1 *= m;
2083 v.v2 *= m;
2084 v.v3 *= m;
2085 this.viewerFaces[i] = v;
2086 }
2087
2055 } 2088 }
2089
2056 } 2090 }
2057 2091
2058 public void DumpRaw(String path, String name, String title) 2092 public void DumpRaw(String path, String name, String title)