public NormalMapRenderer MakeNormalMapRenderer(Figure figureWithGrafts, UvSet uvSetWithGrafts, ChannelInputs shapeInputsWithGrafts)
    {
        /*
         * HUGE HACKS:
         * This class only works on figures without grafts whereas everything else works on figures with grafts.
         * So I have to convert the uvSet and shapeInputs the with-grafts figure to the without-grafts figure.
         */

        var uvSet = figure.UvSets[uvSetWithGrafts.Name];

        ChannelInputs ldInputs = figure.MakeDefaultChannelInputs();
        ChannelInputs hdInputs = figure.MakeDefaultChannelInputs();

        string hdCorrectionMorphChannelName = HdCorrectionMorphSynthesizer.CalcChannelName(figure.Name);

        foreach (var channel in figure.Channels)
        {
            var channelWithGrafts = figureWithGrafts.ChannelsByName[channel.Name];

            double value = channelWithGrafts.GetInputValue(shapeInputsWithGrafts);
            channel.SetValue(ldInputs, value);
            if (channel.Name != hdCorrectionMorphChannelName)
            {
                channel.SetValue(hdInputs, value);
            }
        }

        return(MakeNormalMapRenderer(ldInputs, hdInputs, uvSet));
    }
예제 #2
0
    public static FigureRecipe ImportFor(string figureName, DsonObjectLocator locator, FigureUris figureUris, FigureRecipe parentRecipe, double hdCorrectionInitialValue)
    {
        var geometryRecipe = GeometryImporter.ImportForFigure(locator, figureUris);

        FigureRecipe recipe = new FigureRecipe {
            Name        = figureName,
            Geometry    = geometryRecipe,
            Channels    = ChannelImporter.ImportForFigure(locator, figureUris).ToList(),
            Formulas    = FormulaImporter.ImportForFigure(locator, figureUris).ToList(),
            Bones       = BoneImporter.ImportForFigure(locator, figureUris).ToList(),
            Morphs      = MorphImporter.ImportForFigure(locator, figureUris).ToList(),
            SkinBinding = SkinBindingImporter.ImportForFigure(locator, figureUris),
            UvSets      = UvSetImporter.ImportForFigure(locator, figureUris, geometryRecipe).ToList()
        };

        Geometry geometry = recipe.Geometry.Bake();

        var correctionSynthesizer = new HdCorrectionMorphSynthesizer(figureName, geometry);

        recipe.Channels.Add(correctionSynthesizer.SynthesizeChannel(hdCorrectionInitialValue));
        recipe.Morphs.Add(correctionSynthesizer.SynthesizeMorph());

        if (parentRecipe != null)
        {
            Geometry parentGeometry = parentRecipe.Geometry.Bake();
            recipe.Automorpher = AutomorpherRecipe.Make(parentGeometry, geometry);
        }

        return(recipe);
    }