AI3DHInteractiveSplineDrawing Class Reference
instant3Dhub
|
#include "I3DHInteractiveSplineDrawing.h"


Detailed Description
A helper for creating spline-based drawings in the scene that are synced to the session when finished.
The drawing is meant to connect multiple sampling points by deforming a (usually 2D) mesh along a spline between them. The intended use is drawing on other geometry, i.e. for the spline to share the local surface normal at the sampling points.
(Blueprint) Class Setup:
- Select a mesh to render spline segments. Usually a square in the x-y plane. The mesh needs some finer tessellation/subdivision so it can be deformed along the spline. The mesh's size defines the units of the spline size at scale == 1 The segment mesh needs to be CPU accessible for the finalization step.
Typical usage:
- MoveCursorTo(..) moves the cursor in the scene. The cursor is visible by default and shows where the user would place new spline points. The active (aka last created) spline's end follows the cursor.
- AddSplinePointAtCursor() adds a new point to the active spline (or creates a new one if there is none).
- FinishActiveSpline() ends the active spline.
- AsyncCreateHubDrawingAndDestroy(..) finalizes the drawing with all splines in it, syncs it with the session and removes this actor.
Implementation-wise each spline uses one SplineComponent for the spline itself and one SplineMeshComponent per segment for rendering.
Public Member Functions | |
void | InitializePreSpawn (AI3DHConnector *ParentHubConnector) |
AI3DHConnector * | GetHubConnector () const |
void | SetDrawingColor (const FLinearColor &Color) |
FLinearColor | GetDrawingColor () const |
void | SetDrawingScale (const FVector2D &Scale) |
FVector2D | GetDrawingScale () const |
void | SetCursorHiddenInGame (bool bIsHiddenInGame) |
bool | IsEmpty () const |
void | Clear () |
void | MoveCursorTo (const FVector &Location, const FVector &Normal) |
void | AddSplinePointAtCursor () |
void | RemoveLastSegmentFromActiveSpline () |
void | FinishActiveSpline () |
void | FinalizeDrawing (TUniqueFunction< void(FI3DHDrawingResult)> OnComplete) |
void | CreateHubDrawingAndDestroy (const FString &Name, TUniqueFunction< void(int DrawingHandle, EI3DHErrorCode ErrorCode)> OnComplete) |
Static Public Member Functions | |
static AI3DHInteractiveSplineDrawing * | CreateInteractiveSplineDrawing (AI3DHConnector *HubConnector, TSubclassOf< AI3DHInteractiveSplineDrawing > DrawingClass) |
Public Attributes | |
double | CursorNormalOffset = 0.01 |
FString | ThumbnailBase64DataURI |
Member Function Documentation
◆ AddSplinePointAtCursor()
void AI3DHInteractiveSplineDrawing::AddSplinePointAtCursor | ( | ) |
Adds a spline point at the cursor position to the active spline.
If no spline is active, a new one is created.
◆ CreateHubDrawingAndDestroy()
void AI3DHInteractiveSplineDrawing::CreateHubDrawingAndDestroy | ( | const FString & | Name, |
TUniqueFunction< void(int DrawingHandle, EI3DHErrorCode ErrorCode)> | OnComplete ) |
Finalizes the drawing, synchronizes it with the hub and destroys this actor.
- Note
- Must be called from the game thread.
-
Empty drawings are not allowed. If the drawing is empty, synchronization with the hub is skipped and OnComplete is called with OnComplete(
0
, EI3DHErrorCode::Success).
- Parameters
-
Name The name of the drawing. OnComplete Callback called on completion.
◆ CreateInteractiveSplineDrawing()
|
static |
Creates an actor which can be used for drawing and syncing to the Hub when finished.
- Parameters
-
HubConnector The hub connector. DrawingClass The drawing class.
- Returns
- Nullptr if it fails, else the new interactive spline drawing.
◆ FinalizeDrawing()
void AI3DHInteractiveSplineDrawing::FinalizeDrawing | ( | TUniqueFunction< void(FI3DHDrawingResult)> | OnComplete | ) |
Finalizes the drawing and builds the drawing geometry.
This disables further editing of the drawing.
- Note
- The output coordinates are relative to this actor (which should be attached to the HubConnector).
- Must be called from the game thread.
- Parameters
-
OnComplete Callback called on completion.
◆ FinishActiveSpline()
void AI3DHInteractiveSplineDrawing::FinishActiveSpline | ( | ) |
Detaches the currently edited spline from the cursor.
It can't be added to / removed from once finished.
◆ GetDrawingColor()
FLinearColor AI3DHInteractiveSplineDrawing::GetDrawingColor | ( | ) | const |
Retrieves the color currently used for drawing.
- Returns
- The drawing color.
◆ GetDrawingScale()
FVector2D AI3DHInteractiveSplineDrawing::GetDrawingScale | ( | ) | const |
Retrieves the scale currently used for drawing.
- Returns
- The drawing scale.
◆ GetHubConnector()
|
inline |
Returns the parent hub connector.
- Returns
- The parent hub connector.
◆ InitializePreSpawn()
void AI3DHInteractiveSplineDrawing::InitializePreSpawn | ( | AI3DHConnector * | ParentHubConnector | ) |
Call before (deferred) spawning.
- Parameters
-
ParentHubConnector The parent hub connector.
◆ IsEmpty()
bool AI3DHInteractiveSplineDrawing::IsEmpty | ( | ) | const |
Query if this drawing is empty.
- Returns
- True if empty, false if not.
◆ MoveCursorTo()
void AI3DHInteractiveSplineDrawing::MoveCursorTo | ( | const FVector & | Location, |
const FVector & | Normal ) |
Sets the cursor position.
If there is an active spline, its last segment's end moves with the cursor.
- Parameters
-
Location The location. Normal The "Normal" determines the up-direction at the sampling point. If the segment mesh is a square in the x-y plane, this is the direction of the square's surface normal. If drawing on other geometry, this should be the surface normal at the location.
◆ RemoveLastSegmentFromActiveSpline()
void AI3DHInteractiveSplineDrawing::RemoveLastSegmentFromActiveSpline | ( | ) |
Removes the last segment of the active spline, which was following the cursor.
If the spline has remaining segments, its new last segment's end is attached to the cursor.
◆ SetCursorHiddenInGame()
void AI3DHInteractiveSplineDrawing::SetCursorHiddenInGame | ( | bool | bIsHiddenInGame | ) |
Hides the cursor in game.
- Parameters
-
bIsHiddenInGame True if is hidden in game, false if not.
◆ SetDrawingColor()
void AI3DHInteractiveSplineDrawing::SetDrawingColor | ( | const FLinearColor & | Color | ) |
Sets the color used for drawing and applies it to the active spline.
- Parameters
-
Color The drawing color.
◆ SetDrawingScale()
void AI3DHInteractiveSplineDrawing::SetDrawingScale | ( | const FVector2D & | Scale | ) |
Sets the scale used for drawing and applies it to the active spline.
- Parameters
-
Scale The drawing scale.
Member Data Documentation
◆ CursorNormalOffset
double AI3DHInteractiveSplineDrawing::CursorNormalOffset = 0.01 |
Offset along the normal when moving the cursor (in world units).
Alleviates z-fighting with the drawn-on surface.
◆ ThumbnailBase64DataURI
FString AI3DHInteractiveSplineDrawing::ThumbnailBase64DataURI |
Data-URI string, e.g.
"data:image/svg+xml;base64,<BASE 64 ENCODED SVG>".
The documentation for this class was generated from the following file:
Generated by