source: GTP/trunk/App/Demos/Illum/Envmap/Parameters.h @ 843

Revision 843, 4.9 KB checked in by szirmay, 19 years ago (diff)
Line 
1
2#include <assert.h>
3
4/// Enumerates the available rendering methods. Parameter #iWhichMethod will have one of these values.
5typedef enum {  IDEAL,                         
6                                IDEAL_LOCALIZED,
7                                DIFFUSE_SPECULAR,
8                                DIFFUSE_SPECULAR_LOCALIZED_COSTEX,
9                                DIFFUSE_SPECULAR_LOCALIZED
10                         } method_t;
11
12typedef enum { bShowHelp, bCubeMapFromFile, bAutoGenCubeMap, /*bUseCosTexture,*/ LAST_BOOL } bool_t;
13
14typedef enum { iWhichMethod, iWhichMetal, iShowCubeMap, sFresnel, refractionIndex, fIntensity, iShininess, LAST_NUMBER } number_t;
15
16/// These three buttons are present by default.
17typedef enum { IDC_RESET_BUTTON = -3, IDC_SAVE_BUTTON, IDC_LOAD_BUTTON } defaultbutton_t;
18/// Specifies the id domain reserved for each GUI control type.
19typedef enum { checkboxID0 = 1000, sliderID0 = 2000, staticID0 = 3000, upID0 = 4000, downID0 = 5000 } control_t;
20
21/// Pointer to a float/float function that transforms the given parameter value. Also see noconvert().
22typedef float (*CONVERTER)(float a);   
23/// Pointer to a void/void function describing an action that must be performed when the given parameter changes. Also see OnChange().
24typedef void (*ONCHANGE_CALLBACK)(void);
25
26/// \brief Default transformation for the parameter values. The argument is returned unchanged, no conversion is performed.
27///
28/// See #CONVERTER function pointer type.
29float noconvert(float a);       // { return a; }
30/// \brief Default action for a parameter change. Does nothing.
31///
32/// See #ONCHANGE_CALLBACK function pointer type.
33void OnChange();                        // {}
34
35// \image html Parameters.png
36
37/**
38  \brief Provides an easy way to manage application-specific parameters.
39
40  You can easily add numeric/boolean parameters represented by GUI sliders and checkboxes/radio buttons.
41  Then get the current values of these parameters when needed. All parameters can be saved to file or read from file in one step.
42
43  The following <b>rendering methods</b> (#method_t) are defined here:
44 
45  - IDEAL : Ideal reflections/refractions with classic environment mapping.
46 
47  Uses technique EnvMapClassicPS() (or EnvMapClassicMetalPS() for metals).
48
49  - IDEAL_LOCALIZED : Ideal reflections/refractions with depth impostors.
50 
51  Uses technique EnvMapImpostorPS() (or EnvMapImpostorMetalPS() for metals).
52
53  - DIFFUSE_SPECULAR : Diffuse/glossy reflections with classic (preconvolved) diffuse/specular environment mapping.
54
55  Uses technique EnvMapDiffusePS() for rendering and EnvMap::PreConvolve() for precalculation.
56
57  - DIFFUSE_SPECULAR_LOCALIZED_COSTEX : Diffuse/glossy reflections with convolution on-the fly.
58  To correctly represent the reflectivity of a texel, the reflectivity integral is precalculated.
59
60  Uses technique EnvMapDiffuseLocalizedWithCosLookupPS() for rendering and EnvMap::GenerateCosTexture() for precalculation.
61
62  Sorry for the long function names ;)
63
64  - DIFFUSE_SPECULAR_LOCALIZED : Diffuse/glossy reflections with convolution on-the fly.
65  The reflectivity integral is approximated with only one sample considering the center of the texel.
66  This can cause problems when the object is close to that texel.
67
68  Uses technique EnvMapDiffuseLocalizedPS().
69
70  \author Istvan Lazanyi, TU Budapest
71  \date   2006-04-26
72*/
73
74class Parameters
75{
76        const static int CHARBUFFER_SIZE = 200; ///< The max length of a line in the saved file
77
78        bool bparam[LAST_BOOL];
79        wchar_t bname[LAST_BOOL][CHARBUFFER_SIZE];
80        int radiogroup[LAST_BOOL];
81
82        int param[LAST_NUMBER]; // 0..100 (0..num_steps)
83        wchar_t name[LAST_NUMBER][CHARBUFFER_SIZE];
84        int numsteps[LAST_NUMBER];
85        bool rotate[LAST_NUMBER];
86
87        CONVERTER ffunc[LAST_NUMBER];
88        ONCHANGE_CALLBACK chfunc[LAST_NUMBER+3];
89
90        ONCHANGE_CALLBACK bchfunc[LAST_BOOL];
91
92        CDXUTDialog* g_HUD;                                             ///< Manages input and rendering for the GUI controls.
93
94        bool bSilent;
95       
96public:
97        void Setup( CDXUTDialog* g_HUD );
98        void Setup( CDXUTDialog* g_HUD, ONCHANGE_CALLBACK OnReset, ONCHANGE_CALLBACK OnSave = OnChange, ONCHANGE_CALLBACK OnLoad = OnChange);
99
100        bool Get( bool_t i );
101        float Get( number_t i );
102        int GetInt( number_t i );
103
104        void SetBool( bool_t ID, bool b );
105        void SetFloat( number_t ID, float v );
106        void SetInt( number_t ID, int v );
107
108        void Add( bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange );
109        void Add( int radiogroupID, bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange );
110
111        void Add( number_t ID, char* label, int num_steps);
112
113        void Add( number_t ID, char* label, int num_steps,
114                CONVERTER ff, ONCHANGE_CALLBACK chf = OnChange );
115
116        void Add( number_t ID, char* label, int num_steps, char cKeyDecr, char cKeyIncr = 0,
117                CONVERTER ff = noconvert, ONCHANGE_CALLBACK chf = OnChange );
118
119        void SetEnabled( bool_t ID, bool bEnabled );
120        void SetEnabled( number_t ID, bool bEnabled );
121
122        void UpdateFromHUD( int controlID );
123
124        void SaveToFile( char* fileName );
125        void LoadFromFile( char* fileName );
126};
Note: See TracBrowser for help on using the repository browser.