c++ 添加 Tuio 接收点

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

c++ 添加 Tuio 接收点

c++ 添加 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);
c++ 添加 Tuio 接收点

 

c++ 添加 Tuio 接收点
#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")

c++ 添加 Tuio 接收点,布布扣,bubuko.com

c++ 添加 Tuio 接收点

上一篇:C++ std::thread的坑


下一篇:重新理理C++:从《c++ primer》开始