draw a cube with mouse in helix3D

Jan 17, 2012 at 9:24 AM

Hello ,

I am using the Helix 3d toolkit to develop my solution.

What I need and have not yet managed to develop properly is the drawing of a cube, or for that matter any other figure, with the mouse.

So when I press the left click I need the cube to begin drawing , as I keep dragging the mouse the cube should increase in size until I release the mouse button. at which moment the drawing should stop and the cube should be completed.

Unfortunately when drawing the cube i use the "HelixToolkit.Wpf.CubeVisual3D" which only has the center property and the size(width, height, depth) properties. so I am having problems drawing like any 3d program would , that is when when starting the drawing one corner should be fixed and the other points should mode until the drawing is complete. I thought of making the cube out of lines but that only applies to the cube and I also need to draw cylinders polygons   and others.

One more problem I am facing is that I assigned the rotation of the camera to the left click instead of the right click as it is usually. So that works for me only that when I select a figure to draw the left click should be used to draw and not to rotate the camera anymore until the selected button with the figure to draw is deselected then the left click is assigned back tot the rotation function.

Can anyone please point me in a right direction in order to solve this problems?

Thanks in advance.

Jan 17, 2012 at 10:33 AM
Edited Jan 17, 2012 at 10:33 AM

CubeVisual3D: right, you have to change the center point when you want to keep one corner (P1) fixed:

Center = P1 + new Vector3D(1,1,1) * SideLength * 0.5;

Rotate/draw modes: Can you set the RotateGesture to a MouseGesture(MouseAction.None) while you are in the draw mode?

I will add a box-drawing example when I get time :)

Jan 17, 2012 at 11:36 AM

Thank you for your quick reply, i have tried to move the center instead of keeping it fixed but whatever I tried failed because the cube was still growing in both directions so i did not get the fixed corner I was hopping . I will try this too.

Another thing is that I get the mouse position like this HelixViewport.CurrentPosition to get a Point3D object in order to check how much the position of the mouse has changed . But if I cross an object that I already have loaded in the viewport the coordinates I get from the "CurrentPosition" property are very different and I barely move the mouse this is most visible when I have the grid lines loaded and i pas over the lines. What could be the nature of this problem ?

I will try to set the gesture to MouseAction.None when in draw mode. Actually I have thought of doing this before but wanted to modify as little as I could in the Helix code so that I don't have conflicts in other parts of the toolkit. So i tried to catch the mouse down event outside but the handler I was using was not getting triggered. the mouse up and move events were triggered i user it like this :