One of the most exciting and groundbreaking technology products at the moment is the Microsoft HoloLens. The ability to show real time 3D holograms mixed seamlessly with any physical environment opens up endless new possibilities for modern computing. I have just scratched the surface of the holographic rabbit hole and, considering the hardware has just started shipping as a US$3,000 developer kit, it is safe to say that the best is yet to come.
If you can't wait for the general availability release and want to delve into HoloLens app development today, then there is good news! The tooling is already available, it is free and you don't even need a HoloLens to get started.
Prerequisites
As HoloLens runs Windows 10, apps are built for the Universal Windows Platform (UWP), which means that UWP apps written for mobile devices, desktops, Xbox and other platforms will also run on HoloLens. There are two main tools you need to create holographic experiences — Visual Studio 2015 and Unity 3D. You will use these alongside the SDK and emulator. In total, you will need the following:
- Windows 10
- Visual Studio 2015 Update 2 (Community Edition)
- Unity 3D for HoloLens
- Windows 10 SDK (if you didn't already install it with Visual Studio 2015)
- HoloLens Emulator
Once you have installed these tools, you are ready to create your first holographic experience.
Although the HoloLens runs UWP apps, which are in turn written using C# and Visual Studio, the unique aspect of HoloLens apps is the 3D holograms. These are created and modeled in your favorite 3D software, but if you are like me and don't have a clue how to create 3D models, there are services you can use where professionals will create them for you. Unity even has their own 3D model asset store. I will include a short introduction to Unity, however it is a huge topic. SitePoint has some other Unity articles to get you started.
Unity 3D allows you to import and manipulate 3D models, and manage events and scripts for each object. You can control the lighting, the surroundings (known as the "scene") and every other aspect of the world you want to project to your users. Unity is not easy to master, but there is no way around it if you want to create HoloLens apps.
Creating 3D Objects in Unity
You can create basic shapes in Unity by going opening the GameObject menu, going to 3D Object and choosing the 3D object you want.
Choosing a sphere creates a basic sphere shape in your scene, which you can then manipulate, animate and control.
The main way to interact with the 3D objects in a holographic experience is to attach scripts to the objects. You do this by creating a new script in Unity.
You can edit this script in Visual Studio by double-clicking it.
using UnityEngine;
using System.Collections;
public class SphereBehaviour : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
The Start
method is called when the app starts and sets up any events or initialization code. Update
is called once per frame and is where you detect interactions such as collisions, RayCast
hits and other user interactions.
To attach the script to an object in Unity, drag and drop it on to it. The code in the script will execute appropriately when the methods are called. This could be on start, when a user speaks a voice command or any other event in your holographic experience.
To run the holographic app, you need to import the project into Visual Studio and Unity can create a full UWP app solution for you. Use the following build settings from the Build Settings menu.
Make sure you open Player Settings, select Virtual Reality Supported, and make sure the Windows Holographic SDK is present.
When you hit Build, Unity will create a full UWP app solution in a folder you choose. You can open this solution in Visual Studio.
By default, Universal Windows Platform apps exported from Unity will run on any Windows 10 device. Because HoloLens is different, the app should take advantage of features that are only available on HoloLens. To do this, you need to set the TargetDeviceFamily
to "Windows.Holographic" in the Package.appxmanifest file in Visual Studio as shown below.
And now you can run the solution in the HoloLens Emulator.
Now that you know the workflow for creating a 3D workspace, can add models and apply scripts to these models, it's time to look at the main areas of interaction with holograms in HoloLens apps.
Gaze Input
The gaze is the first form of input into HoloLens apps and is how you put focus on holograms. It is the center of the field of view when a user looks through the HoloLens, and is essentially a "mouse cursor". You can design this cursor any way you want, so it could be contextual to your app, a company logo or any other 3D shape.
[caption id="attachment_132512" align="aligncenter" width="1024"] Image Credit: Microsoft[/caption]
Bear in mind that HoloLens uses the position and orientation of your user's head, not their eyes, to determine their gaze vector. It's like a laser pointer that comes straight out from the center of the HoloLens.
Continue reading %Getting Started with Microsoft HoloLens Development%
by Lars Klint via SitePoint
No comments:
Post a Comment