I assume the progress at 60%, so far ray-triangle intersection works very good, you can check the following files
- Axiom's stuff, to be patched later
The reason I'm posting is that consideration should be made whether and how to integrate the intersector with a common SceneQuery
. What do you think? I believe that's a good idea. More to it below.
- compiles against SVN Crickhollow branch
- see demo source for list of keyboard commands
- mouse: starts off in window center regardless of system mouse position (also doesn't precisely follow it at least not with DX input), no 2D cursor visualisation ATM
- TODO's, commented areas of code, to be polished
- uses custom Transform class to do transformations, because there were some issues with Matrix4. I hope to find out what was wrong and use Matrix4 again.
- TriangleListBuilder now builds a List<List<TriangleVertices>> (instead List<TriangleVertices>) to get a separate set of triangles per index set. This allows a one to one mapping between triangle sets and submeshes so index of submesh can be reported.
But I believe that submesh index should be handled elsewhere letting the intersector handle one triangle soup only, possibly making a TriangleIntersector per SubEntity and determine the index while iterating Entities and SubEntities in a scene query.
So first thoughts to integrating the intersector with SceneQuery
1. method RayTriMeshSceneQuery SceneManager.CreateRayTriMeshSceneQuery();
2. class DefaultRayTriMeshSceneQuery : SceneQuery
3. WorldFragmentType - add type TriMeshIntersection
4. WorldFragment - add field for TriMeshIntersection and report intersection details there (currently struct IntersectResultTriMesh in TriangleBuilder.cs)
5. Utility.Intersects() I'd try to provide general Ray-Tri tests (details will show up yet)
RayTriMeshSceneQuery would work similarly to RaySceneQuery. It will return Entities in the RaySceneQueryResultEntry.SceneObject and closest triangle intersection per entity in RaySceneQueryResultEntry.worldFragment. Other than Entity will not primarily be supported, same as RaySceneQuery. The container for each TriangleIntersector would be SubEntity since it provides a render operation, SubMesh could do too, but with SubEntity it should be better accessible from user code. As the TriangleIntersector needs to be created for object prior to op. the query could check that and create it if necessary.
So much for the generic SceneManager. For other scene managers things should be quite easy too.
What do you think?