本文整理汇总了C++中TuioCursor::getY方法的典型用法代码示例。如果您正苦于以下问题:C++ TuioCursor::getY方法的具体用法?C++ TuioCursor::getY怎么用?C++ TuioCursor::getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TuioCursor
的用法示例。
在下文中一共展示了TuioCursor::getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseDragged
void SimpleSimulator::mouseDragged(float x, float y) {
//printf("dragged %f %f\n",x,y);
TuioCursor *cursor = NULL;
float distance = width;
for (std::list<TuioCursor*>::iterator iter = activeCursorList.begin(); iter!=activeCursorList.end(); iter++) {
TuioCursor *tcur = (*iter);
float test = tcur->getDistance(x,y);
if (test<distance) {
distance = test;
cursor = tcur;
}
}
if (cursor==NULL) return;
if (cursor->getTuioTime()==frameTime) return;
std::list<TuioCursor*>::iterator joint = std::find( jointCursorList.begin(), jointCursorList.end(), cursor );
if( joint != jointCursorList.end() ) {
float dx = x-cursor->getX();
float dy = y-cursor->getY();
for (std::list<TuioCursor*>::iterator iter = jointCursorList.begin(); iter!=jointCursorList.end(); iter++) {
TuioCursor *jointCursor = (*iter);
tuioServer->updateTuioCursor(jointCursor,jointCursor->getX()+dx,jointCursor->getY()+dy);
}
} else tuioServer->updateTuioCursor(cursor,x,y);
}
示例2: tuioCursorAdded
void testApp::tuioCursorAdded(TuioCursor & tcur){
cout << " cursor added: " + ofToString(tcur.getCursorID())+
" X: "+ofToString(tcur.getX())+
" Y: "+ofToString(tcur.getY())
<< endl;
// cout << ofToString(touch.id) << ofToString((int)time(NULL)) << ofToString(touch.x) << endl;
updateDB(tcur.getCursorID(), time(NULL), tcur.getX(), tcur.getY());
//forward the touch events to ofxMultiTouch for the InteractiveObjects
// ofxMultiTouch.touchDown(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
}
示例3: tuioCursorRemoved
void testApp::tuioCursorRemoved(TuioCursor & tcur){
/*cout << " cursor removed: " + ofToString(tcur.getCursorID())+
" X: "+ofToString(tcur.getX())+
" Y: "+ofToString(tcur.getY())
<< endl;*/
mtActionsHub.touchUp(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
mtSliderHub.touchUp(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
//draggableRotatableScalableItem.touchUp(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
//forward the touch events to ofxMultiTouch for the InteractiveObjects
ofxMultiTouch.touchUp(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
}
示例4: touchDown
void testApp::touchDown(TuioCursor & tcur)
{
cout << "testApp::touchDown" << endl;
touchPoints.push_back( ofPoint(tcur.getX()*ofGetWidth(), tcur.getY()*ofGetHeight()) );
}
示例5: drawCursors
//draw them for debug purposes
void ofxTuioServer::drawCursors() {
char id[3];
// draw the cursors
std::list<TuioCursor*> cursorList = tuioServer->getTuioCursors();
for (std::list<TuioCursor*>::iterator tuioCursor = cursorList.begin(); tuioCursor!=cursorList.end(); tuioCursor++) {
TuioCursor * tcur = (*tuioCursor);
std::list<TuioPoint> path = tcur->getPath();
if (path.size()>0) {
TuioPoint last_point = path.front();
glBegin(GL_LINES);
glColor3f(0.0, 0.0, 1.0);
for (std::list<TuioPoint>::iterator point = path.begin(); point!=path.end(); point++) {
glVertex3f(last_point.getX()*ofGetWidth(), last_point.getY()*ofGetHeight(), 0.0f);
glVertex3f(point->getX()*ofGetWidth(), point->getY()*ofGetHeight(), 0.0f);
last_point.update(point->getX(),point->getY());
}
glEnd();
// draw the finger tip
glColor3f(0.0, 0.75, 0.75);
//float size = tcur->getWidth() + tcur
ofCircle(tcur->getX()*ofGetWidth(), tcur->getY()*ofGetHeight(), 10);
}
}
}
示例6: tuioCursorUpdated
void testApp::tuioCursorUpdated(TuioCursor & tcur){
/*cout << " cursor updated: " + ofToString(tcur.getCursorID())+
" X: "+ofToString(tcur.getXSpeed())+
" Y: "+ofToString(tcur.getYSpeed())
<< endl;*/
//forward the touch events to ofxMultiTouch for the InteractiveObjects
ofxMultiTouch.touchMoved(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
}
示例7: drawCursors
void ofxTuioClient::drawCursors(){
std::list<TuioCursor*> cursorList = client->getTuioCursors();
std::list<TuioCursor*>::iterator tit;
client->lockCursorList();
for (tit=cursorList.begin(); tit != cursorList.end(); tit++) {
TuioCursor * cur = (*tit);
//if(tcur!=0){
//TuioCursor cur = *tcur;
glColor3f(0.0,0.0,0.0);
ofEllipse(cur->getX()*ofGetWidth(), cur->getY()*ofGetHeight(), 10.0, 10.0);
string str = "SessionId: "+ofToString((int)(cur->getSessionID()));
ofDrawBitmapString(str, cur->getX()*ofGetWidth()-10.0, cur->getY()*ofGetHeight()+25.0);
str = "CursorId: "+ofToString((int)(cur->getCursorID()));
ofDrawBitmapString(str, cur->getX()*ofGetWidth()-10.0, cur->getY()*ofGetHeight()+40.0);
//}
}
client->unlockCursorList();
}
示例8: tuioCursorRemoved
void testApp::tuioCursorRemoved(TuioCursor & tcur){
// cout << " cursor removed: " + ofToString(tcur.getCursorID())+
// " X: "+ofToString(tcur.getX())+
// " Y: "+ofToString(tcur.getY())
// << endl;
updateDB(tcur.getCursorID(), time(NULL), tcur.getX(), tcur.getY());
//forward the touch events to ofxMultiTouch for the InteractiveObjects
// ofxMultiTouch.touchUp(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
}
示例9: cursorUpdateHandler
void testApp::cursorUpdateHandler(TuioCursor & tcur)
{
/*std::cout << "cursorUpdated " << tcur->getCursorID() << " (" << tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY()
<< " " << tcur->getMotionSpeed() << " " << tcur->getMotionAccel() << " " << std::endl;*/
cout << "testApp::cursorUpdateHandler: " << " tcur.getX(): " << tcur.getX() << " tcur.getY(): " << tcur.getY() << endl;
touchPoints.push_back(ofPoint(tcur.getX()*ofGetWidth(), tcur.getY()*ofGetHeight()));
//touchPoints.push_back( ofPoint(tcur.getX(), tcur.getY()) );
//cout << "tcur.getX(): " << tcur.getX() << " tcur.getY() : " << tcur.getY() << endl;
}
示例10: tuioCursorUpdated
void testApp::tuioCursorUpdated(TuioCursor & tcur){
/*cout << " cursor updated: " + ofToString(tcur.getCursorID())+
" X: "+ofToString(tcur.getXSpeed())+
" Y: "+ofToString(tcur.getYSpeed())
<< endl;*/
ofxMultiTouchCustomDataSF multiTouchCustomData;
multiTouchCustomData.sessionID = tcur.getSessionID();
mtActionsHub.touchMoved(tcur.getX(), tcur.getY(), tcur.getCursorID(), &multiTouchCustomData);
mtSliderHub.touchMoved(tcur.getX(), tcur.getY(), tcur.getCursorID(), &multiTouchCustomData);
/*
draggableRotatableScalableItem.touchMoved(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
if(draggableRotatableScalableItem.ownTouchCursor(tcur.getSessionID())) {
return;
}
*/
//forward the touch events to ofxMultiTouch for the InteractiveObjects
ofxMultiTouch.touchMoved(tcur.getX(), tcur.getY(), tcur.getCursorID(), NULL);
}
示例11: removeTuioCursor
void TUIOInputModule::removeTuioCursor(TuioCursor *tcur) {
std::vector<TouchInfo> touches;
std::list<TuioCursor*> cursorList = tuioClient->getTuioCursors();
tuioClient->lockCursorList();
for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) {
TuioCursor *tuioCursor = (*iter);
TouchInfo touch;
touch.position.x = tuioCursor->getX();
touch.position.y = tuioCursor->getY();
touch.id= tuioCursor->getCursorID();
touches.push_back(touch);
}
tuioClient->unlockCursorList();
TUIOEvent event;
event.type = InputEvent::EVENT_TOUCHES_ENDED;
event.touches = touches;
CoreServices::getInstance()->getCore()->lockMutex(eventMutex);
events.push_back(event);
CoreServices::getInstance()->getCore()->unlockMutex(eventMutex);
}
示例12: draw
//--------------------------------------------------------------
void TuioKinect::draw()
{
float height = (float)ofGetHeight();
float width = (float)ofGetWidth() ;
ofSetColor(0,0,0,200) ;
//Additive blend mode
glBlendFunc(GL_SRC_COLOR, GL_ONE);
ofSetColor(255, 255, 255) ;
ofEnableSmoothing();
for(int i=0; i< customParticles.size(); i++)
{
customParticles[i].draw(0);
}
box2d.draw();
box2d.drawGround() ;
ofSetColor(255, 255, 255);
std::list<TuioCursor*> alive_cursor_list = tuioServer->getTuioCursors();
std::list<TuioCursor*>::iterator alive_cursor;
for (alive_cursor=alive_cursor_list.begin(); alive_cursor!= alive_cursor_list.end(); alive_cursor++)
{
TuioCursor *ac = (*alive_cursor);
float absXSpeed = ac->getXSpeed() ;
float absYSpeed = ac->getYSpeed() ;
float xpos = ac->getX() * (float)ofGetWidth() ;
float ypos = ac->getY() * (float)ofGetHeight() ;
absXSpeed = ( absXSpeed < 0 ) ? absXSpeed * -1 : absXSpeed ;
absYSpeed = ( absYSpeed < 0 ) ? absYSpeed * -1 : absYSpeed ;
if ( absXSpeed > .30 || absYSpeed > .30 )
{
int _size = customParticles.size() ;
if ( _size < 20 )
{
CustomParticle p;
if ( _size % 2 == 0 )
{
p.changeIsFire(true);
}
else {
p.changeIsFire(false) ;
}
float r = ofRandom(.25f, 1.0f); //normalized diff
p.setPhysics(4.0 * r, .2 * r, .45 * r );
p.setup(box2d.getWorld(), xpos, ypos, (r*30) );
p.setVelocity( ac->getXSpeed()*10 , ac->getYSpeed()*10 ) ;
customParticles.push_back(p);
}
}
//Draw that path!
drawTuioPath( ac->getPath() ) ;
}
//Debug Text
ofSetColor(255, 255, 255);
char reportStr[1024];
sprintf(reportStr, "set near threshold %i (press: + -)\nset far threshold %i (press: < >)\nnum blobs found %i, fps: %i", nearThreshold, farThreshold, (int)contourFinder.blobs.size(), (int)ofGetFrameRate());
ofDrawBitmapString(reportStr, 20, 650);
ofEnableAlphaBlending() ;
ofSetColor ( 10 , 10 , 10 );
ofFill() ;
ofSetLineWidth( 2 ) ;
ofRect(0, 0, 40, 40 ) ;
ofSetColor(255, 255, 255 ) ;
ofFill() ;
grayImage.draw(5, 5, 192, 144 );
contourFinder.draw(5, 5, 192, 144 );
ofFill() ;
ofDisableAlphaBlending() ;
}
示例13: oscMessageReceived
void TuioClient::oscMessageReceived (const OSCMessage& message) {
if( message.getAddressPattern() == "/tuio/2Dcur" ) {
String cmd;
cmd = message[0].getString();
if (cmd == "set") {
int32 s_id;
float xpos, ypos, xspeed, yspeed, maccel;
s_id=message[1].getInt32();
xpos=message[2].getFloat32();
ypos=message[3].getFloat32();
xspeed =message[4].getFloat32();
yspeed=message[5].getFloat32();
maccel=message[6].getFloat32();
std::list<TuioCursor*>::iterator tcur;
for (tcur=cursorList.begin(); tcur!= cursorList.end(); tcur++)
if((*tcur)->getSessionID()==(long)s_id) break;
if (tcur==cursorList.end()) {
TuioCursor *addCursor = new TuioCursor((long)s_id,-1,xpos,ypos);
frameCursors.push_back(addCursor);
} else if ( ((*tcur)->getX()!=xpos) || ((*tcur)->getY()!=ypos) || ((*tcur)->getXSpeed()!=xspeed) || ((*tcur)->getYSpeed()!=yspeed) || ((*tcur)->getMotionAccel()!=maccel) ) {
int id = (*tcur)->getCursorID();
TuioCursor *updateCursor = new TuioCursor((long)s_id,id,xpos,ypos);
updateCursor->update(xpos,ypos,xspeed,yspeed,maccel);
frameCursors.push_back(updateCursor);
}
} else if (cmd=="alive") {
aliveCursorList.clear();
for(int i = 1; i < message.size() ; i++) {
aliveCursorList.push_back(message[i].getInt32());
}
} else if( cmd== "fseq" ){
int32 fseq;
fseq = message[1].getInt32();
bool lateFrame = false;
if (fseq>0) {
if (fseq>currentFrame) currentTime = TuioTime::getSessionTime();
if ((fseq>=currentFrame) || ((currentFrame-fseq)>100)) currentFrame = fseq;
else lateFrame = true;
} else if ((TuioTime::getSessionTime().getTotalMilliseconds()-currentTime.getTotalMilliseconds())>100) {
currentTime = TuioTime::getSessionTime();
}
if (!lateFrame) {
// lockCursorList();
// find the removed cursors first
for (std::list<TuioCursor*>::iterator tcur=cursorList.begin(); tcur != cursorList.end(); tcur++) {
std::list<long>::iterator iter = find(aliveCursorList.begin(), aliveCursorList.end(), (*tcur)->getSessionID());
if (iter == aliveCursorList.end()) {
(*tcur)->remove(currentTime);
frameCursors.push_back(*tcur);
}
}
// unlockCursorList();
for (std::list<TuioCursor*>::iterator iter=frameCursors.begin(); iter != frameCursors.end(); iter++) {
TuioCursor *tcur = (*iter);
int c_id = -1;
TuioCursor *frameCursor = NULL;
switch (tcur->getTuioState()) {
case TUIO_REMOVED:
frameCursor = tcur;
frameCursor->remove(currentTime);
for (std::list<TuioListener*>::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
(*listener)->removeTuioCursor(frameCursor);
// lockCursorList();
for (std::list<TuioCursor*>::iterator delcur=cursorList.begin(); delcur!=cursorList.end(); delcur++) {
if((*delcur)->getSessionID()==frameCursor->getSessionID()) {
cursorList.erase(delcur);
break;
}
}
//.........这里部分代码省略.........
示例14: touchMoved
void testApp::touchMoved(TuioCursor & tcur){
touchPoints.push_back( ofPoint(tcur.getX()*ofGetWidth(), tcur.getY()*ofGetHeight()) );
}
示例15: appendNewInputEventsSinceLastCall
void VRTUIODevice::appendNewInputEventsSinceLastCall(VRDataQueue *inputEvents)
{
// Send out events for TUIO "cursors" by polling the TuioClient for the current state
std::list<TuioCursor*> cursorList = _tuioClient->getTuioCursors();
_tuioClient->lockCursorList();
// Send "button" up events for cursors that were down last frame, but are now up.
std::vector<int> downLast;
for (std::set<int>::iterator downLast_it = _cursorsDown.begin(); downLast_it!= _cursorsDown.end(); ++downLast_it ) {
downLast.push_back(*downLast_it);
}
for (int i=0;i<downLast.size();i++) {
bool stillDown = false;
for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) {
TuioCursor *tcur = (*iter);
if (tcur->getCursorID() == downLast[i]) {
stillDown = true;
}
}
if (!stillDown) {
std::string event = "Touch_Cursor_Up";
_dataIndex.addData(event + "/Id", downLast[i]);
inputEvents->push(_dataIndex.serialize(event));
_cursorsDown.erase(downLast[i]);
}
}
// Send "button" down events for cursors that are new and updated positions for all cursors
for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) {
TuioCursor *tcur = (*iter);
if (_cursorsDown.find(tcur->getCursorID()) == _cursorsDown.end()) {
std::string event = "Touch_Cursor_Down";
_dataIndex.addData(event + "/Id", tcur->getCursorID());
_dataIndex.addData(event + "/XPos", _xScale*tcur->getX());
_dataIndex.addData(event + "/YPos", _yScale*tcur->getY());
inputEvents->push(_dataIndex.serialize(event));
_cursorsDown.insert(tcur->getCursorID());
}
if (tcur->getMotionSpeed() > 0.0) {
std::string event = "Touch_Cursor_Move";
_dataIndex.addData(event + "/Id", tcur->getCursorID());
_dataIndex.addData(event + "/XPos", _xScale*tcur->getX());
_dataIndex.addData(event + "/YPos", _yScale*tcur->getY());
inputEvents->push(_dataIndex.serialize(event));
}
// Can also access several other properties of cursors (speed, acceleration, path followed, etc.)
//std::cout << "cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY()
// << " " << tcur->getMotionSpeed() << " " << tcur->getMotionAccel() << " " << std::endl;
// This is how to access all the points in the path that a cursor follows:
//std::list<TuioPoint> path = tuioCursor->getPath();
//if (path.size() > 0) {
// TuioPoint last_point = path.front();
// for (std::list<TuioPoint>::iterator point = path.begin(); point!=path.end(); point++) {
// last_point.update(point->getX(),point->getY());
// }
//}
}
_tuioClient->unlockCursorList();
}