Click or drag to resize
AB4D logo

DXScene Class

DXScene is the main object in the DXEngine rendering engine. It defines the 3D scene in a hierarchical tree hat starts with the RootNode. It updates the SceneNodes and renders them.
Inheritance Hierarchy
SystemObject
  Ab3d.DirectXDXResourceBase
    Ab3d.DirectXDisposableDXResource
      Ab3d.DirectXDXScene

Namespace: Ab3d.DirectX
Assembly: Ab3d.DXEngine (in Ab3d.DXEngine.dll) Version: 6.1.8746.1045
Syntax
C#
public class DXScene : DisposableDXResource

The DXScene type exposes the following members.

Constructors
 NameDescription
Public methodDXScene(DXDevice, String) Constructor
Public methodDXScene(DXScene, Boolean, String) Creates a child DXScene that will render the objects defined in the masterDXScene to the back buffer and with camera defined in this DXScene.
Top
Properties
 NameDescription
Public propertyBackBuffer Gets the BackBuffer as Texture2D
Public propertyBackBufferDescription Gets the Description of the BackBuffer
Public propertyBackBufferRenderTargetView Gets the RenderTargetView of the BackBuffer
Public propertyBackBufferShaderResourceView ShaderResourceView that is created from BackBuffer. Created when DXScene is initialized with CreateBackBufferShaderResourceView property set to true and when swap chain is not used. The created ShaderResourceView can be used in another DXScene so that the renderer 3D scene can be used as a texture. This works only when both DXScenes are created by the same DXDevice.
Public propertyBackgroundColor Gets or sets a Color4 that represents a background color for the scene. The color values must be alpha premultiplied - each red, green and blue value must be multiplied with alpha value (for example a fully transparent value is (0, 0, 0, 0) and not (0, 255, 255, 255) as in WPF.
Public propertyBackgroundRenderingQueue Gets a RenderingQueue that is rendered first. Objects in this queue are not sorted and are rendered in the same order as they are added to the queue.
Public propertyBackgroundThreadsManager Gets or sets a BackgroundThreadsManager that is used instead of BackgroundThreadsManager defined in DXDevice.
Public propertyBackgroundWaitingUntilRenderedThresholdTimeMs Time in milliseconds that is used to enable background waiting until rendered. When DXViewportView.IsWaitingInBackgroundUntilRendered is true and after waiting for rendered in the last two frames is bigger then this time, then waiting is actually enabled (this prevents using background thread for simple scenes). Default value is 3 milliseconds.
Public propertyBuffersInitialized Gets a Boolean that specifis if SwapChain and buffers are created. This property can be false when DXScene is initialized with zero width and height.
Public propertyCamera Gets or sets an ICamera that is used to show the scene.
Public propertyComplexGeometryRenderingQueue Gets a RenderingQueue that contains opaque and very complex 3D objects that are expected to take a lot of GPU time to render and should therefore start rendering as soon as possible. Usually this queue contains instanced objects, big point cloud objects or standard objects with many triangles. Objects in this queue are not sorted and are rendered in the main thread (no multi-threading rendering) and in the same order as they are added to the queue.
Public propertyCreateBackBufferShaderResourceView When true and when swap chain is not used, then a BackBufferShaderResourceView is created from BackBuffer. Default value is false.
Public propertyDefaultCompleteRenderingStep Gets a default CompleteRenderingStep.
Public propertyDefaultInitializeRenderingStep Gets a default InitializeRenderingStep.
Public propertyDefaultPreparePostProcessingRenderingStep Gets a default PreparePostProcessingRenderingStep. This rendering step is defined in the DefaultRenderPostProcessingRenderingStepsGroup.
Public propertyDefaultPrepareRenderTargetsRenderingStep Gets a default PrepareRenderTargetsRenderingStep.
Public propertyDefaultRenderObjectsRenderingStep Gets a default RenderObjectsRenderingStep.
Public propertyDefaultRenderPostProcessingRenderingStep Gets a default RenderPostProcessingRenderingStep. This rendering step is defined in the DefaultRenderPostProcessingRenderingStepsGroup.
Public propertyDefaultRenderPostProcessingRenderingStepsGroup Gets a default RenderingStepsGroup that groups PreparePostProcessing and RenderPostProcessing rendering steps.
Public propertyDefaultRenderSpritesRenderingStep Gets a default RenderSpritesRenderingStep. This step is added to the RenderingSteps before the DefaultCompleteRenderingStep after the first SpriteBatch is created. The step is removed when the last SpriteBatch is removed from DXScene.
Public propertyDefaultResolveBackBufferRenderingStep Gets a default ResolveBackBufferRenderingStep.
Public propertyDepthStencilBufferFormat Gets or sets a depth stencil buffer format that is used in rendering the scene. Default value is D32_Float (32 bit depth buffer, no stencil buffer). If this value is changed, a new depth stencil buffer will be created in the next call to PrepareRenderTargetsRenderingStep.
Public propertyDepthStencilView Gets the DepthStencilView
Public propertyDevice Gets a DirectX device that is used by this DXScene.
Public propertyDpiScaleX Gets or sets a float that represents a DPI scale factor in X direction: 1 means 96 DPI, 1.5 means 144 DPI, etc. This value is used in line and pixel rendering and scales the line thickness or size of pixels.
Public propertyDpiScaleY Gets or sets a float that represents a DPI scale factor in Y direction: 1 means 96 DPI, 1.5 means 144 DPI, etc. This value is used in line and pixel rendering and scales the line thickness or size of pixels.
Public propertyDXDevice Gets a DXDevice that was used to initialize this DXScene.
Public propertyDXHitTestOptions DXHitTestOptions specifies hit testing parameters that are used with DXScene's hit testing.
Public propertyExecutePixelShaderPerSampleObsolete.
ExecutePixelShaderPerSample is obsolete. Use SupersamplingCount instead.
Public propertyForegroundRenderingQueue Gets a RenderingQueue that is rendered after standard GeometryRenderingQueue but before TransparentRenderingQueue. Objects in this queue are not sorted and are rendered in the same order as they are added to the queue.
Public propertyFrameNumber Gets an integer that represents the last rendered frame number (increased after each rendered frame)
Public propertyGeometryRenderingQueueObsolete.
OBSOLETE: GeometryRenderingQueue is obsolete because it was slit into ComplexGeometryRenderingQueue, LineGeometryRenderingQueue, OtherGeometryRenderingQueue and StandardGeometryRenderingQueue. Please add your objects to any of those RenderingQueues. For Backwards compatibility the GeometryRenderingQueue is assigned to the OtherGeometryRenderingQueue.
Public propertyHardwareAccelerate3DLineCaps Gets or sets a Boolean that specifies if line caps (arrow, box, diamond, etc.) are hardware accelerated and generated on the graphics card. Default value is true. When false, then lines with caps will be generated on the CPU by Ab3d.PowerToys library.
Public propertyHardwareAccelerate3DLines Gets or sets a boolean that specifies if rendering 3D lines is hardware accelerated by DXEngine.
Public propertyHeight Gets an integer that represents a height of the Viewport
Public propertyIsAutomaticallyUpdatingBeforeEachRender Gets or sets a Boolean that specifies if Update method is automatically called before each rendering of the scene (if it was not yet manually called). Default value is true.
Public propertyIsCachingCommandLists Gets or sets a Boolean that specifies if Ab3d.DXEngine records all DirectX commands into DirectX CommandLists and reuses the command lists on next frame if only camera and light properties have changed. See remarks for more info. Default value is false.
Public propertyIsCurrentlyWaitingUntilRendered Gets a Boolean that specifies if the background thread is currently waiting to complete rendering (this can be used for DirectXImage PresentationType where the DXEngine needs to notify WPF when the 3D scene is rendered; this is enabled by default - the DXViewportView.IsWaitingInBackgroundUntilRendered is set to true). When this property is true, then a new render pass should not begin (by default the InitializeRenderingStep is waiting on the main thread until the rendering is completed).
Public propertyIsEnabled Gets or sets if this DXScene is enabled and is rendering the scene.
Public propertyIsInitialized Gets a Boolean that is set to true when this DXScene is initialized - DXDevice are created and also required objects and collections are created: RenderingContext, RenderingQueues, PostProcessing. Also the SwapChain is created when the DXScene in initialized with InitializeSwapChain method (though the size of SwapChain buffers might not be final yet). Note that when IsInitialized is set to true, the DirectX buffers are initialized only when the size of viewport is already known. To see if buffers are initialized check the BuffersInitialized property.
Public propertyIsMaterialSortingEnabled Gets or sets a Boolean that specified if sorting objects by their materials is enabled. Sorting objects usually improves rendering performance because objects with same materials are rendered one after another and this reduces the required DirectX state changes. Objects are sorted by their material hash value only when they are in the MaterialSortedRenderingQueue (usually all standard and opaque geometry objects). But sometimes user wants to have full control of the order in which the objects are sorted. In this case it is possible to disable material sorting. Default value is true.
Public propertyIsRendering Returns true when DXScene is currently executing object rendering (is inside RenderScene method). This property can be checked from a background thread.
Public propertyIsSwapChainCreated Gets a Boolean that specifis if DXScene will be using SwapChain to render the scene and if SwapChain is already created.
Public propertyIsTransparencySortingEnabled Gets or sets a Boolean that specifies if sorting transparent objects by their distance to the camera is enabled. Default value is false. See remarks for more info.
Public propertyIsWaitingUntilRenderedEnabled Gets a Boolean that specifies if the background waiting until rendered is enabled (when using DirectXImage presentation type, when DXViewportView.IsWaitingInBackgroundUntilRendered is true and when two consecutive frames took longer then BackgroundWaitingUntilRenderedThresholdTimeMs).
Public propertyLights Gets a list of lights that are used in this DXScene.
Public propertyLineGeometryRenderingQueue Gets a RenderingQueue that contains opaque and single-colored 3D line objects that are rendered with ThickLineEffect. Objects in this queue are not sorted but are rendered with using multi-threading.
Public propertyMasterDXScene Gets a DXScene that is set when this DXScene is rendered a 3D scene that is defined in a MasterDXScene.
Public propertyMaxBackgroundThreadsCount Gets or sets an integer that specifies the maximum number of background threads that can be used for multi-threaded operations. Value 0 means that no background thread will be used and that all rendering will be performed on the main thread. Value 4 means that besides the main thread up to four additional background threads can be used for rendering. The actually used number of threads can be lower if there is not a lot of objects to render. Default value is set to Environment.ProcessorCount minus 1 but 7 is the maximum value. See remarks for more info.
Public propertyMaxFarPlaneDistance When MaxFarPlaneDistance is set to any positive value and OptimizeNearAndFarCameraPlanes is true, the calculated far plane distance is never bigger then the specified value. This value must be bigger then MinNearPlaneDistance or its value is not used. Default value is NaN.
Public propertyMinNearPlaneDistance When MinNearPlaneDistance is set to any positive value and OptimizeNearAndFarCameraPlanes is true, the calculated near plane distance is never smaller then the specified value. Default value is NaN.
Public propertyMSAABackBuffer Gets the MSAA BackBuffer as Texture2D (set if multisampling is used)
Public propertyMSAABackBufferDescription Gets the Description of the MSAABackBuffer
Public propertyMSAABackBufferRenderTargetView Get the RenderTargetView of the MSAA BackBuffer
Public propertyMultisampleCount Gets an integer that represents a used multisample count (used for anti-aliasing)
Public propertyOptimizeNearAndFarCameraPlanes Gets or sets a boolean that specify if NearPlaneDistance and FarPlaneDistance are automatically set by scene bounds (true by default). This can prevent z-fighting problems. If you want that that NearPlaneDistance and FarPlaneDistance are set manually, this property must be set to false.
Public propertyOtherGeometryRenderingQueue Gets a RenderingQueue that contains opaque objects that cannot be rendered with StandardEffect. Usually this queue contains pixels, objects with physically based rendering material and other objects with non-standard effect (for example vertex colored materials). The objects in this queue are not rendered with using multi-threading. Objects in this queue are sorted so that they are grouped by material to minimize state changes.
Public propertyOverlayRenderingQueue Gets a RenderingQueue that is rendered last. Objects in this queue are not sorted and are rendered in the same order as they are added to the queue.
Public propertyPostProcesses Gets a collection of post processes that will be applied after rendering the 3D scene.
Public propertyRenderAntialiased3DLines When false and UseGeometryShaderFor3DLines is also false, the 3D lines are rendered without antialiasing them. This greatly improves rendering performance. Default value is true.
Public propertyRenderConnectedLinesAsDisconnected Gets or sets a boolean that specifies if all connected 3D lines (polylines, line arc, rectangle, etc.) are rendered as disconnected 3D lines (separate lines). Default value is false.
Public propertyRenderConnectedLinesAsDisconnectedLinesThicknessLimitObsolete.
Gets or sets the LineThickness value that will limit rendering connected 3D lines (polylines, line arc, rectangle, etc.), as disconnected 3D lines (fully hardware accelerated). The connected 3D lines that have lower or equal LineThickness then the value of this property will be rendered as disconnected 3D line; other connected lines will still be generated on the CPU by Ab3d.PowerToys library. Default value is 3.
Public propertyRenderingContext Gets the RenderingContext that defines the context information that are used during scene rendering.
Public propertyRenderingQueues RenderingQueues is a read only collection of rendering queues that represent queues of low lever objects that are prepared to be rendered with DirectX. RenderingQueue are rendered in the same order as in the RenderingQueues list. The rendering is done in the RenderObjectsRenderingStep rendering step.
Public propertyRenderingSteps Gets a RenderingStepsList that represents the rendering steps that are executed to render the 3D scene.
Public propertyRenderMultiPolyLinesWithOneDrawCall When true (by default) then multiple poly-lines can be rendered with one draw call (one ScreenSpaceLineNode is created). When false, then for each poly-line one ScreenSpaceLineNode is create and this renders each line with its own draw call.
Public propertyRootNode Gets or sets a root SceneNode - the first in the hierarchy.
Public propertyShaderQuality Gets or sets a quality settings that specifies the type of shader that should be used to render the scene. If DXScene is used with DXViewportView, then this value is set from used GraphicsProfile. NOTE: Changing this property after the DXDevice is initialized will have no effect.
Public propertyShadowRenderingProvider Gets a ShadowRenderingProvider that is currently used by this DXScene to render shadows. This property can be set by calling InitializeShadowRendering(ShadowRenderingProviderBase) method.
Public propertySSAABackBuffer Gets the super-sampled BackBuffer as Texture2D (set if super-sampling is used)
Public propertySSAABackBufferDescription Gets the Description of the super-sampled BackBuffer
Public propertySSAABackBufferRenderTargetView Get the RenderTargetView of the super-sampled BackBuffer
Public propertySSAABackBufferShaderResourceView Get the ShaderResourceView of the super-sampled BackBuffer
Public propertyStagingBackBuffer Gets the StagingBackBuffer that is used when the final rendered image needs to be copied to main memory. This can be done only from staging buffer. When final render image in not copied to main memory the StagingBackBuffer is null.
Public propertyStagingBackBufferDescription Gets the Description of the StagingBackBuffer
Public propertyStandardGeometryRenderingQueue Gets a RenderingQueue that contains standard opaque objects that can be rendered with StandardEffect (all objects with StandardMaterial or objects that are created from WPF 3D objects). Objects in this queue are sorted so that they are grouped by material to minimize state changes and are also rendered with using multi-threading.
Public propertyStatistics Gets RenderingStatistics class that contains various rendering statistics. Statistics is collected only when IsCollectingStatistics is set to true.
Public propertySupersamplingCount Gets the super-sampling count that describes how much more pixels are rendered for each final pixel. The rendering is done on a scaled texture that is bigger for the amount specified by SupersamplingCount. At the end of rendering this texture is down-sampled into the texture with the final size. Valid values are 1 (no super-sampling), 4, 16 and 64. Value 4 means that width and height are multiplied by 2 and this produces a texture with 4 times as much pixels.
Public propertySupersamplingFactor Gets the factor by which width and height are multiplied because of the SupersamplingCount.
Public propertySwapChain Gets the SwapChain or null if SwapChain is not used.
Public propertyTransparentRenderingQueue Gets a RenderingQueue that contains transparent objects. Objects in this queue are sorted by their distance to the camera - farthest objects are rendered first.
Public propertyUsedMultisamplingDescription Gets a SampleDescription that describes what level of multisampling is used by the current DXScene. Multisampling is used to create antialiased images with rendering the multiple samples of the same pixel.
Public propertyUsedSwapChainEffect Gets the SwapEffect that was used to create the SwapChain.
Public propertyUseGeometryShaderFor3DLines Gets or sets a boolean that specifies if 3D lines are rendered with using GeometryShader that can create thick lines. If false, then all 3D lines will be rendered as simple DirectX lines with thickness 1. Default value is true.
Public propertyCode exampleUseSharedWpfTexture Gets or sets a nullable Boolean that is used only when using BackBuffer without SwapChain and specifies if DXScene is using a shared resources (texture) that can be used by both DirectX 11 (DXEngine) and DirectX 9 (WPF). Using shared resources improves performance because the texture that is used to render the DirectX 11 image is shader with WPF composition engine. This means that the texture is not copied to main CPU memory and than back to GPU by WPF. When the value is not set by the user (is null), then the value is set in the DXScene initialization. It is set to true when DXEngine is using the same graphics card (adapter) then WPF. Otherwise the value is set to false.
Public propertyViewport Gets or sets a Viewport that defines the area where the scene will be rendered.
Public propertyVirtualRealityProvider Gets a virtual reality provider that is currently used by this DXScene. This property can be set by calling InitializeVirtualRealityRendering(VirtualRealityProviderBase) method.
Public propertyWidth Gets an integer that represents a width of the Viewport
Top
Methods
 NameDescription
Public methodAddRenderingQueueAfter Adds the newRenderQueue after the already registered afterRenderQueue. If rendering queue is MaterialSortedRenderingQueue or CameraDistanceSortedRenderingQueue, then also its IsSortingEnabled property is set according to the current DXScene settings.
Public methodAddRenderingQueueBefore Adds the newRenderQueue before the already registered afterRenderQueue
Public methodCalculateCameraPlanes(ICamera, Boolean, Single, Single) CalculateCameraPlanes sets the zNear and zFar parameters to camera near plane distance and camera far plane distance. The values are calculated with using the bounding box of the current scene and specified camera. When adjustValues Boolean parameter is true, the zNear and zFar values are slightly adjusted to increase the distance between zNear and zFar (recommended). CalculateCameraPlanes returns false if the calculated values are not correct (are 0, NaN or Infinity). This can happen when camera's matrices are not set.
Public methodStatic memberCalculateCameraPlanes(Matrix, Boolean, Boolean, Vector3, Boolean, Single, Single) CalculateCameraPlanes sets the zNear and zFar parameters to camera near plane distance and camera far plane distance. When adjustValues Boolean parameter is true, the zNear and zFar values are slightly adjusted to increase the distance between zNear and zFar (recommended). CalculateCameraPlanes returns false if the calculated values are not correct (are 0, NaN or Infinity). This can happen when camera's matrices are not set.
Public methodCreateAndUseStagingBuffer CreateAndUseStagingBuffer creates a Staging buffer (used to copy the rendered back buffer to main memory) and set it to RenderingContext.
Public methodCode exampleCreateCustomRenderingContext(Int32, Int32, Int32, BackBufferReadyEventHandler, DisposeList) Creates a CustomRenderingContext with all needed DirectX buffers and views that can be used to call RenderScene with custom RenderingContext. The created RenderingContext can be used in RenderScene(RenderingContext, Boolean) or RenderScene(RenderingContext, Boolean, Boolean, DXScene) methods.
Public methodCreateCustomRenderingContext(Texture2D, Texture2DDescription, RenderTargetView, DepthStencilView, Int32) Creates a CustomRenderingContext from the specified back buffer, its render target view and depthStencilView. The created CustomRenderingContext can be used in RenderScene(RenderingContext, Boolean) or RenderScene(RenderingContext, Boolean, Boolean, DXScene) methods.
Public methodCode exampleCreateCustomRenderingContext(Int32, Int32, Int32, Format, Format, BackBufferReadyEventHandler, DisposeList) Creates a CustomRenderingContext with all needed DirectX buffers and views that can be used to call RenderScene with custom RenderingContext. The created RenderingContext can be used in RenderScene(RenderingContext, Boolean) or RenderScene(RenderingContext, Boolean, Boolean, DXScene) methods.
Public methodCode exampleCreateCustomRenderingContext(Int32, Int32, Int32, Format, Format, BackBufferReadyEventHandler, VirtualRealityProviderBase, DisposeList) Creates a CustomRenderingContext with all needed DirectX buffers and views that can be used to call RenderScene with custom RenderingContext. The created RenderingContext can be used in RenderScene(RenderingContext, Boolean) or RenderScene(RenderingContext, Boolean, Boolean, DXScene) methods.
Public methodCode exampleCreateCustomRenderingContext(Int32, Int32, Int32, Int32, Format, Format, BackBufferReadyEventHandler, VirtualRealityProviderBase, DisposeList) Creates a CustomRenderingContext with all needed DirectX buffers and views that can be used to call RenderScene with custom RenderingContext. The created RenderingContext can be used in RenderScene(RenderingContext, Boolean) or RenderScene(RenderingContext, Boolean, Boolean, DXScene) methods.
Public methodCreateDefaultRenderingSteps CreateDefaultRenderingSteps clears the current rendering step (RenderingSteps) and adds the default rendering steps to the RenderingSteps list.
Public methodCreateSpriteBatch(String) Creates a SpriteBatch that will be used in this DXScene. The SpriteBatch will be added to the DefaultRenderSpritesRenderingStep rendering step. If this is the first sprite batch then the DefaultRenderSpritesRenderingStep is added to RenderingSteps.
Public methodCreateSpriteBatch(RenderSpritesRenderingStep, String) Creates a SpriteBatch that will be added to the specified RenderSpritesRenderingStep. When renderSpritesRenderingStep is not specified, then the created SpriteBatch is added to a the DefaultRenderSpritesRenderingStep rendering step (if this is the first sprite batch then the DefaultRenderSpritesRenderingStep is added to RenderingSteps).
Public methodDisposeBackBuffers Disposes the back buffers and views that are defined in this DXScene
Public methodDumpRenderingQueues Writes string that contains details about all objects inside rendering queues to the console (when the application is debugged in Visual Studio the string is written to Output window).
Public methodDumpRenderingSteps Writes string that contains details about all RenderingSteps in this DXScene to the console (when the application is debugged in Visual Studio the string is written to Output window).
Public methodDumpSceneNodes Writes string that contains details about all DXScene's SceneNodes and their hierarchy to the console (when the application is debugged in Visual Studio the string is written to Output window).
Public methodFindNode FindNode searches SceneNode hierarchy starting from RootNode and tries to find the SceneNode with the nodeName. Null is returned if SceneNode is not found.
Public methodGetAllHitObjects GetAllHitObjects method executes a hit testing on the SceneNodes in this DXScene (or when specified on rootSceneNode and its children) and returns a list of DXRayHitTestResult objects sorted from the closest to the farthest object. When no object is hit, an empty list is returned.
Public methodGetClosestHitObject GetClosestHitObject method executes a hit testing on the SceneNodes in this DXScene (or when specified on rootSceneNode and its children) and returns a DXRayHitTestResult object with the closest triangle hit by the specified ray. When no triangle is hit, null is returned.
Public methodGetHitSceneNodeBounds GetHitSceneNodeBounds returns a List of SceneNode objects where the ray intersects the BoundingBox of the SceneNode.
Public methodGetRayFromCamera Returns SharpDX.Ray that goes into a direction that is calculated from the specified x and y position in screen coordinates. For perspective camera the ray starts at the current camera position. The ray can be used for hit testing from the mouse position defined by x and y (relative to this DXScene object).
Public methodGetRayFromNearPlane Returns SharpDX.Ray that starts at the camera's near plane and goes into a direction that is calculated from the specified x and y position in screen coordinates. The ray can be used for hit testing from the mouse position defined by x and y (relative to this DXScene object).
Public methodGetRenderingQueuesDumpString(Boolean) Returns string that contains details about all objects inside rendering queues.
Public methodGetRenderingQueuesDumpString(Boolean, Boolean, Boolean) Returns string that contains details about all objects inside rendering queues.
Public methodGetRenderingStepsDumpString Returns string that contains details about all RenderingSteps in this DXScene.
Public methodGetSceneNodesDumpString(Boolean, Boolean, Boolean, Boolean) Returns string that contains details about all DXScene's SceneNodes and their hierarchy.
Public methodGetSceneNodesDumpString(Boolean, Boolean, Boolean, Boolean, Boolean, Boolean) Returns string that contains details about all DXScene's SceneNodes and their hierarchy.
Public methodHandleDeviceRemoved HandleDeviceRemoved is called when a DirectX device is removed or reset. The method gets device removed reason from DirectX API and then calls the DeviceRemoved event handler. If the event handler handles the event, then the method returns. Otherwise the method throws an DXEngineException with description from specified message and device removed reason.
Public methodHasDirtyFlag Returns true if this DXScene has the flags from the method argument set. Note that if this value is checked before the Update phase is completed, then the value may not have the final value (but it has the camera and light changed flags already set).
Public methodHitTestSceneNode Returns DXRayHitTestResult if the specified ray hits the specified sceneNode. Otherwise null is returned. Child SceneNodes are not tested.
Public methodInitializeBackBuffer InitializeWithBackBuffer
Public methodInitializeDevice InitializeDevice is a virtual method that calls InitializeDevice on DXDevice if it was not yet initialized.
Public methodInitializeShadowRendering InitializeShadowRendering initializes shadow rendering with using the specified shadowRenderingProvider. To dispose shadow rendering rendering pass null as shadowRenderingProvider parameter.
Public methodInitializeSwapChain InitializeWithSwapChain
Public methodInitializeVirtualRealityRendering InitializeVirtualRealityRendering initializes virtual reality rendering with using the specified virtualRealityProvider. To dispose virtual reality rendering pass null as virtualRealityProvider parameter.
Public methodIsOnMainRenderThread Returns true when the code is currently executing on main render thread (the thread that was used to create this DXScene).
Public methodLogUserMessage LogUserLabel can be used to add custom user message to DXEngine log file. This method work only with debug DXEngine build and with enabled logging. It added the "USER MESSAGE: " prefix to log entry.
Public methodNotifyChange(DXSceneChangeNotifications) NotifyChange method adds the specified ChangeNotifications to all the changes flags
Public methodNotifyChange(DXSceneChangeNotifications, Object) NotifyChange method adds the specified ChangeNotifications to all the changes flags
Public methodRemoveRenderingQueue Adds the newRenderQueue before the already registered afterRenderQueue
Public methodRemoveSpriteBatch(SpriteBatch) Removes the specified SpriteBatch from the list of sprite batches that are rendered by this DXScene. If this is the last SpriteBatch in the DefaultRenderSpritesRenderingStep, then it will be removed from the RenderingSteps.
Public methodRemoveSpriteBatch(SpriteBatch, RenderSpritesRenderingStep) Removes the specified SpriteBatch from the list of sprite batches that are rendered by the specified RenderSpritesRenderingStep.
Public methodRenderScene(Boolean) Renders the scene. If forceRenderAll is true, then the RenderingQueues are always regenerated and the scene is always rendered (use RenderScene(Boolean, Boolean) to control regeneration of rendering queues).
Public methodRenderScene(Boolean, Boolean) RenderScene rendered the scene. If forceRender is false then the scene is rendered only if there are any changes in the scene nodes. If forceUpdate is true then the RenderingQueues are always regenerated (otherwise RenderingQueues are regenerated only when this is required because of the changes).
Public methodRenderScene(RenderingContext, Boolean) Renders the scene with using custom RenderingContext. This allows rendering to custom buffers and render targets.
Public methodRenderScene(DXScene, Boolean, Boolean) Renders the scene to the back buffers and with using cameras defined in childDXScene.
Public methodCode exampleRenderToBitmap(Int32, Int32, Int32, BackBufferReadyEventHandler) RenderToBitmap renders the 3D scene to bitmap with specified width, height and multisampling count (used if possible). When the scene is rendered the renderedTextureReadyCallback delegate is called - here it is possible to read the memory with the rendered buffer.
Public methodCode exampleRenderToBitmap(Int32, Int32, Int32, Int32, BackBufferReadyEventHandler) RenderToBitmap renders the 3D scene to bitmap with specified width, height and multisampling count (used if possible). When the scene is rendered the renderedTextureReadyCallback delegate is called - here it is possible to read the memory with the rendered buffer.
Public methodResize(Int32, Int32) Resize method resizes the buffers needed to render the DXScene (DpiScale values are preserved; to change or set DpiScale, call overloaded method that takes DpiScale parameters)
Public methodResize(Int32, Int32, Single, Single) Resize method resizes the buffers needed to render the DXScene
Public methodResize(Int32, Int32, Int32, Single, Single) Resize method resizes the buffers needed to render the DXScene
Public methodSetupWaitingInBackgroundUntilRendered SetupWaitingInBackgroundUntilRendered method can be used to enable waiting in background until rendering is complete (this can be used for DirectXImage PresentationType where the DXEngine needs to notify WPF when the 3D scene is rendered; this is enabled by default - the DXViewportView.IsWaitingInBackgroundUntilRendered is set to true). In this case the rendering steps in DXEngine are completed before graphic card finishes rendering. When the rendering is complete the renderingCompleteAction is called from another thread. There the user can update the shared texture. When the renderingCompleteAction parameter is null, then waiting in background is disabled.
Public methodStatic memberTransformRay Transforms the specified ray with the specified matrix. The transformation is done with transforming the ray's position and its direction (direction is transformed without translation).
Public methodUpdate Update calls Update method on all child nodes.
Top
Events
 NameDescription
Public eventAfterFrameInitialized AfterFrameInitialized event is triggered after the RenderTargets have been set and cleared, Viewports have been set and default Rasterizer state has been set.
Public eventAfterFrameRendered AfterFrameRendered event is triggered after all the rendering activities for one frame have been finished.
Public eventAfterObjectsRendered AfterObjectsRendered event is triggered after all the objects have been rendered and before rendered objects are "sent to the screen" (Present method on SwapChain is called or the render target is prepared for D3DImage)
Public eventAfterUpdated AfterUpdated event is triggered after the SceneNode objects have been updated and before the decision is made to render the next frame or not. Subscriber to this event can prevent rendering frame or force rendering it with changing the IsRenderNeeded property in the event args.
Public eventBackBufferReady BackBufferReady event is triggered when the rendered image is ready to be copied from graphic to main memory. This is used when DirectXImage presentation type is used and when DXEngine is using software rendering or when UseSharedWpfTexture is set to true. In those cases the DXEngine is rendering the image to a so called staging buffer and when the image in staging buffer is ready the BackBufferReady is triggered. The event arguments contain the size of the image, its format and the mapped subresource.
Public eventDeviceRemoved DeviceRemoved event is triggered when the DirectX device is removed or reset (for example when the DirectX driver is updated; but not when computer goes to sleep). The event handler can handle this case with saving the current state of the 3D scene, dispose the current DirectX objects and recreate the 3D scene.
Public eventHardwareAccelerate3DLineSettingsChanged HardwareAccelerate3DLineSettingsChanged is triggered when HardwareAccelerate3DLines or HardwareAccelerate3DLineCaps properties are changed.
Public eventSizeChanged SizeChanged event is trigger after the Resize(Int32, Int32, Single, Single) method is called.
Top
Fields
 NameDescription
Public fieldStatic memberLinesCountRequiredForComplexGeometry LinesCountRequiredForComplexGeometry specifies the number of 3D lines that are required to put the objects rendered with ScreenSpaceLineNode into the ComplexGeometryRenderingQueue (sending it to GPU as fast as possible) instead of into the LineGeometryRenderingQueue. Default value is 20000.
Public fieldStatic memberLogger Logger is not used in release build and is always null
Public fieldStatic memberMeshTriangleIndicesCountRequiredForComplexGeometry TriangleIndicesCountRequiredForComplexGeometry specifies the number of triangles that are required to put the objects rendered with WpfGeometryModel3DNode into the ComplexGeometryRenderingQueue (sending it to GPU as fast as possible) instead of into the StandardGeometryRenderingQueue. Default value is 100000.
Top
Remarks

DXScene has the following tasks in the DXEngine:
- it represents a viewport that shows the scene (has a render target, buffers and other DirectX objects that are used to render the scene to)
- it has the camera
- it holds the hierarchical tree of the 3d objects
- it creates lists of used materials and effects
- it creates list of RenderQueues. Each RenderQueue is filled with IRenderable objects. List of RenderQueues is than passed to DXDevice that renderer the objects to the render targets specified by this DXScene.
- it can get change notifications from 3d objects and updates the lists of materials, effects, and RenderQueues accordingly. It also triggers rendering when needed.

See Also