Пример #1
0
        private bool computeCameraRect(Point p1,Point p2,View view)
        {
            Rectangle r = Tool.MakeScreenRect(p1, p2);

            if (r.Right - r.Left <= 0 || r.Bottom - r.Top <= 0)
            {
                mRectPT[0] = mRectPT[1] = mRectPT[2] = mRectPT[3] = Vector3F.Zero;
                return false;
            }

            mRectPT[0] = view.getCamera().getScreenWorldLocation(r.Left, r.Top, view);
            mRectPT[1] = view.getCamera().getScreenWorldLocation(r.Right, r.Top, view);
            mRectPT[2] = view.getCamera().getScreenWorldLocation(r.Right, r.Bottom, view);
            mRectPT[3] = view.getCamera().getScreenWorldLocation(r.Left, r.Bottom, view);

            for (int i = 0; i < 4; i++ )
            {
                Vector3F dir = mRectPT[i] - view.getCamera().Position;
                dir.Normalize();
                dir = dir * 0.01f;
                mRectPT[i] += dir;
            }

            return true;
        }
Пример #2
0
        public static IntersectionPair Intersect(Point screenpt, Plane plane, View view)
        {
            Vector3F pos = view.getCamera().getScreenWorldLocation(screenpt.X, screenpt.Y, view);
            Vector3F dir = pos - view.getCamera().Position; dir.Normalize();

            Ray ray = new Ray(pos, dir);
            IntersectionPair res = Sharp3D.Math.Geometry3D.IntersectionMethods.Intersects(ray, plane);
            return res;
        }