Author Topic: Individual Mesh Rotation  (Read 21084 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Individual Mesh Rotation
« Reply #45 on: June 11, 2018, 09:23:45 pm »
My dear friend, :)

Thank you very much for the balls. Before getting offended for your old rotation code !!! which was imperfect and spatially incorrect !!! try running the balls test in your code against complex rotations as in the test.mtl file from the attachment below. Your glRotate() primitives cannot produce such rotations in either one or three calls in a row.

Now recompile ObjReader with my mobj.h from the attached zip and enjoy ball rotation as is coded in test.mtl.

I'm going to study your #group mods tonight.

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: Individual Mesh Rotation
« Reply #46 on: June 11, 2018, 10:12:54 pm »
your code works great with test.obj and complex rotation.

Next step would be to have it working with the Helios2 group, but no rush there and take a good sleep first to save your neurones.
I am going to bed myself, because today i started to mown my lawn, and i have to get up early tomorrow to finish the second part of it.  :)
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Individual Mesh Rotation
« Reply #47 on: June 11, 2018, 11:10:52 pm »
Yes Patrice,

There's a Russian proverb that says it's better to eat too much than to sleep too little. ;D
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: Individual Mesh Rotation
« Reply #48 on: June 12, 2018, 07:31:51 pm »
No Patrice,

This isn't a correct test case for the mesh center calc algo that we're using. The mesh must be mirror symmetrical to have its center of rotation coincide with our bounding sphere's center. This is a side effect requirement resulting from the fact that there may be several bounding spheres with different radii depending on the original spatial orientation of a non-symmetrical object.

A pentagon isn't mirror symmetrical for our algo while a hexagon is, and a heptagon isn't while an octagon is.

Look into my comments inside the calcMeshBounds() code:

        // MLL 02-09-2018: meshRadius is in fact AABB's half-diagonal,
        // i.e. half-distance between AABB's rMax and rMin point vectors.
        // This isn't the tightest possible mesh bounding sphere though...

where AABB stands for axis-aligned bounding box.

In other words, abs(rMax) != abs(rMin) for a non-mirror symmetrical mesh. Our bounding sphere center is closer to the topmost bolt of the mesh pentagon than the mesh's center of rotational symmetry because the two bottom-most bolts aren't protruding exactly as far downwards as the topmost one is protruding upwards.

If you want to rotate the car wheels then make sure you use 6-bolt meshes to fix the wheels to the wheel spindles, or merge the bolt and wheel materials together. :)
« Last Edit: June 12, 2018, 07:39:26 pm by Michael Lobko-Lobanovsky »
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: Individual Mesh Rotation
« Reply #49 on: June 12, 2018, 07:37:20 pm »
Quote
If you want to rotate the car wheels then make sure you use 6-bolt meshes to fix the wheels to the wheel spindles, or merge the bolt and wheel materials together.
Ok, i just took them from an existing model…  8)
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Individual Mesh Rotation
« Reply #50 on: June 12, 2018, 07:45:58 pm »
Anyway, I can try to compensate such eccentricities when calculating the mesh and group centers of rotation, in fact, recalculate the rotCenter[] arrays more precisely rather than copying the centerPoint[] values to them.

Don't rework your models yet. We'll see if I can succeed. I'll be using this test model to verify my attempts. :)
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: Individual Mesh Rotation
« Reply #51 on: June 12, 2018, 08:34:27 pm »
I did find a solution for that specific one, however it couldn't be used for the rotating group of the Helios2.obj project.

The solution for the rim, is to mix the 5 bolts altogether with a hidden circle (see the screen shot)

And the most complex case would be to be able to rotate along the vertical axe to turn the front Wheel  ::)
« Last Edit: June 12, 2018, 08:58:20 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Individual Mesh Rotation
« Reply #52 on: June 12, 2018, 10:41:03 pm »
Patrice,

I asked you not to fiddle with the models, didn't I? ;)

Your solution is nice but kinda brute force.

The point we're looking for is in fact a centroid: c = [average(x), average(y), average(z)], whereby average() is the sum of respective vertex coordinates divided by the number of vertices in a mesh. Generally, the centroid of an asymmetrical 3D mesh doesn't coincide with the center of its AABB. But its calculus fits very nicely in our existing calcMeshBounds(). So, we can fill in each mesh's rotCenter[] array very easily regardless of whether it's going to actually rotate or not -- just in case, so to speak. :D

Your asymmetric bolts are now rotating very nicely together, and concentrically with, the car wheels in my ObjReader. 8)
« Last Edit: June 12, 2018, 10:48:01 pm by Michael Lobko-Lobanovsky »
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: Individual Mesh Rotation
« Reply #53 on: June 12, 2018, 11:02:56 pm »
Good work, thank you.

Have you been able to check it also with the Helios2.obj rotating group section ?
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Individual Mesh Rotation
« Reply #54 on: June 12, 2018, 11:16:08 pm »
I'm still polishing the #group syntax. :)

The rotation of Helios2 meshes is perfectly concentric. Some meshes are rotating faster than the others.
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: Individual Mesh Rotation
« Reply #55 on: June 13, 2018, 09:22:29 am »
Quote
Some meshes are rotating faster than the others.
I have checked the material file, they all use the same speed of 0.125.

Thus it must be related to the new rotation algo, i have attached the rot.obj model that is composed only from the Helios2 rotating group for test purpose.
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Individual Mesh Rotation
« Reply #56 on: June 13, 2018, 10:52:04 am »
And using the amazing c4d cogwheel spline vertex and manipulation tool.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Individual Mesh Rotation
« Reply #57 on: June 13, 2018, 12:23:46 pm »
rot.zip   gears.zip

Thanks a lot, the models are excellent! :)

Quote
I have checked the material file, they all use the same speed of 0.125.

So did I and yes they do.

Quote
Thus it must be related to the new rotation algo ...

Hardly. I think the glitch is related to either the #rotate parser or improper modelview matrix push/pop. I've also noticed another glitch: when I uncheck the visibility of some material (don't remember which one exactly ) in the listview control, rot_Storage_Colour_Light starts to spin twice slower than usual.

And using the amazing c4d cogwheel spline vertex and manipulation tool.

The gears are awesome! :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: Individual Mesh Rotation
« Reply #58 on: June 13, 2018, 01:14:55 pm »
Quote
I think the glitch is related to either the #rotate parser or improper modelview matrix push/pop.
I don't know if this could help or not, however the rot group alone was working with the older rotating code, it failed only when mixed with the other non-rotating meshes.

Combined rotating orientation, works only with spherical/cubic objects, and produces bad looking transformations for any other shapes.

In my StarGate64 project, i am using several embedded push/pop matrix to render correctly each of the monolith rotation, pulsating on the music tempo (each one rotating along its own axis).
« Last Edit: June 13, 2018, 02:51:10 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Individual Mesh Rotation
« Reply #59 on: June 13, 2018, 04:12:34 pm »
Quote
... works only with spherical/cubic objects, and produces bad looking transformations for any other shapes.

I am afraid this isn't so. Try and rotate your test.obj tires on two or three axes simultaneously -- there are no "bad looking transformations" in sight, and these meshes aren't spheroid or cuboid at all. Moreover, even your asymmetrical bolt meshes spin quite reliably around their centroids.

This kind of rotation was initiated by you, Patrice, not me. This is rotation around the mesh "center of mass", or centroid, and it is "axial" and more or less pleasing to the eye only when the mesh is generally orientated along one of the model's orthogonal axes.
_____________________________________

There is another kind of rotation -- around an arbitrarily inclined axis (-es), which requires a different type of matrix calc. But I think you still have a ton of meshes in the existing models that can be animated as-is to make them more attractive to the user. With time, when the #group syntax works and there are no more glitches, we could add axis rotation too, enriching our #rotate options accordingly.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)