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!
0
Under review

Select Object into the view

Anonymous 11 years ago updated by ไอยดา สุรีวงค์ 4 years ago 2
This discussion was imported from CodePlex

CesarMayorine wrote at 2014-09-01 12:59:

how can I select a Object (Children) in view?

CesarMayorine wrote at 2014-09-01 13:00:

With mauseclick...
0

Camera rotate around centroid or specific point

Anonymous 11 years ago 0
This discussion was imported from CodePlex

charlh wrote at 2012-07-30 17:33:

Hi there.

Is there any way to always have the camera rotate about a model's centroid (say a cube for example)? In other words, update the rotation point when a model is zoomed in on or panned so that the point of rotation is always about the model's centroid or a point of choice in 3d space.  Thanks for the help.


objo wrote at 2012-08-09 00:52:

This is a new feature in the 'camera controller'. Need to create a new mode where the rotation point is fixed (currently you can choose between rotating around the 'mouse down point' or the camera 'target' point).

Added as issue http://helixtoolkit.codeplex.com/workitem/9961

0

Moving the Model instead of the camera

Anonymous 11 years ago 0
This discussion was imported from CodePlex

MikeCo wrote at 2012-10-24 18:42:

Is there a way to move the model in space and not the camera?

 

Thanks!


objo wrote at 2012-10-26 08:54:

The mouse handlers in this toolkit moves the camera, you need to write your own mouse handlers if you want to transform your model!

0

CuttingEarsTriangulator possible bug

Anonymous 11 years ago 0
This discussion was imported from CodePlex

baucez wrote at 2013-04-19 16:03:

Hi! I'm using CuttingEarsTriangulator to draw complex polygons.
It works almost all the time but I found some cases in which method Triangulate gives me null even if the polygons is valid.

One of this cases is when I pass the following list of points:
0,0
0,1.894
-2.536,1.42
-5.072,1.42
-5.072,2.84
-10.144,2.84
-10.144,0

How can I get my triangles? Is there a workaround?

RobPerkins wrote at 2013-04-22 23:05:

I haven't studied the code in the Helix stack, but I've gotten very good Cutting Ear results from the archived CodeProject project at:

http://www.codeproject.com/Articles/8238/Polygon-Triangulation-in-C

The code is conveniently in C# and contains no dependencies on anything except .NET (probably .NET 1.1, so it would be good for any .NET stack)

objo wrote at 2013-04-26 22:23:

baucez: thanks for the example polygon - I will add a unit test for this case
RobPerkins: thanks for the link, I will have a look at that implementation, and possible use it to verify results

objo wrote at 2013-04-30 23:09:

the following code
           var polygon = new[]
                              {
                                  new Point(0, 0),
                                  new Point(0, 1.894),
                                  new Point(-2.536, 1.42),
                                  new Point(-5.072, 1.42),
                                  new Point(-5.072, 2.84),
                                  new Point(-10.144, 2.84),
                                  new Point(-10.144, 0)
                              };
            var result = CuttingEarsTriangulator.Triangulate(polygon);
gives the result
{0 1 2 3 4 5 6 0 2 3 5 6 6 2 3}
which looks correct to me...

baucez wrote at 2013-05-02 10:21:

Objo.. you are right!
I looked better at my code and I found that the list of points that I gave you was approximated.

If you try this code will fail:
  {
            var polygon = new[]
                {
                    new Point(0, 0),
                    new Point(0, 2.97),
                    new Point(-2.389999999999997, 2.97),
                    new Point(-2.389999999999997, 1.4849999999999999),
                    new Point(-4.7799999999999976, 1.4849999999999999),
                    new Point(-4.7799999999999976, 2.97),
                    new Point(-9.5599999999999987, 2.97),
                    new Point(-9.5599999999999987, 0),
                };

            var result = CuttingEarsTriangulator.Triangulate(polygon);
            Assert.IsNotNull(result);
        }
The problem is caused by double arithmetic approximations.
In particular (but I'm not sure is the only place in the code) the problem is in the comparisons at the end of CuttingEarsTriangulator.InsideTriangle method

objo wrote at 2013-05-08 15:28:

thanks! I have checked in the fix
0

Meshbuilder with 32000 position, normal and etc memory problem

Anonymous 11 years ago 0
This discussion was imported from CodePlex

behnam263 wrote at 2014-07-05 09:07:

Hi
I started to add position and normal and texture coordinates to a meshbuilder but i get memory inefficient by debuger!
Is it a memory leak? How can i handle this?

objo wrote at 2014-07-11 21:45:

Please provide an example that shows the problem! The MeshBuilder should not hold any memory.

behnam263 wrote at 2014-07-22 10:41:

I found that my problem is about exceeding memory for an array not meshbuilder thank you
0

Merge 2 meshgeometry3D to 1 ?

Anonymous 11 years ago 0
This discussion was imported from CodePlex

behnam263 wrote at 2014-05-11 07:43:

What is the concept For merging two meshgeometry3D ?
Is there anything in this library for it?

objo wrote at 2014-05-19 21:46:

The MeshBuilder.Append method can do this!
0

FileModelVisual3D and opacity

Anonymous 11 years ago 0
This discussion was imported from CodePlex

regha wrote at 2013-09-20 18:42:

Hi,
I don't know how to change the opacity of an FileModelVisual3D object.
Somebody can help me...

objo wrote at 2013-09-29 10:03:

Try to traverse the visual tree below the FileModelVisual3D and replace the materials in the GeometryModel3D objects.

regha wrote at 2013-09-29 10:55:

thanks for your answer but I don't know how 'to traverse the visual tree'...
I can access to children of viewport but after... I don't know...

regha wrote at 2014-07-30 14:59:

Hi,
Anybody knows how to retrieve geometryModel3D from FileModelVisual3D ?

everytimer wrote at 2014-07-30 19:24:

I've never worked with FileModelVisual3D but I'm sure that the way is to try to cast its Content as GeometryModel3D and Model3DGroup:
   Model3DGroup grupo = (Model3DGroup)myFileModelVisual3D.Content;

            foreach (var modelo in grupo.Children.OfType<GeometryModel3D>())
            {
                GeometryModel3D model = (GeometryModel3D)modelo;
                var mat1 = modelo.Material.Clone();
                var mat2 = modelo.BackMaterial.Clone();
                MaterialHelper.ChangeOpacity(mat1, SliderVerifyOpacity.Value);
                MaterialHelper.ChangeOpacity(mat2, SliderVerifyOpacity.Value);

                model.Material = mat1;
                model.BackMaterial = mat2;
            }

            foreach (var group in grupo.Children.OfType<Model3DGroup>())
            {
                Model3DGroup grupoModel = (Model3DGroup)group;
                foreach (var modelo in grupoModel.Children.OfType<GeometryModel3D>())
                {
                    GeometryModel3D model = (GeometryModel3D)modelo;

                    var mat1 = modelo.Material.Clone();
                    var mat2 = modelo.BackMaterial.Clone();
                    MaterialHelper.ChangeOpacity(mat1, SliderVerifyOpacity.Value);
                    MaterialHelper.ChangeOpacity(mat2, SliderVerifyOpacity.Value);

                    model.Material = mat1;
                    model.BackMaterial = mat2;
                }
            }
In this example the opacity is controlled by a Slider, change to a specific value if you want it so.
Good luck.
0
Under review

Fill polygon with texture

Anonymous 11 years ago updated by Øystein Bjørke 10 years ago 2
This discussion was imported from CodePlex

Nikodem wrote at 2014-06-25 22:55:

How can I make 2D polygon geometry with image texture.

For the rectangle I use two triangle and for texture I added coordinates for triangles:

// triangle ABC
mesh.TriangleIndices.Add(0);
mesh.TriangleIndices.Add(1);
mesh.TriangleIndices.Add(2);

// triangle ACD
mesh.TriangleIndices.Add(0);
mesh.TriangleIndices.Add(2);
mesh.TriangleIndices.Add(3);

mesh.TextureCoordinates.Add(new Point(0, 1)); // point A
mesh.TextureCoordinates.Add(new Point(1, 1)); // point B
mesh.TextureCoordinates.Add(new Point(1, 0)); // point C
mesh.TextureCoordinates.Add(new Point(0, 0)); // point D


var d = new DiffuseMaterial(imgBrush);
mGeometries.Add(new GeometryModel3D(mesh, d));

....


On this discussion I found functions for create of polygon.
public static MeshGeometry3D FillPolygon(Polygon p)
    {
        List<Point3D> pts3D = new List<Point3D>();
        foreach (var point in p.Points)
        {
            pts3D.Add(new Point3D(point.X, point.Y, 0));
        }
        Polygon3D p3 = new Polygon3D(pts3D);
        return FillPolygon(p3);
    }

    public static MeshGeometry3D FillPolygon(Polygon3D p3)
    {
        var meshBuilder = new MeshBuilder(false, false);

        Polygon polygon = p3.Flatten();
        var triangleIndexes = CuttingEarsTriangulator.Triangulate(polygon.Points);

        meshBuilder.Append(p3.Points, triangleIndexes);

        return meshBuilder.ToMesh();
    }

Polygon drawing right, but I do not know how I do configuration for fill texture on the polygon.
Texture is rectangle image and I wants show shape cut of texture on the polygon.

Thank you very much.
Jindrich
0

Help with cutting plane group

Nit29 10 years ago 0
I have a bindable version of cutting plane group(a custom control wrapping the cutting plane group to make it bindable) that cuts the model correctly. However, other items are not cut in the group. The other items are custom control of type Visual3D. ModelVisual3D nested within the cuttingplane group gets cut but not the 'PlanesControl'. Below is the xaml-

<controls:BindableCuttingPlaneGroup Operation="Intersect" BindableCuttingPlanes="{Binding ModelCuttingPlanes.DataValue}">
<controls:BindableCuttingPlaneGroup.IsCuttingPlanesEnabled>
<MultiBinding Converter="{StaticResource CuttingPlaneConverter}">
<Binding Path="DataContext.IsBindableCuttingPlanesEnabled.DataValue" RelativeSource="{RelativeSource AncestorType=UserControl}" />
<Binding Path="DataContext.MainViewTitle.DataValue" RelativeSource="{RelativeSource AncestorType=UserControl}" />
</MultiBinding>
</controls:BindableCuttingPlaneGroup.IsCuttingPlanesEnabled>
<ContainerUIElement3D x:Name="MainContainer" Transform="{Binding ModelTransform.DataValue}">
<ModelVisual3D x:Name="Model3D" Content="{Binding Model3DGroupObj.DataValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<ContainerUIElement3D x:Name="FirstTeethPlanesContainerElement" Visibility="{Binding FirstToothPlanesVisibility.DataValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Transform="{Binding InvertedModelTransform.DataValue}">
<controls:PlanesControl Transform="{Binding FirstToothPlanesTransform.DataValue}"/>
</ContainerUIElement3D>
<ContainerUIElement3D x:Name="SecondTeethPlanesContainerElement" Visibility="{Binding SecondToothPlanesVisibility.DataValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Transform="{Binding InvertedModelTransform.DataValue}">
<controls:PlanesControl Transform="{Binding SecondToothPlanesTransform.DataValue}"/>
</ContainerUIElement3D>
<ContainerUIElement3D x:Name="ImplantationPlanesContainerElement" Visibility="{Binding ImplantationPlanesVisibility.DataValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Transform="{Binding InvertedModelTransform.DataValue}">
<controls:PlanesControl Transform="{Binding ImplantationPlanesTransform.DataValue}"/>
<ht:PipeVisual3D Fill="Red" Diameter="0.5" InnerDiameter="0" Point1="0,0,25" Point2="0,0,-25"></ht:PipeVisual3D>
</ContainerUIElement3D>
<ContainerUIElement3D x:Name="AdjContactContainer" Transform="{Binding InvertedModelTransform.DataValue}">
<ht:SphereVisual3D Radius="0.75" Fill="Red" Center="{Binding AdjContact1Point.DataValue}" Visible="{Binding AdjContact1Point.DataValue, Converter={StaticResource BoolConverter}}" />
<ht:SphereVisual3D Radius="0.75" Fill="Red" Center="{Binding AdjContact2Point.DataValue}" Visible="{Binding AdjContact2Point.DataValue, Converter={StaticResource BoolConverter}}" />
<ht:PipeVisual3D Fill="DodgerBlue" Diameter="0.5" InnerDiameter="0" Point1="{Binding AdjContact1Point.DataValue}" Point2="{Binding AdjContact2Point.DataValue}" Visible="{Binding AdjContactMidPoint.DataValue, Converter={StaticResource BoolConverter}}" />
<ht:SphereVisual3D Radius="0.75" Fill="Green" Center="{Binding AdjContactMidPoint.DataValue}" Visible="{Binding AdjContactMidPoint.DataValue, Converter={StaticResource BoolConverter}}" />
<ht:PipeVisual3D Fill="Yellow" Diameter="0.5" InnerDiameter="0" Point1="{Binding AdjContactMidPointVectored1.DataValue}" Point2="{Binding AdjContactMidPointVectored2.DataValue}" Visible="{Binding AdjContactMidPoint.DataValue, Converter={StaticResource BoolConverter}}"></ht:PipeVisual3D>
</ContainerUIElement3D>
</ContainerUIElement3D>
</controls:BindableCuttingPlaneGroup>



0

Purpose of EnableCurrentPosition property

everytimer 11 years ago updated by anonymous 8 years ago 3
What is the purpose of the EnableCurrentPosition property?

If we inspect the code we can see that it controls whether CurrentPosition is calculated or not:

[HelixViewport3D.cs]
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);


if (this.EnableCurrentPosition)
{
var pt = e.GetPosition(this);
var pos = this.FindNearestPoint(pt);
if (pos != null)
{
this.CurrentPosition = pos.Value;
}
else
{
var p = this.Viewport.UnProject(pt);
if (p != null)
{
this.CurrentPosition = p.Value;
}
}
}
}

So, each time OnMouseMove method is called the (Point3D) pos is calculated (by FindNearstPoint) and that may be a costly operation to perform each time the mouse is moved.

Why CurrentPosition is needed and why it is optional?