Manipulate ofSpherePrimative with ofvec3f

#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.

Try storing the original positions normalized. All of the vertices are relative to the center, which is basically a normal.

originVerts = planet.getVertices();
for( int i = 0; i < originVerts.size(); i++ ) {
     originVerts[i].normalize();
}

Now that you have all of the normals, you can multiply each vert along that vector. You can choose how to map the fft values.

float * spectrum = ofSoundGetSpectrum(bands);
     for (int i=0; i<bands; i++) {
         fftSmooth[i] *= 0.9f;
         if (fftSmooth[i] < spectrum[i]) {
             fftSmooth[i] = spectrum[i];
         }
     }
float baseRadius = 200.f;

    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
            int fftindex = ofMap( i, 12*(resolution*2)+12, 15*(resolution*2)+15, 0, bands-1, true );
            if( fftindex >= bands) fftindex = bands-1;
            float fftRadius = fftSmooth[fftindex] * 100.f;
            verts[i] = origVerts[i] * (baseRadius + fftRadius);
        }
    }

thanks so much i tried to fix it with this code

if(i >= 10*(resolution*2)+10 && i < 11*(resolution*2)+11) {
    float angle = ofMap(i, 10*(resolution*2)+10, 11*(resolution*2)+10, 0, 2*PI);
    float r = 200 + fftSmooth[1]*multiplier;
    float x = r * sin(angle);
    float z = r * cos(angle);
    //manipulate verts here
    verts[i].x = x;
    verts[i].z = z;   
}

but then i needed to make this for every single layer of verts and it would only work with this sphere and radius, ur solution is a lot shorter and better.