ofSpherePrimitive sphere;
ofEasyCam cam;
ofxPanel gui;
ofxIntSlider countX;
ofLight light;
ofMaterial material;
ofxFloatSlider rad, deform, deformFreq, extrude;
vector<ofPoint> vertices0;
//--------------------------------------------------------------
void ofApp::setup(){
gui.setup( "MixerGroup", "setting.xml" );
gui.add( rad.setup("rad", 250, 0, 500) ) ;
gui.add( deform.setup("deform", 0.3, 0, 1.5) ) ;
gui.add( deformFreq.setup("deformFreq", 3, 0, 10) ) ;
gui.add( extrude.setup("extrude", 1, 0, 1) ) ;
sphere.set(250,20);
vertices0 = sphere.getMesh().getVertices(); /* No viable overloaded '=' */
}
//--------------------------------------------------------------
void ofApp::update(){
vector<ofPoint> &vertices = sphere.getMesh().getVertices();
/* Non-const lvalue reference to type âvectorâ cannot bind to a value of unrelated type âvector<glm::tvec3<float, glm::packed_highp>>â */
for (int i=0; i<vertices.size(); i++) {
ofPoint v = vertices0[i];
v.normalize();
float sx = sin (v.x * deformFreq);
float sy = sin (v.y * deformFreq);
float sz = sin (v.z * deformFreq);
v.x += sy * sz * deform;
v.y += sx * sz * deform;
v.z += sx * sy * deform;
v *= rad;
vertices[i] = v;
}
}
//--------------------------------------------------------------
void ofApp::draw(){
light.setPosition ( ofGetWidth()/2, ofGetHeight()/2, 600);
light.enable();
material.begin();
ofEnableDepthTest();
cam.begin();
ofSetColor ( ofColor::white ) ;
sphere.draw() ;
sphere.setGlobalPosition( ofGetWidth()/2, ofGetHeight()/2, 0 ) ;
cam.end();
}
//--------------------------------------------------------------
Iâm beginner of OF. When I followed the description of books to deform sphere, the error comes up. I make wrong code bold. please check it out. Thank you.