class_camera.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Camera:
  4. Camera
  5. ======
  6. **Inherits:** :ref:`Spatial<class_spatial>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`InterpolatedCamera<class_interpolatedcamera>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Camera node, displays from a point of view.
  12. Member Functions
  13. ----------------
  14. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`Vector3<class_vector3>` | :ref:`project_ray_normal<class_Camera_project_ray_normal>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  16. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`Vector3<class_vector3>` | :ref:`project_local_ray_normal<class_Camera_project_local_ray_normal>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  18. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Vector3<class_vector3>` | :ref:`project_ray_origin<class_Camera_project_ray_origin>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  20. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Vector2<class_vector2>` | :ref:`unproject_position<class_Camera_unproject_position>` **(** :ref:`Vector3<class_vector3>` world_point **)** const |
  22. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`is_position_behind<class_Camera_is_position_behind>` **(** :ref:`Vector3<class_vector3>` world_point **)** const |
  24. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Vector3<class_vector3>` | :ref:`project_position<class_Camera_project_position>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  26. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`set_perspective<class_Camera_set_perspective>` **(** :ref:`float<class_float>` fov, :ref:`float<class_float>` z_near, :ref:`float<class_float>` z_far **)** |
  28. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`set_orthogonal<class_Camera_set_orthogonal>` **(** :ref:`float<class_float>` size, :ref:`float<class_float>` z_near, :ref:`float<class_float>` z_far **)** |
  30. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`make_current<class_Camera_make_current>` **(** **)** |
  32. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`clear_current<class_Camera_clear_current>` **(** **)** |
  34. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`is_current<class_Camera_is_current>` **(** **)** const |
  36. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Transform<class_transform>` | :ref:`get_camera_transform<class_Camera_get_camera_transform>` **(** **)** const |
  38. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`float<class_float>` | :ref:`get_fov<class_Camera_get_fov>` **(** **)** const |
  40. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`float<class_float>` | :ref:`get_size<class_Camera_get_size>` **(** **)** const |
  42. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`float<class_float>` | :ref:`get_zfar<class_Camera_get_zfar>` **(** **)** const |
  44. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`float<class_float>` | :ref:`get_znear<class_Camera_get_znear>` **(** **)** const |
  46. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_projection<class_Camera_get_projection>` **(** **)** const |
  48. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_visible_layers<class_Camera_set_visible_layers>` **(** :ref:`int<class_int>` mask **)** |
  50. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`get_visible_layers<class_Camera_get_visible_layers>` **(** **)** const |
  52. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_environment<class_Camera_set_environment>` **(** :ref:`Environment<class_environment>` env **)** |
  54. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Environment<class_environment>` | :ref:`get_environment<class_Camera_get_environment>` **(** **)** const |
  56. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_keep_aspect_mode<class_Camera_set_keep_aspect_mode>` **(** :ref:`int<class_int>` mode **)** |
  58. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`int<class_int>` | :ref:`get_keep_aspect_mode<class_Camera_get_keep_aspect_mode>` **(** **)** const |
  60. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. Numeric Constants
  62. -----------------
  63. - **PROJECTION_PERSPECTIVE** = **0** --- Perspective Projection (object's size on the screen becomes smaller when far away).
  64. - **PROJECTION_ORTHOGONAL** = **1** --- Orthogonal Projection (objects remain the same size on the screen no matter how far away they are).
  65. - **KEEP_WIDTH** = **0**
  66. - **KEEP_HEIGHT** = **1**
  67. Description
  68. -----------
  69. Camera is a special node that displays what is visible from its current location. Cameras register themselves in the nearest :ref:`Viewport<class_viewport>` node (when ascending the tree). Only one camera can be active per viewport. If no viewport is available ascending the tree, the Camera will register in the global viewport. In other words, a Camera just provides *3D* display capabilities to a :ref:`Viewport<class_viewport>`, and, without one, a scene registered in that :ref:`Viewport<class_viewport>` (or higher viewports) can't be displayed.
  70. Member Function Description
  71. ---------------------------
  72. .. _class_Camera_project_ray_normal:
  73. - :ref:`Vector3<class_vector3>` **project_ray_normal** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  74. Return a normal vector in worldspace, that is the result of projecting a point on the :ref:`Viewport<class_viewport>` rectangle by the camera projection. This is useful for casting rays in the form of (origin,normal) for object intersection or picking.
  75. .. _class_Camera_project_local_ray_normal:
  76. - :ref:`Vector3<class_vector3>` **project_local_ray_normal** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  77. .. _class_Camera_project_ray_origin:
  78. - :ref:`Vector3<class_vector3>` **project_ray_origin** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  79. Return a 3D position in worldspace, that is the result of projecting a point on the :ref:`Viewport<class_viewport>` rectangle by the camera projection. This is useful for casting rays in the form of (origin,normal) for object intersection or picking.
  80. .. _class_Camera_unproject_position:
  81. - :ref:`Vector2<class_vector2>` **unproject_position** **(** :ref:`Vector3<class_vector3>` world_point **)** const
  82. Return how a 3D point in worldspace maps to a 2D coordinate in the :ref:`Viewport<class_viewport>` rectangle.
  83. .. _class_Camera_is_position_behind:
  84. - :ref:`bool<class_bool>` **is_position_behind** **(** :ref:`Vector3<class_vector3>` world_point **)** const
  85. .. _class_Camera_project_position:
  86. - :ref:`Vector3<class_vector3>` **project_position** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  87. .. _class_Camera_set_perspective:
  88. - void **set_perspective** **(** :ref:`float<class_float>` fov, :ref:`float<class_float>` z_near, :ref:`float<class_float>` z_far **)**
  89. Set the camera projection to perspective mode, by specifying a *FOV* Y angle in degrees (FOV means Field of View), and the *near* and *far* clip planes in worldspace units.
  90. .. _class_Camera_set_orthogonal:
  91. - void **set_orthogonal** **(** :ref:`float<class_float>` size, :ref:`float<class_float>` z_near, :ref:`float<class_float>` z_far **)**
  92. Set the camera projection to orthogonal mode, by specifying a width and the *near* and *far* clip planes in worldspace units. (As a hint, 2D games often use this projection, with values specified in pixels)
  93. .. _class_Camera_make_current:
  94. - void **make_current** **(** **)**
  95. Make this camera the current Camera for the :ref:`Viewport<class_viewport>` (see class description). If the Camera Node is outside the scene tree, it will attempt to become current once it's added.
  96. .. _class_Camera_clear_current:
  97. - void **clear_current** **(** **)**
  98. .. _class_Camera_is_current:
  99. - :ref:`bool<class_bool>` **is_current** **(** **)** const
  100. Return whether the Camera is the current one in the :ref:`Viewport<class_viewport>`, or plans to become current (if outside the scene tree).
  101. .. _class_Camera_get_camera_transform:
  102. - :ref:`Transform<class_transform>` **get_camera_transform** **(** **)** const
  103. Get the camera transform. Subclassed cameras (such as CharacterCamera) may provide different transforms than the :ref:`Node<class_node>` transform.
  104. .. _class_Camera_get_fov:
  105. - :ref:`float<class_float>` **get_fov** **(** **)** const
  106. .. _class_Camera_get_size:
  107. - :ref:`float<class_float>` **get_size** **(** **)** const
  108. .. _class_Camera_get_zfar:
  109. - :ref:`float<class_float>` **get_zfar** **(** **)** const
  110. .. _class_Camera_get_znear:
  111. - :ref:`float<class_float>` **get_znear** **(** **)** const
  112. .. _class_Camera_get_projection:
  113. - :ref:`int<class_int>` **get_projection** **(** **)** const
  114. .. _class_Camera_set_visible_layers:
  115. - void **set_visible_layers** **(** :ref:`int<class_int>` mask **)**
  116. .. _class_Camera_get_visible_layers:
  117. - :ref:`int<class_int>` **get_visible_layers** **(** **)** const
  118. .. _class_Camera_set_environment:
  119. - void **set_environment** **(** :ref:`Environment<class_environment>` env **)**
  120. .. _class_Camera_get_environment:
  121. - :ref:`Environment<class_environment>` **get_environment** **(** **)** const
  122. .. _class_Camera_set_keep_aspect_mode:
  123. - void **set_keep_aspect_mode** **(** :ref:`int<class_int>` mode **)**
  124. .. _class_Camera_get_keep_aspect_mode:
  125. - :ref:`int<class_int>` **get_keep_aspect_mode** **(** **)** const