Hi everyone, I loaded a low-polygon STL model into my viewport. Now I want to highlight any facet of the model whenever my mouse cursor hovers on the surface → After that, I want to get that facet's information such as: normal vector, center's position... I don't know what to do now. Here is part of my code so far:
private void viewPort3D_MouseMove(object sender, MouseEventArgs e)
{
findFacet();
}
void findFacet()
{
Vector3D vector3D;
var mousePosition = Mouse.GetPosition(viewPort3D);
var source = FindSource(mousePosition, out vector3D); // Return Model3D
}
Model3D FindSource(Point point, out Vector3D normalVector)
{
var hits = Viewport3DHelper.FindHits(viewPort3D.Viewport, point);
foreach (var hit in hits)
{
if (hit.Model == our_model3D)
continue;
normalVector = hit.Normal;
Console.WriteLine("normalVector: " + normalVector.ToString());
return hit.Model;
}
normalVector = new Vector3D();
return null;
}
Thank you!
@atlesg You need a separate model to render your highlighted triangles. Just create a different mesh model and create your geometry you want to highlight on the fly.
I see, but how can I get the clicked triangle? The only info I can get now is position of Rayhit, normals, and triangle indices. I mean I need to return 3 points of the facet when event MouseDown happens, how can I seize that info? Thank you
you can get your triangle from the triangle indices, right?
At the moment I don't know how to do that :( I have list of vertexes like: 0.151,0.8965,0.861 and indices like: 1 2 3 4 5... 768, but how can I get the triangle? Is there any method to do that or I must write the algorithm myself?
p1 = Positions[index1]; p2 = Positions[index2]; p3 = Positions[index3]
.
Positions
and create a Indices = new Int32Collection(){index1, index2, index3};
@artipo
Hi, I was trying to add a custom ViewCube to my viewport, without sucess.
Following CustomViewCuboDemo I've added a 'ScreenSpacedGroup3D' to my 'Viewport3DX' (The project uses 'HelixToolkit.SharpDX.Core.Wpf').
If I set ScreenSpacedGroup3D's content as in the demo, everything works.
In my attemps I tried to set ScreenSpacedGroup3D's content via nodes systems as in image above.
ViewCubeNode is structured like this:
'GroupNode' containing 3 'LineNode', one for each axis.
Sadly the ViewCube don't appear where it should, but instead in the main scene, with all the other nodes.
Any ideas?
Currently the ScreenSpacedGroup3D only supports one layer of children. I will need to figure out a way to support multiple layers.
@Gravemind2401 You need to tune the depth bias to avoid z fighting.
Hello, I'm using the component process of Gis to load Google maps section of ellipsoid, the different layers of the biopsy, after treatment, the depth of the calculated error problem may cause the depth buffer, through access to information, I found that you can use the logarithmic depth buffer, to adjust the depth to solve this problem, but I did not found in the components of the depth of description, the position of the sources are vec4, but the position of the component is vec3, so what is the component of the depth of the attribute name?
Where is the depth of the model stored?