ClipPlane API

instant3Dhub: ClipPlane API
instant3Dhub

Detailed Description

Clip planes hide the geometry on one side of a user-defined plane to reveal the interior of a 3D model.

There are two main aspects to support clipping in Unreal Engine. Each clip plane has an associated clip plane actor, which is responsible for the visual elements of the plane itself (e.g. grid, arrow). The actual clipping is implemented in the geometry materials (see /Content/instant3Dhub/Internal/Materials/MF_I3DHClipPlaneOpacity).

You can override which class is used for the clip plane actors using AI3DHConnector::ClipPlaneActorClass. Note that the FI3DHClipPlaneAPI manages the lifecycle and the "Hidden In Game" state of the clip plane actors; the application should not spawn / destroy clip plane actors or change the "Hidden In Game" state of the actors manually.

Currently, the transformation of the clip plane actors is the source of truth for each clip plane. To change a clip plane it is sufficient to set a new transformation on the clip plane actor and the change will automatically be synced to other clients in the session (note also that the transformation of an actor might be changed by the FI3DHClipPlaneAPI, to reflect changes made by other clients).

The plugin supports a maximum of 8 clip planes. Additional clip planes can be created via the API, but they will not affect the geometry (and no corresponding clip plane actor will be spawned).

Topics

 Get Clip Planes
 

Classes

class  FI3DHClipPlaneAPI
 

Functions

TArray< int32 > AI3DHConnector::GetClipPlanes ()
 
AActorAI3DHConnector::FindClipPlaneActor (int32 ClipPlaneId)
 
AActorAI3DHConnector::GetMainClipPlaneActor ()
 
static FPlane UI3DHUtilities::MakePlaneFromClipPlaneActor (const AActor *ClipPlaneActor)
 
static bool UI3DHUtilities::ClipLineSegmentByPlane (FVector &Start, FVector &End, const FPlane &Plane)
 
static bool UI3DHUtilities::ClipLineSegmentByMainClipPlane (AI3DHConnector *HubConnector, FVector &Start, FVector &End)
 
static bool UI3DHUtilities::ClipLineSegmentByClipPlanes (AI3DHConnector *HubConnector, FVector &Start, FVector &End)
 

Variables

FClipPlaneCreatedDelegate AI3DHConnector::OnClipPlaneCreatedDelegate
 
FClipPlaneRemovedDelegate AI3DHConnector::OnClipPlaneRemovedDelegate
 
float AI3DHConnector::ClipPlaneSyncHz = 1.0
 
TSubclassOf< AActorAI3DHConnector::ClipPlaneActorClass = nullptr
 

Advanced API

The advanced API allows you to manage multiple clip planes.

virtual void FI3DHClipPlaneAPI::CreateClipPlane (const FI3DHClipPlaneProperties &Properties, TUniqueFunction< void(int32 ClipPlaneId, EI3DHErrorCode ErrorCode)> OnComplete)=0
 
virtual void FI3DHClipPlaneAPI::ChangeClipPlane (int32 ClipPlaneId, const FI3DHClipPlaneProperties &Properties, TUniqueFunction< void(EI3DHErrorCode ErrorCode)> OnComplete)=0
 
virtual void FI3DHClipPlaneAPI::GetClipPlaneProperties (int32 ClipPlaneId, TUniqueFunction< void(const FI3DHClipPlaneProperties &Properties, EI3DHErrorCode ErrorCode)> OnComplete)=0
 
virtual void FI3DHClipPlaneAPI::RemoveClipPlane (int32 ClipPlaneId, TUniqueFunction< void(EI3DHRemoveState RemoveState, EI3DHErrorCode ErrorCode)> OnComplete)=0
 
virtual TArray< int32 > FI3DHClipPlaneAPI::GetClipPlanes ()=0
 
virtual AActorFI3DHClipPlaneAPI::FindClipPlaneActor (int32 ClipPlaneId)=0
 

Basic API

The basic API allows you to manage a single clip plane only. One of the regular clip planes will be designated the main clip plane. Usually this is the first clip plane created by webvis. If there is no main clip plane, when you call FI3DHClipPlaneAPI::EnableMainClipPlane, then a new clip plane is automatically created for you.

virtual void FI3DHClipPlaneAPI::EnableMainClipPlane (TUniqueFunction< void(EI3DHErrorCode ErrorCode)> OnComplete)=0
 
virtual void FI3DHClipPlaneAPI::DisableMainClipPlane (TUniqueFunction< void(EI3DHErrorCode ErrorCode)> OnComplete)=0
 
virtual AActorFI3DHClipPlaneAPI::GetMainClipPlaneActor ()=0
 

Function Documentation

◆ ChangeClipPlane()

virtual void FI3DHClipPlaneAPI::ChangeClipPlane ( int32 ClipPlaneId,
const FI3DHClipPlaneProperties & Properties,
TUniqueFunction< void(EI3DHErrorCode ErrorCode)> OnComplete )
pure virtual

Changes one or more properties of the clip plane with the specified ID.

Parameters
ClipPlaneIdThe ID of the clip plane to change.
PropertiesNew properties. Unset properties keep their value.
OnCompleteCallback called on completion.

◆ ClipLineSegmentByClipPlanes()

static bool UI3DHUtilities::ClipLineSegmentByClipPlanes ( AI3DHConnector * HubConnector,
FVector & Start,
FVector & End )
static

Clip a line segment to the positive half space (the side with the normal pointing upwards) of all ClipPlanes (if any).

Parameters
HubConnectorThe hub connector used to retrieve all ClipPlanes.
StartStart location of the line segment.
EndEnd location of the line segment.
Returns
False if the LineSegment is completely clipped. True otherwise.
See also
FI3DHClipPlaneAPI::GetClipPlanes

◆ ClipLineSegmentByMainClipPlane()

static bool UI3DHUtilities::ClipLineSegmentByMainClipPlane ( AI3DHConnector * HubConnector,
FVector & Start,
FVector & End )
static

Clip a line segment to the positive half space (the side with the normal pointing upwards) of the Main ClipPlane (if any).

Parameters
HubConnectorThe hub connector used to retrieve the Main ClipPlane.
StartStart location of the line segment.
EndEnd location of the line segment.
Returns
False if the LineSegment is completely clipped. True otherwise.
See also
FI3DHClipPlaneAPI::GetMainClipPlaneActor

◆ ClipLineSegmentByPlane()

static bool UI3DHUtilities::ClipLineSegmentByPlane ( FVector & Start,
FVector & End,
const FPlane & Plane )
static

Clip a line segment to the positive half space (the side with the normal pointing upwards) of a plane.

Parameters
StartStart location of the line segment.
EndEnd location of the line segment.
PlaneThe plane to clip the line against.
Returns
False if the LineSegment lies completely inside the negative half space.
See also
MakePlaneFromClipPlaneActor

◆ CreateClipPlane()

virtual void FI3DHClipPlaneAPI::CreateClipPlane ( const FI3DHClipPlaneProperties & Properties,
TUniqueFunction< void(int32 ClipPlaneId, EI3DHErrorCode ErrorCode)> OnComplete )
pure virtual

Creates a new clip plane.

Parameters
PropertiesProperties of the new clip plane.
OnCompleteCallback called on completion.

◆ DisableMainClipPlane()

virtual void FI3DHClipPlaneAPI::DisableMainClipPlane ( TUniqueFunction< void(EI3DHErrorCode ErrorCode)> OnComplete)
pure virtual

Disables the main clip plane.

Parameters
OnCompleteAsync callback.

◆ EnableMainClipPlane()

virtual void FI3DHClipPlaneAPI::EnableMainClipPlane ( TUniqueFunction< void(EI3DHErrorCode ErrorCode)> OnComplete)
pure virtual

Enables the main clip plane.

Parameters
OnCompleteAsync callback.

◆ FindClipPlaneActor() [1/2]

AActor * AI3DHConnector::FindClipPlaneActor ( int32 ClipPlaneId)

Gets clip plane actor for a specific clip plane.

Note
Must be called from the game thread.
Returns
The ClipPlane Actor if there is one, otherwise nullptr.

◆ FindClipPlaneActor() [2/2]

virtual AActor * FI3DHClipPlaneAPI::FindClipPlaneActor ( int32 ClipPlaneId)
pure virtual

Gets clip plane actor for a specific clip plane.

Note
Must be called from the game thread.
Can return nullptr, even if the ClipPlaneId is valid, if the clip plane rendering limit of the plugin has been reached.
Returns
The ClipPlane Actor if there is one, otherwise nullptr.

◆ GetClipPlaneProperties()

virtual void FI3DHClipPlaneAPI::GetClipPlaneProperties ( int32 ClipPlaneId,
TUniqueFunction< void(const FI3DHClipPlaneProperties &Properties, EI3DHErrorCode ErrorCode)> OnComplete )
pure virtual

Retrieves the properties of a clip plane.

Parameters
ClipPlaneIdThe ID of the clip plane.
OnCompleteCallback called on completion.

◆ GetClipPlanes() [1/2]

TArray< int32 > AI3DHConnector::GetClipPlanes ( )

Returns the IDs of the currently existing clip planes.

Note
Must be called from the game thread.

◆ GetClipPlanes() [2/2]

virtual TArray< int32 > FI3DHClipPlaneAPI::GetClipPlanes ( )
pure virtual

Returns the IDs of the currently existing clip planes.

Note
Must be called from the game thread.

◆ GetMainClipPlaneActor() [1/2]

AActor * AI3DHConnector::GetMainClipPlaneActor ( )

Gets the main clip plane actor.

Returns
The ClipPlane Actor if there is one, otherwise nullptr.

◆ GetMainClipPlaneActor() [2/2]

virtual AActor * FI3DHClipPlaneAPI::GetMainClipPlaneActor ( )
pure virtual

Gets main clip plane actor.

Returns
The ClipPlane Actor if there is one, otherwise nullptr.

◆ MakePlaneFromClipPlaneActor()

static FPlane UI3DHUtilities::MakePlaneFromClipPlaneActor ( const AActor * ClipPlaneActor)
static

Makes a plane structure from the clip plane actor with its world space location as plane origin and its world space up-vector as plane normal.

Parameters
ClipPlaneActorThe clip plane actor (must not be null).
Returns
The plane structure of the clip actor.
See also
FI3DHClipPlaneAPI::FindClipPlaneActor

◆ RemoveClipPlane()

virtual void FI3DHClipPlaneAPI::RemoveClipPlane ( int32 ClipPlaneId,
TUniqueFunction< void(EI3DHRemoveState RemoveState, EI3DHErrorCode ErrorCode)> OnComplete )
pure virtual

Removes a clip plane.

Parameters
ClipPlaneIdThe ID of the clip plane.
OnCompleteCallback called on completion.

Variable Documentation

◆ ClipPlaneActorClass

TSubclassOf<AActor> AI3DHConnector::ClipPlaneActorClass = nullptr

Actor class used to render a clip plane.

Parts in local -z direction of the actor will be clipped.