DI-Guy SDK Documentation  13.1
diguyCharacterPath.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2015 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************
8  **
9  *t diguyCharacterPath
10  **
11  *b Link against: libdiguy
12  */
13 
14 #ifndef __diguyCharacterPath_H
15 #define __diguyCharacterPath_H
16 
17 #ifdef SWIG
18 %module diguyCharacterPath
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 
25 class bdiScenarioPath;
26 class diguyCharacter;
27 class diguyCharacterPath;
33 class diguyPathShape;
34 class diguyWaypoint;
35 
36 #include <diguy_constants.h>
37 #include <stdlib.h>
38 
39 #endif /* CPLUSPLUS_ONLY */
40 
41 
42 
43 #include <declspec_diguy.h>
44 
52 /****************************************************************************/
53 class BDI_DECLSPEC_diguy diguyCharacterPath
54 {
55 
56 /*****************************************************************************/
66 public:
67 
68  /*l
69  *b Description:
70  **
71  ** Returns the name of the path. This pointer will
72  ** never be NULL.
73  **
74  *b Returns:
75  **
76  ** name of the path
77  */
78  const char* get_name();
79 
80  /*l
81  *b Description:
82  **
83  ** This function sets the name of this object.
84  **
85  *b Returns:
86  **
87  ** 0 on success, -1 on failure
88  */
89  int set_name(const char* name);
90 
91  /*l
92  *b Description:
93  **
94  ** All character paths are assigned a unique identifier, or uid. This
95  ** function returns this path's uid.
96  **
97  ** *Note*: unique identifiers will change between DI-Guy runs!
98  **
99  *b Returns:
100  **
101  ** unique identifier of object
102  */
103  long get_uid();
104 
105  /*l
106  *b Returns:
107  **
108  ** character that owns this path
109  */
110  diguyCharacter* get_character();
111 
112  /*l
113  *b Description:
114  **
115  ** This function should be called after all modifications have
116  ** been made to the path and it is time to re-derive the overall
117  ** path shape and when actions happen.
118  **
119  ** This update is deferred for reasons of performance; if there
120  ** are a lot of modifications to be made to the path they can all
121  ** be done in a group with only a single final update.
122  **
123  ** A call to update() is typically required after certain calls
124  ** are made on objects owned by the path, such as a diguyWaypoint or
125  ** a diguyCharacterPathActionBead. The documentation for function
126  ** calls of these objects will state whether a subsequent update()
127  ** call is necessary.
128  **
129  *b Returns:
130  **
131  ** 0 on success, -1 on failure
132  */
133  int update();
134 
135  /*l
136  *b Description:
137  **
138  ** This function returns the total length of the path,
139  ** in meters.
140  **
141  *b Returns:
142  **
143  ** length of path in meters
144  */
145  float get_length();
146 
147  /*l
148  *b Description:
149  **
150  ** This function returns how long this path is
151  **
152  *b Returns:
153  **
154  ** duration of this path, in seconds
155  */
156  float get_duration();
157 
158  /*l
159  *b Description:
160  **
161  ** This function returns, via the passed variable pointers,
162  ** the position and orientation of the point on the path
163  ** at the specified distance.
164  **
165  *b Arguments:
166  **
167  *a distance_into_path - distance in meters into path
168  *a of the desired point
169  *a x, y, z - position of point in meters from the origin
170  *a rz, rx, ry - orientation of point in degrees counter-clockwise
171  *a from the positive X axis
172  **
173  *b Returns:
174  **
175  ** 0 on success, -1 on failure
176  */
177  int get_point_at_distance(float distance_into_path,
178  float* x, float* y, float* z,
179  float* rz, float* rx, float* ry);
180 
181  /*l
182  *b Description:
183  **
184  ** This function returns the underlying path shape of the
185  ** path. The path shape defines only the waypoints and
186  ** associated spline shape of the path; it doesn't not
187  ** contain any beads or other information.
188  **
189  ** The returned path shape should be considered READ ONLY.
190  ** DO NOT edit the path shape using diguyPathShape member
191  ** functions!
192  **
193  *b Returns:
194  **
195  ** pointer to object of type diguyPathShape
196  */
197  diguyPathShape* get_path_shape();
198 
199 
200 /*****************************************************************************/
210  /*l
211  *b Returns:
212  *
213  ** the number of waypoints belonging to this path
214  */
215  int get_num_waypoints();
216 
217  /*l
218  *b Description:
219  **
220  ** This function gets the waypoint at the specified
221  ** index and returns a pointer to it. The returned
222  ** waypoint can then be queried for information or
223  ** modified.
224  **
225  ** Note that if the waypoint is modified, the update()
226  ** function must be called to update the path's shape
227  ** and other information.
228  **
229  *b Arguments:
230  **
231  *a index - index of the waypoint; indices start at 0
232  **
233  *b Returns:
234  **
235  ** pointer of type diguyWaypoint; NULL if no
236  ** waypoint at the specified index
237  **
238  *b Lua Example:
239  **
240  ** This example gets the first waypoint of the first
241  ** character's first path. It then changes the x coordinate
242  ** of the waypoint and updates the path to reflect the change.
243  **
244  *e local character = this_scenario:get_character_at_index(0);
245  *e local path0 = character:get_path_at_index(0);
246  *e
247  *e local wp0 = path0:get_waypoint_at_index(0);
248  *e local wp0_x = wp0:get_x();
249  *e wp0:set_x(wp0_x + 1.0);
250  *e
251  *e path0:update();
252  */
253  diguyWaypoint* get_waypoint_at_index(int index);
254 
255  /*l
256  *b Description:
257  **
258  ** This function returns a pointer to the specified waypoint.
259  **
260  *b Arguments:
261  **
262  *a name - name of waypoint to be found
263  **
264  *b Returns:
265  **
266  ** pointer of type diguyWaypoint; NULL if not found
267  */
268  diguyWaypoint* find_waypoint(const char* name);
269 
270  /*l
271  *b Description:
272  **
273  ** This function creates a new waypoint that is added to the
274  ** path. Do not call diguyScenario::destroy_waypoint() on
275  ** the returned waypoint; it will be destroyed automatically
276  ** with the path.
277  **
278  *b Arguments:
279  **
280  *a tx, ty, tz - position in meters from the origin
281  *a rz, rx, ry - orientations in degrees counter-clockwise
282  *a from the positive X axis
283  *a weight - how much influence this waypoint exerts
284  *a over the path curve
285  *a index - where the waypoint should be inserted in
286  *a the path; indices start at 0; pass -1 to
287  *a add to end of path
288  **
289  *b Returns:
290  **
291  ** pointer to type diguyWaypoint
292  */
293  diguyWaypoint* create_waypoint(float x = 0.0f, float y = 0.0f, float z = 0.0f,
294  float yaw = 0.0f, float roll = 0.0f, float pitch = 0.0f,
295  float weight = 1.0f,
296  int index = -1);
297 
298  /*l
299  *b Description:
300  **
301  ** This function adds a waypoint to the path.
302  **
303  ** The waypoint should be created using the function
304  ** diguyScenario::create_waypoint(), and destroyed
305  ** using the function diguyScenario::destroy_waypoint().
306  **
307  ** An internal copy of the waypoint is made, so it can
308  ** be destroyed right after this function call or used
309  ** for other path shapes.
310  **
311  *b Arguments:
312  **
313  *a waypoint - waypoint to be appended to end of path
314  **
315  *b Returns:
316  **
317  ** 0 on success, -1 on failure
318  */
319  int add_waypoint(diguyWaypoint* waypoint);
320 
321  /*l
322  *b Description:
323  **
324  ** This function destroys a waypoint on the path.
325  **
326  *b Arguments:
327  **
328  *a waypoint - waypoint to be deleted
329  **
330  *b Returns:
331  **
332  ** 0 on success, -1 on failure
333  */
334  int destroy_waypoint(diguyWaypoint* waypoint);
335 
336 /*****************************************************************************/
346  /*l
347  *b Returns:
348  *
349  ** the number of action beads belonging to this path
350  */
351  int get_num_action_beads();
352 
353  /*l
354  *b Description:
355  **
356  ** This function gets the action bead at the specified
357  ** index and returns a pointer to it. The returned
358  ** action bead can then be queried for information or
359  ** modified.
360  **
361  ** Note that if the action bead is modified, the update()
362  ** function must be called to update the path's information.
363  **
364  *b Returns:
365  **
366  ** pointer of type diguyCharacterPathActionBead; NULL if no
367  ** action bead at the specified index
368  **
369  *b Arguments:
370  **
371  *a index - index of the action bead; indices start at 0
372  */
373  diguyCharacterPathActionBead* get_action_bead_at_index(int index);
374 
375  /*l
376  *b Description:
377  **
378  ** This function returns a pointer to the specified bead.
379  **
380  *b Arguments:
381  **
382  *a name - name of bead to be found
383  **
384  *b Returns:
385  **
386  ** pointer of type diguyCharacterPathActionBead; NULL if not found
387  */
388  diguyCharacterPathActionBead* find_action_bead(const char* name);
389 
390  /*l
391  *b Description:
392  **
393  ** This function returns a pointer to the last action bead of the
394  ** path. The last action bead is slightly different than the
395  ** rest. It has no inherent duration or length; instead, it
396  ** effectively specifies what the character should do once this
397  ** path has completed.
398  **
399  ** Calling this function is the same as the following:
400  **
401  *e int num_action_beads = path->get_num_action_beads();
402  *e diguyCharacterPathActionBead* ab;
403  *e ab = path->get_action_bead_at_index(num_action_beads-1);
404  **
405  ** Do not call delete or destroy_action_bead() on the returned
406  ** pointer. All paths must have a final action bead.
407  **
408  *b Returns:
409  **
410  ** pointer of type diguyCharacterPathActionBead; this pointer
411  ** should never be NULL
412  */
413  diguyCharacterPathActionBead* get_final_action_bead();
414 
415  /*l
416  *b Description:
417  **
418  ** This function inserts a new action bead at the specified
419  ** index and returns a pointer to it. The returned
420  ** action bead can then be queried for information or
421  ** modified.
422  **
423  ** Note that the update() function must be called after this
424  ** function.
425  **
426  ** Do not call delete on the returned pointer. Use
427  ** destroy_action_bead() instead.
428  **
429  *b Returns:
430  **
431  ** pointer of type diguyCharacterPathActionBead; NULL if
432  ** insertion failed
433  **
434  *b Arguments:
435  **
436  *a action - action new bead should perform
437  *a index - index of the action bead; indices start at 0;
438  *a pass -1 to append the action bead to the end
439  *a of the path
440  */
441  diguyCharacterPathActionBead* create_action_bead(const char* action,
442  int index = -1);
443 
444  /*l
445  *b Description:
446  **
447  ** This function removes the passed action bead from the
448  ** path and destroys it.
449  **
450  ** Note that the update() function must be called after this
451  ** function.
452  **
453  *b Returns:
454  **
455  ** 0 on success, -1 on failure
456  **
457  *b Arguments:
458  **
459  *a action_bead - object to destroy; must be part of this path
460  */
461  int destroy_action_bead(diguyCharacterPathActionBead* action_bead);
462 
463 
464 /*****************************************************************************/
474  /*l
475  *b Returns:
476  *
477  ** the number of script beads belonging to this path
478  */
479  int get_num_script_beads();
480 
481  /*l
482  *b Description:
483  **
484  ** This function gets the script bead at the specified
485  ** index and returns a pointer to it. The returned
486  ** script bead can then be queried for information or
487  ** modified.
488  **
489  ** Note that if the script bead is modified, the update()
490  ** function must be called to update the path's information.
491  **
492  *b Returns:
493  **
494  ** pointer of type diguyCharacterPathScriptBead; NULL if no
495  ** script bead at the specified index
496  **
497  *b Arguments:
498  **
499  *a index - index of the script bead; indices start at 0
500  */
501  diguyCharacterPathScriptBead* get_script_bead_at_index(int index);
502 
503  /*l
504  *b Description:
505  **
506  ** This function returns a pointer to the specified bead.
507  **
508  *b Arguments:
509  **
510  *a name - name of bead to be found
511  **
512  *b Returns:
513  **
514  ** pointer of type diguyCharacterPathScriptBead; NULL if not found
515  */
516  diguyCharacterPathScriptBead* find_script_bead(const char* name);
517 
518  /*l
519  *b Description:
520  **
521  ** This function inserts a new script bead at the specified
522  ** index and returns a pointer to it. The returned
523  ** script bead can then be queried for information or
524  ** modified.
525  **
526  ** Note that the update() function must be called after this
527  ** function.
528  **
529  ** Do not call delete on the returned pointer. Use
530  ** destroy_script_bead() instead.
531  **
532  *b Returns:
533  **
534  ** pointer of type diguyCharacterPathScriptBead; NULL if
535  ** insertion failed
536  **
537  *b Arguments:
538  **
539  *a script - script new bead should perform
540  *a index - index of the script bead; indices start at 0;
541  *a pass -1 to create the bead at the last index
542  *a script_type - defaults to "lua"
543  */
544  diguyCharacterPathScriptBead* create_script_bead(const char* script,
545  int index = -1,
546  const char* script_type = "lua");
547 
548  /*l
549  *b Description:
550  **
551  ** This function removes the passed script bead from the
552  ** path and destroys it.
553  **
554  ** Note that the update() function must be called after this
555  ** function.
556  **
557  *b Returns:
558  **
559  ** 0 on success, -1 on failure
560  **
561  *b Arguments:
562  **
563  *a script_bead - object to destroy; must be part of this path
564  */
565  int destroy_script_bead(diguyCharacterPathScriptBead* script_bead);
566 
567 
568 /*****************************************************************************/
578  /*l
579  *b Returns:
580  *
581  ** the number of decision beads belonging to this path
582  */
583  int get_num_decision_beads();
584 
585  /*l
586  *b Description:
587  **
588  ** This function gets the decision bead at the specified
589  ** index and returns a pointer to it. The returned
590  ** decision bead can then be queried for information.
591  **
592  ** Note that if the decision bead is modified, the update()
593  ** function must be called to update the path's information.
594  **
595  *b Returns:
596  **
597  ** pointer of type diguyCharacterPathDecisionBead; NULL if no
598  ** script bead at the specified index
599  **
600  *b Arguments:
601  **
602  *a index - index of the decision bead; indices start at 0
603  */
604  diguyCharacterPathDecisionBead* get_decision_bead_at_index(int index);
605 
606  /*l
607  *b Description:
608  **
609  ** This function returns a pointer to the specified bead.
610  **
611  *b Arguments:
612  **
613  *a name - name of bead to be found
614  **
615  *b Returns:
616  **
617  ** pointer of type diguyCharacterPathDecisionBead; NULL if not found
618  */
619  diguyCharacterPathDecisionBead* find_decision_bead(const char* name);
620 
621 
622 /*****************************************************************************/
632  /*l
633  *b Returns:
634  *
635  ** the number of gaze beads belonging to this path
636  */
637  int get_num_gaze_beads();
638 
639  /*l
640  *b Description:
641  **
642  ** This function gets the gaze bead at the specified
643  ** index and returns a pointer to it. The returned
644  ** gaze bead can then be queried for information.
645  **
646  ** Note that if the gaze bead is modified, the update()
647  ** function must be called to update the path's information.
648  **
649  *b Returns:
650  **
651  ** pointer of type diguyCharacterPathDecisionBead; NULL if no
652  ** script bead at the specified index
653  **
654  *b Arguments:
655  **
656  *a index - index of the gaze bead; indices start at 0
657  */
658  diguyCharacterPathGazeBead* get_gaze_bead_at_index(int index);
659 
660  /*l
661  *b Description:
662  **
663  ** This function returns a pointer to the specified bead.
664  **
665  *b Arguments:
666  **
667  *a name - name of bead to be found
668  **
669  *b Returns:
670  **
671  ** pointer of type diguyCharacterPathGazeBead; NULL if not found
672  */
673  diguyCharacterPathGazeBead* find_gaze_bead(const char* name);
674 
675 
676 /*****************************************************************************/
686  /*l
687  *b Returns:
688  *
689  ** the number of aim beads belonging to this path
690  */
691  int get_num_aim_beads();
692 
693  /*l
694  *b Description:
695  **
696  ** This function gets the aim bead at the specified
697  ** index and returns a pointer to it. The returned
698  ** aim bead can then be queried for information.
699  **
700  ** Note that if the aim bead is modified, the update()
701  ** function must be called to update the path's information.
702  **
703  *b Returns:
704  **
705  ** pointer of type diguyCharacterPathDecisionBead; NULL if no
706  ** script bead at the specified index
707  **
708  *b Arguments:
709  **
710  *a index - index of the aim bead; indices start at 0
711  */
712  diguyCharacterPathAimBead* get_aim_bead_at_index(int index);
713 
714  /*l
715  *b Description:
716  **
717  ** This function returns a pointer to the specified bead.
718  **
719  *b Arguments:
720  **
721  *a name - name of bead to be found
722  **
723  *b Returns:
724  **
725  ** pointer of type diguyCharacterPathAimBead; NULL if not found
726  */
727  diguyCharacterPathAimBead* find_aim_bead(const char* name);
728 
729 
730 
731 /****************************************************************************/
732 /****************************************************************************/
733 /****************************************************************************/
740 /****************************************************************************/
741 /****************************************************************************/
742 /****************************************************************************/
743 
744  int translate(float tx, float ty, float tz);
745 
746  int rotate_about_point(float rz, float rx, float ry,
747  float rotation_pt_x, float rotation_pt_y, float rotation_pt_z);
748 
749  int set_ground_clamp_when_on_path(int ground_clamp_when_on_path);
750  int get_ground_clamp_when_on_path();
752  int get_position_at_distance(float distance,
753  float* tx, float* ty, float* tz,
754  float* rz = NULL, float* rx = NULL, float* ry = NULL);
755  int get_position_at_distance_double(float distance,
756  double* tx, double* ty, double* tz,
757  float* rz = NULL, float* rx = NULL, float* ry = NULL);
758 
759  int get_position_at_t(float t,
760  float* tx, float* ty, float* tz,
761  float* rz = NULL, float* rx = NULL, float* ry = NULL);
762  int get_position_at_t_double(float t,
763  double* tx, double* ty, double* tz,
764  float* rz = NULL, float* rx = NULL, float* ry = NULL);
765 
766 
771 #ifdef CPLUSPLUS_ONLY
772 
773  bdiScenarioPath* get_scripted_object() {return m_scripted_object;}
774 
775 private:
776 
777  /*l
778  ** A private constructor.
779  */
780  diguyCharacterPath(bdiScenarioPath* path);
781 
782  /*l
783  ** A private destructor.
784  */
786 
787  /*l
788  ** A pointer to internal data.
789  */
790  bdiScenarioPath* m_scripted_object;
791 
792  friend class bdiScenarioPath;
793  friend class diguyCharacter;
794 
795 #endif /* CPLUSPLUS_ONLY */
796 
797 };
798 
799 #endif /* __diguyCharacterPath_H */
800 
Definition: diguyPathShape.h:30
A bead that sits on a character's spline path and triggers a new gaze.
Definition: diguyCharacterPathGazeBead.h:35
A bead that sits on a character's spline path and triggers a new decision.
Definition: diguyCharacterPathDecisionBead.h:35
An interface for manipulating a character's spline path. Path is typically authored in DI-Guy Scenari...
Definition: diguyCharacterPath.h:50
A bead that sits on a character's spline path and triggers a new action.
Definition: diguyCharacterPathActionBead.h:35
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:78
Definition: diguyWaypoint.h:29
static double t
4 Header files and forward declarations
Definition: simple_playback_ogl.cpp:53
A bead that sits on a character's spline path and triggers a new script evaluation.
Definition: diguyCharacterPathScriptBead.h:36
A bead that sits on a character's spline path and triggers a new aim event.
Definition: diguyCharacterPathAimBead.h:35