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