Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Highlight tringle in mesh
#1
Lightbulb 
Hello

I am in the need of highlighting the face of a mesh under the pointer

Is this even possible?

Thanks
#2
You can do that with the following:
- do a mouse hit test by calling SceneView.GetClosestHitObject method (pass mouse x and y coordinate to the method)
- if a 3D object is hit, you get a RayHitTestResult object. It has TriangleIndex property - the index of the hit triangle.
- use a new MultiMaterialModelNode (introduced in v2.0) to show a single mesh (you can get the mesh from the hit ModelNode by calling GetMesh method) with multiple materials. The materials are defined by SubMeshes - each submesh specifies the material, StartIndexLocation and IndexCount (to get the StartIndexLocation from the TriangleIndex, multiply TriangleIndex by 3; set IndexCount to 3 to show a single triangle). For example if hit TriangleIndex is 10, then set the frist SubMesh to StartIndexLocation = 0, IndexCount = 3 * 10, the second SubMesh to StartIndexLocation = 3 * 10, IndexCount = 3 and the third SubMesh to StartIndexLocation = 3 * 11, IndexCount = (total triangle indices count - 3 * 11)

See the "Advanced 3D objects / MultiMaterialModelNode" sample for more info.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)