source: GTP/trunk/App/Demos/Illum/EnvMap/Parameters.h @ 1672

Revision 1672, 3.7 KB checked in by szirmay, 18 years ago (diff)
RevLine 
[1488]1#include <assert.h>
2#define CHARBUF 250                             ///< length of the buffer (one line to be saved to file)
3
4/// Boolean variables that will be displayed as GUI checkboxes.
5typedef enum {  bShowHelp, /*bAutoGenCubeMap, bUseCosTexture, */
6                                bShowFireballs, bMultipleObjects, bConfineToRoom,
7                                LAST_BOOL } bool_t;
8
9/// Numeric variables that will be displayed as GUI sliders.
10typedef enum {  iWhichMethod, iWhichMesh, fMeshScale,
11                                iResolution, iShowCubeMap, fIntensity, iShininess,
12                                LAST_NUMBER } number_t;
13
14/// Possible values for #iWhichMethod.
15typedef enum {
[1672]16        DIFFUSE_SPECULAR_CLASSIC,                       ///< Classic environment mapping technique.
17        DIFFUSE_SPECULAR_LOCALIZED,                     ///< Our proposal.
[1534]18        DIFFUSE_SPECULAR_LOCALIZED_5TEX,        ///< Our proposal, using 5 texel only.
[1573]19        DIFFUSE_SPECULAR_LOCALIZED_NEW,         ///< Our proposal.     
[1672]20        DIFFUSE_SPECULAR_LOCALIZED_P2P,         ///< Point to point form factor
21        DIFFUSE_SPECULAR_LOCALIZED_ADAPT        ///< Point to point form factor
[1488]22} method_t;
23
24/// Parameter-manager buttons
25typedef enum {
26        IDC_RESET_BUTTON = -3,
27        IDC_SAVE_BUTTON,
28        IDC_LOAD_BUTTON
29} std_buttons_t;
30
31/// Conversion function (see Parameters::Add()).
32/// E.g. to create a slider that produces exponential values.
33typedef float (*CONVERTER)(float a);
34/// Change callback function (see Parameters::Add()).
35/// To be called when the respective parameter is modified.
36typedef void (*ONCHANGE_CALLBACK)(void);
37
38/// Default conversion function (see #CONVERTER).
39/// Does nothing but returning the value passed.
40float noconvert(float a);       // { return a; }
41/// Default change callback function (see #ONCHANGE_CALLBACK).
42/// Does nothing.
43void OnChange();                        // {}
44
45/**
46  \brief Manages application parameters.
47  \brief Creates GUI controls (sliders, checkboxes) and hotkeys.
48 
49  \author Istvan Lazanyi, TU Budapest
50  \date   2006-04-26
51*/
52class Parameters {
53        bool bparam[LAST_BOOL];                         ///< current param value (boolean)
54        wchar_t bname[LAST_BOOL][CHARBUF];      ///< param name
55        int radiogroup[LAST_BOOL];                      ///< for boolean params that are represented by a checkbox
56
57        int param[LAST_NUMBER];                         ///< current param value (numeric)
58        wchar_t name[LAST_NUMBER][CHARBUF];     ///< param name
59        int numsteps[LAST_NUMBER];                      ///< number of possible steps for param
60        bool rotate[LAST_NUMBER];                       ///< stores whether the slider can rotate around
61
62        CONVERTER ffunc[LAST_NUMBER];
63        ONCHANGE_CALLBACK chfunc[LAST_NUMBER+3];
64        ONCHANGE_CALLBACK bchfunc[LAST_BOOL];
65
66        CDXUTDialog* g_HUD;
67
68        bool bSilent;                                           ///< to avoid an endless loop due to a change
69        const static int CHARBUFFER_SIZE = 200;
70        enum { checkboxID0 = 1000, sliderID0 = 2000, staticID0 = 3000, upID0 = 4000, downID0 = 5000 };
71
72public:
73        void Setup( CDXUTDialog* g_HUD );
74        void Setup( CDXUTDialog* g_HUD, ONCHANGE_CALLBACK OnReset, ONCHANGE_CALLBACK OnSave = OnChange, ONCHANGE_CALLBACK OnLoad = OnChange);
75
76        bool Get( bool_t i );
77        float Get( number_t i );
78        int GetInt( number_t i );
79
80        void SetBool( bool_t ID, bool b );
81        void SetFloat( number_t ID, float v );
82        void SetInt( number_t ID, int v );
83
84        void Add( bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange );
85        void Add( int radiogroupID, bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange );
86
87        void Add( number_t ID, char* label, int num_steps);
88
89        void Add( number_t ID, char* label, int num_steps,
90                CONVERTER ff, ONCHANGE_CALLBACK chf = OnChange );
91
92        void Add( number_t ID, char* label, int num_steps, char cKeyDecr, char cKeyIncr = 0,
93                CONVERTER ff = noconvert, ONCHANGE_CALLBACK chf = OnChange );
94
95        void SetEnabled( bool_t ID, bool bEnabled );
96        void SetEnabled( number_t ID, bool bEnabled );
97
98        void UpdateFromHUD( int controlID );
99
100        void SaveToFile( char* fileName );
101        void LoadFromFile( char* fileName );
102};
Note: See TracBrowser for help on using the repository browser.