I am trying to use matrix palettes for vertex skinning
I have two cuboids adjacent to each other. One of the cuboid is rotated, which results in a gap between the cuboids (like bending an arm).
Now i would like to use matrix palettes for skinning. Is it achieved by the below code?
I do not know how to decide the elements of the matrix and also how to assign a set of matrices to a particular vertex. Since all the vertices do not need skinning and only the vertices which are adjacent to each other need skinning ( in my case 4 vertices, 2 from each cuboid) .
//VBO’s are used to upload the vertices and texture
GLfloat weights[] = {0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f };
GLfloat matrix[4][16] = {…};
glEnable(GL_MATRIX_PALETTE_OES);
glMatrixMode(GL_MATRIX_PALETTE_OES);
glCurrentPaletteMatrixOES(0);
glLoadMatrixf(matrix[0]);
glCurrentPaletteMatrixOES(1);
glLoadMatrixf(matrix[1]);
glCurrentPaletteMatrixOES(2);
glLoadMatrixf(matrix[2]);
glCurrentPaletteMatrixOES(3);
glLoadMatrixf(matrix[3]);
glEnableClientState(GL_MATRIX_INDEX_ARRAY_OES);
glEnableClientState(GL_WEIGHT_ARRAY_OES);
glWeightPointerOES (1, GL_FLOAT, 0, weights);
glMatrixIndexPointerOES (1, GL_UNSIGNED_BYTE, sizeof(GLfloat) * 16, matrix);
glMatrixMode(GL_MODELVIEW);
//Draw and move the objects
Thank you.