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