DI-Guy C++ SDK Reference  13.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguySensorRegion.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2014 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************
8  **
9  *t diguySensorRegion
10  **
11  *b Link against: libdiguy
12  */
13 
14 #ifndef __diguySensorRegion_H
15 #define __diguySensorRegion_H
16 
17 #ifdef SWIG
18 %module diguySensorRegion
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 
25 #include <stdio.h> // for NULL definition
26 #include <diguy_constants.h>
27 #include <diguy_typedefs.h>
28 
29 class bdiScenarioSensorRegion;
30 class diguySensorRegion;
31 class diguyCharacter;
33 
34 #endif
35 
36 
37 #include <declspec_diguy.h>
38 
39 /****************************************************************************/
40 class BDI_DECLSPEC_diguy diguySensorRegion
41 {
42 
43 public:
44 
45  /*l
46  *b Description:
47  **
48  ** Returns the name of the object. This pointer will
49  ** never be NULL.
50  **
51  *b Returns:
52  **
53  ** name of the object
54  **
55  *b Callable From:
56  **
57  *- - C++
58  *- - Script
59  */
60  const char* get_name();
61 
62  /*l
63  *b Description:
64  **
65  ** This function sets the name of this object.
66  **
67  *b Returns:
68  **
69  ** 0 on success, -1 on failure
70  **
71  *b Callable From:
72  **
73  *- - C++
74  *- - Script
75  */
76  int set_name(const char* name);
77 
78  /*l
79  *b Description:
80  **
81  ** Returns the type name of the object. This pointer will
82  ** never be NULL.
83  **
84  *b Returns:
85  **
86  ** type name of the object
87  **
88  *b Callable From:
89  **
90  *- - C++
91  *- - Script
92  */
93  const char* get_type_name();
94 
95  /*l
96  *b Description:
97  **
98  ** This function is checks whether the passed x, y, z position
99  ** is in the sensor region.
100  **
101  *b Arguments:
102  **
103  *a tx, ty, tz - point to check
104  **
105  *b Returns:
106  **
107  ** 1 if the passed point is in the sensor region;
108  ** 0 otherwise.
109  */
110  int contains_point(float tx, float ty, float tz);
111 
112  /*l
113  *b Description:
114  **
115  ** This function checks to see whether the passed character is
116  ** within this sensor region. The actual point that is checked
117  ** is the point returned by diguyCharacter::get_position().
118  **
119  ** Note that this point is typically by the character's feet, so
120  ** it is possible for the upper half of a character to pass
121  ** through a sensor region without this function detecting this.
122  **
123  ** To check the upper portion of a character, use
124  ** contains_character_link() instead, and specify "cervical"
125  ** or "back" as the link.
126  **
127  *b Arguments:
128  **
129  *a character - character to check
130  **
131  *b Returns:
132  **
133  ** 1 if the passed character is in the sensor region;
134  ** 0 otherwise.
135  **
136  *b Callable From:
137  **
138  *- - C++
139  *- - Script
140  *- - Decision Bead
141  */
142  int contains_character(const char* character_name);
143 
144  /*l
145  *b Description:
146  **
147  ** This function checks to see whether a character with the specified
148  ** type is within this sensor region. The actual point that is
149  ** checked is the point returned by diguyCharacter::get_position().
150  **
151  ** Note that this point is typically by the character's feet, so it
152  ** is possible for the upper half of a character to pass through a
153  ** sensor region without this function detecting this.
154  **
155  *b Arguments:
156  **
157  *a character_type - character type to check
158  **
159  *b Returns:
160  **
161  ** 1 if a character with the passed type is in the sensor region;
162  ** 0 otherwise.
163  **
164  *b Callable From:
165  **
166  *- - C++
167  *- - Script
168  *- - Decision Bead
169  */
170  int contains_character_by_type(const char* character_type);
171 
172  /*l
173  *b Description:
174  **
175  ** This function checks to see whether a character with the specified
176  ** type and appearance is within this sensor region. The actual point
177  ** that is checked is the point returned by
178  ** diguyCharacter::get_position().
179  **
180  ** Note that this point is typically by the character's feet, so
181  ** it is possible for the upper half of a character to pass
182  ** through a sensor region without this function detecting this.
183  **
184  *b Arguments:
185  **
186  *a character_type - character type to check
187  *a appearance - appearance to check
188  **
189  *b Returns:
190  **
191  ** 1 if a character with the passed type is in the sensor region;
192  ** 0 otherwise.
193  **
194  *b Callable From:
195  **
196  *- - C++
197  *- - Script
198  *- - Decision Bead
199  */
200  int contains_character_by_type_and_appearance(const char* character_type,
201  const char* appearance);
202 
203  /*l
204  *b Description:
205  **
206  ** This function checks to see whether a character from the specified
207  ** group is within this sensor region. The actual point that is
208  ** checked is the point returned by diguyCharacter::get_position().
209  **
210  ** Note that this point is typically by the character's feet, so it
211  ** is possible for the upper half of a character to pass through a
212  ** sensor region without this function detecting this.
213  **
214  *b Arguments:
215  **
216  *a group_name - group of characters to check
217  **
218  *b Returns:
219  **
220  ** 1 if a character from the group is in the sensor region;
221  ** 0 otherwise.
222  **
223  *b Callable From:
224  **
225  *- - C++
226  *- - Script
227  *- - Decision Bead
228  */
229  int contains_character_from_group(const char* group_name);
230 
231  /*l
232  *b Description:
233  **
234  ** This function is similar to contains_character(), but
235  ** rather than checking whether the character's ideal position
236  ** is in the sensor region, this function checks whether the
237  ** specified link is in the sensor region.
238  **
239  *b Arguments:
240  **
241  *a character_name - name of the character
242  *a link_name - name of the link
243  *a offset_tx, offset_ty, offset_tz - offset in link
244  **
245  *b Returns:
246  **
247  ** 1 if the passed character link is in the sensor region;
248  ** 0 otherwise.
249  */
250  int contains_character_link(const char* character_name,
251  const char* link_name,
252  float offset_tx, float offset_ty, float offset_tz);
253 
254  /*l
255  *b Description:
256  **
257  ** This function checks all characters in the scenario for whether
258  ** they are in this sensor region. Each character that is in the
259  ** sensor region is put into the passed character group. Note that
260  ** the group is first cleared of all members.
261  **
262  ** A subset of characters can be checked by calling
263  ** add_candidate_characters_in_region_to_group().
264  **
265  *b Arguments:
266  **
267  *a group - group to which characters in sensor region should
268  *a be added
269  **
270  *b Returns:
271  **
272  ** 0 on success, -1 on failure
273  **
274  *b Callable From:
275  **
276  *- - C++
277  *- - Script
278  */
279  int add_characters_in_region_to_group(diguyCharacterGroup* group);
280 
281  /*l
282  *b Description:
283  **
284  ** This function checks all characters in the candidates_group
285  ** for whether they are in this sensor region. Each character that
286  ** is in the sensor region is put into the passed character group.
287  ** Note that the group is first cleared of all members.
288  **
289  *b Arguments:
290  **
291  *a candidates_group - group whose members should be checked
292  *a group - group to which characters in sensor region
293  *a should be added
294  **
295  *b Returns:
296  **
297  ** 0 on success, -1 on failure
298  **
299  *b Callable From:
300  **
301  *- - C++
302  *- - Script
303  */
304  int add_candidate_characters_in_region_to_group(diguyCharacterGroup* candidates_group,
305  diguyCharacterGroup* group);
306 
307 
308 /*****************************************************************************/
336  /*l
337  *b Description:
338  **
339  ** This function sets the group that will be used as
340  ** autosense candidates.
341  **
342  ** The passed group must be created by the DI-Guy Scenario UI
343  ** or via a call to diguyScenario::create_group().
344  **
345  ** The members of the candidates group should be set using
346  ** the DI-Guy Scenario UI or via calls to
347  ** diguyCharacterGroup::add_member().
348  **
349  *b Arguments:
350  **
351  *a autosense_candidates_group - group of characters to
352  *a use as candidates
353  **
354  *b Returns:
355  **
356  ** 0 on success, -1 on failure
357  **
358  *b Callable From:
359  **
360  *- - C++
361  *- - Script
362  */
363  int set_autosense_candidates_group(diguyCharacterGroup* autosense_candidates_group);
364 
365  /*l
366  *b Returns:
367  **
368  ** the most recent setting of set_autosense_candidates_group()
369  **
370  *b Callable From:
371  **
372  *- - C++
373  *- - Script
374  */
375  diguyCharacterGroup* get_autosense_candidates_group();
376 
377  /*l
378  *b Description:
379  **
380  ** This function sets the group that will be used to hold
381  ** autosense candidate characters that are in this sensor
382  ** region.
383  **
384  ** The passed group must be created by the DI-Guy Scenario UI
385  ** or via a call to diguyScenario::create_group().
386  **
387  ** The members group is always a subset of the candidates group.
388  ** Characters should not be manually added or removed from the
389  ** members group.
390  **
391  *b Arguments:
392  **
393  *a autosense_members_group - group that holds which candidate
394  *a characters are in this sensor region
395  **
396  *b Returns:
397  **
398  ** 0 on success, -1 on failure
399  **
400  *b Callable From:
401  **
402  *- - C++
403  *- - Script
404  */
405  int set_autosense_members_group(diguyCharacterGroup* autosense_members_group);
406 
407  /*l
408  *b Returns:
409  **
410  ** the most recent setting of set_autosense_members_group()
411  **
412  *b Callable From:
413  **
414  *- - C++
415  *- - Script
416  */
417  diguyCharacterGroup* get_autosense_members_group();
418 
419  /*l
420  *b Description:
421  **
422  ** This function returns the character of the autosense
423  ** candidates group that has entered the sensor
424  ** region, triggering a CALLBACK_ID_AUTOSENSE_CHARACTER_ENTERED
425  ** callback. This function will return NULL when not in the
426  ** above callback.
427  **
428  *b Returns:
429  **
430  ** autosense candidate that has entered this region; NULL if
431  ** not in a CALLBACK_ID_AUTOSENSE_CHARACTER_ENTERED callback
432  **
433  *b Callable From:
434  **
435  *- - C++
436  *- - Script
437  */
438  diguyCharacter* get_autosense_callback_candidate_entered();
439 
440  /*l
441  *b Description:
442  **
443  ** This function returns the character of the autosense
444  ** candidates group that has left the sensor
445  ** region, triggering a CALLBACK_ID_AUTOSENSE_CHARACTER_LEFT
446  ** callback. This function will return NULL when not in the
447  ** above callback.
448  **
449  *b Returns:
450  **
451  ** autosense candidate that has left this region; NULL if
452  ** not in a CALLBACK_ID_AUTOSENSE_CHARACTER_LEFT callback
453  **
454  *b Callable From:
455  **
456  *- - C++
457  *- - Script
458  */
459  diguyCharacter* get_autosense_callback_candidate_left();
460 
461 
462 /*****************************************************************************/
467  /*l
468  *b Description:
469  **
470  ** This is an enumeration of the different callbacks
471  ** that can be registered with add_callback() and
472  ** add_callback_script().
473  **
474  *b Usable From:
475  **
476  *- - C++
477  *- - Script
478  */
479  enum {
480  CALLBACK_ID_CREATE = 1,
481  CALLBACK_ID_DESTROY,
482  CALLBACK_ID_DETONATION,
483  CALLBACK_ID_AUTOSENSE_CHARACTER_ENTERED,
484  CALLBACK_ID_AUTOSENSE_CHARACTER_LEFT
485  };
486 
487 
488 #ifdef CPLUSPLUS_ONLY
489 
490  /*l
491  *b Description:
492  **
493  ** This function adds a user callback. Callbacks can be removed
494  ** with remove_callback() or remove_callback_with_user_data().
495  **
496  *b Arguments:
497  **
498  *a callback - pointer to function with prototype
499  *a diguySensorRegionCallback (typedefed above)
500  *a callback_id - integer id of when this callback is to be called
501  *a callback_params - not currently used; pass NULL
502  *a callback_user_data - pointer for user's own use; DI-Guy will
503  *a do nothing to the contents of this pointer
504  *a beyond passing it back when the callback is
505  *a invoked
506  **
507  ** callback_id should be one of the following values:
508  **
509  *i CALLBACK_ID_CREATE
510  **
511  ** This callback will be called when a new sensor region is created.
512  **
513  ** Note that this callback can only be added by calling
514  ** diguyScenario::add_default_sensor_region_callback(); adding it
515  ** with diguySensorRegion::add_callback() will have no effect, as
516  ** by that time the sensor region has already been created.
517  **
518  *i CALLBACK_ID_DESTROY
519  **
520  ** This callback will be called when a sensor region is
521  ** destroyed.
522  **
523  *i CALLBACK_ID_DETONATION
524  **
525  ** This callback will be called when a detonation occurs within
526  ** the sensor region.
527  **
528  *i CALLBACK_ID_AUTOSENSE_CHARACTER_ENTERED
529  **
530  ** This callback will be called when an autosense candidate
531  ** character first enters the sensor region.
532  **
533  *i CALLBACK_ID_AUTOSENSE_CHARACTER_LEFT
534  **
535  ** This callback will be called when an autosense candidate
536  ** character first leaves the sensor region.
537  **
538  ** Callbacks return a value of type diguyCallbackReturn,
539  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
540  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
541  ** of the function will not be called; the callback is asserting
542  ** that it has done everything necessary for the function call.
543  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
544  ** handler for the function will be called after the callback.
545  **
546  *b Returns:
547  **
548  ** 0 on success, -1 on failure
549  **
550  *b Callable From:
551  **
552  *- - C++
553  */
554  int add_callback(int callback_id,
555  diguySensorRegionCallback* callback,
556  void* callback_params = 0,
557  void* callback_user_data = 0);
558 
559  /*l
560  *b Description:
561  **
562  ** This function removes a user callback. All callbacks matching
563  ** the specified callback_id and callback function will be removed.
564  **
565  *b Arguments:
566  **
567  *a callback_id - integer id of when this callback is to be called
568  *a callback - pointer to function with prototype
569  *a diguySensorRegionCallback (typedefed above)
570  **
571  *b Returns:
572  **
573  ** 0 on success, -1 on failure
574  */
575  int remove_callback(int callback_id,
576  diguySensorRegionCallback* callback);
577 
578  /*l
579  *b Description:
580  **
581  ** This function removes a user callback. All callbacks matching
582  ** the specified callback_id and callback_user_data pointer will
583  ** be removed.
584  **
585  *b Arguments:
586  **
587  *a callback_id - integer id of when this callback is to be called
588  *a callback_user_data - pointer for user's own use
589  **
590  *b Returns:
591  **
592  ** 0 on success, -1 on failure
593  */
594  int remove_callback_with_user_data(int callback_id,
595  void* callback_user_data);
596 
597 #endif
598 
599  /*l
600  *b Description:
601  **
602  ** This function adds a user callback script. Callback scripts can
603  ** be removed with remove_callback_script().
604  **
605  ** See diguyCharacter::add_callback_script() for an example
606  ** of use.
607  **
608  *b Arguments:
609  **
610  *a callback_id - integer id of the callback
611  *a callback_script - script text of callback to be added
612  *a callback_script_type - the type of script contained in
613  *a callback_script
614  **
615  ** If NULL is passed for callback_script_type, a default script type
616  ** will be derived based on the default script interpreter of the
617  ** scenario.
618  **
619  *i lua specific:
620  **
621  ** When the script is called, the object for which it is being called
622  ** will be in the callback_object global.
623  **
624  ** To pass NULL when calling from a lua script, use nil.
625  **
626  *b Returns:
627  **
628  ** 0 on success, -1 on failure
629  **
630  *b Callable From:
631  **
632  *- - C++
633  *- - Script
634  */
635  int add_callback_script(int callback_id,
636  const char* callback_script,
637  const char* callback_script_type = NULL);
638 
639  /*l
640  *b Description:
641  **
642  ** This function removes a user callback script previously added with
643  ** add_callback_script().
644  **
645  ** See diguyCharacter::remove_callback_script() for an example
646  ** of use.
647  **
648  *b Arguments:
649  **
650  *a callback_id - integer id of the callback
651  *a callback_script - script text of callback previously added
652  *a callback_script_type - the type of script contained in
653  *a callback_script
654  **
655  ** If NULL is passed for callback_script, all callback
656  ** scripts whose ids match callback_id and whose types match
657  ** callback_script_type will be removed.
658  **
659  ** If NULL is passed for callback_script_type, a default script type
660  ** will be derived based on the default script interpreter of the
661  ** scenario.
662  **
663  *i Lua specific:
664  **
665  ** To pass NULL when calling from a lua script, use nil.
666  **
667  *b Returns:
668  **
669  ** 0 on success, -1 on failure
670  **
671  *b Callable From:
672  **
673  *- - C++
674  *- - Script
675  */
676  int remove_callback_script(int callback_id,
677  const char* callback_script,
678  const char* callback_script_type = NULL);
679 
680 
681 /*****************************************************************************/
687  /*l
688  *b Description:
689  **
690  ** This function maps the event handler with the given name
691  ** to a callback id. This mapping will be saved in the .dss
692  ** file and restored when the .dss file is loaded.
693  **
694  ** Mappings can also be made via the DI-Guy Scenario UI.
695  **
696  ** The event handler is one of the following:
697  **
698  *- - a scene object callback function registered by
699  *- diguyScenario::register_sensor_region_event_handler() or
700  *- diguyScenario::register_sensor_region_event_handler_from_library()
701  *- - a script registered by
702  *- diguyScenario::register_sensor_region_event_handler_script()
703  *- - a Script, Decision, or Library Function in the scenario
704  *- whose "Event Type" is "Sensor Region"
705  **
706  *b Arguments:
707  **
708  *a callback_id - integer id of callback
709  *a handler_name - name of the event handler to map
710  **
711  *b Returns:
712  **
713  ** 0 on success, -1 on failure
714  **
715  *b Callable From:
716  **
717  *- - C++
718  *- - Script
719  */
720  int map_event_handler_to_callback_id(int callback_id,
721  const char* handler_name);
722 
723  /*l
724  *b Description:
725  **
726  ** This function unmaps the event handler with the given name
727  ** from a callback id.
728  **
729  *b Arguments:
730  **
731  *a callback_id - integer id of callback
732  *a handler_name - name of the event handler to map
733  *a unmap_all_matches - pass 0 to unmap only the first match,
734  *a pass 1 to unmap all matches
735  **
736  *b Returns:
737  **
738  ** 0 on success, -1 on failure
739  **
740  *b Callable From:
741  **
742  *- - C++
743  *- - Script
744  */
745  int unmap_event_handler_from_callback_id(int callback_id,
746  const char* handler_name,
747  int unmap_all_matches = 0);
748 
749 
754 #ifdef CPLUSPLUS_ONLY
755 
756 private:
757 
758  /*l
759  ** A private constructor.
760  */
761  diguySensorRegion(bdiScenarioSensorRegion* sensor_region);
762 
763  /*l
764  ** A pointer to internal data.
765  */
766  bdiScenarioSensorRegion* m_sensor_region;
767 
768  friend class bdiScenarioSensorRegion;
769 
770 #endif
771 
772 };
773 
774 #endif /* __diguySensorRegion_H */