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