Hello,
First, check the images added (foto 1 and 2).
You will se that there’s some parts of the robot where the light isn’t correctly displayed.
You may be thinking about different problems, I will explain the algorithm used as best as I can to see if someone find the problem.
Step 1:
Each joint (part) of the robot is drawed in a different origin of coordinates (Denavit-Hartenberg transformation). So, for each vertex of the joints, we need to make the transformation to:
GLfloat * matrixModel = new GLfloat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrixModel);
//ModelView after the transformation
matrixModel = mCalc.doTranspose(matrixModel);
matrixModel = mCalc.doInverse(matrixModel);
vertexArray = new GLfloat[sizeVertex];
Vertex v;
int i = 0;
int j;
for(j=0;j<vertexVector.size();j++)
{
v = vertexVector[j]; //vertexVector ----> vector<Vertex> type ---> Vertex is a struct of 3 floats
vertexArray[i] = v.x*matrixModel[0]+v.y*matrixModel[1]+v.z*matrixModel[2]+matrixModel[3];
//transforming to the new origin coordinantes..
vertexArray[i+1] = v.x*matrixModel[4]+v.y*matrixModel[5]+v.z*matrixModel[6]+matrixModel[7];
vertexArray[i+2] = v.x*matrixModel[8]+v.y*matrixModel[9]+v.z*matrixModel[10]+matrixModel[11];
i+=3;
}
After this I do the same with normals except that I don’t apply the calculations to transform it to the new origin coordinantes.
Those arrays are added to VBO and after, I call glDrawArrays(…) (in a different function ofc).
I tryied to apply the calculations to transform it to the new origin coordinantes to the normals but the result is horrible (check foto4).
Do you have any idea?
Thanks