コード例 #1
0
	public AnimationExportData (Transform transform, bool useQuaternion)
	{
		t = transform;

		Animator ator = t.GetComponent<Animator>();

		a = ator.runtimeAnimatorController;

		defaultAnimation = a.animationClips[0];

		AnimationClipCurveData[] data = AnimationUtility.GetAllCurves (defaultAnimation, true);
		properties = new Hashtable();

		foreach (AnimationClipCurveData d in data) {
			
			string jn = AnimationUtil.ExtractPropertyName (d.propertyName);

			if(!properties.ContainsKey (d.path))
				properties.Add(d.path, new AnimationObject(d.path));

			AnimationObject ao = (AnimationObject) properties[d.path];

			AnimationProperty p = new AnimationProperty (jn, d);
			ao.Properties.Add(p);
		}
	}
コード例 #2
0
        public double PlayAnimation(double time, double oldTime, Guid key)
        {
            bool value = true;
            List <AnimationProperty> animationPropertyList;
            ToolboxItem toolboxItem;
            double      stopMinute = 0;


            if (Math.Round(Math.Abs(time - oldTime), 1) != 0.1 && time != 0)
            {
                SetProgress(time);
            }
            foreach (var v in timeLineItemList)
            {
                if (v.TimePointList.FirstOrDefault(model => model.Point == time && v.Id == key) == null)
                {
                    continue;
                }
                animationPropertyList = GetItem(time);
                AnimationProperty animationProperty = animationPropertyList.Find(p => p.ItemId == key);

                stopMinute = Math.Max(animationProperty.timeSpan.TotalSeconds, stopMinute);

                foreach (var vv in v.TimePointList)//遇到不自动播放的祯,返回false,暂停播放。
                {
                    if (!vv.AutoPlay)
                    {
                        value = false;
                    }
                }

                toolboxItem = GetToolboxItem(v.Id);
                if (toolboxItem == null)
                {
                    return(-1);
                }
                switch (toolboxItem.AssetType)
                {
                case AssetType.Sound:
                    ((MediaPlayer)toolboxItem.Content).Play();
                    break;

                case AssetType.Movie:
                    ((MediaElement)toolboxItem.Content).Position = new TimeSpan(0, 0, 0, 0, Convert.ToInt32(time * 100));
                    ((MediaElement)toolboxItem.Content).Play();
                    break;

                default:
                    Play(animationProperty, toolboxItem);
                    break;
                }
            }
            if (!value)
            {
                return(stopMinute);
            }
            else
            {
                return(-1);
            }
        }
コード例 #3
0
 set => SetValue(AnimationProperty, value);
コード例 #4
0
ファイル: AnimationExportData.cs プロジェクト: theDrGray/J3D
    public AnimationExportData(Transform transform, bool useQuaternion, float samplesPerSec)
    {
        t = transform;
        a = t.animation;

        samplingRate = 1.0f / samplesPerSec;

        AnimationClipCurveData[] data = AnimationUtility.GetAllCurves(a.clip, true);
        properties = new Hashtable();

        foreach (AnimationClipCurveData d in data)
        {
            string un       = d.propertyName;
            string jn       = AnimationUtil.ExtractPropertyName(un);
            bool   doExport = AnimationUtil.CheckForEulerHint(un);

            //Debug.Log ("Property: " + un + " as " + jn + " is exported " + doExport);

            AnimationProperty p = new AnimationProperty(jn);

            numSamples = 0;
            for (float i = 0; i <= a.clip.length; i += samplingRate)
            {
                p.Samples.Add(d.curve.Evaluate(i));
                numSamples++;
            }

            if (doExport)
            {
                properties.Add(jn, p);
            }
        }

        for (int i = 0; i < numSamples; i++)
        {
            if (properties.ContainsKey("pz"))
            {
                float px = ((AnimationProperty)properties["px"]).Samples[i];
                float py = ((AnimationProperty)properties["py"]).Samples[i];
                float pz = ((AnimationProperty)properties["pz"]).Samples[i];
                pz = -pz;
                ((AnimationProperty)properties["px"]).SamplesEx.Add(px.ToString(ExporterProps.LN));
                ((AnimationProperty)properties["py"]).SamplesEx.Add(py.ToString(ExporterProps.LN));
                ((AnimationProperty)properties["pz"]).SamplesEx.Add(pz.ToString(ExporterProps.LN));
            }

            if (properties.ContainsKey("rx"))
            {
                Quaternion r = new Quaternion();
                r.x = ((AnimationProperty)properties["rx"]).Samples[i];
                r.y = ((AnimationProperty)properties["ry"]).Samples[i];
                r.z = -((AnimationProperty)properties["rz"]).Samples[i];
                r.w = ((AnimationProperty)properties["rw"]).Samples[i];

                r = Conversions.NormalizeQuaternion(r);

                if (!useQuaternion)
                {
                    Vector3 e = Conversions.SwitchRotation(r);
                    ((AnimationProperty)properties["rx"]).SamplesEx.Add(e.x.ToString(ExporterProps.LN));
                    ((AnimationProperty)properties["ry"]).SamplesEx.Add(e.y.ToString(ExporterProps.LN));
                    ((AnimationProperty)properties["rz"]).SamplesEx.Add(e.z.ToString(ExporterProps.LN));
                }
                else
                {
                    ((AnimationProperty)properties["rx"]).SamplesEx.Add(r.x.ToString(ExporterProps.LN));
                    ((AnimationProperty)properties["ry"]).SamplesEx.Add(r.y.ToString(ExporterProps.LN));
                    ((AnimationProperty)properties["rz"]).SamplesEx.Add(r.z.ToString(ExporterProps.LN));
                    ((AnimationProperty)properties["rw"]).SamplesEx.Add(r.w.ToString(ExporterProps.LN));
                }

                /*
                 * Vector3 r = new Vector3();
                 * r.x = ( (AnimationProperty) properties["rx"] ).Samples[i];
                 * r.y = ( (AnimationProperty) properties["ry"] ).Samples[i];
                 * r.z = ( (AnimationProperty) properties["rz"] ).Samples[i];
                 *
                 * ( (AnimationProperty) properties["rx"] ).SamplesEx.Add ( r.x.ToString (ExporterProps.LN) );
                 * ( (AnimationProperty) properties["ry"] ).SamplesEx.Add ( r.y.ToString (ExporterProps.LN) );
                 * ( (AnimationProperty) properties["rz"] ).SamplesEx.Add ( r.z.ToString (ExporterProps.LN) );
                 */
            }
        }
    }
コード例 #5
0
ファイル: AnimationExportData.cs プロジェクト: fhchina/J3D
    public AnimationExportData(Transform transform, bool useQuaternion, float samplesPerSec)
    {
        t = transform;
        a = t.animation;

        samplingRate = 1.0f / samplesPerSec;

        AnimationClipCurveData[] data = AnimationUtility.GetAllCurves (a.clip, true);
        properties = new Hashtable();

        foreach (AnimationClipCurveData d in data) {
            string un = d.propertyName;
            string jn = AnimationUtil.ExtractPropertyName (un);
            bool doExport = AnimationUtil.CheckForEulerHint (un);

            //Debug.Log ("Property: " + un + " as " + jn + " is exported " + doExport);

            AnimationProperty p = new AnimationProperty (jn);

            numSamples = 0;
            for (float i = 0; i <= a.clip.length; i += samplingRate) {
                p.Samples.Add(d.curve.Evaluate(i));
                numSamples++;
            }

            if (doExport)
                properties.Add (jn, p);
        }

        for(int i = 0; i < numSamples; i++) {
            if(properties.ContainsKey("pz")) {
                float px = ( (AnimationProperty) properties["px"] ).Samples[i];
                float py = ( (AnimationProperty) properties["py"] ).Samples[i];
                float pz = ( (AnimationProperty) properties["pz"] ).Samples[i];
                pz = -pz;
                ( (AnimationProperty) properties["px"] ).SamplesEx.Add ( px.ToString (ExporterProps.LN) );
                ( (AnimationProperty) properties["py"] ).SamplesEx.Add ( py.ToString (ExporterProps.LN) );
                ( (AnimationProperty) properties["pz"] ).SamplesEx.Add ( pz.ToString (ExporterProps.LN) );
            }

            if(properties.ContainsKey("rx")) {
                Quaternion r = new Quaternion();
                r.x = ( (AnimationProperty) properties["rx"] ).Samples[i];
                r.y = ( (AnimationProperty) properties["ry"] ).Samples[i];
                r.z = -( (AnimationProperty) properties["rz"] ).Samples[i];
                r.w = ( (AnimationProperty) properties["rw"] ).Samples[i];

                r = Conversions.NormalizeQuaternion(r);

                if(!useQuaternion) {
                    Vector3 e = Conversions.SwitchRotation(r);
                    ( (AnimationProperty) properties["rx"] ).SamplesEx.Add ( e.x.ToString (ExporterProps.LN) );
                    ( (AnimationProperty) properties["ry"] ).SamplesEx.Add ( e.y.ToString (ExporterProps.LN) );
                    ( (AnimationProperty) properties["rz"] ).SamplesEx.Add ( e.z.ToString (ExporterProps.LN) );
                } else {
                    ( (AnimationProperty) properties["rx"] ).SamplesEx.Add ( r.x.ToString (ExporterProps.LN) );
                    ( (AnimationProperty) properties["ry"] ).SamplesEx.Add ( r.y.ToString (ExporterProps.LN) );
                    ( (AnimationProperty) properties["rz"] ).SamplesEx.Add ( r.z.ToString (ExporterProps.LN) );
                    ( (AnimationProperty) properties["rw"] ).SamplesEx.Add ( r.w.ToString (ExporterProps.LN) );
                }

                /*
                Vector3 r = new Vector3();
                r.x = ( (AnimationProperty) properties["rx"] ).Samples[i];
                r.y = ( (AnimationProperty) properties["ry"] ).Samples[i];
                r.z = ( (AnimationProperty) properties["rz"] ).Samples[i];

                ( (AnimationProperty) properties["rx"] ).SamplesEx.Add ( r.x.ToString (ExporterProps.LN) );
                ( (AnimationProperty) properties["ry"] ).SamplesEx.Add ( r.y.ToString (ExporterProps.LN) );
                ( (AnimationProperty) properties["rz"] ).SamplesEx.Add ( r.z.ToString (ExporterProps.LN) );
                */
            }
        }
    }
コード例 #6
0
ファイル: PageStage.xaml.cs プロジェクト: LoveChiba/jg.editor
        void Play(AnimationProperty animationProperty, ToolboxItem toolboxItem)
        {
            TransformGroup     transformGroup;
            RotateTransform    rotateTransform;
            ScaleTransform     scaleTransform;
            SkewTransform      skewTransform;
            TranslateTransform translateTransform;

            var vv = animationProperty;

            if (vv == null)
            {
                return;
            }
            if (vv.tp1 == null || vv.tp2 == null)
            {
                return;
            }
            foreach (var vvv in vv.tp1.propertyList)
            {
                switch (vvv.propertyEnum)
                {
                case PropertyEnum.ColorProperty:
                    break;

                case PropertyEnum.DoubleProperty:
                    double v1, v2;
                    AssetDoubleProperty dp1, dp2;
                    dp1 = vvv as AssetDoubleProperty;
                    dp2 = vv.tp2.propertyList.Find(model => model.Name == dp1.Name) as AssetDoubleProperty;
                    if (dp1 == null || dp2 == null)
                    {
                        break;
                    }
                    if (dp1.Value == dp2.Value)
                    {
                        continue;
                    }
                    v1 = dp1.Value;
                    v2 = dp2.Value;

                    DoubleAnimation doubleAnimation = new DoubleAnimation(v1, v2, vv.timeSpan);

                    switch (vvv.Name)
                    {
                    case "PropertyFontSizeCommand":        // 字号动画
                        Animation(toolboxItem, DesignerItem.FontSizeProperty, doubleAnimation);
                        break;

                    case "PropertyXCommand":         // X轴动画
                        Animation(toolboxItem, Canvas.LeftProperty, doubleAnimation);
                        break;

                    case "PropertyYCommand":        // Y轴动画
                        Animation(toolboxItem, Canvas.TopProperty, doubleAnimation);
                        break;

                    case "PropertyWidthCommand":        // 宽度动画
                        Animation(toolboxItem, DesignerItem.WidthProperty, doubleAnimation);
                        break;

                    case "PropertyHeightCommand":        // 高度动画
                        Animation(toolboxItem, DesignerItem.HeightProperty, doubleAnimation);
                        break;

                    case "PropertyOpacityCommand":         // 透明度
                        Animation(toolboxItem, Canvas.OpacityProperty, doubleAnimation);
                        break;

                    case "PropertyRotateCommand":        // 旋转动画
                        transformGroup = toolboxItem.RenderTransform as TransformGroup;
                        if (null == transformGroup)
                        {
                            return;
                        }
                        rotateTransform = transformGroup.Children.FirstOrDefault(model => model.GetType().Name == "RotateTransform") as RotateTransform;
                        if (rotateTransform != null)
                        {
                            Animation(rotateTransform, RotateTransform.AngleProperty, doubleAnimation);
                        }
                        break;

                    case "PropertyScaleXCommand":        // X轴缩放
                        transformGroup = toolboxItem.RenderTransform as TransformGroup;
                        if (null == transformGroup)
                        {
                            return;
                        }
                        scaleTransform = transformGroup.Children.FirstOrDefault(model => model.GetType().Name == "ScaleTransform") as ScaleTransform;
                        if (scaleTransform != null)
                        {
                            Animation(scaleTransform, ScaleTransform.ScaleXProperty, doubleAnimation);
                        }
                        break;

                    case "PropertyScaleYCommand":        // X轴缩放
                        transformGroup = toolboxItem.RenderTransform as TransformGroup;
                        if (null == transformGroup)
                        {
                            return;
                        }
                        scaleTransform = transformGroup.Children.FirstOrDefault(model => model.GetType().Name == "ScaleTransform") as ScaleTransform;
                        if (scaleTransform != null)
                        {
                            Animation(scaleTransform, ScaleTransform.ScaleYProperty, doubleAnimation);
                        }
                        break;

                    case "PropertySkewXCommand":        // X轴2D变幻
                        transformGroup = toolboxItem.RenderTransform as TransformGroup;
                        if (null == transformGroup)
                        {
                            return;
                        }
                        skewTransform = transformGroup.Children.FirstOrDefault(model => model.GetType().Name == "SkewTransform") as SkewTransform;
                        if (skewTransform != null)
                        {
                            Animation(skewTransform, SkewTransform.AngleXProperty, doubleAnimation);
                        }
                        break;

                    case "PropertySkewYCommand":        // Y轴2D变幻
                        transformGroup = toolboxItem.RenderTransform as TransformGroup;
                        if (null == transformGroup)
                        {
                            return;
                        }
                        skewTransform = transformGroup.Children.FirstOrDefault(model => model.GetType().Name == "SkewTransform") as SkewTransform;
                        if (skewTransform != null)
                        {
                            Animation(skewTransform, SkewTransform.AngleYProperty, doubleAnimation);
                        }
                        break;

                    case "PropertyTranslateXCommand":        // X轴平移
                        transformGroup = toolboxItem.RenderTransform as TransformGroup;
                        if (null == transformGroup)
                        {
                            return;
                        }
                        translateTransform = transformGroup.Children.FirstOrDefault(model => model.GetType().Name == "TranslateTransform") as TranslateTransform;
                        if (translateTransform != null)
                        {
                            Animation(translateTransform, TranslateTransform.XProperty, doubleAnimation);
                        }
                        break;

                    case "PropertyTranslateYCommand":        // Y轴平移
                        transformGroup = toolboxItem.RenderTransform as TransformGroup;
                        if (null == transformGroup)
                        {
                            return;
                        }
                        translateTransform = transformGroup.Children.FirstOrDefault(model => model.GetType().Name == "TranslateTransform") as TranslateTransform;
                        if (translateTransform != null)
                        {
                            Animation(translateTransform, TranslateTransform.YProperty, doubleAnimation);
                        }
                        break;
                    }
                    break;
                }
            }
        }
コード例 #7
0
        public ComponentInfo Copy()
        {
            List <HelperRectangle> newRectangles = new List <HelperRectangle>();

            foreach (HelperRectangle rect in HelperRectangles)
            {
                newRectangles.Add(rect.Copy());
            }

            Dictionary <string, ComponentProperty> newProperties = new Dictionary <string, ComponentProperty>();

            foreach (KeyValuePair <string, ComponentProperty> pair in Properties)
            {
                newProperties.Add((string)pair.Key.Clone(), pair.Value.Copy());
            }

            var newComponent = new ComponentInfo((string)RealName.Clone(), (string)ClassName.Clone(), DefaultAnimation.Copy(), (string)AnimationProperty.Clone(), newRectangles, newProperties);

            newComponent.SetAnimKey        = (string)SetAnimKey.Clone();
            newComponent._CurrentAnimation = _CurrentAnimation;

            return(newComponent);
        }
コード例 #8
0
ファイル: Animation.cs プロジェクト: stratts/Wisp
 public AnimationTrack(AnimationProperty property, EaseType tweenType)
 {
     Property = property;
     Ease     = tweenType;
 }
コード例 #9
0
ファイル: Animation.cs プロジェクト: stratts/Wisp
 public AnimationTrack(AnimationProperty property)
 {
     Property = property;
     Ease     = EaseType.None;
 }
コード例 #10
0
        private void btnGenerateAnim_Click(object sender, EventArgs e)
        {
            AnimationProperty property = (AnimationProperty)cbSelectProperty.SelectedIndex;

            //generate values out of keyframes
            if (property == AnimationProperty.TRANSLATION_X)
            {
                m_animEntry.m_TranslationXValues = new List <float>();
                for (int i = 0; i < m_animations[m_animId].m_NumFrames; i++)
                {
                    m_animEntry.m_TranslationXValues.Add(InterpolatedValue(m_keyFrames, i) * (float)numScaling.Value);
                }
            }
            else if (property == AnimationProperty.TRANSLATION_Y)
            {
                m_animEntry.m_TranslationYValues = new List <float>();
                for (int i = 0; i < m_animations[m_animId].m_NumFrames; i++)
                {
                    m_animEntry.m_TranslationYValues.Add(InterpolatedValue(m_keyFrames, i) * (float)numScaling.Value);
                }
            }
            else if (property == AnimationProperty.ROTATION)
            {
                m_animEntry.m_RotationValues = new List <float>();
                for (int i = 0; i < m_animations[m_animId].m_NumFrames; i++)
                {
                    float wrappedValue = Helper.Wrap(InterpolatedValue(m_keyFrames, i) * (float)numScaling.Value, 360);
                    if (wrappedValue <= 180)
                    {
                        m_animEntry.m_RotationValues.Add(wrappedValue);
                    }
                    else
                    {
                        m_animEntry.m_RotationValues.Add(wrappedValue - 360);
                    }
                }
            }
            else
            {
                m_animEntry.m_ScaleValues = new List <float>();
                for (int i = 0; i < m_animations[m_animId].m_NumFrames; i++)
                {
                    m_animEntry.m_ScaleValues.Add(InterpolatedValue(m_keyFrames, i) * (float)numScaling.Value);
                }
            }

            //add to unsaved
            if (m_unsavedEntries[m_animId].ContainsKey(m_animEntry.m_MaterialName))
            {
                m_unsavedEntries[m_animId][m_animEntry.m_MaterialName] = m_animEntry;
            }
            else
            {
                m_unsavedEntries[m_animId].Add(m_animEntry.m_MaterialName, m_animEntry);
            }

            //switch panels
            valueSettingPanel1.Visible = true;
            valueSettingPanel2.Visible = false;
            valueSettingPanel1.BringToFront();
            StopAnimation();
            tvMaterials.Enabled = true;
            btnNextPart.Visible = true;
            btnPrevPart.Visible = true;

            InitializeTimeLine(property);
        }