public OccluderLoader(Device device, ShaderCache shaderCache, FigureDefinition figureDefinition) { this.device = device; this.shaderCache = shaderCache; channelSystem = figureDefinition.ChannelSystem; unmorphedOcclusionDirectory = figureDefinition.Directory.Subdirectory("occlusion"); }
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)); }
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); }
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 BoneAttributesCalculator(ChannelSystem channelSystem, BoneSystem boneSystem, Geometry geometry, SkinBinding skinBinding) { this.channelSystem = channelSystem; this.boneSystem = boneSystem; this.geometry = geometry; this.skinBinding = skinBinding; }
public ExpressionAnimator(ChannelSystem channelSystem) { expressionChannels = ExpressionChannelNames .Select(name => channelSystem.ChannelsByName[name]) .ToArray(); nextExpression = expressionChannels[rnd.Next(expressionChannels.Length)]; }
public ChannelSystem(ChannelSystem parent, List <Channel> channels) { this.parent = parent; this.channels = channels; this.channelsByName = channels.ToDictionary(channel => channel.Name, channel => channel); this.channelEvaluator = new ChannelEvaluator(channels); this.defaultOutputs = Evaluate(parent?.defaultOutputs, MakeDefaultChannelInputs()); }
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(); }
public static Shape Load(ChannelSystem channelSystem, IArchiveDirectory shapeDirectory) { var channelInputsFile = shapeDirectory.File("channel-inputs.dat"); var channelInputs = LoadChannelInputs(channelSystem, channelInputsFile); var parentOverridesFile = shapeDirectory.File("parent-overrides.dat"); var parentOverrides = LoadParentOverrides(channelSystem, parentOverridesFile); return(new Shape(shapeDirectory.Name, shapeDirectory, channelInputs, parentOverrides)); }
public InverseKinematicsUserInterface(ControllerManager controllerManager, ChannelSystem channelSystem, RigidBoneSystem boneSystem, InverterParameters inverterParameters) { this.channelSystem = channelSystem; this.boneSystem = boneSystem; this.inverterParameters = inverterParameters; deviceTrackers = controllerManager.StateTrackers .Select(stateTracker => new DeviceTracker(this, stateTracker)) .ToArray(); }
public OccluderChannelPicker(ChannelSystem channelSystem) { this.channelSystem = channelSystem; isFormulaInput = new bool[channelSystem.Channels.Count]; foreach (Channel channel in channelSystem.Channels) { TagInputs(channel); } }
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"]; }
/* * // Update is called once per frame * void Update () { * if (Input.GetMouseButtonDown(0)) { * RaycastHit hit; * if (Physics.Raycast (cam.ScreenPointToRay(Input.mousePosition), out hit)) { * Debug.Log (hit.textureCoord2); * Camera c=ChannelSystem.GetInstance ().c [ChannelSystem.GetInstance ().channelIndex].GetChannelLevel ().GetCamera (); * Ray r = c.ViewportPointToRay (hit.textureCoord); * * rayTester.SetPosition(0,r.origin); * rayTester.SetPosition(1,r.origin+ r.direction*1000); * MouseButtonDown (0, hit.textureCoord); * } * } * } * void empty(int i, Vector2 xy){ * * } */ public static Ray GetScreenMouseRay() { RaycastHit hit; Ray r = new Ray(); if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit)) { Camera c = ChannelSystem.GetInstance().c [ChannelSystem.GetInstance().channelIndex].GetChannelLevel().GetCamera(); r = c.ViewportPointToRay(hit.textureCoord); } return(r); }
public ChannelSystem Bake(ChannelSystem parent) { var channels = new List <Channel>(); Channels.ForEach(recipe => recipe.Bake(channels, parent?.ChannelsByName)); var channelsByName = channels.ToDictionary(channel => channel.Name, channel => channel); Formulas.ForEach(recipe => recipe.Bake(channelsByName)); return(new ChannelSystem(parent, channels)); }
public static Shape LoadDefault(ChannelSystem channelSystem, IArchiveDirectory figureDirectory) { var channelInputsFile = figureDirectory.File("channel-inputs.dat"); var channelInputs = channelInputsFile != null? LoadChannelInputs(channelSystem, channelInputsFile) : channelSystem.MakeDefaultChannelInputs(); var parentOverridesFile = figureDirectory.File("parent-overrides.dat"); var parentOverrides = LoadParentOverrides(channelSystem, parentOverridesFile); return(new Shape(DefaultLabel, null, channelInputs, parentOverrides)); }
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; }
// Use this for initialization void Awake() { if (instance == null) { instance = this; activeChannels = new List <ChannelLevel> (); } else if (instance != this) { Debug.Log("Channel System already exists, committing seppuku"); Destroy(this.gameObject); } }
public static ChannelSystem GetInstance() { if (ChannelSystem.instance == null) { Debug.Log("Creating CHannel System"); GameObject temp = new GameObject("ChannelSystem"); instance = temp.AddComponent <ChannelSystem> (); instance.Init(); Debug.Log("Lazy instantiation assuming a level is being loaded"); instance.waitForRegister = true; } return(ChannelSystem.instance); }
public DeformableOccluder(Device device, ShaderCache shaderCache, ChannelSystem channelSystem, OcclusionInfo[] unmorphedOcclusionInfos, OccluderParameters parameters) { this.unmorphedOcclusionInfos = unmorphedOcclusionInfos; shader = shaderCache.GetComputeShader <DeformableOccluder>("figure/occlusion/shader/Occluder"); unmorphedWithoutChildrenOcclusionInfosView = BufferUtilities.ToStructuredBufferView(device, OcclusionInfo.PackArray(unmorphedOcclusionInfos)); unmorphedWithChildrenOcclusionInfosBufferManager = new StructuredBufferManager <uint>(device, unmorphedOcclusionInfos.Length); parametersResources = OccluderParametersResources.Make(device, parameters); channelIndices = parameters.ChannelNames .Select(channelName => channelSystem.ChannelsByName[channelName].Index) .ToArray(); }
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"); } }
private static ChannelInputs LoadChannelInputs(ChannelSystem channelSystem, IArchiveFile channelInputsFile) { var shapeInputsByName = Persistance.Load <Dictionary <string, double> >(channelInputsFile); ChannelInputs channelInputs = channelSystem.MakeDefaultChannelInputs(); foreach (var entry in shapeInputsByName) { Channel channel = channelSystem.ChannelsByName[entry.Key]; channel.SetValue(channelInputs, entry.Value); } return(channelInputs); }
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"); } }
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; }
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); }
private static ParentOverride[] LoadParentOverrides(ChannelSystem channelSystem, IArchiveFile parentOverridesFile) { if (parentOverridesFile == null) { return(null); } var parentChannelSystem = channelSystem.Parent; var parentOverridesByName = Persistance.Load <Dictionary <string, double> >(parentOverridesFile); var parentOverrides = parentOverridesByName .Select(entry => new ParentOverride { channel = parentChannelSystem.ChannelsByName[entry.Key], value = entry.Value }) .ToArray(); return(parentOverrides); }
public static List <Shape> LoadAllForFigure(IArchiveDirectory figureDir, ChannelSystem channelSystem) { List <Shape> shapes = new List <Shape>(); IArchiveDirectory shapesDirectory = figureDir.Subdirectory("shapes"); if (shapesDirectory != null) { foreach (var shapeDirectory in shapesDirectory.Subdirectories) { var shape = Shape.Load(channelSystem, shapeDirectory); shapes.Add(shape); } } else { var defaultShape = Shape.LoadDefault(channelSystem, figureDir); shapes.Add(defaultShape); } return(shapes); }
public ChannelShaker(ChannelSystem channelSystem) { isDirectlyUsed = new bool[channelSystem.Channels.Count]; }
public BlinkAnimator(ChannelSystem channelSystem) { eyesClosedChannel = channelSystem.ChannelsByName["eCTRLEyesClosed?value"]; }
// Use this for initialization void Start() { ChannelSystem.GetInstance().RegisterChannel(this); Init(); }
private IEnumerable <Channel> GetChannelsForOcclusionSystem() { ChannelSystem channelSystem = figureGroup.Parent.ChannelSystem; return(new OccluderChannelPicker(channelSystem).GetChannels()); }