C++ SDK Reference  12.5
 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-2013 Boston Dynamics
4  * ALL RIGHTS RESERVED.
5  *
6  * These coded instructions, statements, and computer programs
7  * contain unpublished proprietary information of Boston Dynamics
8  * and are protected by Copyright Laws of the United States.
9  * They may not be used, duplicated, or disclosed in any form, in
10  * whole or in part, without the prior written consent from Boston
11  * Dynamics.
12  *
13  * RESTRICTED RIGHTS LEGEND
14  * Use, duplication, or disclosure by the government is subject
15  * to restrictions as set forth in FAR 52.227.19(c)(2) or
16  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
17  * Computer Software clause at DFARS 252.227-7013 and/or in
18  * similar or successor clauses in the FAR, or the DOD or NASA
19  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
20  * Commercial Computer Software--Restricted Rights at 48 CFR
21  * 52.227-19, as applicable. Unpublished-rights reserved under
22  * the Copyright Laws of the United States.
23  * Contractor/Manufacturer is:
24  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
25  */
26 
27 /*********************************************************************/
33 #ifndef __diguyViewLight_H
34 #define __diguyViewLight_H
35 
36 #ifdef SWIG
37 %module diguyViewLight
38 #else
39 #define CPLUSPLUS_ONLY
40 #endif
41 
42 #ifdef CPLUSPLUS_ONLY
43 class bdiLight;
44 class diguyViewLight;
46 
47 #include <stdio.h> // for NULL definition
48 #include <diguy_constants.h>
49 #include <diguy_typedefs.h>
50 
51 #endif
52 
53 
54 #include <declspec_diguy.h>
55 
56 /****************************************************************************/
57 class BDI_DECLSPEC_diguy diguyViewLight
58 {
59 
60 public:
61 
62 /*****************************************************************************/
68  /*l
69  *b Description:
70  **
71  ** Returns the name of the object. This pointer will
72  ** never be NULL.
73  **
74  *b Returns:
75  **
76  ** name of the object
77  **
78  *b Callable From:
79  **
80  *- - C++
81  *- - Script
82  */
83  const char* get_name();
84 
85  /*l
86  *b Description:
87  **
88  ** Returns the type name of the object. This pointer will
89  ** never be NULL.
90  **
91  *b Returns:
92  **
93  ** type name of the object
94  **
95  *b Callable From:
96  **
97  *- - C++
98  *- - Script
99  */
100  const char* get_type_name();
101 
102  /*l
103  *b Description:
104  **
105  ** This function sets the direction of this light.
106  **
107  *b Arguments:
108  **
109  *a x - x direction, in meters
110  *a y - y direction, in meters
111  *a z - z direction, in meters
112  **
113  *b Callable From:
114  **
115  *- - C++
116  *- - Script
117  */
118  void set_direction(float x, float y, float z);
119 
120  /*l
121  *b Description:
122  **
123  ** This function gets the direction of this light.
124  ** Values are returned via the passed pointers.
125  **
126  *b Arguments:
127  **
128  *a x - x direction, in meters
129  *a y - y direction, in meters
130  *a z - z direction, in meters
131  **
132  *b Callable From:
133  **
134  *- - C++
135  *- - Script
136  */
137  void get_direction(float* x, float* y, float* z);
138 
139  /*l
140  *b Description:
141  **
142  ** This function sets the position of this light.
143  **
144  *b Arguments:
145  **
146  *a x - x position, in meters
147  *a y - y position, in meters
148  *a z - z position, in meters
149  **
150  *b Callable From:
151  **
152  *- - C++
153  *- - Script
154  */
155  void set_position(float x, float y, float z);
156 
157  /*l
158  *b Description:
159  **
160  ** This function gets the position of this light.
161  ** Values are returned via the passed pointers.
162  **
163  *b Arguments:
164  **
165  *a x - x position, in meters
166  *a y - y position, in meters
167  *a z - z position, in meters
168  **
169  *b Callable From:
170  **
171  *- - C++
172  *- - Script
173  */
174  void get_position(float* x, float* y, float* z);
175 
176  /*l
177  *b Description:
178  **
179  ** This function sets the ambient color.
180  **
181  *b Arguments:
182  **
183  *a r - red component
184  *a g - blue component
185  *a b - green component
186  *a a - alpha component
187  **
188  *b Callable From:
189  **
190  *- - C++
191  *- - Script
192  */
193  void set_ambient_color(float r, float g, float b, float a);
194 
195  /*l
196  *b Description:
197  **
198  ** This function gets the ambient color of this light.
199  ** Values are returned via the passed pointers.
200  **
201  *b Arguments:
202  **
203  *a r - red component
204  *a g - blue component
205  *a b - green component
206  *a a - alpha component
207  **
208  *b Callable From:
209  **
210  *- - C++
211  *- - Script
212  */
213  void get_ambient_color(float* r, float* g, float* b, float* a);
214 
215  /*l
216  *b Description:
217  **
218  ** This function sets the diffuse color.
219  **
220  *b Arguments:
221  **
222  *a r - red component
223  *a g - blue component
224  *a b - green component
225  *a a - alpha component
226  **
227  *b Callable From:
228  **
229  *- - C++
230  *- - Script
231  */
232  void set_diffuse_color(float r, float g, float b, float a);
233 
234  /*l
235  *b Description:
236  **
237  ** This function gets the diffuse color of this light.
238  ** Values are returned via the passed pointers.
239  **
240  *b Arguments:
241  **
242  *a r - red component
243  *a g - blue component
244  *a b - green component
245  *a a - alpha component
246  **
247  *b Callable From:
248  **
249  *- - C++
250  *- - Script
251  */
252  void get_diffuse_color(float* r, float* g, float* b, float* a);
253 
254  /*l
255  *b Description:
256  **
257  ** This function sets the specular color.
258  **
259  *b Arguments:
260  **
261  *a r - red component
262  *a g - blue component
263  *a b - green component
264  *a a - alpha component
265  **
266  *b Callable From:
267  **
268  *- - C++
269  *- - Script
270  */
271  void set_specular_color(float r, float g, float b, float a);
272 
273  /*l
274  *b Description:
275  **
276  ** This function gets the specular color of this light.
277  ** Values are returned via the passed pointers.
278  **
279  *b Arguments:
280  **
281  *a r - red component
282  *a g - blue component
283  *a b - green component
284  *a a - alpha component
285  **
286  *b Callable From:
287  **
288  *- - C++
289  *- - Script
290  */
291  void get_specular_color(float* r, float* g, float* b, float* a);
292 
293 
294 /*****************************************************************************/
300  /*l
301  *b Description:
302  **
303  ** Loads the specified settings into this light.
304  **
305  *b Returns:
306  **
307  ** 0 on success, -1 on failure
308  **
309  *b Callable From:
310  **
311  *- - C++
312  *- - Script
313  */
314  int load_settings(const char* settings_name);
315 
316 #ifdef CPLUSPLUS_ONLY
317 
318  /*l
319  *b Description:
320  **
321  ** Loads the specified settings into this light.
322  **
323  *b Returns:
324  **
325  ** 0 on success, -1 on failure
326  **
327  *b Callable From:
328  **
329  *- - C++
330  *- - Script
331  */
332  int load_settings(diguyViewLightSettings* settings);
333 
334 #endif
335 
336  /*l
337  *b Description:
338  **
339  ** Applies the light to OpenGL state. Currently DI-Guy only supports
340  ** one light in it's default OpenGL implementation.
341  **
342  ** At least one light must be applied for advanced DI-Guy reference
343  ** shaders to work.
344  */
345  void apply(int i = 0);
347 
348 /*****************************************************************************/
354  /*l
355  *b Description:
356  **
357  ** This is an enumeration of the different callbacks
358  ** that can be registered with add_callback() and
359  ** add_callback_script().
360  **
361  *b Usable From:
362  **
363  *- - C++
364  *- - Script
365  */
366  enum {
367  CALLBACK_ID_SETTINGS_CHANGED = 1
368  };
369 
370 #ifdef CPLUSPLUS_ONLY
371 
372  /*l
373  *b Description:
374  **
375  ** This function adds a user callback.
376  **
377  *b Arguments:
378  **
379  *a callback - pointer to function with prototype
380  *a diguyViewLightCallback (typedefed above)
381  *a callback_id - integer id of when this callback is to be called
382  *a callback_params - struct containing additional parameters
383  *a needed by some callbacks; actual type depends
384  *a on callback_id
385  *a callback_user_data - pointer for user's own use; DI-Guy will
386  *a do nothing to the contents of this pointer
387  *a beyond passing it back when the callback is
388  *a invoked
389  **
390  ** callback_id should be one of the following values:
391  **
392  *i CALLBACK_ID_SETTINGS_CHANGED
393  **
394  ** This callback will be called if the current settings of this
395  ** light change
396  **
397  ** Callbacks return a value of type diguyCallbackReturn,
398  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
399  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
400  ** of the function will not be called; the callback is asserting
401  ** that it has done everything necessary for the function call.
402  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
403  ** handler for the function will be called after the callback.
404  **
405  *b Returns:
406  **
407  ** 0 on success, -1 on failure
408  **
409  *b Callable From:
410  **
411  *- - C++
412  */
413  int add_callback(int callback_id,
414  diguyViewLightCallback* callback,
415  void* callback_params = 0,
416  void* callback_user_data = 0);
417 
418  /*l
419  *b Description:
420  **
421  ** This function removes a user callback. All callbacks matching
422  ** the specified callback_id and callback function will be removed.
423  **
424  *b Arguments:
425  **
426  *a callback_id - integer id of when this callback is to be called
427  *a callback - pointer to function with prototype
428  *a diguyViewLightCallback (typedefed above)
429  **
430  *b Returns:
431  **
432  ** 0 on success, -1 on failure
433  **
434  *b Callable From:
435  **
436  *- - C++
437  */
438  int remove_callback(int callback_id,
439  diguyViewLightCallback* callback);
440 
441  /*l
442  *b Description:
443  **
444  ** This function removes a user callback. All callbacks matching
445  ** the specified callback_id and callback_user_data pointer will
446  ** be removed.
447  **
448  *b Arguments:
449  **
450  *a callback_id - integer id of when this callback is to be called
451  *a callback_user_data - pointer for user's own use
452  **
453  *b Returns:
454  **
455  ** 0 on success, -1 on failure
456  **
457  *b Callable From:
458  **
459  *- - C++
460  */
461  int remove_callback_with_user_data(int callback_id,
462  void* callback_user_data);
463 
464 #endif
465 
466  /*l
467  *b Description:
468  **
469  ** This function adds a user callback script. Callback scripts can
470  ** be removed with remove_callback_script().
471  **
472  *b Arguments:
473  **
474  *a callback_id - integer id of the callback
475  *a callback_script - script text of callback to be added
476  *a callback_script_type - the type of script contained in
477  *a callback_script
478  **
479  ** If NULL is passed for callback_script_type, a default script type
480  ** will be derived based on the default script interpreter of the
481  ** scenario.
482  **
483  *i lua specific:
484  **
485  ** When the script is called, the object for which it is being called
486  ** will be in the callback_object global.
487  **
488  ** To pass NULL when calling from a lua script, use nil.
489  **
490  *b Returns:
491  **
492  ** 0 on success, -1 on failure
493  **
494  *b Callable From:
495  **
496  *- - C++
497  *- - Script
498  */
499  int add_callback_script(int callback_id,
500  const char* callback_script,
501  const char* callback_script_type = NULL);
502 
503  /*l
504  *b Description:
505  **
506  ** This function removes a user callback script previously added with
507  ** add_callback_script().
508  **
509  *b Arguments:
510  **
511  *a callback_id - integer id of the callback
512  *a callback_script - script text of callback previously added
513  *a callback_script_type - the type of script contained in
514  *a callback_script
515  **
516  ** If NULL is passed for callback_script, all callback
517  ** scripts whose ids match callback_id and whose types match
518  ** callback_script_type will be removed.
519  **
520  ** If NULL is passed for callback_script_type, a default script type
521  ** will be derived based on the default script interpreter of the
522  ** scenario.
523  **
524  *i lua specific:
525  **
526  ** To pass NULL when calling from a lua script, use nil.
527  **
528  *b Returns:
529  **
530  ** 0 on success, -1 on failure
531  **
532  *b Callable From:
533  **
534  *- - C++
535  *- - Script
536  */
537  int remove_callback_script(int callback_id,
538  const char* callback_script,
539  const char* callback_script_type = NULL);
540 
541 
542 /****************************************************************************/
543 /****************************************************************************/
544 /****************************************************************************/
551 /****************************************************************************/
552 /****************************************************************************/
553 /****************************************************************************/
554 
555  void set_near_plane(float near_plane);
556 
557  float get_near_plane();
558 
559  void set_far_plane(float far_plane);
560 
561  float get_far_plane();
562 
563  /*l
564  *b Description:
565  **
566  ** Sets if a light will cast shadow; this will only work in DI-Guy
567  ** Scenario.
568  */
569  void set_casts_shadows(int casts_shadows);
570 
571  /*l
572  *b Returns:
573  **
574  ** Returns if a light will cast shadow; this is limited to DI-Guy
575  ** Scenario
576  */
577  int get_casts_shadows();
578 
579  int set_scene_objects_cast_shadows(int value);
580  int get_scene_objects_cast_shadows();
581 
582  int set_brightness_multiplier(float multiplier);
583  float get_brightness_multiplier();
584 
585  void set_shadow_volume_size(float volume);
586  float get_shadow_volume_size();
587 
588  void set_shadow_offset_multiplier(float multiplier);
589  float get_shadow_offset_multiplier();
590 
591  // SPOT LIGHT Functions, not used in DI-Guy 12
592  void set_spotlight_angle(float angle);
593  float get_spotlight_angle();
594  void set_texture_name(const char* name);
595 
596  // unused
597  void set_active(int active);
598  int get_active();
599 
600  // runtime values
601  int set_shadow_map_update_paused(int pause);
602  int get_shadow_map_update_paused();
603 
604  int set_shadow_map_update_frequency(int frame_frequency);
605  int get_shadow_map_update_frequency();
606 
607 
612 #ifdef CPLUSPLUS_ONLY
613 
614  bdiLight* get_scripted_object() {return m_light;}
615 
616 private:
617 
618  /*
619  * Private constructor.
620  */
621  diguyViewLight(bdiLight* light);
622 
623  bdiLight* m_light;
624  friend class bdiLight;
625 
626 #endif
627 
628 };
629 
630 #endif /* __diguyViewLight_H */
631