class_camera.rst 17 KB

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