DI-Guy SDK Documentation  13.7
diguyViewFog.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2022 MAK Technologies, Inc.
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************/
13 #ifndef __diguyViewFog_H
14 #define __diguyViewFog_H
15 
16 #ifdef SWIG
17 %module diguyViewFog
18 #else
19 #define CPLUSPLUS_ONLY
20 #endif
21 
22 #ifdef CPLUSPLUS_ONLY
23 class bdiFog;
24 class diguyViewFog;
26 
27 #include <stdio.h> // for NULL definition
28 #include <diguy_constants.h>
29 #include <diguy_typedefs.h>
30 
31 #endif
32 
33 
34 #include <declspec_diguy.h>
35 
44 class BDI_DECLSPEC_diguy diguyViewFog
45 {
46 
47 public:
48 
49 /*****************************************************************************/
59  /*l
60  *b Description:
61  **
62  ** Returns the name of the object. This pointer will
63  ** never be NULL.
64  **
65  *b Returns:
66  **
67  ** name of the object
68  */
69  const char* get_name();
70 
71  /*l
72  *b Description:
73  **
74  ** Returns the type name of the object. This pointer will
75  ** never be NULL.
76  **
77  *b Returns:
78  **
79  ** type name of the object
80  */
81  const char* get_type_name();
82 
83  /*l
84  *b Description:
85  **
86  ** This sets the density of the fog.
87  **
88  *b Arguments:
89  **
90  *a density - distance of this fog; higher causes more opaque fog
91  */
92  void set_density(float density);
93 
94  /*l
95  *b Returns:
96  **
97  ** density of fog
98  */
99  float get_density() const;
100 
101  /*l
102  *b Description:
103  **
104  ** This sets the distance at which fog begins to affect the scene.
105  ** Colors of objects before this distance will not be affected.
106  ** Colors of objects after this distance will start to be modulated
107  ** toward to fog color.
108  **
109  *b Arguments:
110  **
111  *a start - distance to where fog starts, in meters
112  */
113  void set_start(float start);
114 
115  /*l
116  *b Returns:
117  **
118  ** distance to where fog starts, in meters; see set_start()
119  */
120  float get_start() const;
121 
122  /*l
123  *b Description:
124  **
125  ** This sets the distance at which the fog completely overrides
126  ** the colors of objects in the scene.
127  **
128  *b Arguments:
129  **
130  *a end - distance to where fog ends, in meters
131  */
132  void set_end(float end);
133 
134  /*l
135  *b Returns:
136  **
137  ** distance to where fog ends, in meters; see set_end()
138  */
139  float get_end() const;
140 
141  /*l
142  *b Description:
143  **
144  ** This function sets the color of this fog.
145  **
146  *b Arguments:
147  **
148  *a r, g, b, a - red, green, blue, and alpha components
149  */
150  void set_color(float r, float g, float b, float a);
151 
152  /*l
153  *b Description:
154  **
155  ** This function gets the color of this fog.
156  ** Values are returned via the passed pointers.
157  **
158  *b Arguments:
159  **
160  *a r, g, b, a - red, green, blue, and alpha components
161  */
162  void get_color(float* r, float* g, float* b, float* a) const;
163 
164  /*l
165  *b Description:
166  **
167  ** This function sets the fog mode.
168  **
169  *b Arguments:
170  **
171  *a mode - new mode for fog calculations
172  **
173  *a DIGUY_FOG_MODE_DISABLED - fog is completely turned off
174  *a DIGUY_FOG_MODE_EXP - per-vertex exponential
175  *a DIGUY_FOG_MODE_EXP2 - per-vertex exponential style 2
176  *a DIGUY_FOG_MODE_LINEAR - per-vertex linear
177  **
178  *b Returns:
179  **
180  ** 0 on success, -1 on failure
181  */
182  void set_fog_mode(int mode);
183 
184  /*l
185  *b Returns:
186  **
187  ** the most recent setting made by set_fog_mode()
188  */
189  int get_fog_mode() const;
190 
192  void apply();
193 
194 /*****************************************************************************/
204  /*l
205  *b Description:
206  **
207  ** Loads the specified settings into this fog.
208  **
209  *b Returns:
210  **
211  ** 0 on success, -1 on failure
212  */
213  int load_settings(const char* settings_name);
214 
215  /*l
216  *b Description:
217  **
218  ** Loads the specified settings into this fog.
219  **
220  *b Returns:
221  **
222  ** 0 on success, -1 on failure
223  */
224  int load_settings(diguyViewFogSettings* settings);
225 
226 
227 
228 /*****************************************************************************/
234  /*l
235  *b Description:
236  **
237  ** This is an enumeration of the different callbacks
238  ** that can be registered with add_callback() and
239  ** add_callback_script().
240  **
241  *b Usable From:
242  **
243  *- - C++
244  *- - Script
245  */
246  enum {
247  CALLBACK_ID_SETTINGS_CHANGED = 1
248  };
249 
250 #ifdef CPLUSPLUS_ONLY
251 
252  /*l
253  *b Description:
254  **
255  ** This function adds a user callback.
256  **
257  *b Arguments:
258  **
259  *a callback - pointer to function with prototype
260  *a diguyViewFogCallback (typedefed above)
261  *a callback_id - integer id of when this callback is to be called
262  *a callback_params - struct containing additional parameters
263  *a needed by some callbacks; actual type depends
264  *a on callback_id
265  *a callback_user_data - pointer for user's own use; DI-Guy will
266  *a do nothing to the contents of this pointer
267  *a beyond passing it back when the callback is
268  *a invoked
269  **
270  ** callback_id should be one of the following values:
271  **
272  *i CALLBACK_ID_SETTINGS_CHANGED
273  **
274  ** This callback will be called if the current settings of
275  ** this fog change
276  **
277  ** Callbacks return a value of type diguyCallbackReturn,
278  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
279  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
280  ** of the function will not be called; the callback is asserting
281  ** that it has done everything necessary for the function call.
282  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
283  ** handler for the function will be called after the callback.
284  **
285  *b Returns:
286  **
287  ** 0 on success, -1 on failure
288  **
289  *b Callable From:
290  **
291  *- - C++
292  */
293  int add_callback(int callback_id,
294  diguyViewFogCallback* callback,
295  void* callback_params = 0,
296  void* callback_user_data = 0);
297 
298  /*l
299  *b Description:
300  **
301  ** This function removes a user callback. All callbacks matching
302  ** the specified callback_id and callback function will be removed.
303  **
304  *b Arguments:
305  **
306  *a callback_id - integer id of when this callback is to be called
307  *a callback - pointer to function with prototype
308  *a diguyViewFogCallback (typedefed above)
309  **
310  *b Returns:
311  **
312  ** 0 on success, -1 on failure
313  **
314  *b Callable From:
315  **
316  *- - C++
317  */
318  int remove_callback(int callback_id,
319  diguyViewFogCallback* callback);
320 
321  /*l
322  *b Description:
323  **
324  ** This function removes a user callback. All callbacks matching
325  ** the specified callback_id and callback_user_data pointer will
326  ** be removed.
327  **
328  *b Arguments:
329  **
330  *a callback_id - integer id of when this callback is to be called
331  *a callback_user_data - pointer for user's own use
332  **
333  *b Returns:
334  **
335  ** 0 on success, -1 on failure
336  **
337  *b Callable From:
338  **
339  *- - C++
340  */
341  int remove_callback_with_user_data(int callback_id,
342  void* callback_user_data);
343 
344 #endif
345 
346  /*l
347  *b Description:
348  **
349  ** This function adds a user callback script. Callback scripts can
350  ** be removed with remove_callback_script().
351  **
352  *b Arguments:
353  **
354  *a callback_id - integer id of the callback
355  *a callback_script - script text of callback to be added
356  *a callback_script_type - the type of script contained in
357  *a callback_script
358  **
359  ** If NULL is passed for callback_script_type, a default script type
360  ** will be derived based on the default script interpreter of the
361  ** scenario.
362  **
363  *i lua specific:
364  **
365  ** When the script is called, the object for which it is being called
366  ** will be in the callback_object global.
367  **
368  ** To pass NULL when calling from a lua script, use nil.
369  **
370  *b Returns:
371  **
372  ** 0 on success, -1 on failure
373  **
374  *b Callable From:
375  **
376  *- - C++
377  *- - Script
378  */
379  int add_callback_script(int callback_id,
380  const char* callback_script,
381  const char* callback_script_type = NULL);
382 
383  /*l
384  *b Description:
385  **
386  ** This function removes a user callback script previously added with
387  ** add_callback_script().
388  **
389  *b Arguments:
390  **
391  *a callback_id - integer id of the callback
392  *a callback_script - script text of callback previously added
393  *a callback_script_type - the type of script contained in
394  *a callback_script
395  **
396  ** If NULL is passed for callback_script, all callback
397  ** scripts whose ids match callback_id and whose types match
398  ** callback_script_type will be removed.
399  **
400  ** If NULL is passed for callback_script_type, a default script type
401  ** will be derived based on the default script interpreter of the
402  ** scenario.
403  **
404  *i lua specific:
405  **
406  ** To pass NULL when calling from a lua script, use nil.
407  **
408  *b Returns:
409  **
410  ** 0 on success, -1 on failure
411  **
412  *b Callable From:
413  **
414  *- - C++
415  *- - Script
416  */
417  int remove_callback_script(int callback_id,
418  const char* callback_script,
419  const char* callback_script_type = NULL);
420 
425 #ifdef CPLUSPLUS_ONLY
426 
427  bdiFog* get_scripted_object() {return m_fog;}
428 
429 private:
430 
431  /*l
432  ** A private constructor.
433  */
434  diguyViewFog(bdiFog* fog);
435 
436  /*l
437  ** A pointer to internal data.
438  */
439  bdiFog* m_fog;
440 
441  friend class bdiFog;
442 
443 #endif
444 
445 };
446 
447 #endif /* __diguyViewFog_H */
448 
diguyCallbackReturn diguyViewFogCallback(diguyViewFog *fog, int callback_id, void *callback_params, void *callback_user_data)
Definition: diguy_typedefs.h:217
The diguyViewFogSettings class holds camera settings data that can be loaded into a diguyViewFog usin...
Definition: diguyViewFogSettings.h:43
Describes basic fog model that is used by DI-Guy Scenario and our default ogl renderer Most users wil...
Definition: diguyViewFog.h:42