public ConvexHullSet GetConvexHulls(LLPrimitive prim) { ConvexHullSet hullSet; ulong physicsKey = prim.GetPhysicsKey(); // Try a cache lookup first if (m_meshCache != null && m_meshCache.TryGetConvexHullSet(physicsKey, BASIC_MESH_LOD, out hullSet)) { return(hullSet); } // FIXME: Implement this return(null); }
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 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 RenderingMesh GetRenderingMesh(LLPrimitive prim, DetailLevel lod) { RenderingMesh mesh; ulong physicsKey = prim.GetPhysicsKey(); // Try a cache lookup first if (m_meshCache != null && m_meshCache.TryGetRenderingMesh(physicsKey, lod, out mesh)) { return(mesh); } // Can't go any further without a prim renderer if (m_renderer == null) { return(null); } // Convert our DetailLevel to the OpenMetaverse.Rendering DetailLevel OpenMetaverse.Rendering.DetailLevel detailLevel; switch (lod) { case DetailLevel.Low: detailLevel = OpenMetaverse.Rendering.DetailLevel.Low; break; case DetailLevel.Medium: detailLevel = OpenMetaverse.Rendering.DetailLevel.Medium; break; case DetailLevel.High: detailLevel = OpenMetaverse.Rendering.DetailLevel.High; break; case DetailLevel.Highest: default: detailLevel = OpenMetaverse.Rendering.DetailLevel.Highest; break; } FacetedMesh facetedMesh = null; if (prim.Prim.Sculpt != null && prim.Prim.Sculpt.SculptTexture != UUID.Zero) { // Sculpty meshing Bitmap sculptTexture = GetSculptMap(prim.Prim.Sculpt.SculptTexture); if (sculptTexture != null) { facetedMesh = m_renderer.GenerateFacetedSculptMesh(prim.Prim, sculptTexture, detailLevel); } } else { // Basic prim meshing facetedMesh = m_renderer.GenerateFacetedMesh(prim.Prim, detailLevel); } if (facetedMesh != null) { #region FacetedMesh to RenderingMesh Conversion mesh = new RenderingMesh(); mesh.Faces = new RenderingMesh.Face[facetedMesh.Faces.Count]; for (int i = 0; i < facetedMesh.Faces.Count; i++) { Face face = facetedMesh.Faces[i]; Vertex[] vertices = new Vertex[face.Vertices.Count]; for (int j = 0; j < face.Vertices.Count; j++) { OpenMetaverse.Rendering.Vertex omvrVertex = face.Vertices[j]; vertices[j] = new Vertex { Position = omvrVertex.Position, Normal = omvrVertex.Normal, TexCoord = omvrVertex.TexCoord }; } ushort[] indices = face.Indices.ToArray(); mesh.Faces[i] = new RenderingMesh.Face { Vertices = vertices, Indices = indices }; } #endregion FacetedMesh to RenderingMesh Conversion // Store the result in the mesh cache, if we have one if (m_meshCache != null) { m_meshCache.StoreRenderingMesh(physicsKey, lod, mesh); } return(mesh); } else { return(null); } }
public RenderingMesh GetRenderingMesh(LLPrimitive prim, DetailLevel lod) { RenderingMesh mesh; ulong physicsKey = prim.GetPhysicsKey(); // Try a cache lookup first if (m_meshCache != null && m_meshCache.TryGetRenderingMesh(physicsKey, lod, out mesh)) return mesh; // Can't go any further without a prim renderer if (m_renderer == null) return null; // Convert our DetailLevel to the OpenMetaverse.Rendering DetailLevel OpenMetaverse.Rendering.DetailLevel detailLevel; switch (lod) { case DetailLevel.Low: detailLevel = OpenMetaverse.Rendering.DetailLevel.Low; break; case DetailLevel.Medium: detailLevel = OpenMetaverse.Rendering.DetailLevel.Medium; break; case DetailLevel.High: detailLevel = OpenMetaverse.Rendering.DetailLevel.High; break; case DetailLevel.Highest: default: detailLevel = OpenMetaverse.Rendering.DetailLevel.Highest; break; } FacetedMesh facetedMesh = null; if (prim.Prim.Sculpt != null && prim.Prim.Sculpt.SculptTexture != UUID.Zero) { // Sculpty meshing Bitmap sculptTexture = GetSculptMap(prim.Prim.Sculpt.SculptTexture); if (sculptTexture != null) facetedMesh = m_renderer.GenerateFacetedSculptMesh(prim.Prim, sculptTexture, detailLevel); } else { // Basic prim meshing facetedMesh = m_renderer.GenerateFacetedMesh(prim.Prim, detailLevel); } if (facetedMesh != null) { #region FacetedMesh to RenderingMesh Conversion mesh = new RenderingMesh(); mesh.Faces = new RenderingMesh.Face[facetedMesh.Faces.Count]; for (int i = 0; i < facetedMesh.Faces.Count; i++) { Face face = facetedMesh.Faces[i]; Vertex[] vertices = new Vertex[face.Vertices.Count]; for (int j = 0; j < face.Vertices.Count; j++) { OpenMetaverse.Rendering.Vertex omvrVertex = face.Vertices[j]; vertices[j] = new Vertex { Position = omvrVertex.Position, Normal = omvrVertex.Normal, TexCoord = omvrVertex.TexCoord }; } ushort[] indices = face.Indices.ToArray(); mesh.Faces[i] = new RenderingMesh.Face { Vertices = vertices, Indices = indices }; } #endregion FacetedMesh to RenderingMesh Conversion // Store the result in the mesh cache, if we have one if (m_meshCache != null) m_meshCache.StoreRenderingMesh(physicsKey, lod, mesh); return mesh; } else { return null; } }
public ConvexHullSet GetConvexHulls(LLPrimitive prim) { ConvexHullSet hullSet; ulong physicsKey = prim.GetPhysicsKey(); // Try a cache lookup first if (m_meshCache != null && m_meshCache.TryGetConvexHullSet(physicsKey, BASIC_MESH_LOD, out hullSet)) return hullSet; // FIXME: Implement this return null; }