Isosurface.ManifoldDC.OctreeNode.ProcessCell C# (CSharp) Method

ProcessCell() public method

public ProcessCell ( List indexes, List tri_count, float threshold ) : void
indexes List
tri_count List
threshold float
return void
        public void ProcessCell(List<int> indexes, List<int> tri_count, float threshold)
        {
            if (type == NodeType.Internal)
            {
                for (int i = 0; i < 8; i++)
                {
                    if (children[i] != null)
                        children[i].ProcessCell(indexes, tri_count, threshold);
                }

                if (index == 31681)
                {
                }
                for (int i = 0; i < 12; i++)
                {
                    OctreeNode[] face_nodes = new OctreeNode[2];

                    int c1 = Utilities.TEdgePairs[i, 0];
                    int c2 = Utilities.TEdgePairs[i, 1];

                    face_nodes[0] = children[c1];
                    face_nodes[1] = children[c2];

                    ProcessFace(face_nodes, Utilities.TEdgePairs[i, 2], indexes, tri_count, threshold);
                }

                for (int i = 0; i < 6; i++)
                {
                    OctreeNode[] edge_nodes =
                    {
                        children[Utilities.TCellProcEdgeMask[i, 0]],
                        children[Utilities.TCellProcEdgeMask[i, 1]],
                        children[Utilities.TCellProcEdgeMask[i, 2]],
                        children[Utilities.TCellProcEdgeMask[i, 3]]
                    };

                    ProcessEdge(edge_nodes, Utilities.TCellProcEdgeMask[i, 4], indexes, tri_count, threshold);
                }
            }
        }

Usage Example

Ejemplo n.º 1
0
        public void CalculateIndexes(float threshold)
        {
            if (!FlatShading)
            {
                Indices.Clear();
            }
            else
            {
                Indices = new List <int>();
            }
            List <int> tri_count = new List <int>();

            tree.ProcessCell(Indices, tri_count, threshold);
            if (!FlatShading)
            {
                IndexCount = Indices.Count;
                if (Indices.Count == 0)
                {
                    return;
                }
            }

            if (!FlatShading)
            {
                IndexBuffer.SetData <int>(Indices.ToArray());
            }
            else
            {
                List <VertexPositionColorNormal> new_vertices = new List <VertexPositionColorNormal>();
                int t_index = 0;
                for (int i = 0; i < Indices.Count; i += 3)
                {
                    int     count = tri_count[t_index++];
                    Vector3 n     = Vector3.Zero;
                    if (count == 1)
                    {
                        n = GetNormalQ(Vertices, Indices[i + 2], Indices[i + 0], Indices[i + 1]);
                    }
                    else
                    {
                        n = GetNormalQ(Vertices, Indices[i + 2], Indices[i + 0], Indices[i + 1], Indices[i + 5], Indices[i + 3], Indices[i + 4]);
                    }
                    Vector3 nc = n * 0.5f + Vector3.One * 0.5f;
                    nc.Normalize();
                    Color c = new Color(nc);

                    VertexPositionColorNormal v0 = new VertexPositionColorNormal(Vertices[Indices[i + 0]].Position, c, n);
                    VertexPositionColorNormal v1 = new VertexPositionColorNormal(Vertices[Indices[i + 1]].Position, c, n);
                    VertexPositionColorNormal v2 = new VertexPositionColorNormal(Vertices[Indices[i + 2]].Position, c, n);

                    new_vertices.Add(v0);
                    new_vertices.Add(v1);
                    new_vertices.Add(v2);

                    if (count > 1)
                    {
                        VertexPositionColorNormal v3 = new VertexPositionColorNormal(Vertices[Indices[i + 3]].Position, c, n);
                        VertexPositionColorNormal v4 = new VertexPositionColorNormal(Vertices[Indices[i + 4]].Position, c, n);
                        VertexPositionColorNormal v5 = new VertexPositionColorNormal(Vertices[Indices[i + 5]].Position, c, n);

                        new_vertices.Add(v3);
                        new_vertices.Add(v4);
                        new_vertices.Add(v5);

                        i += 3;
                    }
                }

                if (new_vertices.Count > 0)
                {
                    VertexBuffer.SetData <VertexPositionColorNormal>(new_vertices.ToArray());
                }
                VertexCount = new_vertices.Count;
            }
        }
All Usage Examples Of Isosurface.ManifoldDC.OctreeNode::ProcessCell