Click or drag to resize
Ab4d.SharpEngine logo

SceneView Methods

The SceneView type exposes the following members.

Methods
 NameDescription
Public methodAddAnimation Adds the specified animation to the list of animations that are updated in each update phase.
Public methodBoundingBox3DTo2D Converts a 3D BoundingBox to the two Vector2 that define the 2D bounding box on the screen.
Public methodCalculateCameraPlanes(ICamera, 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. 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(Matrix4x4, Boolean, Vector3[], Single, Single, Single) CalculateCameraPlanes sets the zNear and zFar parameters to camera near plane distance and camera far plane distance. 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 methodCanConvertPoint3DTo2D CanConvertPoint3DTo2D returns true when the matrix to convert 3D world position to screen 2D position can be generated.
Public methodCaptureNextFrameInRenderDoc CaptureNextFrameInRenderDoc will try to capture the next frame in RenderDoc. The application that is using SharpEngine must be started from RenderDoc. This works only on Windows. The method returns true when the RenderDocHelper was correctly initialized and when the capture is possible. The actual capture will start before the next frame will be rendered.
Protected methodChooseDepthStencilFormat virtual ChooseDepthStencilFormat that can be overriden to set a different Format for the depth-stencil buffer. Returns Format.Undefined if not supported
Protected methodChooseSwapPresentMode virtual ChooseSwapPresentMode that can be overriden to set a different PresentModeKHR.
Protected methodChooseSwapSurfaceFormat(SurfaceDetails) virtual ChooseSwapSurfaceFormat that can be overriden to set a different SurfaceFormatKHR
Protected methodChooseSwapSurfaceFormat(SurfaceFormatKHR[]) virtual ChooseSwapSurfaceFormat that can be overriden to set a different SurfaceFormatKHR
Public methodCreateBackgroundSpriteBatch Creates a SpriteBatch that will be rendered before the objects in this SceneView are rendered. SpriteBatch that is created from SceneView object can use relative and absolute coordinates. To remove the created SpriteBatch call the RemoveSpriteBatch(SpriteBatch, Boolean) or RemoveAllSpriteBatches(Boolean) methods. It is also possible to add sprites that are rendered when rendering the Scene - in this case call CreateBackgroundSpriteBatch(String) or CreateOverlaySpriteBatch(String) methods.
Public methodCreateOverlaySpriteBatch Creates a SpriteBatch that will be rendered after the objects in this SceneView are rendered. SpriteBatch that is created from SceneView object can use relative and absolute coordinates. To remove the created SpriteBatch call the RemoveSpriteBatch(SpriteBatch, Boolean) or RemoveAllSpriteBatches(Boolean) methods. It is also possible to add sprites that are rendered when rendering the Scene - in this case call CreateBackgroundSpriteBatch(String) or CreateOverlaySpriteBatch(String) methods.
Public methodDispose() Dispose
Protected methodDispose(Boolean) Dispose
(Overrides ComponentBase.Dispose(Boolean))
Public methodDumpCameraInfo Writes string about the details about the current camera to the console (when the application is debugged in Visual Studio the result is written to Output window or Immediate Window if started from there; in Rider the result is written to Debug Output window).
Public methodDumpRenderingStatistics Writes string with major rendering statistics from the last rendered frame to the console (when the application is debugged in Visual Studio the result is written to Output window or Immediate Window if started from there; in Rider the result is written to Debug Output window).
Public methodDumpRenderingSteps Writes string about each used rendering step to the console (when the application is debugged in Visual Studio the result is written to Output window or Immediate Window if started from there; in Rider the result is written to Debug Output window).
Public methodGetAllHitObjects(Ray, HitTestOptions) GetAllHitObjects method executes a hit testing by using the specified Ray on the SceneNodes that are shown by this SceneView and returns a list of RayHitTestResult objects sorted from the closest to the farthest object. When no object is hit, an empty list is returned.
Public methodGetAllHitObjects(Single, Single, Boolean, HitTestOptions) GetAllHitObjects method executes a hit testing from the specified x and y positions on the SceneNodes that are shown by this SceneView and returns a list of RayHitTestResult objects sorted from the closest to the farthest object. When no object is hit, an empty list is returned.
Public methodGetCameraInfo Gets a string that shows the details about the current camera.
Public methodGetClosestHitObject(Ray, HitTestOptions) GetClosestHitObject method executes a hit testing by using the specified Ray on the SceneNodes that are shown by this SceneView and returns a RayHitTestResult object with the closest triangle hit. When no triangle is hit, null is returned.
Public methodGetClosestHitObject(Single, Single, Boolean, HitTestOptions) GetClosestHitObject method executes a hit testing from the specified x and y positions on the SceneNodes that are shown by this SceneView and returns a RayHitTestResult object with the closest triangle hit. When no triangle is hit, null is returned.
Protected methodGetCurrentSurfaceSize Gets the size of the Surface
Public methodGetCurrentSwapChainImage Returns the Vulkan Image that is used as the current swap chain image.
Public methodGetImageAvailableSemaphore Gets the Semaphore that is used to signal when the rendered image is available.
Public methodGetRayFromCamera(Int32, Int32, Boolean, Boolean) Returns a 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 SceneView object). When the Ray cannot be created (size is zero or camera matrix is not valid), then a Ray with zero Direction is returned (Ray.IsValid would return false).
Public methodGetRayFromCamera(Single, Single, Boolean, Boolean) Returns a 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 SceneView object). When the Ray cannot be created (size is zero or camera matrix is not valid), then a Ray with zero Direction is returned (Ray.IsValid would return false).
Public methodGetRayFromNearPlane(Int32, Int32, Boolean, Boolean) Returns a 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 SceneView object). When the Ray cannot be created (size is zero or camera matrix is not valid), then a Ray with zero Direction is returned (Ray.IsValid would return false).
Public methodGetRayFromNearPlane(Single, Single, Boolean, Boolean) Returns a 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 SceneView object). When the Ray cannot be created (size is zero or camera matrix is not valid), then a Ray with zero Direction is returned (Ray.IsValid would return false).
Public methodGetRenderFinishedSemaphore Gets the Semaphore that is used to signal when the rendering is finished.
Public methodGetRenderingStatisticsInfo Returns a string with major rendering statistics from the last rendered frame. To collect statistics set the IsCollectingStatistics to true before rendering a frame.
Public methodGetRenderingStepsInfo Gets a string that shows each used rendering step in its own line.
Public methodGetWorldToViewMatrix Gets Matrix4x4 that can be used to convert 3D coordinates to 2D view (screen) coordinates. If the method returns true, than the worldToViewMatrix was set; if false is returned than the matrix cannot be calculated.
Public methodGetWorldToViewportMatrix Gets Matrix4x4 that can be used to convert 3D coordinates to 2D viewport (screen) coordinates. If the method returns true, than the worldToViewportMatrix was set; if false is returned than the matrix cannot be calculated.
Public methodInitialize(SurfaceKHR, Single, Single) Initializes the SceneView with the size from the specified Vulkan Surface. Optionally it is possible to set the DPI scale because that data is not available from the surface.
Public methodInitialize(VulkanSurfaceProvider, Single, Single) Initializes the SceneView with the size from the specified vulkanSurfaceProvider that can return a Vulkan Surface. Optionally it is possible to set the DPI scale because that data is not available from the surface.
Public methodInitialize(Int32, Int32, Single, Single) Initializes the SceneView with the specified size. This method can be called only when the SceneView was created without a Surface parameter (call Initialize(SurfaceKHR, Single, Single) or Initialize(VulkanSurfaceProvider, Single, Single) when a valid Surface is provided).
Public methodInitialize(VulkanDevice, VulkanSurfaceProvider, Single, Single) Initializes the SceneView with the size from the specified vulkanSurfaceProvider that can return a Vulkan Surface. Optionally it is possible to set the DPI scale because that data is not available from the surface.
Public methodInitialize(VulkanDevice, SurfaceKHR, Single, Single) Initializes the SceneView with the size from the specified Vulkan Surface. Optionally it is possible to set the DPI scale because that data is not available from the surface.
Public methodInitializeWithDefaultSurface Initializes the SceneView with the size from the DefaultSurface that was used to create the VulkanDevice. Optionally it is possible to set the DPI scale because that data is not available from the surface.
Protected methodIsCommandBuffersRecreateNeeded IsCommandBuffersRecreateNeeded returns true if Scene.DirtyFlags and DirtyFlags require that the command buffer is recreated.
Public methodIsFrameRenderingFinished Returns true if the frame with the specified number was fully rendered (no tasks on the GPU are still running for this frame).
Protected methodIsRenderingLayersRecreateNeeded IsRenderingLayersRecreateNeeded returns true if Scene.DirtyFlags and DirtyFlags require that the RenderingLayers are recreated by calling CollectRenderingItems(RenderingContext) methods on all SceneNodes..
Public methodLine3DTo2D(Vector3, Vector3, Boolean) Converts a 3D line that is defined by startPositionWorld and endPositionWorld to a line on the screen that is defined by startPositionScreen and endPositionScreen. This method correctly handles the case when the 3D line crosses the camera near plane (goes behind the camera). In this case the line needs to be cropped at the camera's near plane.
Public methodStatic memberLine3DTo2D(Vector3, Vector3, Camera, Single, Single) Converts a 3D line that is defined by startPositionWorld and endPositionWorld to a line on the screen that is defined by startPositionScreen and endPositionScreen. This method correctly handles the case when the 3D line crosses the camera near plane (goes behind the camera). In this case the line needs to be cropped at the camera's near plane.
Public methodNotifyChange NotifyChange method adds the specified SceneViewDirtyFlags to the changes flags for this SceneView.
Protected methodOnInitializeDeviceResources OnInitializeDeviceResources
(Overrides SceneComponent.OnInitializeDeviceResources(VulkanDevice))
Protected methodOnSceneRendered OnSceneRendered
Protected methodOnSceneUpdating OnSceneUpdating
Protected methodOnViewResized OnViewSizeChanged
Public methodPoint3DTo2D(Vector3, Boolean) Point3DTo2D converts a world space 3D position (as Vector3) to the 2D screen position (as Vector2). To calculate the 2D position for the final UI element, set the adjustByDpiScale to true otherwise the 2D positions will be positioned inside the view defined by SceneView's Width and Height.
Public methodPoint3DTo2D(Vector3, Camera, Single, Single) Point3DTo2D converts a world space 3D point (as Vector3) to the 2D point (as Vector2) on the view that is defined by specified camera, viewWidth and viewHeight.
Public methodPoints3DTo2D(Span, Void, Vector3, Span, Void) 
Public methodPoints3DTo2D(Vector3[], Vector2[], Transform, Boolean, Boolean) Points3DTo2D calculates 2D screen positions from the specified 3D positions. To calculate the 2D positions for the final UI element, set the adjustByDpiScale to true otherwise the 2D positions will be positioned inside the view defined by SceneView's Width and Height. Calculated 2D positions are stored into the specified points2D array (its size must be at least the size of the 3D positions).
Public methodPoints3DTo2D(Span, Void, Vector3, Span, Void, Vector2, Camera, Single) 
Public methodPoints3DTo2D(Vector3[], Vector2[], Camera, Single, Single, Transform, Boolean, Boolean) Points3DTo2D calculates 2D positions from the specified 3D positions. Calculated 2D positions are stored into the specified points2D array (its size must be at least the size of the 3D positions).
Public methodRegisterStagingGpuBufferReadyCallback RegisterStagingGpuBufferReadyCallback can be called to copy the rendered image to a staging GpuBuffer and call the provided action when the staging buffer is ready to be copied to the main memory. To get the GpuImage instead of a staging buffer, use the RegisterStagingGpuImageReadyCallback(Action<GpuImage>). To unregister call UnregisterStagingGpuBufferReadyCallback(Action<GpuBuffer, Int32, Int32> ) method.
Public methodRegisterStagingGpuImageReadyCallback RegisterStagingGpuImageReadyCallback can be called to copy the rendered image to a staging GpuImage and call the provided action when the staging buffer is ready to be copied to the main memory. To get the GpuBuffer as a staging buffer, use the RegisterStagingGpuBufferReadyCallback(Action<GpuBuffer, Int32, Int32>). To unregister call UnregisterStagingGpuImageReadyCallback(Action<GpuImage> ) method.
Public methodRemoveAllSpriteBatches Removes all SpriteBatches.
Public methodRemoveAnimation Remove the specified animation from the list of animations.
Public methodRemoveSpriteBatch Removes the specified SpriteBatch from the list of sprite batches associated to this Scene (created by CreateBackgroundSpriteBatch(String) or CreateOverlaySpriteBatch(String) methods).
Public methodRender Render method checked the dirty flags of this SceneView and the Scene and when there are some changes rendered the next frame. Rendering cna be forced by setting forceRender to true.
Public methodRenderToGpuBuffer Renders the current scene view to the bitmap and saves the image data a GpuBuffer that is passed to the specified stagingGpuBufferReady Action (parameters: GpuBuffer gpuBuffer, int imageWidth, int imageHeight). The data in the GpuBuffer always have 4 bytes per pixel and have no row padding (stride = width * 4).
Public methodRenderToGpuImage Renders the current scene view to the bitmap and saves the image data a GpuImage that is passed to the specified stagingGpuImageReady Action.
Public methodRenderToRawImageData(Boolean, Boolean, StandardBitmapFormats) Renders the current scene view to the bitmap that is represented by RawImageData object. To reuse the RawImageData and its data array, call RenderToRawImageData that takes RawImageData as the first parameter.
Public methodRenderToRawImageData(RawImageData, Boolean, Boolean, StandardBitmapFormats) Renders the current scene view to the bitmap and saves the image data into an existing RawImageData object. When the rendered size is the same or smaller, then the existing Data array is preserved, otherwise a new Data array is created.
Public methodResize(Boolean) Resizes the current SceneView by updating the size from the size of the Surface. When no Surface is used, then Resize(Int32, Int32, SurfaceTransformFlagsKHR, Boolean) must be used.
Public methodResize(Int32, Int32, SurfaceTransformFlagsKHR, Boolean) Resizes the current SceneView to the provided size. When SceneView is rendered to the Surface, then call the Resize(Boolean) method.
Public methodToString
(Overrides Object.ToString())
Public methodUnregisterStagingGpuBufferReadyCallback Removes the specified Action from the actions that were registered by calling the RegisterStagingGpuBufferReadyCallback(Action<GpuBuffer, Int32, Int32> ) method.
Public methodUnregisterStagingGpuImageReadyCallback Removes the specified Action from the actions that were registered by calling the RegisterStagingGpuImageReadyCallback(Action<GpuImage> ) method.
Public methodUpdateAnimations Update all Scene's animations and all animations that are added by calling the AddAnimation(IAnimation) (this is done automatically by the animation classes).
Public methodUpdateCameraNearAndFarPlanes UpdateCameraNearAndFarPlanes method updates the camera's NearPlaneDistance and FarPlaneDistance based on the size of the scene. This is done only when the current Scene's camera implements IAutomaticNearFarPlaneCamera interface and when IsAutomaticNearPlaneDistanceCalculation or IsAutomaticFarPlaneDistanceCalculation are true.
Public methodWaitUntilRendered WaitUntilRendered method waits until this SceneView finishes rendering the current frame.
Top
See Also