Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Camera¶
Inherits: Spatial < Node < Object
Inherited By: ARVRCamera, ClippedCamera, InterpolatedCamera
Nodo de cámara, muestra desde un punto de vista.
Descripción¶
Camera is a special node that displays what is visible from its current location. Cameras register themselves in the nearest 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 Viewport, and, without one, a scene registered in that Viewport (or higher viewports) can't be displayed.
Tutoriales¶
Propiedades¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Métodos¶
void |
clear_current ( bool enable_next=true ) |
get_camera_rid ( ) const |
|
get_camera_transform ( ) const |
|
get_cull_mask_bit ( int layer ) const |
|
get_frustum ( ) const |
|
is_position_behind ( Vector3 world_point ) const |
|
void |
make_current ( ) |
project_local_ray_normal ( Vector2 screen_point ) const |
|
project_position ( Vector2 screen_point, float z_depth ) const |
|
project_ray_normal ( Vector2 screen_point ) const |
|
project_ray_origin ( Vector2 screen_point ) const |
|
void |
set_cull_mask_bit ( int layer, bool enable ) |
void |
set_frustum ( float size, Vector2 offset, float z_near, float z_far ) |
void |
set_orthogonal ( float size, float z_near, float z_far ) |
void |
set_perspective ( float fov, float z_near, float z_far ) |
unproject_position ( Vector3 world_point ) const |
Enumeraciones¶
enum Projection:
PROJECTION_PERSPECTIVE = 0 --- Proyección de la perspectiva. Los objetos en la pantalla se hacen más pequeños cuando están lejos.
PROJECTION_ORTHOGONAL = 1 --- Proyección ortogonal, también conocida como proyección ortográfica. Los objetos permanecen del mismo tamaño en la pantalla sin importar lo lejos que estén.
PROJECTION_FRUSTUM = 2 --- Proyección de Frustum. Este modo permite ajustar frustum_offset para crear efectos de "frustum inclinado".
enum KeepAspect:
KEEP_WIDTH = 0 --- Preserva la relación de aspecto horizontal; también conocida como escala de Vert-. Esta suele ser la mejor opción para los proyectos que se ejecutan en modo de retrato, ya que las proporciones de aspecto más altas se beneficiarán de un mayor FOV vertical.
KEEP_HEIGHT = 1 --- Preserva la relación de aspecto vertical; también conocida como escala Hor+. Esta suele ser la mejor opción para los proyectos que se ejecutan en modo paisaje, ya que las relaciones de aspecto más amplias se beneficiarán automáticamente de un FOV horizontal más amplio.
enum DopplerTracking:
DOPPLER_TRACKING_DISABLED = 0 --- Desactiva la simulación del efecto Doppler (por defecto).
DOPPLER_TRACKING_IDLE_STEP = 1 --- Simulate Doppler effect by tracking positions of objects that are changed in
_process
. Changes in the relative velocity of this camera compared to those objects affect how audio is perceived (changing the audio's AudioStreamPlayer3D.pitch_scale).DOPPLER_TRACKING_PHYSICS_STEP = 2 --- Simulate Doppler effect by tracking positions of objects that are changed in
_physics_process
. Changes in the relative velocity of this camera compared to those objects affect how audio is perceived (changing the audio's AudioStreamPlayer3D.pitch_scale).
Descripciones de Propiedades¶
int cull_mask
Default |
|
Setter |
set_cull_mask(value) |
Getter |
get_cull_mask() |
La máscara de selección que describe qué capas de renderizado 3D son renderizadas por esta cámara.
bool current
Default |
|
Setter |
set_current(value) |
Getter |
is_current() |
Si true
, el ancestro Viewport está actualmente usando esta cámara.
DopplerTracking doppler_tracking
Default |
|
Setter |
set_doppler_tracking(value) |
Getter |
get_doppler_tracking() |
If not DOPPLER_TRACKING_DISABLED, this camera will simulate the Doppler effect for objects changed in particular _process
methods. The Doppler effect is only simulated for AudioStreamPlayer3D nodes that have AudioStreamPlayer3D.doppler_tracking set to a value other than AudioStreamPlayer3D.DOPPLER_TRACKING_DISABLED.
Note: To toggle the Doppler effect preview in the editor, use the Perspective menu in the top-left corner of the 3D viewport and toggle Enable Doppler.
Environment environment
Setter |
set_environment(value) |
Getter |
get_environment() |
El Environment a utilizar para esta cámara.
float far
Default |
|
Setter |
set_zfar(value) |
Getter |
get_zfar() |
La distancia al límite lejano de selección de esta cámara en relación con su eje Z local.
float fov
Default |
|
Setter |
set_fov(value) |
Getter |
get_fov() |
The camera's field of view angle (in degrees). Only applicable in perspective mode. Since keep_aspect locks one axis, fov
sets the other axis' field of view angle.
For reference, the default vertical field of view value (70.0
) is equivalent to a horizontal FOV of:
~86.07 degrees in a 4:3 viewport
~96.50 degrees in a 16:10 viewport
~102.45 degrees in a 16:9 viewport
~117.06 degrees in a 21:9 viewport
Vector2 frustum_offset
Default |
|
Setter |
set_frustum_offset(value) |
Getter |
get_frustum_offset() |
El desplazamiento de la cámara de frustum. Se puede cambiar desde el valor predeterminado para crear efectos de "frustum inclinado" como Y-shearing.
float h_offset
Default |
|
Setter |
set_h_offset(value) |
Getter |
get_h_offset() |
El desplazamiento horizontal (X) de la vista de la cámara.
KeepAspect keep_aspect
Default |
|
Setter |
set_keep_aspect_mode(value) |
Getter |
get_keep_aspect_mode() |
El eje a bloquear durante los ajustes de fov/size. Puede ser KEEP_WIDTH o KEEP_HEIGHT.
float near
Default |
|
Setter |
set_znear(value) |
Getter |
get_znear() |
La distancia al límite cercano de selección de esta cámara en relación con su eje Z local.
Projection projection
Default |
|
Setter |
set_projection(value) |
Getter |
get_projection() |
El modo de proyección de la cámara. En el modo PROJECTION_PERSPECTIVE, la distancia Z de los objetos al espacio local de la cámara escala su tamaño percibido.
float size
Default |
|
Setter |
set_size(value) |
Getter |
get_size() |
El tamaño de la cámara se mide como la mitad de la anchura o la altura. Sólo aplicable en modo ortogonal. Dado que keep_aspect se bloquea en el eje, size
establece la longitud del tamaño del otro eje.
float v_offset
Default |
|
Setter |
set_v_offset(value) |
Getter |
get_v_offset() |
El desplazamiento vertical (Y) del viewport de la cámara.
Descripciones de Métodos¶
void clear_current ( bool enable_next=true )
Si esta es la cámara actual, quítala de ser la actul. Si enable_next
es true
, pide que se actualice la siguiente cámara, si la hay.
RID get_camera_rid ( ) const
Returns the camera's RID from the VisualServer.
Transform get_camera_transform ( ) const
Returns the transform of the camera plus the vertical (v_offset) and horizontal (h_offset) offsets; and any other adjustments made to the position and orientation of the camera by subclassed cameras such as ClippedCamera, InterpolatedCamera and ARVRCamera.
Devuelve true
si el layer
dado en el cull_mask está activado, false
en caso contrario.
Array get_frustum ( ) const
Returns the camera's frustum planes in world space units as an array of Planes in the following order: near, far, left, top, right, bottom. Not to be confused with frustum_offset.
Devuelve true
si la posición dada está detrás de la cámara.
Nota: Una posición que devuelva false
puede seguir estando fuera del campo de visión de la camara.
void make_current ( )
Hace que esta cámara sea la cámara actual para el Viewport (ver descripción de la clase). Si el nodo de la cámara está fuera del árbol de la escena, intentará convertirse en actual una vez que se añada.
Devuelve un vector normal de la ubicación del punto de la pantalla dirigido a lo largo de la cámara. Las cámaras ortogonales están normalizadas. Las cámaras de perspectiva tienen en cuenta la perspectiva, la anchura y la altura de la pantalla, etc.
Returns the 3D point in world space that maps to the given 2D coordinate in the Viewport rectangle on a plane that is the given z_depth
distance into the scene away from the camera.
Returns a normal vector in world space, that is the result of projecting a point on the Viewport rectangle by the camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking.
Returns a 3D position in world space, that is the result of projecting a point on the Viewport rectangle by the camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking.
Habilita o deshabilita la layer
dada en el cull_mask.
Sets the camera projection to frustum mode (see PROJECTION_FRUSTUM), by specifying a size
, an offset
, and the z_near
and z_far
clip planes in world space units.
Sets the camera projection to orthogonal mode (see PROJECTION_ORTHOGONAL), by specifying a size
, and the z_near
and z_far
clip planes in world space units. (As a hint, 2D games often use this projection, with values specified in pixels.)
Sets the camera projection to perspective mode (see PROJECTION_PERSPECTIVE), by specifying a fov
(field of view) angle in degrees, and the z_near
and z_far
clip planes in world space units.
Returns the 2D coordinate in the Viewport rectangle that maps to the given 3D point in world space.
Note: When using this to position GUI elements over a 3D viewport, use is_position_behind to prevent them from appearing if the 3D point is behind the camera:
# This code block is part of a script that inherits from Spatial.
# `control` is a reference to a node inheriting from Control.
control.visible = not get_viewport().get_camera().is_position_behind(global_transform.origin)
control.rect_position = get_viewport().get_camera().unproject_position(global_transform.origin)