-- Initialization Function g_rotatesundirection = {} function rotatesundirection_init(e) g_rotatesundirection[e] = {} g_rotatesundirection[e]['x'] = math.random() g_rotatesundirection[e]['y'] = math.random() g_rotatesundirection[e]['z'] = math.random() g_rotatesundirection[e]['obj'] = g_Entity[e].obj end -- Main Function function rotatesundirection_main(e) g_rotatesundirection[e]['x'] = g_rotatesundirection[e]['x'] + (0.030*GetTimeElapsed()) g_rotatesundirection[e]['y'] = g_rotatesundirection[e]['y'] + (0.045*GetTimeElapsed()) -- sun y moves a little faster. g_rotatesundirection[e]['z'] = g_rotatesundirection[e]['z'] + (0.030*GetTimeElapsed()) if g_rotatesundirection[e]['x'] > 360.0 then g_rotatesundirection[e]['x'] = g_rotatesundirection[e]['x'] - 360.0 end if g_rotatesundirection[e]['y'] > 360.0 then g_rotatesundirection[e]['y'] = g_rotatesundirection[e]['y'] - 360.0 end if g_rotatesundirection[e]['z'] > 360.0 then g_rotatesundirection[e]['z'] = g_rotatesundirection[e]['z'] - 360.0 end local xdir = math.sin(g_rotatesundirection[e]['x']) local ydir = math.cos(g_rotatesundirection[e]['y']) + 0.75 -- move sun closer to horizont local zdir = math.cos(g_rotatesundirection[e]['z']) SetSunDirection(xdir,ydir,zdir) xdir = (xdir * 6000.0) + GetCameraPositionX(0) ydir = (ydir * 3000.0) + GetCameraPositionY(0) - 400 zdir = (zdir * 6000.0) + GetCameraPositionZ(0) PositionObject(g_rotatesundirection[e]['obj'] , xdir , ydir, zdir ) RotateToCamera(e) end -- Exit Function function rotatesundirection_exit(e) SetSunDirection(5,10,5) end