Beispiel #1
0
        public ViewerControl(ModelingHistory history) :
            base(new GraphicsMode(m_GLColorFormat, m_GLDepth, m_GLStencil, m_GLSamples, 48, 2, m_GLStereo), 3, 0, GraphicsContextFlags.Debug)
        {
            hist = history;

            //clusters = hist.Layers.GetClusters();
            clusters = hist.Layers.GetClusteringLayer(currentClusterLayer).clusters;

            this.SuspendLayout();
            this.BackColor = System.Drawing.Color.DimGray;
            this.ResumeLayout(false);

            base.CreateControl();

            this.Cursor = Cursors.Cross;
            VSync       = false;

            //setup viewables
            SetCluster();

            //setup camera
            m_Camera.Width  = Width;
            m_Camera.Height = Height;
            m_Camera.Set(new Vec3f(), Quatf.AxisAngleToQuatf(Vec3f.Z, -45), 10, false);

            //m_RefreshTimer.Elapsed += delegate { RefreshControl(); };
        }
        /// <summary>
        /// Orbit Camera Position around Target, maintaining distance to Target and the Up vector
        /// </summary>
        /// <param name="theta_degrees">
        /// A <see cref="System.Double"/>
        /// </param>
        public void OrbitTarget(double theta_degrees)
        {
            double theta  = theta_degrees * Math.PI / 180.0;
            Quatf  newrot = qrot * Quatf.AxisAngleToQuatf(NaturalUp.Val, (float)theta);

            Set(Target.Val, newrot, dist);
        }
        /// <summary>
        /// Pan the Camera around the Up vector by <c>theta_degrees</c> degrees.
        /// </summary>
        /// <param name="theta_degrees">
        /// A <see cref="System.Double"/>
        /// </param>
        public void RotatecAboutAxis(Vec3f axis, double theta_degrees)
        {
            double theta = theta_degrees * Math.PI / 180;
            Vec3f  tar   = Quatf.AxisAngleToQuatf(axis, (float)theta).Rotate(Forward.Val * dist) + Position.Val;

            Set(tar, qrot * Quatf.AxisAngleToQuatf(axis, (float)theta), dist);
        }
Beispiel #4
0
        public void OrbitTargetUpDown(double theta_degrees, bool clampflips = false)
        {
            double theta  = theta_degrees * Math.PI / 180.0;
            Quatf  newrot = qrot * Quatf.AxisAngleToQuatf(GetRight(), (float)theta);

            //if (clampflips)
            //{
            //    Vec3f newup = Vec3f.Normalize(newrot.Rotate(Vec3f.Y));
            //    float dot = FMath.PI / 2.0f - Vec3f.AngleBetween(newup, NaturalUp);
            //    if (dot < 0)
            //    {
            //        Vec3f newforward = Vec3f.Normalize(newrot.Rotate(-Vec3f.Z));
            //        Vec3f newright = newforward ^ newup;
            //        float sign = -Math.Sign(newforward % NaturalUp);
            //        newrot = newrot * Quatf.RotAxisAngleToQuatf(newright, dot * sign);
            //    }
            //}

            Set(Target, newrot, dist);
        }
        /*public void OrbitTargetUpDownNatural( double theta_degrees )
         *      {
         *              float fn = Forward.Val % NaturalUp.Val;
         *              if( ( theta_degrees < 0.0 && fn >= 0.95f ) || ( theta_degrees > 0.0 && fn <= -0.95f ) ) return;
         *
         *              double theta = theta_degrees * Math.PI / 180.0;
         *              Vec3f posreltar = Position.Val - Target.Val;
         *              Vec3f right = Forward.Val ^ NaturalUp.Val;
         *              float dist = (Target.Val - Position.Val).Length;
         *
         *              Properties.DeferPropertyChanged = true;
         *              bIgnoreChanges = true;
         *              Position.Set( Target.Val + Vec3f.Normalize( VecExtensions.RotateVectorAroundAxis( posreltar, right, (float) theta ) ) * dist );
         *              Up.Set( VecExtensions.RotateVectorAroundAxis( Up.Val, right, (float) theta ) );
         *              bIgnoreChanges = false;
         *              Target.Set( Target.Val );
         *              Properties.DeferPropertyChanged = false;
         *      }*/

        public void OrbitTargetUpDown(double theta_degrees, bool clampflips)
        {
            double theta  = theta_degrees * Math.PI / 180.0;
            Quatf  newrot = qrot * Quatf.AxisAngleToQuatf(GetRight(), (float)theta);

            if (clampflips)
            {
                // prevent camera from flipping over!
                Vec3f newup = Vec3f.Normalize(newrot.Rotate(Vec3f.Y));
                float dot   = FMath.PI / 2.0f - Vec3f.AngleBetween(newup, NaturalUp.Val);
                if (dot < 0)
                {
                    Vec3f newforward = Vec3f.Normalize(newrot.Rotate(-Vec3f.Z));
                    Vec3f newright   = newforward ^ newup;
                    float sign       = -Math.Sign(newforward % NaturalUp.Val);
                    newrot = newrot * Quatf.RotAxisAngleToQuatf(newright, dot * sign);
                }
            }

            Set(Target.Val, newrot, dist);
        }
Beispiel #6
0
 public void Reset()
 {
     Set(new Vec3f(), Quatf.AxisAngleToQuatf(Vec3f.Z, -45) * Quatf.AxisAngleToQuatf(Vec3f.Y, -45), 10, false);
 }