AI3DHInteractiveSplatDrawing Class Reference

instant3Dhub: AI3DHInteractiveSplatDrawing Class Reference
instant3Dhub

#include "I3DHInteractiveSplatDrawing.h"

+ Inheritance diagram for AI3DHInteractiveSplatDrawing:
+ Collaboration diagram for AI3DHInteractiveSplatDrawing:

Detailed Description

A helper for creating splat-based drawings in the scene that are synced to the session when finished.

A "splat" in this context is the (usually 2D) geometry used as the brush mesh. Drawing with the brush will leave a copy of this geometry at the brush location. The class is intended to draw on another geometries surface, using the surface normal to orient the brush.

(Blueprint) Class Setup:

  • Select a mesh to use as a brush. This is usually a 2D shape in the x-y plane. The size of this mesh defines the unit the brush will have at scale == 1. The brush mesh needs to be CPU accessible for the finalization step.

Typical usage:

  • MoveBrushTo(..) places the configured brush mesh in the scene. The brush is visible by default and shows where the user would paint.
  • DrawAtBrush() adds the current brush transformation to the drawing. The implementation might optimize this and e.g. reject transformations to close to the existing drawing.
  • AsyncCreateHubDrawingAndDestroy(..) finalizes the drawing, syncs it with the session and removes this actor.

Implementation-wise the actor uses one instanced static mesh component per color for rendering.

Public Member Functions

void InitializePreSpawn (AI3DHConnector *ParentHubConnector)
 
AI3DHConnectorGetHubConnector () const
 
void SetBrushAndEraserColor (const FLinearColor &Color)
 
FLinearColor GetBrushAndEraserColor () const
 
void SetBrushHiddenInGame (bool bIsHiddenInGame)
 
void MoveBrushTo (const FVector &Location, const FVector &Normal, const FVector &Scale) const
 
void DrawAtBrush ()
 
void EraseAtBrush (bool bEraseAllColors=false)
 
bool IsEmpty () const
 
void Clear ()
 
void FinalizeDrawing (TUniqueFunction< void(FI3DHDrawingResult)> OnComplete)
 
void CreateHubDrawingAndDestroy (const FString &Name, TUniqueFunction< void(int DrawingHandle, EI3DHErrorCode ErrorCode)> OnComplete)
 

Static Public Member Functions

static AI3DHInteractiveSplatDrawingCreateInteractiveSplatDrawing (AI3DHConnector *HubConnector, TSubclassOf< AI3DHInteractiveSplatDrawing > DrawingClass=nullptr)
 

Public Attributes

double MinBrushDist = 0.25
 
double EraserRelativeSize = 0.75
 
double DrawingNormalOffset = 0.01
 
FString ThumbnailBase64DataURI
 

Member Function Documentation

◆ CreateHubDrawingAndDestroy()

void AI3DHInteractiveSplatDrawing::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
NameThe name of the drawing.
OnCompleteCallback called on completion.

◆ CreateInteractiveSplatDrawing()

static AI3DHInteractiveSplatDrawing * AI3DHInteractiveSplatDrawing::CreateInteractiveSplatDrawing ( AI3DHConnector * HubConnector,
TSubclassOf< AI3DHInteractiveSplatDrawing > DrawingClass = nullptr )
static

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

Parameters
HubConnectorThe hub connector.
DrawingClassThe drawing class.
Returns
Nullptr if it fails, else the new interactive splat drawing.

◆ DrawAtBrush()

void AI3DHInteractiveSplatDrawing::DrawAtBrush ( )

Adds the current brush transformation to the drawing.

The implementation might optimize this and e.g. reject transformations too close to the existing drawing depending on the value of MinBrushDist.

◆ EraseAtBrush()

void AI3DHInteractiveSplatDrawing::EraseAtBrush ( bool bEraseAllColors = false)

Uses the eraser at the current brush transformation for either the active color or every color.

Size of the eraser is controlled by EraserRelativeSize.

Parameters
bEraseAllColorsTrue to erase all colors.

◆ FinalizeDrawing()

void AI3DHInteractiveSplatDrawing::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
OnCompleteCallback called on completion.

◆ GetBrushAndEraserColor()

FLinearColor AI3DHInteractiveSplatDrawing::GetBrushAndEraserColor ( ) const

Gets brush and eraser color.

Returns
The brush and eraser color.

◆ GetHubConnector()

AI3DHConnector * AI3DHInteractiveSplatDrawing::GetHubConnector ( ) const
inline

Returns the parent hub connector.

Returns
The parent hub connector.

◆ InitializePreSpawn()

void AI3DHInteractiveSplatDrawing::InitializePreSpawn ( AI3DHConnector * ParentHubConnector)

Call before (deferred) spawning.

Parameters
ParentHubConnectorThe parent hub connector.

◆ IsEmpty()

bool AI3DHInteractiveSplatDrawing::IsEmpty ( ) const

Query if this Drawing is empty.

Returns
True if empty, false if not.

◆ MoveBrushTo()

void AI3DHInteractiveSplatDrawing::MoveBrushTo ( const FVector & Location,
const FVector & Normal,
const FVector & Scale ) const

Set a new location of the brush.

Parameters
LocationThe location.
NormalThe normal determines the direction the brush will "look at". If drawing on other geometry, this should be the surface normal.
ScaleThe scale.

◆ SetBrushAndEraserColor()

void AI3DHInteractiveSplatDrawing::SetBrushAndEraserColor ( const FLinearColor & Color)

Sets brush and eraser color.

Parameters
ColorThe color.

◆ SetBrushHiddenInGame()

void AI3DHInteractiveSplatDrawing::SetBrushHiddenInGame ( bool bIsHiddenInGame)

Sets the brush to be hidden in game.

Parameters
bIsHiddenInGameTrue if is hidden in game, false if not.

Member Data Documentation

◆ DrawingNormalOffset

double AI3DHInteractiveSplatDrawing::DrawingNormalOffset = 0.01

Offset along the normal when moving the brush (in world units).

Alleviates z-fighting with the drawn-on surface independent of the used material.

◆ ThumbnailBase64DataURI

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