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

Point Cloud to Mesh

Anonymous 12 years ago 0
This discussion was imported from CodePlex

zaurska wrote at 2012-08-15 16:52:

Hi

Is there a good way to take Point data and generate a mesh?

I have 300,000 points and if I just iterate through taking consecutive triangles and ignoring "Big triangles" I get a sort of usuable point cloud in about 2 seconds but I want a surface.

I don't have a regular grid so some of the examples (Surface Plot and Kinect Demo) are nearly what I need but not quite.

I'm at the limit of my math and want to resist getting into delaunay/voronoi if its already a feature here.

H3D is so great!

Z


objo wrote at 2012-08-24 09:47:

Do you need a convex hull? See http://miconvexhull.codeplex.com/


zaurska wrote at 2012-08-28 15:51:

Wow!

Yes that looks like it.  Thanks so much.

So very cool!

0

some bugs found in MeshBuilder

Anonymous 12 years ago 0
This discussion was imported from CodePlex

jpg99 wrote at 2012-08-15 15:17:

hello,

i'm using your toolkit for a project at work . I  have to draw 3d houses from a 2D polygon (plane section of the house), so i experimented with AddExtrudedGeometry, and encountered several difficulties. Eventually i wrote my own function for building the 3d houses, and i don't remember precisely what the problems were (sorry it was a few weeks ago), mostly problems with triangles defined in the wrong sense so that the outside / inside were  inversed.

Here is the code i corrected in MeshBuilder.cs :

    public void AddExtrudedGeometry(IList points, Vector3D xaxis, Point3D p0, Point3D p1)
        {
            var ydirection = Vector3D.CrossProduct(xaxis, p0 - p1);
            ydirection.Normalize();
            xaxis.Normalize();

            int np = 2 * points.Count;
            foreach (var p in points)
            {
                int i0 = this.positions.Count;
                var v = (xaxis * p.X) + (ydirection * p.Y);
                this.positions.Add(p0 + v);
                this.positions.Add(p1 + v);
                v.Normalize();
                if (this.normals != null)
                {
                    this.normals.Add(v);
                    this.normals.Add(v);
                }

                if (this.textureCoordinates != null)
                {
                    this.textureCoordinates.Add(new Point(0, 0));
                    this.textureCoordinates.Add(new Point(1, 0));
                }
               
                int i1 = i0 + 1;
                int i2 = (i0 + 2) % np;
                int i3 = i2 + 1;

                this.triangleIndices.Add(i0);
                this.triangleIndices.Add(i2);
                this.triangleIndices.Add(i1);

                this.triangleIndices.Add(i2);
                this.triangleIndices.Add(i3);
                this.triangleIndices.Add(i1);
            }
        }

    
   public void AddTriangleFan(
            IList fanPositions, IList fanNormals = null, IList fanTextureCoordinates = null)
        {
            if (this.positions == null)
            {
                throw new ArgumentNullException("fanPositions");
            }

            if (fanNormals != null && this.normals == null)
            {
                throw new ArgumentNullException("fanNormals");
            }

            if (fanTextureCoordinates != null && this.textureCoordinates == null)
            {
                throw new ArgumentNullException("fanTextureCoordinates");
            }

            int index0 = this.positions.Count;
            foreach (var p in fanPositions)
            {
                this.positions.Add(p);
            }

            if (this.textureCoordinates != null && fanTextureCoordinates != null)
            {
                foreach (var tc in fanTextureCoordinates)
                {
                    this.textureCoordinates.Add(tc);
                }
            }

            if (this.normals != null && fanNormals != null)
            {
                foreach (var n in fanNormals)
                {
                    this.normals.Add(n);
                }
            }

            int indexEnd = this.positions.Count;
            for (int i = index0; i + 2 < indexEnd; i += 3)
            {
                this.triangleIndices.Add(i);
                this.triangleIndices.Add(i + 1);
                this.triangleIndices.Add(i + 2);
            }
        }


objo wrote at 2012-08-24 09:49:

Thanks for the code! I added http://helixtoolkit.codeplex.com/workitem/9964

0

WeakEventListener not called with .NET 3.5

Anonymous 12 years ago updated by purecokesupply 3 months ago 7
This discussion was imported from CodePlex

jpg99 wrote at 2012-07-09 10:24:

Hello,

I have to use .NET 3.5 for my application.That needed some modifications in the 3d toolkit code : first commenting all the code referring to 'manipulation' (screen touch interface, introduced in .NET 4), and then moving the cameraController.InputBindings initializations in .cs code rather than in xaml, as explained in discussion http://helixtoolkit.codeplex.com/discussions/273572.

After that, most of the mouse and keyboard interface works for pan, zoom and rotate. But rolling the mouse wheel for zoom with inertia didn't work anymore. After some search in your code, i found that the CameraController.renderingEventListener is never called (in .NET 3.5), thus failing to call OnCompositionTargetRendering and finally OnTimeStep, which implements zoom with inertia.

I fixed that problem by replacing the WeakEventLlistener with standard  handlers attached to events : for example in CameraController.cs :

private void SubscribeEvents()
        {
            this.MouseWheel += this.OnMouseWheel;
            this.KeyDown += this.OnKeyDown;
            //RenderingEventManager.AddListener(this.renderingEventListener);
            CompositionTarget.Rendering += new EventHandler(OnCompositionTargetRendering);
        }

        private void UnSubscribeEvents()
        {
            this.MouseWheel -= this.OnMouseWheel;
            this.KeyDown -= this.OnKeyDown;
       //     RenderingEventManager.RemoveListener(this.renderingEventListener);
            CompositionTarget.Rendering -= new EventHandler(OnCompositionTargetRendering);
        }

 

So it works. But using standard event handlers rather than weak events could cause in some cases memory leaks, did i learn by searching a bit about weak events (http://msdn.microsoft.com/en-us/library/aa970850.aspx).

Finally my question is : have you a clue about the reason why the renderingEventListener is not called in .NET 3.5  ?

Thanks for your work.

0

Using DataTemplate

Anonymous 12 years ago updated by asim 4 months ago 1
This discussion was imported from CodePlex

lucasmckenna wrote at 2012-07-03 10:02:

Hi,

I was wondering if there was a workaround to use Helix Visual3D objects in XAML DataTemplates ?

Thanks.

Great Toolkit BTW.


RobPerkins wrote at 2012-07-05 09:24:

If you encased it in a UserControl, would that be a workable approach? 


objo wrote at 2012-07-07 00:57:

I found this blog post
http://pelebyte.net/blog/2009/09/22/more-2d3d-tricks-itemscontrol3d/

It would also be interesting to see an ItemsControl3D derived from a ModelVisual3D that supports data templates. I'm not sure how to implement this, though...

0

How to hide the pole in the Cloth example

Anonymous 12 years ago 0
This discussion was imported from CodePlex

koawangjun wrote at 2012-06-28 08:55:

I am trying to comprehend the Physics involved in Cloth example. After viewing through the code. Unfortunately, could not locate where is the model of pole created. Can anyone enlighten me? because I am trying to display the pure flag instead of flag with pole.


koawangjun wrote at 2012-06-28 09:05:

Oh. I have found the solution, the code for pole is declared in the MainWindow's xaml file.

0

Track camera rotation

Anonymous 12 years ago 0
This discussion was imported from CodePlex

ejleigh wrote at 2012-05-31 16:17:

This is a great project! Many thanks.

I have 3D labels that sit above the scene models. I want the labels to rotate when the camera is rotated so the labels always face the camera. This should occur as the rotation is taking place - not just at the end. Is there an easy way to accomplish this?


objo wrote at 2012-05-31 21:04:

See the "Billboard" and "Overlay" examples in the "Example browser". The billboard text has an issue when spinning the camera (this is not a problem with billboard images) - have not figured that one out yet. The "Overlay" example uses TextBlock elements over the 3D viewport - in some cases this can be the best way to show labels.


ejleigh wrote at 2012-06-12 02:30:

Thanks! This worked well. There is one unexpected behavior that I saw that may be obvious to many but not to a novice like myself. It seems that the backgound material of the billboard cannot be set and it uses the material of most distant object in the Z plane. In many cases, when using this control as a label and not necessarily as a billboard you would want the text to show up with a transparent background. Adding this line to the example xaml after all the TextBillboardVisual3D objects are created will illustrate the problem.  <ht:BoxVisual3D Fill="Chocolate" Center="0,0,0" Length="20" Width="10" Height ="20"/> As you rotate the labels overtop of the box the white background of the view shows through. The only way I found to control this so the labels appear to have a transparent background is to ensure the labels are always added to the end of the visual tree. Perhaps there is a better way?

0

Curved Line

Anonymous 12 years ago 0
This discussion was imported from CodePlex

lmat619 wrote at 2012-06-08 20:55:

Hello. I am wondering if there is anything in the toolkit that gives a curved line. Something kind of like a mix between the PieSliceVisual and the LineVisual? Just wondering if it's out there before I start writing code to make one. Thanks!


objo wrote at 2012-06-09 22:18:

there is a CanonicalSplineHelper class that will interpolate a list of points. You can use this with the LinesVisual3D or TubeVisual3D. (note that the Points collection in LinesVisual3D defines line segments, so you need to modify the result from the CanonicalSplineHelper...)


lmat619 wrote at 2012-06-11 17:53:

Thanks so much! That's exactly what I was looking for. I have one last (stupid) question. The result from CanonicalSplineHelper creates dashed lines. Is there any way I can make it a solid line?

edit:

Nevermind, I figured it out. In the Segment function in CanonicalSplineHelper where the points are added, I changed the way it adds the points to:

if (points.Count == 0)
    points.Add(pt);
else
{
    points.Add(pt);
    points.Add(points.ElementAt(points.Count - 1));
}

This way, a line is made from each point to its preceding point.

0

Helix and Avalondock

Anonymous 12 years ago 0
This discussion was imported from CodePlex

dfridline wrote at 2012-06-11 15:39:

Hello,

I am new to using the Helix Toolkit and have scoured the forum discussions to see if this has been raised before and couldn't find anything on it.   My question is whether or not it is possible to use the Helix Toolkit in combination with Avalondock.  I'm putting together an application that will have a similar look to Visual Studio with an Explorer Tree and Properties Editor docked on one side and would like a Viewport where the Code Editor is in VS.

Any thoughts or examples would be greatly appreciated.

Thanks,

Dan


objo wrote at 2012-06-11 15:51:

The OxyPlot.WPF.Plot control is a standard WPF custom control, and should work with AvalonDock. I have done some testing with AvalonDock 1.3, but not 2.0 yet.

If there are problems with the OxyPlot control, please report it in the issue tracker.


dfridline wrote at 2012-06-11 16:02:

objo wrote:

The OxyPlot.WPF.Plot control is a standard WPF custom control, and should work with AvalonDock. I have done some testing with AvalonDock 1.3, but not 2.0 yet.

If there are problems with the OxyPlot control, please report it in the issue tracker.

Objo,

Thanks for the suggestion.  I didn't know about the OxyPlot project and it may come in handy for some other things I am doing.  However and I am sorry if I wasn't clear in my original post but OxyPlot is not what I am looking for in this project.  It appears to be a 2D plotting component and I am looking at the Helix Toolkit so I can display and manipulate 3D models in a Viewport contained within an application that uses Avalondock.

If anyone has tried this before, I would appreciate any advice.

Thanks,

Dan


objo wrote at 2012-06-11 17:07:

sorry, I didn't notice I mixed up my projects... :)

The same answer is valid here:

The HelixToolkit.Wpf.HelixViewport3D control is a standard WPF custom control, and should work with AvalonDock. I have done some testing with AvalonDock 1.3, but not 2.0 yet.

If there are problems with the HelixViewport3D control, please report it in the issue tracker.

0

Transparent GeometryModel3D

Anonymous 12 years ago updated by asim 4 months ago 1
This discussion was imported from CodePlex

finder_sl wrote at 2012-06-12 10:53:

Hello.

In Polyhedron example, I want to get transparent triangles.

I tried this (PanelModelBuilder class): 

// Line 59 in PanelModelBuilder.cs
var panelsGeometry = tm.ToMesh();
            Brush br = new SolidColorBrush(Colors.Red);
            br.Opacity = 0.5;
            m.Children.Add(new GeometryModel3D(panelsGeometry, new DiffuseMaterial(br)) { BackMaterial= new DiffuseMaterial(br) });

But it does not work, the faces are opaque.

How can I do that?


objo wrote at 2012-06-15 06:22:

I don't think it will work to set both Material and BackMaterial in the same model when you want transparency. The transparent triangles nearest the camera should be rendered last, and this doesn't happen automatically.

For simple geometries (e.g. sphere, cuboid) you could try to add two models using the same geometry, the first one with the BackMaterial set, the second one with the Material set. This ensures that triangles inside the shape (furthest away from camera) are rendered before outside triangles (near the camera).

For other geometries (e.g. doughnut) I don't know a good solution to render transparency in wpf 3d...

0

Nuget Package

Anonymous 12 years ago 0
This discussion was imported from CodePlex

murray_b wrote at 2012-03-30 08:24:

Hi Objo

I am using the helix NuGet package to keep up to date with the changes to your library.

Can I just make a request that you remove the HelixWindow.xaml from the next package release please. 

As it is a bit annoying having to remove it from our projects everytime we update the package.

thanks for the great library

regards

Murray


objo wrote at 2012-04-03 01:17:

I agree on that. Removed the content from the nuget package!