Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added setCursorWorld to force external cursor recognition (e.g. ofxGr…

…abScene)
  • Loading branch information...
commit 75c0113aca58c337033d8bde698af3e3429368aa 1 parent 07aadcf
Elliot Woods authored
Showing with 18 additions and 2 deletions.
  1. +14 −2 src/ofxGrabCam.cpp
  2. +4 −0 src/ofxGrabCam.h
16 src/ofxGrabCam.cpp
View
@@ -15,6 +15,7 @@ ofxGrabCam::ofxGrabCam(bool useMouseListeners) : initialised(true), mouseDown(fa
this->mouseActions = true;
this->trackballRadius = 0.5f;
this->resetDown = 0;
+ this->mouseWForced = false;
ofCamera::setNearClip(0.1);
addListeners();
@@ -45,7 +46,7 @@ void ofxGrabCam::end() {
//optimistically, we presume there's no stray push/pops
ofPopMatrix();
- if (pickCursorFlag || !mouseDown || !mouseActions) {
+ if ((pickCursorFlag || !mouseDown || !mouseActions) && !mouseWForced) {
findCursor();
pickCursorFlag = false;
}
@@ -86,6 +87,17 @@ void ofxGrabCam::reset() {
}
//--------------------------
+void ofxGrabCam::setCursorWorld(const ofVec3f& world) {
+ this->mouseW = world;
+ this->mouseWForced = true;
+}
+
+//--------------------------
+void ofxGrabCam::clearCursorWorld() {
+ this->mouseWForced = false;
+}
+
+//--------------------------
void ofxGrabCam::setCursorDraw(bool enabled, float size) {
this->drawCursor = enabled;
this->drawCursorSize = size;
@@ -157,7 +169,7 @@ void ofxGrabCam::removeListeners() {
//--------------------------
void ofxGrabCam::update(ofEventArgs &args) {
-
+
}
//--------------------------
4 src/ofxGrabCam.h
View
@@ -27,6 +27,9 @@ class ofxGrabCam : public ofCamera {
const ofVec3f& getCursorWorld() { return mouseW; }
const ofVec3f& getCursorProjected() { return mouseP; }
+ void setCursorWorld(const ofVec3f &);
+ void clearCursorWorld();
+
void setCursorDraw(bool enabled, float size=0.1);
void toggleCursorDraw();
@@ -71,6 +74,7 @@ class ofxGrabCam : public ofCamera {
bool pickCursorFlag;
ofVec3f mouseP;
ofVec3f mouseW;
+ bool mouseWForced;
bool drawCursor;
float drawCursorSize;
//
Please sign in to comment.
Something went wrong with that request. Please try again.