public Figure Bake(Figure parentFigure) { if (Channels == null) { Channels = new List <ChannelRecipe>(); } if (Formulas == null) { Formulas = new List <FormulaRecipe>(); } if (Morphs == null) { Morphs = new List <MorphRecipe>(); } Geometry geometry = Geometry.Bake(); Dictionary <string, UvSet> uvSets = new Dictionary <string, UvSet>(); UvSets.ForEach(recipe => recipe.Bake(geometry, uvSets)); UvSet defaultUvSet = uvSets[Geometry.DefaultUvSet]; ChannelSystem channelSystem = new ChannelSystemRecipe(Channels, Formulas).Bake(parentFigure?.ChannelSystem); int graftVertexOffset = Geometry.VertexPositions.Length; List <MorphRecipe> rewrittenMorphRecipes = Automorpher != null?Automorpher.Rewrite(Morphs, parentFigure) : Morphs; List <Morph> morphs = rewrittenMorphRecipes.Select(recipe => recipe.Bake(channelSystem.ChannelsByName)).ToList(); Morpher morpher = new Morpher(morphs); Automorpher automorpher = Automorpher?.Bake(); BoneSystem selfBoneSystem = new BoneSystemRecipe(Bones).Bake(channelSystem.ChannelsByName); BoneSystem boneSystem; RigidTransform[] childToParentBindPoseTransforms; if (parentFigure != null) { boneSystem = parentFigure.BoneSystem; childToParentBindPoseTransforms = MakeChildToParentBindPoseTransforms(channelSystem, selfBoneSystem, boneSystem); } else { boneSystem = selfBoneSystem; childToParentBindPoseTransforms = null; } SkinBinding skinBinding = SkinBinding.Bake(boneSystem.BonesByName, selfBoneSystem.BonesByName); OcclusionBinding occlusionBinding = OcclusionBinding.MakeForFigure(Name, geometry, boneSystem, skinBinding); return(new Figure(Name, parentFigure, this, geometry, channelSystem, boneSystem, childToParentBindPoseTransforms, morpher, automorpher, skinBinding, uvSets, defaultUvSet, occlusionBinding)); }
public Figure(string name, Figure parent, FigureRecipe recipe, Geometry geometry, ChannelSystem channelSystem, BoneSystem boneSystem, RigidTransform[] childToParentBindPoseTransforms, Morpher morpher, Automorpher automorpher, SkinBinding skinBinding, Dictionary <string, UvSet> uvSets, UvSet defaultUvSet, OcclusionBinding occlusionBinding) { this.name = name; this.parent = parent; this.recipe = recipe; this.geometry = geometry; this.channelSystem = channelSystem; this.boneSystem = boneSystem; this.childToParentBindPoseTransforms = childToParentBindPoseTransforms; this.morpher = morpher; this.automorpher = automorpher; this.skinBinding = skinBinding; this.uvSets = uvSets; this.defaultUvSet = defaultUvSet; this.occlusionBinding = occlusionBinding; }