#include /// Enumerates the available rendering methods. Parameter #iWhichMethod will have one of these values. typedef enum { IDEAL, IDEAL_LOCALIZED, DIFFUSE_SPECULAR, DIFFUSE_SPECULAR_LOCALIZED_COSTEX, DIFFUSE_SPECULAR_LOCALIZED } method_t; typedef enum { bShowHelp, bCubeMapFromFile, bAutoGenCubeMap, /*bUseCosTexture,*/ LAST_BOOL } bool_t; typedef enum { iWhichMethod, iWhichMetal, iShowCubeMap, sFresnel, refractionIndex, fIntensity, iShininess, LAST_NUMBER } number_t; /// These three buttons are present by default. typedef enum { IDC_RESET_BUTTON = -3, IDC_SAVE_BUTTON, IDC_LOAD_BUTTON } defaultbutton_t; /// Specifies the id domain reserved for each GUI control type. typedef enum { checkboxID0 = 1000, sliderID0 = 2000, staticID0 = 3000, upID0 = 4000, downID0 = 5000 } control_t; /// Pointer to a float/float function that transforms the given parameter value. Also see noconvert(). typedef float (*CONVERTER)(float a); /// Pointer to a void/void function describing an action that must be performed when the given parameter changes. Also see OnChange(). typedef void (*ONCHANGE_CALLBACK)(void); /// \brief Default transformation for the parameter values. The argument is returned unchanged, no conversion is performed. /// /// See #CONVERTER function pointer type. float noconvert(float a); // { return a; } /// \brief Default action for a parameter change. Does nothing. /// /// See #ONCHANGE_CALLBACK function pointer type. void OnChange(); // {} // \image html Parameters.png /** \brief Provides an easy way to manage application-specific parameters. You can easily add numeric/boolean parameters represented by GUI sliders and checkboxes/radio buttons. Then get the current values of these parameters when needed. All parameters can be saved to file or read from file in one step. The following rendering methods (#method_t) are defined here: - IDEAL : Ideal reflections/refractions with classic environment mapping. Uses technique EnvMapClassicPS() (or EnvMapClassicMetalPS() for metals). - IDEAL_LOCALIZED : Ideal reflections/refractions with depth impostors. Uses technique EnvMapImpostorPS() (or EnvMapImpostorMetalPS() for metals). - DIFFUSE_SPECULAR : Diffuse/glossy reflections with classic (preconvolved) diffuse/specular environment mapping. Uses technique EnvMapDiffusePS() for rendering and EnvMap::PreConvolve() for precalculation. - DIFFUSE_SPECULAR_LOCALIZED_COSTEX : Diffuse/glossy reflections with convolution on-the fly. To correctly represent the reflectivity of a texel, the reflectivity integral is precalculated. Uses technique EnvMapDiffuseLocalizedWithCosLookupPS() for rendering and EnvMap::GenerateCosTexture() for precalculation. Sorry for the long function names ;) - DIFFUSE_SPECULAR_LOCALIZED : Diffuse/glossy reflections with convolution on-the fly. The reflectivity integral is approximated with only one sample considering the center of the texel. This can cause problems when the object is close to that texel. Uses technique EnvMapDiffuseLocalizedPS(). \author Istvan Lazanyi, TU Budapest \date 2006-04-26 */ class Parameters { const static int CHARBUFFER_SIZE = 200; ///< The max length of a line in the saved file bool bparam[LAST_BOOL]; wchar_t bname[LAST_BOOL][CHARBUFFER_SIZE]; int radiogroup[LAST_BOOL]; int param[LAST_NUMBER]; // 0..100 (0..num_steps) wchar_t name[LAST_NUMBER][CHARBUFFER_SIZE]; int numsteps[LAST_NUMBER]; bool rotate[LAST_NUMBER]; CONVERTER ffunc[LAST_NUMBER]; ONCHANGE_CALLBACK chfunc[LAST_NUMBER+3]; ONCHANGE_CALLBACK bchfunc[LAST_BOOL]; CDXUTDialog* g_HUD; ///< Manages input and rendering for the GUI controls. bool bSilent; public: void Setup( CDXUTDialog* g_HUD ); void Setup( CDXUTDialog* g_HUD, ONCHANGE_CALLBACK OnReset, ONCHANGE_CALLBACK OnSave = OnChange, ONCHANGE_CALLBACK OnLoad = OnChange); bool Get( bool_t i ); float Get( number_t i ); int GetInt( number_t i ); void SetBool( bool_t ID, bool b ); void SetFloat( number_t ID, float v ); void SetInt( number_t ID, int v ); void Add( bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange ); void Add( int radiogroupID, bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange ); void Add( number_t ID, char* label, int num_steps); void Add( number_t ID, char* label, int num_steps, CONVERTER ff, ONCHANGE_CALLBACK chf = OnChange ); void Add( number_t ID, char* label, int num_steps, char cKeyDecr, char cKeyIncr = 0, CONVERTER ff = noconvert, ONCHANGE_CALLBACK chf = OnChange ); void SetEnabled( bool_t ID, bool bEnabled ); void SetEnabled( number_t ID, bool bEnabled ); void UpdateFromHUD( int controlID ); void SaveToFile( char* fileName ); void LoadFromFile( char* fileName ); };