AI3DHDrawingEditor Class Reference

instant3Dhub: AI3DHDrawingEditor Class Reference
instant3Dhub

#include "I3DHDrawingEditor.h"

+ Inheritance diagram for AI3DHDrawingEditor:
+ Collaboration diagram for AI3DHDrawingEditor:

Detailed Description

Actor for creating line-based 3D drawings that sync to instant3Dhub when finished.

A drawing contains one or more Splines (Linear Splines = Line Segments). You can group points in slices, so they can be removed together in an undo step. Modes primarily change what is visualized and which actions are enabled:

Typical usage:

Public Member Functions

AI3DHConnectorGetHubConnector () const
 
void SetDrawingColor (const FLinearColor &Color)
 
FLinearColor GetDrawingColor () const
 
void SetDrawingScale (const double &Scale)
 
double GetDrawingScale () const
 
const FStringGetEditedDrawingName () const
 
void SetOmitStrokeStartAndEndJoints (bool bNewOmitJoints)
 
void SetShowActiveSliceControlPoints (bool bNewShowActiveSliceControlPoints)
 
bool IsEmpty () const
 
int32 NumSplines () const
 
void Clear ()
 
void Restore ()
 
void MoveCursorTo (const FVector &Location)
 
void AddPointAtCursor ()
 
void BeginNewSplineSlice ()
 
bool RemoveLastSplineSlice ()
 
void BeginNewSpline ()
 
void FinalizeDrawing (TUniqueFunction< void(FI3DHDrawingResult)> OnComplete)
 
void CreateHubDrawingAndDestroy (const FString &Name, TUniqueFunction< void(int32 DrawingHandle, EI3DHErrorCode ErrorCode)> OnComplete)
 
void SetDrawingMode (EI3DHDrawingEditorMode InDrawingMode)
 
EI3DHDrawingEditorMode GetDrawingEditorMode () const
 
bool AddPoint (const FVector &Location, bool bIsWorldSpace=false)
 
void InitFromSplines (const TArray< FI3DHSplineData > &InSplines)
 
void InitFromSplines (TArray< FI3DHSplineData > &&InSplines)
 
const TArray< FI3DHSplineData > & GetSplines () const
 
bool SelectNearestPointAtCursor ()
 
bool SelectNearestPoint (const FVector &Location, bool bIsWorldSpace=false)
 
int32 GetNumFinalizedSplines () const
 
TArray< int32 > GetFinalizedSplineIndices () const
 
bool WasSplineFinalized (int32 SplineIndex) const
 
const TBitArrayGetFinalizedSplineMask () const
 
- Public Member Functions inherited from II3DHEditDrawingInterface
void BeginEditDrawing (int32 DrawingHandle, const FI3DHDrawingProperties &DrawingProperties, const UI3DHEditDrawingGeometryProvider *GeometryProvider, const AI3DHDrawing *DrawingActor)
 
void FailedEditDrawing (int32 DrawingHandle, const FString &Reason)
 

Static Public Member Functions

static AI3DHDrawingEditorCreateDrawingEditor (AI3DHConnector *HubConnector, TSubclassOf< AI3DHDrawingEditor > DrawingClass)
 

Public Attributes

bool bCreateLineStripDrawings {true}
 
bool bCreateCollidersForTriangleMeshDrawings {false}
 
double MinimumPointDistance = 3.0
 
double HoverPointDistance = 1.0
 
FString ThumbnailBase64DataURI
 

Member Function Documentation

◆ AddPoint()

bool AI3DHDrawingEditor::AddPoint ( const FVector & Location,
bool bIsWorldSpace = false )

Adds a Spline point at the given location to the active Spline (actor local space unless bIsWorldSpace is true).

If no Spline is active, a new one is created. The point is not added if the world-space distance to the previous point is less than AI3DHDrawingEditor::MinimumPointDistance.

Parameters
LocationThe location.
bIsWorldSpaceIf true, Location is interpreted in world space; otherwise in this actor's local space.
Returns
True if a point was added; otherwise false.

◆ AddPointAtCursor()

void AI3DHDrawingEditor::AddPointAtCursor ( )

Adds a Spline point at the cursor position to the active Spline.

If no Spline is active, a new one is created. New points are not added if the world-space distance to the previous point is less than AI3DHDrawingEditor::MinimumPointDistance.

◆ BeginNewSpline()

void AI3DHDrawingEditor::BeginNewSpline ( )

Begins a new Spline that is discontinuous from the previous Spline.

Does not create a new Spline if the currently active Spline is empty.

◆ BeginNewSplineSlice()

void AI3DHDrawingEditor::BeginNewSplineSlice ( )

Begins a new Slice; the next points belong to this Slice.

A Slice groups a contiguous range of points within a Spline, allowing operations on that set of points. A common use case is to remove the last Slice with AI3DHDrawingEditor::RemoveLastSplineSlice.

◆ Clear()

void AI3DHDrawingEditor::Clear ( )

Removes all Splines and points from this drawing, leaving it empty.

◆ CreateDrawingEditor()

static AI3DHDrawingEditor * AI3DHDrawingEditor::CreateDrawingEditor ( AI3DHConnector * HubConnector,
TSubclassOf< AI3DHDrawingEditor > DrawingClass )
static

Creates an actor which can be used for drawing and syncing to instant3Dhub when finished.

Parameters
HubConnectorThe AI3DHConnector to attach to.
DrawingClassThe editor class to spawn.
Returns
Nullptr on failure; otherwise the new AI3DHDrawingEditor.

◆ CreateHubDrawingAndDestroy()

void AI3DHDrawingEditor::CreateHubDrawingAndDestroy ( const FString & Name,
TUniqueFunction< void(int32 DrawingHandle, EI3DHErrorCode ErrorCode)> OnComplete )

Finalizes the drawing, synchronizes it with instant3Dhub and destroys this actor.

Note
Must be called on the game thread.
If the drawing is empty, synchronization is skipped and OnComplete is called with (0, EI3DHErrorCode::Success). The actor is destroyed in both cases.
Parameters
NameThe name of the drawing.
OnCompleteCallback called on completion with the drawing handle and error code.

◆ FinalizeDrawing()

void AI3DHDrawingEditor::FinalizeDrawing ( TUniqueFunction< void(FI3DHDrawingResult)> OnComplete)

Finalizes the drawing.

Disables further editing and computes export geometries.

  • After this call, the editor enters EI3DHDrawingEditorMode::Finalize and cannot leave it.
  • Positions in FI3DHDrawingResult are relative to the HubConnector (AI3DHConnector).
  • Splines that don't produce geometry are not part of the export geometry.

Helper queries available after finalize:

Note
Must be called on the game thread.
Parameters
OnCompleteCallback called on completion with the FI3DHDrawingResult.

◆ GetDrawingColor()

FLinearColor AI3DHDrawingEditor::GetDrawingColor ( ) const

Retrieves the color currently used for drawing.

Returns
The drawing color.

◆ GetDrawingEditorMode()

EI3DHDrawingEditorMode AI3DHDrawingEditor::GetDrawingEditorMode ( ) const
inline

Returns the current DrawingEditor Mode.

Returns
The current mode.

◆ GetDrawingScale()

double AI3DHDrawingEditor::GetDrawingScale ( ) const

Retrieves the scale currently used for drawing.

Typically, a scale of 1 equals 1 centimeter.

Returns
The drawing scale.

◆ GetEditedDrawingName()

const FString & AI3DHDrawingEditor::GetEditedDrawingName ( ) const
inline

Returns the name of drawing if this editor is editing an existing drawing.

Returns
Name of the drawing being edited, or an empty string if this editor is creating a new drawing.

◆ GetFinalizedSplineIndices()

TArray< int32 > AI3DHDrawingEditor::GetFinalizedSplineIndices ( ) const
inline

Returns the indices (into AI3DHDrawingEditor::GetSplines) of all splines that produced exportable geometry during the last finalize.

Note
Returns an empty array before the drawing has been finalized.
Returns
The indices of finalized splines.

◆ GetFinalizedSplineMask()

const TBitArray & AI3DHDrawingEditor::GetFinalizedSplineMask ( ) const
inline

Returns the bitmask of finalized splines.

Note
Empty before finalize. Same indexing as AI3DHDrawingEditor::GetSplines
Returns
Mask with bit set to true for finalized splines.

◆ GetHubConnector()

AI3DHConnector * AI3DHDrawingEditor::GetHubConnector ( ) const
inline

Returns the parent hub connector.

Returns
The parent hub connector.

◆ GetNumFinalizedSplines()

int32 AI3DHDrawingEditor::GetNumFinalizedSplines ( ) const
inline

Returns the number of splines that produced exportable geometry during finalize.

Note
Returns 0 before the drawing has been finalized.
Returns
Number of finalized splines.

◆ GetSplines()

const TArray< FI3DHSplineData > & AI3DHDrawingEditor::GetSplines ( ) const
inline

Returns all Spline data currently in the editor.

Note
Points are relative to this actor.
Returns
The Splines.

◆ InitFromSplines() [1/2]

void AI3DHDrawingEditor::InitFromSplines ( const TArray< FI3DHSplineData > & InSplines)

Clears all Splines and initializes the editor from the provided Splines.

Parameters
InSplinesThe new set of Splines.

◆ InitFromSplines() [2/2]

void AI3DHDrawingEditor::InitFromSplines ( TArray< FI3DHSplineData > && InSplines)

Clears all Splines and initializes the editor from the provided Splines (move version).

Parameters
InSplinesThe new set of Splines (moved).

◆ IsEmpty()

bool AI3DHDrawingEditor::IsEmpty ( ) const

Returns true if the drawing has no content.

Returns
True if there are no Splines, or if there is exactly one empty Spline (no points); false otherwise.

◆ MoveCursorTo()

void AI3DHDrawingEditor::MoveCursorTo ( const FVector & Location)

Sets the cursor location.

Note
Only available in EI3DHDrawingEditorMode::Draw
Parameters
LocationThe location, interpreted in world space.

◆ NumSplines()

int32 AI3DHDrawingEditor::NumSplines ( ) const

Returns the number of Splines the drawing consists of.

Note
Includes potential empty Splines. Use AI3DHDrawingEditor::IsEmpty to check if empty.
Returns
The total number of Splines.

◆ RemoveLastSplineSlice()

bool AI3DHDrawingEditor::RemoveLastSplineSlice ( )

Removes the last Slice from the active Spline.

Returns
True if no Slice remains afterwards; otherwise false.

◆ Restore()

void AI3DHDrawingEditor::Restore ( )

Restores the drawing to its initial state.

  • If this editor is editing an existing drawing, it restores the original content.
  • If this editor is creating a new drawing, it clears the current content.

◆ SelectNearestPoint()

bool AI3DHDrawingEditor::SelectNearestPoint ( const FVector & Location,
bool bIsWorldSpace = false )

Selects the nearest endpoint (start or end) within AI3DHDrawingEditor::HoverPointDistance of the given location.

Note
Selecting the first point reverses the Spline (including Slice indices) so subsequent points are appended.
Parameters
LocationThe location.
bIsWorldSpaceIf true, Location is interpreted in world space; otherwise in this actor's local space.
Returns
False if nothing changed (no point found or the same endpoint was already active); true otherwise.

◆ SelectNearestPointAtCursor()

bool AI3DHDrawingEditor::SelectNearestPointAtCursor ( )

Selects the nearest endpoint (start or end) within AI3DHDrawingEditor::HoverPointDistance of the current cursor location.

Note
Selecting the first point reverses the Spline (including Slice indices) so subsequent points are appended.
Returns
False if nothing changed (no point found or the same endpoint was already active); true otherwise.

◆ SetDrawingColor()

void AI3DHDrawingEditor::SetDrawingColor ( const FLinearColor & Color)

Sets the color used for drawing and applies it to the active Spline.

Parameters
ColorThe drawing color.

◆ SetDrawingMode()

void AI3DHDrawingEditor::SetDrawingMode ( EI3DHDrawingEditorMode InDrawingMode)

Sets the DrawingEditor Mode.

Parameters
InDrawingModeThe new mode (affects visualization and available actions).

◆ SetDrawingScale()

void AI3DHDrawingEditor::SetDrawingScale ( const double & Scale)

Sets the scale used for drawing and applies it to the active Spline.

Typically, a scale of 1 equals 1 centimeter.

Parameters
ScaleThe drawing scale.

◆ SetOmitStrokeStartAndEndJoints()

void AI3DHDrawingEditor::SetOmitStrokeStartAndEndJoints ( bool bNewOmitJoints)

Controls whether the first and last sample point of Splines are rendered with a joint.

Deprecated
Deprecated in v1.1.0. "Will be removed because it is not supported for LineStrip drawings."
Please update your code to the new instant3Dhub API before upgrading to the next release, otherwise your project will no longer compile.
Parameters
bNewOmitJointsTrue to omit joints for the first and last point.

◆ SetShowActiveSliceControlPoints()

void AI3DHDrawingEditor::SetShowActiveSliceControlPoints ( bool bNewShowActiveSliceControlPoints)

Controls whether all ControlPoints belonging to the active Slice should be visualized.

Parameters
bNewShowActiveSliceControlPointsTrue to show control points of the active Slice.

◆ WasSplineFinalized()

bool AI3DHDrawingEditor::WasSplineFinalized ( int32 SplineIndex) const
inline

Tests whether the given editor spline index produced exportable geometry during the last finalize.

Note
Returns false before the drawing has been finalized.
Parameters
SplineIndexIndex into AI3DHDrawingEditor::GetSplines
Returns
True if this spline was exported during finalize.

Member Data Documentation

◆ bCreateCollidersForTriangleMeshDrawings

bool AI3DHDrawingEditor::bCreateCollidersForTriangleMeshDrawings {false}

Whether to create complex colliders for triangle mesh drawings.

Needed only for physics interactions or queries on the meshes.

◆ bCreateLineStripDrawings

bool AI3DHDrawingEditor::bCreateLineStripDrawings {true}

If enabled, export LINE_STRIP drawings.

Otherwise export triangle meshes (TRIANGLES).

Note
This feature is only available if FI3DHDrawingAPI::SupportsWorldSpaceDrawings and will be ignored at runtime if not supported.

◆ HoverPointDistance

double AI3DHDrawingEditor::HoverPointDistance = 1.0

World-space distance (Unreal units) used to hover/select ControlPoints.

◆ MinimumPointDistance

double AI3DHDrawingEditor::MinimumPointDistance = 3.0

Minimum world-space distance (Unreal units) between consecutive points added to the active Spline.

◆ ThumbnailBase64DataURI

FString AI3DHDrawingEditor::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: