Sphere deform issue


#1

Hello guys,

I am trying to recreate the example from openFrameworks Essentials -AV synthesizer. In chapter 5 it gives a way to deform the sphere which is the following:

vector &vertices = sphere.getMesh().getVertices();
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;
}

This is not working so instead I used glm::vec3 vectors:

vectorglm::vec3 &vertices = sphere.getMesh().getVertices();
for (int i = 0; i < vertices.size(); i++) {
glm::vec3 v = vertices0[i];
glm::normalize(v);
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 *= int(rad);

	vertices[i] = v;

}

This way I get no errors but the sphere is no longer drawn in the screen. Does anybody know what I am doing wrong here? Thanks :smiley:


#2

FIX: I used glm::normalize(v); instead I should be using v = glm::normalize(v);