aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing/Extruder.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-04-10 00:31:44 +0000
committerTeravus Ovares2008-04-10 00:31:44 +0000
commitb85624db1832c54ea2a8b3d53d93b8ca60a18a38 (patch)
treec6f831b8aa53c2a9c1b5dfbbc95dffa6e5c4607d /OpenSim/Region/Physics/Meshing/Extruder.cs
parentUpdate svn properties. (diff)
downloadopensim-SC_OLD-b85624db1832c54ea2a8b3d53d93b8ca60a18a38.zip
opensim-SC_OLD-b85624db1832c54ea2a8b3d53d93b8ca60a18a38.tar.gz
opensim-SC_OLD-b85624db1832c54ea2a8b3d53d93b8ca60a18a38.tar.bz2
opensim-SC_OLD-b85624db1832c54ea2a8b3d53d93b8ca60a18a38.tar.xz
* Adds twist support for Cubes, Cylinders, and Prisms in the Meshmerizer
* A tweak of the SimStatsReporter so it would report the prim capacity to be 45000.
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/Extruder.cs')
-rw-r--r--OpenSim/Region/Physics/Meshing/Extruder.cs116
1 files changed, 112 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs
index 4d2ed4b..c7dcf33 100644
--- a/OpenSim/Region/Physics/Meshing/Extruder.cs
+++ b/OpenSim/Region/Physics/Meshing/Extruder.cs
@@ -39,9 +39,15 @@ namespace OpenSim.Region.Physics.Meshing
39 public float taperTopFactorY = 1f; 39 public float taperTopFactorY = 1f;
40 public float taperBotFactorX = 1f; 40 public float taperBotFactorX = 1f;
41 public float taperBotFactorY = 1f; 41 public float taperBotFactorY = 1f;
42
42 public float pushX = 0f; 43 public float pushX = 0f;
43 public float pushY = 0f; 44 public float pushY = 0f;
44 45
46 // twist amount in radians. NOT DEGREES.
47 public float twistTop = 0;
48 public float twistBot = 0;
49 public float twistMid = 0;
50
45 public Mesh Extrude(Mesh m) 51 public Mesh Extrude(Mesh m)
46 { 52 {
47 startParameter = float.MinValue; 53 startParameter = float.MinValue;
@@ -50,8 +56,12 @@ namespace OpenSim.Region.Physics.Meshing
50 Mesh result = new Mesh(); 56 Mesh result = new Mesh();
51 57
52 Mesh workingPlus = m.Clone(); 58 Mesh workingPlus = m.Clone();
59 Mesh workingMiddle = m.Clone();
53 Mesh workingMinus = m.Clone(); 60 Mesh workingMinus = m.Clone();
54 61
62 Quaternion tt = new Quaternion();
63 Vertex v2 = new Vertex(0, 0, 0);
64
55 foreach (Vertex v in workingPlus.vertices) 65 foreach (Vertex v in workingPlus.vertices)
56 { 66 {
57 if (v == null) 67 if (v == null)
@@ -68,8 +78,44 @@ namespace OpenSim.Region.Physics.Meshing
68 //Push the top of the object over by the Top Shear amount 78 //Push the top of the object over by the Top Shear amount
69 v.X += pushX * size.X; 79 v.X += pushX * size.X;
70 v.Y += pushY * size.X; 80 v.Y += pushY * size.X;
81
82 if (twistTop != 0)
83 {
84 // twist and shout
85 tt = new Quaternion(new Vertex(0, 0, 1), twistTop);
86 v2 = v * tt;
87 v.X = v2.X;
88 v.Y = v2.Y;
89 v.Z = v2.Z;
90 }
71 } 91 }
72 92
93 foreach (Vertex v in workingMiddle.vertices)
94 {
95 if (v == null)
96 continue;
97
98 // This is the top
99 // Set the Z + .5 to match the rest of the scale of the mesh
100 // Scale it by Size, and Taper the scaling
101 v.Z *= size.Z;
102 v.X *= (size.X * ((taperTopFactorX + taperBotFactorX) /2));
103 v.Y *= (size.Y * ((taperTopFactorY + taperBotFactorY) / 2));
104
105 v.X += (pushX / 2) * size.X;
106 v.Y += (pushY / 2) * size.X;
107 //Push the top of the object over by the Top Shear amount
108 if (twistMid != 0)
109 {
110 // twist and shout
111 tt = new Quaternion(new Vertex(0, 0, 1), twistMid);
112 v2 = v * tt;
113 v.X = v2.X;
114 v.Y = v2.Y;
115 v.Z = v2.Z;
116 }
117
118 }
73 foreach (Vertex v in workingMinus.vertices) 119 foreach (Vertex v in workingMinus.vertices)
74 { 120 {
75 if (v == null) 121 if (v == null)
@@ -80,6 +126,16 @@ namespace OpenSim.Region.Physics.Meshing
80 v.X *= (size.X * taperBotFactorX); 126 v.X *= (size.X * taperBotFactorX);
81 v.Y *= (size.Y * taperBotFactorY); 127 v.Y *= (size.Y * taperBotFactorY);
82 v.Z *= size.Z; 128 v.Z *= size.Z;
129
130 if (twistBot != 0)
131 {
132 // twist and shout
133 tt = new Quaternion(new Vertex(0, 0, 1), twistBot);
134 v2 = v * tt;
135 v.X = v2.X;
136 v.Y = v2.Y;
137 v.Z = v2.Z;
138 }
83 } 139 }
84 140
85 foreach (Triangle t in workingMinus.triangles) 141 foreach (Triangle t in workingMinus.triangles)
@@ -88,9 +144,47 @@ namespace OpenSim.Region.Physics.Meshing
88 } 144 }
89 145
90 result.Append(workingMinus); 146 result.Append(workingMinus);
91 result.Append(workingPlus); 147
148 result.Append(workingMiddle);
149
92 150
93 int iLastNull = 0; 151 int iLastNull = 0;
152
153 for (int i = 0; i < workingMiddle.vertices.Count; i++)
154 {
155 int iNext = (i + 1);
156
157 if (workingMiddle.vertices[i] == null) // Can't make a simplex here
158 {
159 iLastNull = i + 1;
160 continue;
161 }
162
163 if (i == workingMiddle.vertices.Count - 1) // End of list
164 {
165 iNext = iLastNull;
166 }
167
168 if (workingMiddle.vertices[iNext] == null) // Null means wrap to begin of last segment
169 {
170 iNext = iLastNull;
171 }
172
173 Triangle tSide;
174 tSide = new Triangle(workingMiddle.vertices[i], workingMinus.vertices[i], workingMiddle.vertices[iNext]);
175 result.Add(tSide);
176
177 tSide =
178 new Triangle(workingMiddle.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]);
179 result.Add(tSide);
180 }
181 //foreach (Triangle t in workingPlus.triangles)
182 //{
183 //t.invertNormal();
184 // }
185 result.Append(workingPlus);
186
187 iLastNull = 0;
94 for (int i = 0; i < workingPlus.vertices.Count; i++) 188 for (int i = 0; i < workingPlus.vertices.Count; i++)
95 { 189 {
96 int iNext = (i + 1); 190 int iNext = (i + 1);
@@ -112,14 +206,28 @@ namespace OpenSim.Region.Physics.Meshing
112 } 206 }
113 207
114 Triangle tSide; 208 Triangle tSide;
115 tSide = new Triangle(workingPlus.vertices[i], workingMinus.vertices[i], workingPlus.vertices[iNext]); 209 tSide = new Triangle(workingPlus.vertices[i], workingMiddle.vertices[i], workingPlus.vertices[iNext]);
116 result.Add(tSide); 210 result.Add(tSide);
117 211
118 tSide = 212 tSide =
119 new Triangle(workingPlus.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]); 213 new Triangle(workingPlus.vertices[iNext], workingMiddle.vertices[i], workingMiddle.vertices[iNext]);
120 result.Add(tSide); 214 result.Add(tSide);
121 } 215 }
122 216 if (twistMid != 0)
217 {
218 foreach (Vertex v in result.vertices)
219 {
220 // twist and shout
221 if (v != null)
222 {
223 tt = new Quaternion(new Vertex(0, 0, -1), twistMid*2);
224 v2 = v * tt;
225 v.X = v2.X;
226 v.Y = v2.Y;
227 v.Z = v2.Z;
228 }
229 }
230 }
123 return result; 231 return result;
124 } 232 }
125 } 233 }