A few days ago I wrote on how we can now use Xamarin and URHO to create Hololens apps. As always, it’s great to have a 3rd option as well as Unity and Wave Engine, and in this case, URHO is fairly simple to understand.
A few days ago, in addition original samples, the URHO team have added a sample on how to work with SpatialMapping and Hololens. This means, we can now have a “real time spatial mapping of objects detected with the Hololens”, and get them to act with our holograms.
In the following video we can see how we can move a red cube, until the app detects that it can “settle” on a flat surface. At that time with an AirTap cube settles in the flat surface and the cube changes it color to gray.
From this moment on, we can shoot colored balls using an AirTap gesture and we can see how they act with the cube and the elements detected such as a bank or a wall.
The OnUpdate() function, is used to process each Frame. Here I verify if a SpatialMapping context has been obtained. If we have a valid SpatialMapping, I check if the surface where the camera is looking (RayCast) is flat enough to settle the bucket (lines 77 to 80).
Once I position the bucket, I change the color to gray and update the bucket position. Another interesting function is ThrowBall(). Here we create a sphere in the scene with a Random color; and then fires it toward the position that the right camera is pointing.
Note: I use the Right Camera, but also is possible to use LeftCamera.
Finally the function OnSurfaceAddedOrUpdated() is where I perform the process for the SpatialMapping. Within this function detected items are added or deleted in _environmentNode which is a node created from the main scene.
The code you can download from: https://github.com/elbruno/Blog/tree/master/Hololens/URHOPhysics
Greetings @ Toronto
- El Bruno, Now Xamarin Devs can create Hololens Apps !
- GitHub, Urho Samples
- Podcast, NTN 09 – Wave Engine, Hololens y el ataque de un oso