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