aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/Meshmerizer.cs')
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs92
1 files changed, 62 insertions, 30 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 9c6dff4..1d2f986 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -1209,7 +1209,29 @@ namespace OpenSim.Region.Physics.Meshing
1209 1209
1210 return m; 1210 return m;
1211 } 1211 }
1212 private SculptMesh CreateSculptMesh(string primName, PrimitiveBaseShape primShape, PhysicsVector size)
1213 {
1214 SculptMesh sm = new SculptMesh(primShape.SculptData);
1215 // Scale the mesh based on our prim scale
1216 foreach (Vertex v in sm.vertices)
1217 {
1218 v.X *= 0.5f;
1219 v.Y *= 0.5f;
1220 v.Z *= 0.5f;
1221 v.X *= size.X;
1222 v.Y *= size.Y;
1223 v.Z *= size.Z;
1224 }
1225 // This was built with the normals pointing inside..
1226 // therefore we have to invert the normals
1227 foreach (Triangle t in sm.triangles)
1228 {
1229 t.invertNormal();
1230 }
1231 sm.DumpRaw(baseDir, primName, "Sculpt");
1232 return sm;
1212 1233
1234 }
1213 public static void CalcNormals(Mesh mesh) 1235 public static void CalcNormals(Mesh mesh)
1214 { 1236 {
1215 int iTriangles = mesh.triangles.Count; 1237 int iTriangles = mesh.triangles.Count;
@@ -1317,43 +1339,53 @@ namespace OpenSim.Region.Physics.Meshing
1317 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) 1339 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size)
1318 { 1340 {
1319 Mesh mesh = null; 1341 Mesh mesh = null;
1320 1342 if (primShape.SculptEntry && primShape.SculptType != (byte)0 && primShape.SculptData.Length > 0)
1321 switch (primShape.ProfileShape)
1322 { 1343 {
1323 case ProfileShape.Square: 1344 SculptMesh smesh = CreateSculptMesh(primName, primShape, size);
1324 mesh = CreateBoxMesh(primName, primShape, size); 1345 mesh = (Mesh)smesh;
1325 CalcNormals(mesh); 1346 CalcNormals(mesh);
1326 break; 1347 }
1327 case ProfileShape.Circle: 1348 else
1328 if (primShape.PathCurve == (byte)Extrusion.Straight) 1349 {
1329 { 1350 switch (primShape.ProfileShape)
1330 mesh = CreateCyllinderMesh(primName, primShape, size); 1351 {
1331 CalcNormals(mesh); 1352 case ProfileShape.Square:
1332 } 1353 mesh = CreateBoxMesh(primName, primShape, size);
1333 break;
1334 case ProfileShape.HalfCircle:
1335 if (primShape.PathCurve == (byte)Extrusion.Curve1)
1336 {
1337 mesh = CreateSphereMesh(primName, primShape, size);
1338 CalcNormals(mesh); 1354 CalcNormals(mesh);
1339 } 1355 break;
1340 break; 1356 case ProfileShape.Circle:
1357 if (primShape.PathCurve == (byte)Extrusion.Straight)
1358 {
1359 mesh = CreateCyllinderMesh(primName, primShape, size);
1360 CalcNormals(mesh);
1361 }
1362 break;
1363 case ProfileShape.HalfCircle:
1364 if (primShape.PathCurve == (byte)Extrusion.Curve1)
1365 {
1366 mesh = CreateSphereMesh(primName, primShape, size);
1367 CalcNormals(mesh);
1368 }
1369 break;
1341 1370
1342 case ProfileShape.EquilateralTriangle: 1371 case ProfileShape.EquilateralTriangle:
1343 mesh = CreatePrismMesh(primName, primShape, size); 1372 mesh = CreatePrismMesh(primName, primShape, size);
1344 CalcNormals(mesh); 1373 CalcNormals(mesh);
1345 break; 1374 break;
1346 1375
1347 default: 1376 default:
1348 mesh = CreateBoxMesh(primName, primShape, size); 1377 mesh = CreateBoxMesh(primName, primShape, size);
1349 CalcNormals(mesh); 1378 CalcNormals(mesh);
1350 //Set default mesh to cube otherwise it'll return 1379 //Set default mesh to cube otherwise it'll return
1351 // null and crash on the 'setMesh' method in the physics plugins. 1380 // null and crash on the 'setMesh' method in the physics plugins.
1352 //mesh = null; 1381 //mesh = null;
1353 break; 1382 break;
1383 }
1354 } 1384 }
1355 1385
1356 return mesh; 1386 return mesh;
1357 } 1387 }
1388
1389
1358 } 1390 }
1359} 1391}