Author Topic: hover_guard  (Read 4948 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
hover_guard
« on: January 26, 2019, 06:20:09 pm »
The accrobatic contortions are over, here is the final version.
This one uses one more mesh and a new texture set to achieve the extra rotations.

Thank you again for your help and suggestions.
« Last Edit: January 30, 2019, 06:53:54 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: hover_guard
« Reply #1 on: January 29, 2019, 08:47:12 am »
Good morning Patrice,

Hope you slept well. :)

0. First of all, implement the code as I described earlier and enjoy the results.

1. Now goto the MobjMat definition in globals.h and change it as follows:
........
    float rotate[7];  // MLL: 01-29-2019 glRotatef(rSpeed, rX, rY, rZ)+lbound(rock)+ubound(rock)+init(rotangle)
........


2. In mobj.h, fix material initialization (!!!) in Mobj_importMaterials() and Mobj_importGeometryFirstPass() to reset the new rotate[6] element to 0.0f.

3. In mobj.h, fix Mobj_importMaterials() as follows:
........
            } else if (strcmp(szBuffer, "#rotate") == 0) { // PAT: 06-05-2018
                fscanf(pFile, "%f %f %f %f %f %f %f", &pMaterial->rotate[0], &pMaterial->rotate[1], &pMaterial->rotate[2],
                    &pMaterial->rotate[3], &pMaterial->rotate[4], &pMaterial->rotate[5], &pMaterial->rotate[6]); // MLL 01-29-2019:
                pMaterial->rotangle = pMaterial->rotate[6];
                saturateVec3(&pMaterial->rotate[1]); // MLL 06-13-2018: saturate rotation axes to +-1.f
........


4. In Main.cpp, fix ResetCamera() as follows:
........
        if (gM.numberOfMeshes) { // PAT: 01-01-2019 avoid subscript out of range
            MobjMesh* pMesh = &gtm_meshes[0];
            for (int i = 0; i < gM.numberOfMeshes; i++, pMesh++) { // MLL 10-18-2018: reset mesh rotation angles
                pMesh->pMaterial->rotangle = pMesh->pMaterial->rotate[6]; // MLL 01-29-2019:
            }
        }
........


5. In renderers.h, use the following shorter and faster code in the both drawUsingXXX() render procs:
........
        if (gP.bRotation) { // MLL 06-13-2018: regardless of visibility!
            float* rotate = pMaterial->rotate, *rotangle = &pMaterial->rotangle; // cache
            if ((*rotangle += rotate[0]) > 720.0f) // pure rotation & rocking
                *rotangle -= 720.0f;
            if (rotate[4] != rotate[5]) { // rocking only
                if ((*rotangle > rotate[5]) || (*rotangle < rotate[4])) {
                    rotate[0] = -rotate[0]; // flip sign
                    *rotangle += (2.0f * rotate[0]); // fix angular position
                }
            }
        }
........


6. And finally, use the following meta in the wip mat library to test the latest mods:
#rotate -1 0 1 0 315 405 360



Now you can start enjoying yet better results. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: hover_guard
« Reply #2 on: January 29, 2019, 11:59:55 am »
Thank you for your efforts, that works very well!

I have added this at line 1630 in mobj.h
                fscanf(pFile, "%f %f %f %f %f %f %f", &pMaterial->rotate[0], &pMaterial->rotate[1], &pMaterial->rotate[2], &pMaterial->rotate[3], &pMaterial->rotate[4], &pMaterial->rotate[5], &pMaterial->rotate[6]); // MLL 01-29-2019
                if (pMaterial->rotate[6] == 0.0f) pMaterial->rotate[6] = pMaterial->rotate[4] + (pMaterial->rotate[5] - pMaterial->rotate[4]) / 2.0f;
                pMaterial->rotangle = pMaterial->rotate[6];
« Last Edit: January 29, 2019, 01:09:05 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: hover_guard
« Reply #3 on: January 29, 2019, 01:08:08 pm »
I have added this at line 1630 in mobj.h

Oui, vous avez raison, mon ami! :)

But please make it *0.5f rather than /2.0f. No speed compromises! :D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: hover_guard
« Reply #4 on: January 30, 2019, 06:08:22 pm »
The first post of this thread has been updated with a new zip.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: hover_guard
« Reply #5 on: January 30, 2019, 06:17:39 pm »
Wow-wow-wow, hold on a little!

The two bottom green lights are still a little off their respective shadow spots!!! :D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: hover_guard
« Reply #6 on: January 30, 2019, 07:00:30 pm »
I think i have fixed the light offset, however there is still a small glitch if you look the turret rotation from the bottom, this is because i was too lazy to rework the missing symmetry.  ::)

The zip has been updated.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: hover_guard
« Reply #7 on: January 30, 2019, 07:29:52 pm »
Thank you, Patrice! :)

The eccentricity of bottom turret is not so much noticeable and we can live with it, I think.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: hover_guard
« Reply #8 on: January 30, 2019, 07:54:36 pm »
By the way, what about:

1. A matching #translate, both global and local? The global one could help implement such effects like e.g. idle hovering of the craft in the air...

2. Interpolated propagation of the camera along a closed trajectory described by a set of Bezier control points around the model or along a route in the streets of a city model or in the corridors of a mansion?

The effects are called cinematics, i.e. pre-programmed animation of the model's (or models') geo in the scene. (simple as it can be in our case...)

8)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: hover_guard
« Reply #9 on: January 30, 2019, 09:24:13 pm »
#translate, yes that could be a nice addition, i already tought of it to create simple up or down effect, and cinematic sounds also good to me.

About cinematic, does that means that we should use a specific mesh to create the path or the Bezier curve ?
« Last Edit: January 31, 2019, 09:12:20 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: hover_guard
« Reply #10 on: January 31, 2019, 11:40:09 am »
#translate, yes that could be a nice addition, i already tought of it to create simple up or down effect, and cinematic sounds also good to me.

OK, I'm going to work on both #translate and #scale to complete the classic "holy trinity" of options. I'll open separate WIP topics on them. I'm finding these options an interesting challenge and a good excuse for my persistent procrastination regarding frustum culling, FBO, and PP. ;)

Quote
About cinematic, does that means that we should use a specific mesh to create the path or the Bezier curve ?

Cinematics means any pre-programmed animation of models or meshes. It's like running a movie film through your Monroe projector on your screen. Thus, an animated view of your steam-punk hover_guard is already a cinematics of sorts. :)

OTOH the pre-programming of camera trajectory around the scene is called camera path editing. Ideally it would require a dedicated WYSIWYG editor to be integrated in ObjReader but we can subside to just adding an invisible d 0 "mesh" called, say, campath similar to how you create your shadow meshes for your models using your C4D editor. We can have this "mesh" written verbatim into the OBJ file (it is invisible, after all) or we can later on comment it out manually using hashtags, but it isn't absolutely necessary.

Additionally, we can have one more invisible "mesh" called e.g. camtarget to define the orientation (view vector) of camera towards the points of interest as it moves along its path. (re. gluLookAt() in gl_DrawScene())

Alternatively, we can use Wavefront OBJ vp u [, v[, w]] statements (see the format specs if you still have them ;)) to define this "mesh" as a Bezier curve in an absolutely legit way. I do not know of any contemporary 3D editor/viewer that's capable of reading the OBJ format advanced statements like Bezier curves or B-splines etc., so they will all safely omit them reading in our modded models. :)

The campath and camtarget mesh vertices will be read into their respective separate arrays of points to control the 3D Bezier loop for the camera to follow in real time at a given velocity. 8)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)