On 10/25/20 12:27 PM, Bart wrote:
> On 25/10/2020 16:11, Rick C. Hodgin wrote:
>> On 10/25/20 12:38 AM, Chris M. Thomasson wrote:
>>> Why not try to move the calculations to the GPU?
>>
>> Because I don't know how to do that. :-) I've reported on things like
>> OpenCL before, but I've never programmed with any of those GPU libraries.
>>
>> It would lend itself well to parallel processing as I have hundreds of
>> vertices that all need to have the same operations performed. I need
>> to use atan2() to get the angle theta, and another atan2() to get rho,
>> and then rotate them, recompute sin() and cos() on both to reposition
>> for rotation and axial tilt.
>>
>> That's the bulk of the transformations.
>
> If rotating by the same angle lots of times, presumably you set up a
> transformation matrix first? If not, you presumably don't recalculate
> sin/cos with the same angle?
Each planet rotates by its rotational rate in the simulation. If you
look near the top of the earth_solar_system.cpp file in the main()
function you'll see where the multiple iBuildSphere() functions are
called. They have rotation rate.
Each vertex is rotated by that amount. You can search for the
iRotateZ() and iRotateY() functions to find them. This performs
arbitrary rotation on the Z or Y axes.
> A transformation matrix can combine several operations (multiple
> rotations, shearing, moving) into one matrix. OpenGL I think has
> facilies to apply such a matrix.
I've never understood how those kinds of matrices work. I've tried
reading through some tutorials a handful of times over my life, but it's
always been confusing to me. It would be better to see the example, and
then see the assembly instructions it would generate on a CPU, while I
also recognize that in a GPU it performs them as a single operation.
I understand quite well trigonometry and the unit circle (and unit
sphere). So, I've been able to operate within those boundaries just
fine to date, but it is slower. And, as I say, on our gaming laptop
with a high-end Nvidia graphics card, I am able to get a 29 second
cycle, which is actually too fast. We had to slow it down a little for
the videos.
I'll put a fps setting on there, but just don't have it yet. I'm also
not working on that repository for my active development. That's just a
snapshot taken at a given time for public consumption.
The work I'm doing now is in creating a triangle map of the land area of
the Earth, and then flattening it out so rather than being curved around
the sphere / globe, it's as though you took something like a shape in
the shape of Australia and then laid it on a flat surface. It changes
its geometry a little. Then, I'm taking it and placing it somewhere
arbitrarily on the surface of the sphere and having it wrap back around
the curve of the sphere's surface. By doing this, I'm able to move
continents about to other places on the globe.
Baby steps.
--
Rick C. Hodgin