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