#Hololens – #Xamarin, #URHO and an Spatial Mapping sample (with 2 more lines of code it became a Shooting Game)

Hello!

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.

holo-urho-spatial-mapping-02

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).

clipboard02

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.

clipboard04

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.

clipboard06

The code you can download from: https://github.com/elbruno/Blog/tree/master/Hololens/URHOPhysics

Greetings @ Toronto

El Bruno

References

Advertisements

One thought on “#Hololens – #Xamarin, #URHO and an Spatial Mapping sample (with 2 more lines of code it became a Shooting Game)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s