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