Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

compatibility with NVidia and ATI checked at current state. Fixes to …

…cursorOver. Removed legacy line on handles
  • Loading branch information...
commit baa13875f87699aaa84aff4914928db4ea207f92 1 parent 2fee110
@elliotwoods authored
View
7 data/ofxGrabScene/shaders/outlineIndex.frag
@@ -1,3 +1,4 @@
+
#version 120
uniform sampler2DRect texIndex;
@@ -17,9 +18,9 @@ bool isElement(int index) {
}
void main() {
- const int centerIndex = int(texture2DRect(texIndex, gl_TexCoord[0].xy).r);
- const int centerElementIndex = centerIndex;
- const int centerNodeIndex = centerIndex - elementCount;
+ int centerIndex = int(texture2DRect(texIndex, gl_TexCoord[0].xy).r);
+ int centerElementIndex = centerIndex;
+ int centerNodeIndex = centerIndex - elementCount;
int outerIndex;
int outerNodeIndex;
View
7 ofxGrabScene-example/bin/data/ofxGrabScene/shaders/outlineIndex.frag
@@ -1,3 +1,4 @@
+
#version 120
uniform sampler2DRect texIndex;
@@ -17,9 +18,9 @@ bool isElement(int index) {
}
void main() {
- const int centerIndex = int(texture2DRect(texIndex, gl_TexCoord[0].xy).r);
- const int centerElementIndex = centerIndex;
- const int centerNodeIndex = centerIndex - elementCount;
+ int centerIndex = int(texture2DRect(texIndex, gl_TexCoord[0].xy).r);
+ int centerElementIndex = centerIndex;
+ int centerNodeIndex = centerIndex - elementCount;
int outerIndex;
int outerNodeIndex;
View
4 src/ofxGrabScene/Handles.h
@@ -37,7 +37,6 @@ namespace GrabScene {
Axis axis;
static BaseNode * parent;
static ofCamera * camera;
- ofColor lineColor;
ofColor fillColor;
bool rollover;
static float scale;
@@ -45,7 +44,6 @@ namespace GrabScene {
void rotateAxis() const;
void setStyleFill() const;
- void setStyleLine() const;
private:
virtual string getReading() const = 0;
};
@@ -63,7 +61,6 @@ namespace GrabScene {
protected:
string getReading() const;
static ofMesh fill;
- static ofMesh line;
};
class Rotate : public BaseHandle {
@@ -80,7 +77,6 @@ namespace GrabScene {
void doTransform() const;
string getReading() const;
static ofMesh fill;
- static ofMesh line;
};
Handles();
View
14 src/ofxGrabScene/Handles/BaseHandle.cpp
@@ -19,22 +19,18 @@ namespace GrabScene {
switch (this->axis) {
case X_AXIS:
this->fillColor.setHsb(0, GRABSCENE_HANDLES_SATURATION, GRABSCENE_HANDLES_FILL_BRIGHTNESS);
- this->lineColor.setHsb(0, 0, GRABSCENE_HANDLES_LINE_BRIGHTNESS, 0);
break;
case Y_AXIS:
this->fillColor.setHsb(255/3, GRABSCENE_HANDLES_SATURATION, GRABSCENE_HANDLES_FILL_BRIGHTNESS);
- this->lineColor.setHsb(255/3, 0, GRABSCENE_HANDLES_LINE_BRIGHTNESS, 0);
break;
case Z_AXIS:
this->fillColor.setHsb(255/3*2, GRABSCENE_HANDLES_SATURATION, GRABSCENE_HANDLES_FILL_BRIGHTNESS);
- this->lineColor.setHsb(255/3*2, 0, GRABSCENE_HANDLES_LINE_BRIGHTNESS, 0);
break;
case NO_AXIS:
this->fillColor = ofColor(200,200,200);
- this->lineColor = ofColor(GRABSCENE_HANDLES_LINE_BRIGHTNESS,GRABSCENE_HANDLES_LINE_BRIGHTNESS,GRABSCENE_HANDLES_LINE_BRIGHTNESS, 0);
break;
}
}
@@ -87,16 +83,6 @@ namespace GrabScene {
ofSetLineWidth(0.0f);
ofSetColor(this->fillColor);
}
-
- //---------
- void Handles::BaseHandle::setStyleLine() const {
- ofNoFill();
- ofSetLineWidth(2.0f);
- if (this->rollover)
- ofSetColor(255, 255, 255, 255);
- else
- ofSetColor(this->lineColor);
- }
//---------
void Handles::BaseHandle::cursorOver(const Cursor &) {
View
27 src/ofxGrabScene/Handles/Rotate.cpp
@@ -7,7 +7,6 @@
namespace GrabScene {
//---------
ofMesh Handles::Rotate::fill = ofMesh();
- ofMesh Handles::Rotate::line = ofMesh();
//---------
Handles::Rotate::Rotate(Axis axis) : BaseHandle(axis) {
@@ -29,39 +28,20 @@ namespace GrabScene {
//inner ring
for (int i=0; i<resolution; i++) {
theta = (float) i / (float) resolution * TWO_PI;
- line.addVertex(ofVec3f(radius * cos(theta), radius * sin(theta), 0.0f));
+ fill.addVertex(ofVec3f(radius * cos(theta), radius * sin(theta), 0.0f));
}
//outer ring
for (int i=0; i<resolution; i++) {
theta = ((float) i + 0.5f) / (float) resolution * TWO_PI;
- line.addVertex(ofVec3f((radius + width) * cos(theta), (radius + width) * sin(theta), 0.0f));
+ fill.addVertex(ofVec3f((radius + width) * cos(theta), (radius + width) * sin(theta), 0.0f));
}
-
- fill.addVertices(line.getVertices());
//
////
////
//indices
-
- //line
-
- //inner ring
- for (int i=0; i<resolution; i++) {
- line.addIndex(i);
- line.addIndex((i+1) % resolution);
- }
-
- //inner ring
- for (int i=0; i<resolution; i++) {
- line.addIndex(i + resolution);
- line.addIndex(((i+1) % resolution) + resolution);
- }
-
-
- //fill
for (int i=0; i<resolution+1; i++) {
fill.addIndex(i % resolution);
fill.addIndex((i % resolution) + resolution);
@@ -71,7 +51,6 @@ namespace GrabScene {
////
//styles
- line.setMode(OF_PRIMITIVE_LINES);
fill.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
//
////
@@ -96,8 +75,6 @@ namespace GrabScene {
this->rotateAxis();
this->setStyleFill();
fill.draw();
- this->setStyleLine();
- line.draw();
shader("fixed").end();
View
61 src/ofxGrabScene/Handles/Translate.cpp
@@ -7,7 +7,6 @@
namespace GrabScene {
//---------
ofMesh Handles::Translate::fill = ofMesh();
- ofMesh Handles::Translate::line = ofMesh();
//---------
Handles::Translate::Translate(Axis axis) :
@@ -21,48 +20,17 @@ namespace GrabScene {
const float radius = GRABSCENE_HANDLES_RADIUS_2;
const float width = GRABSCENE_HANDLES_RADIUS_2 * 2.0f / 3.0f;
- line.addVertex(ofVec3f(-width,-width, radius * 2)); //0
- line.addVertex(ofVec3f(+width,-width, radius * 2)); //1
- line.addVertex(ofVec3f(+width,+width, radius * 2)); //2
- line.addVertex(ofVec3f(-width,+width, radius * 2)); //3
+ fill.addVertex(ofVec3f(-width,-width, radius * 2)); //0
+ fill.addVertex(ofVec3f(+width,-width, radius * 2)); //1
+ fill.addVertex(ofVec3f(+width,+width, radius * 2)); //2
+ fill.addVertex(ofVec3f(-width,+width, radius * 2)); //3
- line.addVertex(ofVec3f(-width,-width, length - radius)); //4
- line.addVertex(ofVec3f(+width,-width, length - radius)); //5
- line.addVertex(ofVec3f(+width,+width, length - radius)); //6
- line.addVertex(ofVec3f(-width,+width, length - radius)); //7
+ fill.addVertex(ofVec3f(-width,-width, length - radius)); //4
+ fill.addVertex(ofVec3f(+width,-width, length - radius)); //5
+ fill.addVertex(ofVec3f(+width,+width, length - radius)); //6
+ fill.addVertex(ofVec3f(-width,+width, length - radius)); //7
- line.addVertex(ofVec3f(0.0f, 0.0f, length)); //8
-
- //back
- line.addIndex(0);
- line.addIndex(1);
- line.addIndex(2);
- line.addIndex(3);
- line.addIndex(0);
- //left
- line.addIndex(4);
- line.addIndex(7);
- line.addIndex(3);
- line.addIndex(0);
- //bottom
- line.addIndex(4);
- line.addIndex(5);
- line.addIndex(1);
- //right
- line.addIndex(2);
- line.addIndex(6);
- line.addIndex(5);
- //tip
- line.addIndex(8);
- line.addIndex(6);
- line.addIndex(7);
- line.addIndex(8);
- line.addIndex(4);
- line.addIndex(5);
-
- line.setMode(OF_PRIMITIVE_LINE_STRIP);
-
- fill.addVertices(Handles::Translate::line.getVertices());
+ fill.addVertex(ofVec3f(0.0f, 0.0f, length)); //8
//back
fill.addIndex(0);
@@ -147,17 +115,10 @@ namespace GrabScene {
if (this->axis == NO_AXIS) {
this->setStyleFill();
ofBox(GRABSCENE_HANDLES_RADIUS_2 * 2);
-
- this->setStyleLine();
- ofBox(GRABSCENE_HANDLES_RADIUS_2 * 2);
} else {
this->rotateAxis();
this->setStyleFill();
- fill.draw();
-
- this->setStyleLine();
- line.draw();
-
+ fill.draw();
}
ofPopStyle();
@@ -183,7 +144,7 @@ namespace GrabScene {
ofScale(scale, scale, scale);
if (this->axis == NO_AXIS) {
- ofBox(GRABSCENE_HANDLES_RADIUS_2);
+ ofBox(GRABSCENE_HANDLES_RADIUS_2 * 2);
} else {
this->rotateAxis();
fill.draw();
View
5 src/ofxGrabScene/Node.h
@@ -5,7 +5,9 @@
#pragma once
#include "ofNode.h"
+
#include "Assets.h"
+#include "Cursor.h"
namespace GrabScene {
class BaseNode {
@@ -14,6 +16,9 @@ namespace GrabScene {
virtual void drawStencil() = 0;
virtual ofNode & getNode() = 0;
+ virtual void cursorOver(Cursor &) { }
+ virtual void cursorOut(Cursor &) { }
+
void save(ofBuffer &);
void load(ofBuffer &);
};
View
30 src/ofxGrabScene/Scene.cpp
@@ -149,16 +149,16 @@ namespace GrabScene {
//clear cut cases:
if (returnedIndex == 0) {
//we're not over anything
- this->elementUnderCursor = 0;
- this->nodeUnderCursor = 0;
+ this->setElementUnderCursor(0);
+ this->setNodeUnderCursor(0);
} else if (returnedIndex < this->elements.size()) {
//we're over an element
- this->elementUnderCursor = returnedIndex;
- this->nodeUnderCursor = 0;
+ this->setElementUnderCursor(returnedIndex);
+ this->setNodeUnderCursor(nodeUnderCursor);
} else if (returnedIndex - this->elements.size() < this->nodes.size()) {
//we're over a node
- this->elementUnderCursor = 0;
- this->nodeUnderCursor = returnedIndex - this->elements.size();
+ this->setElementUnderCursor(0);
+ this->setNodeUnderCursor(returnedIndex - this->elements.size());
} else {
//we're fucked
ofLogError("GrabScene") << "Error when checking what's under the cursor";
@@ -321,6 +321,24 @@ namespace GrabScene {
}
//----------
+ void Scene::setNodeUnderCursor(uint16_t index) {
+ if (this->nodeUnderCursor == index || index >= this->nodes.size())
+ return;
+ this->nodes[nodeUnderCursor]->cursorOut(this->cursor);
+ this->nodeUnderCursor = index;
+ this->nodes[nodeUnderCursor]->cursorOver(this->cursor);
+ }
+
+ //----------
+ void Scene::setElementUnderCursor(uint16_t index) {
+ if (this->elementUnderCursor == index || index >= this->nodes.size())
+ return;
+ this->elements[elementUnderCursor]->cursorOut(this->cursor);
+ this->elementUnderCursor = index;
+ this->elements[elementUnderCursor]->cursorOver(this->cursor);
+ }
+
+ //----------
void Scene::updateCursor() {
this->cursor.lastFrame = this->cursor;
View
3  src/ofxGrabScene/Scene.h
@@ -93,6 +93,9 @@ namespace GrabScene{
//
bool lockIndex;
//
+ void setElementUnderCursor(uint16_t);
+ void setNodeUnderCursor(uint16_t);
+ //
////
Please sign in to comment.
Something went wrong with that request. Please try again.