aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Meshing')
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs150
1 files changed, 80 insertions, 70 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index cf57c0a..e1203ea 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -256,102 +256,112 @@ namespace OpenSim.Region.Physics.Meshing
256 PrimMesh primMesh; 256 PrimMesh primMesh;
257 PrimMesher.SculptMesh sculptMesh; 257 PrimMesher.SculptMesh sculptMesh;
258 258
259 List<Coord> coords; 259 List<Coord> coords = new List<Coord>();
260 List<Face> faces; 260 List<Face> faces = new List<Face>();
261 261
262 Image idata = null; 262 Image idata = null;
263 string decodedSculptFileName = ""; 263 string decodedSculptFileName = "";
264 264
265 if (primShape.SculptEntry) 265 if (primShape.SculptEntry)
266 { 266 {
267 if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero) 267 if (((OpenMetaverse.SculptType)primShape.SculptType) == SculptType.Mesh)
268 {
269 // add code for mesh physics proxy generation here
270 m_log.Debug("[MESH]: mesh proxy generation not implemented yet ");
271 return null;
272
273 }
274 else
268 { 275 {
269 decodedSculptFileName = System.IO.Path.Combine(decodedSculptMapPath, "smap_" + primShape.SculptTexture.ToString()); 276 if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero)
270 try
271 { 277 {
272 if (File.Exists(decodedSculptFileName)) 278 decodedSculptFileName = System.IO.Path.Combine(decodedSculptMapPath, "smap_" + primShape.SculptTexture.ToString());
279 try
273 { 280 {
274 idata = Image.FromFile(decodedSculptFileName); 281 if (File.Exists(decodedSculptFileName))
282 {
283 idata = Image.FromFile(decodedSculptFileName);
284 }
275 } 285 }
276 } 286 catch (Exception e)
277 catch (Exception e) 287 {
278 { 288 m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message);
279 m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message);
280 289
290 }
291 //if (idata != null)
292 // m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString());
281 } 293 }
282 //if (idata != null)
283 // m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString());
284 }
285 294
286 if (idata == null) 295 if (idata == null)
287 {
288 if (primShape.SculptData == null || primShape.SculptData.Length == 0)
289 return null;
290
291 try
292 { 296 {
293 OpenMetaverse.Imaging.ManagedImage unusedData; 297 if (primShape.SculptData == null || primShape.SculptData.Length == 0)
294 OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); 298 return null;
295 unusedData = null; 299
300 try
301 {
302 OpenMetaverse.Imaging.ManagedImage unusedData;
303 OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata);
304 unusedData = null;
296 305
297 //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); 306 //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData);
298 307
299 if (cacheSculptMaps && idata != null) 308 if (cacheSculptMaps && idata != null)
309 {
310 try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); }
311 catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); }
312 }
313 }
314 catch (DllNotFoundException)
300 { 315 {
301 try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } 316 m_log.Error("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!");
302 catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } 317 return null;
318 }
319 catch (IndexOutOfRangeException)
320 {
321 m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
322 return null;
323 }
324 catch (Exception ex)
325 {
326 m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message);
327 return null;
303 } 328 }
304 } 329 }
305 catch (DllNotFoundException) 330
306 { 331 PrimMesher.SculptMesh.SculptType sculptType;
307 m_log.Error("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!"); 332 switch ((OpenMetaverse.SculptType)primShape.SculptType)
308 return null;
309 }
310 catch (IndexOutOfRangeException)
311 {
312 m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
313 return null;
314 }
315 catch (Exception ex)
316 { 333 {
317 m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message); 334 case OpenMetaverse.SculptType.Cylinder:
318 return null; 335 sculptType = PrimMesher.SculptMesh.SculptType.cylinder;
336 break;
337 case OpenMetaverse.SculptType.Plane:
338 sculptType = PrimMesher.SculptMesh.SculptType.plane;
339 break;
340 case OpenMetaverse.SculptType.Torus:
341 sculptType = PrimMesher.SculptMesh.SculptType.torus;
342 break;
343 case OpenMetaverse.SculptType.Sphere:
344 sculptType = PrimMesher.SculptMesh.SculptType.sphere;
345 break;
346 default:
347 sculptType = PrimMesher.SculptMesh.SculptType.plane;
348 break;
319 } 349 }
320 }
321 350
322 PrimMesher.SculptMesh.SculptType sculptType; 351 bool mirror = ((primShape.SculptType & 128) != 0);
323 switch ((OpenMetaverse.SculptType)primShape.SculptType) 352 bool invert = ((primShape.SculptType & 64) != 0);
324 {
325 case OpenMetaverse.SculptType.Cylinder:
326 sculptType = PrimMesher.SculptMesh.SculptType.cylinder;
327 break;
328 case OpenMetaverse.SculptType.Plane:
329 sculptType = PrimMesher.SculptMesh.SculptType.plane;
330 break;
331 case OpenMetaverse.SculptType.Torus:
332 sculptType = PrimMesher.SculptMesh.SculptType.torus;
333 break;
334 case OpenMetaverse.SculptType.Sphere:
335 sculptType = PrimMesher.SculptMesh.SculptType.sphere;
336 break;
337 default:
338 sculptType = PrimMesher.SculptMesh.SculptType.plane;
339 break;
340 }
341 353
342 bool mirror = ((primShape.SculptType & 128) != 0); 354 sculptMesh = new PrimMesher.SculptMesh((Bitmap)idata, sculptType, (int)lod, false, mirror, invert);
343 bool invert = ((primShape.SculptType & 64) != 0); 355
356 idata.Dispose();
344 357
345 sculptMesh = new PrimMesher.SculptMesh((Bitmap)idata, sculptType, (int)lod, false, mirror, invert); 358 sculptMesh.DumpRaw(baseDir, primName, "primMesh");
346
347 idata.Dispose();
348 359
349 sculptMesh.DumpRaw(baseDir, primName, "primMesh"); 360 sculptMesh.Scale(size.X, size.Y, size.Z);
350 361
351 sculptMesh.Scale(size.X, size.Y, size.Z); 362 coords = sculptMesh.coords;
352 363 faces = sculptMesh.faces;
353 coords = sculptMesh.coords; 364 }
354 faces = sculptMesh.faces;
355 } 365 }
356 else 366 else
357 { 367 {