Пример #1
0
        public BoundingBox GetRotatedBoundingBox()
        {
            var min = LocalBoundingBoxOffset - (BoundingBoxSize * 0.5f);
            var max = LocalBoundingBoxOffset + (BoundingBoxSize * 0.5f);

            min = Vector3.Transform(min, GlobalTransform);
            max = Vector3.Transform(max, GlobalTransform);
            return(new BoundingBox(MathFunctions.Min(min, max), MathFunctions.Max(min, max)));
        }
Пример #2
0
        public Rectangle GetScreenRect(BoundingBox Box, Camera Camera)
        {
            Vector3 ext    = (Box.Max - Box.Min);
            Vector3 center = Box.Center();

            Vector3 p1 = Camera.Project(Box.Min);
            Vector3 p2 = Camera.Project(Box.Max);
            Vector3 p3 = Camera.Project(Box.Min + new Vector3(ext.X, 0, 0));
            Vector3 p4 = Camera.Project(Box.Min + new Vector3(0, ext.Y, 0));
            Vector3 p5 = Camera.Project(Box.Min + new Vector3(0, 0, ext.Z));
            Vector3 p6 = Camera.Project(Box.Min + new Vector3(ext.X, ext.Y, 0));

            Vector3 min = MathFunctions.Min(p1, p2, p3, p4, p5, p6);
            Vector3 max = MathFunctions.Max(p1, p2, p3, p4, p5, p6);

            return(new Rectangle((int)min.X, (int)min.Y, (int)(max.X - min.X), (int)(max.Y - min.Y)));
        }
Пример #3
0
        public Rectangle GetScreenRect(Camera camera)
        {
            BoundingBox box = GetBoundingBox();


            Vector3 ext    = (box.Max - box.Min);
            Vector3 center = box.Center();


            Vector3 p1 = camera.Project(box.Min);
            Vector3 p2 = camera.Project(box.Max);
            Vector3 p3 = camera.Project(box.Min + new Vector3(ext.X, 0, 0));
            Vector3 p4 = camera.Project(box.Min + new Vector3(0, ext.Y, 0));
            Vector3 p5 = camera.Project(box.Min + new Vector3(0, 0, ext.Z));
            Vector3 p6 = camera.Project(box.Min + new Vector3(ext.X, ext.Y, 0));


            Vector3 min = MathFunctions.Min(p1, p2, p3, p4, p5, p6);
            Vector3 max = MathFunctions.Max(p1, p2, p3, p4, p5, p6);

            return(new Rectangle((int)min.X, (int)min.Y, (int)(max.X - min.X), (int)(max.Y - min.Y)));
        }