DI-Guy SDK Documentation  13.1
diguyCharacterGesture.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2015 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 
8 /*********************************************************************
9  **
10  *t diguyCharacterGesture
11  **
12  */
13 
14 #ifndef __diguyCharacterGesture_H
15 #define __diguyCharacterGesture_H
16 
17 
18 #ifdef SWIG
20 #else
21 #define CPLUSPLUS_ONLY
22 #endif
23 
24 #ifdef CPLUSPLUS_ONLY
25 class bdiGestureInstance;
26 class bdiScenarioCharacter;
28 
31 
32 /****************************************************************************/
34  int callback_id,
35  void* callback_params,
36  void* callback_user_data);
37 
38 #endif
39 
40 
41 #include <declspec_diguy.h>
42 
49 /****************************************************************************/
50 class BDI_DECLSPEC_diguy diguyCharacterGesture
51 {
52 
53 public:
54 
55 /*****************************************************************************/
65  /*l
66  *b Returns:
67  **
68  ** name of the gesture
69  **
70  *b Callable For Gesture Types:
71  **
72  *- - all
73  */
74  const char* get_name();
75 
76  /*l
77  *b Returns:
78  **
79  ** type of the gesture
80  **
81  *b Callable For Gesture Types:
82  **
83  *- - all
84  */
85  diguyCharacterGestureType get_gesture_type();
86 
87  /*l
88  *b Description:
89  **
90  ** This function causes the gesture to begin immediately.
91  ** The gesture will continue until it has completed or
92  ** is aborted.
93  **
94  ** Calling this function on a gesture that has already
95  ** begun will result in a warning message and have no other
96  ** effect.
97  **
98  *i Progression Gestures:
99  **
100  ** The overall duration of the gesture can be set by calling
101  ** set_overall_duration(). The durations of each stage will be
102  ** set proportionately over the overall duration.
103  **
104  ** Alternatively, the durations of individual stages of the
105  ** gesture can be set by calling set_stage_duration().
106  **
107  ** The number of repetitions of the gesture can be set
108  ** by calling set_max_reps().
109  **
110  *b Returns:
111  **
112  ** 0 on success, -1 on failure
113  **
114  *b Callable For Gesture Types:
115  **
116  *- - all
117  */
118  int begin_now();
119 
120  /*l
121  *b Description:
122  **
123  ** This function returns the time at which the gesture began.
124  **
125  *b Returns:
126  **
127  ** time in seconds when scenario began
128  **
129  *b Callable For Gesture Types:
130  **
131  *- - all
132  */
133  float get_tin();
134 
135  /*l
136  *b Returns:
137  **
138  ** 1 if the gesture has begun; 0 if not
139  **
140  *b Callable For Gesture Types:
141  **
142  *- - all
143  */
144  int get_has_begun_flag();
145 
146  /*l
147  *b Description:
148  **
149  ** This function notifies the gesture that it should complete
150  ** as soon as possible. To end a gesture immediately, call
151  ** abort_now().
152  **
153  *b Returns:
154  **
155  ** 0 on success, -1 on failure
156  **
157  *b Callable For Gesture Types:
158  **
159  *- - all
160  */
161  int end_gesture();
162 
163  /*l
164  *b Returns:
165  **
166  ** 1 if the gesture has completed; 0 if not
167  **
168  *b Callable For Gesture Types:
169  **
170  *- - all
171  */
172  int get_has_completed_flag();
173 
174  /*l
175  *b Description:
176  **
177  ** This function causes this gesture to abort. Aborting a gesture
178  ** doesn't destroy it. The gesture can be begun again if desired.
179  ** To end a gesture gracefully call end_gesture().
180  **
181  *b Arguments:
182  **
183  *a max_rampdown_interval - max amount of time spent trying to
184  *a smooth over any motion seams; pass
185  *a 0.5 for a smooth transition, pass
186  *a 0 for an immediate abort
187  **
188  *b Returns:
189  **
190  ** 0 on success, -1 on failure
191  **
192  *b Callable For Gesture Types:
193  **
194  *- - all
195  */
196  int abort_now(float max_rampdown_interval);
197 
198  /*l
199  *b Description:
200  **
201  ** This function causes the gesture object to be automatically
202  ** deleted when the gesture has completed. No further calls
203  ** through the diguyCharacterGesture object can or should
204  ** be made, so this function should only be called once all
205  ** durations, reps, etc. have been set.
206  **
207  *a automatic_destroy_flag - pass 1 to enable automatic
208  *a deletion
209  **
210  *b Returns:
211  **
212  ** 0 on success, -1 on failure
213  **
214  *b Callable For Gesture Types:
215  **
216  *- - all
217  */
218  int set_automatic_destroy_flag(int automatic_destroy_flag);
219 
220  /*l
221  *b Description:
222  **
223  ** This function sets whether joint angles in the gesture
224  ** will be interpolated. This takes more time, but results
225  ** in smoother motion at high frame rates.
226  **
227  *b Arguments:
228  **
229  *a flag - pass 1 to turn on interpolation, pass 0 to turn
230  *a off interpolation
231  **
232  *b Returns:
233  **
234  ** 0 on success, -1 on failure
235  **
236  *b Callable For Gesture Types:
237  **
238  *- - all
239  */
240  int set_interpolation_flag(int flag);
241 
242  /*l
243  *b Returns:
244  **
245  ** the most recent setting of set_interpolation_flag()
246  **
247  *b Callable For Gesture Types:
248  **
249  *- - all
250  */
251  int get_interpolation_flag();
252 
253  /*l
254  *b Returns:
255  **
256  ** how many channels are in the gesture
257  **
258  *b Callable For Gesture Types:
259  **
260  *- - all
261  */
262  int get_num_channels();
263 
264  /*l
265  *b Description:
266  **
267  ** This function sets the weight of the specified channel. The other
268  ** channel weights in a multi-channel gesture will be affected by this
269  ** call so that all channel weight add to 1.
270  **
271  ** If the gesture does not have the channel, this function has no
272  ** effect.
273  **
274  *b Arguments:
275  **
276  *a channel - which channel to affect; pass a single upper
277  *a case character (e.g., 'A')
278  *a channel_weight - value between 0 and 1; 1 means gesture is
279  *a entirely driven by specified channel, 0 means
280  *a specified channel has no effect on gesture
281  **
282  *b Returns:
283  **
284  ** 0 on success, -1 on failure
285  **
286  *b Callable For Gesture Types:
287  **
288  *- - all
289  */
290  int set_channel_weight(char channel, float channel_weight);
291 
292  /*l
293  *b Returns:
294  **
295  ** the current weight of the specified channel; see set_channel_weight()
296  **
297  *b Callable For Gesture Types:
298  **
299  *- - all
300  */
301  float get_channel_weight(char channel);
302 
303  /*l
304  *b Description:
305  **
306  ** This function schedules a smooth ramp of the channel weight
307  ** from its current value to the specified target value.
308  **
309  ** This function is equivalent to calling set_channel_weight()
310  ** many times over the course of a gesture.
311  **
312  ** Calling this function removes any pending channel weight targets
313  ** added by calls to either set_channel_weight_target() or
314  ** add_channel_weight_target().
315  **
316  *b Arguments:
317  **
318  *a channel - which channel to affect; pass a single upper
319  *a case character (e.g., 'A')
320  *a channel_weight_target - target channel weight; a value between
321  *a 0 and 1
322  *a blend_tin - when, relative to the start of the gesture,
323  *a the channel weight should begin moving
324  *a toward channel_weight_target
325  *a blend_tout - when, relative to the start of the gesture,
326  *a the channel weight should arrive at
327  *a channel_weight_target
328  *a blend_function_name - name of the curve to use to move between
329  *a current channel weight and target channel
330  *a weight
331  **
332  ** The possible blend function names are:
333  **
334  *a "HalfSine" - half of a sine curve going from 0 to 1;
335  *a good blend function for smooth entry and exit
336  *a "Linear" - linear line from 0 to 1
337  **
338  *b Returns:
339  **
340  ** 0 on success, -1 on failure
341  **
342  *b Callable For Gesture Types:
343  **
344  *- - all
345  */
346  int set_channel_weight_target(char channel,
347  float channel_weight_target,
348  float blend_tin,
349  float blend_tout,
350  const char* blend_function_name = 0);
351 
352  /*l
353  *b Description:
354  **
355  ** This function is similar to set_channel_weight_target(),
356  ** but adds the channel weight target to a queue of pending
357  ** targets. The gesture will not begin moving the current
358  ** channel weight to the specified target until all pending
359  ** channel weight targets from previous calls to
360  ** set_channel_weight_target() and add_channel_weight_target()
361  ** have been reached.
362  **
363  *b Arguments:
364  **
365  *a channel - which channel to affect; pass a single upper
366  *a case character (e.g., 'A')
367  *a channel_weight_target - target channel weight; a value between
368  *a 0 and 1
369  *a blend_tin - when, relative to the start of the gesture,
370  *a the channel weight should begin moving
371  *a toward channel_weight_target
372  *a blend_tout - when, relative to the start of the gesture,
373  *a the channel weight should arrive at
374  *a channel_weight_target
375  *a blend_function_name - name of the curve to use to move between
376  *a current channel weight and target channel
377  *a weight
378  **
379  *b Lua Example:
380  **
381  *e -- Create a gesture.
382  *e local gesture1 = character:create_gesture("example_gesture");
383  *e
384  *e -- Set the starting channel weight of channel 'A' to 0.2.
385  *e gesture1:set_channel_weight('A', 0.2);
386  *e
387  *e --
388  *e -- Set a channel weight target. This call essentially does this:
389  *e --
390  *e -- Smoothly change the channel A weight of the gesture from its
391  *e -- current value (0.2) to 0, starting at 1.5 seconds into the
392  *e -- gesture, finishing 3.5 seconds into the gesture.
393  *e --
394  *e gesture1:set_channel_weight_target(
395  *e 'A', -- channel to change
396  *e 0.0, -- target weight
397  *e 1.5, -- when to start changing
398  *e 3.5, -- when to stop changing
399  *e "HalfSine"); -- curve to use for blend
400  *e
401  *e --
402  *e -- Add another channel weight target. This call essentially does this:
403  *e --
404  *e -- Smoothly change the channel A weight of the gesture from its
405  *e -- last set channel weight (0) to 0.8, starting at 3.5 seconds into
406  *e -- the gesture, finishing 5.5 seconds into the gesture.
407  *e --
408  *e gesture1:add_channel_weight_target(
409  *e 'A',
410  *e 0.8,
411  *e 3.5,
412  *e 5.5,
413  *e "HalfSine");
414  *e
415  *e --
416  *e -- We're done tweaking the gesture. Set its automatic destroy flag
417  *e -- so that it will be deleted when the gesture has completed.
418  *e --
419  *e gesture1:set_automatic_destroy_flag(1);
420  **
421  *b Returns:
422  **
423  ** 0 on success, -1 on failure
424  **
425  *b Callable For Gesture Types:
426  **
427  *- - all
428  */
429  int add_channel_weight_target(char channel,
430  float channel_weight_target,
431  float blend_tin,
432  float blend_tout,
433  const char* blend_function_name = 0);
434 
435  /*l
436  *b Description:
437  **
438  ** This function sets how long the gesture will take to
439  ** "rampup" control of joints from the base motion to the
440  ** gesture. A longer rampup will result in a smoother
441  ** transition into the gesture.
442  **
443  ** If the rampup duration is longer than the first motion
444  ** of the gesture, it will be shortened to be the same
445  ** duration as the first motion. Motion motions are 0.5
446  ** seconds or shorter.
447  **
448  ** The default duration is 0.5 seconds.
449  **
450  *b Arguments:
451  **
452  *a duration - rampup duration, in seconds
453  **
454  *b Returns:
455  **
456  ** 0 on success, -1 on failure
457  **
458  *b Callable For Gesture Types:
459  **
460  *- - all
461  */
462  int set_rampup_duration(float duration);
463 
464  /*l
465  *b Returns:
466  **
467  ** the rampup duration as set by set_rampup_duration()
468  **
469  *b Callable For Gesture Types:
470  **
471  *- - all
472  */
473  float get_rampup_duration();
474 
475  /*l
476  *b Description:
477  **
478  ** This function sets which blend function will be used during
479  ** rampup to transition control of joints from the base motion
480  ** to the gesture.
481  **
482  ** The default blend function is "HalfSine".
483  **
484  *b Arguments:
485  **
486  *a blend_function_name - new rampup blend function
487  **
488  *b Returns:
489  **
490  ** 0 on success, -1 on failure
491  **
492  *b Callable For Gesture Types:
493  **
494  *- - all
495  */
496  int set_rampup_blend_function_name(const char* blend_function_name);
497 
498  /*l
499  *b Returns:
500  **
501  ** the rampup blend function as set by
502  ** set_rampup_blend_function_name()
503  **
504  *b Callable For Gesture Types:
505  **
506  *- - all
507  */
508  const char* get_rampup_blend_function_name();
509 
510  /*l
511  *b Description:
512  **
513  ** This function sets how long the gesture will take to
514  ** "rampdown" control of joints from the gesture to the
515  ** base motion. A longer rampdown will result in a smoother
516  ** transition out of the gesture.
517  **
518  *b Arguments:
519  **
520  *a duration - rampdown duration, in seconds
521  **
522  *b Returns:
523  **
524  ** 0 on success, -1 on failure
525  **
526  *b Callable For Gesture Types:
527  **
528  *- - all
529  */
530  int set_rampdown_duration(float duration);
531 
532  /*l
533  *b Returns:
534  **
535  ** the rampdown duration as set by set_rampdown_duration()
536  **
537  *b Callable For Gesture Types:
538  **
539  *- - all
540  */
541  float get_rampdown_duration();
542 
543  /*l
544  *b Description:
545  **
546  ** This function sets which blend function will be used during
547  ** rampdown to transition control of joints from the gesture
548  ** to the base motion.
549  **
550  ** The default blend function is "HalfSine".
551  **
552  *b Arguments:
553  **
554  *a blend_function_name - new rampdown blend function
555  **
556  *b Returns:
557  **
558  ** 0 on success, -1 on failure
559  **
560  *b Callable For Gesture Types:
561  **
562  *- - all
563  */
564  int set_rampdown_blend_function_name(const char* blend_function_name);
565 
566  /*l
567  *b Returns:
568  **
569  ** the rampdown blend function as set by
570  ** set_rampdown_blend_function_name()
571  **
572  *b Callable For Gesture Types:
573  **
574  *- - all
575  */
576  const char* get_rampdown_blend_function_name();
577 
578  /*l
579  *b Description:
580  **
581  ** This function returns the default blend duration. This
582  ** is the amount of time the gesture will take to blend
583  ** motions together to produce more seamless motions.
584  **
585  *b Returns:
586  **
587  ** default blend duration, in seconds
588  **
589  *b Callable For Gesture Types:
590  **
591  *- - all
592  */
593  float get_default_blend_duration();
594 
595 
596 /*****************************************************************************/
602  /*l
603  *b Description:
604  **
605  ** This function sets the number of times the gesture will
606  ** be repeated. The optimal overall duration can be optionally
607  ** computed based on the number of repetitions specified.
608  **
609  *i Table Gestures:
610  **
611  ** Table gestures do not yet make use of the overall duration.
612  ** The derive_duration_flag should be given a value of 0.
613  **
614  *b Arguments:
615  **
616  *a max_reps - number of times gesture will be repeated
617  *a derive_duration_flag - pass 1 to derive optimal overall duration
618  *a from passed max_reps
619  **
620  *b Returns:
621  **
622  ** 0 on success, -1 on failure
623  **
624  *b Callable For Gesture Types:
625  **
626  *- - progression
627  */
628  int set_max_reps(int max_reps,
629  int derive_duration_flag = 1);
630 
631  /*l
632  *b Returns:
633  **
634  ** the number of times the gesture will be repeated
635  **
636  *b Callable For Gesture Types:
637  **
638  *- - progression
639  */
640  int get_max_reps();
641 
642  /*l
643  *b Description:
644  **
645  ** This function sets the overall duration the gesture will
646  ** have. The optimal number of repetitions can be optionally
647  ** computed based on the specified duration.
648  **
649  ** Calling this function will override any previous calls
650  ** that set specific stage durations (e.g., as set by a call
651  ** to set_stage_duration()).
652  **
653  *i Table Gestures:
654  **
655  ** Table gestures do not yet make use of the overall duration.
656  **
657  *b Arguments:
658  **
659  *a overall_duration - duration of all stages of the gesture,
660  *a in seconds
661  *a derive_max_reps_flag - pass 1 to derive optimal number of
662  *a reps for the given duration
663  **
664  *b Returns:
665  **
666  ** 0 on success, -1 on failure
667  **
668  *b Callable For Gesture Types:
669  **
670  *- - progression
671  */
672  int set_overall_duration(float overall_duration,
673  int derive_max_reps_flag = 1);
674 
675  /*l
676  *b Returns:
677  **
678  ** the overall duration in seconds of the gesture
679  **
680  *i Table Gestures:
681  **
682  ** Table gestures do not yet make use of the overall duration.
683  **
684  *b Callable For Gesture Types:
685  **
686  *- - progression
687  */
688  float get_overall_duration();
689 
690  /*l
691  *b Returns:
692  **
693  ** the number of stages in the gesture
694  **
695  *b Callable For Gesture Types:
696  **
697  *- - progression
698  **
699  */
700  int get_num_progression_stages();
701 
702  /*l
703  *b Description:
704  **
705  ** This function sets the exact duration of the specified stage
706  ** of the gesture.
707  **
708  *b Arguments:
709  **
710  *a stage - stage; an integer between 1 and 3
711  *a duration - duration of stage, in seconds
712  **
713  *b Returns:
714  **
715  ** 0 on success, -1 on failure
716  **
717  *b Callable For Gesture Types:
718  **
719  *- - progression
720  */
721  int set_progression_stage_duration(int stage, float duration);
722 
723  /*l
724  *b Returns:
725  **
726  ** the duration in seconds of specified stage of the gesture
727  **
728  *b Arguments:
729  **
730  *a stage - stage; an integer between 1 and 3
731  **
732  *b Callable For Gesture Types:
733  **
734  *- - progression
735  */
736  float get_progression_stage_duration(int stage);
737 
738  /*l
739  *b Returns:
740  **
741  ** the optimal duration in seconds of specified stage of the gesture
742  **
743  *b Arguments:
744  **
745  *a stage - stage; an integer between 1 and 3
746  **
747  *b Callable For Gesture Types:
748  **
749  *- - progression
750  */
751  float get_progression_stage_optimal_duration(int stage);
752 
753 
754 /*****************************************************************************/
760  /*l
761  *b Description:
762  **
763  ** This function sets the desired action for table gestures.
764  ** The gesture will begin a transition to the desired action
765  ** as soon as it can.
766  **
767  ** The time required to reach the desired action can be
768  ** determined by calling the
769  ** get_time_required_to_reach_table_action_desired() function.
770  **
771  *b Arguments:
772  **
773  *a action_name - name of desired action
774  **
775  *b Returns:
776  **
777  ** 0 on success, -1 on failure
778  **
779  *b Callable For Gesture Types:
780  **
781  *- - table
782  */
783  int set_table_action_desired(const char* action_name);
784 
785  /*l
786  *b Description:
787  **
788  ** This function returns the desired action for table gestures.
789  **
790  ** If this gesture is not a table gesture the string "error"
791  ** will be returned.
792  **
793  ** The desired action can be set using the
794  ** set_table_action_desired() function.
795  **
796  *b Returns:
797  **
798  ** name of desired action, "error" on error
799  **
800  *b Callable For Gesture Types:
801  **
802  *- - table
803  */
804  const char* get_table_action_desired();
805 
806  /*l
807  *b Description:
808  **
809  ** This function returns how much time it will take to reach
810  ** the desired action for table gestures.
811  **
812  *b Returns:
813  **
814  ** time in seconds needed to reach desired action
815  **
816  *b Callable For Gesture Types:
817  **
818  *- - table
819  */
820  float get_time_required_to_reach_table_action_desired();
821 
822  /*l
823  *b Description:
824  **
825  ** This function returns how many actions a table gesture contains.
826  ** The function get_table_action_at_index() can be called to
827  ** get the name of the actions.
828  **
829  *b Returns:
830  **
831  ** number of actions in table gesture
832  **
833  *b Callable For Gesture Types:
834  **
835  *- - table
836  */
837  int get_num_table_actions();
838 
839  /*l
840  *b Description:
841  **
842  ** This function returns the name of the table action at the
843  ** specified index.
844  **
845  *b Returns:
846  **
847  ** name of table action; NULL if no action at given index
848  **
849  *b Callable For Gesture Types:
850  **
851  *- - table
852  */
853  const char* get_table_action_at_index(int index);
854 
855  /*l
856  *b Description:
857  **
858  ** This function returns how long a single repetition of a
859  ** table action takes.
860  **
861  *b Arguments:
862  **
863  *a action_name - name of action
864  **
865  *b Returns:
866  **
867  ** duration of single rep, in seconds
868  **
869  *b Callable For Gesture Types:
870  **
871  *- - table
872  */
873  float get_table_action_rep_duration(const char* action_name);
874 
875  /*l
876  *b Description:
877  **
878  ** This function returns how long the transition motion(s)
879  ** take between two table actions.
880  **
881  *b Arguments:
882  **
883  *a action_from - name of origin action
884  *a action_to - name of destination action
885  **
886  *b Returns:
887  **
888  ** duration of transition, in seconds
889  **
890  *b Callable For Gesture Types:
891  **
892  *- - table
893  */
894  float get_table_transition_duration(const char* action_from,
895  const char* action_to);
896 
897  /*l
898  *b Description:
899  **
900  ** This function sets which action a table gesture should
901  ** begin at when begin_now() is called. The gesture's first
902  ** motion will be the transition motion from the beginning
903  ** action to the desired action if the actions differ, or
904  ** the looping motion of the desired action if they are the
905  ** same.
906  **
907  ** The default beginning action is the action at index 0.
908  **
909  *b Arguments:
910  **
911  *a action_name - name of beginning action
912  **
913  *b Returns:
914  **
915  ** 0 on success, -1 on failure
916  **
917  *b Callable For Gesture Types:
918  **
919  *- - table
920  */
921  int set_table_action_begin(const char* action_name);
922 
923  /*l
924  *b Returns:
925  **
926  ** the name of the beginning action of a table gesture,
927  ** as set by set_table_action_begin()
928  **
929  *b Callable For Gesture Types:
930  **
931  *- - table
932  */
933  const char* get_table_action_begin();
934 
935  /*l
936  *b Description:
937  **
938  ** This function sets which action a table gesture should
939  ** end with when end_gesture() is called. The default ending
940  ** action is the action at index 0.
941  **
942  *b Arguments:
943  **
944  *a action_name - name of ending action
945  **
946  *b Returns:
947  **
948  ** 0 on success, -1 on failure
949  **
950  *b Callable For Gesture Types:
951  **
952  *- - table
953  */
954  int set_table_action_end(const char* action_name);
955 
956  /*l
957  *b Returns:
958  **
959  ** the name of the ending action of a table gesture,
960  ** as set by set_table_action_end()
961  **
962  *b Callable For Gesture Types:
963  **
964  *- - table
965  */
966  const char* get_table_action_end();
967 
968  /*l
969  *b Returns:
970  **
971  ** the name of the action the table gesture is currently
972  ** playing
973  **
974  *b Callable For Gesture Types:
975  **
976  *- - table
977  */
978  const char* get_table_action_now();
979 
980  /*l
981  *b Returns:
982  **
983  ** the name of the action the table gesture will play next
984  **
985  *b Callable For Gesture Types:
986  **
987  *- - table
988  */
989  const char* get_table_action_next();
990 
991  /*l
992  *b Description:
993  **
994  ** This function forces the current action of the table gesture
995  ** to be the action identified by action_name.
996  **
997  *b Arguments:
998  **
999  *a action_name - name of the action to be performed by
1000  *a the gesture
1001  *a include_transition_arc - flag for whether the transition
1002  *a motion from the current action to
1003  *a the new action is included;
1004  *a pass 1 for best chance of good looking
1005  *a transition;
1006  *a pass 0 for fastest response
1007  *a max_rampdown_interval - max amount of time spent trying to
1008  *a smooth over any motion seams; set
1009  *a to 0.5 for a smooth transition, set
1010  *a to 0 for a potentially rough transition
1011  **
1012  *b Returns:
1013  **
1014  ** 0 on success, -1 on failure
1015  */
1016  int force_table_action(const char* action_name,
1017  int include_transition_arc = 1,
1018  float max_rampdown_interval = 0.5f);
1019 
1020 
1021 /*****************************************************************************/
1027  /*l
1028  *b Description:
1029  **
1030  ** This is an enumeration of the different callbacks
1031  ** that can be registered with add_callback() and
1032  ** add_callback_script().
1033  **
1034  *b Usable From:
1035  **
1036  *- - C++
1037  *- - Script
1038  */
1039  enum {
1040  CALLBACK_ID_CREATE = 1,
1041  CALLBACK_ID_DESTROY,
1042  CALLBACK_ID_ATTAINED_DESIRED_ACTION
1043  };
1044 
1045 #ifdef CPLUSPLUS_ONLY
1046 
1047  /*l
1048  *b Description:
1049  **
1050  ** This function adds a user callback.
1051  **
1052  *b Arguments:
1053  **
1054  *a callback - pointer to function with prototype
1055  *a diguyCharacterGestureCallback (typedefed above)
1056  *a callback_id - integer id of when this callback is to be called
1057  *a callback_params - not currently used; pass NULL
1058  *a callback_user_data - pointer for user's own use; DI-Guy will
1059  *a do nothing to the contents of this pointer
1060  *a beyond passing it back when the callback is
1061  *a invoked
1062  **
1063  ** callback_id should be one of the following values:
1064  **
1065  *i CALLBACK_ID_CREATE
1066  **
1067  ** This callback will be called when a new gesture is created.
1068  **
1069  *i CALLBACK_ID_DESTROY
1070  **
1071  ** This callback will be called when the gesture is destroyed.
1072  **
1073  *i CALLBACK_ID_ATTAINED_DESIRED_ACTION
1074  **
1075  ** This callback will be called when a table gesture has reached
1076  ** its desired action as set by set_table_action_desired().
1077  **
1078  *i Callback Return Values:
1079  **
1080  ** Callbacks return a value of type diguyCallbackReturn,
1081  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
1082  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
1083  ** of the function will not be called; the callback is asserting
1084  ** that it has done everything necessary for the function call.
1085  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
1086  ** handler for the function will be called after the callback.
1087  **
1088  *b Returns:
1089  **
1090  ** 0 on success, -1 on failure
1091  **
1092  *b Callable From:
1093  **
1094  *- - C++
1095  */
1096  int add_callback(int callback_id,
1098  void* callback_params = 0,
1099  void* callback_user_data = 0);
1100 
1101  /*l
1102  *b Description:
1103  **
1104  ** This function removes a user callback. All callbacks matching
1105  ** the specified callback_id and callback function will be removed.
1106  **
1107  *b Arguments:
1108  **
1109  *a callback_id - integer id of when this callback is to be called
1110  *a callback - pointer to function with prototype
1111  *a diguyCharacterGestureCallback (typedefed above)
1112  **
1113  *b Returns:
1114  **
1115  ** 0 on success, -1 on failure
1116  **
1117  *b Callable From:
1118  **
1119  *- - C++
1120  */
1121  int remove_callback(int callback_id,
1122  diguyCharacterGestureCallback* callback);
1123 
1124  /*l
1125  *b Description:
1126  **
1127  ** This function removes a user callback. All callbacks matching
1128  ** the specified callback_id and callback_user_data pointer will
1129  ** be removed.
1130  **
1131  *b Arguments:
1132  **
1133  *a callback_id - integer id of when this callback is to be called
1134  *a callback_user_data - pointer for user's own use
1135  **
1136  *b Returns:
1137  **
1138  ** 0 on success, -1 on failure
1139  **
1140  *b Callable From:
1141  **
1142  *- - C++
1143  */
1144  int remove_callback_with_user_data(int callback_id,
1145  void* callback_user_data);
1146 
1147 #endif /* CPLUSPLUS_ONLY */
1148 
1149  /*l
1150  *b Description:
1151  **
1152  ** This function adds a user callback script. Callback scripts can
1153  ** be removed with remove_callback_script().
1154  **
1155  ** See diguyCharacter::add_callback_script() for an example
1156  ** of use.
1157  **
1158  *b Arguments:
1159  **
1160  *a callback_id - integer id of the callback
1161  *a callback_script - script text of callback to be added
1162  *a callback_script_type - the type of script contained in
1163  *a callback_script
1164  **
1165  ** If NULL is passed for callback_script_type, a default script type
1166  ** will be derived based on the default script interpreter of the
1167  ** scenario.
1168  **
1169  *i lua specific:
1170  **
1171  ** When the script is called, the object for which it is being called
1172  ** will be in the $callback_object scalar.
1173  **
1174  ** To pass NULL when calling from a lua script, use nil.
1175  **
1176  *b Returns:
1177  **
1178  ** 0 on success, -1 on failure
1179  */
1180  int add_callback_script(int callback_id,
1181  const char* callback_script,
1182  const char* callback_script_type = NULL);
1183 
1184  /*l
1185  *b Description:
1186  **
1187  ** This function removes a user callback script previously added with
1188  ** add_callback_script().
1189  **
1190  ** See diguyCharacter::remove_callback_script() for an example
1191  ** of use.
1192  **
1193  *b Arguments:
1194  **
1195  *a callback_id - integer id of the callback
1196  *a callback_script - script text of callback previously added
1197  *a callback_script_type - the type of script contained in
1198  *a callback_script
1199  **
1200  ** If NULL is passed for callback_script, all callback
1201  ** scripts whose ids match callback_id and whose types match
1202  ** callback_script_type will be removed.
1203  **
1204  ** If NULL is passed for callback_script_type, a default script type
1205  ** will be derived based on the default script interpreter of the
1206  ** scenario.
1207  **
1208  *i lua specific:
1209  **
1210  ** To pass NULL when calling from a lua script, use nil.
1211  **
1212  *b Returns:
1213  **
1214  ** 0 on success, -1 on failure
1215  */
1216  int remove_callback_script(int callback_id,
1217  const char* callback_script,
1218  const char* callback_script_type = NULL);
1219 
1220 
1221 /****************************************************************************/
1222 /****************************************************************************/
1223 /*****************************************************************************/
1234 /****************************************************************************/
1235 /****************************************************************************/
1236 /****************************************************************************/
1237 
1242 #ifdef CPLUSPLUS_ONLY
1243 
1244  bdiGestureInstance* get_scripted_object() {return m_scripted_object;}
1245 
1246 private:
1247 
1248  /*l
1249  ** A private constructor. Call diguyCharacter::create_gesture()
1250  ** to create this object.
1251  */
1252  diguyCharacterGesture(bdiGestureInstance* scripted_object);
1253 
1254  /*l
1255  ** A private destructor. Call diguyCharacter::destroy_gesture()
1256  ** to destroy this object.
1257  */
1259 
1260  /*l
1261  ** A pointer to internal data.
1262  */
1263  bdiGestureInstance* m_scripted_object;
1264 
1265  friend class bdiScenarioCharacter;
1266  friend class bdiGestureInstance;
1267  friend class diguyCharacter;
1268 
1269 #endif
1270 
1271 };
1272 
1273 
1274 #endif /* __diguyCharacterGesture_H */
1275 
1276 
1277 /*********************************************************************
1278  ** Copyright (c) 1992-2015 VT MAK
1279  ** All rights reserved.
1280  *********************************************************************/
1281 
int diguyCharacterGestureType
Definition: diguyCharacterGestureType.h:26
diguyCallbackReturn diguyCharacterGestureCallback(diguyCharacterGesture *gesture, int callback_id, void *callback_params, void *callback_user_data)
Definition: diguyCharacterGesture.h:30
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:78
diguyCallbackReturn
DI-Guy callbacks return a value of type diguyCallbackReturn, which will be DIGUY_CALLBACK_STOP or DIG...
Definition: diguy_constants.h:115
A class representing a overlaid performance on a character's base animation.
Definition: diguyCharacterGesture.h:46