C++ SDK Reference  12.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyAuthorInterface.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 #ifndef __diguyAuthorInterface_H
30 #define __diguyAuthorInterface_H
31 
32 #ifdef SWIG
34 #else
35 #define CPLUSPLUS_ONLY
36 #endif
37 
38 #ifdef CPLUSPLUS_ONLY
41 class diguyCharacter;
42 class diguyCharacterPath;
43 class diguyGraphicsLink;
44 class diguyGraphicsShape;
45 class diguyPathShape;
46 class diguyWaypoint;
47 class bdiScenarioEditorInput;
48 
49 typedef diguyAuthorInterface* diguyAuthorInterfaceCreateFunc(void* internal_data);
50 
51 #include <stdio.h>
52 #include <declspec_diguy.h>
53 #include <diguy_constants.h>
55 
56 #define AUTHOR_UI_MAIN_WINDOW_NAME "main_window"
57 #define AUTHOR_UI_INPUT_MODE_WINDOW_NAME "input_mode"
58 #define AUTHOR_UI_TIME_CONTROL_WINDOW_NAME "time_control"
59 #define AUTHOR_UI_LOG_WINDOW_NAME "log"
60 #define AUTHOR_UI_VISIBILITY_WINDOW_NAME "visibility"
61 #define AUTHOR_UI_ELEMENTS_WINDOW_NAME "elements"
62 #define AUTHOR_UI_CHARACTER_WINDOW_NAME "character"
63 #define AUTHOR_UI_CROWD_WINDOW_NAME "crowd"
64 #define AUTHOR_UI_MIND_EDITOR_WINDOW_NAME "mind_editor"
65 #define AUTHOR_UI_AI_INSPECTOR_WINOW_NAME "ai_inspector"
66 
67 
68 #endif
69 
70 
71 /*********************************************************************/
83 class BDI_DECLSPEC_diguy diguyAuthorInterface
84 {
85 
86 public:
87 
88  /*l
89  ** Returns a pointer to the region paintbrush. Returned pointer may be
90  ** NULL.
91  */
92  diguyAuthorVisualRegionPaintbrush* get_region_paintbrush();
93 
94 
95 /*****************************************************************************/
109  /*l
110  *b Description:
111  **
112  ** Sets the current position of the mouse in screen coordinates.
113  **
114  ** This should be done whenever a DI-Guy input mode is active and the
115  ** mouse moves.
116  **
117  ** Note that nothing is done with this information until
118  ** apply_mouse_inputs() is called.
119  **
120  *b Arguments:
121  **
122  *a x - horizontal pixel from left edge of window
123  *a y - vertical pixel from bottom edge of window
124  */
125  void set_mouse_screen_coordinates(int x, int y);
126 
127  /*l
128  *b Description:
129  **
130  ** Sets the current position of the mouse in world coordinates. This
131  ** should be the intersection point of the ray that would begin at
132  ** the mouse's screen position, and extend into the far distance (at
133  ** least as far as the graphics far plane).
134  **
135  ** This should be done whenever a DI-Guy input mode is active, and a
136  ** point in the 3D world is requested, such as during a call to
137  ** convert_screen_to_world().
138  **
139  ** Note that nothing is done with this information until
140  ** apply_mouse_inputs() is called.
141  **
142  *b Arguments:
143  **
144  *a world_coords - mouse position in world coordinates, in meters from
145  *a the origin
146  */
147  void set_mouse_world_coordinates(diguyVec3f world_coords);
148 
149  /*l
150  *b Description:
151  **
152  ** Sets the current state of the left mouse button.
153  **
154  ** This should be done whenever a DI-Guy input mode is active and the
155  ** a mouse button is pressed.
156  **
157  ** Note that nothing is done with this information until
158  ** apply_mouse_inputs() is called.
159  **
160  *b Arguments:
161  **
162  *a button_state - 1 for down, 0 for up
163  */
164  void set_mouse_button_l(int button_state);
165 
166  /*l
167  *b Description:
168  **
169  ** Same as set_mouse_button_l(), but for the right mouse button.
170  */
171  void set_mouse_button_r(int button_state);
172 
173  /*l
174  *b Description:
175  **
176  ** Same as set_mouse_button_m(), but for the middle mouse button.
177  */
178  void set_mouse_button_m(int button_state);
179 
180  /*l
181  *b Description:
182  **
183  ** Sets the change in the mouse wheel position since the last call
184  ** to this function.
185  **
186  ** This should be done whenever a DI-Guy input mode is active and the
187  ** the mouse wheel is moved.
188  **
189  ** Note that nothing is done with this information until
190  ** apply_mouse_inputs() is called.
191  **
192  *b Arguments:
193  **
194  *a mouse_wheel_change - (units documentation pending)
195  */
196  void set_mouse_wheel_change(float mouse_wheel_change);
197 
198  /*l
199  *b Description:
200  **
201  ** Applies effects of inputs set by set_mouse_screen_coordinates(),
202  ** set_mouse_button_l(), etc. DI-Guy Author will make modifications
203  ** on edited objects based on these inputs.
204  */
205  void apply_mouse_inputs();
206 
207 
208 /*****************************************************************************/
226  /*l
227  *b Description:
228  **
229  ** Sets the current state of the shift key. The shift key can change
230  ** the results of mouse inputs in the 3D window.
231  **
232  ** This should be done whenever a DI-Guy input mode is active and the
233  ** state of the shift key changes.
234  **
235  *b Arguments:
236  **
237  *a key_state - 1 for down, 0 for up
238  */
239  void set_keyboard_shift(int key_state);
240 
241  /*l
242  *b Description:
243  **
244  ** Same as set_keyboard_shift(), but for ctrl key.
245  */
246  void set_keyboard_ctrl(int key_state);
247 
248  /*l
249  *b Description:
250  **
251  ** Same as set_keyboard_alt(), but for alt key.
252  */
253  void set_keyboard_alt(int key_state);
254 
255  /*l
256  *b Description:
257  **
258  ** Sets the current state of the speficied key. Key presses can
259  ** change the input mode, cause a reset, load camera settings, etc.
260  **
261  ** *Note:* Often it will be better for the Host IG to handle key
262  ** presses and make the appropriate DI-Guy calls manually.
263  **
264  *b Arguments:
265  **
266  *a key - ASCII code of pressed key
267  *a key_state - 1 for down, 0 for up
268  */
269  void set_key_pressed(int key, int key_state);
270 
271 
272 /*****************************************************************************/
286  /*l
287  *b Description:
288  **
289  ** Sets the current selected DI-Guy object based on the passed uid.
290  ** If the uid matches an object in the scenario, that object will
291  ** become the selected object.
292  **
293  ** This function is typically called during a
294  ** update_selected_objects() call.
295  **
296  ** The type of object the uid is associated with can be determined by
297  ** calling get_uid_base_type().
298  **
299  ** DI-Guy Author will internally decide what the uid code means, and
300  ** set its selected object pointers appropriately. The get_selected_*
301  ** functions below (e.g., get_selected_character()) will return
302  ** objects that are selected as a result of this call. Calling this
303  ** function will un-select all other objects, even if they are of
304  ** different types.
305  **
306  ** Note, however, that in some cases multiple objects may become
307  ** selected, if the uid of the object is for an object owned by
308  ** another. For example, selecting a waypoint will also select the
309  ** waypoint's path, and the path's character.
310  **
311  *b Arguments:
312  **
313  *a uid - unique identifier of selected object
314  **
315  *b Returns:
316  **
317  ** 1 if uid is valid, 0 if not (e.g., no such object)
318  */
319  int set_selected_diguy_uid(long uid);
320 
321  /*l
322  *b Description:
323  **
324  ** Same as set_selected_diguy_uid(), but with uid in string form.
325  */
326  int set_selected_diguy_uid_from_string(const char* uid_string);
327 
328  /*l
329  *b Description:
330  **
331  ** Returns a value that describes the object type associated with the
332  ** passed uid. The returned value will be one of the
333  ** DIGUY_TYPE_UID_BASE_* values listed in diguy_constants.h; e.g.,
334  ** a return value of DIGUY_TYPE_UID_BASE_CHARACTER means that the
335  ** uid is associated with a diguyCharacter object.
336  **
337  ** DIGUY_TYPE_UID_BASE_NOTHING is returned if the passed value is not
338  ** a valid DI-Guy uid.
339  **
340  *b Arguments:
341  **
342  *a uid - unique identifier to be checked
343  **
344  *b Returns:
345  **
346  ** uid base type enumeration
347  */
348  int get_uid_base_type(long uid);
349 
350  /*l
351  *b Description:
352  **
353  ** Same as get_uid_base_type(), but with uid in string form.
354  */
355  int get_uid_base_type_from_string(const char* uid_string);
356 
357  /*l
358  *b Description:
359  **
360  ** Returns the character that was selected as a result of calling
361  ** set_selected_diguy_uid().
362  **
363  *b Returns:
364  **
365  ** pointer to type diguyCharacter
366  */
367  diguyCharacter* get_selected_character();
368 
369  /*l
370  *b Description:
371  **
372  ** diguyCharacterPath version of get_selected_character().
373  */
374  diguyCharacterPath* get_selected_character_path();
375 
376  /*l
377  *b Description:
378  **
379  ** diguyWaypoint version of get_selected_character().
380  */
381  diguyWaypoint* get_selected_waypoint();
382 
383  /*l
384  *b Description:
385  **
386  ** diguyPathShape version of get_selected_character().
387  */
388  diguyPathShape* get_selected_path_shape();
389 
390  /*l
391  *b Description:
392  **
393  ** diguyGraphicsLink version of get_selected_character().
394  */
395  diguyGraphicsLink* get_selected_link();
396 
397  /*l
398  *b Description:
399  **
400  ** diguyGraphicsShape version of get_selected_character().
401  */
402  diguyGraphicsShape* get_selected_shape();
403 
404 
405 /*****************************************************************************/
425  /*l
426  *b Description:
427  **
428  ** This function will be called when DI-Guy Author nneds to know the
429  ** world position behind the given screen coordinate.
430  **
431  ** See above for information on the world and screen coordinate
432  ** systems.
433  **
434  ** A typical implementation will construct a ray with its beginning at
435  ** the world coordinate corresponding to the screen coordinate,
436  ** projected some distance into the world using a camera projection
437  ** matrix.
438  **
439  *b Arguments:
440  **
441  *a screen_xyz - screen coordinates as described above
442  *a world_xyz - return value world intersection point
443  **
444  *b Returns:
445  **
446  ** 1 if an intersection occurred, 0 if not
447  */
448  virtual int convert_screen_to_world(const diguyVec3f& screen_xyz,
449  diguyVec3f* world_xyz) = 0;
450 
451  /*l
452  *b Description:
453  **
454  ** This function is the inverse of convert_screen_to_world(). It
455  ** takes a world position and returns the corresponding screen
456  ** coordinate.
457  **
458  *b Arguments:
459  **
460  *a world_xyz - point in world coordinates
461  *a screen_xyz - return value screen coordinate that covers that point
462  **
463  *b Returns:
464  **
465  ** 1 if an intersection occurred, 0 if not
466  */
467  virtual int convert_world_to_screen(const diguyVec3f& world_xyz,
468  diguyVec3f* screen_xyz) = 0;
469 
470  virtual float get_altitude(float x, float y, float old_z,
471  float from_height = 10.0f,
472  int* valid_result = NULL) = 0;
473 
474  /*
475  * In overridden function call set_selected_diguy_uid() or
476  * set_selected_diguy_uid_from_string()
477  */
478  virtual int update_selected_objects(const diguyVec3f& screen_xyz) = 0;
479 
480  virtual int check_z_clearance(const diguyVec3f& pos,
481  const float radius,
482  const float ground_angle,
483  float z_clear_height,
484  int check_below = 1) const = 0;
485 
486 
487 /*****************************************************************************/
499  /*l
500  *b Description:
501  **
502  ** Calling this function will tell the DI-Guy Author UI to show or
503  ** hide the specified window.
504  **
505  *b Arguments:
506  **
507  *a window_name - name of the window to show or hide
508  *a visible - pass 1 to show the window, 0 to hide it
509  **
510  ** Currently valid window names are:
511  **
512  *- - "input_mode"
513  *- - "time_control"
514  *- - "log"
515  *- - "elements"
516  */
517  int set_author_ui_window_visible(const char* window_name, int visible);
518 
519  /*l
520  *b Returns:
521  **
522  ** 1 if the specified DI-Guy Author UI window is shown, 0 if not
523  **
524  *b Arguments:
525  **
526  *a window_name - name of the window to show or hide
527  */
528  int get_author_ui_window_visible(const char* window_name);
529 
530  /*l
531  *b Description:
532  **
533  ** Calling this function will tell the DI-Guy Author UI to show
534  ** the specified panel in the elements window.
535  **
536  *b Arguments:
537  **
538  *a panel_name - name of the window to show or hide
539  **
540  ** Currently valid window names are:
541  **
542  *- - "Character"
543  *- - "Crowd"
544  */
545  int set_author_ui_panel_visible(const char* panel_name);
546 
547  /*l
548  *b Description:
549  **
550  ** Calling this function will tell the DI-Guy Author UI to select
551  ** the specified character in the crowd page.
552  **
553  *b Arguments:
554  **
555  *a character - name of the character to select in the crowd window
556  **
557  */
558  int set_author_ui_select_crowd_character(diguyCharacter* character);
559 
560  /*l
561  *b Description:
562  **
563  ** Calling this function will tell the DI-Guy Author UI to select
564  ** the specified script for the character.
565  **
566  *b Arguments:
567  **
568  *a character - name of the character to select in the crowd window
569  **
570  */
571  int set_author_ui_select_code_browser_script(diguyCharacter* character);
572 
573 
574 
575 
576 /*****************************************************************************/
588 #ifdef CPLUSPLUS_ONLY
589 
590  /*l
591  *b Description:
592  **
593  ** Called if the named window in the Author UI application changes
594  ** visibility state.
595  */
596  virtual void author_ui_window_visibility_changed(const char* window_name,
597  int is_visible);
598 
599 #endif
600 
601 
602 /*****************************************************************************/
634 #ifdef CPLUSPLUS_ONLY
635 
636  /*l
637  *b Description:
638  **
639  ** Generates vertices for a sphere with the passed radius. The
640  ** data returned in the vertices, normals, texture_indices, and
641  ** indices pointers must be deleted using delete_generated_vertices().
642  **
643  ** Untransformed, the sphere's center will be at the local origin.
644  **
645  ** The slices will radiate around the z axis. The stacks will be
646  ** along the z axis.
647  **
648  *b Arguments:
649  **
650  *a radius - (input) radius of sphere, in meters
651  *a num_slices - (input) number of radial slices; think slices in
652  *a a cake
653  *a num_layers - (input) number of vertical layers; think layers
654  *a in a cake
655  *a position_offset - (input) position offset of sphere from local
656  *a origin, in meters
657  *a orientation - (input) orientation offset of sphere about local
658  *a origin, in degrees
659  *a num_vertices - (output) number of generated vertices
660  *a vertices - (output) vertex data
661  *a normals - (output) normal data
662  *a texture_indices - (output) texture index data (not currently used)
663  *a indices_for_wireframe - (input) pass 1 if vertices are for a
664  *a wireframe object that will be represented be
665  *a line segments, 0 if the vertices are for a
666  *a solid object represented by polygons
667  *a num_indices - (output) number of indices telling how vertices
668  *a connect
669  *a indices - (output) data on how vertices connect
670  **
671  *b Returns:
672  **
673  ** 0 on success, -1 on error
674  */
675  static int generate_sphere_vertices(float radius,
676  int num_slices,
677  int num_layers,
678  const diguyVec3f& position_offset,
679  const diguyVec3f& orientation, // degrees
680  int* num_vertices,
681  diguyVec3f** vertices,
682  diguyVec3f** normals,
683  diguyVec2f** texture_indices,
684  int indices_for_wireframe,
685  int* num_indices,
686  unsigned int** indices);
687 
688  /*l
689  *b Description:
690  **
691  ** Similar to generate_sphere_vertices(), but for cones.
692  **
693  ** Untransformed, the cone's base will be at the local origin, with
694  ** the point tapering in positive z.
695  **
696  ** The slices will radiate around the z axis. The stacks will be
697  ** along the z axis.
698  */
699  static int generate_cone_vertices(float radius,
700  float height,
701  int num_slices,
702  int num_layers,
703  const diguyVec3f& position_offset,
704  const diguyVec3f& orientation, // degrees
705  int* num_vertices,
706  diguyVec3f** vertices,
707  diguyVec3f** normals,
708  diguyVec2f** texture_indices,
709  int indices_for_wireframe,
710  int* num_indices,
711  unsigned int** indices);
712 
713  /*l
714  *b Description:
715  **
716  ** Similar to generate_sphere_vertices(), but for cylinders.
717  **
718  ** Untransformed, the cylinder's base will be at the local origin,
719  ** the top above the base in positive z.
720  **
721  ** The slices will radiate around the z axis. The stacks will be
722  ** along the z axis.
723  */
724  static int generate_cylinder_vertices(float radius,
725  float height,
726  int num_slices,
727  int num_layers,
728  const diguyVec3f& position_offset,
729  const diguyVec3f& orientation, // degrees
730  int* num_vertices,
731  diguyVec3f** vertices,
732  diguyVec3f** normals,
733  diguyVec2f** texture_indices,
734  int indices_for_wireframe,
735  int* num_indices,
736  unsigned int** indices);
737 
738  /*l
739  *b Description:
740  **
741  ** Similar to generate_sphere_vertices(), but for boxes, AKA
742  ** rectangular solids.
743  **
744  ** Untransformed, the box's corners are represented by the passed min
745  ** and max vectors, relative to the local origin.
746  */
747  static int generate_box_vertices(diguyVec3f min,
748  diguyVec3f max,
749  const diguyVec3f& position_offset,
750  const diguyVec3f& orientation, // degrees
751  int* num_vertices,
752  diguyVec3f** vertices,
753  diguyVec3f** normals,
754  diguyVec2f** texture_indices,
755  int indices_for_wireframe,
756  int* num_indices,
757  unsigned int** indices);
759  /*l
760  *b Description:
761  **
762  ** For deleting data generated by the various generate_*_vertices()
763  ** functions.
764  */
765  static void delete_generated_vertices(diguyVec3f* vertices,
766  diguyVec3f* normals,
767  diguyVec2f* texture_indices,
768  unsigned int* indices);
769 
770 #endif
771 
772 /****************************************************************************/
773 /****************************************************************************/
774 
779 #ifdef CPLUSPLUS_ONLY
780 
781  bdiScenarioEditorInput* get_scripted_object() {return m_scripted_object;}
782 
783 protected:
784 
785  // protected constructor
786  diguyAuthorInterface(void* internal_data);
787 
788  // protected destructor
789  virtual ~diguyAuthorInterface();
790 
791  // pointer to internal data
792  friend class bdiScenarioApp;
793  friend class bdiScenarioEditorInput;
794  bdiScenarioEditorInput* m_scripted_object;
795 
796  static diguyAuthorInterfaceCreateFunc* s_create_func;
797 
798 #endif
799 
800 };
801 
802 #endif /* __diguyAuthorInterface_H */
803