public BasicMesh GetBasicMesh(LLPrimitive prim) { BasicMesh mesh; OpenMetaverseMesh omvMesh = null; ulong physicsKey = prim.GetPhysicsKey(); // Try a cache lookup first if (m_meshCache != null && m_meshCache.TryGetBasicMesh(physicsKey, BASIC_MESH_LOD, out mesh)) { return(mesh); } // Can't go any further without a prim renderer if (m_renderer == null) { return(null); } if (prim.Prim.Sculpt != null && prim.Prim.Sculpt.SculptTexture != UUID.Zero) { // Sculpty meshing Bitmap sculptTexture = GetSculptMap(prim.Prim.Sculpt.SculptTexture); if (sculptTexture != null) { omvMesh = m_renderer.GenerateSimpleSculptMesh(prim.Prim, sculptTexture, OpenMetaverse.Rendering.DetailLevel.Low); } } else { // Basic prim meshing omvMesh = m_renderer.GenerateSimpleMesh(prim.Prim, OpenMetaverse.Rendering.DetailLevel.Medium); } if (omvMesh == null) { return(null); } #if DEBUG for (int i = 0; i < omvMesh.Indices.Count; i++) { System.Diagnostics.Debug.Assert(omvMesh.Indices[i] < omvMesh.Vertices.Count, "Mesh index is out of range"); } #endif // Convert the OpenMetaverse.Rendering mesh to a BasicMesh mesh = new BasicMesh(); mesh.Vertices = new Vector3[omvMesh.Vertices.Count]; for (int i = 0; i < omvMesh.Vertices.Count; i++) { mesh.Vertices[i] = omvMesh.Vertices[i].Position; } mesh.Indices = omvMesh.Indices.ToArray(); mesh.Volume = Util.GetMeshVolume(mesh, Vector3.One); // Store the result in the mesh cache, if we have one if (m_meshCache != null) { m_meshCache.StoreBasicMesh(physicsKey, BASIC_MESH_LOD, mesh); } return(mesh); }
public SimpleMesh GenerateSimpleMesh(Primitive prim, DetailLevel lod) { return(Renderer.GenerateSimpleMesh(prim, lod)); }