体感测试

Assets 下导入Chart and Graph 和 Kinect 
打开示例场景连接设备 根据设备型号插入相应USB中 当前设备是最新的 插入USB3.0里 
官方文档里有写msdn上  https://docs.microsoft.com/zh-cn/azure/kinect-dk/system-requirements
Kinect  AzureKinectExamples/KinectDemos/AvatarDemo/KinectAvatarsDemo1  场景 示例   从中可以拿到cubeman 另外这里要记住 Kinect Manager 作为主要入口 
           AzureKinectExamples/KinectScripts 所有的脚本都在这里
Chart and Graph Themes/2d/Graph/preset 7  打开场景将cubeman放入Hierarchy面板里 创建个空对象 把 Kinect Manager  这个脚本挂上
	           根据上篇Chart and Graph博客修改代码挂在DataInitializer
using UnityEngine;
using ChartAndGraph;//引用命名空间
using com.rfilkov.components;//引入cubeman的脚本
using static com.rfilkov.kinect.KinectInterop;
using com.rfilkov.kinect;

public class TestCubeMan : MonoBehaviour
{
    public GraphChart chart;

    public KinectManager kinectManager;
    public JointData[] jointData;

    private float timer = 1f;
    private float x = 4f;

    public CubemanController cubemanController;

    private void Start()
    {
        
        //if (kinectManager.GetUserIndexById(1) == 1)
        //{
            //在开始处理或结束处理的时候调用
            //It is also best practice to enclose graph changes in StartBatch and EndBatch calls
            chart.DataSource.StartBatch();

            //使用新数据之前清空原来的
            //chart.DataSource.ClearCategory("名字");
            chart.DataSource.ClearCategory("CubeManHandRight");

            //测试通过AddPointToCategory这个方法可以生成图表
            //chart.DataSource.AddPointToCategory("名字", x轴, y轴);
            chart.DataSource.AddPointToCategory("CubeManHandRight", 0, cubemanController.WristRight.transform.position.y);

            //如果有第二种类别 可以在绘制第二种 我这里没有 
            //第二种操作步骤同上 先ClearCategory 然后 AddPointToCategory
            //now we do the same for the second category
            /*
             ClearCategory
             AddPointToCategory
             AddPointToCategory
             */

            chart.DataSource.ClearCategory("CubeManHandLeft");
            chart.DataSource.AddPointToCategory("CubeManHandLeft", 0, cubemanController.WristLeft.transform.position.y);

            //有开始处理就要有结束处理 StartBatch 要和 EndBatch 对应
            //each StartBatch call must be matched with an EndBatch call
            chart.DataSource.EndBatch();

            //调用EndBatch重新绘制图表
            //graph is redrawn after EndBatch is called
        //}
    }

    private void Update()
    {
        //添加每隔一秒更新一次数据
        //now let's add a streaming data update the goes every 1 second

        //更新时间减过去的时间
        timer -= Time.deltaTime;//each update we decrease the time that has passed 
        //如果更新时间小于0
        //if (timer <= 0f)
        //{
            //时间重新设置回1
            timer = 1f;//set the time to one again and
            //AddPointToCategoryRealtime 实时添加点到类别
            //chart.DataSource.AddPointToCategoryRealtime("名字", x轴, y轴); //为动画设置流动时间 时间设置为1 让他在一秒内融合
            chart.DataSource.AddPointToCategoryRealtime("CubeManHandRight", x, cubemanController.WristRight.transform.position.y, 0.1f); //now we can also set the animation time for the streaming value. setting it to 1 will make it blend in 1 second
            chart.DataSource.AddPointToCategoryRealtime("CubeManHandLeft", x, cubemanController.WristLeft.transform.position.y, 0.1f); //now we can also set the animation time for the streaming value. setting it to 1 will make it blend in 1 second
            //设置下一个点的距离
            x++; //increase the x value so the next point is 1 unity away
        //}
    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值