-
-
Save miguelbermudez/d6d3adf4da199afa8d6b to your computer and use it in GitHub Desktop.
Nonlinear Animation Ex. for or Adv. Animation Studio, HW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "cinder/app/AppBasic.h" | |
#include "cinder/gl/gl.h" | |
using namespace ci; | |
using namespace ci::app; | |
using namespace std; | |
class sphereCycleApp : public AppBasic { | |
public: | |
void prepareSettings( Settings *settings ); | |
void setup(); | |
void mouseDown( MouseEvent event ); | |
void update(); | |
void draw(); | |
int radius; | |
}; | |
void sphereCycleApp::prepareSettings( Settings *settings ) | |
{ | |
settings->setWindowSize( 512, 384 ); | |
settings->setFrameRate( 60.0f ); | |
settings->setFullScreen( false ); | |
} | |
void sphereCycleApp::setup() | |
{ | |
radius = 100; | |
} | |
void sphereCycleApp::mouseDown( MouseEvent event ) | |
{ | |
} | |
void sphereCycleApp::update() | |
{ | |
} | |
void sphereCycleApp::draw() | |
{ | |
// clear out the window with black | |
gl::clear( Color( 0, 0, 0 ) ); | |
float s = 0; | |
float t = 0; | |
float lastx = 0; | |
float lasty = 0; | |
float lastz = 0; | |
while(t < 180) { | |
s += 18; | |
t += 1; | |
float radianS = toRadians(s); | |
float radianT = toRadians(t); | |
float thisx = 0 + (radius * cos(radianS) * sin(radianT)); | |
float thisy = 0 + (radius * sin(radianS) * sin(radianT)); | |
float thisz = 0 + (radius * cos(radianT)); | |
if (lastx != 0) { | |
glColor3f(1, 1, 1); | |
gl::pushMatrices(); | |
gl::translate(Vec2f(getWindowWidth()/2, getWindowHeight()/2)); | |
gl::rotate( Vec3f(getElapsedFrames()*0.09, getElapsedFrames()*0.04, 0) ); | |
gl::drawLine(Vec3f(thisx, thisy, thisz), Vec3f(lastx, lasty, lastz)); | |
gl::popMatrices(); | |
} | |
lastx = thisx; | |
lasty = thisy; | |
lastz = thisz; | |
} | |
} | |
CINDER_APP_BASIC( sphereCycleApp, RendererGl ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment