DI-Guy SDK Documentation  13.1
diguyViewCamera.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2015 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************
8  **
9  *t diguyViewCamera
10  **
11  */
12 
13 #ifndef __diguyViewCamera_H
14 #define __diguyViewCamera_H
15 
16 #ifdef SWIG
17 %module diguyViewCamera
18 #else
19 #define CPLUSPLUS_ONLY
20 #endif
21 
22 #ifdef CPLUSPLUS_ONLY
23 class bdiCamera;
24 class diguyViewCamera;
26 
27 #include <stdio.h> // for NULL definition
28 #include <diguy_constants.h>
29 #include <diguy_typedefs.h>
30 
31 
32 #endif
33 
34 
35 #include <declspec_diguy.h>
36 
93 class BDI_DECLSPEC_diguy diguyViewCamera
94 {
95 
96 public:
97 
98 /*****************************************************************************/
108  /*l
109  *b Description:
110  **
111  ** Returns the name of the object. This pointer will never be NULL.
112  **
113  *b Returns:
114  **
115  ** name of the object
116  */
117  const char* get_name();
118 
119  /*l
120  *b Description:
121  **
122  ** Returns the type name of the object. This pointer will never be
123  ** NULL.
124  **
125  *b Returns:
126  **
127  ** type name of the object
128  */
129  const char* get_type_name();
130 
131  /*l
132  *b Description:
133  **
134  ** This sets the distance from the camera to the near plane.
135  **
136  *b Arguments:
137  **
138  *a near_plane - distance to near plane, in meters
139  */
140  void set_near_plane(float near_plane);
141 
142  /*l
143  *b Returns:
144  **
145  ** distance from the camera to the near plane, in meters
146  */
147  float get_near_plane();
148 
149  /*l
150  *b Description:
151  **
152  ** This sets the distance from the camera to the far plane.
153  **
154  *b Arguments:
155  **
156  *a far_plane - distance to far plane, in meters
157  */
158  void set_far_plane(float far_plane);
159 
160  /*l
161  *b Returns:
162  **
163  ** distance from the camera to the far plane, in meters
164  */
165  float get_far_plane();
166 
167  /*l
168  *b Description:
169  **
170  ** This sets the field-of-view of the current camera.
171  **
172  *b Arguments:
173  **
174  *a fov - field-of-view, in degrees
175  */
176  void set_fov(float fov);
177 
178  /*l
179  *b Description:
180  **
181  ** This sets the maximum field-of-view of the current camera. This
182  ** affects the FOV that can be set via set_fov.
183  **
184  *b Arguments:
185  **
186  *a fov - max field-of-view, in degrees
187  */
188  void set_max_fov(float fov);
189 
190  /*l
191  *b Description:
192  **
193  ** This sets the minimum field-of-view of the current camera. This
194  ** affects the FOV that can be set via set_fov.
195  **
196  *b Arguments:
197  **
198  *a fov - min field-of-view, in degrees
199  */
200  void set_min_fov(float fov);
201 
202  /*l
203  *b Returns:
204  **
205  ** field-of-view of the camera, in degrees
206  */
207  float get_fov();
208 
209  /*l
210  *b Returns:
211  **
212  ** min field-of-view of the camera, in degrees
213  */
214  float get_min_fov();
215 
216  /*l
217  *b Returns:
218  **
219  ** max field-of-view of the camera, in degrees
220  */
221  float get_max_fov();
222 
223  /*l
224  *b Description:
225  **
226  ** This function sets the aspect ratio of the camera.
227  **
228  *b Arguments:
229  **
230  *a aspect - aspect ratio; 1.3333 (4/3) is the default
231  */
232  void set_aspect(float aspect);
233 
234  /*l
235  *b Returns:
236  **
237  ** aspect ratio of the camera
238  */
239  float get_aspect();
240 
241  /*l
242  *b Description:
243  **
244  ** Sets whether or not the orientation and position offsets have any effect.
245  ** See the class-level comments for explanations of these.
246  */
247  void set_offsets_active(int value);
248 
249  /*l
250  *b Description:
251  **
252  ** Returns whether or not the orientation and position offsets have any effect.
253  */
254  int get_offsets_active();
255 
256  /*l
257  *b Description:
258  **
259  ** This function sets the base position of the camera. Will not work if a dolly
260  ** character has been set.
261  **
262  *b Arguments:
263  **
264  *a x, y, z - position in meters from the origin
265  */
266  void set_base_position(float x, float y, float z);
267 
268  /*l
269  *b Description:
270  **
271  ** This function sets the base position of the camera, and disables the offsets.
272  ** Will not work if a dolly character has been set.
273  */
274  void set_position(float x, float y, float z);
275 
276  /*l
277  *b Description:
278  **
279  ** Gets the base position of the camera.
280  **
281  *b Returns:
282  **
283  ** x, y, and z, in meters
284  */
285  void get_base_position(float *x, float *y, float *z);
286 
287  /*l
288  *b Returns:
289  **
290  ** x position, in meters from the origin. Not necessarily the base position of the system, but the actual
291  ** position of the camera itself.
292  */
293  float get_position_x();
294 
295  /*l
296  *b Returns:
297  **
298  ** y position, in meters from the origin. Not necessarily the base position of the system, but the actual
299  ** position of the camera itself.
300  */
301  float get_position_y();
302 
303  /*l
304  *b Returns:
305  **
306  ** z position, in meters from the origin. Not the base position of the system, but the actual
307  ** position of the camera itself.
308  */
309  float get_position_z();
310 
311  /*l
312  *b Description:
313  **
314  ** This function sets the desired base position of the camera. The camera will
315  ** interpolate over time to this position.
316  **
317  *b Arguments:
318  **
319  *a x, y, z - position in meters from the origin
320  */
321  void set_desired_base_position(float x, float y, float z);
322 
323  /*l
324  *b Description:
325  **
326  ** Sets the desired base position and disables any offsets.
327  **
328  *b Arguments:
329  **
330  *a x, y, z - position in meters from the origin
331  *a preserve_fix - obsolete, but kept for backwards compatibility
332  */
333  void set_desired_position(float x, float y, float z, bool preserve_fix = false);
334 
335  /*l
336  *b Description:
337  **
338  ** This function sets the position offset of the camera. See the
339  ** class-level documentation for an explanation. Note that calls to
340  ** set_position_offset_is_in_world_coordinates() might change the effect of
341  ** this function.
342  **
343  *b Arguments:
344  **
345  *a x, y, z - position in meters from the origin
346  */
347  void set_position_offset(float x, float y, float z);
348 
349  /*l
350  *b Description:
351  **
352  ** This function sets the desired position offset of the camera. The camera will
353  ** interpolate over time to this position.
354  **
355  *b Arguments:
356  **
357  *a x, y, z - position in meters from the origin
358  */
359  void set_desired_position_offset(float x, float y, float z);
360 
361  /*l
362  *b Description:
363  **
364  ** Gets the position offset of the camera. Note that it might be
365  ** relative to the base position *and* the base orientation, or just to
366  ** the base position
367  **
368  *b Returns:
369  **
370  ** x, y, and z, in meters
371  */
372  void get_position_offset(float *x, float *y, float *z);
373 
374  /*l
375  *b Description:
376  **
377  ** Sets whether or not the position offset is relative to both base
378  ** position and orientation, or just the position.
379  */
380  void set_position_offset_is_in_world_coordinates(int value);
381 
382  /*l
383  *b Returns:
384  **
385  ** Setting of position_offset_is_in_world_coordinates
386  */
387  int get_position_offset_is_in_world_coordinates();
388 
389  /*l
390  *b Description:
391  **
392  ** This function sets the base orientation of the camera. Note that this
393  ** causes a new fix point to be derived.
394  **
395  ** *NOTE*: Pitch angles are positive for looking down, not up!
396  **
397  *b Arguments:
398  **
399  *a yaw - rotation about z axis, in degrees
400  *a roll - rotation about x axis, in degrees
401  *a pitch - rotation about y axis, in degrees
402  */
403  void set_base_orientation(float yaw, float roll, float pitch);
404 
405  /*l
406  *b Description:
407  **
408  ** This function sets the base orientation of the camera. It will disable
409  ** the offsets.
410  */
411  void set_orientation(float yaw, float roll, float pitch);
412 
413  /*l
414  *b Description:
415  **
416  ** This function sets the roll value of the camera's base orientation.
417  **
418  *b Arguments:
419  **
420  *a roll - rotation about x axis, in radians
421  */
422  void set_orientation_roll(float roll);
423 
424  /*l
425  *b Returns:
426  **
427  ** yaw. roll, pitch. The actual orientation, with base orientation and offset
428  * orientation both applied.
429  */
430  void get_orientation(float *yaw, float *roll, float *pitch);
431 
432  /*l
433  *b Returns:
434  **
435  ** rotation about z axis, in degrees.
436  */
437  float get_orientation_yaw();
438 
439  /*l
440  *b Returns:
441  **
442  ** rotation about x axis, in degrees
443  */
444  float get_orientation_roll();
445 
446  /*l
447  *b Returns:
448  **
449  ** rotation about y axis, in degrees
450  */
451  float get_orientation_pitch();
452 
453  /*l
454  *b Description:
455  **
456  ** This function sets the desired base orientation of the camera, which
457  ** will be interpolated to over time.
458  **
459  ** *NOTE*: Pitch angles are positive for looking down, not up!
460  **
461  *b Arguments:
462  **
463  *a yaw - rotation about z axis, in degrees
464  *a roll - rotation about x axis, in degrees
465  *a pitch - rotation about y axis, in degrees
466  */
467  void set_desired_base_orientation(float yaw, float roll, float pitch);
468 
469  /*l
470  *b Description:
471  **
472  ** Sets the lower limit of the camera pitch *up*. Default is
473  ** very close to -90 degrees.
474  **
475  ** *NOTE*: Pitch angles are positive for looking down, not up!
476  **
477  *b Arguments:
478  **
479  *a limit - rotation about y axis, in degrees
480  */
481  void set_pitch_lower_limit(float limit);
482 
483  /*l
484  *b Returns:
485  **
486  ** lower limit of the camera pitch (up/down)
487  */
488  float get_pitch_lower_limit();
489 
490  /*l
491  *b Description:
492  **
493  ** Sets the upper limit of the camera pitch *down*. Default is
494  ** very close to 90 degrees.
495  **
496  ** *NOTE*: Pitch angles are positive for looking down, not up!
497  **
498  *b Arguments:
499  **
500  *a limit - rotation about y axis, in degrees
501  */
502  void set_pitch_upper_limit(float limit);
503 
504  /*l
505  *b Returns:
506  **
507  ** upper limit of the camera pitch (up/down)
508  */
509  float get_pitch_upper_limit();
510 
511  /*l
512  *b Returns:
513  **
514  ** 1 if pitch has limits, 0 if not
515  */
516  int get_pitch_has_limits();
517 
518  /*l
519  *b Description:
520  **
521  ** The degimbalize angle is intended to compensate for a situation
522  ** that occurs when a camera passes directly over or under the thing
523  ** it is fixed on. Normally, this leads to the yaw suddenly flipping
524  ** 180 degrees. When the degimbalize angle is set, the camera is
525  ** blocked from coming within that many degrees of the vertical.
526  ** Instead, it will move along a circle around the pole.
527  **
528  ** Normally, this value is set to zero. The units are degrees.
529  */
530  void set_degimbalize_angle(float angle);
531 
532  /*l
533  *b Returns:
534  **
535  ** Current degimbalize angle, in degrees.
536  */
537  float get_degimbalize_angle();
538 
539  /*l
540  *b Description:
541  **
542  ** This function sets the orientation offset of the camera. See the
543  ** class-level documentation for an explanation. Note that calls to
544  ** set_orientation_offset_is_relative() might change the effect of
545  ** this function.
546  **
547  *b Arguments:
548  **
549  *a yaw - rotation about z axis, in degrees
550  *a roll - rotation about x axis, in degrees
551  *a pitch - rotation about y axis, in degrees
552  */
553  void set_orientation_offset(float yaw, float roll, float pitch);
554 
555  /*l
556  *b Description:
557  **
558  ** Gets the orientation offset of the camera. Note that it might be
559  ** relative to the base orientation, or relative to world axes.
560  **
561  *b Returns:
562  **
563  ** yaw, pitch, roll, in degrees
564  */
565  void get_orientation_offset(float *yaw, float *roll, float *pitch);
566 
567  /*l
568  *b Description:
569  **
570  ** This function sets the desired orientation offset of the camera, which
571  ** will be interpolated to over time.
572  **
573  ** *NOTE*: Pitch angles are positive for looking down, not up!
574  **
575  *b Arguments:
576  **
577  *a yaw - rotation about z axis, in degrees
578  *a roll - rotation about x axis, in degrees
579  *a pitch - rotation about y axis, in degrees
580  */
581  void set_desired_orientation_offset(float yaw, float roll, float pitch);
582 
583  /*l
584  *b Description:
585  **
586  ** This function sets the distance from the position to the fix
587  ** point. Note that this affects the fix values.
588  **
589  *b Arguments:
590  **
591  *a distance - distance in meters
592  */
593  void set_distance(float distance);
594 
595  /*l
596  *b Description:
597  **
598  ** This function sets the maximum allowed distance from the position
599  ** to the fix point.
600  **
601  *b Arguments:
602  **
603  *a distance - distance in meters; set to -1 if no max to be used
604  */
605  void set_max_track_distance(float distance);
606 
607  /*l
608  *b Description:
609  **
610  ** This function sets the minimum allowed distance from the position
611  ** to the fix point.
612  **
613  *b Arguments:
614  **
615  *a distance - distance in meters; set to -1 if no min to be used
616  */
617  void set_min_track_distance(float distance);
618 
619  /*l
620  *b Returns:
621  **
622  ** distance from position to fix point, in meters
623  */
624  float get_distance();
625 
626  /*l
627  *b Returns:
628  **
629  ** minimum allowed tracking distance, in meters; will be less than
630  ** zero if not applicable
631  */
632  float get_min_track_distance();
633 
634  /*l
635  *b Returns:
636  **
637  ** maximum allowed tracking distance, in meters; will be less than
638  ** zero if not applicable
639  */
640  float get_max_track_distance();
641 
642  /*l
643  *b Description:
644  **
645  ** This function sets the fix point of the camera. Note that this
646  ** affects the orientation.
647  **
648  *b Arguments:
649  **
650  *a x, y, z - position in meters from the origin
651  */
652  void set_fix(float x, float y, float z);
653 
654  /*l
655  *b Description:
656  **
657  ** Causes the camera to lose whatever fix point it was pointed at.
658  ** The camera will simply maintain its current orientation until
659  ** a new orientation is assigned. Only has a visible effect if the
660  ** camera is in motion.
661  **
662  */
663  void release_fix();
664 
665  /*l
666  *b Returns:
667  **
668  ** fix point in x, in meters. If camera is tracking, the fix point will still
669  ** be in absolute world coordinates.
670  */
671  float get_fix_x();
672 
673  /*l
674  *b Returns:
675  **
676  ** fix point in y, in meters. If camera is tracking, the fix point will still
677  ** be in absolute world coordinates.
678  */
679  float get_fix_y();
680 
681  /*l
682  *b Returns:
683  **
684  ** fix point in z, in meters. If camera is tracking, the fix point will still
685  ** be in absolute world coordinates.
686  */
687  float get_fix_z();
688 
689  /*l
690  *b Description:
691  **
692  ** This function sets the desired fix point of the camera. The camera
693  ** will interpolate to there from its current fix over time.
694  **
695  *b Arguments:
696  **
697  *a x, y, z - position in meters from the origin
698  */
699  void set_desired_fix(float x, float y, float z);
700 
701  /*l
702  *b Description:
703  **
704  ** This function sets the movement mode of the camera.
705  **
706  ** In DI-Guy Scenario in Camera Input Mode, the movement mode of the
707  ** camera determines what will happen when mouse buttons are pressed
708  ** in the view window.
709  **
710  *b Arguments:
711  **
712  *a move_mode - new movement mode of the camera; enumeration
713  *a of type diguyViewCameraMoveMode
714  **
715  *a DIGUY_CAMERA_MOVE_FORWARD - left mouse press moves camera
716  *a forward, right mouse press moves
717  *a camera back
718  *a DIGUY_CAMERA_MOVE_SIDEWAYS - left mouse press moves camera
719  *a left, right mouse press moves
720  *a camera right
721  *a DIGUY_CAMERA_MOVE_VERTICAL - left mouse press moves camera
722  *a up, right mouse press moves
723  *a camera down
724  **
725  *b Returns:
726  **
727  ** 0 on success, -1 on failure
728  */
729  int set_move_mode(diguyViewCameraMoveMode move_mode);
730 
731  /*l
732  *b Returns:
733  **
734  ** the most recent setting made by set_move_mode()
735  */
736  diguyViewCameraMoveMode get_move_mode();
737 
738  /*l
739  *b Description:
740  **
741  ** This function sets the movement speed of the camera when the
742  ** camera is translating due to user input.
743  **
744  ** In DI-Guy Scenario in Camera Input Mode, the movement speed of the
745  ** camera determines how fast the camera will move when mouse buttons
746  ** are pressed in the view window.
747  **
748  *b Arguments:
749  **
750  *a speed - speed of camera movement is meters per second
751  **
752  *b Returns:
753  **
754  ** 0 on success, -1 on failure
755  */
756  int set_speed(float speed);
757 
758  /*l
759  *b Returns:
760  **
761  ** the most recent setting made by set_speed()
762  */
763  float get_speed();
764 
765  /*l
766  *b Description:
767  **
768  ** This function increases the movement speed of the camera
769  ** when the camera is translating due to user input. The
770  ** increase is typically by a factor of 2.
771  **
772  *b Returns:
773  **
774  ** 0 on success, -1 on failure
775  */
776  int increase_speed();
777 
778  /*l
779  *b Description:
780  **
781  ** This function decreases the movement speed of the camera
782  ** when the camera is translating due to user input. The
783  ** decrease is typically by a factor of 2.
784  **
785  *b Returns:
786  **
787  ** 0 on success, -1 on failure
788  */
789  int decrease_speed();
790 
791  /*l
792  *b Description:
793  **
794  ** This function sets the projection mode of the camera.
795  **
796  ** In DI-Guy Scenario in Camera Input Mode, the movement
797  ** mode of the camera determines what will happen when
798  ** mouse buttons are pressed in the view window.
799  **
800  *b Arguments:
801  **
802  *a projection_mode - new projection mode of the camera;
803  *a enumeration of type
804  *a diguyViewCameraProjectionMode
805  **
806  *a DIGUY_CAMERA_PROJECTION_PERSPECTIVE - standard perspective
807  *a camera, can move and
808  *a rotate freely
809  *a DIGUY_CAMERA_PROJECTION_PLANVIEW_XY - always views in negative
810  *a Z direction
811  *a DIGUY_CAMERA_PROJECTION_PLANVIEW_XZ - always views in negative
812  *a Y direction
813  *a DIGUY_CAMERA_PROJECTION_PLANVIEW_YZ - always views in negative
814  *a X direction
815  **
816  *b Notes:
817  **
818  ** In projection modes, only the fix point and the distance from it
819  ** can be changed. Dollying and tracking are each possible, and
820  ** effectively the same, but can't be done at once.
821  **
822  */
823  int set_projection_mode(diguyViewCameraProjectionMode projection_mode);
824 
825  /*l
826  *b Returns:
827  **
828  ** the most recent setting made by set_projection_mode()
829  */
830  diguyViewCameraProjectionMode get_projection_mode();
831 
832 
833 /*****************************************************************************/
848  /*l
849  *b Description:
850  **
851  ** Loads the specified settings into this camera.
852  **
853  *b Returns:
854  **
855  ** 0 on success, -1 on failure
856  */
857  int load_settings(const char* settings_name);
858 
859  /*l
860  *b Description:
861  **
862  ** Loads the specified settings into this camera.
863  **
864  *b Returns:
865  **
866  ** 0 on success, -1 on failure
867  */
868  int load_settings(diguyViewCameraSettings* settings);
869 
870  /*l
871  *b Description:
872  **
873  ** This function applies this camera's settings and internal
874  ** state to the actual view frustrum. It should be called as
875  ** often as the camera needs to be updated. Note that code that
876  ** controls the camera's motions (e.g. when the camera is
877  ** tracking a character) gets called via
878  ** diguyScenario::update().
879  **
880  *i OpenGL Version:
881  **
882  ** This function sets the current viewpoint in these
883  ** environments based on information in this camera.
884  **
885  *i Direct3D Version:
886  **
887  ** This function has no effect. The viewpoint in
888  ** these environments must be set manually.
889  */
890  void apply_settings();
891 
892 
893 /*****************************************************************************/
970  /*l
971  *b Description:
972  **
973  ** This function sets the base position of this camera using
974  ** double precision floating point numbers. The numbers
975  ** will be converted internally into a DI-Guy far position.
976  **
977  *b Arguments:
978  **
979  *a x - x position, in meters
980  *a y - y position, in meters
981  *a z - z position, in meters
982  */
983  void set_base_position_double(double x, double y, double z);
984 
985  /*l
986  *b Description:
987  **
988  ** Equivalent to set_base_position_double(), but disables offsets.
989  */
990  void set_position_double(double x, double y, double z);
991 
992  /*l
993  *b Description:
994  **
995  ** Gets the base position of the camera.
996  **
997  *b Returns:
998  **
999  ** x, y, and z, in meters
1000  */
1001  void get_base_position_double(double *x, double *y, double *z);
1002 
1003  /*l
1004  *b Description:
1005  **
1006  ** This function returns the world-space position of this
1007  ** camera. These values are computed from the DI-Guy
1008  ** far position of the camera. The results are placed into
1009  ** the passed pointers. If camera is dollied, the position will
1010  ** still indicate its absolute world coordinates.
1011  **
1012  *b Arguments:
1013  **
1014  *a x - x position, in meters
1015  *a y - y position, in meters
1016  *a z - z position, in meters
1017  */
1018  void get_position_double(double* x, double* y, double* z);
1019 
1020  /*l
1021  *b Description:
1022  **
1023  ** This function returns the world-space origin of the far
1024  ** position segment the camera is in. This segment origin
1025  ** plus the position segment offset returned by
1026  ** get_position_segment_offset() yields the final world-space
1027  ** position of the camera.
1028  **
1029  ** The results are placed into the passed pointers.
1030  **
1031  *b Arguments:
1032  **
1033  *a x - x component of origin, in meters
1034  *a y - y component of origin, in meters
1035  *a z - z component of origin, in meters
1036  */
1037  void get_segment_origin(float* x, float* y, float* z);
1038 
1039  /*l
1040  *b Description:
1041  **
1042  ** This function returns the far position segment offset
1043  ** part of the camera's base position. The results are placed
1044  ** into the passed pointers.
1045  **
1046  *b Arguments:
1047  **
1048  *a x - x component of segment offset, in meters
1049  *a y - y component of segment offset, in meters
1050  *a z - z component of segment offset, in meters
1051  */
1052  void get_position_segment_offset(float* x, float* y, float* z);
1053 
1054  /*l
1055  *b Description:
1056  **
1057  ** This function returns the far position offset portion of
1058  ** the camera's fix point. The results are placed into the
1059  ** passed pointers.
1060  **
1061  *b Arguments:
1062  **
1063  *a x - x component of fix segment offset, in meters
1064  *a y - y component of fix segment offset, in meters
1065  *a z - z component of fix segment offset, in meters
1066  */
1067  void get_fix_segment_offset(float* x, float* y, float* z);
1068 
1069  /*l
1070  *b Description:
1071  **
1072  ** This function sets the fix point of the camera using
1073  ** double precision floating point numbers. The numbers
1074  ** will be converted internally into a DI-Guy far position. Note
1075  ** that this affects the orientation.
1076  **
1077  *b Arguments:
1078  **
1079  *a x - x position, in meters
1080  *a y - y position, in meters
1081  *a z - z position, in meters
1082  */
1083  void set_fix_double(double x, double y, double z);
1084 
1085 /*****************************************************************************/
1095  /*l
1096  *b Description:
1097  **
1098  ** This function sets the name of the character the camera should
1099  ** look at, if such a character can be found. This will cause
1100  ** fix values to change over time.
1101  **
1102  ** By default the camera will look at the idealized position of
1103  ** the character (a spot on the ground typically under the center
1104  ** of gravity for human characters). To look at a particular part
1105  ** of a character, call set_track_link_name().
1106  **
1107  ** The spot looked at on a link can be offset by calling
1108  ** set_track_offset(). Whether the offset is in world coordinates
1109  ** or character-local coordinates is controlled by a call to
1110  ** set_track_offset_is_in_world_coordinates().
1111  **
1112  ** Note that tracking and dollying can be combined. For example,
1113  ** picture a camera affixed to a pedestrian walking along. The
1114  ** camera might track a car going by in a different direction. The
1115  ** dolly entity and the tracked entity can even be the same.
1116  **
1117  *b Arguments:
1118  **
1119  *a track_name - name of character to look at, or NULL if no character
1120  *a is to be tracked
1121  **
1122  **
1123  *b C++ Example
1124  **
1125  ** The following example shows how to use some of the pose
1126  ** functions.
1127  **
1128  *e //
1129  *e // Get a pointer to the primary view's camera, and
1130  *e // to the first character.
1131  *e //
1132  *e diguyViewCamera* camera = scenario->get_scenario_camera();
1133  *e diguyCharacter* character = scenario->get_character_at_index(0);
1134  *e
1135  *e //
1136  *e // Look just a little bit above the character's head.
1137  *e //
1138  *e camera->set_track_name(character->get_name());
1139  *e camera->set_track_link_name("cervical");
1140  *e camera->set_track_offset(0.0f, 0.0f, 0.1f);
1141  */
1142  void set_track_name(const char* track_name);
1143 
1144  /*l
1145  *b Returns:
1146  **
1147  ** name of character to be looked at; see set_track_name()
1148  */
1149  const char* get_track_name();
1150 
1151  /*l
1152  *b Description:
1153  **
1154  ** This function sets the name of the group the camera will track.
1155  **
1156  *b Arguments:
1157  **
1158  *a track_name - name of group to look at; pass NULL to un-set track
1159  *a group
1160  */
1161  void set_track_group_name(const char* track_name);
1162 
1163  /*l
1164  *b Returns:
1165  **
1166  ** name of group to be looked at; see set_track_group_name()
1167  */
1168  const char* get_track_group_name();
1169 
1170  /*l
1171  *b Description:
1172  **
1173  ** This function sets the name of the link to be tracked on
1174  ** the character specified by set_track_name(). See
1175  ** set_track_name() for more information.
1176  **
1177  *b Arguments:
1178  **
1179  *a track_link_name - name of link to look at, or NULL if the base
1180  *a link is to be tracked
1181  */
1182  void set_track_link_name(const char* track_link_name);
1183 
1184  /*l
1185  *b Returns:
1186  **
1187  ** name of link to be looked at; see set_track_link_name()
1188  */
1189  const char* get_track_link_name();
1190 
1191  /*l
1192  *b Description:
1193  **
1194  ** This function sets the position of the look-at point relative
1195  ** to the tracked entity. Note that this overrides any position
1196  ** given to set_fix().
1197  **
1198  ** Whether the offset is in world coordinates or character-local
1199  ** coordinates is controlled by a call to
1200  ** set_track_offset_is_in_world_coordinates().
1201  **
1202  *b Arguments:
1203  **
1204  *a x, y, z - offset, in meters, of track point
1205  */
1206  void set_track_offset(float x, float y, float z);
1207 
1208  /*l
1209  *b Returns:
1210  **
1211  ** x component of track offset; see set_track_offset()
1212  */
1213  float get_track_offset_x();
1214 
1215  /*l
1216  *b Returns:
1217  **
1218  ** y component of track offset; see set_track_offset()
1219  */
1220  float get_track_offset_y();
1221 
1222  /*l
1223  *b Returns:
1224  **
1225  ** z component of track offset; see set_track_offset()
1226  */
1227  float get_track_offset_z();
1228 
1229  /*l
1230  *b Description:
1231  **
1232  ** This function sets whether the offset of the track
1233  ** position is character-relative (pass 0) or in
1234  ** world coordinates (pass 1).
1235  **
1236  ** Default value is 0.
1237  **
1238  *b Arguments:
1239  **
1240  *a value - pass 0 for character-relative, 0 for world coordinates
1241  */
1242  void set_track_offset_is_in_world_coordinates(int value);
1243 
1244  /*l
1245  *b Returns:
1246  **
1247  ** the most recent setting made by set_track_offset_is_in_world_coordinates().
1248  */
1249  int get_track_offset_is_in_world_coordinates();
1250 
1251  /*l
1252  *b Description:
1253  **
1254  ** Sets the dolly entity. The "dolly" is the character that the camera
1255  ** "rides" on, though at an offset. Picture the camera cart commonly
1256  ** used in film-making, with the camera viewing the subject from the
1257  ** end of a crane that extends out from the cart. The cart would be the
1258  ** dolly character.
1259  **
1260  ** Once you set a dolly character, you lose the ability to set the base
1261  ** position and orientation of the camera. However, you can still set the
1262  ** position offset and the orientation offset.
1263  **
1264  ** Note that tracking and dollying can be combined. For example,
1265  ** picture a camera affixed to a pedestrian walking along. The
1266  ** camera might track a car going by in a different direction. The
1267  ** dolly entity and the tracked entity can even be the same.
1268  **
1269  *b Arguments:
1270  **
1271  *a dolly_name - name of entity to look from, or NULL if none
1272  */
1273  void set_dolly_name(const char* dolly_name);
1274 
1275  /*l
1276  *b Description:
1277  **
1278  ** This function gets the name of the dolly entity.
1279  **
1280  *b Arguments:
1281  **
1282  *a dolly_name - name of character to look from, or NULL
1283  */
1284  const char* get_dolly_name();
1285 
1286  /*l
1287  *b Description:
1288  **
1289  ** Sets the position at which the camera will be relative to the
1290  ** dolly entity. This function does the same thing as set_position_offset(),
1291  ** but remains here for backwards compatibility.
1292  **
1293  ** Whether the offset is in world coordinates or character-local
1294  ** coordinates is controlled by a call to
1295  ** set_dolly_offset_is_in_world_coordinates().
1296  **
1297  *b Arguments:
1298  **
1299  *a x, y, z - offset, in meters, of dolly point
1300  */
1301  void set_dolly_offset(float x, float y, float z);
1302 
1303  /*l
1304  *b Returns:
1305  **
1306  ** x component of position offset; see set_dolly_offset()
1307  */
1308  float get_dolly_offset_x();
1309 
1310  /*l
1311  *b Returns:
1312  **
1313  ** y component of position offset; see set_dolly_offset()
1314  */
1315  float get_dolly_offset_y();
1316 
1317  /*l
1318  *b Returns:
1319  **
1320  ** z component of position offset; see set_dolly_offset()
1321  */
1322  float get_dolly_offset_z();
1323 
1324  /*l
1325  *b Description:
1326  **
1327  ** This function sets the name of the link to be dollied on
1328  ** the character specified by set_dolly_name().
1329  **
1330  *b Arguments:
1331  **
1332  *a dolly_link_name - name of link to look from, or NULL if the
1333  *a position link is to influence camera position
1334  */
1335  void set_dolly_link_name(const char* dolly_link_name);
1336 
1337  /*l
1338  *b Returns:
1339  **
1340  ** name of link to be looked from; see set_dolly_link_name()
1341  */
1342  const char* get_dolly_link_name();
1343 
1344  /*l
1345  *b Description:
1346  **
1347  ** This function sets whether the position offset is character-relative
1348  ** (pass 0) or in world coordinates (pass 1).
1349  **
1350  ** Default value is 0.
1351  **
1352  *b Arguments:
1353  **
1354  *a value - pass 0 for character-relative, 1 for world coordinates
1355  */
1356  void set_dolly_offset_is_in_world_coordinates(int value);
1357 
1358  /*l
1359  *b Returns:
1360  **
1361  ** the most recent setting made by
1362  ** set_dolly_offset_is_in_world_coordinates().
1363  */
1364  int get_dolly_offset_is_in_world_coordinates();
1365 
1366  /*l
1367  *b Description:
1368  **
1369  ** Sets whether the camera's orientation offset is relative or not. If it's
1370  ** relative, it will be in the coordinate system established by the base
1371  ** orientation (or the orientation of the dolly character). If not relative,
1372  ** it will be in the world's coordinate system.
1373  **
1374  ** For example, setting an orientation of (-90, 0, 0) when the dolly entity
1375  ** is rolled 45 degrees to the left will cause the camera to look towards
1376  ** the area to the dolly entity's right, which will be up towards to the
1377  ** sky. If the dolly entity rolls 90 degrees to the right (from where it
1378  ** is) the camera will now be facing the ground.
1379  **
1380  ** When the camera is tracking something, however, the orientation offset's
1381  ** yaw and pitch components will be derived.
1382  **
1383  ** Default value is 0.
1384  **
1385  *b Arguments:
1386  **
1387  *a value - pass 1 to match orientation, 0 to not match
1388  */
1389  void set_orientation_offset_is_relative(int value);
1390 
1391  /*l
1392  *b Returns:
1393  **
1394  ** the most recent setting made by set_orientation_offset_is_relative().
1395  */
1396  int get_orientation_offset_is_relative();
1397 
1398  /*l
1399  *b Description:
1400  **
1401  ** This function has been deprecated, but remains for backwards compatibility.
1402  ** It is replaced by set_orientation_offset_is_relative()
1403  */
1404  void set_match_dolly_orientation(int value);
1405 
1406  /*l
1407  *b Description:
1408  **
1409  ** This function has been deprecated, but remains for backwards compatibility.
1410  ** It is replaced by get_orientation_offset_is_relative()
1411  */
1412  int get_match_dolly_orientation();
1413 
1414  /*l
1415  *b Description:
1416  **
1417  ** If activated, the camera will behave differently when both dollying and tracking.
1418  ** The base orientation will swivel towards the target. Move the position offset
1419  ** back a bit, and the dolly character will remain between the camera and target.
1420  */
1421  void set_use_special_track_mode(int value);
1422 
1423  /*l
1424  *b Returns:
1425  **
1426  ** 1, if special track mode is being used.
1427  */
1428  int get_use_special_track_mode();
1429 
1430  /*l
1431  *b Returns:
1432  **
1433  ** if DI-Guy Scenario is rendering simplified 2D representations of
1434  ** characters.
1435  */
1436  int get_symbolic_view();
1437 
1438 
1439 /*****************************************************************************/
1445  /*l
1446  *b Description:
1447  **
1448  ** This is an enumeration of the different callbacks
1449  ** that can be registered with add_callback() and
1450  ** add_callback_script().
1451  **
1452  *b Usable From:
1453  **
1454  *- - C++
1455  *- - Script
1456  */
1457  enum {
1458  CALLBACK_ID_SETTINGS_CHANGED = 1
1459  };
1460 
1461 #ifdef CPLUSPLUS_ONLY
1462 
1463  /*l
1464  *b Description:
1465  **
1466  ** This function adds a user callback.
1467  **
1468  *b Arguments:
1469  **
1470  *a callback - pointer to function with prototype
1471  *a diguyViewCameraCallback (typedefed above)
1472  *a callback_id - integer id of when this callback is to be called
1473  *a callback_params - struct containing additional parameters
1474  *a needed by some callbacks; actual type depends
1475  *a on callback_id
1476  *a callback_user_data - pointer for user's own use; DI-Guy will
1477  *a do nothing to the contents of this pointer
1478  *a beyond passing it back when the callback is
1479  *a invoked
1480  **
1481  ** callback_id should be one of the following values:
1482  **
1483  *i CALLBACK_ID_SETTINGS_CHANGED
1484  **
1485  ** This callback will be called if the current settings of this
1486  ** camera change
1487  **
1488  ** Callbacks return a value of type diguyCallbackReturn,
1489  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
1490  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
1491  ** of the function will not be called; the callback is asserting
1492  ** that it has done everything necessary for the function call.
1493  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
1494  ** handler for the function will be called after the callback.
1495  **
1496  *b Returns:
1497  **
1498  ** 0 on success, -1 on failure
1499  */
1500  int add_callback(int callback_id,
1501  diguyViewCameraCallback* callback,
1502  void* callback_params = 0,
1503  void* callback_user_data = 0);
1504 
1505  /*l
1506  *b Description:
1507  **
1508  ** This function removes a user callback. All callbacks matching
1509  ** the specified callback_id and callback function will be removed.
1510  **
1511  *b Arguments:
1512  **
1513  *a callback_id - integer id of when this callback is to be called
1514  *a callback - pointer to function with prototype
1515  *a diguyViewCameraCallback (typedefed above)
1516  **
1517  *b Returns:
1518  **
1519  ** 0 on success, -1 on failure
1520  */
1521  int remove_callback(int callback_id,
1522  diguyViewCameraCallback* callback);
1523 
1524  /*l
1525  *b Description:
1526  **
1527  ** This function removes a user callback. All callbacks matching
1528  ** the specified callback_id and callback_user_data pointer will
1529  ** be removed.
1530  **
1531  *b Arguments:
1532  **
1533  *a callback_id - integer id of when this callback is to be called
1534  *a callback_user_data - pointer for user's own use
1535  **
1536  *b Returns:
1537  **
1538  ** 0 on success, -1 on failure
1539  */
1540  int remove_callback_with_user_data(int callback_id,
1541  void* callback_user_data);
1542 
1543 #endif
1544 
1545 /*****************************************************************************/
1550  /*l
1551  *b Description:
1552  **
1553  ** This function adds a user callback script. Callback scripts can
1554  ** be removed with remove_callback_script().
1555  **
1556  *b Arguments:
1557  **
1558  *a callback_id - integer id of the callback
1559  *a callback_script - script text of callback to be added
1560  *a callback_script_type - the type of script contained in
1561  *a callback_script
1562  **
1563  ** If NULL is passed for callback_script_type, a default script type
1564  ** will be derived based on the default script interpreter of the
1565  ** scenario.
1566  **
1567  *i lua specific:
1568  **
1569  ** When the script is called, the object for which it is being called
1570  ** will be in the callback_object local.
1571  **
1572  ** To pass NULL when calling from a lua script, use nil.
1573  **
1574  *b Returns:
1575  **
1576  ** 0 on success, -1 on failure
1577  */
1578  int add_callback_script(int callback_id,
1579  const char* callback_script,
1580  const char* callback_script_type = NULL);
1581 
1582  /*l
1583  *b Description:
1584  **
1585  ** This function removes a user callback script previously added with
1586  ** add_callback_script().
1587  **
1588  *b Arguments:
1589  **
1590  *a callback_id - integer id of the callback
1591  *a callback_script - script text of callback previously added
1592  *a callback_script_type - the type of script contained in
1593  *a callback_script
1594  **
1595  ** If NULL is passed for callback_script, all callback
1596  ** scripts whose ids match callback_id and whose types match
1597  ** callback_script_type will be removed.
1598  **
1599  ** If NULL is passed for callback_script_type, a default script type
1600  ** will be derived based on the default script interpreter of the
1601  ** scenario.
1602  **
1603  *i lua specific:
1604  **
1605  ** To pass NULL when calling from a lua script, use nil.
1606  **
1607  *b Returns:
1608  **
1609  ** 0 on success, -1 on failure
1610  */
1611  int remove_callback_script(int callback_id,
1612  const char* callback_script,
1613  const char* callback_script_type = NULL);
1614 
1615 
1616 /****************************************************************************/
1617 /****************************************************************************/
1618 /****************************************************************************/
1630 /****************************************************************************/
1631 /****************************************************************************/
1632 /****************************************************************************/
1633 
1634  /*l
1635  *b Description:
1636  **
1637  ** Sets number of degrees by which the camera FOV should change
1638  ** whenever the user moves the mouse wheel.
1639  **
1640  *b Arguments:
1641  **
1642  *a fov_change - change to FOV in degrees
1643  **
1644  */
1645  void set_speed_fov_degrees_per_wheel_click(float fov_change);
1646 
1647  /*l
1648  *b Description:
1649  **
1650  ** Gets the number of degrees by which the camera FOV should change
1651  ** whenever the user moves the mouse wheel.
1652  **
1653  *b Returns:
1654  **
1655  ** change to FOV, in degrees
1656  */
1657  float get_speed_fov_degrees_per_wheel_click();
1659  /*l
1660  *b Description:
1661  **
1662  ** Sets how fast the camera should move in various flyaround modes.
1663  **
1664  *b Arguments:
1665  **
1666  *a speed - flying speed in meters per second
1667  */
1668  void set_speed_meters_per_second(float speed);
1669 
1670  /*l
1671  *b Description:
1672  **
1673  ** Gets how fast the camera should move in various flyaround modes.
1674  **
1675  *b Returns:
1676  **
1677  ** speed in meters per second
1678  */
1679  float get_speed_meters_per_second();
1680 
1681  /*l
1682  *b Description:
1683  **
1684  ** Sets whether the camera should smoothly servo to its new desired
1685  ** position/heading (as opposed to instantly popping there).
1686  **
1687  *b Arguments:
1688  **
1689  *a require - 0 for smooth servoing
1690  */
1691  void set_require_smooth_servo(int require);
1692 
1693  /*l
1694  *b Description:
1695  **
1696  ** Gets whether the camera should smoothly servo to its new desired
1697  ** position/heading (as opposed to instantly popping there).
1698  **
1699  *b Returns:
1700  **
1701  ** 1 if smooth servoing is required; 0 if not
1702  */
1703  int get_require_smooth_servo();
1704 
1705  /*l
1706  *b Description:
1707  **
1708  ** Sets a factor that determines how smoothly the camera should servo.
1709  ** If a high number (e.g. 10.0), the camera will servo quickly. If
1710  ** a low number (e.g. 1.0), it will servo more slowly.
1711  **
1712  *b Arguments:
1713  **
1714  *a modifier
1715  */
1716  void set_servo_time_modifier( float modifier );
1717 
1718  /*l
1719  *b Returns:
1720  **
1721  ** The servo modifier time that determines how smoothly the camera
1722  ** should servo.
1723  */
1724  float get_servo_time_modifier();
1725 
1726  /*l
1727  *b Description:
1728  **
1729  ** Sets if the camera mover should make an effort to avoid obstacles
1730  ** that block visibility while a character or group is being tracked.
1731  **
1732  *b Arguments:
1733  **
1734  *a avoids - true for avoidance
1735  */
1736  void set_track_camera_avoids_obstacles(int avoid);
1737 
1738  /*l
1739  *b Description:
1740  **
1741  ** Gets whether the camera mover should make an effort to avoid
1742  ** obstacles that block visibility while a character or group is
1743  ** being tracked.
1744  **
1745  *b Returns:
1746  **
1747  ** 1 if obstacle avoidance should be attempted
1748  */
1749  int get_track_camera_avoids_obstacles();
1750 
1751  /*l
1752  *b Description:
1753  **
1754  ** Sets if the camera should not respond to mouse input from DI-Guy Scenario.
1755  ** In Scenario, responding is the default. In API Mode, not responding is the default.
1756  **
1757  *b Arguments:
1758  **
1759  *a avoids - 1 to ignore mouse drags; 0 if not
1760  */
1761  void set_ignore_mouse_drags(int ignore);
1762 
1763  /*l
1764  *b Description:
1765  **
1766  ** Gets whether the camera should ignore mouse input from DI-Guy Scenario.
1767  **
1768  *b Returns:
1769  **
1770  ** 1 if mouse drags are to be ignored; 0 if not
1771  */
1772  int get_ignore_mouse_drags();
1773 
1774 #ifdef CPLUSPLUS_ONLY
1775  /*l
1776  *b Description:
1777  **
1778  ** Allows the diguy camera to build an internal frustum needed for
1779  ** doing character and scene object culling. projection_matrix and
1780  ** model_matrix should be pointers to 16 floats in OpenGL style matrix
1781  ** format.
1782  **
1783  *b This function is not callable from lua.
1784  */
1785  void update_frustum(float* proj_matrix, float* model_matrix);
1786 
1787 #endif
1788 
1793 #ifdef CPLUSPLUS_ONLY
1794 
1795  bdiCamera* get_scripted_object() {return m_camera;}
1796 
1797 private:
1798 
1799  /*l
1800  ** A private constructor.
1801  */
1802  diguyViewCamera(bdiCamera* camera);
1803 
1804  /*l
1805  ** A pointer to internal data.
1806  */
1807  bdiCamera* m_camera;
1808 
1809  friend class bdiCamera;
1810 
1811  static bool s_warn_if_position_set_ignored;
1812 
1813 #endif
1814 
1815 };
1816 
1817 #endif /* __diguyViewCamera_H */
1818 
The diguyViewCameraSettings class holds camera settings data that can be loaded into a diguyViewCamer...
Definition: diguyViewCameraSettings.h:43
diguyViewCameraProjectionMode
DI-Guy camera projection modes.
Definition: diguy_constants.h:251
diguyViewCameraMoveMode
DI-Guy camera move modes.
Definition: diguy_constants.h:236
The class that represents a camera in the world.
Definition: diguyViewCamera.h:90
diguyCallbackReturn diguyViewCameraCallback(diguyViewCamera *camera, int callback_id, void *callback_params, void *callback_user_data)
Definition: diguy_typedefs.h:204