Prerequisites
Source CodeThe source code, along with the required assemblies, is included in the following versions of Vitruvius: Step 1: Create a new Unity projectLaunch Unity and create a new project, or open an existing Kinect project. Read our Getting Started Guide to see how easy it is. You’ll also need to import Windows.Kinect.dll and LightBuzz.Vitruvius.dll. These are the required assemblies to use the complete power of Vitruvius. Step 2: Import the 3D modelsOpen your scene file in the Editor and import the 3D models. Place them whenever you think it’s necessary for your game. I have imported the male and female 3D body models. They are named “male” and “female”, respectively. This is how my editor looks like: Step 3: Action!It’s now time to write your Kinect script. You’ll need to include the following namespaces:
After importing the assemblies, we’ll create the required members to open the sensor, acquire the Body data and update the avatars accordingly. The separatedPlayers variable indicates whether a single player will control one avatar or multiple avatars. Members
StartThe Start method initializes Kinect and Vitruvius. It’s important to open the sensor and enable avateering functionality to your 3D models. The code is really simple and self-explanatory:
UpdateNow, it’s time for the cool part! To see your avatars animated, you simply have to loop through the tracked bodies and update the corresponding avatar. Vitruvius does this with just one line of code.
DisposeFinally, do not forget to dispose Kinect and clean any resources.
This is it! You have just developed an avateering app using Kinect v2! Bonus – Change texturesVitruvius is bundled with five 3D models and multiple textures. Simply open the Samples/Models/FBX folder and pick the 3D models and textures of your choice. The following models are included:
This is a video of what our partners from Kinetisense did. They are using an animated 3D model to examine and measure the posture of patients. What will you do with Vitruvius? Let me know in the comments below! |
|