TriangleIndices & Vertex Positions to LinesVisual3D

Apr 13, 2012 at 2:09 AM
Edited Apr 13, 2012 at 2:16 AM

Hey Guys,

I import a model using the Helix3d toolkit. Next, I perform a hit-test on the 3Dmodel. ThenI get the MeshGeometry3D information from rayMeshResult.Meshit. Finally I get the vertex position information, and triangleIndices from the MeshGeometry3D. Now I clone the points from LinesVisual3D, and then I feed the triangleIndices/vertex info into the clone. Finally, I copy the clone's point data into LinesVisual3D.Points, and add the lines to my viewport.

As you can see from the picture at the link, not all of the edges of the cube are drawn, yet all of the points are there.

GeometryModel3D hitgeo = rayMeshResult.ModelHit as GeometryModel3D;
                MeshGeometry3D newGeom = rayMeshResult.MeshHit as MeshGeometry3D;
                Point3DCollection srtpnt = modelLines.Points.Clone();

                for (int i = 0; i < newGeom.TriangleIndices.Count; i ++)
                    textBlock4.Text += newGeom.Positions[newGeom.TriangleIndices[i]].ToString() + "\n";

                modelLines.Points = srtpnt;
                modelPoints.Points = srtpnt;

                modelPoints.Color = Colors.Red;
                modelPoints.Size = 15;

                modelLines.Thickness = 6;
                modelLines.Color = Colors.Blue;


Apr 13, 2012 at 3:20 AM

I'm going to go out on a limb here and guess that the problem is that I'm calling the geometry information from the Meshhit, instead of from the imported model.

Apr 13, 2012 at 11:11 PM

I think the problem is that you are using the same points for the modelPoints and the modelLines.

The Points collection in the LinesVisual3D defines line segments.

It treats each pair of points as an independent line segment. Vertices 2 n - 1 and 2 n define line N / 2 lines are drawn.

Apr 13, 2012 at 11:37 PM

I understand what you are saying, but whether I use the points for modelPoints, or not, the modelLines, do not fully cover the cube.

Apr 14, 2012 at 1:20 AM

Ah, nevermind. I understand, it's my bad. Of course a model won't contain information for drawing lines from each vertex, I will have to code a method myself.