DI-Guy SDK Documentation  13.7
diguyPathShape.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 diguyPathShape
10  **
11  *b Link against: libdiguy
12  */
13 
14 #ifndef __diguyPathShape_H
15 #define __diguyPathShape_H
16 
17 #ifdef SWIG
18 %module diguyPathShape
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 class bdiScenarioPathShape;
25 class diguyWaypoint;
26 #endif
27 
28 
29 #include <declspec_diguy.h>
30 
31 /****************************************************************************/
38 class BDI_DECLSPEC_diguy diguyPathShape
39 {
40 
41 /*****************************************************************************/
51 public:
52 
53  /*l
54  *b Description:
55  **
56  ** Returns the name of the path shape. This pointer will
57  ** never be NULL.
58  **
59  *b Returns:
60  **
61  ** name of the path shape
62  */
63  const char* get_name();
64 
65  /*l
66  *b Description:
67  **
68  ** This function sets the name of this object.
69  **
70  *b Returns:
71  **
72  ** 0 on success, -1 on failure
73  */
74  int set_name(const char* name);
75 
76  /*l
77  *b Description:
78  **
79  ** All path shapes are assigned a unique identifier, or uid. This
80  ** function returns this path shape's uid.
81  **
82  ** *Note*: unique identifiers will change between DI-Guy runs!
83  **
84  *b Returns:
85  **
86  ** unique identifier of object
87  */
88  long get_uid();
89 
90  /*l
91  *b Description:
92  **
93  ** This function determines what happens to objects following this
94  ** path when they reach the end.
95  **
96  ** If 1, the object is restricted to stay at the end of the path.
97  **
98  ** If 0, the object will wrap to the beginning of the path.
99  **
100  *b Arguments:
101  **
102  *a value - 1 to clamp, 0 to wrap
103  **
104  *b Returns:
105  **
106  ** 0 on success, -1 on failure
107  */
108  int set_clamp_at_end_flag(int value);
109 
110  /*l
111  *b Returns:
112  **
113  ** most recent setting of set_clamp_at_end_flag().
114  */
115  int get_clamp_at_end_flag();
116 
117  /*l
118  *b Description:
119  **
120  ** This function should be called after all modifications have
121  ** been made to the path shape and its waypoints and it is time
122  ** to re-derive the overall path shape.
123  **
124  ** This update is deferred for reasons of performance; if there
125  ** are a lot of modifications to be made to the path shape they can
126  ** all be done in a group with only a single final update.
127  **
128  ** A call to update() is typically required after certain calls
129  ** are made on objects owned by the path, such as a diguyWaypoint.
130  ** The documentation for function calls of these objects will state
131  ** whether a subsequent update() call is necessary.
132  **
133  *b Returns:
134  **
135  ** 0 on success, -1 on failure
136  */
137  int update();
138 
139  /*l
140  *b Description:
141  **
142  ** This function returns the total length of the path
143  ** shape, in meters.
144  **
145  *b Returns:
146  **
147  ** length of path shape in meters
148  */
149  float get_length();
150 
151  /*l
152  *b Description:
153  **
154  ** This function returns, via the passed variable pointers,
155  ** the position and orientation of the point on the path shape
156  ** at the specified distance.
157  **
158  *b Arguments:
159  **
160  *a distance_into_path_shape - distance in meters into path shape
161  *a of the desired point
162  *a x, y, z - position of point in meters from the origin
163  *a rz, rx, ry - orientation of point in degrees counter-clockwise
164  *a from the positive X axis
165  **
166  *b Returns:
167  **
168  ** 0 on success, -1 on failure
169  */
170  int get_point_at_distance(float distance_into_path_shape,
171  float* x, float* y, float* z,
172  float* rz, float* rx, float* ry);
173 
174 
175 /*****************************************************************************/
185  /*l
186  *b Returns:
187  *
188  ** the number of waypoints belonging to this path shape
189  */
190  int get_num_waypoints();
191 
192  /*l
193  *b Description:
194  **
195  ** This function gets the waypoint at the specified
196  ** index and returns a pointer to it. The returned
197  ** waypoint can then be queried for information or
198  ** modified.
199  **
200  ** Note that if the waypoint is modified, the update()
201  ** function must be called to update the path shape.
202  **
203  *b Arguments:
204  **
205  *a index - index of the waypoint; indices start at 0
206  **
207  *b Returns:
208  **
209  ** pointer of type diguyWaypoint; NULL if no
210  ** waypoint at the specified index
211  */
212  diguyWaypoint* get_waypoint_at_index(int index);
213 
214  /*l
215  *b Description:
216  **
217  ** This function creates a new waypoint that is added to the
218  ** path shape. Do not call diguyScenario::destroy_waypoint() on
219  ** the returned waypoint; it will be destroyed automatically
220  ** with the path shape.
221  **
222  *b Arguments:
223  **
224  *a tx, ty, tz - position in meters from the origin
225  *a rz, rx, ry - orientations in degrees counter-clockwise
226  *a from the positive X axis
227  *a weight - how much influence this waypoint exerts
228  *a over the path curve
229  *a index - where the waypoint should be inserted in
230  *a the path shape; indices start at 0; pass -1 to
231  *a add to end of path shape
232  **
233  *b Returns:
234  **
235  ** pointer to type diguyWaypoint
236  */
237  diguyWaypoint* create_waypoint(float x = 0.0f, float y = 0.0f, float z = 0.0f,
238  float yaw = 0.0f, float roll = 0.0f, float pitch = 0.0f,
239  float weight = 1.0f,
240  int index = -1);
241 
242  /*l
243  *b Description:
244  **
245  ** This function adds a waypoint to the path shape.
246  **
247  ** The waypoint should be created using the function
248  ** diguyScenario::create_waypoint(), and destroyed
249  ** using the function diguyScenario::destroy_waypoint().
250  **
251  ** An internal copy of the waypoint is made, so it can
252  ** be destroyed right after this function call or used
253  ** for other path shapes.
254  **
255  *b Arguments:
256  **
257  *a waypoint - waypoint to be appended to end of path
258  **
259  *b Returns:
260  **
261  ** 0 on success, -1 on failure
262  */
263  int add_waypoint(diguyWaypoint* waypoint);
264 
265  /*l
266  *b Description:
267  **
268  ** This function destroys a waypoint on the path.
269  **
270  *b Arguments:
271  **
272  *a waypoint - waypoint to be deleted
273  **
274  *b Returns:
275  **
276  ** 0 on success, -1 on failure
277  */
278  int destroy_waypoint(diguyWaypoint* waypoint);
279 /*****************************************************************************/
289  /*l
290  *b Description:
291  **
292  ** This function tells the Navmesh regions to use this path as a
293  ** connection between two regions. The Navmesh should automatically
294  ** choose the regions closest to the start and end points of the
295  ** path. By default this functionality is off, but once activated
296  ** it's assumed to be a two way connection.
297  **
298  *b Arguments:
299  **
300  *a use_as_portal - 1 to use as a connection, 0 to not
301  */
302  void set_use_as_navmesh_portal(int use_as_portal);
303 
304  /*l
305  *b Description:
306  **
307  ** This function returns if the path is being used as a connection
308  ** between two regions.
309  **
310  *b Returns:
311  **
312  *a 1 if is a connection, 0 if not
313  */
314  int get_use_as_navmesh_portal();
315 
316  /*l
317  *b Description:
318  **
319  ** This function tells the Navmesh regions to use this path as a one
320  ** way connection between two regions. Defaults to 0 (two way
321  ** connection)
322  **
323  *b Arguments:
324  **
325  *a one_way - 1 to set as one way connection, 0 to set as
326  *a bidirectional
327  */
328  void set_one_way_portal(int one_way);
329 
330  /*l
331  *b Description:
332  **
333  ** This function returns if the path is being used as a one way
334  ** connection between two regions.
335  **
336  *b Returns:
337  **
338  *a 1 if is one way connection, 0 if two way
339  */
340  int get_one_way_portal();
341 
342 
343 /****************************************************************************/
344 /****************************************************************************/
345 /****************************************************************************/
352 /****************************************************************************/
353 /****************************************************************************/
354 /****************************************************************************/
356  int translate(float tx, float ty, float tz);
358  int rotate_about_point(float rz, float rx, float ry,
359  float rotation_pt_x, float rotation_pt_y, float rotation_pt_z);
360 
361  int set_ground_clamp_when_on_path(int ground_clamp_when_on_path);
362  int get_ground_clamp_when_on_path();
363 
368 #ifdef CPLUSPLUS_ONLY
369 
370  bdiScenarioPathShape* get_scripted_object() {return m_path_shape;}
371 
372 private:
373 
374  /*l
375  ** A private constructor.
376  */
377  diguyPathShape(bdiScenarioPathShape* path_shape);
378 
379  /*l
380  ** A pointer to internal data.
381  */
382  bdiScenarioPathShape* m_path_shape;
383 
384  friend class bdiScenarioPathShape;
385  friend class diguyScenario;
386 
387 #endif
388 
389 };
390 
391 #endif /* __diguyPathShape_H */
392 
Represents a scriptable api wrapping a diguy path shape, a curve defined by with a number of waypoint...
Definition: diguyPathShape.h:36
Represents the scenario currently being portrayed.
Definition: diguyScenario.h:99
Represents a scriptable api wrapping a 3D point on a path.
Definition: diguyWaypoint.h:35