Comments (3)
Thank you very much for the comment. That motivated me to test my understanding of StereoKit again.
I did some very simple tests. Only SK.Input-based rendering works with Psi without pushing world hierarchy or inheriting from StereoKitRenderer. I have figured out why we couldn't render things with Input.Head.Forward while using Psi. It has nothing to do with Psi. Our understanding of Input.Head.Forward was incorrect.
Input.Head.Forward (or Pose.Forward) only calculates the direction vector. It doesn't provide the actual location wrt to head position in that forward direction. The direction is always calculated wrt to (0,0,0) and the direction vector's values are always bound between -1 to 1. Checking Input.Head.Forward, I saw that the values always stayed in the -1 to 1 range no matter where I stood in the room.
So when we were trying to display a menu using:
_menuPose = new Pose(Input.Head.Forward, Quat.LookAt(Input.Head.Forward, Input.Head.position));
It didn't work once we walked away wearing the headset from the initial position where we started the app. The reason it worked if we didn't walk away was that the (0,0,0) of SK basis was initialized at the initial position where the device was. Psi also mentions this in the documentation.
The correct solution is:
_menuPose = new Pose(Input.Head.position + Input.Head.Forward, Quat.LookAt(Input.Head.position + Input.Head.Forward, Input.Head.position));
As a result, we don't need the PsiInput.Head or WordHiarchy anymore. We can directly render simple stuff using pure SK even if we had initialized Psi's MixedReality.InitializeAsync()
.
I tried this out on today and it worked. The following is a simple code snipped that I tried.
internal class Program
{
static void Main(string[] args)
{
// Initialize StereoKit
SKSettings settings = new SKSettings
{
appName = "StereoKitPsiMenuRendering",
assetsFolder = "Assets",
};
if (!SK.Initialize(settings))
Environment.Exit(1);
MixedReality.InitializeAsync().GetAwaiter().GetResult(); // Initialize Psi MixedReality statics
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;
Pose menuPose = new Pose(Input.Head.Forward, Quat.LookAt(Input.Head.Forward, Input.Head.position));
// Core application loop
while (SK.Step(() =>
{
if (SK.System.displayType == Display.Opaque)
Default.MeshCube.Draw(floorMaterial, floorTransform);
//Lines.AddAxis(new Pose(Input.Head.Forward, Quat.Identity) , 0.2f); // Uncomment to see the problem
Lines.AddAxis(new Pose(Input.Head.position + Input.Head.Forward, Quat.Identity) , 0.1f);
Lines.AddAxis(Pose.Identity, 0.1f);
UI.WindowBegin("Input.Head.Forward", ref menuPose);
UI.Label($"Head: {Input.Head.position.ToString()}");
UI.Label($"Head forward: {Input.Head.Forward.ToString()}");
UI.WindowEnd();
})) ;
SK.Shutdown();
}
}
from psi.
We could consider opening up some of these APIs to be public, but I'd like to understand a bit better what you'd like to achieve. A couple points given what you described:
- It should still be possible to do pure StereoKit input and rendering, even if you are using Psi as well. Positioning a UI menu using StereoKit.Input.Head.Forward and Quat.LookAt should work as normal if you do not want to use a Psi renderer component. Does this seem to not be true for you?
- The PsiInput.Head
CoordinateSystem
uses itsXAxis
as "Forward". Does that help?
In general, PsiInput simply gets you the StereoKit inputs in the Psi "world". If you would like to compute StereoKit things, you should simply use the StereoKit inputs. There shouldn't be a reason to convert StereoKit -> Psi -> back to StereoKit, unless I'm missing something.
from psi.
Great, glad you got it working! I'll mark this issue as closed for now, but feel free to open it back up if you have any follow-up questions.
from psi.
Related Issues (20)
- Backwards compatibility of annotations HOT 5
- Exposing the HoloLens 2's PhotoVideoCamera's MediaCaptureTask
- How to write asynchronous components to a store HOT 7
- Feature request: Option to record audio with MixedReality UWP's PhotoVideoCamera class HOT 2
- Feature request: Pause a pipeline HOT 11
- FFmpeg probelm HOT 2
- Question about "FFMPEGMediaSource.cs" HOT 2
- Troubles with RemoteImporter HOT 6
- Will the implementation of "Continual Learning about Objects in the Wild: An Interactive Approach" be opensource? HOT 2
- PSI on Oculus Quest (Android) HOT 4
- Publicizing StereoKitTransforms properties HOT 1
- `NullReferenceException` in MixedReality.cs HOT 1
- Thread-safety bug for the pipeline's stopping state HOT 1
- HoloLens 2 ir cam intrinsics HOT 4
- Fix missing project Microsoft.Psi.Audio.Windows in solution HoloLensCapture.sln
- \psi Studio's 3D panel not rendering properly when using the integrated GPU (but ok with an external monitor) HOT 1
- [Bug]: Hitting an exception when attempting to start hololenscaptureapp in hololens2 using VS2022 HOT 5
- Memory usage of SharedImagePool keeps growing HOT 3
- Poor Serialization Performance for the Diagnostics's `TrackMessageSize` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psi.