added ofDrawGrid to complement ofDrawAxis. added 'get' accessors to ofCam #726

Merged
merged 3 commits into from Feb 9, 2012
@@ -19,3 +19,82 @@ void ofDrawAxis(float size) {
ofPopStyle();
}
+
+//--------------------------------------------------------------
+void ofDrawGrid(float scale, float ticks, bool labels, bool x, bool y, bool z) {
+
+ ofColor c = ofGetStyle().color;
+
+ ofPushStyle();
+
+ if (x) {
+ c.setHue(0.0f);
+ ofSetColor(c);
+ ofDrawGridPlane(scale, ticks, labels);
+ }
+ if (y) {
+ c.setHue(255.0f / 3.0f);
+ ofSetColor(c);
+ ofPushMatrix();
+ ofRotate(90, 0, 0, 1);
+ ofDrawGridPlane(scale, ticks, labels);
+ ofPopMatrix();
+ }
+ if (z) {
+ c.setHue(255.0f * 2.0f / 3.0f);
+ ofSetColor(c);
+ ofPushMatrix();
+ ofRotate(90, 0, 1, 0);
+ ofDrawGridPlane(scale, ticks, labels);
+ ofPopMatrix();
+ }
+
+ ofPopStyle();
+}
+
+
+//--------------------------------------------------------------
+void drawGridPlane(float scale, float ticks, bool labels) {
+
+ float minor = scale / ticks;
+ float major = minor * 2.0f;
+
+ ofPushStyle();
+ for (int iDimension=0; iDimension<2; iDimension++)
+ {
+ for (float yz=-scale; yz<=scale; yz+= minor)
+ {
+ //major major
+ if (fabs(yz) == scale || yz == 0)
+ ofSetLineWidth(4);
+
+ //major
+ else if (yz / major == floor(yz / major) )
+ ofSetLineWidth(2);
+
+ //minor
+ else
+ ofSetLineWidth(1);
+ if (iDimension==0)
+ ofLine(0, yz, -scale, 0, yz, scale);
+ else
+ ofLine(0, -scale, yz, 0, scale, yz);
+ }
+ }
+ ofPopStyle();
+
+ if (labels) {
+ //draw numbers on axes
+ ofPushStyle();
+ ofSetColor(255, 255, 255);
+
+ ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
+ for (float yz = -scale; yz<=scale; yz+=minor)
+ {
+ ofDrawBitmapString(ofToString(yz, 0), 0, yz, 0);
+ ofDrawBitmapString(ofToString(yz, 0), 0, 0, yz);
+ }
+ ofPopStyle();
+ }
+
+}
@@ -1,3 +1,6 @@
#pragma once
void ofDrawAxis(float size);
+
+void ofDrawGrid(float scale = 10.0f, float ticks = 5.0f, bool labels = false, bool x = true, bool y = true, bool z = true);
+void ofDrawGridPlane(float scale, float ticks = 5.0f, bool labels = false);
@@ -34,6 +34,10 @@ class ofCamera : public ofNode {
void setNearClip(float f);
void setFarClip(float f);
+ float getFov() const { return fov; };
+ float getNearClip() const { return nearClip; };
+ float getFarClip() const { return farClip; };
+
void enableOrtho();
void disableOrtho();
bool getOrtho() const;
@@ -57,7 +61,7 @@ class ofCamera : public ofNode {
ofVec3f cameraToWorld(ofVec3f CameraXYZ, ofRectangle viewport = ofGetCurrentViewport());
-private:
+protected:
void calcClipPlanes(ofRectangle viewport);
bool isOrtho;
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 42;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -51,7 +51,6 @@
E4B27C2E10CBEBAB00536013 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9770E8CC7DD009D7055 /* CoreServices.framework */; };
E4B27C3010CBEBAB00536013 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9790E8CC7DD009D7055 /* OpenGL.framework */; };
E4B27C3110CBEBAB00536013 /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE97A0E8CC7DD009D7055 /* QuickTime.framework */; };
- E4B5AE1E12D94F9B00BA355D /* ofQtUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B5AE1412D94F9B00BA355D /* ofQtUtils.cpp */; };
E4B5AE1F12D94F9B00BA355D /* ofQtUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B5AE1512D94F9B00BA355D /* ofQtUtils.h */; };
E4B5AE2012D94F9B00BA355D /* ofQuickTimeGrabber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B5AE1612D94F9B00BA355D /* ofQuickTimeGrabber.cpp */; };
E4B5AE2112D94F9B00BA355D /* ofQuickTimeGrabber.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B5AE1712D94F9B00BA355D /* ofQuickTimeGrabber.h */; };
@@ -631,8 +630,11 @@
/* Begin PBXProject section */
E4B69B4C0A3A1720003C02F2 /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "openFrameworksLib" */;
- compatibilityVersion = "Xcode 2.4";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
@@ -664,7 +666,6 @@
E4B27C2610CBEB9D00536013 /* ofVideoGrabber.cpp in Sources */,
E4B27C2710CBEB9D00536013 /* ofVideoPlayer.cpp in Sources */,
E4998A26128A39480094AC3F /* ofEvents.cpp in Sources */,
- E4B5AE1E12D94F9B00BA355D /* ofQtUtils.cpp in Sources */,
E4B5AE2012D94F9B00BA355D /* ofQuickTimeGrabber.cpp in Sources */,
E4B5AE2212D94F9B00BA355D /* ofQuickTimePlayer.cpp in Sources */,
E4F3BA6712F4C4BF002D19BB /* of3dUtils.cpp in Sources */,
@@ -749,9 +750,8 @@
"$(LIB_GLUT)",
"$(LIB_FMODEX)",
);
- PREBINDING = NO;
PRODUCT_NAME = openFrameworksDebug;
- SDKROOT = "";
+ SDKROOT = macosx10.6;
};
name = Debug;
};
@@ -790,9 +790,8 @@
"$(LIB_GLUT)",
"$(LIB_FMODEX)",
);
- PREBINDING = NO;
PRODUCT_NAME = openFrameworks;
- SDKROOT = "";
+ SDKROOT = macosx10.6;
};
name = Release;
};