2
0

class_camera.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. | void | :ref:`clear_current<class_Camera_clear_current>` **(** **)** |
  16. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`Transform<class_transform>` | :ref:`get_camera_transform<class_Camera_get_camera_transform>` **(** **)** const |
  18. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`int<class_int>` | :ref:`get_cull_mask<class_Camera_get_cull_mask>` **(** **)** const |
  20. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`get_doppler_tracking<class_Camera_get_doppler_tracking>` **(** **)** const |
  22. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Environment<class_environment>` | :ref:`get_environment<class_Camera_get_environment>` **(** **)** const |
  24. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`get_fov<class_Camera_get_fov>` **(** **)** const |
  26. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`float<class_float>` | :ref:`get_h_offset<class_Camera_get_h_offset>` **(** **)** const |
  28. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`get_keep_aspect_mode<class_Camera_get_keep_aspect_mode>` **(** **)** const |
  30. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_projection<class_Camera_get_projection>` **(** **)** const |
  32. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`get_size<class_Camera_get_size>` **(** **)** const |
  34. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`get_v_offset<class_Camera_get_v_offset>` **(** **)** const |
  36. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`float<class_float>` | :ref:`get_zfar<class_Camera_get_zfar>` **(** **)** const |
  38. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`float<class_float>` | :ref:`get_znear<class_Camera_get_znear>` **(** **)** const |
  40. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`is_current<class_Camera_is_current>` **(** **)** const |
  42. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`is_position_behind<class_Camera_is_position_behind>` **(** :ref:`Vector3<class_vector3>` world_point **)** const |
  44. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`make_current<class_Camera_make_current>` **(** **)** |
  46. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Vector3<class_vector3>` | :ref:`project_local_ray_normal<class_Camera_project_local_ray_normal>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  48. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Vector3<class_vector3>` | :ref:`project_position<class_Camera_project_position>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  50. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector3<class_vector3>` | :ref:`project_ray_normal<class_Camera_project_ray_normal>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  52. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Vector3<class_vector3>` | :ref:`project_ray_origin<class_Camera_project_ray_origin>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  54. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_cull_mask<class_Camera_set_cull_mask>` **(** :ref:`int<class_int>` mask **)** |
  56. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_doppler_tracking<class_Camera_set_doppler_tracking>` **(** :ref:`int<class_int>` mode **)** |
  58. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`set_environment<class_Camera_set_environment>` **(** :ref:`Environment<class_environment>` env **)** |
  60. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_h_offset<class_Camera_set_h_offset>` **(** :ref:`float<class_float>` ofs **)** |
  62. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_keep_aspect_mode<class_Camera_set_keep_aspect_mode>` **(** :ref:`int<class_int>` mode **)** |
  64. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | 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 **)** |
  66. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | 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 **)** |
  68. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`set_v_offset<class_Camera_set_v_offset>` **(** :ref:`float<class_float>` ofs **)** |
  70. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Vector2<class_vector2>` | :ref:`unproject_position<class_Camera_unproject_position>` **(** :ref:`Vector3<class_vector3>` world_point **)** const |
  72. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. Numeric Constants
  74. -----------------
  75. - **PROJECTION_PERSPECTIVE** = **0** --- Perspective Projection (object's size on the screen becomes smaller when far away).
  76. - **PROJECTION_ORTHOGONAL** = **1** --- Orthogonal Projection (objects remain the same size on the screen no matter how far away they are).
  77. - **KEEP_WIDTH** = **0**
  78. - **KEEP_HEIGHT** = **1**
  79. - **DOPPLER_TRACKING_DISABLED** = **0**
  80. - **DOPPLER_TRACKING_IDLE_STEP** = **1**
  81. - **DOPPLER_TRACKING_FIXED_STEP** = **2**
  82. Description
  83. -----------
  84. 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.
  85. Member Function Description
  86. ---------------------------
  87. .. _class_Camera_clear_current:
  88. - void **clear_current** **(** **)**
  89. .. _class_Camera_get_camera_transform:
  90. - :ref:`Transform<class_transform>` **get_camera_transform** **(** **)** const
  91. Get the camera transform. Subclassed cameras (such as CharacterCamera) may provide different transforms than the :ref:`Node<class_node>` transform.
  92. .. _class_Camera_get_cull_mask:
  93. - :ref:`int<class_int>` **get_cull_mask** **(** **)** const
  94. .. _class_Camera_get_doppler_tracking:
  95. - :ref:`int<class_int>` **get_doppler_tracking** **(** **)** const
  96. .. _class_Camera_get_environment:
  97. - :ref:`Environment<class_environment>` **get_environment** **(** **)** const
  98. .. _class_Camera_get_fov:
  99. - :ref:`float<class_float>` **get_fov** **(** **)** const
  100. .. _class_Camera_get_h_offset:
  101. - :ref:`float<class_float>` **get_h_offset** **(** **)** const
  102. .. _class_Camera_get_keep_aspect_mode:
  103. - :ref:`int<class_int>` **get_keep_aspect_mode** **(** **)** const
  104. .. _class_Camera_get_projection:
  105. - :ref:`int<class_int>` **get_projection** **(** **)** const
  106. .. _class_Camera_get_size:
  107. - :ref:`float<class_float>` **get_size** **(** **)** const
  108. .. _class_Camera_get_v_offset:
  109. - :ref:`float<class_float>` **get_v_offset** **(** **)** const
  110. .. _class_Camera_get_zfar:
  111. - :ref:`float<class_float>` **get_zfar** **(** **)** const
  112. .. _class_Camera_get_znear:
  113. - :ref:`float<class_float>` **get_znear** **(** **)** const
  114. .. _class_Camera_is_current:
  115. - :ref:`bool<class_bool>` **is_current** **(** **)** const
  116. Return whether the Camera is the current one in the :ref:`Viewport<class_viewport>`, or plans to become current (if outside the scene tree).
  117. .. _class_Camera_is_position_behind:
  118. - :ref:`bool<class_bool>` **is_position_behind** **(** :ref:`Vector3<class_vector3>` world_point **)** const
  119. .. _class_Camera_make_current:
  120. - void **make_current** **(** **)**
  121. 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.
  122. .. _class_Camera_project_local_ray_normal:
  123. - :ref:`Vector3<class_vector3>` **project_local_ray_normal** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  124. .. _class_Camera_project_position:
  125. - :ref:`Vector3<class_vector3>` **project_position** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  126. .. _class_Camera_project_ray_normal:
  127. - :ref:`Vector3<class_vector3>` **project_ray_normal** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  128. 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.
  129. .. _class_Camera_project_ray_origin:
  130. - :ref:`Vector3<class_vector3>` **project_ray_origin** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  131. 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.
  132. .. _class_Camera_set_cull_mask:
  133. - void **set_cull_mask** **(** :ref:`int<class_int>` mask **)**
  134. .. _class_Camera_set_doppler_tracking:
  135. - void **set_doppler_tracking** **(** :ref:`int<class_int>` mode **)**
  136. .. _class_Camera_set_environment:
  137. - void **set_environment** **(** :ref:`Environment<class_environment>` env **)**
  138. .. _class_Camera_set_h_offset:
  139. - void **set_h_offset** **(** :ref:`float<class_float>` ofs **)**
  140. .. _class_Camera_set_keep_aspect_mode:
  141. - void **set_keep_aspect_mode** **(** :ref:`int<class_int>` mode **)**
  142. .. _class_Camera_set_orthogonal:
  143. - void **set_orthogonal** **(** :ref:`float<class_float>` size, :ref:`float<class_float>` z_near, :ref:`float<class_float>` z_far **)**
  144. 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)
  145. .. _class_Camera_set_perspective:
  146. - void **set_perspective** **(** :ref:`float<class_float>` fov, :ref:`float<class_float>` z_near, :ref:`float<class_float>` z_far **)**
  147. 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.
  148. .. _class_Camera_set_v_offset:
  149. - void **set_v_offset** **(** :ref:`float<class_float>` ofs **)**
  150. .. _class_Camera_unproject_position:
  151. - :ref:`Vector2<class_vector2>` **unproject_position** **(** :ref:`Vector3<class_vector3>` world_point **)** const
  152. Return how a 3D point in worldspace maps to a 2D coordinate in the :ref:`Viewport<class_viewport>` rectangle.