Beispiel #1
0
        public SerializableAnimatable(Animatable sceneObj, bool top = false)
        {
            IsTopLevel = top;

            if (sceneObj.Creator != null)
            {
                ShelfParent = sceneObj.Creator.name;
            }
            else
            {
                ShelfParent = "";
            }

            StartFrame = sceneObj.StartFrame;

            TranslationKeys = new List <Tuple <int, SerializableVector3> >(sceneObj.TranslationKeys.Count);
            ScaleKeys       = new List <Tuple <int, SerializableVector3> >(sceneObj.ScaleKeys.Count);
            RotationKeys    = new List <Tuple <int, SerializableQuaternion> >(sceneObj.RotationKeys.Count);

            foreach (var t in sceneObj.TranslationKeys)
            {
                TranslationKeys.Add(new Tuple <int, SerializableVector3>(t.Item1, t.Item2));
            }
            foreach (var t in sceneObj.ScaleKeys)
            {
                ScaleKeys.Add(new Tuple <int, SerializableVector3>(t.Item1, t.Item2));
            }
            foreach (var t in sceneObj.RotationKeys)
            {
                RotationKeys.Add(new Tuple <int, SerializableQuaternion>(t.Item1, t.Item2));
            }

            Children = new List <SerializableAnimatable>();
            // serialize all immediate children
            foreach (var child in sceneObj.GetComponentsInChildren <Animatable>())
            {
                // make sure to skip the current object
                if (child.GetInstanceID() == sceneObj.GetInstanceID())
                {
                    continue;
                }

                Children.Add(new SerializableAnimatable(child));
            }

            // Assumption: Only top-level Animatable objects can have an emitter
            var sceneEmitter = sceneObj.GetComponentInChildren <ParticleEmitter>();

            if (top == false || sceneEmitter == null)
            {
                Emitter = new SerializableEmitter();
            }
            else
            {
                Emitter = new SerializableEmitter(sceneEmitter);
            }
        }
Beispiel #2
0
        public static void DeleteReferencesToObject(Animatable obj)
        {
            var deleteKeys = new List <int>(Intersections.Count);

            for (int i = Intersections.Count - 1; i >= 0; --i)
            {
                if (Intersections[i].Item3.GetInstanceID() == obj.GetInstanceID())
                {
                    OnIntersectionEnd?.Invoke(Intersections[i]);
                    Intersections.RemoveAt(i);
                }
            }
        }