public void ResetView() { Scene.SetSceneScale(1.0f); ActiveCamera.Manipulator().ResetSceneOrbit(Scene, true, true, true); // [RMS] above should already do this, but sometimes it gets confused.. Scene.RootGameObject.transform.rotation = Quaternion.identity; ActiveCamera.Manipulator().ResetScenePosition(scene); ActiveCamera.Manipulator().SceneTranslate(Scene, SceneGraphConfig.InitialSceneTranslate); }
public void ResetView() { ActiveCamera.Animator().DoActionDuringDipToBlack(() => { Scene.SetSceneScale(1.0f); ActiveCamera.Manipulator().ResetSceneOrbit(Scene, true, true, true); // [RMS] above should already do this, but sometimes it gets confused.. Scene.RootGameObject.SetRotation(Quaternion.identity); ActiveCamera.Manipulator().ResetScenePosition(scene); ActiveCamera.Manipulator().SceneTranslate(Scene, SceneGraphConfig.InitialSceneTranslate, true); }, 0.5f); }
public void ScaleView(Vector3 vCenterW, float fRadiusW) { //Vector3f camTarget = ActiveCamera.GetTarget(); //Vector3f localTarget = Scene.WorldFrame.ToFrameP(camTarget); Vector3f vDeltaOrig = Scene.SceneFrame.ToFrameP(vCenterW); ActiveCamera.Manipulator().ResetSceneOrbit( Scene, false, true, true); float fCurScale = Scene.GetSceneScale(); Frame3f cockpitF = ActiveCockpit.GetLevelViewFrame(CoordSpace.WorldCoords); float fScale = 1.0f / fRadiusW; vDeltaOrig *= fScale; Frame3f deskF = cockpitF.Translated(1.2f, 2).Translated(-0.5f, 1).Translated(-vDeltaOrig); Scene.SceneFrame = deskF; Scene.SetSceneScale(fCurScale * fScale); Vector3f newTarget = Scene.SceneFrame.Origin + vDeltaOrig; ActiveCamera.SetTarget(newTarget); }
public void Reset(bool bKeepBoundsObjects = true, bool bKeepLighting = true) { ClearHistory(); ClearSelection(); RemoveAllSceneObjects(); foreach (var so in vDeleted) { so.Disconnect(true); so.RootGameObject.Destroy(); } vDeleted.Clear(); RemoveAllUIElements(); LinkManager.RemoveAllLinks(); SetCurrentTime(0); SelectionMask = null; // save bounds objects var save_bounds = vBoundsObjects; fGameObject boundsGO = null; if (bKeepBoundsObjects) { boundsGO = bounds_objects; boundsGO.SetParent(null, true); } // save lighting objects fGameObject lightingGO = null; if (bKeepLighting) { lightingGO = lighting_objects; lightingGO.SetParent(null, true); } // save camera CameraState camera_state = ActiveCamera.Manipulator().GetCurrentState(this); // make sure we get rid of any cruft sceneRoot.Destroy(); // rebuild scene initialize_scene_root(); // restore camera ActiveCamera.Manipulator().SetCurrentSceneState(this, camera_state); // restore bounds objects if (bKeepBoundsObjects) { bounds_objects.Destroy(); boundsGO.SetParent(sceneRoot, true); bounds_objects = boundsGO; vBoundsObjects = save_bounds; } // restore lighting objects if (bKeepLighting) { lighting_objects.Destroy(); lightingGO.SetParent(sceneRoot, true); lighting_objects = lightingGO; } }
// Use this for initialization public void Start(SceneOptions options) { this.options = options; DebugUtil.LogLevel = options.LogLevel; FPlatform.InitializeMainThreadID(); // initialize VR platform if VR is active if (gs.VRPlatform.VREnabled) { if (options.Use2DCockpit) { throw new Exception("FContext.Start: cannot use 2D Orthographic Cockpit with VR!"); } if (options.SpatialCameraRig != null) { gs.VRPlatform.Initialize(options.SpatialCameraRig); } } InputExtension.Get.Start(); nextFrameActions = new ActionSet(); // intialize camera stuff camTracker = new CameraTracking(); camTracker.Initialize(this); GetScene(); if (options.SceneInitializer != null) { options.SceneInitializer.Initialize(GetScene()); } if (options.DefaultGizmoBuilder != null) { transformManager = new TransformManager(options.DefaultGizmoBuilder); } else { transformManager = new TransformManager(new AxisTransformGizmoBuilder()); } if (options.EnableTransforms) { transformManager.Initialize(this); } toolManager = new ToolManager(); toolManager.Initialize(this); toolManager.OnToolActivationChanged += OnToolActivationChanged; MouseController.Start(); SpatialController.Start(); // [RMS] hardcode starting cam target point to origin ActiveCamera.SetTarget(Vector3f.Zero); if (options.MouseCameraControls != null) { MouseCameraController = options.MouseCameraControls; } // apply initial transformation to scene ActiveCamera.Manipulator().SceneTranslate(Scene, SceneGraphConfig.InitialSceneTranslate, true); // create behavior sets inputBehaviors = new InputBehaviorSet(); overrideBehaviors = new InputBehaviorSet(); // cockpit needs to go last because UI setup may depend on above cockpitStack = new Stack <Cockpit>(); if (options.EnableCockpit) { PushCockpit(options.CockpitInitializer); } captureMouse = null; captureTouch = null; captureLeft = captureRight = null; bInCameraControl = false; // [RMS] this locks cursor to game unless user presses escape or exits if (FPlatform.IsUsingVR() || options.UseSystemMouseCursor == false) { Cursor.lockState = CursorLockMode.Locked; } // set hacky hackenstein global ActiveContext_HACK = this; startup_checks(); }