コード例 #1
0
ファイル: TransformState.cs プロジェクト: nan0bug00/kerbcam
        /// <summary>
        /// Moves toMove, retaining the local position, scale, rotation.
        ///
        /// This is in contrast to simply modifying Transform.parent, which modifies
        /// the local transformation state to retain the same world-space result.
        /// </summary>
        /// <param name="toMove">The Transform to reparent.</param>
        /// <param name="newParent">The new parent Transform.</param>
        public static void MoveToParent(Transform toMove, Transform newParent)
        {
            var state = new TransformState(toMove);

            toMove.parent = newParent;
            state.Revert();
        }
コード例 #2
0
ファイル: CameraController.cs プロジェクト: nan0bug00/kerbcam
        /// <summary>
        /// Updates references to Transform objects that we're interested in.
        /// </summary>
        private void UpdateTransformReferences()
        {
            Transform newParent;

            if (relativeTrn == null)
            {
                if (FlightGlobals.ActiveVessel == null)
                {
                    newParent = null;
                }
                else
                {
                    newParent = FlightGlobals.ActiveVessel.transform;
                }
            }
            else
            {
                newParent = relativeTrn;
            }
            TransformState.MoveToParent(destructionProxy.transform, newParent);
            TransformState.ResetTransformToIdentity(destructionProxy.transform);
            TransformState.ResetTransformToIdentity(transform);

            // For FlightCamera, the second transform is that for the FlightCamera itself.
            secondTrn = new TransformState(FlightCamera.fetch.transform);
            // ... and the transform parent is the "main camera pivot".
            firstTrn = new TransformState(secondTrn.Transform.parent);
        }
コード例 #3
0
ファイル: CameraController.cs プロジェクト: nan0bug00/kerbcam
        private void ReplaceProxy()
        {
            if (destructionProxy != null)
            {
                destructionProxy.onDestroy -= this.OnProxyDestroyed;
            }
            GameObject obj = new GameObject("KerbCam.CameraController DestructionProxy");

            destructionProxy            = obj.AddComponent <DestructionProxy>();
            destructionProxy.onDestroy += OnProxyDestroyed;
            TransformState.MoveToParent(transform, destructionProxy.transform);
        }
コード例 #4
0
ファイル: CameraController.cs プロジェクト: nan0bug00/kerbcam
        private void ReacquireFlightCamera()
        {
            if (!isControlling)
            {
                return;
            }

            FlightCamera.fetch.DeactivateUpdate();

            UpdateTransformReferences();

            // Store the first and second transform states, for when we release the camera.
            firstTrn.Store();
            secondTrn.Store();

            // The CameraController becomes the parent transform for the camera transforms.
            TransformState.MoveToParent(firstTrn.Transform, transform);
        }