public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
        {
            KeyframeMotion newMotion = null;

            try
            {
                using (MemoryStream ms = new MemoryStream(data))
                {
                    BinaryFormatter fmt = new BinaryFormatter();
                    newMotion = (KeyframeMotion)fmt.Deserialize(ms);
                }

                newMotion.m_group = grp;

                if (grp != null)
                {
                    newMotion.m_scene = grp.Scene;
                    if (grp.IsSelected)
                    {
                        newMotion.m_selected = true;
                    }
                }

                newMotion.m_timerStopped    = false;
                newMotion.m_running         = true;
                newMotion.m_isCrossing      = false;
                newMotion.m_waitingCrossing = false;
            }
            catch
            {
                newMotion = null;
            }

            return(newMotion);
        }
Esempio n. 2
0
        public KeyframeMotion Copy(SceneObjectGroup newgrp)
        {
            StopTimer();

            KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data);

            newmotion.m_group = newgrp;
            newmotion.m_scene = newgrp.Scene;

            if (m_keyframes != null)
            {
                newmotion.m_keyframes = new Keyframe[m_keyframes.Length];
                m_keyframes.CopyTo(newmotion.m_keyframes, 0);
            }

            lock (m_frames)
            {
                newmotion.m_frames = new List <Keyframe>(m_frames);

                newmotion.m_basePosition = m_basePosition;
                newmotion.m_baseRotation = m_baseRotation;

                if (m_selected)
                {
                    newmotion.m_serializedPosition = m_serializedPosition;
                }
                else
                {
                    if (m_group != null)
                    {
                        newmotion.m_serializedPosition = m_group.AbsolutePosition;
                    }
                    else
                    {
                        newmotion.m_serializedPosition = m_serializedPosition;
                    }
                }

                newmotion.m_currentFrame = m_currentFrame;

                newmotion.m_iterations = m_iterations;
                newmotion.m_running    = m_running;
            }

            if (m_running && !m_waitingCrossing)
            {
                StartTimer();
            }

            return(newmotion);
        }
Esempio n. 3
0
        public static void Remove(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
            {
                return;
            }

            if (m_timers.TryGetValue(motion.Scene, out timer))
            {
                timer.m_motions.Remove(motion);
            }
        }
        public static void Add(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
            {
                return;
            }

            lock (m_timers)
            {
                if (!m_timers.TryGetValue(motion.Scene, out timer))
                {
                    timer = new KeyframeTimer(motion.Scene);
                    m_timers[motion.Scene] = timer;

                    if (!SceneManager.Instance.AllRegionsReady)
                    {
                        // Start the timers only once all the regions are ready. This is required
                        // when using megaregions, because the megaregion is correctly configured
                        // only after all the regions have been loaded. (If we don't do this then
                        // when the prim moves it might think that it crossed into a region.)
                        SceneManager.Instance.OnRegionsReadyStatusChange += delegate(SceneManager sm)
                        {
                            if (sm.AllRegionsReady)
                            {
                                timer.Start();
                            }
                        };
                    }

                    // Check again, in case the regions were started while we were adding the event handler
                    if (SceneManager.Instance.AllRegionsReady)
                    {
                        timer.Start();
                    }
                }
            }

            lock (timer.m_lockObject)
            {
                timer.m_motions[motion] = null;
            }
        }
Esempio n. 5
0
        public static void Add(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
            {
                return;
            }

            lock (m_timers)
            {
                if (!m_timers.TryGetValue(motion.Scene, out timer))
                {
                    timer = new KeyframeTimer(motion.Scene);
                    m_timers[motion.Scene] = timer;
                }
            }

            lock (timer.m_lockObject)
            {
                timer.m_motions[motion] = null;
            }
        }
Esempio n. 6
0
        public KeyframeMotion Copy(SceneObjectGroup newgrp)
        {
            StopTimer();

            KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data);

            newmotion.m_group = newgrp;
            newmotion.m_scene = newgrp.Scene;

            if (m_keyframes != null)
            {
                newmotion.m_keyframes = new Keyframe[m_keyframes.Length];
                m_keyframes.CopyTo(newmotion.m_keyframes, 0);
            }

            newmotion.m_frames = new List<Keyframe>(m_frames);

            newmotion.m_basePosition = m_basePosition;
            newmotion.m_baseRotation = m_baseRotation;

            if (m_selected)
                newmotion.m_serializedPosition = m_serializedPosition;
            else
            {
                if (m_group != null)
                    newmotion.m_serializedPosition = m_group.AbsolutePosition;
                else
                    newmotion.m_serializedPosition = m_serializedPosition;
            }

            newmotion.m_currentFrame = m_currentFrame;

            newmotion.m_iterations = m_iterations;
            newmotion.m_running = m_running;

            if (m_running && !m_waitingCrossing)
                StartTimer();

            return newmotion;
        }
Esempio n. 7
0
        public static void Remove(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
                return;

            lock (m_timers)
            {
                if (!m_timers.TryGetValue(motion.Scene, out timer))
                {
                    return;
                }
            }

            lock (timer.m_lockObject)
            {
                timer.m_motions.Remove(motion);
            }
        }
Esempio n. 8
0
        public static void Add(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
                return;

            lock (m_timers)
            {
                if (!m_timers.TryGetValue(motion.Scene, out timer))
                {
                    timer = new KeyframeTimer(motion.Scene);
                    m_timers[motion.Scene] = timer;
                }
            }

            lock (timer.m_lockObject)
            {
                timer.m_motions[motion] = null;
            }
        }
Esempio n. 9
0
        public static void Add(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
                return;

            lock (m_timers)
            {
                if (!m_timers.TryGetValue(motion.Scene, out timer))
                {
                    timer = new KeyframeTimer(motion.Scene);
                    m_timers[motion.Scene] = timer;

                    if (!SceneManager.Instance.AllRegionsReady)
                    {
                        // Start the timers only once all the regions are ready. This is required
                        // when using megaregions, because the megaregion is correctly configured
                        // only after all the regions have been loaded. (If we don't do this then
                        // when the prim moves it might think that it crossed into a region.)
                        SceneManager.Instance.OnRegionsReadyStatusChange += delegate(SceneManager sm)
                        {
                            if (sm.AllRegionsReady)
                                timer.Start();
                        };
                    }
                    
                    // Check again, in case the regions were started while we were adding the event handler
                    if (SceneManager.Instance.AllRegionsReady)
                    {
                        timer.Start();
                    }
                }
            }

            lock (timer.m_lockObject)
            {
                timer.m_motions[motion] = null;
            }
        }
Esempio n. 10
0
        public static void Remove(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
                return;

            if (m_timers.TryGetValue(motion.Scene, out timer))
            {
                timer.m_motions.Remove(motion);
            }
        }