Day night cycle: Difference between revisions

From wowdev
Jump to navigation Jump to search
No edit summary
Line 54: Line 54:
=== DayNight::DarkenColor ===
=== DayNight::DarkenColor ===


Adjusts a given RGB value's brightness by a given floating point multiplier. Converts RGB to HSV, applies the multipler to the V component, converts the adjusted HSV value back to RGB, and returns it.
Adjusts a given RGB value's brightness by a given floating point multiplier. Converts RGB to HSV, applies the multiplier to the V component, converts the adjusted HSV value back to RGB, and returns it.


Called from the various SetColors functions within DayNight.
Called from the various SetColors functions within DayNight.

Revision as of 03:34, 17 September 2016

Summary

WIP

CGameTime

CGameTime contains the logic and values necessary to determine things like: time of day progression, adjustments necessary to transform local time in to server time, etc.

CGameTime::GameTimeGetDayProgression

The GameTimeGetDayProgression function in CGameTime is frequently used in the various DayNight calculations. This function calculates the minutes since midnight in server time, and divides by the total number of minutes in a day.

The return value is a floating point that ranges from 0.0 to 1.0, measuring the distance the current server time is from midnight. 0.0 represents the time just after midnight, 0.5 represents midday, and 1.0 represents the time just before midnight.

DayNight

DayNight::InterpTable

Given a table and an interpolation factor, this function returns a value linearly interpolated out of the table. The function is commonly called in various DayNight value / color update functions.

Return values are always floating points.

Tables

Tables that are fed into DayNight::InterpTable include:

  • DayNight::s_sidnTable
  • DayNight::DNSky::s_darkTable
  • DayNight::DNSky::s_fadeTable
  • DayNight::DNStars::s_fadeTable
  • DayNight::DNClouds::s_bumpFadeTable
  • DayNight::CDayNightObjectInt::SetDirection(void)::phiTable
  • DayNight::CDayNightObjectInt::SetDirection(void)::thetaTable

Tables are structured:

struct {
  float distance_along_interpolation;
  float value_at_distance;
};

For example,

DayNight::DNStars::s_fadeTable = { {0.1250, 1.0}
                                 , {0.1875, 0.0}
                                 , {0.9375, 0.0}
                                 , {1.0000, 1.0}
                                 }

Logic

WIP

DayNight::DarkenColor

Adjusts a given RGB value's brightness by a given floating point multiplier. Converts RGB to HSV, applies the multiplier to the V component, converts the adjusted HSV value back to RGB, and returns it.

Called from the various SetColors functions within DayNight.