not good but great

プログラミング、アート、映画・本の感想について書きます。

openFrameworksで3dの球を表示する

demo

f:id:naoyashiga:20140403220439p:plain
球を表示してみました。

ヴァージョンの違いに注意

ヴァージョンによって、3dSphereを扱うクラス名が違うので注意です。
ヴァージョン0.7

ofSphere

こちらの資料は0.7で作られています。
http://openframeworks.cc/tutorials/first%20steps/004_presentations.html

ofSpherePrimitive

これは0.8です。僕はこちらで書きました。
http://www.slideshare.net/tado/media-art-ii-2013

code

ofSpherePrimitive sphere;

インスタンスを生成します。

void ofApp::draw(){
    ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
    ofSetColor(255);
    
    sphere.set(100, 16);
    sphere.setPosition(150, 0, 0);
    sphere.drawWireframe();

}

こんな感じでdrawします。

http://openframeworks.cc/documentation/3d/ofSpherePrimitive.html

詳しいことはまだわからないので後日にまわします・・・。