Пример #1
0
 public virtual void tweenObjects(com.brashmonkey.spriter.animation.SpriterAnimation
                                  animation)
 {
     foreach (System.Collections.Generic.KeyValuePair <com.brashmonkey.spriter.objects.SpriterObject
                                                       , int> entry in objectsToTween.EntrySet())
     {
         com.brashmonkey.spriter.objects.SpriterObject     toTween = entry.Key;
         com.brashmonkey.spriter.animation.SpriterKeyFrame frame   = animation.frames[entry.
                                                                                      Value];
         long time = frame.getTime();
         com.brashmonkey.spriter.animation.SpriterKeyFrame currentFrame = animation.getPreviousFrameForObject
                                                                              (toTween, time);
         com.brashmonkey.spriter.animation.SpriterKeyFrame nextFrame = animation.getNextFrameFor
                                                                           (toTween, currentFrame, 1);
         if (nextFrame != currentFrame)
         {
             com.brashmonkey.spriter.objects.SpriterObject object1 = currentFrame.getObjectFor
                                                                         (toTween);
             com.brashmonkey.spriter.objects.SpriterObject object2 = nextFrame.getObjectFor(toTween
                                                                                            );
             this.interpolateSpriterObject(toTween, object1, object2, currentFrame.getTime(),
                                           nextFrame.getTime(), time);
         }
         com.brashmonkey.spriter.objects.SpriterObject[] objects = new com.brashmonkey.spriter.objects.SpriterObject
                                                                   [frame.getObjects().Length + 1];
         for (int i = 0; i < objects.Length - 1; i++)
         {
             objects[i] = frame.getObjects()[i];
         }
         objects[objects.Length - 1] = toTween;
         frame.setObjects(objects);
     }
 }
 protected internal override void setInstructionRef(com.brashmonkey.spriter.draw.DrawInstruction
                                                    dI, com.brashmonkey.spriter.objects.SpriterObject obj1, com.brashmonkey.spriter.objects.SpriterObject
                                                    obj2)
 {
     dI.@ref = (this.weight <= 0.5f || obj2 == null) ? obj1.getRef() : obj2.getRef();
     //dI.loader = (this.weight <= 0.5f || obj2 == null) ? obj1.getLoader() : obj2.getLoader	();
     dI.obj = (this.weight <= 0.5f || obj2 == null) ? obj1 : obj2;
 }
Пример #3
0
 public virtual com.brashmonkey.spriter.objects.SpriterObject getObjectFor(com.brashmonkey.spriter.objects.SpriterObject
                                                                           @object)
 {
     foreach (com.brashmonkey.spriter.objects.SpriterObject obj in this.objects)
     {
         if (obj.equals(@object))
         {
             return(obj);
         }
     }
     return(null);
 }
Пример #4
0
 private void interpolateSpriterObject(com.brashmonkey.spriter.objects.SpriterObject
                                       target, com.brashmonkey.spriter.objects.SpriterObject obj1, com.brashmonkey.spriter.objects.SpriterObject
                                       obj2, float startTime, float endTime, float frame)
 {
     if (obj2 == null)
     {
         return;
     }
     this.interpolateAbstractObject(target, obj1, obj2, startTime, endTime, frame);
     target.setPivotX(this.interpolate(obj1.getPivotX(), obj2.getPivotX(), startTime,
                                       endTime, frame));
     target.setPivotY(this.interpolate(obj1.getPivotY(), obj2.getPivotY(), startTime,
                                       endTime, frame));
     target.setAlpha(this.interpolateAngle(obj1.getAlpha(), obj2.getAlpha(), startTime
                                           , endTime, frame));
 }
Пример #5
0
 /// <summary>Searches for a keyframe in this animation which has a smaller or equal starting time as the given time and contains the given object.
 ///     </summary>
 /// <remarks>Searches for a keyframe in this animation which has a smaller or equal starting time as the given time and contains the given object.
 ///     </remarks>
 /// <param name="object"></param>
 /// <param name="time"></param>
 /// <returns>A keyframe object which has a smaller or equal starting time than the given time and contains the given object.
 ///     </returns>
 public virtual com.brashmonkey.spriter.animation.SpriterKeyFrame getPreviousFrameForObject
     (com.brashmonkey.spriter.objects.SpriterObject @object, long time)
 {
     com.brashmonkey.spriter.animation.SpriterKeyFrame frame = null;
     foreach (com.brashmonkey.spriter.animation.SpriterKeyFrame key in this.frames)
     {
         if (!key.containsObject(@object))
         {
             continue;
         }
         if (key.getTime() <= time)
         {
             frame = key;
         }
         else
         {
             break;
         }
     }
     return(frame);
 }
        public virtual void tweenObjects(com.brashmonkey.spriter.animation.SpriterAnimation
			 animation)
        {
            foreach (System.Collections.Generic.KeyValuePair<com.brashmonkey.spriter.objects.SpriterObject
                , int> entry in objectsToTween.EntrySet())
            {
                com.brashmonkey.spriter.objects.SpriterObject toTween = entry.Key;
                com.brashmonkey.spriter.animation.SpriterKeyFrame frame = animation.frames[entry.
                    Value];
                long time = frame.getTime();
                com.brashmonkey.spriter.animation.SpriterKeyFrame currentFrame = animation.getPreviousFrameForObject
                    (toTween, time);
                com.brashmonkey.spriter.animation.SpriterKeyFrame nextFrame = animation.getNextFrameFor
                    (toTween, currentFrame, 1);
                if (nextFrame != currentFrame)
                {
                    com.brashmonkey.spriter.objects.SpriterObject object1 = currentFrame.getObjectFor
                        (toTween);
                    com.brashmonkey.spriter.objects.SpriterObject object2 = nextFrame.getObjectFor(toTween
                        );
                    this.interpolateSpriterObject(toTween, object1, object2, currentFrame.getTime(),
                        nextFrame.getTime(), time);
                }
                com.brashmonkey.spriter.objects.SpriterObject[] objects = new com.brashmonkey.spriter.objects.SpriterObject
                    [frame.getObjects().Length + 1];
                for (int i = 0; i < objects.Length - 1; i++)
                {
                    objects[i] = frame.getObjects()[i];
                }
                objects[objects.Length - 1] = toTween;
                frame.setObjects(objects);
            }
        }
Пример #7
0
 /// <summary>Manipulates the given object.</summary>
 /// <remarks>Manipulates the given object.</remarks>
 /// <param name="object"></param>
 public virtual void modSpriterObject(com.brashmonkey.spriter.objects.SpriterObject
                                      @object)
 {
     this.modObject(@object);
     @object.setAlpha(@object.getAlpha() * this.alpha);
 }
Пример #8
0
 /// <summary>Returns whether this frame has information about the given object.</summary>
 /// <remarks>Returns whether this frame has information about the given object.</remarks>
 /// <param name="object"></param>
 /// <returns>True if this frame contains the object, false otherwise.</returns>
 public virtual bool containsObject(com.brashmonkey.spriter.objects.SpriterObject
                                    @object)
 {
     return(this.getObjectFor(@object) != null);
 }
Пример #9
0
 //import com.brashmonkey.spriter.converters.SpriterObjectConverter;
 //import com.discobeard.spriter.dom.AnimationObject;
 //final private SpriterObjectConverter objectConverter = new SpriterObjectConverter();
 public virtual com.brashmonkey.spriter.animation.SpriterAnimation buildAnimation(
     com.discobeard.spriter.dom.Animation animation)
 {
     com.discobeard.spriter.dom.MainLine mainline = animation.getMainline();
     System.Collections.Generic.IList <com.discobeard.spriter.dom.TimeLine> timeLines =
         animation.getTimeline();
     System.Collections.Generic.IList <com.discobeard.spriter.dom.Key> keyFrames = mainline
                                                                                   .getKey();
     bonesToTween = new System.Collections.Generic.Dictionary <com.brashmonkey.spriter.objects.SpriterBone
                                                               , int>();
     objectsToTween = new System.Collections.Generic.Dictionary <com.brashmonkey.spriter.objects.SpriterObject
                                                                 , int>();
     com.brashmonkey.spriter.animation.SpriterAnimation spriterAnimation = new com.brashmonkey.spriter.animation.SpriterAnimation
                                                                               (animation.getId(), animation.getName(), animation.getLength());
     for (int k = 0; k < keyFrames.Count; k++)
     {
         com.discobeard.spriter.dom.Key mainlineKey = keyFrames[k];
         System.Collections.Generic.IList <com.brashmonkey.spriter.objects.SpriterObject> tempObjects
             = new System.Collections.Generic.List <com.brashmonkey.spriter.objects.SpriterObject
                                                    >();
         System.Collections.Generic.IList <com.brashmonkey.spriter.objects.SpriterBone> tempBones
             = new System.Collections.Generic.List <com.brashmonkey.spriter.objects.SpriterBone
                                                    >();
         com.brashmonkey.spriter.animation.SpriterKeyFrame frame = new com.brashmonkey.spriter.animation.SpriterKeyFrame
                                                                       ();
         frame.setTime(mainlineKey.getTime());
         frame.setId(mainlineKey.getId());
         foreach (com.discobeard.spriter.dom.BoneRef boneRef in mainlineKey.getBoneRef())
         {
             com.discobeard.spriter.dom.TimeLine         timeline    = timeLines[boneRef.getTimeline()];
             com.discobeard.spriter.dom.Key              timelineKey = timeline.getKey()[boneRef.getKey()];
             com.brashmonkey.spriter.objects.SpriterBone bone        = boneMerger.merge(boneRef, timelineKey
                                                                                        );
             bone.setName(timeline.getName());
             if (mainlineKey.getTime() != timelineKey.getTime())
             {
                 bonesToTween.Add(bone, k);
             }
             else
             {
                 tempBones.Add(bone);
             }
         }
         //}
         foreach (com.discobeard.spriter.dom.AnimationObjectRef objectRef in mainlineKey.getObjectRef
                      ())
         {
             com.discobeard.spriter.dom.TimeLine timeline    = timeLines[objectRef.getTimeline()];
             com.discobeard.spriter.dom.Key      timelineKey = timeline.getKey()[objectRef.getKey()
                                                               ];
             com.brashmonkey.spriter.objects.SpriterObject @object = objectMerger.merge(objectRef
                                                                                        , timelineKey);
             @object.setName(timeline.getName());
             if (mainlineKey.getTime() != timelineKey.getTime())
             {
                 objectsToTween.Add(@object, k);
             }
             else
             {
                 tempObjects.Add(@object);
             }
         }
         //}
         frame.setObjects(Sharpen.Collections.ToArray(tempObjects, new com.brashmonkey.spriter.objects.SpriterObject
                                                      [tempObjects.Count]));
         frame.setBones(Sharpen.Collections.ToArray(tempBones, new com.brashmonkey.spriter.objects.SpriterBone
                                                    [tempBones.Count]));
         spriterAnimation.frames.Add(frame);
     }
     this.tweenBones(spriterAnimation);
     this.tweenObjects(spriterAnimation);
     return(spriterAnimation);
 }
 /// <summary>Generates data which is necessary to animate all animations as intended.
 /// 	</summary>
 /// <remarks>
 /// Generates data which is necessary to animate all animations as intended.
 /// This method has to called inside the specific constructor.
 /// </remarks>
 protected internal void generateData()
 {
     int maxObjects = 0;
     int maxBones = 0;
     int maxBonesFrameIndex = 0;
     int maxObjectsFrameIndex = 0;
     int maxBonesAnimationIndex = 0;
     int maxObjectsAnimationIndex = 0;
     foreach (com.brashmonkey.spriter.animation.SpriterAnimation animation in this.animations)
     {
         foreach (com.brashmonkey.spriter.animation.SpriterKeyFrame frame in animation.frames)
         {
             maxBones = System.Math.Max(frame.getBones().Length, maxBones);
             if (maxBones == frame.getBones().Length)
             {
                 maxBonesFrameIndex = frame.getId();
                 maxBonesAnimationIndex = animation.id;
             }
             maxObjects = System.Math.Max(frame.getObjects().Length, maxObjects);
             if (maxObjects == frame.getObjects().Length)
             {
                 maxObjectsFrameIndex = frame.getId();
                 maxObjectsAnimationIndex = animation.id;
             }
             foreach (com.brashmonkey.spriter.objects.SpriterObject o in frame.getObjects())
             {
                 //o.setLoader(this.loader);
                 o.setRef(this.loader.findReference(o.getRef()));
             }
         }
     }
     this.instructions = new com.brashmonkey.spriter.draw.DrawInstruction[maxObjects];
     this.moddedObjects = new com.brashmonkey.spriter.objects.SpriterModObject[this.instructions
         .Length];
     this.tempObjects = new com.brashmonkey.spriter.objects.SpriterObject[this.instructions
         .Length];
     this.tempObjects2 = new com.brashmonkey.spriter.objects.SpriterObject[this.instructions
         .Length];
     this.nonTransformedTempObjects = new com.brashmonkey.spriter.objects.SpriterObject
         [this.instructions.Length];
     for (int i = 0; i < this.instructions.Length; i++)
     {
         this.instructions[i] = new com.brashmonkey.spriter.draw.DrawInstruction(null, 0,
             0, 0, 0, 0, 0, 0, 0);
         this.tempObjects[i] = new com.brashmonkey.spriter.objects.SpriterObject();
         this.tempObjects2[i] = new com.brashmonkey.spriter.objects.SpriterObject();
         this.nonTransformedTempObjects[i] = new com.brashmonkey.spriter.objects.SpriterObject
             ();
         this.nonTransformedTempObjects[i].setId(i);
         this.moddedObjects[i] = new com.brashmonkey.spriter.objects.SpriterModObject();
         this.moddedObjects[i].setId(i);
     }
     this.tempBones = new com.brashmonkey.spriter.objects.SpriterBone[maxBones];
     this.tempBones2 = new com.brashmonkey.spriter.objects.SpriterBone[tempBones.Length
         ];
     this.nonTransformedTempBones = new com.brashmonkey.spriter.objects.SpriterBone[tempBones
         .Length];
     this.moddedBones = new com.brashmonkey.spriter.objects.SpriterModObject[this.tempBones
         .Length];
     for (int i_1 = 0; i_1 < this.tempBones.Length; i_1++)
     {
         this.tempBones[i_1] = new com.brashmonkey.spriter.objects.SpriterBone();
         this.tempBones2[i_1] = new com.brashmonkey.spriter.objects.SpriterBone();
         this.nonTransformedTempBones[i_1] = new com.brashmonkey.spriter.objects.SpriterBone
             ();
         this.nonTransformedTempBones[i_1].setId(i_1);
         this.moddedBones[i_1] = new com.brashmonkey.spriter.objects.SpriterModObject();
         this.moddedBones[i_1].setId(i_1);
     }
     com.brashmonkey.spriter.objects.SpriterBone[] tmpBones1 = new com.brashmonkey.spriter.objects.SpriterBone
         [this.tempBones.Length];
     com.brashmonkey.spriter.objects.SpriterBone[] tmpBones2 = new com.brashmonkey.spriter.objects.SpriterBone
         [this.tempBones.Length];
     com.brashmonkey.spriter.objects.SpriterObject[] tmpObjs1 = new com.brashmonkey.spriter.objects.SpriterObject
         [this.instructions.Length];
     com.brashmonkey.spriter.objects.SpriterObject[] tmpObjs2 = new com.brashmonkey.spriter.objects.SpriterObject
         [this.instructions.Length];
     for (int i_2 = 0; i_2 < tmpObjs1.Length; i_2++)
     {
         tmpObjs1[i_2] = new com.brashmonkey.spriter.objects.SpriterObject();
         tmpObjs2[i_2] = new com.brashmonkey.spriter.objects.SpriterObject();
     }
     for (int i_3 = 0; i_3 < tmpBones1.Length; i_3++)
     {
         tmpBones1[i_3] = new com.brashmonkey.spriter.objects.SpriterBone();
         tmpBones2[i_3] = new com.brashmonkey.spriter.objects.SpriterBone();
     }
     this.lastFrame.setBones(tmpBones1);
     this.lastFrame.setObjects(tmpObjs1);
     this.lastTempFrame.setBones(tmpBones2);
     this.lastTempFrame.setObjects(tmpObjs2);
     foreach (com.brashmonkey.spriter.objects.SpriterObject @object in this.animations
         [maxObjectsAnimationIndex].frames[maxObjectsFrameIndex].getObjects())
     {
         for (int i_4 = 0; i_4 < this.nonTransformedTempObjects.Length; i_4++)
         {
             if (this.nonTransformedTempObjects[i_4].getId() == @object.getId())
             {
                 @object.copyValuesTo(this.nonTransformedTempObjects[i_4]);
             }
         }
     }
     foreach (com.brashmonkey.spriter.objects.SpriterBone bone in this.animations[maxBonesAnimationIndex
         ].frames[maxBonesFrameIndex].getBones())
     {
         for (int i_4 = 0; i_4 < this.nonTransformedTempBones.Length; i_4++)
         {
             if (this.nonTransformedTempBones[i_4].getId() == bone.getId())
             {
                 bone.copyValuesTo(this.nonTransformedTempBones[i_4]);
             }
         }
     }
     this.generated = true;
 }
Пример #11
0
 public virtual void addChildObject(com.brashmonkey.spriter.objects.SpriterObject
                                    @object)
 {
     @object.setParent(this);
     childObjects.AddLast(@object);
 }