Hello,
I have implemented a brush-like selection of mesh faces inside a GetPoint
, with the final purpose of splitting a mesh into specific parts.
The result I got so far is this:
Following @jeff suggestions from another post, I draw the preview mesh as a shaded geometry with vertex colors (blue = unselected, yellow = selected).
The preview mesh would be much nicer if it showed also wires (with depth test filtering).
What I’m currently doing is drawing everything inside a custom GetPoint.DynamicDraw()
method. I understand the DynamicDraw
routine does not consider depth testing in any way (so it’s like a conduit’s DrawOverlay()
), but I thought of using it to have e.CurrentPoint
for free, without having to implement all mouse events.
public class GetPointDraggable : GetPoint
{
public class CustomMouseCallback : MouseCallback
{
public bool DragFlag = false;
public CustomMouseCallback() {
Enabled = true;
}
protected override void OnMouseUp(MouseCallbackEventArgs e) {
base.OnMouseUp(e);
DragFlag = false;
}
protected override void OnMouseDown(MouseCallbackEventArgs e) {
base.OnMouseDown(e);
if (e.MouseButton == MouseButton.Left) {
DragFlag = true;
}
}
}
public CustomMouseCallback Callback = new CustomMouseCallback();
public HashSet<int> SelectedFaceIndices = new HashSet<int>();
public Point3d? CurrentPoint = null;
public GetPointDraggable() {
MouseDown += (s, e) => {
SelectedFaceIndices.Clear();
CurrentPoint = null;
};
MouseMove += (s, e) => {
if (Callback.DragFlag) {
CurrentPoint = e.Point;
}
};
}
}
But anyway, that was not actually true, because to know when the user is dragging I had to attach a MouseCallback
to the GetPoint class…
(by the way, is there a reason why GetPoint allows you to override OnMouseDown
/ OnMouseMove
but NOT OnMouseUp
? I need to know when the mouse is released to understand when the drag operation is finished… that’s why I had to attach a MouseCallback
instead).
I also tried to draw wires or unselected faces on a separate Conduit, but then I had a hard time synchronizing the conduit redraw and the selected faces draw from the DynamicDraw
.
I think I messed up a little all the interactions
So what approach would it be the best to draw a preview with mesh wires, over which the user can “paint” faces by dragging the mouse?
I you have any idea, it would be much appreciated.
Thanks