DI-Guy SDK Documentation  13.8
diguyViewCamera.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  *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 
263 class BDI_DECLSPEC_diguy diguyViewCamera
264 {
265 
266 public:
267 
268 /*****************************************************************************/
278  /*l
279  *b Description:
280  **
281  ** Returns the name of the object. This pointer will never be NULL.
282  **
283  *b Returns:
284  **
285  ** name of the object
286  */
287  const char* get_name();
288 
289  /*l
290  *b Description:
291  **
292  ** Returns the type name of the object. This pointer will never be
293  ** NULL.
294  **
295  *b Returns:
296  **
297  ** type name of the object
298  */
299  const char* get_type_name();
300 
301  /*l
302  *b Description:
303  **
304  ** This sets the distance from the camera to the near plane.
305  **
306  *b Arguments:
307  **
308  *a near_plane - distance to near plane, in meters
309  */
310  void set_near_plane(float near_plane);
311 
312  /*l
313  *b Returns:
314  **
315  ** distance from the camera to the near plane, in meters
316  */
317  float get_near_plane();
318 
319  /*l
320  *b Description:
321  **
322  ** This sets the distance from the camera to the far plane.
323  **
324  *b Arguments:
325  **
326  *a far_plane - distance to far plane, in meters
327  */
328  void set_far_plane(float far_plane);
329 
330  /*l
331  *b Returns:
332  **
333  ** distance from the camera to the far plane, in meters
334  */
335  float get_far_plane();
336 
337  /*l
338  *b Description:
339  **
340  ** This sets the field-of-view of the current camera.
341  **
342  *b Arguments:
343  **
344  *a fov - field-of-view, in degrees
345  */
346  void set_fov(float fov);
347 
348  /*l
349  *b Description:
350  **
351  ** This sets the maximum field-of-view of the current camera. This
352  ** affects the FOV that can be set via set_fov.
353  **
354  *b Arguments:
355  **
356  *a fov - max field-of-view, in degrees
357  */
358  void set_max_fov(float fov);
359 
360  /*l
361  *b Description:
362  **
363  ** This sets the minimum field-of-view of the current camera. This
364  ** affects the FOV that can be set via set_fov.
365  **
366  *b Arguments:
367  **
368  *a fov - min field-of-view, in degrees
369  */
370  void set_min_fov(float fov);
371 
372  /*l
373  *b Returns:
374  **
375  ** field-of-view of the camera, in degrees
376  */
377  float get_fov();
378 
379  /*l
380  *b Returns:
381  **
382  ** min field-of-view of the camera, in degrees
383  */
384  float get_min_fov();
385 
386  /*l
387  *b Returns:
388  **
389  ** max field-of-view of the camera, in degrees
390  */
391  float get_max_fov();
392 
393  /*l
394  *b Description:
395  **
396  ** This function sets the aspect ratio of the camera.
397  **
398  *b Arguments:
399  **
400  *a aspect - aspect ratio; 1.3333 (4/3) is the default
401  */
402  void set_aspect(float aspect);
403 
404  /*l
405  *b Returns:
406  **
407  ** aspect ratio of the camera
408  */
409  float get_aspect();
410 
411  /*l
412  *b Description:
413  **
414  ** Sets whether or not the orientation and position offsets have any effect.
415  ** See the class-level comments for explanations of these.
416  */
417  void set_offsets_active(int value);
418 
419  /*l
420  *b Description:
421  **
422  ** Returns whether or not the orientation and position offsets have any effect.
423  */
424  int get_offsets_active();
425 
426  /*l
427  *b Description:
428  **
429  ** This function sets the base position of the camera. Will not work if a dolly
430  ** character has been set.
431  **
432  *b Arguments:
433  **
434  *a x, y, z - position in meters from the origin
435  */
436  void set_base_position(float x, float y, float z);
437 
438  /*l
439  *b Description:
440  **
441  ** This function sets the base position of the camera, and disables the offsets.
442  ** Will not work if a dolly character has been set.
443  */
444  void set_position(float x, float y, float z);
445 
446  /*l
447  *b Description:
448  **
449  ** Gets the base position of the camera.
450  **
451  *b Returns:
452  **
453  ** x, y, and z, in meters
454  */
455  void get_base_position(float *x, float *y, float *z);
456 
457  /*l
458  *b Returns:
459  **
460  ** x position, in meters from the origin. Not necessarily the base position of the system, but the actual
461  ** position of the camera itself.
462  */
463  float get_position_x();
464 
465  /*l
466  *b Returns:
467  **
468  ** y position, in meters from the origin. Not necessarily the base position of the system, but the actual
469  ** position of the camera itself.
470  */
471  float get_position_y();
472 
473  /*l
474  *b Returns:
475  **
476  ** z position, in meters from the origin. Not the base position of the system, but the actual
477  ** position of the camera itself.
478  */
479  float get_position_z();
480 
481  /*l
482  *b Description:
483  **
484  ** This function sets the desired base position of the camera. The camera will
485  ** interpolate over time to this position.
486  **
487  *b Arguments:
488  **
489  *a x, y, z - position in meters from the origin
490  */
491  void set_desired_base_position(float x, float y, float z);
492 
493  /*l
494  *b Description:
495  **
496  ** Sets the desired base position and disables any offsets.
497  **
498  *b Arguments:
499  **
500  *a x, y, z - position in meters from the origin
501  *a preserve_fix - obsolete, but kept for backwards compatibility
502  */
503  void set_desired_position(float x, float y, float z, bool preserve_fix = false);
504 
505  /*l
506  *b Description:
507  **
508  ** This function sets the position offset of the camera. See the
509  ** class-level documentation for an explanation. Note that calls to
510  ** set_position_offset_is_in_world_coordinates() might change the effect of
511  ** this function.
512  **
513  *b Arguments:
514  **
515  *a x, y, z - position in meters from the origin
516  */
517  void set_position_offset(float x, float y, float z);
518 
519  /*l
520  *b Description:
521  **
522  ** This function sets the desired position offset of the camera. The camera will
523  ** interpolate over time to this position.
524  **
525  *b Arguments:
526  **
527  *a x, y, z - position in meters from the origin
528  */
529  void set_desired_position_offset(float x, float y, float z);
530 
531  /*l
532  *b Description:
533  **
534  ** Gets the position offset of the camera. Note that it might be
535  ** relative to the base position *and* the base orientation, or just to
536  ** the base position
537  **
538  *b Returns:
539  **
540  ** x, y, and z, in meters
541  */
542  void get_position_offset(float *x, float *y, float *z);
543 
544  /*l
545  *b Description:
546  **
547  ** Sets whether or not the position offset is relative to both base
548  ** position and orientation, or just the position.
549  */
550  void set_position_offset_is_in_world_coordinates(int value);
551 
552  /*l
553  *b Returns:
554  **
555  ** Setting of position_offset_is_in_world_coordinates
556  */
557  int get_position_offset_is_in_world_coordinates();
558 
559  /*l
560  *b Description:
561  **
562  ** This function sets the base orientation of the camera. Note that this
563  ** causes a new fix point to be derived.
564  **
565  ** *NOTE*: Pitch angles are positive for looking down, not up!
566  **
567  *b Arguments:
568  **
569  *a yaw - rotation about z axis, in degrees
570  *a roll - rotation about x axis, in degrees
571  *a pitch - rotation about y axis, in degrees
572  */
573  void set_base_orientation(float yaw, float roll, float pitch);
574 
575  /*l
576  *b Description:
577  **
578  ** This function sets the base orientation of the camera. It will disable
579  ** the offsets.
580  */
581  void set_orientation(float yaw, float roll, float pitch);
582 
583  /*l
584  *b Description:
585  **
586  ** This function sets the roll value of the camera's base orientation.
587  **
588  *b Arguments:
589  **
590  *a roll - rotation about x axis, in radians
591  */
592  void set_orientation_roll(float roll);
593 
594  /*l
595  *b Returns:
596  **
597  ** yaw. roll, pitch. The actual orientation, with base orientation and offset
598  * orientation both applied.
599  */
600  void get_orientation(float *yaw, float *roll, float *pitch);
601 
602  /*l
603  *b Returns:
604  **
605  ** rotation about z axis, in degrees.
606  */
607  float get_orientation_yaw();
608 
609  /*l
610  *b Returns:
611  **
612  ** rotation about x axis, in degrees
613  */
614  float get_orientation_roll();
615 
616  /*l
617  *b Returns:
618  **
619  ** rotation about y axis, in degrees
620  */
621  float get_orientation_pitch();
622 
623  /*l
624  *b Description:
625  **
626  ** This function sets the desired base orientation of the camera, which
627  ** will be interpolated to over time.
628  **
629  ** *NOTE*: Pitch angles are positive for looking down, not up!
630  **
631  *b Arguments:
632  **
633  *a yaw - rotation about z axis, in degrees
634  *a roll - rotation about x axis, in degrees
635  *a pitch - rotation about y axis, in degrees
636  */
637  void set_desired_base_orientation(float yaw, float roll, float pitch);
638 
639  /*l
640  *b Description:
641  **
642  ** Sets the lower limit of the camera pitch *up*. Default is
643  ** very close to -90 degrees.
644  **
645  ** *NOTE*: Pitch angles are positive for looking down, not up!
646  **
647  *b Arguments:
648  **
649  *a limit - rotation about y axis, in degrees
650  */
651  void set_pitch_lower_limit(float limit);
652 
653  /*l
654  *b Returns:
655  **
656  ** lower limit of the camera pitch (up/down)
657  */
658  float get_pitch_lower_limit();
659 
660  /*l
661  *b Description:
662  **
663  ** Sets the upper limit of the camera pitch *down*. Default is
664  ** very close to 90 degrees.
665  **
666  ** *NOTE*: Pitch angles are positive for looking down, not up!
667  **
668  *b Arguments:
669  **
670  *a limit - rotation about y axis, in degrees
671  */
672  void set_pitch_upper_limit(float limit);
673 
674  /*l
675  *b Returns:
676  **
677  ** upper limit of the camera pitch (up/down)
678  */
679  float get_pitch_upper_limit();
680 
681  /*l
682  *b Returns:
683  **
684  ** 1 if pitch has limits, 0 if not
685  */
686  int get_pitch_has_limits();
687 
688  /*l
689  *b Description:
690  **
691  ** The degimbalize angle is intended to compensate for a situation
692  ** that occurs when a camera passes directly over or under the thing
693  ** it is fixed on. Normally, this leads to the yaw suddenly flipping
694  ** 180 degrees. When the degimbalize angle is set, the camera is
695  ** blocked from coming within that many degrees of the vertical.
696  ** Instead, it will move along a circle around the pole.
697  **
698  ** Normally, this value is set to zero. The units are degrees.
699  */
700  void set_degimbalize_angle(float angle);
701 
702  /*l
703  *b Returns:
704  **
705  ** Current degimbalize angle, in degrees.
706  */
707  float get_degimbalize_angle();
708 
709  /*l
710  *b Description:
711  **
712  ** This function sets the orientation offset of the camera. See the
713  ** class-level documentation for an explanation. Note that calls to
714  ** set_orientation_offset_is_relative() might change the effect of
715  ** this function.
716  **
717  *b Arguments:
718  **
719  *a yaw - rotation about z axis, in degrees
720  *a roll - rotation about x axis, in degrees
721  *a pitch - rotation about y axis, in degrees
722  */
723  void set_orientation_offset(float yaw, float roll, float pitch);
724 
725  /*l
726  *b Description:
727  **
728  ** Gets the orientation offset of the camera. Note that it might be
729  ** relative to the base orientation, or relative to world axes.
730  **
731  *b Returns:
732  **
733  ** yaw, pitch, roll, in degrees
734  */
735  void get_orientation_offset(float *yaw, float *roll, float *pitch);
736 
737  /*l
738  *b Description:
739  **
740  ** This function sets the desired orientation offset of the camera, which
741  ** will be interpolated to over time.
742  **
743  ** *NOTE*: Pitch angles are positive for looking down, not up!
744  **
745  *b Arguments:
746  **
747  *a yaw - rotation about z axis, in degrees
748  *a roll - rotation about x axis, in degrees
749  *a pitch - rotation about y axis, in degrees
750  */
751  void set_desired_orientation_offset(float yaw, float roll, float pitch);
752 
753  /*l
754  *b Description:
755  **
756  ** This function sets the distance from the position to the fix
757  ** point. This may move the fix point or the position of the camera,
758  ** depending on locking.
759  **
760  *b Arguments:
761  **
762  *a distance - distance in meters
763  */
764  void set_distance(float distance);
765 
766  /*l
767  *b Description:
768  **
769  ** This function sets the maximum allowed distance from the position
770  ** to the fix point.
771  **
772  *b Arguments:
773  **
774  *a distance - distance in meters; set to -1 if no max to be used
775  */
776  void set_max_track_distance(float distance);
777 
778  /*l
779  *b Description:
780  **
781  ** This function sets the minimum allowed distance from the position
782  ** to the fix point.
783  **
784  *b Arguments:
785  **
786  *a distance - distance in meters; set to -1 if no min to be used
787  */
788  void set_min_track_distance(float distance);
789 
790  /*l
791  *b Returns:
792  **
793  ** distance from position to fix point, in meters
794  */
795  float get_distance();
796 
797  /*l
798  *b Returns:
799  **
800  ** minimum allowed tracking distance, in meters; will be less than
801  ** zero if not applicable
802  */
803  float get_min_track_distance();
804 
805  /*l
806  *b Returns:
807  **
808  ** maximum allowed tracking distance, in meters; will be less than
809  ** zero if not applicable
810  */
811  float get_max_track_distance();
812 
813  /*l
814  *b Description:
815  **
816  ** This function sets the fix point of the camera. Note that this
817  ** affects the orientation. It may also move the camera, depending
818  ** on orientation locking.
819  **
820  *b Arguments:
821  **
822  *a x, y, z - position in meters from the origin
823  */
824  void set_fix(float x, float y, float z);
825 
826  /*l
827  *b Description:
828  **
829  ** Causes the camera to lose whatever fix point it was pointed at.
830  ** The camera will simply maintain its current orientation until
831  ** a new orientation is assigned. Only has a visible effect if the
832  ** camera is in motion.
833  **
834  */
835  void release_fix();
836 
837  /*l
838  *b Returns:
839  **
840  ** fix point in x, in meters. If camera is tracking, the fix point will still
841  ** be in absolute world coordinates.
842  */
843  float get_fix_x();
844 
845  /*l
846  *b Returns:
847  **
848  ** fix point in y, in meters. If camera is tracking, the fix point will still
849  ** be in absolute world coordinates.
850  */
851  float get_fix_y();
852 
853  /*l
854  *b Returns:
855  **
856  ** fix point in z, in meters. If camera is tracking, the fix point will still
857  ** be in absolute world coordinates.
858  */
859  float get_fix_z();
860 
861  /*l
862  *b Description:
863  **
864  ** This function sets the desired fix point of the camera. The camera
865  ** will interpolate to there from its current fix over time.
866  **
867  *b Arguments:
868  **
869  *a x, y, z - position in meters from the origin
870  */
871  void set_desired_fix(float x, float y, float z);
872 
873  /*l
874  *b Description:
875  **
876  ** This function sets the movement mode of the camera.
877  **
878  ** In DI-Guy Scenario in Camera Input Mode, the movement mode of the
879  ** camera determines what will happen when mouse buttons are pressed
880  ** in the view window.
881  **
882  *b Arguments:
883  **
884  *a move_mode - new movement mode of the camera; enumeration
885  *a of type diguyViewCameraMoveMode
886  **
887  *a DIGUY_CAMERA_MOVE_DRAG - mouse input drags and rotates
888  *a the landscape (from user's perspective)
889  *a in a manner similar to an RTS game
890  *a DIGUY_CAMERA_MOVE_ORBIT - mouse input causes the camera to
891  *a circle around a fix point or a
892  *a tracked character
893  *a DIGUY_CAMERA_MOVE_FORWARD - left mouse press moves camera
894  *a forward, right mouse press moves
895  *a camera back
896  *a DIGUY_CAMERA_MOVE_SIDEWAYS - left mouse press moves camera
897  *a left, right mouse press moves
898  *a camera right
899  *a DIGUY_CAMERA_MOVE_VERTICAL - left mouse press moves camera
900  *a up, right mouse press moves
901  *a camera down
902  **
903  ** Note: entering forward, sideways, or vertical mode will cause the
904  ** camera to stop tracking any entity currently being tracked. It's
905  ** impossible to fly the camera around the world and keep it fixed to
906  ** a target at the same time.
907  **
908  *b Returns:
909  **
910  ** 0 on success, -1 on failure
911  */
912  int set_move_mode(diguyViewCameraMoveMode move_mode);
913 
914  /*l
915  *b Returns:
916  **
917  ** the most recent setting made by set_move_mode()
918  */
919  diguyViewCameraMoveMode get_move_mode();
920 
921  /*l
922  *b Description:
923  **
924  ** This function sets the movement speed of the camera when the
925  ** camera is translating due to user input.
926  **
927  ** In DI-Guy Scenario in Camera Input Mode, the movement speed of the
928  ** camera determines how fast the camera will move when mouse buttons
929  ** are pressed in the view window.
930  **
931  *b Arguments:
932  **
933  *a speed - speed of camera movement is meters per second
934  **
935  *b Returns:
936  **
937  ** 0 on success, -1 on failure
938  */
939  int set_speed(float speed);
940 
941  /*l
942  *b Returns:
943  **
944  ** the most recent setting made by set_speed()
945  */
946  float get_speed();
947 
948  /*l
949  *b Description:
950  **
951  ** This function increases the movement speed of the camera
952  ** when the camera is translating due to user input. The
953  ** increase is typically by a factor of 2.
954  **
955  *b Returns:
956  **
957  ** 0 on success, -1 on failure
958  */
959  int increase_speed();
960 
961  /*l
962  *b Description:
963  **
964  ** This function decreases the movement speed of the camera
965  ** when the camera is translating due to user input. The
966  ** decrease is typically by a factor of 2.
967  **
968  *b Returns:
969  **
970  ** 0 on success, -1 on failure
971  */
972  int decrease_speed();
973 
974  /*l
975  *b Description:
976  **
977  ** This function sets the projection mode of the camera.
978  **
979  ** In DI-Guy Scenario in Camera Input Mode, the movement
980  ** mode of the camera determines what will happen when
981  ** mouse buttons are pressed in the view window.
982  **
983  *b Arguments:
984  **
985  *a projection_mode - new projection mode of the camera;
986  *a enumeration of type
987  *a diguyViewCameraProjectionMode
988  **
989  *a DIGUY_CAMERA_PROJECTION_PERSPECTIVE - standard perspective
990  *a camera, can move and
991  *a rotate freely
992  *a DIGUY_CAMERA_PROJECTION_PLANVIEW_XY - always views in negative
993  *a Z direction
994  *a DIGUY_CAMERA_PROJECTION_PLANVIEW_XZ - always views in negative
995  *a Y direction
996  *a DIGUY_CAMERA_PROJECTION_PLANVIEW_YZ - always views in negative
997  *a X direction
998  **
999  *b Notes:
1000  **
1001  ** In projection modes, only the fix point and the distance from it
1002  ** can be changed. Dollying and tracking are each possible, and
1003  ** effectively the same, but can't be done at once.
1004  **
1005  */
1006  int set_projection_mode(diguyViewCameraProjectionMode projection_mode);
1007 
1008  /*l
1009  *b Returns:
1010  **
1011  ** the most recent setting made by set_projection_mode()
1012  */
1013  diguyViewCameraProjectionMode get_projection_mode();
1014 
1016  void set_height_above_terrain(float height);
1017 
1018 /*****************************************************************************/
1033  /*l
1034  *b Description:
1035  **
1036  ** Loads the specified settings into this camera.
1037  **
1038  *b Returns:
1039  **
1040  ** 0 on success, -1 on failure
1041  */
1042  int load_settings(const char* settings_name);
1043 
1044  /*l
1045  *b Description:
1046  **
1047  ** Loads the specified settings into this camera.
1048  **
1049  *b Returns:
1050  **
1051  ** 0 on success, -1 on failure
1052  */
1053  int load_settings(diguyViewCameraSettings* settings);
1054 
1055  /*l
1056  *b Description:
1057  **
1058  ** This function applies this camera's settings and internal
1059  ** state to the actual view frustrum. It should be called as
1060  ** often as the camera needs to be updated. Note that code that
1061  ** controls the camera's motions (e.g. when the camera is
1062  ** tracking a character) gets called via
1063  ** diguyScenario::update().
1064  **
1065  *i OpenGL Version:
1066  **
1067  ** This function sets the current viewpoint in these
1068  ** environments based on information in this camera.
1069  **
1070  *i Direct3D Version:
1071  **
1072  ** This function has no effect. The viewpoint in
1073  ** these environments must be set manually.
1074  */
1075  void apply_settings();
1076 
1077 
1078 /*****************************************************************************/
1155  /*l
1156  *b Description:
1157  **
1158  ** This function sets the base position of this camera using
1159  ** double precision floating point numbers. The numbers
1160  ** will be converted internally into a DI-Guy far position.
1161  **
1162  *b Arguments:
1163  **
1164  *a x - x position, in meters
1165  *a y - y position, in meters
1166  *a z - z position, in meters
1167  */
1168  void set_base_position_double(double x, double y, double z);
1169 
1170  /*l
1171  *b Description:
1172  **
1173  ** Equivalent to set_base_position_double(), but disables offsets.
1174  */
1175  void set_position_double(double x, double y, double z);
1176 
1177  /*l
1178  *b Description:
1179  **
1180  ** Gets the base position of the camera.
1181  **
1182  *b Returns:
1183  **
1184  ** x, y, and z, in meters
1185  */
1186  void get_base_position_double(double *x, double *y, double *z);
1187 
1188  /*l
1189  *b Description:
1190  **
1191  ** This function returns the world-space position of this
1192  ** camera. These values are computed from the DI-Guy
1193  ** far position of the camera. The results are placed into
1194  ** the passed pointers. If camera is dollied, the position will
1195  ** still indicate its absolute world coordinates.
1196  **
1197  *b Arguments:
1198  **
1199  *a x - x position, in meters
1200  *a y - y position, in meters
1201  *a z - z position, in meters
1202  */
1203  void get_position_double(double* x, double* y, double* z);
1204 
1205  /*l
1206  *b Description:
1207  **
1208  ** This function returns the world-space origin of the far
1209  ** position segment the camera is in. This segment origin
1210  ** plus the position segment offset returned by
1211  ** get_position_segment_offset() yields the final world-space
1212  ** position of the camera.
1213  **
1214  ** The results are placed into the passed pointers.
1215  **
1216  *b Arguments:
1217  **
1218  *a x - x component of origin, in meters
1219  *a y - y component of origin, in meters
1220  *a z - z component of origin, in meters
1221  */
1222  void get_segment_origin(float* x, float* y, float* z);
1223 
1224  /*l
1225  *b Description:
1226  **
1227  ** This function returns the far position segment offset
1228  ** part of the camera's base position. The results are placed
1229  ** into the passed pointers.
1230  **
1231  *b Arguments:
1232  **
1233  *a x - x component of segment offset, in meters
1234  *a y - y component of segment offset, in meters
1235  *a z - z component of segment offset, in meters
1236  */
1237  void get_position_segment_offset(float* x, float* y, float* z);
1238 
1239  /*l
1240  *b Description:
1241  **
1242  ** This function returns the far position offset portion of
1243  ** the camera's fix point. The results are placed into the
1244  ** passed pointers.
1245  **
1246  *b Arguments:
1247  **
1248  *a x - x component of fix segment offset, in meters
1249  *a y - y component of fix segment offset, in meters
1250  *a z - z component of fix segment offset, in meters
1251  */
1252  void get_fix_segment_offset(float* x, float* y, float* z);
1253 
1254  /*l
1255  *b Description:
1256  **
1257  ** This function sets the fix point of the camera using
1258  ** double precision floating point numbers. The numbers
1259  ** will be converted internally into a DI-Guy far position. Note
1260  ** that this affects the orientation.
1261  **
1262  *b Arguments:
1263  **
1264  *a x - x position, in meters
1265  *a y - y position, in meters
1266  *a z - z position, in meters
1267  */
1268  void set_fix_double(double x, double y, double z);
1269 
1271  void convert_to_local_camera(double * x, double * y, double * z);
1272 
1273 /*****************************************************************************/
1283  /*l
1284  *b Description:
1285  **
1286  ** This function sets the name of the character the camera should
1287  ** look at, if such a character can be found. This will cause
1288  ** fix values to change over time.
1289  **
1290  ** By default the camera will look at the idealized position of
1291  ** the character (a spot on the ground typically under the center
1292  ** of gravity for human characters). To look at a particular part
1293  ** of a character, call set_track_link_name().
1294  **
1295  ** The spot looked at on a link can be offset by calling
1296  ** set_track_offset(). Whether the offset is in world coordinates
1297  ** or character-local coordinates is controlled by a call to
1298  ** set_track_offset_is_in_world_coordinates().
1299  **
1300  ** Note that tracking and dollying can be combined. For example,
1301  ** picture a camera affixed to a pedestrian walking along. The
1302  ** camera might track a car going by in a different direction. The
1303  ** dolly entity and the tracked entity can even be the same.
1304  **
1305  ** Setting a track entity will change the movement mode of the camera
1306  ** to stationary or orbit. This is because the camera can't be flown
1307  ** around the world if it is fixed on something.
1308  **
1309  *b Arguments:
1310  **
1311  *a track_name - name of character to look at, or NULL if no character
1312  *a is to be tracked
1313  **
1314  **
1315  *b C++ Example
1316  **
1317  ** The following example shows how to use some of the pose
1318  ** functions.
1319  **
1320  *e //
1321  *e // Get a pointer to the primary view's camera, and
1322  *e // to the first character.
1323  *e //
1324  *e diguyViewCamera* camera = scenario->get_scenario_camera();
1325  *e diguyCharacter* character = scenario->get_character_at_index(0);
1326  *e
1327  *e //
1328  *e // Look just a little bit above the character's head.
1329  *e //
1330  *e camera->set_track_name(character->get_name());
1331  *e camera->set_track_link_name("cervical");
1332  *e camera->set_track_offset(0.0f, 0.0f, 0.1f);
1333  */
1334  void set_track_name(const char* track_name);
1335 
1336  /*l
1337  *b Returns:
1338  **
1339  ** name of character to be looked at; see set_track_name()
1340  */
1341  const char* get_track_name();
1342 
1343  /*l
1344  *b Description:
1345  **
1346  ** This function sets the name of the group the camera will track.
1347  **
1348  *b Arguments:
1349  **
1350  *a track_name - name of group to look at; pass NULL to un-set track
1351  *a group
1352  */
1353  void set_track_group_name(const char* track_name);
1354 
1355  /*l
1356  *b Returns:
1357  **
1358  ** name of group to be looked at; see set_track_group_name()
1359  */
1360  const char* get_track_group_name();
1361 
1362  /*l
1363  *b Description:
1364  **
1365  ** This function sets the name of the link to be tracked on
1366  ** the character specified by set_track_name(). See
1367  ** set_track_name() for more information.
1368  **
1369  *b Arguments:
1370  **
1371  *a track_link_name - name of link to look at, or NULL if the base
1372  *a link is to be tracked
1373  */
1374  void set_track_link_name(const char* track_link_name);
1375 
1376  /*l
1377  *b Returns:
1378  **
1379  ** name of link to be looked at; see set_track_link_name()
1380  */
1381  const char* get_track_link_name();
1382 
1383  /*l
1384  *b Description:
1385  **
1386  ** This function sets the position of the look-at point relative
1387  ** to the tracked entity. Note that this overrides any position
1388  ** given to set_fix().
1389  **
1390  ** Whether the offset is in world coordinates or character-local
1391  ** coordinates is controlled by a call to
1392  ** set_track_offset_is_in_world_coordinates().
1393  **
1394  *b Arguments:
1395  **
1396  *a x, y, z - offset, in meters, of track point
1397  */
1398  void set_track_offset(float x, float y, float z);
1399 
1400  /*l
1401  *b Returns:
1402  **
1403  ** x component of track offset; see set_track_offset()
1404  */
1405  float get_track_offset_x();
1406 
1407  /*l
1408  *b Returns:
1409  **
1410  ** y component of track offset; see set_track_offset()
1411  */
1412  float get_track_offset_y();
1413 
1414  /*l
1415  *b Returns:
1416  **
1417  ** z component of track offset; see set_track_offset()
1418  */
1419  float get_track_offset_z();
1420 
1421  /*l
1422  *b Description:
1423  **
1424  ** This function sets whether the offset of the track
1425  ** position is character-relative (pass 0) or in
1426  ** world coordinates (pass 1).
1427  **
1428  ** Default value is 0.
1429  **
1430  *b Arguments:
1431  **
1432  *a value - pass 0 for character-relative, 0 for world coordinates
1433  */
1434  void set_track_offset_is_in_world_coordinates(int value);
1435 
1436  /*l
1437  *b Returns:
1438  **
1439  ** the most recent setting made by set_track_offset_is_in_world_coordinates().
1440  */
1441  int get_track_offset_is_in_world_coordinates();
1442 
1443  /*l
1444  *b Description:
1445  **
1446  ** Sets the dolly entity. The "dolly" is the character that the camera
1447  ** "rides" on, though at an offset. Picture the camera cart commonly
1448  ** used in film-making, with the camera viewing the subject from the
1449  ** end of a crane that extends out from the cart. The cart would be the
1450  ** dolly character.
1451  **
1452  ** Once you set a dolly character, you lose the ability to set the base
1453  ** position and orientation of the camera. However, you can still set the
1454  ** position offset and the orientation offset.
1455  **
1456  ** Note that tracking and dollying can be combined. For example,
1457  ** picture a camera affixed to a pedestrian walking along. The
1458  ** camera might track a car going by in a different direction. The
1459  ** dolly entity and the tracked entity can even be the same.
1460  **
1461  ** Setting a dolly entity may switch the camera's movement mode to orbit,
1462  ** if the character is already tracking something. The tracked entity will
1463  ** be orbited, but if the dolly character moves, the camera will still maintain
1464  ** its position relative to that character.
1465  **
1466  *b Arguments:
1467  **
1468  *a dolly_name - name of entity to look from, or NULL if none
1469  */
1470  void set_dolly_name(const char* dolly_name);
1471 
1472  /*l
1473  *b Description:
1474  **
1475  ** This function gets the name of the dolly entity.
1476  **
1477  *b Arguments:
1478  **
1479  *a dolly_name - name of character to look from, or NULL
1480  */
1481  const char* get_dolly_name();
1482 
1483  /*l
1484  *b Description:
1485  **
1486  ** Sets the position at which the camera will be relative to the
1487  ** dolly entity. This function does the same thing as set_position_offset(),
1488  ** but remains here for backwards compatibility.
1489  **
1490  ** Whether the offset is in world coordinates or character-local
1491  ** coordinates is controlled by a call to
1492  ** set_dolly_offset_is_in_world_coordinates().
1493  **
1494  *b Arguments:
1495  **
1496  *a x, y, z - offset, in meters, of dolly point
1497  */
1498  void set_dolly_offset(float x, float y, float z);
1499 
1500  /*l
1501  *b Returns:
1502  **
1503  ** x component of position offset; see set_dolly_offset()
1504  */
1505  float get_dolly_offset_x();
1506 
1507  /*l
1508  *b Returns:
1509  **
1510  ** y component of position offset; see set_dolly_offset()
1511  */
1512  float get_dolly_offset_y();
1513 
1514  /*l
1515  *b Returns:
1516  **
1517  ** z component of position offset; see set_dolly_offset()
1518  */
1519  float get_dolly_offset_z();
1520 
1521  /*l
1522  *b Description:
1523  **
1524  ** This function sets the name of the link to be dollied on
1525  ** the character specified by set_dolly_name().
1526  **
1527  *b Arguments:
1528  **
1529  *a dolly_link_name - name of link to look from, or NULL if the
1530  *a position link is to influence camera position
1531  */
1532  void set_dolly_link_name(const char* dolly_link_name);
1533 
1534  /*l
1535  *b Returns:
1536  **
1537  ** name of link to be looked from; see set_dolly_link_name()
1538  */
1539  const char* get_dolly_link_name();
1540 
1541  /*l
1542  *b Description:
1543  **
1544  ** This function sets whether the position offset is character-relative
1545  ** (pass 0) or in world coordinates (pass 1).
1546  **
1547  ** Default value is 0.
1548  **
1549  *b Arguments:
1550  **
1551  *a value - pass 0 for character-relative, 1 for world coordinates
1552  */
1553  void set_dolly_offset_is_in_world_coordinates(int value);
1554 
1555  /*l
1556  *b Returns:
1557  **
1558  ** the most recent setting made by
1559  ** set_dolly_offset_is_in_world_coordinates().
1560  */
1561  int get_dolly_offset_is_in_world_coordinates();
1562 
1563  /*l
1564  *b Description:
1565  **
1566  ** Sets whether the camera's orientation offset is relative or not. If it's
1567  ** relative, it will be in the coordinate system established by the base
1568  ** orientation (or the orientation of the dolly character). If not relative,
1569  ** it will be in the world's coordinate system.
1570  **
1571  ** For example, setting an orientation of (-90, 0, 0) when the dolly entity
1572  ** is rolled 45 degrees to the left will cause the camera to look towards
1573  ** the area to the dolly entity's right, which will be up towards to the
1574  ** sky. If the dolly entity rolls 90 degrees to the right (from where it
1575  ** is) the camera will now be facing the ground.
1576  **
1577  ** When the camera is tracking something, however, the orientation offset's
1578  ** yaw and pitch components will be derived.
1579  **
1580  ** Default value is 0.
1581  **
1582  *b Arguments:
1583  **
1584  *a value - pass 1 to match orientation, 0 to not match
1585  */
1586  void set_orientation_offset_is_relative(int value);
1587 
1588  /*l
1589  *b Returns:
1590  **
1591  ** the most recent setting made by set_orientation_offset_is_relative().
1592  */
1593  int get_orientation_offset_is_relative();
1594 
1595  /*l
1596  *b Description:
1597  **
1598  ** This function has been deprecated, but remains for backwards compatibility.
1599  ** It is replaced by set_orientation_offset_is_relative()
1600  */
1601  void set_match_dolly_orientation(int value);
1602 
1603  /*l
1604  *b Description:
1605  **
1606  ** This function has been deprecated, but remains for backwards compatibility.
1607  ** It is replaced by get_orientation_offset_is_relative()
1608  */
1609  int get_match_dolly_orientation();
1610 
1611  /*l
1612  *b Description:
1613  **
1614  ** If activated, the camera will behave differently when both dollying and tracking.
1615  ** The base orientation will swivel towards the target. Move the position offset
1616  ** back a bit, and the dolly character will remain between the camera and target.
1617  */
1618  void set_use_special_track_mode(int value);
1619 
1620  /*l
1621  *b Returns:
1622  **
1623  ** 1, if special track mode is being used.
1624  */
1625  int get_use_special_track_mode();
1626 
1627  /*l
1628  *b Returns:
1629  **
1630  ** if DI-Guy Scenario is rendering simplified 2D representations of
1631  ** characters.
1632  */
1633  int get_symbolic_view();
1634 
1635 
1636 /*****************************************************************************/
1642  /*l
1643  *b Description:
1644  **
1645  ** This is an enumeration of the different callbacks
1646  ** that can be registered with add_callback() and
1647  ** add_callback_script().
1648  **
1649  *b Usable From:
1650  **
1651  *- - C++
1652  *- - Script
1653  */
1654  enum {
1655  CALLBACK_ID_SETTINGS_CHANGED = 1
1656  };
1657 
1658 #ifdef CPLUSPLUS_ONLY
1659 
1660  /*l
1661  *b Description:
1662  **
1663  ** This function adds a user callback.
1664  **
1665  *b Arguments:
1666  **
1667  *a callback - pointer to function with prototype
1668  *a diguyViewCameraCallback (typedefed above)
1669  *a callback_id - integer id of when this callback is to be called
1670  *a callback_params - struct containing additional parameters
1671  *a needed by some callbacks; actual type depends
1672  *a on callback_id
1673  *a callback_user_data - pointer for user's own use; DI-Guy will
1674  *a do nothing to the contents of this pointer
1675  *a beyond passing it back when the callback is
1676  *a invoked
1677  **
1678  ** callback_id should be one of the following values:
1679  **
1680  *i CALLBACK_ID_SETTINGS_CHANGED
1681  **
1682  ** This callback will be called if the current settings of this
1683  ** camera change
1684  **
1685  ** Callbacks return a value of type diguyCallbackReturn,
1686  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
1687  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
1688  ** of the function will not be called; the callback is asserting
1689  ** that it has done everything necessary for the function call.
1690  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
1691  ** handler for the function will be called after the callback.
1692  **
1693  *b Returns:
1694  **
1695  ** 0 on success, -1 on failure
1696  */
1697  int add_callback(int callback_id,
1698  diguyViewCameraCallback* callback,
1699  void* callback_params = 0,
1700  void* callback_user_data = 0);
1701 
1702  /*l
1703  *b Description:
1704  **
1705  ** This function removes a user callback. All callbacks matching
1706  ** the specified callback_id and callback function will be removed.
1707  **
1708  *b Arguments:
1709  **
1710  *a callback_id - integer id of when this callback is to be called
1711  *a callback - pointer to function with prototype
1712  *a diguyViewCameraCallback (typedefed above)
1713  **
1714  *b Returns:
1715  **
1716  ** 0 on success, -1 on failure
1717  */
1718  int remove_callback(int callback_id,
1719  diguyViewCameraCallback* callback);
1720 
1721  /*l
1722  *b Description:
1723  **
1724  ** This function removes a user callback. All callbacks matching
1725  ** the specified callback_id and callback_user_data pointer will
1726  ** be removed.
1727  **
1728  *b Arguments:
1729  **
1730  *a callback_id - integer id of when this callback is to be called
1731  *a callback_user_data - pointer for user's own use
1732  **
1733  *b Returns:
1734  **
1735  ** 0 on success, -1 on failure
1736  */
1737  int remove_callback_with_user_data(int callback_id,
1738  void* callback_user_data);
1739 
1740 #endif
1741 
1742 /*****************************************************************************/
1747  /*l
1748  *b Description:
1749  **
1750  ** This function adds a user callback script. Callback scripts can
1751  ** be removed with remove_callback_script().
1752  **
1753  *b Arguments:
1754  **
1755  *a callback_id - integer id of the callback
1756  *a callback_script - script text of callback to be added
1757  *a callback_script_type - the type of script contained in
1758  *a callback_script
1759  **
1760  ** If NULL is passed for callback_script_type, a default script type
1761  ** will be derived based on the default script interpreter of the
1762  ** scenario.
1763  **
1764  *i lua specific:
1765  **
1766  ** When the script is called, the object for which it is being called
1767  ** will be in the callback_object local.
1768  **
1769  ** To pass NULL when calling from a lua script, use nil.
1770  **
1771  *b Returns:
1772  **
1773  ** 0 on success, -1 on failure
1774  */
1775  int add_callback_script(int callback_id,
1776  const char* callback_script,
1777  const char* callback_script_type = NULL);
1778 
1779  /*l
1780  *b Description:
1781  **
1782  ** This function removes a user callback script previously added with
1783  ** add_callback_script().
1784  **
1785  *b Arguments:
1786  **
1787  *a callback_id - integer id of the callback
1788  *a callback_script - script text of callback previously added
1789  *a callback_script_type - the type of script contained in
1790  *a callback_script
1791  **
1792  ** If NULL is passed for callback_script, all callback
1793  ** scripts whose ids match callback_id and whose types match
1794  ** callback_script_type will be removed.
1795  **
1796  ** If NULL is passed for callback_script_type, a default script type
1797  ** will be derived based on the default script interpreter of the
1798  ** scenario.
1799  **
1800  *i lua specific:
1801  **
1802  ** To pass NULL when calling from a lua script, use nil.
1803  **
1804  *b Returns:
1805  **
1806  ** 0 on success, -1 on failure
1807  */
1808  int remove_callback_script(int callback_id,
1809  const char* callback_script,
1810  const char* callback_script_type = NULL);
1811 
1812 
1813 /****************************************************************************/
1814 /****************************************************************************/
1815 /****************************************************************************/
1827 /****************************************************************************/
1828 /****************************************************************************/
1829 /****************************************************************************/
1830 
1831  /*l
1832  ** Prints information about the camera's current state to the log.
1833  */
1834  void print_debug_info(const char *tag);
1835 
1836  /*l
1837  *b Description:
1838  **
1839  ** Sets number of degrees by which the camera FOV should change
1840  ** whenever the user moves the mouse wheel.
1841  **
1842  *b Arguments:
1843  **
1844  *a fov_change - change to FOV in degrees
1845  **
1846  */
1847  void set_speed_fov_degrees_per_wheel_click(float fov_change);
1848 
1849  /*l
1850  *b Description:
1851  **
1852  ** Gets the number of degrees by which the camera FOV should change
1853  ** whenever the user moves the mouse wheel.
1854  **
1855  *b Returns:
1856  **
1857  ** change to FOV, in degrees
1858  */
1859  float get_speed_fov_degrees_per_wheel_click();
1860 
1861  /*l
1862  *b Description:
1863  **
1864  ** Sets how fast the camera should move in various flyaround modes.
1865  **
1866  *b Arguments:
1867  **
1868  *a speed - flying speed in meters per second
1869  */
1870  void set_speed_meters_per_second(float speed);
1871 
1872  /*l
1873  *b Description:
1874  **
1875  ** Gets how fast the camera should move in various flyaround modes.
1876  **
1877  *b Returns:
1878  **
1879  ** speed in meters per second
1880  */
1881  float get_speed_meters_per_second();
1882 
1883  /*l
1884  *b Description:
1885  **
1886  ** Sets whether the camera should smoothly servo to its new desired
1887  ** position/heading (as opposed to instantly popping there).
1888  **
1889  *b Arguments:
1890  **
1891  *a target (position, orientation, or fix)
1892  *a require - 0 for smooth servoing
1893  */
1894  void set_require_smooth_servo(diguyViewCameraServoTarget target, int require);
1895 
1896  /*l
1897  *b Description:
1898  **
1899  ** Similar to main set_require_smooth_servo(), but sets value for all
1900  ** targets. Here for backwards compatibility.
1901  */
1902  void set_require_smooth_servo(int require);
1903 
1904  /*l
1905  *b Description:
1906  **
1907  ** Gets whether the camera should smoothly servo to its new desired
1908  ** position/heading (as opposed to instantly popping there).
1909  **
1910  *b Returns:
1911  **
1912  ** 1 if smooth servoing is required; 0 if not
1913  */
1914  int get_require_smooth_servo(diguyViewCameraServoTarget target);
1915 
1916  /*l
1917  *b Description:
1918  **
1919  ** Sets a factor that determines how smoothly the camera should servo.
1920  ** If a high number (e.g. 10.0), the camera will servo quickly. If
1921  ** a low number (e.g. 1.0), it will servo more slowly.
1922  **
1923  *b Arguments:
1924  **
1925  *a target (position, orientation, or fix)
1926  *a modifier
1927  */
1928  void set_servo_time_modifier( diguyViewCameraServoTarget target, float modifier );
1929 
1930  /*l
1931  *b Description:
1932  **
1933  ** Similar to main set_servo_time_modifier(). Sets value for all targets.
1934  */
1935  void set_servo_time_modifier( float modifier );
1936 
1937  /*l
1938  *b Returns:
1939  **
1940  ** The servo modifier time that determines how smoothly the camera
1941  ** should servo.
1942  */
1943  float get_servo_time_modifier(diguyViewCameraServoTarget target);
1944 
1945  /*l
1946  *b Description:
1947  **
1948  ** Sets if the camera mover should make an effort to avoid obstacles
1949  ** that block visibility while a character or group is being tracked.
1950  **
1951  *b Arguments:
1952  **
1953  *a avoids - true for avoidance
1954  */
1955  void set_track_camera_avoids_obstacles(int avoid);
1956 
1957  /*l
1958  *b Description:
1959  **
1960  ** Gets whether the camera mover should make an effort to avoid
1961  ** obstacles that block visibility while a character or group is
1962  ** being tracked.
1963  **
1964  *b Returns:
1965  **
1966  ** 1 if obstacle avoidance should be attempted
1967  */
1968  int get_track_camera_avoids_obstacles();
1969 
1970  /*l
1971  *b Description:
1972  **
1973  ** Sets if the camera should not respond to mouse input from DI-Guy Scenario.
1974  ** In Scenario, responding is the default. In API Mode, not responding is the default.
1975  **
1976  *b Arguments:
1977  **
1978  *a avoids - 1 to ignore mouse drags; 0 if not
1979  */
1980  void set_ignore_mouse_drags(int ignore);
1981 
1982  /*l
1983  *b Description:
1984  **
1985  ** Gets whether the camera should ignore mouse input from DI-Guy Scenario.
1986  **
1987  *b Returns:
1988  **
1989  ** 1 if mouse drags are to be ignored; 0 if not
1990  */
1991  int get_ignore_mouse_drags();
1992 
1993 #ifdef CPLUSPLUS_ONLY
1994  /*l
1995  *b Description:
1996  **
1997  ** Allows the diguy camera to build an internal frustum needed for
1998  ** doing character and scene object culling. projection_matrix and
1999  ** model_matrix should be pointers to 16 floats in OpenGL style matrix
2000  ** format.
2001  **
2002  *b This function is not callable from lua.
2003  */
2004  void update_frustum(float* proj_matrix, float* model_matrix);
2005 
2006 #endif
2007 
2012 #ifdef CPLUSPLUS_ONLY
2013 
2014  bdiCamera* get_scripted_object() {return m_camera;}
2015 
2016 private:
2017 
2018  /*l
2019  ** A private constructor.
2020  */
2021  diguyViewCamera(bdiCamera* camera);
2022 
2023  /*l
2024  ** A pointer to internal data.
2025  */
2026  bdiCamera* m_camera;
2027 
2028  friend class bdiCamera;
2029 
2030  static bool s_warn_if_position_set_ignored;
2031 
2032 #endif
2033 
2034 };
2035 
2036 #endif /* __diguyViewCamera_H */
2037 
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:296
diguyViewCameraMoveMode
DI-Guy camera move modes.
Definition: diguy_constants.h:266
diguyViewCameraServoTarget
Aspects of the DI-Guy camera that can be servoed.
Definition: diguy_constants.h:283
The class that represents a camera in the world.
Definition: diguyViewCamera.h:260
diguyCallbackReturn diguyViewCameraCallback(diguyViewCamera *camera, int callback_id, void *callback_params, void *callback_user_data)
Definition: diguy_typedefs.h:205