DI-Guy SDK Documentation  13.5
diguyAuthorInterface.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2020 MAK Technologies, Inc.
4  ** All rights reserved.
5  *********************************************************************/
6 
7 
8 
9 #ifndef __diguyAuthorInterface_H
10 #define __diguyAuthorInterface_H
11 
12 #ifdef SWIG
14 #else
15 #define CPLUSPLUS_ONLY
16 #endif
17 
18 #ifdef CPLUSPLUS_ONLY
21 class diguyCharacter;
22 class diguyCharacterPath;
23 class diguyGraphicsLink;
24 class diguyGraphicsShape;
25 class diguyPathShape;
26 class diguyWaypoint;
27 class bdiScenarioEditorInput;
28 
29 typedef diguyAuthorInterface* diguyAuthorInterfaceCreateFunc(void* internal_data);
30 
31 #include <stdio.h>
32 #include <declspec_diguy.h>
33 #include <diguy_constants.h>
35 
36 #define AUTHOR_UI_MAIN_WINDOW_NAME "main_window"
37 #define AUTHOR_UI_INPUT_MODE_WINDOW_NAME "input_mode"
38 #define AUTHOR_UI_TIME_CONTROL_WINDOW_NAME "time_control"
39 #define AUTHOR_UI_LOG_WINDOW_NAME "log"
40 #define AUTHOR_UI_VISIBILITY_WINDOW_NAME "visibility"
41 #define AUTHOR_UI_ELEMENTS_WINDOW_NAME "elements"
42 #define AUTHOR_UI_CHARACTER_WINDOW_NAME "character"
43 #define AUTHOR_UI_CROWD_WINDOW_NAME "crowd"
44 #define AUTHOR_UI_MIND_EDITOR_WINDOW_NAME "mind_editor"
45 #define AUTHOR_UI_AI_INSPECTOR_WINOW_NAME "ai_inspector"
46 
47 
48 #endif
49 
50 
51 /*********************************************************************/
63 class BDI_DECLSPEC_diguy diguyAuthorInterface
64 {
65 
66 public:
67 
68  /*l
69  ** Returns a pointer to the region paintbrush. Returned pointer may be
70  ** NULL.
71  */
72  diguyAuthorVisualRegionPaintbrush* get_region_paintbrush();
73 
74 
75 /*****************************************************************************/
89  /*l
90  *b Description:
91  **
92  ** Sets the current position of the mouse in screen coordinates.
93  **
94  ** This should be done whenever a DI-Guy input mode is active and the
95  ** mouse moves.
96  **
97  ** Note that nothing is done with this information until
98  ** apply_mouse_inputs() is called.
99  **
100  *b Arguments:
101  **
102  *a x - horizontal pixel from left edge of window
103  *a y - vertical pixel from bottom edge of window
104  */
105  void set_mouse_screen_coordinates(int x, int y);
106 
107  /*l
108  *b Description:
109  **
110  ** Sets the current position of the mouse in world coordinates. This
111  ** should be the intersection point of the ray that would begin at
112  ** the mouse's screen position, and extend into the far distance (at
113  ** least as far as the graphics far plane).
114  **
115  ** This should be done whenever a DI-Guy input mode is active, and a
116  ** point in the 3D world is requested, such as during a call to
117  ** convert_screen_to_world().
118  **
119  ** Note that nothing is done with this information until
120  ** apply_mouse_inputs() is called.
121  **
122  *b Arguments:
123  **
124  *a world_coords - mouse position in world coordinates, in meters from
125  *a the origin
126  */
127  void set_mouse_world_coordinates(diguyVec3f world_coords);
128 
129  /*l
130  *b Description:
131  **
132  ** Sets the current state of the left mouse button.
133  **
134  ** This should be done whenever a DI-Guy input mode is active and the
135  ** a mouse button is pressed.
136  **
137  ** Note that nothing is done with this information until
138  ** apply_mouse_inputs() is called.
139  **
140  *b Arguments:
141  **
142  *a button_state - 1 for down, 0 for up
143  */
144  void set_mouse_button_l(int button_state);
145 
146  /*l
147  *b Description:
148  **
149  ** Same as set_mouse_button_l(), but for the right mouse button.
150  */
151  void set_mouse_button_r(int button_state);
152 
153  /*l
154  *b Description:
155  **
156  ** Same as set_mouse_button_m(), but for the middle mouse button.
157  */
158  void set_mouse_button_m(int button_state);
159 
160  /*l
161  *b Description:
162  **
163  ** Sets the change in the mouse wheel position since the last call
164  ** to this function.
165  **
166  ** This should be done whenever a DI-Guy input mode is active and the
167  ** the mouse wheel is moved.
168  **
169  ** Note that nothing is done with this information until
170  ** apply_mouse_inputs() is called.
171  **
172  *b Arguments:
173  **
174  *a mouse_wheel_change - (units documentation pending)
175  */
176  void set_mouse_wheel_change(float mouse_wheel_change);
177 
178  /*l
179  *b Description:
180  **
181  ** Applies effects of inputs set by set_mouse_screen_coordinates(),
182  ** set_mouse_button_l(), etc. DI-Guy Author will make modifications
183  ** on edited objects based on these inputs.
184  */
185  void apply_mouse_inputs();
186 
187 
188 /*****************************************************************************/
206  /*l
207  *b Description:
208  **
209  ** Sets the current state of the shift key. The shift key can change
210  ** the results of mouse inputs in the 3D window.
211  **
212  ** This should be done whenever a DI-Guy input mode is active and the
213  ** state of the shift key changes.
214  **
215  *b Arguments:
216  **
217  *a key_state - 1 for down, 0 for up
218  */
219  void set_keyboard_shift(int key_state);
220 
221  /*l
222  *b Description:
223  **
224  ** Same as set_keyboard_shift(), but for ctrl key.
225  */
226  void set_keyboard_ctrl(int key_state);
227 
228  /*l
229  *b Description:
230  **
231  ** Same as set_keyboard_alt(), but for alt key.
232  */
233  void set_keyboard_alt(int key_state);
234 
235  /*l
236  *b Description:
237  **
238  ** Sets the current state of the speficied key. Key presses can
239  ** change the input mode, cause a reset, load camera settings, etc.
240  **
241  ** *Note:* Often it will be better for the Host IG to handle key
242  ** presses and make the appropriate DI-Guy calls manually.
243  **
244  *b Arguments:
245  **
246  *a key - ASCII code of pressed key
247  *a key_state - 1 for down, 0 for up
248  */
249  void set_key_pressed(int key, int key_state);
250 
251 
252 /*****************************************************************************/
266  /*l
267  *b Description:
268  **
269  ** Sets the current selected DI-Guy object based on the passed uid.
270  ** If the uid matches an object in the scenario, that object will
271  ** become the selected object.
272  **
273  ** This function is typically called during a
274  ** update_selected_objects() call.
275  **
276  ** The type of object the uid is associated with can be determined by
277  ** calling get_uid_base_type().
278  **
279  ** DI-Guy Author will internally decide what the uid code means, and
280  ** set its selected object pointers appropriately. The get_selected_*
281  ** functions below (e.g., get_selected_character()) will return
282  ** objects that are selected as a result of this call. Calling this
283  ** function will un-select all other objects, even if they are of
284  ** different types.
285  **
286  ** Note, however, that in some cases multiple objects may become
287  ** selected, if the uid of the object is for an object owned by
288  ** another. For example, selecting a waypoint will also select the
289  ** waypoint's path, and the path's character.
290  **
291  *b Arguments:
292  **
293  *a uid - unique identifier of selected object
294  **
295  *b Returns:
296  **
297  ** 1 if uid is valid, 0 if not (e.g., no such object)
298  */
299  int set_selected_diguy_uid(long uid);
300 
301  /*l
302  *b Description:
303  **
304  ** Same as set_selected_diguy_uid(), but with uid in string form.
305  */
306  int set_selected_diguy_uid_from_string(const char* uid_string);
307 
308  /*l
309  *b Description:
310  **
311  ** Returns a value that describes the object type associated with the
312  ** passed uid. The returned value will be one of the
313  ** DIGUY_TYPE_UID_BASE_* values listed in diguy_constants.h; e.g.,
314  ** a return value of DIGUY_TYPE_UID_BASE_CHARACTER means that the
315  ** uid is associated with a diguyCharacter object.
316  **
317  ** DIGUY_TYPE_UID_BASE_NOTHING is returned if the passed value is not
318  ** a valid DI-Guy uid.
319  **
320  *b Arguments:
321  **
322  *a uid - unique identifier to be checked
323  **
324  *b Returns:
325  **
326  ** uid base type enumeration
327  */
328  int get_uid_base_type(long uid);
329 
330  /*l
331  *b Description:
332  **
333  ** Same as get_uid_base_type(), but with uid in string form.
334  */
335  int get_uid_base_type_from_string(const char* uid_string);
336 
337  /*l
338  *b Description:
339  **
340  ** Returns the character that was selected as a result of calling
341  ** set_selected_diguy_uid().
342  **
343  *b Returns:
344  **
345  ** pointer to type diguyCharacter
346  */
347  diguyCharacter* get_selected_character();
348 
349  /*l
350  *b Description:
351  **
352  ** diguyCharacterPath version of get_selected_character().
353  */
354  diguyCharacterPath* get_selected_character_path();
355 
356  /*l
357  *b Description:
358  **
359  ** diguyWaypoint version of get_selected_character().
360  */
361  diguyWaypoint* get_selected_waypoint();
362 
363  /*l
364  *b Description:
365  **
366  ** diguyPathShape version of get_selected_character().
367  */
368  diguyPathShape* get_selected_path_shape();
369 
370  /*l
371  *b Description:
372  **
373  ** diguyGraphicsLink version of get_selected_character().
374  */
375  diguyGraphicsLink* get_selected_link();
376 
377  /*l
378  *b Description:
379  **
380  ** diguyGraphicsShape version of get_selected_character().
381  */
382  diguyGraphicsShape* get_selected_shape();
383 
384 
385 /*****************************************************************************/
405  /*l
406  *b Description:
407  **
408  ** This function will be called when DI-Guy Author nneds to know the
409  ** world position behind the given screen coordinate.
410  **
411  ** See above for information on the world and screen coordinate
412  ** systems.
413  **
414  ** A typical implementation will construct a ray with its beginning at
415  ** the world coordinate corresponding to the screen coordinate,
416  ** projected some distance into the world using a camera projection
417  ** matrix.
418  **
419  *b Arguments:
420  **
421  *a screen_xyz - screen coordinates as described above
422  *a world_xyz - return value world intersection point
423  **
424  *b Returns:
425  **
426  ** 1 if an intersection occurred, 0 if not
427  */
428  virtual int convert_screen_to_world(const diguyVec3f& screen_xyz,
429  diguyVec3f* world_xyz) = 0;
430 
431  /*l
432  *b Description:
433  **
434  ** This function is the inverse of convert_screen_to_world(). It
435  ** takes a world position and returns the corresponding screen
436  ** coordinate.
437  **
438  *b Arguments:
439  **
440  *a world_xyz - point in world coordinates
441  *a screen_xyz - return value screen coordinate that covers that point
442  **
443  *b Returns:
444  **
445  ** 1 if an intersection occurred, 0 if not
446  */
447  virtual int convert_world_to_screen(const diguyVec3f& world_xyz,
448  diguyVec3f* screen_xyz) = 0;
449 
450  virtual float get_altitude(float x, float y, float old_z,
451  float from_height = 10.0f,
452  int* valid_result = NULL) = 0;
453 
454  /*
455  * In overridden function call set_selected_diguy_uid() or
456  * set_selected_diguy_uid_from_string()
457  */
458  virtual int update_selected_objects(const diguyVec3f& screen_xyz) = 0;
459 
460  virtual int check_z_clearance(const diguyVec3f& pos,
461  const float radius,
462  const float ground_angle,
463  float z_clear_height,
464  int check_below = 1) const = 0;
465 
466 
467 /*****************************************************************************/
479  /*l
480  *b Description:
481  **
482  ** Calling this function will tell the DI-Guy Author UI to show or
483  ** hide the specified window.
484  **
485  *b Arguments:
486  **
487  *a window_name - name of the window to show or hide
488  *a visible - pass 1 to show the window, 0 to hide it
489  **
490  ** Currently valid window names are:
491  **
492  *- - "input_mode"
493  *- - "time_control"
494  *- - "log"
495  *- - "elements"
496  */
497  int set_author_ui_window_visible(const char* window_name, int visible);
498 
499  /*l
500  *b Returns:
501  **
502  ** 1 if the specified DI-Guy Author UI window is shown, 0 if not
503  **
504  *b Arguments:
505  **
506  *a window_name - name of the window to show or hide
507  */
508  int get_author_ui_window_visible(const char* window_name);
509 
510  /*l
511  *b Description:
512  **
513  ** Calling this function will tell the DI-Guy Author UI to show
514  ** the specified panel in the elements window.
515  **
516  *b Arguments:
517  **
518  *a panel_name - name of the window to show or hide
519  **
520  ** Currently valid window names are:
521  **
522  *- - "Character"
523  *- - "Crowd"
524  */
525  int set_author_ui_panel_visible(const char* panel_name);
526 
527  /*l
528  *b Description:
529  **
530  ** Calling this function will tell the DI-Guy Author UI to select
531  ** the specified character in the crowd page.
532  **
533  *b Arguments:
534  **
535  *a character - name of the character to select in the crowd window
536  **
537  */
538  int set_author_ui_select_crowd_character(diguyCharacter* character);
539 
540  /*l
541  *b Description:
542  **
543  ** Calling this function will tell the DI-Guy Author UI to select
544  ** the specified script for the character.
545  **
546  *b Arguments:
547  **
548  *a character - name of the character to select in the crowd window
549  **
550  */
551  int set_author_ui_select_code_browser_script(diguyCharacter* character);
552 
553 
554 
555 
556 /*****************************************************************************/
568 #ifdef CPLUSPLUS_ONLY
569 
570  /*l
571  *b Description:
572  **
573  ** Called if the named window in the Author UI application changes
574  ** visibility state.
575  */
576  virtual void author_ui_window_visibility_changed(const char* window_name,
577  int is_visible);
578 
579 #endif
580 
581 
582 /*****************************************************************************/
614 #ifdef CPLUSPLUS_ONLY
615 
616  /*l
617  *b Description:
618  **
619  ** Generates vertices for a sphere with the passed radius. The
620  ** data returned in the vertices, normals, texture_indices, and
621  ** indices pointers must be deleted using delete_generated_vertices().
622  **
623  ** Untransformed, the sphere's center will be at the local origin.
624  **
625  ** The slices will radiate around the z axis. The stacks will be
626  ** along the z axis.
627  **
628  *b Arguments:
629  **
630  *a radius - (input) radius of sphere, in meters
631  *a num_slices - (input) number of radial slices; think slices in
632  *a a cake
633  *a num_layers - (input) number of vertical layers; think layers
634  *a in a cake
635  *a position_offset - (input) position offset of sphere from local
636  *a origin, in meters
637  *a orientation - (input) orientation offset of sphere about local
638  *a origin, in degrees
639  *a num_vertices - (output) number of generated vertices
640  *a vertices - (output) vertex data
641  *a normals - (output) normal data
642  *a texture_indices - (output) texture index data (not currently used)
643  *a indices_for_wireframe - (input) pass 1 if vertices are for a
644  *a wireframe object that will be represented be
645  *a line segments, 0 if the vertices are for a
646  *a solid object represented by polygons
647  *a num_indices - (output) number of indices telling how vertices
648  *a connect
649  *a indices - (output) data on how vertices connect
650  **
651  *b Returns:
652  **
653  ** 0 on success, -1 on error
654  */
655  static int generate_sphere_vertices(float radius,
656  int num_slices,
657  int num_layers,
658  const diguyVec3f& position_offset,
659  const diguyVec3f& orientation, // degrees
660  int* num_vertices,
661  diguyVec3f** vertices,
662  diguyVec3f** normals,
663  diguyVec2f** texture_indices,
664  int indices_for_wireframe,
665  int* num_indices,
666  unsigned int** indices);
667 
668  /*l
669  *b Description:
670  **
671  ** Similar to generate_sphere_vertices(), but for cones.
672  **
673  ** Untransformed, the cone's base will be at the local origin, with
674  ** the point tapering in positive z.
675  **
676  ** The slices will radiate around the z axis. The stacks will be
677  ** along the z axis.
678  */
679  static int generate_cone_vertices(float radius,
680  float height,
681  int num_slices,
682  int num_layers,
683  const diguyVec3f& position_offset,
684  const diguyVec3f& orientation, // degrees
685  int* num_vertices,
686  diguyVec3f** vertices,
687  diguyVec3f** normals,
688  diguyVec2f** texture_indices,
689  int indices_for_wireframe,
690  int* num_indices,
691  unsigned int** indices);
692 
693  /*l
694  *b Description:
695  **
696  ** Similar to generate_sphere_vertices(), but for cylinders.
697  **
698  ** Untransformed, the cylinder's base will be at the local origin,
699  ** the top above the base in positive z.
700  **
701  ** The slices will radiate around the z axis. The stacks will be
702  ** along the z axis.
703  */
704  static int generate_cylinder_vertices(float radius,
705  float height,
706  int num_slices,
707  int num_layers,
708  const diguyVec3f& position_offset,
709  const diguyVec3f& orientation, // degrees
710  int* num_vertices,
711  diguyVec3f** vertices,
712  diguyVec3f** normals,
713  diguyVec2f** texture_indices,
714  int indices_for_wireframe,
715  int* num_indices,
716  unsigned int** indices);
717 
718  /*l
719  *b Description:
720  **
721  ** Similar to generate_sphere_vertices(), but for boxes, AKA
722  ** rectangular solids.
723  **
724  ** Untransformed, the box's corners are represented by the passed min
725  ** and max vectors, relative to the local origin.
726  */
727  static int generate_box_vertices(diguyVec3f min,
728  diguyVec3f max,
729  const diguyVec3f& position_offset,
730  const diguyVec3f& orientation, // degrees
731  int* num_vertices,
732  diguyVec3f** vertices,
733  diguyVec3f** normals,
734  diguyVec2f** texture_indices,
735  int indices_for_wireframe,
736  int* num_indices,
737  unsigned int** indices);
738 
739  /*l
740  *b Description:
741  **
742  ** For deleting data generated by the various generate_*_vertices()
743  ** functions.
744  */
745  static void delete_generated_vertices(diguyVec3f* vertices,
746  diguyVec3f* normals,
747  diguyVec2f* texture_indices,
748  unsigned int* indices);
749 
750 #endif
751 
752 /****************************************************************************/
753 /****************************************************************************/
754 
759 #ifdef CPLUSPLUS_ONLY
760 
761  bdiScenarioEditorInput* get_scripted_object() {return m_scripted_object;}
762 
763 protected:
764 
765  // protected constructor
766  diguyAuthorInterface(void* internal_data);
767 
768  // protected destructor
769  virtual ~diguyAuthorInterface();
770 
771  // pointer to internal data
772  friend class bdiScenarioApp;
773  friend class bdiScenarioEditorInput;
774  bdiScenarioEditorInput* m_scripted_object;
775 
776  static diguyAuthorInterfaceCreateFunc* s_create_func;
777 
778 #endif
779 
780 };
781 
782 #endif /* __diguyAuthorInterface_H */
783 
Link against: libdiguy
Definition: diguyAuthorInterface.h:58
Definition: diguy_vector_classes.h:34
Definition: diguyPathShape.h:30
diguyAuthorInterface * diguyAuthorInterfaceCreateFunc(void *internal_data)
Definition: diguyAuthorInterface.h:27
An interface for manipulating a character's spline path. A path is typically authored in DI-Guy Scena...
Definition: diguyCharacterPath.h:47
Definition: diguyAuthorVisualRegionPaintbrush.h:44
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:80
Definition: diguyWaypoint.h:29
Definition: diguy_vector_classes.h:74
A class that represents the unique per-character non-shared mesh object. DI-Guy encapsulates its text...
Definition: diguyGraphicsShape.h:51