Last active
April 3, 2017 12:51
-
-
Save micromeeeter/ded5939c99c126c766f90f847ecb6fcf to your computer and use it in GitHub Desktop.
ce_mosha
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 "ofApp.h" | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
ofBackground(29, 44, 121); | |
ofEnableBlendMode(OF_BLENDMODE_ALPHA); | |
ofSetWindowShape(width, height); //720*720 | |
ofSetFrameRate(30); | |
ofSetLineWidth(3); | |
ofNoFill(); | |
ofSetCircleResolution(64); | |
for(int i = 0; i < 9; i++){ | |
radius[i] = 50 + 20 * pow(i+1, 1.6); //惑星の軌道半径の設定 | |
} | |
//衛星の球の半径、形状の設定 | |
sphere[0].set(5, 3); | |
sphere[1].set(6, 3); | |
sphere[2].set(7, 3); | |
sphere[3].set(5, 3); | |
sphere[4].set(25, 3); | |
sphere[5].set(20, 3); | |
sphere[6].set(8, 3); | |
sphere[7].set(8, 3); | |
sphere[8].set(7, 3); | |
for(int i = 0; i < 9; i++){ | |
sphere[i].setPosition(radius[i] * cos(ofGetFrameNum()/180.0*PI + 170.0 * i), radius[i] * sin(ofGetFrameNum()/180.0*PI + 170.0 * i), 0); | |
} | |
//恒星の球半径、形状の設定 | |
sphere[9].set(40, 4); | |
sphere[9].setPosition(0, 0, 0); | |
sphere[10].set(20, 8); | |
sphere[10].setPosition(0, 0, 0); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
//cam | |
cam.begin(); | |
cam.setPosition(600.0* sin(ofGetFrameNum()/90.0*PI)* cos(ofGetFrameNum()/180.0*PI), 600.0* (0.5+sin(ofGetFrameNum()/90.0*PI))* sin(ofGetFrameNum()/180.0*PI), 300.0 * sin(ofGetFrameNum()/180.0*PI)); | |
cam.lookAt(ofVec3f(-cos(ofGetFrameNum()/180.0*PI), -sin(ofGetFrameNum()/180.0*PI),0), ofVec3f(0, 1, 0)); | |
ofRotateX(ofGetFrameNum()/180.0 * PI); | |
//図形描画 | |
ofSetColor(255, 146, 178, 200); | |
sphere[10].drawWireframe(); | |
ofSetColor(255, 255, 255, 200); | |
for(int i = 0; i < 10; i++){ | |
ofRotateY(110.0 * (i + 1)); | |
ofCircle(0, 0, 0, radius[i]); | |
sphere[i].drawWireframe(); | |
} | |
sphere[9].drawWireframe(); | |
cam.end(); | |
//画面保存 | |
if(ofGetFrameNum() < 360){ | |
ofSaveFrame(); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyPressed(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyReleased(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseMoved(int x, int y ){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseDragged(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mousePressed(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseReleased(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::windowResized(int w, int h){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::gotMessage(ofMessage msg){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::dragEvent(ofDragInfo dragInfo){ | |
} |
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
#pragma once | |
#include "ofMain.h" | |
class ofApp : public ofBaseApp{ | |
public: | |
void setup(); | |
void update(); | |
void draw(); | |
void keyPressed(int key); | |
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 windowResized(int w, int h); | |
void dragEvent(ofDragInfo dragInfo); | |
void gotMessage(ofMessage msg); | |
ofEasyCam cam; | |
int width = 720; | |
int height = 720; | |
ofSpherePrimitive sphere[11]; | |
float radius[9]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment