120class AI3DHConnector : public AActor
125 INSTANT3DHUB_API AI3DHConnector();
129 INSTANT3DHUB_API virtual void BeginPlay() override;
130 INSTANT3DHUB_API virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
132 INSTANT3DHUB_API virtual void Tick(float DeltaTime) override;
135 INSTANT3DHUB_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
138 // ----------------------------------------------------------
140 // ----------------------------------------------------------
149 INSTANT3DHUB_API TSharedPtr<FI3DHConnectorAPI> GetAPI() const;
151 // ----------------------------------------------------------
153 // ----------------------------------------------------------
161 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3Dhub}|Connector
")
162 INSTANT3DHUB_API void AddNetworkCredentialCookie(const FString& CookieKey, const FString& CookieValue);
169 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3Dhub}|Connector
")
170 INSTANT3DHUB_API void RemoveNetworkCredentialCookie(const FString& CookieKey);
178 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3Dhub}|Connector
")
179 INSTANT3DHUB_API void AddNetworkCredentialToken(const FString& TokenKey, const FString& TokenValue);
186 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3Dhub}|Connector
")
187 INSTANT3DHUB_API void RemoveNetworkCredentialToken(const FString& TokenKey);
194 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
195 INSTANT3DHUB_API const TMap<FString, FString>& GetNetworkCredentialCookies() const { return NetworkCredentialCookies; }
202 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
203 INSTANT3DHUB_API const TMap<FString, FString>& GetNetworkCredentialTokens() const { return NetworkCredentialTokens; }
244 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Connector
")
245 INSTANT3DHUB_API void ConnectToHub(const FString& HubURL, const FString& SessionId);
257 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Connector
")
258 INSTANT3DHUB_API void ConnectToHubWithOptions(const FString& HubURL, const FI3DHConnectOptions& Options);
272 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Connector
")
273 INSTANT3DHUB_API void Disconnect();
281 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
282 INSTANT3DHUB_API bool IsDisconnected() const;
290 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
291 INSTANT3DHUB_API bool IsEstablishingConnectionToHub() const;
298 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
299 INSTANT3DHUB_API bool IsConnectedToHub() const;
306 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
307 INSTANT3DHUB_API FString GetHubURL() const;
314 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
315 INSTANT3DHUB_API FString GetSessionId() const;
324 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Connector
")
325 FConnectedDelegate OnConnectedDelegate;
333 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Connector
")
334 FConnectErrorDelegate OnConnectErrorDelegate;
344 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Connector
")
345 FErrorDelegate OnErrorDelegate;
353 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Connector
")
354 FDisconnectedDelegate OnDisconnectedDelegate;
361 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
362 INSTANT3DHUB_API FMatrix GetOriginToWorldTransform() const;
369 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
370 INSTANT3DHUB_API FMatrix GetWorldToOriginTransform() const;
375 INSTANT3DHUB_API AActor* GetOriginActor()
377 AActor* RootActor = this;
378 check(RootActor != nullptr);
385 INSTANT3DHUB_API const AActor* GetOriginActor() const
387 const AActor* RootActor = this;
388 check(RootActor != nullptr);
395 // ----------------------------------------------------------
396 // Internal Connection Helper Functions
397 // ----------------------------------------------------------
399 void OnBackendConnected_Internal_GameThread(const FString& SessionId);
400 void OnBackendError_Internal_GameThread(const FString& ErrorMessage);
402 void ReportError_Internal_GameThread(const FString& ErrorMessage);
403 void ReportConnectError_Internal_GameThread(const FString& ErrorMessage);
404 bool Disconnect_Internal_GameThread();
409 // ----------------------------------------------------------
411 // ----------------------------------------------------------
427 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Debugging
")
428 INSTANT3DHUB_API bool RequestRemoteCullerDebugStream();
442 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Debugging
")
443 INSTANT3DHUB_API UTexture2D* GetRemoteCullerDebugStreamTexture();
456 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Debugging
")
457 INSTANT3DHUB_API const TArray<FI3DHDebugMetric>& GetDebugMetrics();
470 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Debugging
")
471 INSTANT3DHUB_API FString GetDebugSessionInfo();
473 // ----------------------------------------------------------
475 // ----------------------------------------------------------
489 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Progress
")
490 INSTANT3DHUB_API FI3DHClientProgress GetClientProgress();
492 // ----------------------------------------------------------
494 // ----------------------------------------------------------
500 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Clip Plane API
")
501 FClipPlaneCreatedDelegate OnClipPlaneCreatedDelegate;
507 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Clip Plane API
")
508 FClipPlaneRemovedDelegate OnClipPlaneRemovedDelegate;
515 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "0.1
", ClampMax = "120.0
", UIMin = "0.1
", UIMax = "120.0
"), Category = "{instant3Dhub}|Clip Plane API
")
516 float ClipPlaneSyncHz = 1.0;
522 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Clip Plane API
")
523 TSubclassOf<AActor> ClipPlaneActorClass = nullptr;
530 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Clip Plane API
")
531 INSTANT3DHUB_API TArray<int32> GetClipPlanes();
539 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Clip Plane API
")
540 INSTANT3DHUB_API AActor* FindClipPlaneActor(int32 ClipPlaneId);
547 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Clip Plane API
")
548 INSTANT3DHUB_API AActor* GetMainClipPlaneActor();
550 // ----------------------------------------------------------
552 // ----------------------------------------------------------
561 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Drawing API
", AdvancedDisplay)
562 TObjectPtr<UMaterialInterface> DrawingBaseMaterial{nullptr};
571 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Drawing API
", AdvancedDisplay)
572 TObjectPtr<class UStaticMesh> DrawingSegmentMesh{nullptr};
580 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Drawing API
", AdvancedDisplay)
581 TObjectPtr<class UStaticMesh> DrawingJointMesh{nullptr};
590 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing API
", meta = (DisplayName = "Create Drawing Material
"))
591 INSTANT3DHUB_API UMaterialInterface* GetDrawingMaterial(FLinearColor Color);
600 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing API
")
601 INSTANT3DHUB_API class AI3DHDrawing* FindDrawingActor(int32 DrawingHandle);
609 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing API
")
610 INSTANT3DHUB_API void SetClipDrawingsByClipPlane(const bool bClipDrawingsByClipPlaneEnabled);
618 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing API
")
619 INSTANT3DHUB_API bool GetClipDrawingsByClipPlane();
621 // ----------------------------------------------------------
623 // ----------------------------------------------------------
638 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
EditDrawing API
")
639 virtual void EditDrawing(int32 DrawingHandle, const TScriptInterface<class II3DHEditDrawingInterface>& EditDrawingInterface, bool bIsEditingCopy = false);
641 // ----------------------------------------------------------
643 // ----------------------------------------------------------
651 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|
Instance Graph API
")
652 INSTANT3DHUB_API int32 GetGlobalRootNodeId();
655 // ----------------------------------------------------------
657 // ----------------------------------------------------------
665 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Selection API
")
666 INSTANT3DHUB_API TArray<int32> GetSelection();
668 // ----------------------------------------------------------
669 // TransformAuthority API
670 // ----------------------------------------------------------
672 INSTANT3DHUB_EXPERIMENTAL(0.0.23, "TransformAuthorityAPI is a temporary solution suspect to changes or replacement.
")
681 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
Transform Authority
", meta = (DisplayName = "Get WorldTransform With Authority (Experimental)
"))
682 INSTANT3DHUB_API bool GetWorldTransformWithAuthority(const FI3DHTransformAuthorityHandle TransformAuthorityHandle, int32 NodeId, FMatrix& OutWorldTransform);
684 INSTANT3DHUB_EXPERIMENTAL(0.0.23, "TransformAuthorityAPI is a temporary solution suspect to changes or replacement.
")
692 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
Transform Authority
", meta = (DisplayName = "Set WorldTransform With Authority (Experimental)
"))
693 INSTANT3DHUB_API void SetWorldTransformWithAuthority(const FI3DHTransformAuthorityHandle TransformAuthorityHandle, int32 NodeId, const FMatrix& WorldTransform);
695 INSTANT3DHUB_EXPERIMENTAL(0.0.23, "TransformAuthorityAPI is a temporary solution suspect to changes or replacement.
")
702 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
Transform Authority
", meta = (DisplayName = "Release TransformAuthority (Experimental)
"))
703 INSTANT3DHUB_API void ReleaseTransformAuthority(const FI3DHTransformAuthorityHandle TransformAuthorityHandle);
705 INSTANT3DHUB_EXPERIMENTAL(0.0.23, "TransformAuthorityAPI is a temporary solution suspect to changes or replacement.
")
711 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
Transform Authority
", meta = (DisplayName = "Is TransformAuthority Active (Experimental)
"))
712 INSTANT3DHUB_API bool IsTransformAuthorityActive(const FI3DHTransformAuthorityHandle TransformAuthorityHandle) const;
714 // ----------------------------------------------------------
715 // Runtime adjustable performance parameters
716 // ----------------------------------------------------------
719 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3Dhub}|Connector
", meta = (ClampMin = 1, UIMin = 1))
720 int32 MaxConversionTasksCreatedPerTick = 8;
723 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3Dhub}|Connector
", meta = (ClampMin = 1, UIMin = 1))
724 int32 MaxComponentsCreatedPerTick = 2;
731 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3Dhub}|Connector
", meta = (ClampMin = 0, UIMin = 0, Delta = 1000000))
732 int32 TargetedTrianglesOnComponentsWithVisibility = 10000000;
738 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "0.1
", ClampMax = "100.0
", UIMin = "0.1
", UIMax = "100.0
"), Category = "{instant3Dhub}|Connector
")
739 float CreateComponentsBudgetMs = 5.0f;
745 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "0.1
", ClampMax = "120.0
", UIMin = "0.1
", UIMax = "120.0
"), Category = "{instant3Dhub}|Connector
")
746 float ViewSyncHz = 5.0;
753 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Connector
")
754 TObjectPtr<class UMaterialParameterCollection> I3DHParameterCollection = nullptr;
756 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
758 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Connector
")
759 TSubclassOf<AI3DHGeometry> GeometryActorClass;
760 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
763 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Connector
")
764 bool bSpawnedGeometryCastsShadow = false;
768 UPROPERTY(VisibleAnywhere, Category = "{instant3Dhub}|Connector
")
769 TObjectPtr<USceneComponent> RootComponentConnector;
772 // ----------------------------------------------------------
774 // ----------------------------------------------------------
776 FI3DHConnectorDrawingStorage& GetDrawingStorage();
777 const FI3DHConnectorDrawingStorage& GetDrawingStorage() const;
779 FI3DHConnectorRenderStorage& GetRenderStorage();
780 const FI3DHConnectorRenderStorage& GetRenderStorage() const;
782 const FI3DHConnectorRenderStats& GetRenderStats() const;
784 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
786 AI3DHGeometry* FindGeometryActor(int32 RootNodeId);
787 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
789 UMaterialParameterCollectionInstance* GetI3DHParameterCollectionInstance() const;
792 TMap<FString, FString> NetworkCredentialCookies;
793 TMap<FString, FString> NetworkCredentialTokens;
798 // Updated in ConnectToHubWithOptions().
799 // While connected, contains the value of the current connection.
800 bool bUseSenLinBackend = false;
802 bool bReloadKeyPressedLastFrame = false;
803 bool bDebugStreamKeyPressedLastFrame = false;
805 // Timings for measuring time to first pixel.
806 // All values in seconds of platform time.
808 // Note that the camera position and orientation can influence the timings
809 // via effects on the remote culler. For accurate measurements the camera
810 // should be in a fixed position pointing at the scene.
812 double FirstVisibilityTime;
813 double FirstActorTime;
815 // Time estimates for CreateMeshComponents budgeting.
816 // The estimates are updated using exponential moving averages.
817 // For the physics build we assume (based on our tests) that
818 // the constant overhead is negligible and the time is
819 // fully dependent on the per-triangle cost.
820 // Initial values are based on measurements on my computer.
821 double EstimatedSpawnGeometryActorTime = 0.180e-3; // seconds
822 double EstimatedSpawnMeshComponentStaticTime = 0.600e-3; // seconds
823 double EstimatedPhysicsBuildTimePerTriangle = 0.240e-6; // seconds per triangle
825 FTimerHandle ViewSyncTimer;
828 FI3DHConnectorDrawingStorage DrawingStorage;
831 FI3DHConnectorRenderStorage RenderStorage;
833 TArray<FI3DHDebugMetric> DebugMetrics;
834 // Timing metrics in milliseconds.
835 int32 MetricTimingVisibilityMs = 0;
836 int32 MetricTimingGeometryMs = 0;
839 // ----------------------------------------------------------
840 TSharedPtr<class FI3DHConnectorAPIImpl> APIImpl;
842 TSharedPtr<class FI3DHConnectionPromiseImpl> ConnectionPromise;
844 TSharedPtr<class FI3DHConnectorBackend> ConnectorBackend;
845 TSharedPtr<class FI3DHEventBackend> EventBackend;
846 TSharedPtr<class FI3DHRenderBackend> RenderBackend;
849 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
857 AI3DHGeometry* SpawnGeometryActor(AActor* AttachActor, int32 RootNodeId, const struct FI3DHInstanceSpawnProperties& SpawnProperties);
858 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
860 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
868 UStaticMeshComponent* SpawnMeshComponentFromTask(FI3DHPageInstanceHandle PageInstanceHandle, AI3DHGeometry* AttachActor, const FI3DHPageToStaticMeshTask& Task, double& PhysicsBuildTime);
869 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
876 void FinishPhysicsAsyncCook(bool bSuccess, UBodySetup* FinishedBodySetup);
882 void SetAppearance_Internal(const FLinearColor& OverrideColor, EAppearanceURIMode OverrideMode, const TArray<int32>& RootNodeIds);
889 void SetTransforms_Internal(const TArray<FMatrix>& GlobalTransforms, const TArray<int32>& RootNodeIds);
897 void SetEnabled_Internal(bool bNewEnabled, const TArray<int32>& RootNodeIds);
905 void SetVariantEnabled_Internal(bool bNewVariantEnabled, const TArray<int32>& RootNodeIds);
912 void SetSelected_Internal(bool bNewSelected, const TArray<int32>& RootNodeIds);
915 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
920 void UpdateMeshComponentVisibilityAfterActorHiddenInGameStateChange_Internal(AI3DHGeometry* GeometryActor);
921 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
923 struct HubCameraParameters
927 FMatrix44f ViewMatrix;
928 FMatrix44f ProjectionMatrix;
935 HubCameraParameters GetHubCameraParamsForPlayer(const APlayerController* PlayerController);
937 void ViewSyncTimerCallback();
940 TSharedPtr<class FI3DHEventStreamConnector> EventStreamConnector;
943 void AddCredentialHeaders(const FString& URL, TMap<FString, FString>& Headers);
944 void ToggleDebugStreamOverlayModeInternal();
945 void ToggleDebugStreamOverlayEnabledInteral();
947 TSharedPtr<class FI3DHDebugStreamConnector> DebugStreamConnector;
950 TObjectPtr<class AI3DHDebugStreamOverlay> DebugStreamOverlay;
953 static bool TestIsValidDrawingMaterial(const UMaterialInterface* DrawingMaterial);