Click or drag to resize
Ab4d.SharpEngine logo

SharpEngineSceneView Class

SharpEngineSceneView is a control that can show a 3D scene that is defined by the Scene and SceneView objects. See remarks for more info.
Inheritance Hierarchy
SystemObject
  AvaloniaObject
    Animatable
      StyledElement
        Visual
          Layoutable
            Interactive
              InputElement
                Control
                  Ab4d.SharpEngine.AvaloniaUISharpEngineSceneView

Namespace: Ab4d.SharpEngine.AvaloniaUI
Assembly: Ab4d.SharpEngine.AvaloniaUI (in Ab4d.SharpEngine.AvaloniaUI.dll) Version: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
Syntax
C#
public class SharpEngineSceneView : Control, 
	ISharpEngineSceneView, IComponentBase

The SharpEngineSceneView type exposes the following members.

Constructors
 NameDescription
Public methodSharpEngineSceneView Creates the SharpEngineSceneView object (PresentationType is set to SharedTexture). This also creates the Scene and SceneView objects. The VulkanDevice is automatically created when this control is loaded. To manually create or set the VulkanDevice, call the Initialize method.
Public methodSharpEngineSceneView(PresentationTypes) Creates the SharpEngineSceneView object and sets the PresentationType property. This also creates the Scene and SceneView objects. The VulkanDevice is automatically created when this control is loaded. To manually create or set the VulkanDevice, call the Initialize method.
Top
Properties
 NameDescription
Public propertyAvaloniaFrameNumber 
Public propertyBackgroundColor 
Public propertyCreateOptions Gets the EngineCreateOptions that were used to create the VulkanInstance and VulkanDevice.
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 propertyGpuDevice Gets the graphics device object (VulkanDevice).
Public propertyId Gets a unique id of this resource
Public propertyIsAutomaticallyUpdating 
Public propertyIsDisposed Gets a Boolean that specifies if this resource has been disposed.
Public propertyIsDisposing Gets a Boolean that specifies if this resource is currently being disposed (the current code is executing inside Dispose method).
Public propertyPreferredMultiSampleCount PreferredMultiSampleCount can be set before the SceneView is initialized and defines the multi-sampling count (MSAA) that will be used if supported by the device. After initializing the SceneView, the actually used multi-sampling count is set to the UsedMultiSampleCount property.
Public propertyPresentationType Presentation type defines how the rendered 3D scene will be presented to the platform. Default value is SharedTexture.
Public propertyScene Gets the Scene that defines the 3D objects.
Public propertySceneView Gets the SceneView that renders the Scene to this control.
Public propertyStopRenderingWhenHidden Gets or sets a Boolean that specifies if rendering is stopped when this control is hidden (IsVisible goes to false). Default value is true.
Public propertyWaitForVSync Gets or sets a Boolean that specifies if the SceneView is waiting for a v-sync provided by the surface. This property is used only when OverlayTexture is used as a PresentationType.
Protected propertyWriteableBitmap 
Top
Methods
 NameDescription
Protected methodArrangeOverride
(Overrides Layoutable.ArrangeOverride(Size))
Public methodDispose Disposes all resources that were created by this SharpEngineSceneView.
Protected methodDispose(Boolean) 
Protected methodFinalize Destructor
(Overrides ObjectFinalize)
Public methodInitialize Initialize method initializes the engine by using the CreateOptions from this SharpEngineSceneView.
Public methodInitialize(ActionEngineCreateOptions) Initialize method initializes the engine by using EngineCreateOptions that are defined by the provided configureAction.
Public methodInitialize(EngineCreateOptions) Initialize method initializes the engine by using the specified EngineCreateOptions.
Public methodInitialize(VulkanDevice) Initialize method initializes the engine by using the specified VulkanDevice object.
Protected methodIsDesignTime Returns if the control is running in design time.
Public methodStatic memberIsPresentationTypePossible Returns true when the specified presentationType may be supported by this SharpEngineSceneView control. To check if the presentationType is possible on the current or specific GpuDevice call the IsPresentationTypeSupported(PresentationTypes) or IsPresentationTypeSupported(PresentationTypes, String) or IsPresentationTypeSupported(PresentationTypes, VulkanDevice, String) methods.
Public methodIsPresentationTypeSupported(PresentationTypes) Returns true when the specified presentationType is supported on the current GpuDevice. This method must not be called before the GpuDevice is created (before SharpEngineSceneView is initialized).
Public methodIsPresentationTypeSupported(PresentationTypes, String) Returns true when the specified presentationType is supported on the current GpuDevice. When presentation type is not supported, a string with additional information is set to the additionalInfo parameter. This method must not be called before the GpuDevice is created (before SharpEngineSceneView is initialized).
Public methodIsPresentationTypeSupported(PresentationTypes, VulkanDevice, String) Returns true when the specified presentationType is supported on the specified GpuDevice. When presentation type is not supported, a string with additional information is set to the additionalInfo parameter.
Protected methodOnAttachedToVisualTree
(Overrides Control.OnAttachedToVisualTree(VisualTreeAttachmentEventArgs))
Protected methodOnDetachedFromLogicalTree
(Overrides StyledElement.OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs))
Protected methodOnDisposed OnDisposed
Protected methodOnDisposing OnDisposing
Protected methodOnGpuDeviceCreated OnGpuDeviceCreated
Protected methodOnGpuDeviceCreationFailed OnGpuDeviceCreationFailed
Protected methodOnPresentationTypeChanged OnPresentationTypeChanged
Protected methodOnSceneRendered OnSceneRendered
Protected methodOnSceneUpdating OnSceneUpdating
Protected methodOnSceneViewInitialized OnSceneViewInitialized
Protected methodOnViewSizeChanged OnViewSizeChanged
Public methodRender Render method is called by Avalonia to render the content of this control. To manually render the 3D scene call the RenderScene(Boolean, Boolean) method.
(Overrides Visual.Render(DrawingContext))
Public methodRenderScene 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 methodRenderToBitmap(Boolean) RenderToBitmap method renders the current scene to a new Avalonia's WriteableBitmap. To reuse the WriteableBitmap, call the method that takes the WriteableBitmap by ref. See also the RenderToXXXX methods in the SceneView object.
Public methodRenderToBitmap(WriteableBitmap, Boolean) RenderToBitmap method renders the current scene to the specified Avalonia's WriteableBitmap. If the WriteableBitmap is null of its size is not the same as the size of the SceneView, then the WriteableBitmap is resized. See also the RenderToXXXX methods in the SceneView object.
Public methodUpdate 
Top
Events
 NameDescription
Public eventDisposed Occurs when this instance is fully disposed. The value of the parameter is the same the disposing parameter in the Dispose(bool) method.
Public eventDisposing Occurs when this instance is starting to be disposed. The value of the parameter is the same the disposing parameter in the Dispose(bool) method.
Public eventGpuDeviceCreated Called after the GpuDevice object was created. If device creation has failed, then GpuDeviceCreationFailed event is triggered.
Public eventGpuDeviceCreationFailed Called when the device creation has failed. User can set the IsHandled property to true to prevent showing error text that is shown by SharpEngineSceneView.
Public eventPresentationTypeChanged Called when the selected PresentationType is not supported and was changed to a fallback PresentationType. The event parameter may provide some additional information about the reason for change.
Public eventSceneRendered Called after the scene has been rendered.
Public eventSceneUpdating Called when the scene is being updated and before it is rendered. The event is called at the beginning of the RenderScene(Boolean, Boolean) method. This event can be used to update the animations.
Public eventSceneViewInitialized Called after the SceneView object have been initialized (have a valid view size and the back buffers were created).
Public eventViewSizeChanged Called when the size of the rendering area is changed. The event is also called after the back buffers are initialized for the first time.
Top
Fields
 NameDescription
Public fieldStatic memberBackgroundColorProperty 
Public fieldStatic memberRequiredDeviceExtensionNamesForSharedTexture RequiredDeviceExtensionNames is a static List that contains the Vulkan device extension names that are required to use SharedTexture as presentation type. This list must be set before the VulkanDevice is created.
Top
Remarks

SharpEngineSceneView is a control that can show a 3D scene that is defined by the Scene and SceneView objects.

To add SceneNode objects to the Scene add them to the RootNode object. Lights can be added to the Lights collection. Camera can be set to the Camera property.

The SharpEngineSceneView automatically creates a GpuDevice when the control is loaded. To manually create or set the GpuDevice, call the Initialize method. GpuDeviceCreated and GpuDeviceCreationFailed events can be used to be notified when the GpuDevice is created or when the creation failed.

SharpEngineSceneView can use different presentation types that are defined by PresentationType property.

By default, the PresentationType is set to SharedTexture that can combine the rendered 3D scene with other UI controls and can preserve the data for the rendered texture on the graphics card.

When this mode is not supported on the UI framework or operating system, then WriteableBitmap is used. This presentation type is available on all UI frameworks and operating systems. It can still combine the 3D scene with other UI controls, but the rendered texture need to be copied to the main CPU memory to create a WritableBitmap.

The presentation type that provides the best performance is OverlayTexture. The drawback of this mode is that there the 3D scene is always rendered on top of other UI controls. This presentation type is not available on all platforms.

To check if other presentation type is supported, call IsPresentationTypeSupported(PresentationTypes) method. If selected presentation type is not supported, then WriteableBitmap will be used as fallback.

See Also