120class AI3DHConnector : public AActor
125 INSTANT3DHUB_API AI3DHConnector();
128 INSTANT3DHUB_API virtual void BeginPlay() override;
129 INSTANT3DHUB_API virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
131 INSTANT3DHUB_API virtual void Tick(float DeltaTime) override;
134 INSTANT3DHUB_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
137 // ----------------------------------------------------------
139 // ----------------------------------------------------------
148 INSTANT3DHUB_API TSharedPtr<FI3DHConnectorAPI> GetAPI() const;
150 // ----------------------------------------------------------
152 // ----------------------------------------------------------
160 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3Dhub}|Connector
")
161 INSTANT3DHUB_API void AddNetworkCredentialCookie(const FString& CookieKey, const FString& CookieValue);
168 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3Dhub}|Connector
")
169 INSTANT3DHUB_API void RemoveNetworkCredentialCookie(const FString& CookieKey);
177 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3Dhub}|Connector
")
178 INSTANT3DHUB_API void AddNetworkCredentialToken(const FString& TokenKey, const FString& TokenValue);
185 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3Dhub}|Connector
")
186 INSTANT3DHUB_API void RemoveNetworkCredentialToken(const FString& TokenKey);
193 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
194 INSTANT3DHUB_API const TMap<FString, FString>& GetNetworkCredentialCookies() const { return NetworkCredentialCookies; }
201 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
202 INSTANT3DHUB_API const TMap<FString, FString>& GetNetworkCredentialTokens() const { return NetworkCredentialTokens; }
243 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Connector
")
244 INSTANT3DHUB_API void ConnectToHub(const FString& HubURL, const FString& SessionId);
256 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Connector
")
257 INSTANT3DHUB_API void ConnectToHubWithOptions(const FString& HubURL, const FI3DHConnectOptions& Options);
271 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Connector
")
272 INSTANT3DHUB_API void Disconnect();
280 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
281 INSTANT3DHUB_API bool IsDisconnected() const;
289 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
290 INSTANT3DHUB_API bool IsEstablishingConnectionToHub() const;
297 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
298 INSTANT3DHUB_API bool IsConnectedToHub() const;
305 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
306 INSTANT3DHUB_API FString GetHubURL() const;
313 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
314 INSTANT3DHUB_API FString GetSessionId() const;
323 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Connector
")
324 FConnectedDelegate OnConnectedDelegate;
332 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Connector
")
333 FConnectErrorDelegate OnConnectErrorDelegate;
343 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Connector
")
344 FErrorDelegate OnErrorDelegate;
352 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Connector
")
353 FDisconnectedDelegate OnDisconnectedDelegate;
360 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
361 INSTANT3DHUB_API FMatrix GetOriginToWorldTransform() const;
368 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3Dhub}|Connector
")
369 INSTANT3DHUB_API FMatrix GetWorldToOriginTransform() const;
374 INSTANT3DHUB_API AActor* GetOriginActor()
376 AActor* RootActor = this;
377 check(RootActor != nullptr);
384 INSTANT3DHUB_API const AActor* GetOriginActor() const
386 const AActor* RootActor = this;
387 check(RootActor != nullptr);
392 // ----------------------------------------------------------
393 // Internal Connection Helper Functions
394 // ----------------------------------------------------------
396 void OnBackendConnected_Internal_GameThread(const FString& SessionId);
397 void OnBackendError_Internal_GameThread(const FString& ErrorMessage);
400 void ReportError_Internal_GameThread(const FString& ErrorMessage);
401 void ReportConnectError_Internal_GameThread(const FString& ErrorMessage);
402 bool Disconnect_Internal_GameThread();
405 // ----------------------------------------------------------
407 // ----------------------------------------------------------
423 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Debugging
")
424 INSTANT3DHUB_API bool RequestRemoteCullerDebugStream();
438 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Debugging
")
439 INSTANT3DHUB_API UTexture2D* GetRemoteCullerDebugStreamTexture();
452 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Debugging
")
453 INSTANT3DHUB_API const TArray<FI3DHDebugMetric>& GetDebugMetrics();
466 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Debugging
")
467 INSTANT3DHUB_API FString GetDebugSessionInfo();
469 // ----------------------------------------------------------
471 // ----------------------------------------------------------
485 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Progress
")
486 INSTANT3DHUB_API FI3DHClientProgress GetClientProgress();
488 // ----------------------------------------------------------
490 // ----------------------------------------------------------
496 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Clip Plane API
")
497 FClipPlaneCreatedDelegate OnClipPlaneCreatedDelegate;
503 UPROPERTY(BlueprintAssignable, Transient, Category = "{instant3Dhub}|Clip Plane API
")
504 FClipPlaneRemovedDelegate OnClipPlaneRemovedDelegate;
511 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "0.1
", ClampMax = "120.0
", UIMin = "0.1
", UIMax = "120.0
"), Category = "{instant3Dhub}|Clip Plane API
")
512 float ClipPlaneSyncHz = 1.0;
518 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Clip Plane API
")
519 TSubclassOf<AActor> ClipPlaneActorClass = nullptr;
526 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Clip Plane API
")
527 INSTANT3DHUB_API TArray<int32> GetClipPlanes();
535 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Clip Plane API
")
536 INSTANT3DHUB_API AActor* FindClipPlaneActor(int32 ClipPlaneId);
543 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Clip Plane API
")
544 INSTANT3DHUB_API AActor* GetMainClipPlaneActor();
546 // ----------------------------------------------------------
548 // ----------------------------------------------------------
557 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Drawing API
", AdvancedDisplay)
558 TObjectPtr<UMaterialInterface> DrawingBaseMaterial{nullptr};
567 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Drawing API
", AdvancedDisplay)
568 TObjectPtr<class UStaticMesh> DrawingSegmentMesh{nullptr};
576 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Drawing API
", AdvancedDisplay)
577 TObjectPtr<class UStaticMesh> DrawingJointMesh{nullptr};
586 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing API
", meta = (DisplayName = "Create Drawing Material
"))
587 INSTANT3DHUB_API UMaterialInterface* GetDrawingMaterial(FLinearColor Color);
596 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing API
")
597 INSTANT3DHUB_API class AI3DHDrawing* FindDrawingActor(int32 DrawingHandle);
605 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing API
")
606 INSTANT3DHUB_API void SetClipDrawingsByClipPlane(const bool bClipDrawingsByClipPlaneEnabled);
614 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing API
")
615 INSTANT3DHUB_API bool GetClipDrawingsByClipPlane();
617 // ----------------------------------------------------------
619 // ----------------------------------------------------------
634 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
EditDrawing API
")
635 virtual void EditDrawing(int32 DrawingHandle, const TScriptInterface<class II3DHEditDrawingInterface>& EditDrawingInterface, bool bIsEditingCopy = false);
637 // ----------------------------------------------------------
639 // ----------------------------------------------------------
646 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|
Instance Graph API
")
647 INSTANT3DHUB_API int32 GetGlobalRootNodeId();
649 // ----------------------------------------------------------
651 // ----------------------------------------------------------
659 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Selection API
")
660 INSTANT3DHUB_API TArray<int32> GetSelection();
662 // ----------------------------------------------------------
663 // TransformAuthority API
664 // ----------------------------------------------------------
666 INSTANT3DHUB_EXPERIMENTAL(0.0.23, "TransformAuthorityAPI is a temporary solution suspect to changes or replacement.
")
675 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
Transform Authority
", meta = (DisplayName = "Get WorldTransform With Authority (Experimental)
"))
676 INSTANT3DHUB_API bool GetWorldTransformWithAuthority(const FI3DHTransformAuthorityHandle TransformAuthorityHandle, int32 NodeId, FMatrix& OutWorldTransform);
678 INSTANT3DHUB_EXPERIMENTAL(0.0.23, "TransformAuthorityAPI is a temporary solution suspect to changes or replacement.
")
686 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
Transform Authority
", meta = (DisplayName = "Set WorldTransform With Authority (Experimental)
"))
687 INSTANT3DHUB_API void SetWorldTransformWithAuthority(const FI3DHTransformAuthorityHandle TransformAuthorityHandle, int32 NodeId, const FMatrix& WorldTransform);
689 INSTANT3DHUB_EXPERIMENTAL(0.0.23, "TransformAuthorityAPI is a temporary solution suspect to changes or replacement.
")
696 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
Transform Authority
", meta = (DisplayName = "Release TransformAuthority (Experimental)
"))
697 INSTANT3DHUB_API void ReleaseTransformAuthority(const FI3DHTransformAuthorityHandle TransformAuthorityHandle);
699 INSTANT3DHUB_EXPERIMENTAL(0.0.23, "TransformAuthorityAPI is a temporary solution suspect to changes or replacement.
")
705 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|
Transform Authority
", meta = (DisplayName = "Is TransformAuthority Active (Experimental)
"))
706 INSTANT3DHUB_API bool IsTransformAuthorityActive(const FI3DHTransformAuthorityHandle TransformAuthorityHandle) const;
708 // ----------------------------------------------------------
709 // Runtime adjustable performance parameters
710 // ----------------------------------------------------------
713 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3Dhub}|Connector
", meta = (ClampMin = 1, UIMin = 1))
714 int32 MaxConversionTasksCreatedPerTick = 8;
717 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3Dhub}|Connector
", meta = (ClampMin = 1, UIMin = 1))
718 int32 MaxComponentsCreatedPerTick = 2;
725 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3Dhub}|Connector
", meta = (ClampMin = 0, UIMin = 0, Delta = 1000000))
726 int32 TargetedTrianglesOnComponentsWithVisibility = 10000000;
732 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "0.1
", ClampMax = "100.0
", UIMin = "0.1
", UIMax = "100.0
"), Category = "{instant3Dhub}|Connector
")
733 float CreateComponentsBudgetMs = 5.0f;
739 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = "0.1
", ClampMax = "120.0
", UIMin = "0.1
", UIMax = "120.0
"), Category = "{instant3Dhub}|Connector
")
740 float ViewSyncHz = 5.0;
747 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Connector
")
748 TObjectPtr<class UMaterialParameterCollection> I3DHParameterCollection = nullptr;
750 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
752 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Connector
")
753 TSubclassOf<AI3DHGeometry> GeometryActorClass;
754 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
757 UPROPERTY(EditAnywhere, Category = "{instant3Dhub}|Connector
")
758 bool bSpawnedGeometryCastsShadow = false;
762 UPROPERTY(VisibleAnywhere, Category = "{instant3Dhub}|Connector
")
763 TObjectPtr<USceneComponent> RootComponentConnector;
766 // ----------------------------------------------------------
768 // ----------------------------------------------------------
770 FI3DHConnectorDrawingStorage& GetDrawingStorage();
771 const FI3DHConnectorDrawingStorage& GetDrawingStorage() const;
773 FI3DHConnectorRenderStorage& GetRenderStorage();
774 const FI3DHConnectorRenderStorage& GetRenderStorage() const;
776 const FI3DHConnectorRenderStats& GetRenderStats() const;
778 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
780 AI3DHGeometry* FindGeometryActor(int32 RootNodeId);
781 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
783 UMaterialParameterCollectionInstance* GetI3DHParameterCollectionInstance() const;
786 TMap<FString, FString> NetworkCredentialCookies;
787 TMap<FString, FString> NetworkCredentialTokens;
792 bool bReloadKeyPressedLastFrame = false;
793 bool bDebugStreamKeyPressedLastFrame = false;
795 // Timings for measuring time to first pixel.
796 // All values in seconds of platform time.
798 // Note that the camera position and orientation can influence the timings
799 // via effects on the remote culler. For accurate measurements the camera
800 // should be in a fixed position pointing at the scene.
802 double FirstVisibilityTime;
803 double FirstActorTime;
805 // Time estimates for CreateMeshComponents budgeting.
806 // The estimates are updated using exponential moving averages.
807 // For the physics build we assume (based on our tests) that
808 // the constant overhead is negligible and the time is
809 // fully dependent on the per-triangle cost.
810 // Initial values are based on measurements on my computer.
811 double EstimatedSpawnGeometryActorTime = 0.180e-3; // seconds
812 double EstimatedSpawnMeshComponentStaticTime = 0.600e-3; // seconds
813 double EstimatedPhysicsBuildTimePerTriangle = 0.240e-6; // seconds per triangle
815 FTimerHandle ViewSyncTimer;
818 FI3DHConnectorDrawingStorage DrawingStorage;
821 FI3DHConnectorRenderStorage RenderStorage;
823 TArray<FI3DHDebugMetric> DebugMetrics;
824 // Timing metrics in milliseconds.
825 int32 MetricTimingVisibilityMs = 0;
826 int32 MetricTimingGeometryMs = 0;
829 // ----------------------------------------------------------
830 TSharedPtr<class FI3DHConnectorAPIImpl> APIImpl;
832 TSharedPtr<class FI3DHConnectionPromiseImpl> ConnectionPromise;
834 TSharedPtr<class FI3DHConnectorBackend> ConnectorBackend;
835 TSharedPtr<class FI3DHEventBackend> EventBackend;
836 TSharedPtr<class FI3DHRenderBackend> RenderBackend;
839 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
847 AI3DHGeometry* SpawnGeometryActor(AActor* AttachActor, int32 RootNodeId, const struct FI3DHInstanceSpawnProperties& SpawnProperties);
848 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
850 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
858 UStaticMeshComponent* SpawnMeshComponentFromTask(FI3DHPageInstanceHandle PageInstanceHandle, AI3DHGeometry* AttachActor, const FI3DHPageToStaticMeshTask& Task, double& PhysicsBuildTime);
859 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
866 void FinishPhysicsAsyncCook(bool bSuccess, UBodySetup* FinishedBodySetup);
872 void SetAppearance_Internal(const FLinearColor& OverrideColor, EAppearanceURIMode OverrideMode, const TArray<int32>& RootNodeIds);
879 void SetTransforms_Internal(const TArray<FMatrix>& GlobalTransforms, const TArray<int32>& RootNodeIds);
887 void SetEnabled_Internal(bool bNewEnabled, const TArray<int32>& RootNodeIds);
895 void SetVariantEnabled_Internal(bool bNewVariantEnabled, const TArray<int32>& RootNodeIds);
902 void SetSelected_Internal(bool bNewSelected, const TArray<int32>& RootNodeIds);
908 void RemoveGeometryActors_Internal(const TArray<int32>& RootNodeIds);
911 PRAGMA_DISABLE_EXPERIMENTAL_WARNINGS
916 void UpdateMeshComponentVisibilityAfterActorHiddenInGameStateChange_Internal(AI3DHGeometry* GeometryActor);
917 PRAGMA_ENABLE_EXPERIMENTAL_WARNINGS
919 struct HubCameraParameters
923 FMatrix44f ViewMatrix;
924 FMatrix44f ProjectionMatrix;
931 HubCameraParameters GetHubCameraParamsForPlayer(const APlayerController* PlayerController);
933 void ViewSyncTimerCallback();
936 TSharedPtr<class FI3DHEventStreamConnector> EventStreamConnector;
939 void AddCredentialHeaders(const FString& URL, TMap<FString, FString>& Headers);
940 void ToggleDebugStreamOverlayModeInternal();
941 void ToggleDebugStreamOverlayEnabledInteral();
943 TSharedPtr<class FI3DHDebugStreamConnector> DebugStreamConnector;
946 TObjectPtr<class AI3DHDebugStreamOverlay> DebugStreamOverlay;
949 static bool TestIsValidDrawingMaterial(const UMaterialInterface* DrawingMaterial);