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