• c++ 添加 Tuio 接收点


    在项目下新建两个筛选器,添加TUIO中的文件如下,头文件包TUIO官网可下载,这也能下载

    #include "TuioDump.h"//#include <Vision/Samples/Engine/MobileOffroadPlugin/TUIO/TuioDump.h>
    
    //Tuio全局变量
    int port = 3333;
    TuioDump dump;
    TuioClient client(port);
    float KinectTestX=10,KinectTestY=20;
    
     //在场景加载你可以在这里添加你的特定的代码
    client.addTuioListener(&dump);
    client.connect(false);
    #pragma region TuioDump模拟点
    void TuioDump::addTuioObject(TuioObject *tobj) {
        Vision::Message.Add(1, "Add Tuio point.");
        //std::cout << "add obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle() << std::endl;
        KinectTestX=tobj->getX();
        KinectTestY=tobj->getY();
    }
    
    void TuioDump::updateTuioObject(TuioObject *tobj) {
    
        //std::cout << "set obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle() 
        //    << " " << tobj->getMotionSpeed() << " " << tobj->getRotationSpeed() << " " << tobj->getMotionAccel() << " " << tobj->getRotationAccel() << std::endl;
        Vision::Message.Add(1, "Update Tuio point.");
        KinectTestX=tobj->getX();
        KinectTestY=tobj->getY();
    }
    
    void TuioDump::removeTuioObject(TuioObject *tobj) {
        //std::cout << "del obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ")" << std::endl;
    }
    
    void TuioDump::addTuioCursor(TuioCursor *tcur) {
        //std::cout << "add cur " << tcur->getCursorID() << " (" <<  tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY() << std::endl;
        KinectTestX=tcur->getX();
        KinectTestY=tcur->getY();
    }
    
    void TuioDump::updateTuioCursor(TuioCursor *tcur) {
        //std::cout << "set cur " << tcur->getCursorID() << " (" <<  tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY() 
        //<< " " << tcur->getMotionSpeed() << " " << tcur->getMotionAccel() << " " << std::endl;
        KinectTestX=tcur->getX();
        KinectTestY=tcur->getY();
    }
    
    void TuioDump::removeTuioCursor(TuioCursor *tcur) {
        //std::cout << "del cur " << tcur->getCursorID() << " (" <<  tcur->getSessionID() << ")" << std::endl;
    }
    
    void  TuioDump::refresh(TuioTime frameTime) {
        //std::cout << "refresh " << frameTime.getTotalMilliseconds() << std::endl;
    }
    #pragma endregion
    TuioDump模拟点

     会出现如下问题:

    1.原来的 #include "TuioDump.h"添加头文件的方式提示未找到源文件,这里就添加了全路径

    2.编译后错误:error LNK2019: 无法解析的外部符号 __imp__WSAEventSelect@12,该符号在函数 "public: void __thiscall SocketReceiveMultiplexer::Implementation::Run(void)" (?Run@Implementation@SocketReceiveMultiplexer@@QAEXXZ) 中被引用

    在main.cpp中加入 #pragma comment(lib,"ws2_32.lib")

  • 相关阅读:
    JQuery学习笔记(1)——选择器
    Web前端——表单提交和Js添加选项
    Web前端——JavaScript练习
    Web前端——css
    Web前端——JavaScript笔记
    sirius的学习笔记(2)
    sirius的python学习笔记(1)
    Get和Post的请求
    IIS的配置
    一般处理程序aspx
  • 原文地址:https://www.cnblogs.com/bkycjj/p/3566104.html
Copyright © 2020-2023  润新知