Click or drag to resize
AB4D logo

StereoscopicVirtualRealityProvider Class

StereoscopicVirtualRealityProvider is an abstract class and provides common logic to render stereoscopic images.
Inheritance Hierarchy
SystemObject
  Ab3d.DirectXDXResourceBase
    Ab3d.DirectXDisposableDXResource
      Ab3d.DirectXDXSceneResource
        Ab3d.DirectXVirtualRealityProviderBase
          Ab3d.DirectXStereoscopicVirtualRealityProvider
            Ab3d.DirectXAnaglyphVirtualRealityProvider
            Ab3d.DirectXSplitScreenVirtualRealityProvider

Namespace: Ab3d.DirectX
Assembly: Ab3d.DXEngine (in Ab3d.DXEngine.dll) Version: 7.0.8865.1045
Syntax
C#
public abstract class StereoscopicVirtualRealityProvider : VirtualRealityProviderBase

The StereoscopicVirtualRealityProvider type exposes the following members.

Constructors
 NameDescription
Public methodStereoscopicVirtualRealityProvider Constructor
Top
Properties
 NameDescription
Public propertyEyeSeparation Gets or sets a distance between left and right eye. The distance is specified in the same coordinate system as the camera. When rendering, the camera is first shifter to the left for the half of the EyeSeparation distance. Then the whole scene is rendered. The the camera is shifter to the right for half of the EyeSeparation distance. The best value for EyeSeparation is based on the size of objects in the scene, the size of the Viewport3D, monitor DPI settings and the actual distance between eyes of the user.
Public propertyInvertLeftRightView Gets or sets a Boolean that specifies if positions of the eyes are inverted.
Public propertyParallax Parallax defines a value in degrees that specifies an angle of the left and right eye look direction. If the parallax is zero, then the look directions of left and right cameras are parallel. If parallax is bigger then zero, then the left and right look directions are pointed to each other and they cross at some position in front of the camera (the bigger the angle the closer the crossing point). Usually the best 3D effect is producted when the parallax is set so that the look directions cross at the center of the scene - look directions of human eyes cross at the point of focus.
Top
Methods
 NameDescription
Public methodCreateVirtualRealityContext CreateVirtualRealityContext method takes current RenderingContext as parameter and should create the VirtualRealityContext or a class derived from it. The returned VirtualRealityContext defines the context in which this virtual reality provider runs.
(Overrides VirtualRealityProviderBaseCreateVirtualRealityContext(RenderingContext))
Public methodUpdateRenderingContext UpdateRenderingContext is called from the BeginVirtualRealityRenderingStep and should update the properties in the RenderingContext according to the current eye. See remarks for more info about the usual tasks that are preformed in this method.
(Overrides VirtualRealityProviderBaseUpdateRenderingContext(RenderingContext, Boolean))
Top
Remarks

StereoscopicVirtualRealityProvider is an abstract class and provides common logic to render stereoscopic images.

The class provides basic properties to define the stereoscopic camera: EyeSeparation, Parallax and InvertLeftRightView.

The class also provides basic implementation of InitializeRenderingSteps(DXScene) method. The method creates the protected beginVirtualRealityRenderingStep (of type BeginVirtualRealityRenderingStep) and protected renderingStepsLoop (of type RenderingStepsLoop) and also adds them to the RenderingSteps in the DXScene.

The position of the beginVirtualRealityRenderingStep is defined with the prepareRenderTargetsForEachEye parameter that is specified in the constructor. If prepareRenderTargetsForEachEye is true, then the RenderTarget is cleared before each eye is rendered. This is achieved with inserting the BeginVirtualRealityRenderingStep before the DefaultPrepareRenderTargetsRenderingStep (used for Anaglyph rendering). If prepareRenderTargetsForEachEye is false, then the RenderTarget is cleared only once per frame. In this case the BeginVirtualRealityRenderingStep is added after the DefaultPrepareRenderTargetsRenderingStep (used for Split screen stereoscopic rendering) .

The CreateVirtualRealityContext(RenderingContext) method creates a default VirtualRealityContext - calls its constructor with current RenderingContext. It is possible to override this method to create an instance of your own class derived from VirtualRealityContext.

The UpdateRenderingContext(RenderingContext, Boolean) method does:
- sets the virtualRealityContext.CurrentEye based on the isNewFrame parameter: isNewFrame == true => LeftEye else RightEye
- ensures that stereoscopicCamera is created and sets its properties for the current eye and based on the current EyeSeparation, Parallax and InvertLeftRightView
- sets renderingContext.UsedCamera = stereoscopicCamera

See Also