Exemplo n.º 1
0
    /*
     * Come here when "save animation" button has been pressed.
     * Bring up file save dialog
     */
    protected void OnSaveAnimClicked(object sender, EventArgs e)
    {
        string  selected = animationsLoaded.SelectedItem as string;
        dynamic g        = _currentGarment;

        if ((selected == null) || (g == null))
        {
            return;
        }
        if (_clothAnim == null)
        {
            _clothAnim = new MagicMirror.Viewer.ClothRecorder(_timeinc);
        }
        else if (recordButton.IsChecked == true)
        {
            _clothAnim.SaveAnimation();
            recordButton.IsChecked = false;
            return;
        }
        Vixen.Engine saveme;
        string       name = selected + "_" + g.name;

        _clothAnim.AnimName = selected;
        _clothAnim.BaseName = g.name;
        saveme = avatarCanvas.FindAnimation(name);
        if ((saveme != null) && (typeof(Vixen.Animator).IsAssignableFrom(saveme.GetType())))
        {
            Vixen.Animator     anim = (Vixen.Animator)saveme;
            Vixen.Engine       root = anim.GetRootEngine();
            Vixen.MeshAnimator meshanim;

            if ((root != null) && typeof(Vixen.MeshAnimator).IsAssignableFrom(root.GetType()))
            {
                meshanim = (Vixen.MeshAnimator)root;
                _clothAnim.SaveAnimation(meshanim);
            }
        }
        recordButton.IsChecked = false;
    }
Exemplo n.º 2
0
    private bool ConnectClothAnim(Garment garment)
    {
        try
        {
            dynamic           g         = garment;
            Vixen.Model       clothmesh = garment.ClothMesh;
            Vixen.SharedWorld world     = Vixen.SharedWorld.Get();
            dynamic           d         = avatarCanvas.ConfigOpts;

            if (d.timeinc != null)
            {
                _timeinc = (float)Double.Parse(d.timeinc);
            }
            if (clothmesh == null)
            {
                return(false);
            }
            if (_clothAnim == null)
            {
                _clothAnim = new MagicMirror.Viewer.ClothRecorder(_timeinc);
            }
            else
            {
                _clothAnim.Clear();
            }
            _clothAnim.BaseName = g.Name;
            world.SuspendScene();
            _clothAnim.AnimRoot = null;
            _clothAnim.MeshRoot = clothmesh;
            _clothAnim.AnimRoot.PutAfter(Vixen.Physics.Get());
            world.ResumeScene();
            return(true);
        }
        catch (Exception ex)
        {
            Vixen.SharedWorld.LogError(ex.Message);
        }
        return(false);
    }