Show center of rotation during mouse rotations

With this little piece of code it is possible to show a crosshair in correpondence of the center of rotation when the user performs a mouse rotation, like in the following picture:

Capture.PNG

 

This sample takes a ThreeVeiwportLayout derived class and shows the crosshair only in the second viewport.

 

    internal class MyViewportLayout : ThreeViewportLayout 
    { 
        protected override void DrawOverlay(DrawSceneParams myParams) 
        { 

            base.DrawOverlay(myParams); 

            if (ActiveViewport == 1 && ActionMode == actionType.Rotate) 
            { 
                Point3D ptScreen = Viewports[ActiveViewport].WorldToScreen(Viewports[ActiveViewport].CenterOfRotation); 

                gl.Color3f(1, 0, 0); 

                System.Drawing.Point pt = new System.Drawing.Point((int)ptScreen.X, (int)ptScreen.Y); 

                gl.Begin(gl.LINES); 
                gl.Vertex2i(pt.X - 6, pt.Y); 
                gl.Vertex2i(pt.X + 5, pt.Y); 

                gl.Vertex2i(pt.X, pt.Y + 6); 
                gl.Vertex2i(pt.X, pt.Y - 5); 

                gl.End(); 
            } 
        } 
    }
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.