コード例 #1
0
        //Convert rectangle to its 6 quads
        public static QuadList RectToQuads(Rect rect)
        {
            QuadList quads = new QuadList();

            Quad quadTopper = new Quad(rect.Pt1[0], rect.Pt2[1], rect.Pt1[2], rect.Pt2[0], rect.Pt2[1], rect.Pt2[2]);

            quadTopper.Properties = rect.Properties.Clone();
            Quad quadBottom = new Quad(rect.Pt1[0], rect.Pt1[1], rect.Pt1[2], rect.Pt2[0], rect.Pt1[1], rect.Pt2[2]);

            quadBottom.Properties = rect.Properties.Clone();

            Quad quadFront = new Quad(rect.Pt1[0], rect.Pt1[1], rect.Pt2[2], rect.Pt2[0], rect.Pt2[1], rect.Pt2[2]);

            quadFront.Properties = rect.Properties.Clone();
            Quad quadBack = new Quad(rect.Pt1[0], rect.Pt1[1], rect.Pt1[2], rect.Pt2[0], rect.Pt2[1], rect.Pt1[2]);

            quadBack.Properties = rect.Properties.Clone();

            Quad quadRight = new Quad(rect.Pt2[0], rect.Pt1[1], rect.Pt1[2], rect.Pt2[0], rect.Pt2[1], rect.Pt2[2]);

            quadRight.Properties = rect.Properties.Clone();
            Quad quadLeft = new Quad(rect.Pt1[0], rect.Pt1[1], rect.Pt1[2], rect.Pt1[0], rect.Pt2[1], rect.Pt2[2]);

            quadLeft.Properties = rect.Properties.Clone();

            quads.AddQuad(quadFront);
            quads.AddQuad(quadBack);
            quads.AddQuad(quadTopper);
            quads.AddQuad(quadBottom);
            quads.AddQuad(quadRight);
            quads.AddQuad(quadLeft);

            return(quads);
        }
コード例 #2
0
ファイル: RectsToQuads.cs プロジェクト: katascope/Glyphics2
        //Convert rectangles to their 6 quads
        public static QuadList RectsToQuads(RectList rectSet)
        {
            QuadList quadsMacro = new QuadList();

            foreach (Rect rect in rectSet)
            {
                QuadList quads = RectToQuads(rect);

                foreach (Quad quad in quads)
                {
                    quadsMacro.AddQuad(quad);
                }
            }

            //Remove redundant ones automatically
            RemoveRedundantQuads(quadsMacro);

            return(quadsMacro);
        }