Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Drawing lines in 3D space

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013

    Drawing lines in 3D space using mouse

    Hello everyone!
    I'm having a bit of trouble figuring out how to draw a line in 3D space.
    What I want to do is allow the user to use their mouse to draw a line anywhere in the 3D space.
    They would left-click, hold it, and drag the mouse, as they drag the mouse the line would follow the cursor
    to where ever the new mouse position will be located.
    when they release the mouse button, the line should be created.
    here is a snippit of my codes:

    Code :
         public static void MousePos(System.Drawing.Point pt)
                Vector mousePosInit = sceneCamera.LevelToLocal(new Vector(pt.X, pt.Y, .01));
                initialPosX = mousePosInit.X; 
                initialPosY = mousePosInit.Y; 
             public static void UpdatePos(System.Drawing.Point pt)
                Vector mousePosFinal = sceneCamera.LevelToLocal(new Vector(pt.X, pt.Y, .01));
                finalVectorX = mousePosFinal.X; 
                finalVectorY = mousePosFinal.Y;
            public static void Render()
                GL.Vertex2(initialPosX, initialPosY);
                GL.Vertex2(finalVectorX, finalVectorY);
            private static ISE.Scenes.Camera sceneCamera = SceneManager.CurrentCamera;
            private static double initialPosX, initialPosY;
            private static double finalVectorX, finalVectorY;
    I'm using OpenTK as a wrapper since I'm coding it in C#.
    I also use Icarus Scene Engine 3 to do all the camera, and rendering work.
    Thanks for all the help!
    Last edited by ducle91; 07-25-2013 at 12:20 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts