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