Jump to content

wrong sun direction calculation in core/scripts/time.h


photo

Recommended Posts

Posted

I finally found this problem, in normal situation, from top view of 3dsmax, we often assume this kind of direction

     N(Y)
      |
(-X)W<-->E(X)
      |
    S(-Y)

 

so this means in unigine, +Y is north, -Y is south, and +X is east, -X is west, in core/scripts/time.h it can calculate the sun direction from a time and latitude/longitude, I have tested my city with time.h and http://www.esrl.noaa.gov/gmd/grad/solcalc/ this calculator, their result of azimuth/altitude are exactly same. but after using the getSunDirection(), the sun always lit from wrong position.

 

here is a image of azimuth/altitude

azelzen.gif

from this picture, if azimut = altitude = 0 then the sun direction vector should be (0, 1, 0), then the equation of sun direction vector should be:

normalize(vec3(sin(azimuth) ,cos(azimuth), sin(altitude)))

 

if I use original code, the sun always rise from south and falls in north. and the sun at 13:00 will be from east.

 

combined with this post https://developer.unigine.com/forum/topic/239-serious-bug-in-softimage-export-plugin/ , I think it was caused by same problem.

 

If I'm all wrong about this. then I'm really confused about unigine's coordinate system.

Posted

I'm living in Nanjing/China so the constructor of Time should be

Unigine::Time(8.0f, 32.02f, 118.76f );

it's definitely right , you can get this value from http://www.esrl.noaa.gov/gmd/grad/solcalc/

 

or, you can test it use tomsik's location. 3dsmax's coordinate system is same with unigine's coordinate system.

×
×
  • Create New...