#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
sound.load("SHATTER ME.mp3");
sphere.setRadius(200);
sphere.setResolution(resolution);
sphere.setPosition(ofGetWidth()/2, ofGetHeight()/2, 0);
planet = sphere.getMesh();
vector<ofVec3f>& verts = planet.getVertices();
originVerts = planet.getVertices();
for(int i = 0; i < verts.size(); i++){
planet.addColor(ofFloatColor( float(i)/planet.getVertices().size(), 0, 1.0 - (float(i)/planet.getVertices().size()) ));
}
fftSmooth = new float [8192];
bands = resolution;
for (int i=0; i<bands; i++) {
fftSmooth[i] = 0;
}
sound.play();
}
//--------------------------------------------------------------
void ofApp::update(){
ofSoundUpdate();
float * spectrum = ofSoundGetSpectrum(bands);
for (int i=0; i<bands; i++) {
fftSmooth[i] *= 0.9f;
if (fftSmooth[i] < spectrum[i]) {
fftSmooth[i] = spectrum[i];
}
}
vector<ofVec3f>& verts = planet.getVertices();
for(int i = 0; i < verts.size(); i++){
if(i >= 12*(resolution*2)+12 && i < 15*(resolution*2)+15) {
//manipulate verts here
verts[i].x = 100;
verts[i].y = 100;
verts[i].z = 100;
}
}
}
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(180, 180, 180);
cam.begin();
planet.drawWireframe();
cam.end();
// sphere.drawWireframe();
}
im trying to increase the radius on the row of the sphere, im using a sphere primative,
the fftsmooth is used to analyse my sound and i want to use to increase the radius.
i would like to increase the sphere radius and then decrease it again, i hope somebody know how to do this.