public void SetProjectionType(ViewportProjection type)
        {
            bool diff = (type == ViewportProjection.Orthographic && _type != ViewportProjection.Perspective);

            Camera.Orthographic      = (_type = type) != ViewportProjection.Perspective;
            Camera._defaultTranslate = new Vector3();

            if (_type == ViewportProjection.Perspective)
            {
                Camera._nearZ         = 1;
                Camera._farZ          = 200000;
                Camera._ortho         = false;
                Camera._restrictXRot  = false;
                Camera._restrictYRot  = false;
                Camera._defaultScale  = new Vector3(1, 1, 1);
                Camera._defaultRotate = new Vector3();
            }
            else
            {
                Camera._nearZ            = -100000;
                Camera._farZ             = 100000;
                Camera._ortho            = true;
                Camera._restrictXRot     =
                    Camera._restrictYRot = _type != ViewportProjection.Orthographic;
                Camera._defaultScale     = GetDefaultScale();
                Camera._defaultRotate    = GetDefaultRotate();
            }
            if (!diff)
            {
                Camera.Reset();
            }
            Camera.CalculateProjection();
            Invalidate();
        }
示例#2
0
        public void SetCamera(ModelPanelViewport v, float frame, bool retainAspect)
        {
            ViewportProjection proj = (ViewportProjection)(int)ProjectionType;

            if (v.ViewType != proj)
            {
                v.SetProjectionType(proj);
            }

            GLCamera             cam = v.Camera;
            CameraAnimationFrame f   = GetAnimFrame(frame);

            cam.Reset();
            cam.Translate(f.Pos);

            Vector3 rotate = f.GetRotation(Type);

            cam.Rotate(rotate);

            float aspect = retainAspect ? cam.Aspect : f.Aspect;

            cam.SetProjectionParams(aspect, f.FovY, f.FarZ, f.NearZ);
        }