AB4D Forum
TargetPositionCamera.GetRayFromCamera() sometimes returns Direction = NaN - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.DXEngine (https://forum.ab4d.com/forumdisplay.php?fid=11)
+--- Thread: TargetPositionCamera.GetRayFromCamera() sometimes returns Direction = NaN (/showthread.php?tid=4292)



TargetPositionCamera.GetRayFromCamera() sometimes returns Direction = NaN - siik - 10-08-2021

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


RE: TargetPositionCamera.GetRayFromCamera() sometimes returns Direction = NaN - siik - 10-09-2021

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.


RE: TargetPositionCamera.GetRayFromCamera() sometimes returns Direction = NaN - abenedik - 10-19-2021

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.


RE: TargetPositionCamera.GetRayFromCamera() sometimes returns Direction = NaN - siik - 10-19-2021

(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