TriangleIndices & Vertex Positions to LinesVisual3D

Anonymous 10 years ago 0
This discussion was imported from CodePlex

alexalthauser wrote at 2012-04-13 03:09:

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;


alexalthauser wrote at 2012-04-13 04:20:

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.

objo wrote at 2012-04-14 00:11:

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.

alexalthauser wrote at 2012-04-14 00:37:

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

alexalthauser wrote at 2012-04-14 02:20:

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.