Пример #1
0
void OscSendingDevice::beginMultiTouchSequence() {

    std::string application_name;
    getUserValue("tuio_application_name", application_name);
    
    if (application_name.empty())
        application_name = std::string("OpenSceneGraph ") + osgGetVersion() + "@127.0.0.1";
    
    _oscStream << osc::BeginMessage("/tuio/2Dcur") << "source" << application_name.c_str() << osc::EndMessage;
    _oscStream << osc::BeginMessage("/tuio/2Dcur") << "fseq" << static_cast<osc::int32>(_msgId) << osc::EndMessage;

}
Пример #2
0
void OscSendingDevice::sendMultiTouchData(const osgGA::GUIEventAdapter &ea)
{
    if(!ea.isMultiTouchEvent())
        return;
    
    std::string application_name;
    getUserValue("tuio_application_name", application_name);
    
    if (application_name.empty())
        application_name = std::string("OpenSceneGraph ") + osgGetVersion() + "@127.0.0.1";
    
    osgGA::GUIEventAdapter::TouchData* touch_data = ea.getTouchData();
    
    _oscStream << osc::BeginMessage("/tuio/2Dcur") << "source" << application_name.c_str() << osc::EndMessage;
    
    _oscStream << osc::BeginMessage("/tuio/2Dcur") << "alive";
    for(osgGA::GUIEventAdapter::TouchData::iterator i = touch_data->begin(); i != touch_data->end(); ++i)
        _oscStream << static_cast<osc::int32>(i->id);
    _oscStream << osc::EndMessage;
    
    unsigned int j(0);
    for(osgGA::GUIEventAdapter::TouchData::iterator i = touch_data->begin(); i != touch_data->end(); ++i, ++j)
    {
        float x = (ea.getTouchPointNormalizedX(j) + 1.0) / 2.0;
        float y =(ea.getTouchPointNormalizedY(j) + 1.0) / 2.0;
        
        float vel_x(0), vel_y(0), accel(0);
        if (_lastEvent.valid())
        {
        
        }
        
        _oscStream << osc::BeginMessage("/tuio/2Dcur") << "set" << static_cast<osc::int32>(i->id) << x << y << vel_x << vel_y << accel << osc::EndMessage;
    }
    
    _oscStream << osc::BeginMessage("/tuio/2Dcur") << "fseq" << static_cast<osc::int32>(_msgId) << osc::EndMessage;
    
    _lastEvent = new osgGA::GUIEventAdapter(ea);
}