secret
Created

Nonlinear Animation Ex. for or Adv. Animation Studio, HW

  • Download Gist
sphereCycle.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
#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 )

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.