public void ImportFrom(DsonTypes.Modifier modifier)
 {
     if (modifier.skin != null)
     {
         Import(modifier.skin);
     }
 }
Пример #2
0
    public void ImportFrom(DsonTypes.Modifier modifier)
    {
        if (modifier.channel == null)
        {
            return;
        }

        string scope;

        DsonTypes.DsonObject parent = modifier.parent.ReferencedObject;
        if (parent is DsonTypes.Node)
        {
            if (parent.id == rootScope)
            {
                scope = null;
            }
            else
            {
                scope = parent.id;
            }
        }
        else
        {
            //if parent is not a node, then assume it's a geometry attached to the root node
            scope = null;
        }

        string pathPrefix = "";

        if (modifier.presentation?.type?.StartsWith("Modifier/Shape") ?? false)
        {
            pathPrefix += "/Shapes";
        }

        if (modifier.region != null)
        {
            pathPrefix += "/" + modifier.region;
        }

        if (modifier.group != null)
        {
            pathPrefix += modifier.group;
        }

        string name = modifier.name;

        if (scope != null)
        {
            name = scope + ":" + name;
        }

        Import(modifier.channel, "value", name + "?value", pathPrefix);
    }
Пример #3
0
    public void ImportFrom(DsonTypes.Modifier modifier)
    {
        DsonTypes.Morph dsonMorph = modifier.morph;
        if (dsonMorph == null)
        {
            return;
        }

        float[][] dsonDeltas = dsonMorph.deltas?.values;
        if (dsonDeltas == null || dsonDeltas.Length == 0)
        {
            return;
        }

        if (modifier.channel.id != "value")
        {
            throw new InvalidOperationException("expected channel id to be 'value'");
        }
        string channel = modifier.name + "?value";

        int deltaCount = dsonDeltas.Length;

        MorphDelta[] deltas = new MorphDelta[deltaCount];
        for (int i = 0; i < deltaCount; ++i)
        {
            float[] dsonDelta      = dsonDeltas[i];
            int     vertexIdx      = (int)dsonDelta[0];
            Vector3 positionOffset = new Vector3(dsonDelta[1], dsonDelta[2], dsonDelta[3]);
            deltas[i] = new MorphDelta(vertexIdx, positionOffset);
        }

        var hdUrl = ExtractHdUrl(dsonMorph.hd_url);

        MorphRecipe recipe = new MorphRecipe {
            Channel = channel,
            Deltas  = deltas,
            HdUrl   = hdUrl
        };

        morphRecipes.Add(recipe);
    }