Пример #1
0
        internal void UpdateTransform(Transform firstTrns, Transform secondTrns, float t)
        {
            TransformPoint curTrnPoint = transformsCurve.Evaluate(t);

            firstTrns.localRotation  = Quaternion.identity;
            firstTrns.localPosition  = curTrnPoint.position;
            secondTrns.localRotation = curTrnPoint.rotation;
            secondTrns.localPosition = Vector3.zero;
            Time.timeScale           = curTrnPoint.timescale;
        }
Пример #2
0
        public void Load(ConfigNode node)
        {
            name = ConfigUtil.GetValue(node, "NAME", "");
            ConfigUtil.Parse <bool>(node, "SCALE_TIME", out ScaleTime, false);
            interpolator.Load(node);
            float lastTime = -1f;

            foreach (var pointNode in node.GetNodes("POINT"))
            {
                float param;
                ConfigUtil.Parse <float>(pointNode, "PARAM", out param, lastTime + 1f);
                lastTime = param;
                TransformPoint value = new TransformPoint();
                value.Load(pointNode);
                transformsCurve.AddKey(param, value);
            }
        }
Пример #3
0
        private void DoKeyEditing()
        {
            if (selectedKeyIndex < 0 || selectedKeyIndex >= path.Count)
            {
                return;
            }

            bool           remove          = false;
            float          keyTime         = path.TimeAt(selectedKeyIndex);
            bool           keyTimeChanged  = false;
            TransformPoint trnPoint        = path[selectedKeyIndex];
            bool           trnPointChanged = false;

            // Vertical time slider for selected key time.
            // This is a key editing control, but uses the vertical space
            // between path and key editing controls, so it's not put into
            // the key editing buttons layout region.
            {
                float newKeyTime = GUILayout.VerticalSlider(keyTime, 0f, path.MaxTime);
                if (Math.Abs(keyTime - newKeyTime) > 1e-5)
                {
                    keyTime        = newKeyTime;
                    keyTimeChanged = true;
                }
            }

            GUILayout.BeginVertical(); // BEGIN key editing buttons
            GUILayout.Label(string.Format("Key #{0}", selectedKeyIndex));

            {
                // Direct editing of key time.
                GUILayout.BeginHorizontal(); // BEGIN key time editing
                GUILayout.Label("@");
                string newSelectedKeyTimeString = GUILayout.TextField(selectedKeyTimeString);
                if (newSelectedKeyTimeString != selectedKeyTimeString)
                {
                    selectedKeyTimeString = newSelectedKeyTimeString;
                    float newKeyTime;
                    if (float.TryParse(selectedKeyTimeString, out newKeyTime))
                    {
                        keyTime        = newKeyTime;
                        keyTimeChanged = true;
                    }
                }
                GUILayout.Label("s");
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal(); // END key time editing
            }

            if (path.ScaleTime)
            {
                // Editing key timescale.
                float oldTimescale = trnPoint.timescale;
                GUILayout.Label(string.Format("Timescale: {0:0.00}\u00d7", oldTimescale));
                float newTimescale = GUILayout.HorizontalSlider(oldTimescale, 0f, 4f);
                if (Math.Abs(oldTimescale - newTimescale) > 1e-5)
                {
                    trnPoint.timescale = newTimescale;
                }
                if (GUILayout.Button("Reset timescale"))
                {
                    trnPoint.timescale = 1f;
                }
                trnPointChanged = true;
            }

            if (GUILayout.Button("Set"))
            {
                trnPoint = SimpleCamPath.MakeTransformPoint(
                    StateHandler.camControl.SecondTransform,
                    StateHandler.camControl.transform,
                    trnPoint.timescale);
                trnPointChanged = true;
            }

            if (GUILayout.Button("View"))
            {
                path.Runner.StopRunning();
                StateHandler.manCamControl.TakeControl();
                path.UpdateTransform(
                    StateHandler.camControl.FirstTransform,
                    StateHandler.camControl.SecondTransform,
                    path.TimeAt(selectedKeyIndex));
            }

            if (GUILayout.Button("Remove", WindowStyles.DeleteButtonStyle))
            {
                remove = true;
            }

            GUILayout.EndVertical(); // END key editing buttons

            if (remove)
            {
                path.RemoveKey(selectedKeyIndex);
                if (selectedKeyIndex >= path.Count)
                {
                    selectedKeyIndex = 0;
                }
                UpdateSelectedKeyTime();
                // Don't make any other potential changes to the key.
                return;
            }

            if (keyTimeChanged)
            {
                selectedKeyIndex = path.MoveKeyAt(selectedKeyIndex, keyTime);
                UpdateSelectedKeyTime();
            }

            if (trnPointChanged)
            {
                path[selectedKeyIndex] = trnPoint;
            }
        }