Mike
I have started to work on the individual mesh rotation, using a new meta #rotate rStep, rX, rY, rZ that is based on
glRotatef(rStep, rX, rY, rZ) to perform the rotation
at the end of struct MobjMat, i have added this new parameter
float rotate[4]; // PAT: 06-05-2018 dito glRotatef(rSpeed, rX, rY, rZ);
However in order to perform a correct rotation i need to use
glTranslatef(-x, -y, -z) // Move to center
glRotatef(rotation_angle, 0.0f, 0.0f, axisToUse)
glTranslate(x, y, z) // Restore the initial location
I was thinking to use something similar to what you have done in billboard and calcMeshBounds to retrieve the correct
x, y, z mesh bounds to apply the translation.
Do you think that it is the best way to do it ?
Added:
// Dirty code to test the rotation
if (pMaterial->rotate[0] != 0.0f) {
userotate += 5.0;
if (userotate > 360.0f) { userotate = userotate - 360.0f; }
float rx = 1.0f; if (pMesh->centerPoint[0] > 0.0f) { rx = -1.0f; }
float ry = 1.0f; if (pMesh->centerPoint[1] > 0.0f) { ry = -1.0f; }
float rz = 1.0f; if (pMesh->centerPoint[2] > 0.0f) { rz = -1.0f; }
glTranslatef(pMesh->centerPoint[0] * rx, pMesh->centerPoint[1] * ry, pMesh->centerPoint[2] * rz);
glRotatef(userotate, 0.0f, 0.0f, 1.0f);
rx = -rx; ry = -ry; rz = -rz;
glTranslatef(pMesh->centerPoint[0] * rx, pMesh->centerPoint[1] * ry, pMesh->centerPoint[2] * rz);
}
To see the result look at the attached video