diff options
author | Dahlia Trimble | 2008-08-23 10:28:35 +0000 |
---|---|---|
committer | Dahlia Trimble | 2008-08-23 10:28:35 +0000 |
commit | 72f74acdbf71b352b6ea1345df357c1b4dc29ce0 (patch) | |
tree | bcddcdee4badaa232b3a18d617160a8151c5b034 /OpenSim/Region/Physics/Meshing/PrimMesher.cs | |
parent | some initial work on new prim meshing routines (incomplete) (diff) | |
download | opensim-SC_OLD-72f74acdbf71b352b6ea1345df357c1b4dc29ce0.zip opensim-SC_OLD-72f74acdbf71b352b6ea1345df357c1b4dc29ce0.tar.gz opensim-SC_OLD-72f74acdbf71b352b6ea1345df357c1b4dc29ce0.tar.bz2 opensim-SC_OLD-72f74acdbf71b352b6ea1345df357c1b4dc29ce0.tar.xz |
more work on new meshing routines...
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/PrimMesher.cs')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/PrimMesher.cs | 82 |
1 files changed, 77 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index af39ce1..8679f65 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs | |||
@@ -95,7 +95,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
95 | // this class should have a table of most commonly computed values | 95 | // this class should have a table of most commonly computed values |
96 | // instead of all the trig function calls | 96 | // instead of all the trig function calls |
97 | // most common would be for sides = 3, 4, or 24 | 97 | // most common would be for sides = 3, 4, or 24 |
98 | AngleList( int sides, float startAngle, float stopAngle ) | 98 | internal void makeAngles( int sides, float startAngle, float stopAngle ) |
99 | { | 99 | { |
100 | angles = new List<Angle>(); | 100 | angles = new List<Angle>(); |
101 | double twoPi = System.Math.PI * 2.0; | 101 | double twoPi = System.Math.PI * 2.0; |
@@ -148,15 +148,87 @@ namespace OpenSim.Region.Physics.Meshing | |||
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | internal class PrimProfile | 151 | internal class makeProfile |
152 | { | 152 | { |
153 | internal List<vertex> vertices; | 153 | private float twoPi = 2.0f * (float)Math.PI; |
154 | internal List<vertex> coords; | ||
155 | internal List<vertex> hollowCoords; | ||
154 | internal List<face> faces; | 156 | internal List<face> faces; |
155 | 157 | ||
156 | PrimProfile() | 158 | internal int sides = 4; |
159 | internal int hollowSides = 7; | ||
160 | internal vertex center = new vertex(0.0f, 0.0f, 0.0f); | ||
161 | |||
162 | makeProfile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides) | ||
157 | { | 163 | { |
158 | vertices = new List<vertex>(); | 164 | coords = new List<vertex>(); |
165 | hollowCoords = new List<vertex>(); | ||
159 | faces = new List<face>(); | 166 | faces = new List<face>(); |
167 | |||
168 | AngleList angles = new AngleList(); | ||
169 | AngleList hollowAngles = new AngleList(); | ||
170 | |||
171 | this.sides = sides; | ||
172 | this.hollowSides = hollowSides; | ||
173 | |||
174 | float xScale = 0.5f; | ||
175 | float yScale = 0.5f; | ||
176 | if (sides == 4) // corners of a square are sqrt(2) from center | ||
177 | { | ||
178 | xScale = 0.707f; | ||
179 | yScale = 0.707f; | ||
180 | } | ||
181 | |||
182 | float startAngle = profileStart * twoPi; | ||
183 | float stopAngle = profileEnd * twoPi; | ||
184 | float stepSize = twoPi / this.sides; | ||
185 | |||
186 | angles.makeAngles(this.sides, startAngle, stopAngle); | ||
187 | |||
188 | if (hollow > 0.001f) | ||
189 | { | ||
190 | if (this.sides == this.hollowSides) | ||
191 | hollowAngles = angles; | ||
192 | else | ||
193 | { | ||
194 | hollowAngles = new AngleList(); | ||
195 | hollowAngles.makeAngles(this.hollowSides, startAngle, stopAngle); | ||
196 | } | ||
197 | } | ||
198 | else | ||
199 | this.coords.Add(center); | ||
200 | |||
201 | Angle angle; | ||
202 | vertex newVert = new vertex(); | ||
203 | |||
204 | if ( hollow > 0.001f && this.hollowSides != this.sides) | ||
205 | { | ||
206 | int numHollowAngles = hollowAngles.angles.Count; | ||
207 | for (int i = 0; i < numHollowAngles; i++) | ||
208 | { | ||
209 | angle = hollowAngles.angles[i]; | ||
210 | newVert.X = hollow * xScale * angle.X; | ||
211 | newVert.Y = hollow * yScale * angle.Y; | ||
212 | newVert.Z = 0.0f; | ||
213 | this.hollowCoords.Add(newVert); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | int numAngles = angles.angles.Count; | ||
218 | for (int i = 0; i < numAngles; i++) | ||
219 | { | ||
220 | angle = angles.angles[i]; | ||
221 | newVert.X = angle.X * xScale; | ||
222 | newVert.Y = angle.Y * yScale; | ||
223 | newVert.Z = 0.0f; | ||
224 | this.coords.Add(newVert); | ||
225 | } | ||
226 | |||
227 | /* | ||
228 | continue at python source line 174 | ||
229 | |||
230 | */ | ||
231 | |||
160 | } | 232 | } |
161 | } | 233 | } |
162 | 234 | ||