AB4D Forum
FarPlaneDistance for FirstPersonCamera? - 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: FarPlaneDistance for FirstPersonCamera? (/showthread.php?tid=4142)



FarPlaneDistance for FirstPersonCamera? - WillTheGISGuy - 08-05-2019

I have been trying to use the FarPlaneDistance property for a FirstPersonCamera, but the clipping doesn't occur and the FarPlanceDistance value never holds. I have seen in another thread that I may need to set OptimizeNearAndFarCameraPlanes to false on my scene object  ... but I don't have a scene object.   Is there something I need to disable or do in a specific way to get the FarPlaneDistance to "take"?  I am using a WPFHost inside a Winforms application, if that makes a difference. 

Thanks, Will.


RE: FarPlaneDistance for FirstPersonCamera? - abenedik - 08-06-2019

You are right, the DXEngine automatically calculates the near and far plane distances so that they are as close together as possible. This increases the depth resolution and minimizes the z-fighting artifacts. Anyway, if you want to manually control the near and far plane values, you need to set the OptimizeNearAndFarCameraPlanes  to false (this is a property on th DXScene object).

If you are using DXViewportView, then you can get the DXScene from its DXScene property. The property is set when the DirectX device is initialized - you can subscribe DXSceneDeviceCreated event to be notified when this happens:

Code:
_dxViewportView.DXSceneDeviceCreated += delegate(object sender, EventArgs args)
{
   if (_dxViewportView.DXScene != null) // Can be null in WPF 3D rendering (used as fallback by default)
       _dxViewportView.DXScene.OptimizeNearAndFarCameraPlanes = false;
};