コード例 #1
0
ファイル: BSPTree.cs プロジェクト: gauravSGN/snoopy-gs-update
        private List <Polygon> GetFrontLeaves(List <Polygon> leaves, BSPNode node)
        {
            if (node.Front != null)
            {
                if (node.Front.IsLeaf)
                {
                    leaves.Add(node.Front.Polygon);
                }

                GetFrontLeaves(leaves, node.Front);
            }

            if (node.Back != null)
            {
                GetFrontLeaves(leaves, node.Back);
            }

            return(leaves);
        }
コード例 #2
0
ファイル: BSPNode.cs プロジェクト: gauravSGN/snoopy-gs-update
        private void DividePolygon(Vector2 start, Vector2 end)
        {
            var startIndex = FindDivisionPoint(start, end);
            var endIndex   = FindDivisionPoint(end, start);

            if ((startIndex >= 0) && (endIndex >= 0))
            {
                var firstVertex    = Polygon.Vertices[Polygon.Indices[startIndex]];
                var secondVertex   = Polygon.Vertices[Polygon.Indices[(startIndex + 1) % Polygon.Indices.Length]];
                var firstIntersect = LineSegment.Intersect(firstVertex, secondVertex, start, end);

                firstVertex  = Polygon.Vertices[Polygon.Indices[endIndex]];
                secondVertex = Polygon.Vertices[Polygon.Indices[(endIndex + 1) % Polygon.Indices.Length]];
                var secondIntersect = LineSegment.Intersect(firstVertex, secondVertex, end, start);

                var inside  = CreateSubPolygon(WalkEdges(startIndex + 1, endIndex), secondIntersect, start, end, firstIntersect);
                var outside = CreateSubPolygon(WalkEdges(endIndex + 1, startIndex), firstIntersect, end, start, secondIntersect);

                Front = new BSPNode(new Polygon(Polygon.Vertices, inside.ToArray()));
                Back  = new BSPNode(new Polygon(Polygon.Vertices, outside.ToArray()));
            }
        }
コード例 #3
0
ファイル: BSPNode.cs プロジェクト: gauravSGN/snoopy-gs-update
 public void Cull()
 {
     Front = new BSPNode(new Polygon(Polygon.Vertices, new int[0]));
     Back  = new BSPNode(new Polygon(Polygon.Vertices, Polygon.Indices));
 }
コード例 #4
0
ファイル: BSPTree.cs プロジェクト: gauravSGN/snoopy-gs-update
 public BSPTree(Polygon polygon)
 {
     Root = new BSPNode(polygon);
 }