public SpeechAnimator(ChannelSystem channelSystem, BoneSystem boneSystem)
    {
        this.channelSystem = channelSystem;
        this.boneSystem    = boneSystem;

        this.synth   = new SpeechSynthesizer();
        synth.Volume = 100;

        synth.SelectVoice(Voice);
        synth.VisemeReached += Synth_VisemeReached;

        visemeChannels = VisemeChannelMap
                         .Select(name => name == null ? null : channelSystem.ChannelsByName[name + "?value"])
                         .ToArray();

        headBone = boneSystem.BonesByName["head"];

        var audioDevice = new XAudio2(XAudio2Flags.DebugEngine, ProcessorSpecifier.AnyProcessor);

        masteringVoice = new MasteringVoice(audioDevice);

        WaveFormat monoWaveFormat = WaveFormat.CreateIeeeFloatWaveFormat(44100, 2);

        sourceVoice = new SourceVoice(audioDevice, monoWaveFormat, VoiceFlags.None);
        sourceVoice.SetVolume(1);
        sourceVoice.Start();

        phononStream = new PhononSourceVoiceStream(sourceVoice);
        synth.SetOutputToAudioStream(phononStream, new SpeechAudioFormatInfo(44100, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
    }
Ejemplo n.º 2
0
 public BoneAttributesCalculator(ChannelSystem channelSystem, BoneSystem boneSystem, Geometry geometry, SkinBinding skinBinding)
 {
     this.channelSystem = channelSystem;
     this.boneSystem    = boneSystem;
     this.geometry      = geometry;
     this.skinBinding   = skinBinding;
 }
Ejemplo n.º 3
0
    private static RigidTransform[] MakeChildToParentBindPoseTransforms(
        ChannelSystem channelSystem,
        BoneSystem selfBoneSystem,
        BoneSystem parentBoneSystem)
    {
        var childToParentBindPoseTransforms = parentBoneSystem.Bones
                                              .Select(parentBone => {
            selfBoneSystem.BonesByName.TryGetValue(parentBone.Name, out var childBone);
            if (childBone == null)
            {
                return(RigidTransform.Identity);
            }

            var originToChildBindPoseTransform  = childBone.GetOriginToBindPoseTransform(channelSystem.DefaultOutputs);
            var originToParentBindPoseTransform = parentBone.GetOriginToBindPoseTransform(channelSystem.Parent.DefaultOutputs);

            var childBonePoseToParentBindPoseTransform =
                originToChildBindPoseTransform.Invert().Chain(originToParentBindPoseTransform);

            return(childBonePoseToParentBindPoseTransform);
        })
                                              .ToArray();

        return(childToParentBindPoseTransforms);
    }
    public InverseKinematicsPerformanceDemo()
    {
        var figureDir = UnpackedArchiveDirectory.Make(new System.IO.DirectoryInfo("work/figures/genesis-3-female"));

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

        channelSystem = channelSystemRecipe.Bake(null);

        var boneSystemRecipe = Persistance.Load <BoneSystemRecipe>(figureDir.File("bone-system-recipe.dat"));

        boneSystem = boneSystemRecipe.Bake(channelSystem.ChannelsByName);

        var inverterParameters = Persistance.Load <InverterParameters>(figureDir.File("inverter-parameters.dat"));

        rigidBoneSystem = new RigidBoneSystem(boneSystem);

        goalProvider = new DemoInverseKinematicsGoalProvider(rigidBoneSystem);
        solver       = new HarmonicInverseKinematicsSolver(rigidBoneSystem, inverterParameters.BoneAttributes);

        var pose          = Persistance.Load <List <Pose> >(figureDir.File("animations/idle.dat"))[0];
        var channelInputs = channelSystem.MakeDefaultChannelInputs();

        new Poser(channelSystem, boneSystem).Apply(channelInputs, pose, DualQuaternion.Identity);
        var channelOutputs = channelSystem.Evaluate(null, channelInputs);

        rigidBoneSystem.Synchronize(channelOutputs);
        initialInputs = rigidBoneSystem.ReadInputs(channelOutputs);
    }
    public static Animation MakeNone(BoneSystem boneSystem)
    {
        string      label        = "None";
        List <Pose> posesByFrame = new List <Pose> {
            Pose.MakeIdentity(boneSystem.Bones.Count)
        };

        return(new Animation(label, posesByFrame));
    }
Ejemplo n.º 6
0
    public BreastGravityAnimator(ChannelSystem channelSystem, BoneSystem boneSystem)
    {
        this.channelSystem = channelSystem;
        this.boneSystem    = boneSystem;

        chestBone     = boneSystem.BonesByName["chestUpper"];
        lPectoralBone = boneSystem.BonesByName["lPectoral"];
        rPectoralBone = boneSystem.BonesByName["rPectoral"];

        flattenChannel     = channelSystem.ChannelsByName["pCTRLBreastsFlatten?value"];
        hangForwardChannel = channelSystem.ChannelsByName["pCTRLBreastsHangForward?value"];
    }
Ejemplo n.º 7
0
    public RigidBoneSystem(BoneSystem source)
    {
        this.source = source;

        bones = new RigidBone[source.Bones.Count];
        for (int boneIdx = 0; boneIdx < bones.Length; ++boneIdx)
        {
            var sourceBone = source.Bones[boneIdx];
            bones[boneIdx] = new RigidBone(source.Bones[boneIdx], sourceBone.Parent != null ? bones[sourceBone.Parent.Index] : null);
        }

        bonesByName = bones.ToDictionary(bone => bone.Source.Name, bone => bone);
    }
 public FigureDefinition(string name, IArchiveDirectory directory,
                         ChannelSystem channelSystem, BoneSystem boneSystem,
                         RigidTransform[] childToParentBindPoseTransforms,
                         List <Shape> shapeOptions, List <MaterialSetOption> materialSetOptions)
 {
     Name          = name;
     Directory     = directory;
     ChannelSystem = channelSystem;
     BoneSystem    = boneSystem;
     ChildToParentBindPoseTransforms = childToParentBindPoseTransforms;
     ShapeOptions       = shapeOptions;
     MaterialSetOptions = materialSetOptions;
 }
Ejemplo n.º 9
0
    public HeadLookAtAnimator(ChannelSystem channelSystem, BoneSystem boneSystem)
    {
        this.channelSystem = channelSystem;
        this.boneSystem    = boneSystem;

        headBone     = boneSystem.BonesByName["head"];
        leftEyeBone  = boneSystem.BonesByName["lEye"];
        rightEyeBone = boneSystem.BonesByName["rEye"];

        if (leftEyeBone.Parent != headBone || rightEyeBone.Parent != headBone)
        {
            throw new InvalidOperationException("expected parent of eyes to be head");
        }
    }
Ejemplo n.º 10
0
    public EyeLookAtAnimator(ChannelSystem channelSystem, BoneSystem boneSystem, BehaviorModel behaviorModel)
    {
        this.channelSystem = channelSystem;
        this.boneSystem    = boneSystem;
        this.behaviorModel = behaviorModel;

        leftEyeBone  = boneSystem.BonesByName["lEye"];
        rightEyeBone = boneSystem.BonesByName["rEye"];

        eyeParentBone = leftEyeBone.Parent;
        if (eyeParentBone != rightEyeBone.Parent)
        {
            throw new Exception("expected eyes to have same parent");
        }
    }
Ejemplo n.º 11
0
 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;
 }
Ejemplo n.º 12
0
    public BoneSystemPerformanceDemo()
    {
        var figureDir = UnpackedArchiveDirectory.Make(new System.IO.DirectoryInfo("work/figures/genesis-3-female"));

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

        channelSystem = channelSystemRecipe.Bake(null);

        var boneSystemRecipe = Persistance.Load <BoneSystemRecipe>(figureDir.File("bone-system-recipe.dat"));

        boneSystem = boneSystemRecipe.Bake(channelSystem.ChannelsByName);

        var pose = Persistance.Load <List <Pose> >(figureDir.File("animations/idle.dat"))[0];

        inputs = channelSystem.MakeDefaultChannelInputs();
        new Poser(channelSystem, boneSystem).Apply(inputs, pose, DualQuaternion.Identity);
    }
Ejemplo n.º 13
0
    public FigureSystemOutputs UpdateFrame(DeviceContext context, FigureSystemOutputs parentOutputs, ChannelInputs inputs)
    {
        var channelOutputs = definition.ChannelSystem.Evaluate(parentOutputs?.ChannelOutputs, inputs);

        StagedSkinningTransform[] boneTransforms;
        if (parentOutputs == null)
        {
            boneTransforms = definition.BoneSystem.GetBoneTransforms(channelOutputs);
        }
        else
        {
            boneTransforms = (StagedSkinningTransform[])parentOutputs.BoneTransforms.Clone();
            BoneSystem.PrependChildToParentBindPoseTransforms(definition.ChildToParentBindPoseTransforms, boneTransforms);
        }

        occluder.SetValues(context, channelOutputs);
        shaper.SetValues(context, channelOutputs, boneTransforms);

        return(new FigureSystemOutputs(channelOutputs, boneTransforms));
    }
Ejemplo n.º 14
0
 public AnimationRetargeter(BoneSystem boneSystem, ChannelOutputs outputs)
 {
     this.boneSystem = boneSystem;
     this.outputs    = outputs;
 }
 public static List <ImporterOcclusionSurrogate> MakeForFigure(string figureName, Geometry geometry, BoneSystem boneSystem, SkinBinding skinBinding)
 {
     if (figureName == "genesis-3-female")
     {
         return(new List <ImporterOcclusionSurrogate> {
             Make(geometry, skinBinding, boneSystem.BonesByName["lEye"]),
             Make(geometry, skinBinding, boneSystem.BonesByName["rEye"])
         });
     }
     else
     {
         return(new List <ImporterOcclusionSurrogate>());
     }
 }
Ejemplo n.º 16
0
    public static OcclusionBinding MakeForFigure(string figureName, Geometry geometry, BoneSystem boneSystem, SkinBinding skinBinding)
    {
        var surrogates = ImporterOcclusionSurrogate.MakeForFigure(figureName, geometry, boneSystem, skinBinding);

        return(new OcclusionBinding(geometry.VertexCount, surrogates));
    }
Ejemplo n.º 17
0
 public Poser(ChannelSystem channelSystem, BoneSystem boneSystem)
 {
     this.boneSystem         = boneSystem;
     this.orientationOutputs = channelSystem.DefaultOutputs;         //orientation doesn't seem to change between actors so we can use default inputs
 }