Пример #1
0
        public Location[] getAbsoluteMinMaxPoints()
        {
            /*
             * This will check children for their min X Y and Z values RELATIVE TO THIS OBJECT
             * THE RETURNED VALUE WILL BE RELATIVE TO THIS OBJECT, EXAMPLE;
             * THIS OBJECT IS AT 14, 14, 14
             * THIS MIN POINT IS -4, -2, -4 (MAKING ITS ABS POSITION AT 10, 12, 10)
             * THE CHILD IS AT 3, 3, 3 OF THIS, MAKING ITS ABS 17, 17, 17
             * THE CHILD MIN POINT IS -6, -6, -6 OF IT, MAKING ITS POSITION RELATIVE TO ITS OBJECT -3, -3, -3
             * THAT MAKES THE RELATAIVE MIN POINT -4, -3, -4 (X FROM THIS MIN, Y FROM CHILD MIN, Z FROM THIS MIN)
             * THAT MAKES THE ABSOLUTE MIN POINT AT 10, 11, 10
             *
             * RETURNS ARRAY TO INCREASE EFFICIENCY, BE SURE TO DISPOSE BOTH
             * getAbsoluteMinMaxPoints()[0] = min_point;
             * getAbsoluteMinMaxPoints()[1] = max_point;
             */
            double minX = (this.min == null ? 0 : this.min.getX());
            double minY = (this.min == null ? 0 : this.min.getY());
            double minZ = (this.min == null ? 0 : this.min.getZ());
            double maxX = (this.max == null ? 0 : this.max.getX());
            double maxY = (this.max == null ? 0 : this.max.getY());
            double maxZ = (this.max == null ? 0 : this.max.getZ());

            foreach (Model child in this.children)
            {
                Location[] minMaxPoints = child.getAbsoluteMinMaxPoints();
                Location   minPoint     = minMaxPoints[0];
                Location   maxPoint     = minMaxPoints[1];
                minPoint.add(child.getLocation());
                maxPoint.add(child.getLocation());
                //COMPARE VALUES
                if (minPoint.getX() < minX)
                {
                    minX = minPoint.getX();
                }
                if (minPoint.getY() < minY)
                {
                    minY = minPoint.getY();
                }
                if (minPoint.getZ() < minZ)
                {
                    minZ = minPoint.getZ();
                }
                //MAX VALUES
                if (maxPoint.getX() > maxX)
                {
                    maxX = maxPoint.getX();
                }
                if (maxPoint.getY() > maxY)
                {
                    maxY = maxPoint.getY();
                }
                if (maxPoint.getZ() > maxZ)
                {
                    maxZ = maxPoint.getZ();
                }

                //Clean.. soo clean
                minPoint.Dispose();
                maxPoint.Dispose();
            }
            Location aMinPoint = new Location(minX, minY, minZ);
            Location aMaxPoint = new Location(maxX, maxY, maxZ);

            return(new Location[] { aMinPoint, aMaxPoint });
        }
Пример #2
0
        public virtual void tick()
        {
            foreach (AnimationRule rule in this.getAnimationRules())
            {
                lock (rule) {
                    Locateable obj = this.getObject(rule.getObjectID());
                    if (obj == null)
                    {
                        continue;
                    }
                    if (rule.getAnimationType().Equals(AnimationFramingType.FRAME_BY_FRAME))
                    {
                        if (this.getFrame() != rule.getFrame())
                        {
                            continue;
                        }
                        obj.getLocation().set(rule.getTarget());
                    }
                    else if (rule.getAnimationType().Equals(AnimationFramingType.TWEEN))
                    {
                        if (frame < rule.getStartFrame())
                        {
                            continue;
                        }
                        if (frame > (rule.getStartFrame() + rule.getFrame()))
                        {
                            continue;
                        }
                        Location target = rule.getTarget().clone();
                        target.sub(rule.getStartingPosition());

                        double amt        = 0;
                        int    tweenFrame = frame - rule.getStartFrame();
                        double tf         = (double)tweenFrame;

                        double animation_complete_percent = (double)tweenFrame / (double)(rule.getFrame());
                        double curve = (double)rule.getTweenCurve() / 100.0d;
                        double curve_addition_offset = curve * (1 - animation_complete_percent);

                        amt = tf / (double)rule.getFrame();

                        target.multiply(amt);
                        Location q = target.clone();
                        q.multiply(curve_addition_offset);
                        target.add(q);

                        target.add(rule.getStartingPosition());
                        if (rule.isRelative())
                        {
                            target.add(rule.originalLocation);
                        }

                        obj.getLocation().set(target);

                        //Target Dispose
                        target.Dispose();
                        q.Dispose();
                    }
                }
            }
            frame++;
            if (frame > this.getTotalFrames())
            {
                if (loop)
                {
                    frame = 0;
                }
                else
                {
                    this.Dispose();
                }
            }
        }