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:
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.LineWidth(5.0f);
GL.Enable(EnableCap.LineSmooth);
GL.Begin(BeginMode.Lines);
GL.Vertex2(initialPosX, initialPosY);
GL.Vertex2(finalVectorX, finalVectorY);
GL.End();
GL.LineWidth(1.0f);
}
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!