コード例 #1
0
    public static AnimationModel Load(FigureDefinition figureDefinition, string startingAnimationName)
    {
        List <Animation> animations      = new List <Animation>();
        Animation        activeAnimation = null;

        Animation noneAnimation = Animation.MakeNone(figureDefinition.BoneSystem);

        animations.Add(noneAnimation);
        activeAnimation = noneAnimation;

        IArchiveDirectory animationDir = figureDefinition.Directory.Subdirectory("animations");

        if (animationDir != null)
        {
            foreach (IArchiveFile animationFile in animationDir.GetFiles())
            {
                Animation animation = Animation.Load(animationFile);
                animations.Add(animation);
                if (animation.Label == startingAnimationName)
                {
                    activeAnimation = animation;
                }
            }
        }

        return(new AnimationModel(animations, activeAnimation));
    }
コード例 #2
0
    public CharactersMenuLevel(FigureDefinition definition, FigureModel model)
    {
        var materialSetDict = definition.MaterialSetOptions.ToDictionary(item => item.Label, item => item);

        var shapesMenuLevel    = new ShapesMenuLevel(definition, model);
        var materialsMenuLevel = new MaterialsMenuLevel(definition, model);
        var advancedMenuLevel  = new StaticMenuLevel(
            new SubLevelMenuItem("Shape", shapesMenuLevel),
            new SubLevelMenuItem("Skin", materialsMenuLevel)
            );

        var detailsMenuLevel = new MaterialSetVariantsMenuLevel(definition, model);

        items = new List <IMenuItem> {
        };
        items.Add(new SubLevelMenuItem("Mix & Match", advancedMenuLevel));
        items.Add(new SubLevelMenuItem("Character Details", detailsMenuLevel));
        foreach (var shape in definition.ShapeOptions)
        {
            if (materialSetDict.TryGetValue(shape.Label, out var materialSet))
            {
                items.Add(new CharacterMenuItem(model, shape, materialSet));
            }
        }
    }
コード例 #3
0
ファイル: ActorModel.cs プロジェクト: smygarn/virtually-naked
    public static ActorModel Load(FigureDefinition definition, string initialAnimationName)
    {
        AnimationModel animationModel = AnimationModel.Load(definition, initialAnimationName);
        BehaviorModel  behaviorModel  = new BehaviorModel();

        return(new ActorModel(definition, animationModel, behaviorModel));
    }
コード例 #4
0
    public static FigureDefinition Load(IArchiveDirectory dataDir, string name, FigureDefinition parent)
    {
        IArchiveDirectory figureDir = dataDir.Subdirectory("figures").Subdirectory(name);

        var channelSystemRecipe = Persistance.Load <ChannelSystemRecipe>(figureDir.File("channel-system-recipe.dat"));
        var channelSystem       = channelSystemRecipe.Bake(parent?.ChannelSystem);

        BoneSystem boneSystem;

        RigidTransform[] childToParentBindPoseTransforms;
        if (parent != null)
        {
            boneSystem = parent.BoneSystem;
            childToParentBindPoseTransforms = Persistance.Load <RigidTransform[]>(figureDir.File("child-to-parent-bind-pose-transforms.dat"));
        }
        else
        {
            var boneSystemRecipe = Persistance.Load <BoneSystemRecipe>(figureDir.File("bone-system-recipe.dat"));
            boneSystem = boneSystemRecipe.Bake(channelSystem.ChannelsByName);
            childToParentBindPoseTransforms = null;
        }

        var shapeOptions       = Shape.LoadAllForFigure(figureDir, channelSystem);
        var materialSetOptions = MaterialSetOption.LoadAllForFigure(figureDir);

        return(new FigureDefinition(name, figureDir,
                                    channelSystem, boneSystem,
                                    childToParentBindPoseTransforms,
                                    shapeOptions, materialSetOptions));
    }
コード例 #5
0
    public GpuShaper(Device device, ShaderCache shaderCache, FigureDefinition definition, ShaperParameters parameters)
    {
        this.device              = device;
        this.withDeltasShader    = shaderCache.GetComputeShader <GpuShaper>("figure/shaping/shader/Shaper-WithDeltas");
        this.withoutDeltasShader = shaderCache.GetComputeShader <GpuShaper>("figure/shaping/shader/Shaper-WithoutDeltas");

        this.vertexCount         = parameters.InitialPositions.Length;
        this.morphChannelIndices = parameters.MorphChannelIndices;
        this.boneIndices         = parameters.BoneIndices;
        this.occlusionSurrogates = OcclusionSurrogate.MakeAll(definition, parameters.OcclusionSurrogateParameters);

        this.initialPositionsView      = BufferUtilities.ToStructuredBufferView(device, parameters.InitialPositions);
        this.deltaSegmentsView         = BufferUtilities.ToStructuredBufferView(device, parameters.MorphDeltas.Segments);
        this.deltaElemsView            = BufferUtilities.ToStructuredBufferView(device, parameters.MorphDeltas.Elems);
        this.morphWeightsBufferManager = new StructuredBufferManager <float>(device, parameters.MorphCount);

        if (parameters.BaseDeltaWeights != null)
        {
            this.baseDeltaWeightSegmentsView = BufferUtilities.ToStructuredBufferView(device, parameters.BaseDeltaWeights.Segments);
            this.baseDeltaWeightElemsView    = BufferUtilities.ToStructuredBufferView(device, parameters.BaseDeltaWeights.Elems);
        }
        else
        {
            this.baseDeltaWeightSegmentsView = null;
            this.baseDeltaWeightElemsView    = null;
        }

        this.boneWeightSegmentsView      = BufferUtilities.ToStructuredBufferView(device, parameters.BoneWeights.Segments);
        this.boneWeightElemsView         = BufferUtilities.ToStructuredBufferView(device, parameters.BoneWeights.Elems);
        this.boneTransformsBufferManager = new StructuredBufferManager <StagedSkinningTransform>(device, parameters.BoneCount);

        this.occlusionSurrogateMapView            = BufferUtilities.ToStructuredBufferView(device, parameters.OcclusionSurrogateMap);
        this.occlusionSurrogateFacesView          = BufferUtilities.ToStructuredBufferView(device, OcclusionSurrogateCommon.Mesh.Faces.ToArray());
        this.occlusionSurrogateInfosBufferManager = new StructuredBufferManager <OcclusionSurrogate.Info>(device, parameters.OcclusionSurrogateParameters.Length);
    }
コード例 #6
0
 public OccluderLoader(Device device, ShaderCache shaderCache, FigureDefinition figureDefinition)
 {
     this.device                 = device;
     this.shaderCache            = shaderCache;
     channelSystem               = figureDefinition.ChannelSystem;
     unmorphedOcclusionDirectory = figureDefinition.Directory.Subdirectory("occlusion");
 }
コード例 #7
0
 public FigureFacade(Device device, ShaderCache shaderCache, FigureDefinition definition, FigureModel model, ControlVertexProvider controlVertexProvider, FigureRendererLoader figureRendererLoader)
 {
     this.definition            = definition;
     this.model                 = model;
     this.controlVertexProvider = controlVertexProvider;
     this.figureRendererLoader  = figureRendererLoader;
 }
コード例 #8
0
    public void AddFigure()
    {
        var figure = new FigureDefinition();

        mSettings.Geometry_Figures.Add(figure);
        Instantiate(mFigurePrefab, mTree).GetComponent <Figure>().Init(figure);
        Instantiate(mUIFigurePrefab, mUITree).GetComponent <UIFigure>().Init(figure);
    }
コード例 #9
0
    public void Init(FigureDefinition figureDefinition)
    {
        mFigureDefinition = figureDefinition;
        mFigureDefinition.PropertyChanged += OnValueChanged;
        mFigureDefinition.DoneAction      += OnDoneAction;

        mText.text   = mFigureDefinition.Type.GetDescription();
        mToggle.isOn = mFigureDefinition.Enabled;
    }
コード例 #10
0
    public FigureFacade(Device device, ShaderCache shaderCache, FigureDefinition definition, FigureModel model, ControlVertexProvider controlVertexProvider, FigureRendererLoader figureRendererLoader)
    {
        this.definition            = definition;
        this.model                 = model;
        this.controlVertexProvider = controlVertexProvider;
        this.figureRendererLoader  = figureRendererLoader;

        model.MaterialSetChanged += Model_MaterialSetChanged;
        SyncMaterialSet();
    }
 public InverseKinematicsAnimator(ControllerManager controllerManager, FigureDefinition definition, InverterParameters inverterParameters)
 {
     channelSystem = definition.ChannelSystem;
     boneSystem    = new RigidBoneSystem(definition.BoneSystem);
     goalProvider  = new InverseKinematicsUserInterface(controllerManager, channelSystem, boneSystem, inverterParameters);
     //goalProvider = new DemoInverseKinematicsGoalProvider(boneSystem);
     solver     = new HarmonicInverseKinematicsSolver(boneSystem, inverterParameters.BoneAttributes);
     poseDeltas = boneSystem.MakeZeroInputs();
     Reset();
 }
コード例 #12
0
    public FigureDefinition GetNewFigureDefinition()
    {
        var figureDefinition = new FigureDefinition();

        figureDefinition.Enabled  = enabled;
        figureDefinition.Type     = Type;
        figureDefinition.Params   = Params;
        figureDefinition.Position = transform.position;
        figureDefinition.Rotation = transform.eulerAngles;
        return(figureDefinition);
    }
コード例 #13
0
ファイル: ActorModel.cs プロジェクト: smygarn/virtually-naked
    public ActorModel(FigureDefinition mainDefinition, AnimationModel animation, BehaviorModel behavior)
    {
        this.mainDefinition = mainDefinition;

        this.animation = animation;
        this.behavior  = behavior;

        inputs = mainDefinition.ChannelSystem.MakeZeroChannelInputs();

        //hack to turn on eCTRLConfident at start
        mainDefinition.ChannelSystem.ChannelsByName["eCTRLConfident?value"].SetValue(inputs, 1);
    }
コード例 #14
0
    public static ControlVertexProvider Load(Device device, ShaderCache shaderCache, FigureDefinition definition)
    {
        var shaperParameters = Persistance.Load <ShaperParameters>(definition.Directory.File("shaper-parameters.dat"));

        var occluderLoader = new OccluderLoader(device, shaderCache, definition);

        var provider = new ControlVertexProvider(
            device, shaderCache, occluderLoader,
            definition,
            shaperParameters);

        return(provider);
    }
    public StandardProceduralAnimator(FigureDefinition definition, BehaviorModel behaviorModel)
    {
        var channelSystem = definition.ChannelSystem;
        var boneSystem    = definition.BoneSystem;

        animators = new IProceduralAnimator[] {
            //new HeadLookAtAnimator(channelSystem, boneSystem),
            new EyeLookAtAnimator(channelSystem, boneSystem, behaviorModel),
            new BreastGravityAnimator(channelSystem, boneSystem),
            new BlinkAnimator(channelSystem),
            //new ExpressionAnimator(channelSystem),
            //new SpeechAnimator(channelSystem, boneSystem)
        };
    }
コード例 #16
0
    public void MoveFigureUp(FigureDefinition figureDefinition)
    {
        var pos    = mSettings.Geometry_Figures.IndexOf(figureDefinition);
        var action = FigureAction.MovedUP;

        if (pos == 0)
        {
            pos    = mSettings.Geometry_Figures.Count;
            action = FigureAction.MoveLast;
        }
        mSettings.Geometry_Figures.Remove(figureDefinition);
        mSettings.Geometry_Figures.Insert(pos - 1, figureDefinition);
        figureDefinition.DoAction(action);
    }
コード例 #17
0
    public FigureFacade Load(string figureName, FigureDefinition parentDefinition)
    {
        InitialSettings.Shapes.TryGetValue(figureName, out string initialShapeName);
        InitialSettings.MaterialSets.TryGetValue(figureName, out string initialMaterialSetName);

        var recipe = new FigureFacade.Recipe {
            name        = figureName,
            isVisible   = true,
            shape       = initialShapeName,
            materialSet = initialMaterialSetName
        };

        return(Load(recipe, parentDefinition));
    }
コード例 #18
0
    public void Init(FigureDefinition figureDefinition)
    {
        mFigureDefinition = figureDefinition;
        mFigureDefinition.PropertyChanged += OnValueChanged;
        mFigureDefinition.DoneAction      += OnDoneAction;

        gameObject.SetActive(mFigureDefinition.Enabled);
        name = mFigureDefinition.Type.ToString();
        transform.position    = mFigureDefinition.Position;
        transform.eulerAngles = mFigureDefinition.Rotation;

        Type   = mFigureDefinition.Type;
        Params = mFigureDefinition.Params;
    }
コード例 #19
0
    public void MoveFigureDown(FigureDefinition figureDefinition)
    {
        var pos    = mSettings.Geometry_Figures.IndexOf(figureDefinition);
        var action = FigureAction.MovedDown;

        if (pos == mSettings.Geometry_Figures.Count - 1)
        {
            pos    = -1;
            action = FigureAction.MoveFirsrt;
        }
        mSettings.Geometry_Figures.Remove(figureDefinition);
        mSettings.Geometry_Figures.Insert(pos + 1, figureDefinition);
        figureDefinition.DoAction(action);
    }
コード例 #20
0
    public ControlVertexProvider(Device device, ShaderCache shaderCache,
                                 OccluderLoader occluderLoader,
                                 FigureDefinition definition,
                                 ShaperParameters shaperParameters)
    {
        this.occluderLoader = occluderLoader;
        this.definition     = definition;
        this.shaper         = new GpuShaper(device, shaderCache, definition, shaperParameters);
        this.vertexCount    = shaperParameters.InitialPositions.Length;

        controlVertexInfosBufferManager = new InOutStructuredBufferManager <ControlVertexInfo>(device, vertexCount);
        if (definition.ChannelSystem.Parent == null)
        {
            this.controlVertexInfoStagingBufferManager = new StagingStructuredBufferManager <ControlVertexInfo>(device, vertexCount, BackingArrayCount);
        }
    }
コード例 #21
0
    public FigureFacade Load(FigureFacade.Recipe recipe, FigureDefinition parentDefinition)
    {
        FigureDefinition definition = FigureDefinition.Load(dataDir, recipe.name, parentDefinition);

        var model = new FigureModel(definition)
        {
            IsVisible       = recipe.isVisible,
            ShapeName       = recipe.shape,
            MaterialSetName = recipe.materialSet
        };

        var controlVertexProvider = ControlVertexProvider.Load(device, shaderCache, definition);

        var facade = new FigureFacade(device, shaderCache, definition, model, controlVertexProvider, figureRendererLoader);

        return(facade);
    }
コード例 #22
0
    public CharactersMenuLevel(List <Character> characters, FigureDefinition definition, FigureModel model)
    {
        var shapesMenuLevel    = new ShapesMenuLevel(definition, model);
        var materialsMenuLevel = new MaterialsMenuLevel(definition, model);
        var advancedMenuLevel  = new StaticMenuLevel(
            new SubLevelMenuItem("Shape", shapesMenuLevel),
            new SubLevelMenuItem("Skin", materialsMenuLevel)
            );

        var detailsMenuLevel = new MaterialSetVariantsMenuLevel(definition, model);

        items = new List <IMenuItem> {
        };
        items.Add(new SubLevelMenuItem("Mix & Match", advancedMenuLevel));
        items.Add(new SubLevelMenuItem("Character Details", detailsMenuLevel));
        foreach (var character in characters)
        {
            items.Add(new CharacterMenuItem(model, character));
        }
    }
コード例 #23
0
 public static OcclusionSurrogate Make(FigureDefinition definition, OcclusionSurrogateParameters parameters)
 {
     return(new OcclusionSurrogate(definition.BoneSystem.Bones[parameters.BoneIndex], parameters.OffsetInOcclusionInfos));
 }
コード例 #24
0
 public Kralica(FigureDefinition definition) : base(definition)
 {
 }
コード例 #25
0
 public static List <OcclusionSurrogate> MakeAll(FigureDefinition definition, OcclusionSurrogateParameters[] parametersList)
 {
     return(parametersList.Select(parameters => Make(definition, parameters)).ToList());
 }
コード例 #26
0
 public void ShowDetails(FigureDefinition figureDefinition)
 {
     mUIDetails.RemoveChilds();
     Instantiate(mUIDetailsPrefab, mUIDetails).GetComponent <UIDetails>().Init(figureDefinition);
 }
コード例 #27
0
 public void DeleteFigure(FigureDefinition figureDefinition)
 {
     mUIDetails.RemoveChilds();
     mSettings.Geometry_Figures.Remove(figureDefinition);
     figureDefinition.DoAction(FigureAction.Deleted);
 }
コード例 #28
0
 public MaterialSetVariantsMenuLevel(FigureDefinition definition, FigureModel model)
 {
     this.definition = definition;
     this.model      = model;
 }
コード例 #29
0
 public ShapesMenuLevel(FigureDefinition definition, FigureModel model)
 {
     this.definition = definition;
     this.model      = model;
 }
コード例 #30
0
 public FigureModel(FigureDefinition definition)
 {
     this.definition = definition;
 }