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 void Main(string[] args) { if (!Debugger.IsAttached) { AppDomain.CurrentDomain.UnhandledException += ReportUnhandledException; } var commandLineParser = new CommandLineApplication(false); var archiveOption = commandLineParser.Option("--content", "content directory", CommandOptionType.SingleValue); commandLineParser.Execute(args); string contentPath; if (archiveOption.HasValue()) { contentPath = archiveOption.Value(); } else { contentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "content"); } var contentDir = new DirectoryInfo(contentPath); List <IArchiveDirectory> contentArchiveDirs = new List <IArchiveDirectory>(); foreach (var archiveDir in contentDir.GetDirectories()) { contentArchiveDirs.Add(UnpackedArchiveDirectory.Make(archiveDir)); } foreach (var archiveFile in contentDir.GetFiles("*.archive")) { var archive = new PackedArchive(archiveFile); contentArchiveDirs.Add(archive.Root); } var unionedArchiveDir = UnionArchiveDirectory.Join("content", contentArchiveDirs); LeakTracking.Setup(); string title = Application.ProductName + " " + Application.ProductVersion; try { using (VRApp app = new VRApp(unionedArchiveDir, title)) { app.Run(); } } catch (VRInitException e) { string text = String.Join("\n\n", String.Format("OpenVR initialization failed: {0}", e.Message), "Please make sure SteamVR is installed and running, and VR headset is connected."); string caption = "OpenVR Initialization Error"; MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } LeakTracking.Finish(); }
public static void Main(string[] args) { if (!Debugger.IsAttached) { AppDomain.CurrentDomain.UnhandledException += ReportUnhandledException; } var commandLineParser = new CommandLineApplication(false); var archiveOption = commandLineParser.Option("--data", "path to archive file or directory", CommandOptionType.SingleValue); commandLineParser.Execute(args); string archivePath; if (archiveOption.HasValue()) { archivePath = archiveOption.Value(); } else { archivePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data.archive"); } IArchiveDirectory dataDir; var archiveAsDirectory = new DirectoryInfo(archivePath); if (archiveAsDirectory.Exists) { dataDir = UnpackedArchiveDirectory.Make(archiveAsDirectory); } else { var archive = new PackedArchive(new FileInfo(archivePath)); dataDir = archive.Root; } LeakTracking.Setup(); string title = Application.ProductName + " " + Application.ProductVersion; try { using (VRApp app = new VRApp(dataDir, title)) { app.Run(); } } catch (VRInitException e) { string text = String.Join("\n\n", String.Format("OpenVR initialization failed: {0}", e.Message), "Please make sure SteamVR is installed and running, and VR headset is connected."); string caption = "OpenVR Initialization Error"; MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } LeakTracking.Finish(); }
public void Run() { var dataDir = UnpackedArchiveDirectory.Make(new DirectoryInfo("work")); var device = new Device(DriverType.Hardware, DeviceCreationFlags.None, FeatureLevel.Level_11_1); var shaderCache = new ShaderCache(device); var standardSamplers = new StandardSamplers(device); var targetSize = new Size2(1024, 1024); using (var framePreparer = new FramePreparer(dataDir, device, shaderCache, standardSamplers, targetSize)) { OpenVRExtensions.Init(EVRApplicationType.VRApplication_Other); Run(framePreparer); OpenVR.Shutdown(); } }
public void Run() { Device device = new Device(SharpDX.Direct3D.DriverType.Hardware, DeviceCreationFlags.Debug); ShaderCache shaderCache = new ShaderCache(device); var stamdardSamplers = new StandardSamplers(device); var dataDir = UnpackedArchiveDirectory.Make(CommonPaths.WorkDir); var environment = new ImageBasedLightingEnvironment(device, stamdardSamplers, dataDir, "ruins", 0); DeviceContext context = device.ImmediateContext; Vector4[] samplePositions = { new Vector4(+1, 0, 0, 0), new Vector4(-1, 0, 0, 0), new Vector4(0, +1, 0, 0), new Vector4(0, -1, 0, 0), new Vector4(0, 0, +1, 0), new Vector4(0, 0, -1, 0), }; var inBufferView = BufferUtilities.ToStructuredBufferView(device, samplePositions); ComputeShader shader = shaderCache.GetComputeShader <SampleCubeMapApp>("demos/cubemapsampler/SampleCubeMap"); var outBuffer = new StageableStructuredBufferManager <Vector4>(device, samplePositions.Length); context.ComputeShader.Set(shader); environment.Apply(context.ComputeShader); context.ComputeShader.SetShaderResource(1, inBufferView); context.ComputeShader.SetUnorderedAccessView(0, outBuffer.View); context.Dispatch(samplePositions.Length, 1, 1); context.ClearState(); Vector4[] results = outBuffer.ReadContents(context); for (int i = 0; i < samplePositions.Length; ++i) { Console.WriteLine(samplePositions[i]); Console.WriteLine("\t" + results[i].X); Console.WriteLine("\t" + results[i].Y); Console.WriteLine("\t" + results[i].Z); Console.WriteLine("\t" + results[i].W); } }
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); }
public void Run() { var figureDir = UnpackedArchiveDirectory.Make(new System.IO.DirectoryInfo("work/figures/genesis-3-female")); var channelSystemRecipe = Persistance.Load <ChannelSystemRecipe>(figureDir.File("channel-system-recipe.dat")); var channelSystem = channelSystemRecipe.Bake(null); var boneSystemRecipe = Persistance.Load <BoneSystemRecipe>(figureDir.File("bone-system-recipe.dat")); var boneSystem = boneSystemRecipe.Bake(channelSystem.ChannelsByName); bonesByParent = boneSystem.Bones.ToLookup(bone => bone.Parent); foreach (var rootBone in bonesByParent[null]) { PrintBone(rootBone, 0); } }