/////////////////////////////////////////// static void Main(string[] args) { // Initialize the StereoKit application SKSettings settings = new SKSettings { appName = "StereoKit_BingMaps", assetsFolder = "Assets", }; if (!SK.Initialize(settings)) { Environment.Exit(1); } Initialize(); while (SK.Step(() => { // If we're in AR, we don't initialize floorMesh, hence the '?' // operator! The real world should already have a floor :) floorMesh?.Draw(floorMat, Matrix.T(0, -1.5f, 0)); // Draw the terrain widget! ShowTerrainWidget(); })) { ; } SK.Shutdown(); }
static void Main(string[] args) { // If the app has a constructor that takes a string array, then // we'll use that, and pass the command line arguments into it on // creation Type appType = typeof(App); App app = appType.GetConstructor(new Type[] { typeof(string[]) }) != null ? (App)Activator.CreateInstance(appType, new object[] { args }) : (App)Activator.CreateInstance(appType); if (app == null) { throw new Exception("StereoKit loader couldn't construct an instance of the App!"); } // Initialize StereoKit, and the app if (!SK.Initialize(app.Settings)) { Environment.Exit(1); } app.Init(); // Now loop until finished, and then shut down Action step = app.Step; // Storing this separately reduces allocations while (SK.Step(step)) { } SK.Shutdown(); }
static void Main(string[] args) { // If the app has a constructor that takes a string array, then // we'll use that, and pass the command line arguments into it on // creation Type appType = typeof(App); App app = appType.GetConstructor(new Type[] { typeof(string[]) }) != null ? (App)Activator.CreateInstance(appType, new object[] { args }) : (App)Activator.CreateInstance(appType); if (app == null) { throw new Exception("StereoKit loader couldn't construct an instance of the App!"); } // Initialize StereoKit, and the app if (!SK.Initialize(app.Settings)) { Environment.Exit(1); } if (Backend.XRType == BackendXRType.OpenXR) { xrConvertTimeToWin32PerformanceCounterKHR = Backend.OpenXR.GetFunction <XR_xrConvertTimeToWin32PerformanceCounterKHR>("xrConvertTimeToWin32PerformanceCounterKHR"); xrConvertTimeToWin32PerformanceCounterKHR(Backend.OpenXR.Instance, Backend.OpenXR.Time, out long counter); Log.Info($"XrTime: {counter}"); } app.Init(); // Now pass execution over to StereoKit SK.Run(app.Step, () => Log.Info("Bye!")); }
static void Main(string[] args) { if (!SK.Initialize(new SKSettings { appName = "Minecraft AR Test" })) { Environment.Exit(1); } Renderer.EnableSky = false; while (SK.Step(() => { Hand rightHand = Input.Hand(Handed.Right); if (rightHand.pinch.IsActive() && !UI.IsInteracting(Handed.Right)) { blocks.AddBlock(selectedBlock, rightHand.Get(1, 4).position); } blocks.Step(); if (!UI.IsInteracting(Handed.Right)) { blocks.DrawCursor(selectedBlock, rightHand.Get(1, 4).position); } BlocksWindow(); })) { ; } SK.Shutdown(); }
void Run(IntPtr activityHandle) { if (running) { return; } running = true; Task.Run(() => { // If the app has a constructor that takes a string array, then // we'll use that, and pass the command line arguments into it on // creation Type appType = typeof(App); app = appType.GetConstructor(new Type[] { typeof(string[]) }) != null ? (App)Activator.CreateInstance(appType, new object[] { new string[0] { } }) : (App)Activator.CreateInstance(appType); if (app == null) { throw new System.Exception("StereoKit loader couldn't construct an instance of the App!"); } // Initialize StereoKit, and the app SKSettings settings = app.Settings; settings.androidActivity = activityHandle; settings.assetsFolder = ""; // For requesting permission to use the Microphone if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.RecordAudio) != Android.Content.PM.Permission.Granted) { ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.RecordAudio }, 1); } if (!SK.Initialize(settings)) { return; } app.Init(); // Now loop until finished, and then shut down while (SK.Step(app.Step)) { } SK.Shutdown(); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); }); }
static void Main(string[] args) { // Initialize StereoKit SKSettings settings = new SKSettings { appName = "SKTemplate_UWP_Name", assetsFolder = "Assets", }; if (!SK.Initialize(settings)) { Environment.Exit(1); } // Create assets used by the app Pose cubePose = new Pose(0, 0, -0.5f, Quat.Identity); Model cube = Model.FromMesh( Mesh.GenerateRoundedCube(Vec3.One * 0.1f, 0.02f), Default.MaterialUI); Matrix floorTransform = Matrix.TS(0, -1.5f, 0, new Vec3(30, 0.1f, 30)); Material floorMaterial = new Material(Shader.FromFile("floor.hlsl")); floorMaterial.Transparency = Transparency.Blend; // Core application loop while (SK.Step(() => { if (SK.System.displayType == Display.Opaque) { Default.MeshCube.Draw(floorMaterial, floorTransform); } UI.Handle("Cube", ref cubePose, cube.Bounds); cube.Draw(cubePose.ToMatrix()); })) { ; } SK.Shutdown(); }
static void Main(string[] args) { if (!SK.Initialize(new SKSettings { appName = "Project" })) { Environment.Exit(1); } while (SK.Step(() => { Mesh.Cube.Draw(Material.Default, Matrix.S(0.1f)); })) { ; } SK.Shutdown(); }
void Run(IntPtr activityHandle) { if (running) { return; } running = true; Task.Run(() => { // If the app has a constructor that takes a string array, then // we'll use that, and pass the command line arguments into it on // creation Type appType = typeof(App); app = appType.GetConstructor(new Type[] { typeof(string[]) }) != null ? (App)Activator.CreateInstance(appType, new object[] { new string[0] { } }) : (App)Activator.CreateInstance(appType); if (app == null) { throw new System.Exception("StereoKit loader couldn't construct an instance of the App!"); } // Initialize StereoKit, and the app SKSettings settings = app.Settings; settings.androidActivity = activityHandle; settings.assetsFolder = ""; if (!SK.Initialize(settings)) { return; } app.Init(); // Now loop until finished, and then shut down while (SK.Step(app.Step)) { } SK.Shutdown(); }); }
static void Main(string[] args) { if (!SK.Initialize(new SKSettings { appName = "Project" })) { Environment.Exit(1); } Model cube = Model.FromMesh( Mesh.GenerateRoundedCube(Vec3.One, 0.2f), Default.Material); while (SK.Step(() => { cube.Draw(Matrix.TS(Vec3.Zero, 0.1f)); })) { ; } SK.Shutdown(); }
static void Main(string[] args) { // Initialize StereoKit! During initialization, we can prepare a few // settings, like the assetsFolder and appName. assetsFolder the // folder that StereoKit will look for assets in when provided a // relative folder name. Settings can also be told to make a // flatscreen app, or how to behave if the preferred initialization // mode fails. SKSettings settings = new SKSettings { appName = "StereoKitPaintTutorial", assetsFolder = "Assets", }; if (!SK.Initialize(settings)) { Environment.Exit(1); } // This is a simple radial hand menu where we'll store some quick // actions! It's activated by a grip motion, and is great for fast, // gesture-like activation of menu items. It also can be used with // multiple HandRadialLayers to nest commands in sub-menus. // // Steppers are classes that implement the IStepper interface, and // once added to StereoKit's stepper list, will have their Step // method called each frame! This is a great way to add fire-and- // forget objects or systems that need to update each frame. SK.AddStepper(new HandMenuRadial( new HandRadialLayer("Root", -90, new HandMenuItem("Undo", null, () => activePainting?.Undo()), new HandMenuItem("Redo", null, () => activePainting?.Redo())))); // Initialize the palette menu, see PaletteMenu.cs! This class // manages the palette UI object for manipulating our brush stroke // size and color. paletteMenu = new PaletteMenu(); // Step the application each frame, until StereoKit is told to exit! // The callback code here is called every frame after input and // system events, but before the draw events! while (SK.Step(() => { // Send input information to the painting, it will handle this // info to create brush strokes. This will also draw the painting // too! activePainting.Step(Handed.Right, paletteMenu.PaintColor, paletteMenu.PaintSize); // Step our palette UI! paletteMenu.Step(); // Step our application's menu! This includes Save/Load Clear and // Quit commands. StepMenuWindow(); })) { ; } // We're done! Clean up StereoKit and all its resources :) SK.Shutdown(); }
static void Main(string[] args) { Sound song; Queue <Note>[] noteQueues = null; int positionInNotes = 0; double songStartTime = 0; DateTime watcherStart = DateTime.Now; // Initialize StereoKit SKSettings settings = new SKSettings { appName = "DrumMR", assetsFolder = "Assets", }; if (!SK.Initialize(settings)) { Environment.Exit(1); } SerialPort port = new SerialPort(); port.PortName = "COM3"; port.BaudRate = 9600; //port.Open(); port.DataReceived += (sender, dataArgs) => { SerialPort sp = (SerialPort)sender; string result = sp.ReadExisting(); Debug.WriteLine("Serial data received: " + result); //buffer[Int32.Parse(result)] = true; }; Vec3[] unitVectors = createNewUnitVectors(); //x, y, and z Mesh boardMesh = Mesh.GenerateCube(new Vec3(1f, 2f, 0)); Mesh noteMesh = Mesh.GenerateCube(new Vec3(.04f, .048f, 0)); Model boardModel = Model.FromMesh(boardMesh, Default.Material); Model noteModel = Model.FromMesh(noteMesh, Default.Material); Debug.WriteLine(unitVectors[0]); Quat boardQuat = new Quat((float)0, (float).7, (float).7, (float)0); Vec3 boardLocation = new Vec3(drumLocations[1].orientation.x + .05f * (unitVectors[0].x + unitVectors[1].x + unitVectors[2].x), drumLocations[1].orientation.y + .05f * ((unitVectors[0].y + unitVectors[1].y + unitVectors[2].y)), drumLocations[1].orientation.z + (((unitVectors[0].z + unitVectors[1].z + unitVectors[2].z)))); Pose boardPose = new Pose(boardLocation, boardQuat); boardModel.Draw(boardPose.ToMatrix(), Color.Black); //TODO: SET THIS QUAT TO BE PARALLEL TO UNITVECTORS[0] //TODO: MAKE DIFFERENTLY COLORED NOTE MESHES FOR EACH LANE //TODO: ROTATION IS GOING TO NEED TO BE FIGURED OUT. IT CAN'T TURN DYNAMICALLY BECAUSE THE NOTES WOULD NEED TO TURN AS WELL // Core application loop InitializeDrumLocations(); while (SK.Step(() => { if (!PoseIsInitialized(drumLocations[0])) { getDrumLocation(0); } else if (!PoseIsInitialized(drumLocations[1])) { getDrumLocation(1); } else if (!PoseIsInitialized(drumLocations[2])) { getDrumLocation(2); } else if (!PoseIsInitialized(drumLocations[3])) { getDrumLocation(3); } else if (notes is null) { //TODO: CHANGE THIS TO MOVE WITH THE USER USING INPUT.HEAD.POSITION? Pose windowPose = new Pose(-.4f, 0, 0, Quat.LookDir(1, 0, 1)); UI.WindowBegin("Window", ref windowPose, new Vec2(20, 0) * U.cm, UIWin.Normal); for (int i = 0; i < songs.Length; i++) { if (UI.Button(songs[i])) { Debug.WriteLine(songs[i]); string jsonString = getJSONStringOfSong(songs[i] + ".json"); notes = parseJSONSong(jsonString); notes = sortNotes(notes); song = Sound.FromFile(songs[i] + ".wav"); song.Play(Input.Head.position); songStartTime = Time.Total; noteQueues = new Queue <Note> [4]; for (int j = 0; j < 4; j++) { noteQueues[j] = new Queue <Note> { }; } } } UI.WindowEnd(); } else { //calculates x values for note lanes float midpoint = (drumLocations[0].position.x + drumLocations[3].position.x) / 2; float notePoint = midpoint / 8; //draws the board boardModel.Draw(boardPose.ToMatrix(), Color.Black); while (positionInNotes < notes.Length && notes[positionInNotes].time - (Time.Total - songStartTime) < GAME_BOARD_TIME) { Note noteToPush = notes[positionInNotes]; Debug.WriteLine(noteToPush.pad); Debug.WriteLine(noteQueues[noteToPush.pad].Count); noteQueues[noteToPush.pad].Enqueue(noteToPush); positionInNotes++; } for (int i = 0; i < noteQueues.Length; i++) { for (int j = 0; j < noteQueues[i].Count; j++) { Note noteToRender = noteQueues[i].Dequeue(); Pose notePose = new Pose(notePoint * i, (float)(noteToRender.time - songStartTime) * (float)(2 / 1.5), boardLocation.z + (float).1, boardQuat); Debug.WriteLine("note " + i); noteModel.Draw(notePose.ToMatrix(), Color.White); //TODO: RENDER THE NOTE HERE //unitVectors[3] contains vectors representing if (j == 0 && buffer[i] && noteToRender.time - songStartTime < NOTE_HIT_TIME_MARGIN) { //TODO: ONLY DO THIS IF THE NOTE IS CLOSE TO THE BOTTOM buffer[i] = false; } else { noteQueues[i].Enqueue(noteToRender); } } } if (positionInNotes == notes.Length) { notes = null; } } })) { ; } SK.Shutdown(); }