TargetPositionCamera.GetRayFromCamera() sometimes returns Direction = NaN
#1
I'm having some unpredictable results when performing hit testing on my meshes. It works sometimes but not others.

I can see when DXScene.GetClosestHitObject(pickRay) returns null, it is always when DXScene.GetRayFromCamera() method returns a Direction = Nan (the Position is populated though)

What circumstances can this happen? Most of the time, I need to rotate the camera a bit and then it starts working again.

I wonder if I'm doing something incorrect with regards to scene refreshing.

Note: I am using a similar method to winforms DXRenderControl sample in preparing my control/3D scene if that makes any difference.
Curiosuly, TargetPositionCamera.FitIntoView() also doesnt work (it doesn't set the distance). (related?)

TIA
Simon
#2
I think I know the reason why, my near/far distances were too wide. I've reduced my far plane distance and so far so good.
#3
May I ask you what were the values of NearPlane and FarPlane that you used?

By default DXEngine automatically calculates the NearPlane and FarPlane values from the size of the 3D scene so that they are optimally set (making them as close as possible to increase depth resolution). This is controlled by DXScene.OptimizeNearAndFarCameraPlanes property. So usually it is best to leave that property on true value.
Andrej Benedik
#4
(10-19-2021, 10:13 AM)abenedik Wrote: May I ask you what were the values of NearPlane and FarPlane that you used?

By default DXEngine automatically calculates the NearPlane and FarPlane values from the size of the 3D scene so that they are optimally set (making them as close as possible to increase depth resolution). This is controlled by DXScene.OptimizeNearAndFarCameraPlanes property. So usually it is best to leave that property on true value.

Hi abenedik,

I was using arbitrary values: 0.1 and 1000000. I reduced these down to 0.1 and 10000 and I'm getting much better results.

Thanks
  


Forum Jump:


Users browsing this thread:
1 Guest(s)