You should be fully aware of the following two major issues:
0. Your nullified astro-rotation is only feasible if all the rotating meshes are concentric resp. the model center of origin. An attempt to move them elsewhere, or rotate the meshes that are concentric resp. any other point in model space, will send the meshes flying all over the screen in complete chaos. Thus it is one and only special case of a myriad possible mesh animations.
1. Your remming out the red portion of calcMeshBounds() for the animated meshes renders them inferior to the model's other static meshes. Having no centers, bounding boxes and other relevant data, they cannot be effectively used for early visibility culling (my pending TODO to ease up the rendering pipeline), collision detection, physics, etc.
If you still insist on being given such an opportunity, you should do the following:
1. Increase the size of
rotate[] array in the material structure definition (
globals.h) to
rotate[8] and
do not forget to clear it with 0
in all the places where a material structure is initialized. There are
two such places in
mobj.h: Mobj_importMaterials() and Mobj_importGeometryFirstPass().
2. Leave calcMeshBounds() alone the way it is now.
3. Use
rotate[7] as a 0.f/1.f flag to indicate the mesh is supposed to rotate model-centrically regardless of its centroid.
4. Add yet one more
%f to the case
else if (strcmp(szBuffer, "#rotate") == 0) format string in Mobj_importMaterials() (
mobj.h) to read the new flag into
rotate[7].
5. Use the following code in both drawUsingFixedFuncPipeline() and drawUsingProgrammablePipeline() (
renderers.h):
........
// Test rotation // MLL 06-11-2018:
if (bDoRotate) {
float nullCentroid[3] = { 0 };
float m[16], *c = pMaterial->rotate[7] != 0.0f ? nullCentroid : pMesh->meshCentroid; // cache
float *r = pMaterial->rotate, a = pMaterial->rotangle; // ditto
float c0 = c[0], c1 = c[1], c2 = c[2]; // ditto
float r1 = r[1], r2 = r[2], r3 = r[3]; // ditto
glPushMatrix();
glGetFloatv(GL_MODELVIEW_MATRIX, m);
mtxTranslate(m, c0, c1, c2);
if (r1) mtxRotate(m, r1, 0, 0, a);
if (r2) gP.bAxesSwapped ? mtxRotate(m, 0, 0, r2, a) : mtxRotate(m, 0, r2, 0, a);
if (r3) gP.bAxesSwapped ? mtxRotate(m, 0, r3, 0, a) : mtxRotate(m, 0, 0, r3, a);
mtxTranslate(m, -c0, -c1, -c2);
glLoadMatrixf(m);
}
........6. .........................................................................
7. Profit!
(Tell me if those mods are doing for you what you want. I haven't yet tested them here.)Re. AlphaMask: It works for me the way it is (standalone) but it needs some adjustments for use in ObjReader. I don't currently have enough time nor health to finalize it. The weather has been very unstable here in recent two weeks or so, which is making me seriously unwell...
