public static bool Aggregate(Mesh result, OMesh mesh0, OMesh mesh1, int maxVertices = 65535) { int vertCount0 = mesh0.vertIndex, triCount0 = mesh0.triIndex; int vertCount1 = mesh1.vertIndex, triCount1 = mesh1.triIndex; if (vertCount0 + vertCount1 > maxVertices) { return(false); } Vector3[] vertices0 = mesh0.vertices; Vector3[] normals0 = mesh0.normals; Vector2[] uv0 = mesh0.uvs; int[] triangles0 = mesh0.triangles; Vector3[] vertices1 = mesh1.vertices; Vector3[] normals1 = mesh1.normals; Vector2[] uv1 = mesh1.uvs; int[] triangles1 = mesh1.triangles; MergeBuffers(result, null, vertices0, normals0, uv0, triangles0, vertCount0, triCount0, vertices1, normals1, uv1, triangles1, vertCount1, triCount1 ); return(true); }
private void Aggregate(SplineExtruder se) { bool aggregate = OMesh.Aggregate(m_AggregateMesh, m_AggregateMesh, se.extruder.OMesh, cachedOMesh ? m_OMeshCacheID : -1); if (aggregate == false) { CreateAggregateMesh(); OMesh.Aggregate(m_AggregateMesh, m_AggregateMesh, se.extruder.OMesh, cachedOMesh ? m_OMeshCacheID : -1); } m_AggregateMesh.RecalculateBounds(); }
private void CreateAggregateMesh() { Transform view = Instantiate <Transform> (template, transform); MeshFilter meshFilter = view.GetComponent <MeshFilter> (); m_AggregateMesh = meshFilter.sharedMesh; if (m_AggregateMesh == null) { m_AggregateMesh = new Mesh(); meshFilter.sharedMesh = m_AggregateMesh; } m_AggregateMesh.MarkDynamic(); m_OMeshCacheID = OMesh.NewCacheID(); }
public int Renew() { int nodeIndex = Spline.GetNodeIndexForTime(m_SplineT); m_SplinePath.Clear(); m_MeshingNodeIndex = 0; m_MeshingIndex = 0; m_SplinePathIndex = 0; m_SplineT = 0; m_OMesh = new OMesh(m_MaxVertices); m_NeedsUpdate = true; return(nodeIndex); }
public static OMesh From(Mesh mesh) { Vector3[] vertices = mesh.vertices; Vector3[] normals = mesh.normals; Vector2[] uv = mesh.uv; int[] triangles = mesh.triangles; int numVertices = vertices.Length; OMesh oMesh = new OMesh(numVertices); oMesh.vertIndex = numVertices; oMesh.triIndex = triangles.Length; oMesh.vertices = vertices; oMesh.normals = normals; oMesh.uvs = uv; oMesh.triangles = triangles; return(oMesh); }
public static bool Aggregate(Mesh result, Mesh mesh0, OMesh mesh1, int cacheID = -1, int maxVertices = 65535) { AggregateCache cache = null; if (cacheID != -1) { if (c_Cache.TryGetValue(cacheID, out cache) == false) { cache = new AggregateCache(mesh0.vertices, mesh0.normals, mesh0.uv, mesh0.triangles); c_Cache.Add(cacheID, cache); Debug.Log("New AggregateCache created " + cacheID); } } Vector3[] vertices0 = cacheID == -1 ? mesh0.vertices : cache.vertices; int[] triangles0 = cacheID == -1 ? mesh0.triangles : cache.triangles; int vertCount0 = vertices0.Length, triCount0 = triangles0.Length; int vertCount1 = mesh1.vertIndex, triCount1 = mesh1.triIndex; if (vertCount0 + vertCount1 > maxVertices) { return(false); } Vector3[] normals0 = cacheID == -1 ? mesh0.normals : cache.normals; Vector2[] uv0 = cacheID == -1 ? mesh0.uv : cache.uvs; Vector3[] vertices1 = mesh1.vertices; Vector3[] normals1 = mesh1.normals; Vector2[] uv1 = mesh1.uvs; int[] triangles1 = mesh1.triangles; MergeBuffers(result, cache, vertices0, normals0, uv0, triangles0, vertCount0, triCount0, vertices1, normals1, uv1, triangles1, vertCount1, triCount1 ); return(true); }
public OShapeExtrusion(int maxVertices = 65535) { m_OMesh = new OMesh(maxVertices); this.m_MaxVertices = maxVertices; }