DI-Guy SDK Documentation  13.2
diguyViewLight.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2019 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************/
13 #ifndef __diguyViewLight_H
14 #define __diguyViewLight_H
15 
16 #ifdef SWIG
17 %module diguyViewLight
18 #else
19 #define CPLUSPLUS_ONLY
20 #endif
21 
22 #ifdef CPLUSPLUS_ONLY
23 class bdiLight;
24 class diguyViewLight;
26 
27 #include <stdio.h> // for NULL definition
28 #include <diguy_constants.h>
29 #include <diguy_typedefs.h>
30 
31 #endif
32 #include <declspec_diguy.h>
33 
34 /****************************************************************************/
37 struct BDI_DECLSPEC_diguy diguyLightRenderDesc
38 {
39  diguyLightRenderDesc() : m_radius(1.0f), m_spot_angle(0.0f), m_spot_exponent(1.0f), m_falloff_r(.1f), m_falloff_rsq(.1f)
40  {
41  }
42  double m_position[4];
43  float m_radius;
44  float m_direction[4];
45  float m_diffuse[3];
46  float m_ambient[3];
47  float m_specular[3];
48  float m_falloff_r;
49  float m_falloff_rsq;
50  float m_spot_angle;
51  float m_spot_exponent;
52 
53 };
54 
55 
56 /****************************************************************************/
57 class BDI_DECLSPEC_diguy diguyViewLight
58 {
59 
60 public:
61 
62 /*****************************************************************************/
72  /*l
73  *b Description:
74  **
75  ** Returns the name of the object. This pointer will
76  ** never be NULL.
77  **
78  *b Returns:
79  **
80  ** name of the object
81  */
82  const char* get_name();
83 
84  /*l
85  *b Description:
86  **
87  ** Returns the type name of the object. This pointer will
88  ** never be NULL.
89  **
90  *b Returns:
91  **
92  ** type name of the object
93  */
94  const char* get_type_name();
95 
96  /*l
97  *b Description:
98  **
99  ** This function sets the direction of this light.
100  **
101  *b Arguments:
102  **
103  *a x,y,z - x,y,z direction, in meters
104  */
105  void set_direction(float x, float y, float z);
106 
107  /*l
108  *b Description:
109  **
110  ** This function gets the direction of this light.
111  ** Values are returned via the passed pointers.
112  **
113  *b Arguments:
114  **
115  *a x,y,z - x,y,z direction, in meters
116  */
117  void get_direction(float* x, float* y, float* z);
118 
119  /*l
120  *b Description:
121  **
122  ** This function sets the position of this light.
123  **
124  *b Arguments:
125  **
126  *a x,y,z - x,y,z position, in meters
127  */
128  void set_position(float x, float y, float z);
129 
130  /*l
131  *b Description:
132  **
133  ** This function gets the position of this light.
134  ** Values are returned via the passed pointers.
135  **
136  *b Arguments:
137  **
138  *a x,y,z - x,y,z position, in meters
139  */
140  void get_position(float* x, float* y, float* z);
141 
142  /*l
143  *b Description:
144  **
145  ** This function sets the ambient color.
146  **
147  *b Arguments:
148  **
149  *a r,g,b,a - red, green, blue, alpha components
150  */
151  void set_ambient_color(float r, float g, float b, float a);
152 
153  /*l
154  *b Description:
155  **
156  ** This function gets the ambient color of this light.
157  ** Values are returned via the passed pointers.
158  **
159  *b Arguments:
160  **
161  *a r,g,b,a - red, green, blue, alpha components
162  */
163  void get_ambient_color(float* r, float* g, float* b, float* a);
164 
165  /*l
166  *b Description:
167  **
168  ** This function sets the diffuse color.
169  **
170  *b Arguments:
171  **
172  *a r,g,b,a - red, green, blue, alpha components
173  */
174  void set_diffuse_color(float r, float g, float b, float a);
175 
176  /*l
177  *b Description:
178  **
179  ** This function gets the diffuse color of this light.
180  ** Values are returned via the passed pointers.
181  **
182  *b Arguments:
183  **
184  *a r,g,b,a - red, green, blue, alpha components
185  */
186  void get_diffuse_color(float* r, float* g, float* b, float* a);
187 
188  /*l
189  *b Description:
190  **
191  ** This function sets the specular color.
192  **
193  *b Arguments:
194  **
195  *a r,g,b,a - red, green, blue, alpha components
196  */
197  void set_specular_color(float r, float g, float b, float a);
198 
199  /*l
200  *b Description:
201  **
202  ** This function gets the specular color of this light.
203  ** Values are returned via the passed pointers.
204  **
205  *b Arguments:
206  **
207  *a r,g,b,a - red, green, blue, alpha components
208  */
209  void get_specular_color(float* r, float* g, float* b, float* a);
210 
212  int get_casts_shadows();
213 
215  int set_scene_objects_cast_shadows(int value);
216  int get_scene_objects_cast_shadows();
217 
220  int set_brightness_multiplier(float multiplier);
221  float get_brightness_multiplier();
222 
224  void set_spot_exponent(float exponent);
225  float get_spot_exponent();
226 
228  void set_falloff_const(float falloff_const);
229  float get_falloff_const();
230 
232  void set_falloff_rsq(float falloff_rsq);
233  float get_falloff_rsq();
234 
235 
236 /*****************************************************************************/
246  /*l
247  *b Description:
248  **
249  ** Loads the specified settings into this light.
250  **
251  *b Returns:
252  **
253  ** 0 on success, -1 on failure
254  */
255  int load_settings(const char* settings_name);
256 
257  /*l
258  *b Description:
259  **
260  ** Loads the specified settings into this light.
261  **
262  *b Returns:
263  **
264  ** 0 on success, -1 on failure
265  */
266  int load_settings(diguyViewLightSettings* settings);
267 
268  /*l
269  *b Description:
270  **
271  ** Applies the light to OpenGL state. Currently DI-Guy only supports
272  ** one light in it's default OpenGL implementation.
273  **
274  ** At least one light must be applied for advanced DI-Guy reference
275  ** shaders to work.
276  */
277  void apply(int i = 0);
278 
279 
280 /*****************************************************************************/
286  /*l
287  *b Description:
288  **
289  ** This is an enumeration of the different callbacks
290  ** that can be registered with add_callback() and
291  ** add_callback_script().
292  **
293  *b Usable From:
294  **
295  *- - C++
296  *- - Script
297  */
298  enum {
299  CALLBACK_ID_SETTINGS_CHANGED = 1
300  };
301 
302 #ifdef CPLUSPLUS_ONLY
303 
304  /*l
305  *b Description:
306  **
307  ** This function adds a user callback.
308  **
309  *b Arguments:
310  **
311  *a callback - pointer to function with prototype
312  *a diguyViewLightCallback (typedefed above)
313  *a callback_id - integer id of when this callback is to be called
314  *a callback_params - struct containing additional parameters
315  *a needed by some callbacks; actual type depends
316  *a on callback_id
317  *a callback_user_data - pointer for user's own use; DI-Guy will
318  *a do nothing to the contents of this pointer
319  *a beyond passing it back when the callback is
320  *a invoked
321  **
322  ** callback_id should be one of the following values:
323  **
324  *i CALLBACK_ID_SETTINGS_CHANGED
325  **
326  ** This callback will be called if the current settings of this
327  ** light change
328  **
329  ** Callbacks return a value of type diguyCallbackReturn,
330  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
331  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
332  ** of the function will not be called; the callback is asserting
333  ** that it has done everything necessary for the function call.
334  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
335  ** handler for the function will be called after the callback.
336  **
337  *b Returns:
338  **
339  ** 0 on success, -1 on failure
340  **
341  *b Callable From:
342  **
343  *- - C++
344  */
345  int add_callback(int callback_id,
346  diguyViewLightCallback* callback,
347  void* callback_params = 0,
348  void* callback_user_data = 0);
349 
350  /*l
351  *b Description:
352  **
353  ** This function removes a user callback. All callbacks matching
354  ** the specified callback_id and callback function will be removed.
355  **
356  *b Arguments:
357  **
358  *a callback_id - integer id of when this callback is to be called
359  *a callback - pointer to function with prototype
360  *a diguyViewLightCallback (typedefed above)
361  **
362  *b Returns:
363  **
364  ** 0 on success, -1 on failure
365  **
366  *b Callable From:
367  **
368  *- - C++
369  */
370  int remove_callback(int callback_id,
371  diguyViewLightCallback* callback);
372 
373  /*l
374  *b Description:
375  **
376  ** This function removes a user callback. All callbacks matching
377  ** the specified callback_id and callback_user_data pointer will
378  ** be removed.
379  **
380  *b Arguments:
381  **
382  *a callback_id - integer id of when this callback is to be called
383  *a callback_user_data - pointer for user's own use
384  **
385  *b Returns:
386  **
387  ** 0 on success, -1 on failure
388  **
389  *b Callable From:
390  **
391  *- - C++
392  */
393  int remove_callback_with_user_data(int callback_id,
394  void* callback_user_data);
395 
396 #endif
397 
398  /*l
399  *b Description:
400  **
401  ** This function adds a user callback script. Callback scripts can
402  ** be removed with remove_callback_script().
403  **
404  *b Arguments:
405  **
406  *a callback_id - integer id of the callback
407  *a callback_script - script text of callback to be added
408  *a callback_script_type - the type of script contained in
409  *a callback_script
410  **
411  ** If NULL is passed for callback_script_type, a default script type
412  ** will be derived based on the default script interpreter of the
413  ** scenario.
414  **
415  *i lua specific:
416  **
417  ** When the script is called, the object for which it is being called
418  ** will be in the callback_object global.
419  **
420  ** To pass NULL when calling from a lua script, use nil.
421  **
422  *b Returns:
423  **
424  ** 0 on success, -1 on failure
425  **
426  *b Callable From:
427  **
428  *- - C++
429  *- - Script
430  */
431  int add_callback_script(int callback_id,
432  const char* callback_script,
433  const char* callback_script_type = NULL);
434 
435  /*l
436  *b Description:
437  **
438  ** This function removes a user callback script previously added with
439  ** add_callback_script().
440  **
441  *b Arguments:
442  **
443  *a callback_id - integer id of the callback
444  *a callback_script - script text of callback previously added
445  *a callback_script_type - the type of script contained in
446  *a callback_script
447  **
448  ** If NULL is passed for callback_script, all callback
449  ** scripts whose ids match callback_id and whose types match
450  ** callback_script_type will be removed.
451  **
452  ** If NULL is passed for callback_script_type, a default script type
453  ** will be derived based on the default script interpreter of the
454  ** scenario.
455  **
456  *i lua specific:
457  **
458  ** To pass NULL when calling from a lua script, use nil.
459  **
460  *b Returns:
461  **
462  ** 0 on success, -1 on failure
463  **
464  *b Callable From:
465  **
466  *- - C++
467  *- - Script
468  */
469  int remove_callback_script(int callback_id,
470  const char* callback_script,
471  const char* callback_script_type = NULL);
472 
473 
474 
475 /****************************************************************************/
476 /****************************************************************************/
477 /****************************************************************************/
484 /****************************************************************************/
485 /****************************************************************************/
486 /****************************************************************************/
487 
488 
489  /*l
490  *b Description:
491  **
492  ** Sets if a light will cast shadow; this will only work in DI-Guy
493  ** Scenario.
494  */
495  void set_casts_shadows(int casts_shadows);
496 
499  void set_shadow_volume_size(float volume);
500  float get_shadow_volume_size();
501 
504  void set_shadow_offset_multiplier(float multiplier);
505  float get_shadow_offset_multiplier();
508  void set_spotlight_angle(float angle);
509  float get_spotlight_angle();
510 
512  void bind_shadow_map(int shadow_map_size);
513  void clear_shadow_map();
514  void unbind_shadow_map();
515 
516 
518  void set_active(int active);
519  int get_active();
520 
521  // runtime values
522  int set_shadow_map_update_paused(int pause);
523  int get_shadow_map_update_paused();
524 
525  int set_shadow_map_update_frequency(int frame_frequency);
526  int get_shadow_map_update_frequency();
527 
528  // unused
529  void set_near_plane(float near_plane);
530  float get_near_plane();
531 
532  void set_far_plane(float far_plane);
533  float get_far_plane();
534 
539 #ifdef CPLUSPLUS_ONLY
540 
541  bdiLight* get_scripted_object() {return m_light;}
542 
543 private:
544 
545  /*
546  * Private constructor.
547  */
548  diguyViewLight(bdiLight* light);
549 
550  bdiLight* m_light;
551  friend class bdiLight;
552 
553 #endif
554 
555 };
556 
557 #endif /* __diguyViewLight_H */
558 
Summary:
Definition: diguyViewLightSettings.h:45
Definition: diguyViewLight.h:55
This class is a simple structure for transmitting diguy lights down to the uniform buffer system this...
Definition: diguyViewLight.h:36
diguyCallbackReturn diguyViewLightCallback(diguyViewLight *light, int callback_id, void *callback_params, void *callback_user_data)
Definition: diguy_typedefs.h:172