DI-Guy SDK Documentation  13.6
diguyViewLight.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 __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 
64 class BDI_DECLSPEC_diguy diguyViewLight
65 {
66 
67 public:
68 
69 /*****************************************************************************/
79  /*l
80  *b Description:
81  **
82  ** Returns the name of the object. This pointer will
83  ** never be NULL.
84  **
85  *b Returns:
86  **
87  ** name of the object
88  */
89  const char* get_name();
90 
91  /*l
92  *b Description:
93  **
94  ** Returns the type name of the object. This pointer will
95  ** never be NULL.
96  **
97  *b Returns:
98  **
99  ** type name of the object
100  */
101  const char* get_type_name();
102 
103  /*l
104  *b Description:
105  **
106  ** This function sets the direction of this light.
107  **
108  *b Arguments:
109  **
110  *a x,y,z - x,y,z direction, in meters
111  */
112  void set_direction(float x, float y, float z);
113 
114  /*l
115  *b Description:
116  **
117  ** This function gets the direction of this light.
118  ** Values are returned via the passed pointers.
119  **
120  *b Arguments:
121  **
122  *a x,y,z - x,y,z direction, in meters
123  */
124  void get_direction(float* x, float* y, float* z);
125 
126  /*l
127  *b Description:
128  **
129  ** This function sets the position of this light.
130  **
131  *b Arguments:
132  **
133  *a x,y,z - x,y,z position, in meters
134  */
135  void set_position(float x, float y, float z);
136 
137  /*l
138  *b Description:
139  **
140  ** This function gets the position of this light.
141  ** Values are returned via the passed pointers.
142  **
143  *b Arguments:
144  **
145  *a x,y,z - x,y,z position, in meters
146  */
147  void get_position(float* x, float* y, float* z);
148 
149  /*l
150  *b Description:
151  **
152  ** This function sets the ambient color.
153  **
154  *b Arguments:
155  **
156  *a r,g,b,a - red, green, blue, alpha components
157  */
158  void set_ambient_color(float r, float g, float b, float a);
159 
160  /*l
161  *b Description:
162  **
163  ** This function gets the ambient color of this light.
164  ** Values are returned via the passed pointers.
165  **
166  *b Arguments:
167  **
168  *a r,g,b,a - red, green, blue, alpha components
169  */
170  void get_ambient_color(float* r, float* g, float* b, float* a);
171 
172  /*l
173  *b Description:
174  **
175  ** This function sets the diffuse color.
176  **
177  *b Arguments:
178  **
179  *a r,g,b,a - red, green, blue, alpha components
180  */
181  void set_diffuse_color(float r, float g, float b, float a);
182 
183  /*l
184  *b Description:
185  **
186  ** This function gets the diffuse color of this light.
187  ** Values are returned via the passed pointers.
188  **
189  *b Arguments:
190  **
191  *a r,g,b,a - red, green, blue, alpha components
192  */
193  void get_diffuse_color(float* r, float* g, float* b, float* a);
194 
195  /*l
196  *b Description:
197  **
198  ** This function sets the specular color.
199  **
200  *b Arguments:
201  **
202  *a r,g,b,a - red, green, blue, alpha components
203  */
204  void set_specular_color(float r, float g, float b, float a);
205 
206  /*l
207  *b Description:
208  **
209  ** This function gets the specular color of this light.
210  ** Values are returned via the passed pointers.
211  **
212  *b Arguments:
213  **
214  *a r,g,b,a - red, green, blue, alpha components
215  */
216  void get_specular_color(float* r, float* g, float* b, float* a);
217 
219  int get_casts_shadows();
220 
222  int set_scene_objects_cast_shadows(int value);
223  int get_scene_objects_cast_shadows();
224 
227  int set_brightness_multiplier(float multiplier);
228  float get_brightness_multiplier();
229 
231  void set_spot_exponent(float exponent);
232  float get_spot_exponent();
233 
235  void set_falloff_const(float falloff_const);
236  float get_falloff_const();
237 
239  void set_falloff_rsq(float falloff_rsq);
240  float get_falloff_rsq();
241 
242 
243 /*****************************************************************************/
253  /*l
254  *b Description:
255  **
256  ** Loads the specified settings into this light.
257  **
258  *b Returns:
259  **
260  ** 0 on success, -1 on failure
261  */
262  int load_settings(const char* settings_name);
263 
264  /*l
265  *b Description:
266  **
267  ** Loads the specified settings into this light.
268  **
269  *b Returns:
270  **
271  ** 0 on success, -1 on failure
272  */
273  int load_settings(diguyViewLightSettings* settings);
274 
275  /*l
276  *b Description:
277  **
278  ** Applies the light to OpenGL state. Currently DI-Guy only supports
279  ** one light in it's default OpenGL implementation.
280  **
281  ** At least one light must be applied for advanced DI-Guy reference
282  ** shaders to work.
283  */
284  void apply(int i = 0);
285 
286 
287 /*****************************************************************************/
293  /*l
294  *b Description:
295  **
296  ** This is an enumeration of the different callbacks
297  ** that can be registered with add_callback() and
298  ** add_callback_script().
299  **
300  *b Usable From:
301  **
302  *- - C++
303  *- - Script
304  */
305  enum {
306  CALLBACK_ID_SETTINGS_CHANGED = 1
307  };
308 
309 #ifdef CPLUSPLUS_ONLY
310 
311  /*l
312  *b Description:
313  **
314  ** This function adds a user callback.
315  **
316  *b Arguments:
317  **
318  *a callback - pointer to function with prototype
319  *a diguyViewLightCallback (typedefed above)
320  *a callback_id - integer id of when this callback is to be called
321  *a callback_params - struct containing additional parameters
322  *a needed by some callbacks; actual type depends
323  *a on callback_id
324  *a callback_user_data - pointer for user's own use; DI-Guy will
325  *a do nothing to the contents of this pointer
326  *a beyond passing it back when the callback is
327  *a invoked
328  **
329  ** callback_id should be one of the following values:
330  **
331  *i CALLBACK_ID_SETTINGS_CHANGED
332  **
333  ** This callback will be called if the current settings of this
334  ** light change
335  **
336  ** Callbacks return a value of type diguyCallbackReturn,
337  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
338  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
339  ** of the function will not be called; the callback is asserting
340  ** that it has done everything necessary for the function call.
341  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
342  ** handler for the function will be called after the callback.
343  **
344  *b Returns:
345  **
346  ** 0 on success, -1 on failure
347  **
348  *b Callable From:
349  **
350  *- - C++
351  */
352  int add_callback(int callback_id,
353  diguyViewLightCallback* callback,
354  void* callback_params = 0,
355  void* callback_user_data = 0);
356 
357  /*l
358  *b Description:
359  **
360  ** This function removes a user callback. All callbacks matching
361  ** the specified callback_id and callback function will be removed.
362  **
363  *b Arguments:
364  **
365  *a callback_id - integer id of when this callback is to be called
366  *a callback - pointer to function with prototype
367  *a diguyViewLightCallback (typedefed above)
368  **
369  *b Returns:
370  **
371  ** 0 on success, -1 on failure
372  **
373  *b Callable From:
374  **
375  *- - C++
376  */
377  int remove_callback(int callback_id,
378  diguyViewLightCallback* callback);
379 
380  /*l
381  *b Description:
382  **
383  ** This function removes a user callback. All callbacks matching
384  ** the specified callback_id and callback_user_data pointer will
385  ** be removed.
386  **
387  *b Arguments:
388  **
389  *a callback_id - integer id of when this callback is to be called
390  *a callback_user_data - pointer for user's own use
391  **
392  *b Returns:
393  **
394  ** 0 on success, -1 on failure
395  **
396  *b Callable From:
397  **
398  *- - C++
399  */
400  int remove_callback_with_user_data(int callback_id,
401  void* callback_user_data);
402 
403 #endif
404 
405  /*l
406  *b Description:
407  **
408  ** This function adds a user callback script. Callback scripts can
409  ** be removed with remove_callback_script().
410  **
411  *b Arguments:
412  **
413  *a callback_id - integer id of the callback
414  *a callback_script - script text of callback to be added
415  *a callback_script_type - the type of script contained in
416  *a callback_script
417  **
418  ** If NULL is passed for callback_script_type, a default script type
419  ** will be derived based on the default script interpreter of the
420  ** scenario.
421  **
422  *i lua specific:
423  **
424  ** When the script is called, the object for which it is being called
425  ** will be in the callback_object global.
426  **
427  ** To pass NULL when calling from a lua script, use nil.
428  **
429  *b Returns:
430  **
431  ** 0 on success, -1 on failure
432  **
433  *b Callable From:
434  **
435  *- - C++
436  *- - Script
437  */
438  int add_callback_script(int callback_id,
439  const char* callback_script,
440  const char* callback_script_type = NULL);
441 
442  /*l
443  *b Description:
444  **
445  ** This function removes a user callback script previously added with
446  ** add_callback_script().
447  **
448  *b Arguments:
449  **
450  *a callback_id - integer id of the callback
451  *a callback_script - script text of callback previously added
452  *a callback_script_type - the type of script contained in
453  *a callback_script
454  **
455  ** If NULL is passed for callback_script, all callback
456  ** scripts whose ids match callback_id and whose types match
457  ** callback_script_type will be removed.
458  **
459  ** If NULL is passed for callback_script_type, a default script type
460  ** will be derived based on the default script interpreter of the
461  ** scenario.
462  **
463  *i lua specific:
464  **
465  ** To pass NULL when calling from a lua script, use nil.
466  **
467  *b Returns:
468  **
469  ** 0 on success, -1 on failure
470  **
471  *b Callable From:
472  **
473  *- - C++
474  *- - Script
475  */
476  int remove_callback_script(int callback_id,
477  const char* callback_script,
478  const char* callback_script_type = NULL);
479 
480 
481 
482 /****************************************************************************/
483 /****************************************************************************/
484 /****************************************************************************/
491 /****************************************************************************/
492 /****************************************************************************/
493 /****************************************************************************/
494 
495 
496  /*l
497  *b Description:
498  **
499  ** Sets if a light will cast shadow; this will only work in DI-Guy
500  ** Scenario.
501  */
502  void set_casts_shadows(int casts_shadows);
503 
506  void set_shadow_volume_size(float volume);
507  float get_shadow_volume_size();
508 
511  void set_shadow_offset_multiplier(float multiplier);
512  float get_shadow_offset_multiplier();
515  void set_spotlight_angle(float angle);
516  float get_spotlight_angle();
517 
519  void bind_shadow_map(int shadow_map_size);
520  void clear_shadow_map();
521  void unbind_shadow_map();
522 
523 
525  void set_active(int active);
526  int get_active();
527 
528  // runtime values
529  int set_shadow_map_update_paused(int pause);
530  int get_shadow_map_update_paused();
531 
532  int set_shadow_map_update_frequency(int frame_frequency);
533  int get_shadow_map_update_frequency();
534 
535  // unused
536  void set_near_plane(float near_plane);
537  float get_near_plane();
538 
539  void set_far_plane(float far_plane);
540  float get_far_plane();
541 
546 #ifdef CPLUSPLUS_ONLY
547 
548  bdiLight* get_scripted_object() {return m_light;}
549 
550 private:
551 
552  /*
553  * Private constructor.
554  */
555  diguyViewLight(bdiLight* light);
556 
557  bdiLight* m_light;
558  friend class bdiLight;
559 
560 #endif
561 
562 };
563 
564 #endif /* __diguyViewLight_H */
565 
The diguyViewLightSettings class holds camera settings data that can be loaded into a diguyViewLight ...
Definition: diguyViewLightSettings.h:45
The diguyViewLight provides a interface around a scene light useful in diguy scenario and the opengl ...
Definition: diguyViewLight.h:62
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:181