In this topics, Humanoid's face does not move. If you want to move humanoids face as well as its skeleton, please refer " Recognizing Skeleton and Face with Kinect V2 and move Unity's Humanoid Character in Real Time ".
To Table of ContentsExpand the above zip file and change the folder nane as "CheckNtKinectDll6/".
Menu bar -> File -> New Scene
Menu bar -> File -> Save Scene as ... -> humanoid.scene
Now, we use the data makehuman.zip created in " MakeHuman: Create Humanoid Model to use in Unity5 " .
Expand the above zip file, then you will find the "AsianBoy.fbx"" and "textures/"" under the "exports/" . Please import them intto the "Assets/Models/" の下にimportします。[CAUTION]You can do the above operation through
Assets -> Import New Asset... -> AsianBody.fbx, but in this way, some textures may not be imported and the model became white. If you meet the situation, you must import all the textures in "Assets/Models/Materials/" manually.
If required bones are not assigned, you can see no "check" sign before the "Configure". In this project we use optional bones. Please make sure that the "Neck" and "UpperChest" are correctly assgned. 。
Given Humanoid and Bone, the RigBone class extract Bone's transform from the Animator component attached Humanoid and manages it.
RigBone.cs |
|
The CharacterSkeleton class manages data of Humanoid for one person, and changes the pose using given joints data.
In the set() method, the joint data acquired by Kinect V2 is passed. As the joint data for up to 6 person are handed together, the index of the skeleton that is currently being focused is specified bye the 3rd argument offset, an integer from 0 to 5.
The direction of Humanoid reflects the direction of the human body. The orientation of the human pelvis (rotation about the y-axis) is the direction of the whole humanoid, and the orientation of both shoulders is the direction of the upper body of the humanoid.
CharacterSkeleton.cs |
|
RigControl.cs |
|
Transform Position (x,y,z) = (0, 1, -2)
If the "mirrored" variable is checked in the "Rig Control (Script)" component of RigController object, The humanoid takes the mirrored pose of the human. When you uncheck "mirrored" variable, Humanoid turns his back on the camera and follows the movement of human beings as it is. (CAUTION) The screen currently being recognized by Kinect V2, which is displayed small on the right of the running Unity window, is already a mirrored image.
Since the value of the transform.rotation of Humanoid is changed by the program, the initial value of Rotation of AsianBoy's Transform can be anything.
The captured screen of the running program is here CheckNtKinectDll6d.mp4. The mirrored variable was unchecked in the middle of execution.
Also, if "move" variable is unchecked, the Humanoid will not follow the movement (place change) of the human.
[Notince] We generates an OpenCV window in DLL to display the skeleton recognition state. Note that when the OpenCV window is focused, that is, when the Unity game window is not focused, the screen of Unity will not change. Click on the top of Unity's window and make it focused, then try the program's behaviour.
[Notice 2] In the "CharacterSkeleton.cs" program, the optional bones like HumanBodyBones.Neck and HumanBodyBones.UpperChest are accessed. If the bones cannot be set with your Humanoid data, an error will occur.
[Notice 3] In this program, the orientation of Humanoid's face is not changed. To do so, use face recognition and set the orientation of HumanBodyBones.Head.
We will create a project to move up to 6 Humanods simultaneously.
File -> Save Scence as -> humanoid2.unity
Here we usemakehuman2.zip data created with makehuman . Import AfricanBoy, AfricanGirl, AsianGirl, CaucasianBoy, CaucasianGirl, and texture/. Change Animation Type of each data as "Humanoid".
Please set the position and rotation of the Humanoid. Set the z-coordinate not to apear on the camera.
Model Name | Position | Rotation | ||||
---|---|---|---|---|---|---|
X | Y | Z | X | Y | Z | |
AsianBoy | 0 | 0 | -10 | 0 | 0 | 0 |
AsianGirl | 0 | 0 | -10 | 0 | 0 | 0 |
AfricanBoy | 0 | 0 | -10 | 0 | 0 | 0 |
AfricanGirl | 0 | 0 | -10 | 0 | 0 | 0 |
CaucasianBoy | 0 | 0 | -10 | 0 | 0 | 0 |
CaucasianGirl | 0 | 0 | -10 | 0 | 0 | 0 |
RigControl2.cs |
|