Hi everyone,
I'm trying to sort out some basic system which allows my camera to follow the height of a mesh (the mesh pointer itself is a public member of a class, of which meshTorus is an instance) a bit like terrain, using the D3DXIntersect() function. I'm defining a ray to start at the location of my camera (held in &campos) and point directly downwards (effectively allowing me to detect my vertical height above the chosen mesh). This is sent to a float called terrainHeight:
D3DXIntersect(meshTorus.meshPointer, &campos, &D3DXVECTOR3(0, -1, 0), NULL, NULL, NULL, NULL, &terrainHeight, NULL, NULL);
The only problem is that when I use it, the function doesn't succeed (when I run a check, it doesn't return D3D_OK). I can't think why this is - the mesh certainly exists because I render just before the function is called, and it's there.
I suspect that this is something pretty simple that I just don't know about! I should also say that I am running D3DXIntersect() in the render loop, just after rendering the mesh to be tested.
Thanks!