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

Get visible meshes in HelixViewport3D

Anonymous 11 years ago 0
This discussion was imported from CodePlex

chriskro wrote at 2013-11-05 16:34:

Hello,
I wonder if it is possible to get all visible content that is rendered in HelixViewport3D?
Does anybody have experience with that?

Greetings,

Chriskro

objo wrote at 2013-11-11 12:43:

Try the Visual3DHelper.Traverse method
http://www.nudoq.org/#!/Packages/HelixToolkit/HelixToolkit.Wpf/Visual3DHelper/M/Traverse(T)

Select it in the source code and press Shift-F12 and you will find many examples of usage!

chriskro wrote at 2013-11-13 09:01:

Thank you for your answer.
As far as I could see it, it traverses over the model elements, even when they are not visible. But the question is, how do I find out, if a specific element is visible?

objo wrote at 2013-11-19 23:03:

If a model element is visible in the viewport depends on the camera, transforms, lights, material and geometry. If ligths are defined and you don't need to know if the element is within the viewport, you only need to check the material and geometry.
See also https://helixtoolkit.codeplex.com/workitem/10003
0

Load multiple 3ds file in viewport

Anonymous 11 years ago 0
This discussion was imported from CodePlex

sarankani wrote at 2012-12-10 20:01:

Hi Objo,

I am new bee to helix 3D. I need to load many .3ds file in helix viewport. Now i am using the following code

var modelGroup = new Model3DGroup();
            var reader = new StudioReader();
            FileStream c = new FileStream(@"F:\\helixtoolkit3dfiles\" + URL, FileMode.Open, FileAccess.Read, FileShare.Read);           
            reader.TexturePath = ".";
            modelGroup = reader.Read(c);
           this.Model = modelGroup;
            c.Close();

I can only load one file at a time. I need to load many. Thanks in advance for your help. Please let me know your suggestions.

 


objo wrote at 2012-12-13 23:02:

try adding the loaded models to the Children collection

http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.model3dgroup.children.aspx

0

Creating new model after cutting

Anonymous 11 years ago 0
This discussion was imported from CodePlex

MichaelKubrak wrote at 2012-09-27 15:14:

Hello. I need to show the distribution of heat in a solid object. The first thing I came up with that figure expanded to many cubes and noticed paint them depending on the situation. but it's no good for me, because shapes are complex and large.The second thought is that the load already created a model from a file, and then divide it by cutting. But after cutting a cavity appears in the model. Please tell me how to close the cavity?Cutting is done using MeshGeometryHelper.Cut function. Maybe you can get all the vertexes models after cutting, and put them together again to paint this area?


objo wrote at 2012-10-09 22:28:

There is a simple "Ear clipping" triangulation method (see Geometry/CuttingEarsTriangulator) that can be used to close simple convex polygon cutting regions. If your cuts are creating more complex regions you need a more advanced triangulation method (not included in this toolkit). http://en.wikipedia.org/wiki/Polygon_triangulation

0

Printing to scale

Anonymous 11 years ago 0
This discussion was imported from CodePlex

murray_b wrote at 2012-03-27 05:28:

Hi objo

I am trying to print out to scale from the HelixViewport3D. 

I have an example from the book "3D Programming for Windows by Charles Petzold"

In it he utilises the Viewport3DVisual for printing to be able to control the printing better. ( do you have this book I can post the relevant sections if not). Of course HelixViewport extends Viewport3D so I don't have access to this and am not sure how to get it. 

Is this something you think I can use Helix for, and would this be a good approach. Or can you recommend a better way to print to scale.

thanks

Murray


objo wrote at 2012-04-05 01:47:

I have not tried this myself, but I understand you have to create a separate Viewport3DVisual to do this (I see Petzold put it inside a VisualBrush with stretch=None). Have you tried temporarily moving the camera and Visual3D contents from the HelixViewport3D to the Viewport3DVisual when you want to print?


murray_b wrote at 2012-08-31 12:29:

Hi Objo

I have done this and I was thinking it was working fine.

However I have recently found that I can't get text to be printed.

Once I narrow down the issue I will post more. I just wanted to check that you haven't made this work since we had this discussion.

thanks

Murray


murray_b wrote at 2012-09-07 02:28:

For anyone else who has this problem. 

We got it working. Basically had to pause the code before creating the image from thh Veiwport3DVisual

  visual3D.Dispatcher.BeginInvoke(new System.Action(() => { })).Wait();
  BitmapSource bitmapSource = RenderBitmap(visual3D, Width, Height, Brushes.White);

 

It now renders the text correctly

0

Point Cloud to Mesh

Anonymous 11 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 11 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 11 years ago 0
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 11 years ago 0
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 11 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 11 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?