Operations on models
We want to perform the same operations on models that we performed on Meshes. The only difference is that models should account for the world space of the model. The best way to achieve this is to transform the primitive being tested by the inverse world matrix of the model. When we transform anything by the inverse world space of the model, we move that thing into the local space of the model. The untransformed mesh happens to be in the local space of the model.
Getting ready
We are going to implement seven functions to test a model for intersection against rays, lines, spheres, AABBs, OBBs, planes, and triangles. Each of the intersection functions will transform the primitive by the inverse world matrix of the model, and then the transformed primitive is tested against the mesh contained inside the model.
How to do it…
Follow these steps to implement intersection tests against the new Model
class:
- Declare the seven intersection tests against a
Model
inGeometry3D...