예제 #1
0
        private LiveFeedAnimator GetLiveFeedAnimator(string movementFileName)
        {
            VideoAnimationBinding binding = AllVideoBindings.Get(movementFileName);
            string fullPathToMovementFile = VideoAnimationManager.GetFullPathToMovementFile(movementFileName);

            VideoFeed[] videoFeeds = AllVideoFeeds.GetAll(binding);
            return(VideoAnimationManager.LoadLiveAnimation(fullPathToMovementFile, binding, videoFeeds));
        }
예제 #2
0
        private void SaveLightingData()
        {
            string fullPathToLightingFile = VideoAnimationManager.GetFullPathToLightsFile(SelectedSceneName);

            if (HasAnyLightingChanges(LightingSequence))
            {
                LightingSequence compressedLightingSequence = LightingSequence.Compress();
                string           serializedLights           = Newtonsoft.Json.JsonConvert.SerializeObject(compressedLightingSequence, Newtonsoft.Json.Formatting.Indented);
                System.IO.File.WriteAllText(fullPathToLightingFile, serializedLights);
            }
            else
            {
                System.Diagnostics.Debugger.Break();
                // TODO: Delete the file!!!
            }
        }
예제 #3
0
        private void SaveFrames(string movementFileName)
        {
            LiveFeedAnimator liveFeedAnimator = GetLiveFeedAnimator(movementFileName);

            liveFeedAnimator.LiveFeedSequences.Clear();

            bool firstTime = true;

            ObsTransform lastLiveFeedSequence = null;

            foreach (ObsTransformEdit liveFeedEdit in allFrames)
            {
                ObsTransform liveFeedSequence = new ObsTransform()
                {
                    Camera   = liveFeedEdit.Camera,
                    Rotation = liveFeedEdit.GetRotation(),
                    Scale    = liveFeedEdit.GetScale(),
                    Opacity  = liveFeedEdit.GetOpacity(),
                    Origin   = new CommonCore.Point2d(liveFeedEdit.GetX(), liveFeedEdit.GetY()),
                    Flipped  = liveFeedEdit.Flipped,
                    Duration = secondsPerFrame
                };
                if (firstTime)
                {
                    firstTime = false;
                }
                else
                {
                    if (lastLiveFeedSequence.Matches(liveFeedSequence))                      // Compress movement...
                    {
                        lastLiveFeedSequence.Duration += secondsPerFrame;
                        continue;
                    }
                }
                liveFeedAnimator.LiveFeedSequences.Add(liveFeedSequence);

                lastLiveFeedSequence = liveFeedSequence;
            }

            // Only saves for the active movement file. So if I make changes to two different movement files in
            // the same edit session, I need to save twice - use the radio buttons to decide what I'm saving.
            string fullPathToMovementFile = VideoAnimationManager.GetFullPathToMovementFile(movementFileName);
            string serializedTransforms   = Newtonsoft.Json.JsonConvert.SerializeObject(liveFeedAnimator.LiveFeedSequences, Newtonsoft.Json.Formatting.Indented);

            System.IO.File.WriteAllText(fullPathToMovementFile, serializedTransforms);
        }
예제 #4
0
        static void StartLiveAnimation(string sceneName, List <VideoAnimationBinding> bindings, DateTime startTime)
        {
            CleanUpLiveFeedAnimators();
            liveFeedAnimators = new List <LiveFeedAnimator>();
            foreach (VideoAnimationBinding videoAnimationBinding in bindings)
            {
                string      movementFile = GetFullPathToMovementFile(videoAnimationBinding.MovementFileName);
                VideoFeed[] videoFeeds   = AllVideoFeeds.GetAll(videoAnimationBinding);

                LiveFeedAnimator liveFeedAnimator = LoadLiveAnimation(movementFile, videoAnimationBinding, videoFeeds);
                liveFeedAnimator.FrameAnimator.AnimationComplete += LiveFeedAnimator_AnimationComplete;
                liveFeedAnimator.FrameAnimator.Start(startTime);
                liveFeedAnimators.Add(liveFeedAnimator);
            }

            // TODO: Track which video feed we are running in case we abort while we are running.

            string fullPathToLightsFile = VideoAnimationManager.GetFullPathToLightsFile(sceneName);

            if (System.IO.File.Exists(fullPathToLightsFile))
            {
                string           lightsJson       = System.IO.File.ReadAllText(fullPathToLightsFile);
                LightingSequence lightingSequence = JsonConvert.DeserializeObject <LightingSequence>(lightsJson);
                //log.Clear();
                foreach (Light light in lightingSequence.Lights)
                {
                    FrameAnimator frameAnimator = new FrameAnimator(light.SequenceData.Count);
                    frameAnimator.Data = light;
                    frameAnimator.AnimationComplete += FrameAnimator_AnimationComplete;
                    frameAnimator.RenderFrame       += FrameAnimator_RenderLights;
                    frameAnimator.Start(startTime);
                    lightAnimators.Add(frameAnimator);
                }
            }

            existingAnimationIsRunning = true;
        }
예제 #5
0
        LightingSequence LoadLightingSequence(string sceneName, int totalFrameCount)
        {
            string fullPathToLightsFile = VideoAnimationManager.GetFullPathToLightsFile(sceneName);

            if (System.IO.File.Exists(fullPathToLightsFile))
            {
                string           lightsJson       = System.IO.File.ReadAllText(fullPathToLightsFile);
                LightingSequence lightingSequence = JsonConvert.DeserializeObject <LightingSequence>(lightsJson);

                LightingSequence decompressedLightingSequence = lightingSequence.Decompress();

                AddCenterLightIfNeeded(totalFrameCount, decompressedLightingSequence);

                return(decompressedLightingSequence);
            }
            else
            {
                LightingSequence lightingSequence = new LightingSequence();
                lightingSequence.Lights.Add(NewLight(BluetoothLights.Left_ID, totalFrameCount));
                lightingSequence.Lights.Add(NewLight(BluetoothLights.Center_ID, totalFrameCount));
                lightingSequence.Lights.Add(NewLight(BluetoothLights.Right_ID, totalFrameCount));
                return(lightingSequence);
            }
        }
예제 #6
0
 private void Window_Closed(object sender, EventArgs e)
 {
     VideoAnimationManager.ClosingEditor();
 }