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