This is the discussion forum for Helix Toolkit.
For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!

CombinedManipulator question

Anonymous 5 years ago 0
This discussion was imported from CodePlex

avgjoe wrote at 2012-03-11 18:39:

First off...Kick ass toolkit btw!  The examples gave me a good starting point.

The first thing I’m attempting to do is combine the ManipulatorDemo with the ModelViewer example.

I’ve added the following code to the ModelViewer to allow the model to be repositioned and rotated.  The visual rotate manipulators appear to grow in size but the translate manipulators do not.   Am I missing something here?


 private void ModelLoaded(object sender, RoutedEventArgs e)

CombinedManipulator manipulator = new CombinedManipulator();
Rect3D rect = Visual3DHelper.FindBounds(view1.Children);
manipulator.Diameter = rect.Y;

objo wrote at 2012-03-11 20:56:

To me it seems like the manipulation transform is applied twice to the manipulator. Adding the manipulator one level higher in the Visual3D tree should avoid it:


Sorry the "ModelViewer" example is not in good shape, I am planning to improve it, hopefully this year :)

Mrme wrote at 2013-08-01 10:02:

I would like to know if you solved this problem

thebestgin wrote at 2014-08-05 15:32:

I have the same problem. The translate manipulator do not size.
The problem is the emty methode OnDiameterChanged() at line 404.

Here my suggestion:
     /// <summary>
    /// The on diameter changed.
    /// </summary>
    protected virtual void OnDiameterChanged()
        double radius = this.Diameter / 2;
        double newArrowLength = radius + radius * 0.4; 
        this.TranslateXManipulator.Length = newArrowLength;
        this.TranslateYManipulator.Length = newArrowLength;
        this.TranslateZManipulator.Length = newArrowLength;

        double newArrowDiameter = newArrowLength * 0.075;
        this.TranslateXManipulator.Diameter = newArrowDiameter;
        this.TranslateYManipulator.Diameter = newArrowDiameter;
        this.TranslateZManipulator.Diameter = newArrowDiameter;

        double newInnerDiameter = this.Diameter - this.Diameter * 0.12;
        this.RotateXManipulator.InnerDiameter = newInnerDiameter;
        this.RotateYManipulator.InnerDiameter = newInnerDiameter;
        this.RotateZManipulator.InnerDiameter = newInnerDiameter;

Context menu

Anonymous 5 years ago 0
This discussion was imported from CodePlex

ddklo wrote at 2012-03-03 00:06:


I was wondering if there were a recommended way of showing a context menu when the user rights clicks in the HelixViewport3D? Currently we are subscribing to the mouse down event, but there are some problems relating to the mouse being capture and not released (maybe because the right mouse button is also used to move). Is there a way to add a ShowContextMenu Command/Gesture?

Regards Dagfinn

objo wrote at 2012-03-10 16:14:

I have used a standard wpf context menu on a HelixViewport3D in an application that shows a list of selectable items on left mouse clicks, but I have not tried it on the right mouse button. Should add an example that opens a context menu on both left and right clicks. For the left click context menu I had to open the context menu manually by setting IsOpen=true. 

davidop wrote at 2013-05-28 14:53:

Could you give some examples? I have a HelixViewport3D with multiples ModelVisual3D and I would like that when you click with the right mouse button a contextual menu appear.

Change model3dgroup associated to model3d

Anonymous 5 years ago 0
This discussion was imported from CodePlex

AlexanderPD wrote at 2013-03-26 20:49:

Hi, my project started from your kinect example. I'm trying to do a kinect recorder and player.

all is going well but now i need to reproduce my video, obj after obj.
in public MainWindow() i do this:
this.KinectGroup = new Model3DGroup();
Model = KinectGroup;
and the rendered model is the kinectGroup i set. All fine!
but now i need to unbind that KinectGroup and use another group, the one i'm using to reproduce the "video"

This is my try:
Model3DGroup group = HelixToolkit.Wpf.ModelImporter.Load(extractPath + @"\model1.obj");
Model = new GeometryModel3D();
Model = group;
i tried to reinitialize the model and associate my group to it.. but this seems to do nothing! I still see the older group (my 2 kinects input) while it still refresh itself :(

how i can do this? thank you!

AlexanderPD wrote at 2013-03-29 14:29:

Solved by removing kinectGroup's children and adding the new ones. Maybe not optimal solution but it works :\

How to Enable Touch?

Anonymous 5 years ago 0
This discussion was imported from CodePlex

cmouritsen wrote at 2014-01-29 16:14:


Is there an example for enabling Touch? Is all I need to do set IsManipulationEnabled to true on the Helix3DViewPort?


objo wrote at 2014-01-29 19:44:

Touch should be enabled by default. The CameraController class sets IsManipulationEnabled = true

cmouritsen wrote at 2014-01-29 19:50:

OK. It didn't seem to be for me. Here's my code:
<StackPanel Name="previewPanel" Margin="450,0,0,0" Width="430" Height="580">
     <HelixToolkit:HelixViewport3D x:Name="modelPreview" Width="430" Height="580" ZoomExtentsWhenLoaded="True" ModelUpDirection="0,1,0">
                            <PerspectiveCamera LookDirection="0,0,-1" UpDirection="0,1,0"/>
                        <HelixToolkit:DefaultLights />
                        <ModelVisual3D x:Name="model3D"/>                                                
This didn't respond to Touch at all. Then I tried setting IsManipulationEnabled="True" on the HelixViewport3D and that caused it to have some response to Touch, but it still wasn't usable. I'm sure I'm doing something wrong, but I have no idea what. I'm testing the Touch on a Windows 8.1 Touchscreen laptop.

objo wrote at 2014-01-29 19:59:

Is touch event handling working in the examples? Try the "SimpleDemo".
The examples are working with touch events on my Windows 8.1 machine (one finger to rotate, two fingers to pan and pinch to zoom).
Your code looks ok. Are you loading a really big model? Try to replace the ModelVisual3D with a simple cube visual.

cmouritsen wrote at 2014-01-29 20:07:

I will try the SimpleDemo and replacing the ModelVisual3D. In this case it is a fairly big model. Will it not work with big models?

cmouritsen wrote at 2014-01-29 21:54:

I replaced my ModelVisual3D with a Teapot and the Touch worked great. Will Touch not work on bigger models?

objo wrote at 2014-02-02 12:14:

I have seen similar behaviour, but don't know what causes this.
The ManipulationStarted and ManipulationDelta events are used the same way as MouseDown and MouseMove.

ModelViewer code doesn't recognize materials

Anonymous 5 years ago 0
This discussion was imported from CodePlex

pggarland wrote at 2013-02-08 04:43:

ModelImporter.Load, invoked from the ModelViewer source, doesn't seem to recognize material definitions. All models are either green (no material definition) or Yellow (there is a material definition that references a .MTL file, but the material info is ignored). Am I missing something, or is ModelViewer not meant to recognize different colored material in OBJ files?

objo wrote at 2013-02-10 16:16:

The Obj reader should support materials (diffuse, ambient, specular, textures and opacity). You should try to debug the import of the .mtl file. Set a breakpoint in the LoadMaterialLib method. Let us know if there is a bug in the code, and we will correct it.

pggarland wrote at 2013-02-12 04:09:

My bad. Stepping into the code, I saw that there were tabs in the materials file. Still working on lighting, but this problem is solved. Thanks!

Rectangles are not drawn of specified Colors !!!!

Anonymous 5 years ago 0
This discussion was imported from CodePlex

terry_513 wrote at 2014-01-29 11:16:

I need to draw N vertical parts. So, I draw rectangles specifying its parameters & different colors for each part.
        private void DrawSections()
            double x = 0, y = 0;
            int i=0;
            SolidColorBrush[] brushes = new SolidColorBrush[]{Brushes.Red, Brushes.Purple, Brushes.Gold, Brushes.Green, Brushes.YellowGreen, Brushes.Turquoise, Brushes.Wheat, Brushes.Pink, Brushes.PaleVioletRed, Brushes.Olive};

            foreach (Section sec in areasList_Scaled)
                RectangleVisual3D rect = new RectangleVisual3D();
                rect.Origin = new Point3D(x, y, 0);
                rect.Length = 120;
                rect.Width = sec.Length;   // myRect.Width;
                //rect.Fill = Brushes.Lavender;   // new SolidColorBrush(Colors.LightCoral);
                rect.Material = new DiffuseMaterial(brushes[i]);

                Console.Write("RECT LEN = " + sec.Length);

                y += sec.Length;
With this code, I get rectangles, but not of the specified colors - instead of black & white colors. The Length of each sections is like
RECT LEN = 12.2586666666667RECT LEN = 0.202133333333333RECT LEN = 11.5825333333333RECT LEN = 0.157333333333333RECT LEN = 19.9297333333333RECT LEN = 0.15733333333333RECT LEN = 17.8796666666667RECT LEN = 0.157399999999992

I know I have set rect.Width = sec.Length which sould be set for rect.Length. But with that setting, I was getting rectangle vertically long the length is smaller than width. I couldn't get why was getting that results also.

Any idea, why the rectangles are not shown of specified colors and of black & white colors !!!!
This is mainly to get the background effect. Each section tells something different.

Any help is highly appreciated.


objo wrote at 2014-01-29 19:49:

Did you add lights to your scene?

terry_513 wrote at 2014-01-30 06:55:

Oh yes, I hadn't added lights. Had no idea that, without lights 3D colors are not visible !!!!.

Added lights and now it shows properly.

I need to add background to rectangles of image. Can you suggest any link or article that can help me or you provide an example for the same.

Thanks a lot.

Simplest way to draw a new RectangularVisual3d

Anonymous 5 years ago 0
This discussion was imported from CodePlex

ronnyek wrote at 2012-05-10 17:07:

I am looking at creating a plane that when in the overhead view, I'd like to be able to draw a rectangle to represent selection. (like what you might see when lasso'ing a bunch of icons in windows.

I'm struggling to find out a way to draw a rectanglularvisual... and was hoping perhaps someone can point me in the correct direction.

I've got the mouse down/move/up events setting upper left and lower right of a rectangle, but seeing as rectangularvisual 3d uses origin etc, I cant just plug those values in. 


ondown, check mouse buttons, findnearestpoint set variable to that if there is a value

onmove, if dragging, create rectangular visual if not null, and then set its origin to x-x/2 and y-y/2. (z dimension shouldnt really matter in this case.


Is there an easier way to do this? (I couldnt get this to work anyway)

objo wrote at 2012-05-10 22:07:

yes, the RectangleVisual3D is defined by Origin, Width and Length.

If you want to draw a rectangle aligned with the X and Y axes in the z=0 plane, e.g. from P1=Point3D(x1,y1,0) to P2=Point3D(x2,y2,0), you could set

Normal = new Vector3D(0,0,1)
LengthDirection = new Vector3D(1,0,0)
Origin = P1+(P2-P1)*0.5
Length = Math.Abs(P2.X-P1.X)
Width = Math.Abs(P2.Y-P1.Y)

CornelRo wrote at 2012-11-07 09:03:

Thanks for the code above, I am also trying to make a selection box by creating a RectangleVisual3D to always face the camera regardless of the camera position. With the above code I made this possible, but only if the camera is in the standard views(F,B,L,R,U,D).

Does anybody know how to calculate the Normal & LengthDirection of the RectangleVisual3D depending on the Camera settings?

objo wrote at 2012-11-07 09:20:

see Source\HelixToolkit.Wpf\Visual3Ds\ScreenSpaceVisuals\BillboardVisual3D.cs


Camera Settings

Anonymous 5 years ago 0
This discussion was imported from CodePlex

SagarDabas wrote at 2013-02-10 06:08:

Sir, Can you please tell me how to manipulate camera. I want to change lots of things in the default camera. Like
  1. the camera rotation should be done programmatically not mouse.
  2. the camera rotates along only y-axis.
  3. the axis of rotation can be changed.
And, also this thing returns NULL == > myHelixViewPort.CameraController.

Please, it's really very urgent. And thank you for such an awesome product.

objo wrote at 2013-02-10 16:11:

Wish I could help you, but I don't think this is within the scope of this library. But constraints on the camera position/look direction is planned (issue 9979 and 9961).
Maybe animations of the camera properties can help in your case, see msdn.

The CameraController is null until the control template is applied. Should not be null after that. Maybe you try to access the property too early?

SagarDabas wrote at 2013-02-11 15:07:

Thanks for the reply,
I solved my first problem by simulating mouse inputs ... but I am still not able to understand when should I try to access property ....
This was the code
public partial class MainWindow : Window
        public MainWindow()
            CameraController controller = this.myViewPort3D.CameraController;
            if(controller == null)   Console.WriteLine("Controller is null");
            DataContext = this;
and the output is "controller is null". When should I access this property , I am just a beginner. I am not able to figure out whether ControlTemplate is applied or not . Please answer

objo wrote at 2013-02-11 16:52:

Wait until the Window is loaded. Subscribe to the Loaded event on the Window:

SagarDabas wrote at 2013-02-11 17:42:

Ohh, thank you so much. I extended the library and modified some Visuals so easily. Thanks for such a good product.

Model3d Hit Testing

Anonymous 5 years ago 0
This discussion was imported from CodePlex

cobra18t wrote at 2011-12-13 16:12:

I am trying to follow your Voxel example to highlight a 3D model in the viewport when the user mouses over it. I have multiple Model3D objects in the viewport and the hit testing works fine until I start adding transforms to the Model3Ds. Even if the model is transformed to say (100,20,0), the hit testing reports a Model3D that is positioned at its original location, (0,0,0). I tried to determine which model was moused over by the bounding box of the orignal model and the bounding box of the hit result, but this only worked for some of the models. Any ideas? should I be using a different object type?

cobra18t wrote at 2011-12-13 17:33:

Additionally, hits.First().Position is reporting a position that is scaled with the same scale transformation of the model that is moused over. So when mousing over a model so that the mouse is hitting point (1,1,1) on the surface of the model, Position reports (5,5,5) as the hit point since the model is scaled by 5 in each dimension. Is there a way to apply the transformation permanently to avoid these discrepancies?

objo wrote at 2011-12-13 18:38:

have a look at HelixToolkit.Wpf.Viewport3DHelper.GetTransform to get the total transforms applied to the Visual3Ds and Model3Ds in your hits.

Also see the Viewport3DHelper.FindNearestPoint method!

valdis1987 wrote at 2013-08-15 14:07:

Can't get necessary results.
Can someone help me? I think this question is a problem to others also.

So lets say i have:
 <Helix3D:HelixViewport3D x:Name="Mainviewport">
<Helix3D:HelixVisual3D  x:Name="Scene">
..Inside is  <Helix3D:HelixVisual3D.Content><Model3DGroup> with deep tree with   Model3dGroup[...]

<Helix3D:HelixVisual3D  x:Name="Obje1"/>
<Helix3D:HelixVisual3D  x:Name="Obje2"/>
<Helix3D:HelixVisual3D  x:Name="Obje3"/>
<Helix3D:HelixVisual3D  x:Name="Obje4"/>

Inside HelixViewport3D all items have transforms( ScaleTransform3D,RotateTransform3D,TranslateTransform3D)

Now how I can get notice that Obje1 have hit Scene? Or Obje1 have hit Obje2?

I done a lot of try's to get result but no success.

Can someone give me a couple tips how to accomplish my target?


How to Draw a Post Cap

Anonymous 5 years ago 0
This discussion was imported from CodePlex

AQSRanck wrote at 2014-06-28 04:12:

I have adopted the methodology as characterized in SiloVisual3D. In a previous post (How to draw a funnel) objo pointed me to SiloVisual3D, and solved my problem. Actually, I found what I really needed close by, in the ChimneyVisual3D which is contained in the same project.

I can draw all sorts of assemblies that derive from Box, Pipe, Cylinder, Cone etc. But now I have a new challenge. How would I approach drawing a more complex structure, In a similar fashion to SiloVisual3D, suppose I have a PostCapVisual3D. Could you suggest what elements to use to draw the Post Cap pictured below. I don't care about the textured finish, I'm more interested in your suggestion of which tools to use to draw the shape.


link to picture of Post Cap

objo wrote at 2014-07-02 13:19:

I think you need a triangulation method that supports holes here! I would try

AQSRanck wrote at 2014-07-02 15:21:

Thanks objo ,

I will keep that in mind when I need holes. In fact I these holes are to be filled with Nails, so I tried the example you used in Legos (with short pipes) to represent the nail heads and while the results were OK the code for the illustration and its placement became way too complicated. I decided to abandon it for more important issues. There are actually hundreds of different connectors like the one that I linked to in the first post and they are available in 2D form. The real solution for the larger issue here is to someday find a way to edit and convert from .DXF or .DWG files to simple Helix illustrations.

Thank you again,