Skip to content

Instantly share code, notes, and snippets.

@roymacdonald
Created August 13, 2015 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roymacdonald/8d8e2260c593209e3918 to your computer and use it in GitHub Desktop.
Save roymacdonald/8d8e2260c593209e3918 to your computer and use it in GitHub Desktop.
Test for openFrameworks fix-ofNodeOrbit
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1024,768, OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp( new ofApp());
}
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
gui.setup();
gui.add(latitude.set("latitude", 0,-360,360));
gui.add(longitude.set("longitude", 0,-360,360));
gui.add(radius.set("radius", 100, 0, 1000));
gui.add(centerPoint.set("center", ofVec3f(0),ofVec3f(-1000),ofVec3f(1000)));
}
//--------------------------------------------------------------
void ofApp::update(){
node.orbit(longitude, latitude, radius, centerPoint);
}
//--------------------------------------------------------------
void ofApp::draw(){
if(ofGetKeyPressed(' ')){
ofCamera c;
c.setTransformMatrix(node.getGlobalTransformMatrix());
c.begin();
ofDrawGrid(100,10, true);
c.end();
}else{
cam.begin();
ofDrawGrid(100,10, true);
node.draw();
cam.end();
}
gui.draw();
}
#pragma once
#include "ofMain.h"
#include "ofxGui.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
ofxPanel gui;
ofParameter<ofVec3f> centerPoint;
ofParameter<float>latitude, longitude, radius;
ofEasyCam cam;
ofNode node;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment