Unity3D是一个非常成熟的3D引擎;Kinect可以理解为一个输入设备(像鼠标键盘一样)所以这里技术上的关键点是:将输入信号与3D图形控制结合起来
设计上的关键点是:构造正常人会在2—3平方米的面积内通常可以做的事情(比如让普通人在这个范围内挥动手臂切水果、罚点球、垫排球等等)
这些是笔者这几天接触Kinect with Unity3D以来的最大感受吧。(为什么使用Unity3D呢;因为它含有丰富的例程和已开发资源,所以初期适宜用来移植合适的游戏到Kinect上)
对于第二点,我想也是每一个Kinect人都在探索和寻找创意的;
而第一点,笔者刚玩这俩东西,稍稍分享一些思路。在Unity3D当中,笔者主要是利用了KinectPointController.cs这个官方提供的脚本。
这个脚本实现了识别全身各个关键部位,那么理论上我们只要将这些量通过某种转化关系之后,用来控制Unity3D已有的各个元素,就完成了任务。笔者因此进行了这方面的尝试,得益于Unity3D非常丰富的Sample,笔者选取官方的Car Tutorial进行改造。我们要做的就是根据识别部位的结果,将动作映射到汽车控制的指令,而后进行不断的测试和优化用户体验,即可。
笔者将KinectPointController.cs所挂的PointMan这个包挂在Car上,这样他们就可以一起移动,而后笔者目前只用到左右手、头和脚这几点,因此在unity中不显示PointMan的其他几点mesh。
在unity中通过KinectPointController.cs识别PointMan各点相对Car中心的坐标值,而后进行分析,笔者选取了若干个姿势,包括转方向盘,前倾踩油门和后倾踩刹车及挂倒档,通过试验正确识别后,下面剩下的就是模拟键盘鼠标控制Car的结果了。
在Car tutorial这个示例中,车子的油门和方向盘主要通过Car.js这个脚本中的throttle和steer来进行控制,而KinectPointController.cs是C#脚本,这就涉及C#对js中变量值的操作。Unity支持这样的操作。
笔者先将Car.js移到"Pro Standard Assets”目录下,然后修改上面两个变量为全局变量,而后直接可以在C#中调用Car.js的全局变量。为什么这样做可以参考官方文档:
http://docs.unity3d.com/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html
因此再辅以对Unity3D图形界面下的若干设置和操作,就完成了目前的体感赛车demo,而剩下的就是根据用户体验对操控方式进行优化。
最后附上目前使用的修改后的KinectPointController.cs脚本,其中含有笔者目前对Car.js脚本中变量的操作方式
设计上的关键点是:构造正常人会在2—3平方米的面积内通常可以做的事情(比如让普通人在这个范围内挥动手臂切水果、罚点球、垫排球等等)
这些是笔者这几天接触Kinect with Unity3D以来的最大感受吧。(为什么使用Unity3D呢;因为它含有丰富的例程和已开发资源,所以初期适宜用来移植合适的游戏到Kinect上)
对于第二点,我想也是每一个Kinect人都在探索和寻找创意的;
而第一点,笔者刚玩这俩东西,稍稍分享一些思路。在Unity3D当中,笔者主要是利用了KinectPointController.cs这个官方提供的脚本。
这个脚本实现了识别全身各个关键部位,那么理论上我们只要将这些量通过某种转化关系之后,用来控制Unity3D已有的各个元素,就完成了任务。笔者因此进行了这方面的尝试,得益于Unity3D非常丰富的Sample,笔者选取官方的Car Tutorial进行改造。我们要做的就是根据识别部位的结果,将动作映射到汽车控制的指令,而后进行不断的测试和优化用户体验,即可。
笔者将KinectPointController.cs所挂的PointMan这个包挂在Car上,这样他们就可以一起移动,而后笔者目前只用到左右手、头和脚这几点,因此在unity中不显示PointMan的其他几点mesh。
在unity中通过KinectPointController.cs识别PointMan各点相对Car中心的坐标值,而后进行分析,笔者选取了若干个姿势,包括转方向盘,前倾踩油门和后倾踩刹车及挂倒档,通过试验正确识别后,下面剩下的就是模拟键盘鼠标控制Car的结果了。
在Car tutorial这个示例中,车子的油门和方向盘主要通过Car.js这个脚本中的throttle和steer来进行控制,而KinectPointController.cs是C#脚本,这就涉及C#对js中变量值的操作。Unity支持这样的操作。
笔者先将Car.js移到"Pro Standard Assets”目录下,然后修改上面两个变量为全局变量,而后直接可以在C#中调用Car.js的全局变量。为什么这样做可以参考官方文档:
http://docs.unity3d.com/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html
因此再辅以对Unity3D图形界面下的若干设置和操作,就完成了目前的体感赛车demo,而剩下的就是根据用户体验对操控方式进行优化。
最后附上目前使用的修改后的KinectPointController.cs脚本,其中含有笔者目前对Car.js脚本中变量的操作方式