Skip to content

Instantly share code, notes, and snippets.

@tgfrerer
Created March 1, 2016 19:48
Show Gist options
  • Save tgfrerer/525e219d55a39f718b23 to your computer and use it in GitHub Desktop.
Save tgfrerer/525e219d55a39f718b23 to your computer and use it in GitHub Desktop.
#include "ofMain.h"
class ofApp : public ofBaseApp {
ofVboMesh mSphere;
ofNode mNode;
ofNode mNode1;
ofNode mNode2;
ofCamera mCam1;
bool mOrb = false;
public:
void setup() {
mSphere = ofSpherePrimitive(100, 6).getMesh();
ofSetBackgroundColor(ofFloatColor(0.3));
ofEnableDepthTest();
mCam1.enableOrtho();
mCam1.setPosition(0, 200, 0);
mCam1.lookAt({ 0.f,0.f,0.f }, { 0.f, 0.f, -1.f });
};
void update() {
mNode = ofNode();
mNode1 = ofNode();
mNode2 = ofNode();
mNode2.setParent(mNode);
mNode.orbit(90, 0, 100);
// at this point i would expect mNode2 to be congruent with its parent node
mNode2.truck(-100.f);
// now i would expect mNode2 to be 100 units behind its parent node on its x axis
// and i would expect mNode1 to store the current state of mNode2, so that we
// can display it later
mNode1 = mNode2;
// now i would expect mNode 2 to have been rotated 90 deg around mNode, which is the red node
mNode2.orbit(90, 0, 100, mNode);
};
void draw() {
mCam1.begin();
ofSetColor(ofColor::white);
ofDrawGrid(150, 10, true, false, true, false);
mSphere.drawWireframe();
ofSetColor(ofColor::red);
mNode.draw();
ofSetColor(ofColor::green);
mNode1.draw();
ofSetColor(ofColor::blue);
mNode2.draw();
mCam1.end();
};
void keyPressed(int key) {
mOrb ^= true;
};
void keyReleased(int key) {};
void mouseMoved(int x, int y) {};
void mouseDragged(int x, int y, int button) {};
void mousePressed(int x, int y, int button) {};
void mouseReleased(int x, int y, int button) {};
void mouseEntered(int x, int y) {};
void mouseExited(int x, int y) {};
void windowResized(int w, int h) {};
void dragEvent(ofDragInfo dragInfo) {};
void gotMessage(ofMessage msg) {};
};
//========================================================================
int main() {
ofGLFWWindowSettings settings;
settings.setGLVersion(3, 3);
ofCreateWindow(settings);
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment