DI-Guy C++ SDK Reference  13.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyRegion.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 diguyRegion
11  **
12  *b Link against: libdiguy
13  **
14  *b Summary
15  **
16  ** API for accessing diguyRegion objects generated by the crowd
17  ** and region painter.
18  **
19  ** For information on subregions, see the documentation for the
20  ** diguySubregionIndex and diguySubregionMask enumerations in
21  ** diguy_constants.h.
22  */
23 
24 #ifndef __diguyRegion_H
25 #define __diguyRegion_H
26 
27 
28 #ifdef SWIG
29 %module diguyRegion
30 #else
31 #define CPLUSPLUS_ONLY
32 #endif
33 
34 #ifdef CPLUSPLUS_ONLY
35 class bdiNavMeshRegionInterface;
36 
37 #endif
38 
39 
40 #include <declspec_diguy.h>
41 #include <diguy_constants.h>
42 
43 /*********************************************************************/
44 class BDI_DECLSPEC_diguy diguyRegion
45 {
46 
47 public:
48 
49 /*****************************************************************************/
55  /*l
56  *b Description:
57  **
58  ** Returns the name of the region. This pointer will
59  ** never be NULL.
60  **
61  *b Returns:
62  **
63  ** name of the region
64  **
65  *b Callable From:
66  **
67  *- - C++
68  *- - Script
69  */
70  const char* get_name();
71 
72  /*l
73  **
74  *b Description:
75  **
76  ** Returns 1 if a point is approximately inside the region. Supports
77  ** multiple subregions via or'ing masks together.
78  **
79  ** Use the base mask (DIGUY_SUBREGION_MASK_BASE) to test against the
80  ** base of the region.
81  **
82  *b Returns:
83  **
84  ** 1 if the point is in the region, 0 if not
85  **
86  *b Callable From:
87  **
88  *- - C++
89  *- - Script
90  */
91  int is_point_in_region(diguySubregionMask subregion_mask,
92  float x, float y, float z);
93 
94  /*l
95  **
96  **
97  *b Description:
98  **
99  ** Returns a random x, y, z point in the region specified. This
100  ** function takes a region index (e.g. DIGUY_SUBREGION_BASE).
101  **
102  *b Arguments:
103  **
104  *a subregion_index - subregion in which to find the point
105  *a res_x, res_y, res_z - return point
106  **
107  *b Returns:
108  **
109  ** 0 if a point was successfully generated, -1 on failure
110  **
111  *b Callable From:
112  **
113  *- - C++
114  *- - Script
115  */
116  int get_point_in_region(diguySubregionIndex subregion_index,
117  float* res_x, float* res_y, float* res_z);
118 
119  /*l
120  **
121  *b Description:
122  **
123  ** Returns a random x, y, z point, near the seed location, in the
124  ** subregion specified.
125  **
126  *b Arguments:
127  **
128  *a subregion_index - subregion in which to find the point
129  *a seed_x, seed_y, seed_z - location to use as the seed point
130  *a radius - radius around the seed point within which
131  *a the result point should be located
132  *a res_x, res_y, res_z - return point
133  *a
134  *b Returns:
135  **
136  ** 0 if a point was successfully generated, -1 on failure
137  **
138  *b Callable From:
139  **
140  *- - C++
141  *- - Script
142  */
143  int get_point_in_region_near_point(diguySubregionIndex subregion_index,
144  float seed_x, float seed_y, float seed_z,
145  float radius,
146  float* res_x, float* res_y, float* res_z);
147 
148  /*l
149  **
150  *b Description:
151  **
152  ** Returns the nearest point in the region near the seed location,
153  ** in the subregion(s) specified.
154  **
155  *b Arguments:
156  **
157  *a subregion_mask - subregion(s) to search
158  *a seed_x, seed_y, seed_z - location to use as the search seed point
159  *a res_x, res_y, res_z - return point
160  **
161  *b Returns:
162  **
163  ** 0 if a point was successfully generated, -1 on failure
164  **
165  *b Callable From:
166  **
167  *- - C++
168  *- - Script
169  */
170  int get_nearest_point_in_region(diguySubregionMask subregion_mask,
171  float seed_x, float seed_y, float seed_z,
172  float* res_x, float* res_y, float* res_z);
173 
174  /*l
175  **
176  *b Description:
177  **
178  ** Returns the nearest reachable point to the seed location, inside
179  ** the subregion(s) specified by the mask.
180  **
181  ** Determining reachability involves guaranteeing that there is a
182  ** contiguous section of the base region between the seed point
183  ** and the resulting point.
184  **
185  *b Arguments:
186  **
187  *a subregion_mask - the subregion(s) to search
188  *a seed_x, seed_y, seed_z - the location to use as the search seed point
189  *a res_x, res_y, res_z - return point
190  **
191  *b Returns:
192  **
193  ** 0 if a point was successfully found, -1 on failure
194  **
195  *b Callable From:
196  **
197  *- - C++
198  *- - Script
199  */
200  int get_nearest_reachable_point(diguySubregionMask subregion_mask,
201  float seed_x, float seed_y, float seed_z,
202  float* res_x, float* res_y, float* res_z);
203 
204  /*l
205  *b Returns:
206  **
207  ** the number of rows in the region
208  **
209  *b Callable From:
210  **
211  *- - C++
212  *- - Script
213  */
214  int get_num_rows();
215 
216  /*l
217  *b Returns:
218  **
219  ** the number of columns in the region
220  **
221  *b Callable From:
222  **
223  *- - C++
224  *- - Script
225  */
226  int get_num_columns();
227 
228  /*l
229  *b Returns:
230  **
231  ** the resolution of the region in meters per point
232  **
233  *b Callable From:
234  **
235  *- - C++
236  *- - Script
237  */
238  float get_resolution();
239 
240  /*l
241  *b Description:
242  **
243  ** This function returns a random factor between 0 and 1 computed for
244  ** this region. This number can be used, for example, to modify
245  ** colors or depths of region visuals.
246  **
247  ** The number will remain the same for the lifetime of the region.
248  **
249  *b Returns:
250  **
251  ** a random factor between 0 and 1
252  **
253  *b Callable From:
254  **
255  *- - C++
256  *- - Script
257  */
258  float get_random_factor();
259 
260 
261 /*****************************************************************************/
267  /*l
268  **
269  *b Description:
270  **
271  ** Shrinks the region's bounds to just the area with tagged data in
272  ** it. Can help conserve memory. Currently always returns 0.
273  **
274  *b Callable From:
275  **
276  *- - C++
277  *- - Script
278  */
279  int shrink();
280 
281  /*l
282  **
283  *b Description:
284  **
285  ** Erases all region data and then shrinks the region.
286  **
287  *b Callable From:
288  **
289  *- - C++
290  *- - Script
291  */
292  int clear_region();
293 
294  /*l
295  **
296  *b Description:
297  **
298  ** Erases all subregion data and then shrinks the region.
299  **
300  *b Callable From:
301  **
302  *- - C++
303  *- - Script
304  */
305  int clear_subregion(diguySubregionIndex subregion_index);
306 
307  /*l
308  **
309  *b Description:
310  **
311  ** Resamples the mesh and sets the resolution of the mesh to the new
312  ** resolution.
313  **
314  ** Note that the resampled data is currently rough and will probably
315  ** need to be touched up by hand. The system is currently limited to
316  ** creating meshes with a resolution of 0.25 meters per point.
317  **
318  *b Callable From:
319  **
320  *- - C++
321  *- - Script
322  */
323  int resample_mesh(float resolution);
324 
325  /*l
326  **
327  *b Description:
328  **
329  ** This function adds to the specified subregion with a spherical
330  ** brush centered at the specified point and with the specified
331  ** radius.
332  **
333  ** If you are doing a number of edits to the mesh at once, it's
334  ** preferable to wait until the last one before setting
335  ** force_visual_update to 1.
336  **
337  *b Callable From:
338  **
339  *- - C++
340  *- - Script
341  */
342  int paint(diguySubregionIndex subregion_index,
343  float x, float y, float z,
344  float radius,
345  int force_visual_update = 0);
346 
347  /*l
348  **
349  *b Description:
350  **
351  ** This function adds to the specified subregion with a rectangular
352  ** brush stretching from the min point to the max point specified.
353  **
354  ** If you are doing a number of edits to the mesh at once, it's
355  ** preferable to wait until the last one before setting
356  ** force_visual_update to 1.
357  **
358  *b Callable From:
359  **
360  *- - C++
361  *- - Script
362  */
363  int paint_rectangle(diguySubregionIndex subregion_index,
364  float min_x, float min_y, float min_z,
365  float max_x, float max_y, float max_z,
366  int force_visual_update = 0);
367 
368  /*l
369  **
370  *b Description:
371  **
372  ** This function removes from the specified subregion with a spherical
373  ** brush centered at the specified point and with the specified
374  ** radius.
375  **
376  ** If you are doing a number of edits to the mesh at once, it's
377  ** preferable to wait until the last one before setting
378  ** force_visual_update to 1.
379  **
380  ** Returns:
381  **
382  ** 1 if any points were erased, 0 if not
383  **
384  *b Callable From:
385  **
386  *- - C++
387  *- - Script
388  */
389  int erase(diguySubregionIndex subregion_index,
390  float x, float y, float z,
391  float radius,
392  int force_visual_update = 0);
393 
394  /*l
395  **
396  *b Description:
397  **
398  ** This function removes from the specified subregion with a
399  ** rectangular brush stretching from min point to the max point
400  ** specified.
401  **
402  ** If you are doing a number of edits to the mesh at once, it's
403  ** preferable to wait until the last one before setting
404  ** force_visual_update to 1.
405  **
406  ** Returns:
407  **
408  ** 1 if any points were erased, 0 if not
409  **
410  *b Callable From:
411  **
412  *- - C++
413  *- - Script
414  */
415  int erase_rectangle(diguySubregionIndex subregion_index,
416  float min_x, float min_y, float min_z,
417  float max_x, float max_y, float max_z,
418  int force_visual_update = 0);
419 
420  /*l
421  **
422  *b Description:
423  **
424  ** This function attempts to grow the region to encompass the min and
425  ** max points specified as well as determine the reachability of all
426  ** of those points at once. Note: the navmesh reachability algorithm
427  ** is not perfect and the results will probably need to be touched up
428  ** by hand.
429  **
430  *b Callable From:
431  **
432  *- - C++
433  *- - Script
434  */
435  int generate_navmesh(float min_x, float min_y, float min_z,
436  float max_x, float max_y, float max_z);
437 
438 
443 #ifdef CPLUSPLUS_ONLY
445  bdiNavMeshRegionInterface* get_scripted_object() {return m_scripted_object;}
446 
447 private:
448 
449  /*l
450  ** A private constructor.
451  */
452  diguyRegion(bdiNavMeshRegionInterface* scripted_object);
453 
454  /*l
455  ** A private destructor.
456  */
457  ~diguyRegion();
458 
459  /*l
460  ** A pointer to internal data.
461  */
462  bdiNavMeshRegionInterface* m_scripted_object;
463  friend class bdiNavMeshRegionInterface;
464  friend class bdiNavMeshRegion;
465 
466  float m_random_factor;
467 
468 #endif
469 
470 };
471 
472 
473 #endif /* __diguyRegion_H */
474 
475 
476 /*********************************************************************
477  ** Copyright (c) 1992-2014 VT MAK
478  ** All rights reserved.
479  *********************************************************************/
480