[][src]Struct gdnative::api::Camera

pub struct Camera { /* fields omitted */ }

core class Camera inherits Spatial (unsafe).

Official documentation

See the documentation of this class in the Godot engine's official documentation.

Memory management

Non reference counted objects such as the ones of this type are usually owned by the engine.

Camera is a reference-only type. Persistent references can only exist in the unsafe Ref<Camera> form.

In the cases where Rust code owns an object of this type, for example if the object was just created on the Rust side and not passed to the engine yet, ownership should be either given to the engine or the object must be manually destroyed using Ref::free, or Ref::queue_free if it is a Node.

Class hierarchy

Camera inherits methods from:

Safety

All types in the Godot API have "interior mutability" in Rust parlance. To enforce that the official thread-safety guidelines are followed, the typestate pattern is used in the Ref and TRef smart pointers, and the Instance API. The typestate Access in these types tracks whether the access is unique, shared, or exclusive to the current thread. For more information, see the type-level documentation on Ref.

Implementations

impl Camera[src]

Constants

impl Camera[src]

pub fn new() -> Ref<Camera, Unique>[src]

Creates a new instance of this object.

Because this type is not reference counted, the lifetime of the returned object is not automatically managed.

Immediately after creation, the object is owned by the caller, and can be passed to the engine (in which case the engine will be responsible for destroying the object) or destroyed manually using Ref::free, or preferably Ref::queue_free if it is a Node.

pub fn clear_current(&self, enable_next: bool)[src]

If this is the current camera, remove it from being current. If [code]enable_next[/code] is [code]true[/code], request to make the next camera current, if any.

Default Arguments

  • enable_next - true

pub fn get_camera_rid(&self) -> Rid[src]

Returns the camera's RID from the [VisualServer].

pub fn get_camera_transform(&self) -> Transform[src]

Gets the camera transform. Subclassed cameras such as [InterpolatedCamera] may provide different transforms than the [Node] transform.

pub fn cull_mask(&self) -> i64[src]

The culling mask that describes which 3D render layers are rendered by this camera.

pub fn get_cull_mask_bit(&self, layer: i64) -> bool[src]

Returns [code]true[/code] if the given [code]layer[/code] in the [member cull_mask] is enabled, [code]false[/code] otherwise.

pub fn doppler_tracking(&self) -> DopplerTracking[src]

If not [constant DOPPLER_TRACKING_DISABLED], this camera will simulate the [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] for objects changed in particular [code]_process[/code] methods. See [enum DopplerTracking] for possible values.

pub fn environment(&self) -> Option<Ref<Environment, Shared>>[src]

The [Environment] to use for this camera.

pub fn fov(&self) -> f64[src]

The camera's field of view angle (in degrees). Only applicable in perspective mode. Since [member keep_aspect] locks one axis, [code]fov[/code] sets the other axis' field of view angle.

pub fn get_frustum(&self) -> VariantArray<Shared>[src]

Returns the camera's frustum planes in world-space units as an array of [Plane]s in the following order: near, far, left, top, right, bottom. Not to be confused with [member frustum_offset].

pub fn frustum_offset(&self) -> Vector2D<f32, UnknownUnit>[src]

The camera's frustum offset. This can be changed from the default to create "tilted frustum" effects such as [url=https://zdoom.org/wiki/Y-shearing]Y-shearing[/url].

pub fn h_offset(&self) -> f64[src]

The horizontal (X) offset of the camera viewport.

pub fn keep_aspect_mode(&self) -> KeepAspect[src]

The axis to lock during [member fov]/[member size] adjustments. Can be either [constant KEEP_WIDTH] or [constant KEEP_HEIGHT].

pub fn projection(&self) -> Projection[src]

The camera's projection mode. In [constant PROJECTION_PERSPECTIVE] mode, objects' Z distance from the camera's local space scales their perceived size.

pub fn size(&self) -> f64[src]

The camera's size measured as 1/2 the width or height. Only applicable in orthogonal mode. Since [member keep_aspect] locks on axis, [code]size[/code] sets the other axis' size length.

pub fn v_offset(&self) -> f64[src]

The vertical (Y) offset of the camera viewport.

pub fn zfar(&self) -> f64[src]

The distance to the far culling boundary for this camera relative to its local Z axis.

pub fn znear(&self) -> f64[src]

The distance to the near culling boundary for this camera relative to its local Z axis.

pub fn is_current(&self) -> bool[src]

If [code]true[/code], the ancestor [Viewport] is currently using this camera.

pub fn is_position_behind(
    &self,
    world_point: Vector3D<f32, UnknownUnit>
) -> bool
[src]

Returns [code]true[/code] if the given position is behind the camera.
				[b]Note:[/b] A position which returns [code]false[/code] may still be outside the camera's field of view.

pub fn make_current(&self)[src]

Makes this camera the current camera for the [Viewport] (see class description). If the camera node is outside the scene tree, it will attempt to become current once it's added.

pub fn project_local_ray_normal(
    &self,
    screen_point: Vector2D<f32, UnknownUnit>
) -> Vector3D<f32, UnknownUnit>
[src]

Returns a normal vector from the screen point location directed along the camera. Orthogonal cameras are normalized. Perspective cameras account for perspective, screen width/height, etc.

pub fn project_position(
    &self,
    screen_point: Vector2D<f32, UnknownUnit>,
    z_depth: f64
) -> Vector3D<f32, UnknownUnit>
[src]

Returns the 3D point in worldspace that maps to the given 2D coordinate in the [Viewport] rectangle on a plane that is the given [code]z_depth[/code] distance into the scene away from the camera.

pub fn project_ray_normal(
    &self,
    screen_point: Vector2D<f32, UnknownUnit>
) -> Vector3D<f32, UnknownUnit>
[src]

Returns a normal vector in worldspace, 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.

pub fn project_ray_origin(
    &self,
    screen_point: Vector2D<f32, UnknownUnit>
) -> Vector3D<f32, UnknownUnit>
[src]

Returns a 3D position in worldspace, 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.

pub fn set_cull_mask(&self, mask: i64)[src]

The culling mask that describes which 3D render layers are rendered by this camera.

pub fn set_cull_mask_bit(&self, layer: i64, enable: bool)[src]

Enables or disables the given [code]layer[/code] in the [member cull_mask].

pub fn set_current(&self, arg0: bool)[src]

If [code]true[/code], the ancestor [Viewport] is currently using this camera.

pub fn set_doppler_tracking(&self, mode: i64)[src]

If not [constant DOPPLER_TRACKING_DISABLED], this camera will simulate the [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] for objects changed in particular [code]_process[/code] methods. See [enum DopplerTracking] for possible values.

pub fn set_environment(&self, env: impl AsArg<Environment>)[src]

The [Environment] to use for this camera.

pub fn set_fov(&self, arg0: f64)[src]

The camera's field of view angle (in degrees). Only applicable in perspective mode. Since [member keep_aspect] locks one axis, [code]fov[/code] sets the other axis' field of view angle.

pub fn set_frustum(
    &self,
    size: f64,
    offset: Vector2D<f32, UnknownUnit>,
    z_near: f64,
    z_far: f64
)
[src]

Sets the camera projection to frustum mode (see [constant PROJECTION_FRUSTUM]), by specifying a [code]size[/code], an [code]offset[/code], and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units.

pub fn set_frustum_offset(&self, arg0: Vector2D<f32, UnknownUnit>)[src]

The camera's frustum offset. This can be changed from the default to create "tilted frustum" effects such as [url=https://zdoom.org/wiki/Y-shearing]Y-shearing[/url].

pub fn set_h_offset(&self, ofs: f64)[src]

The horizontal (X) offset of the camera viewport.

pub fn set_keep_aspect_mode(&self, mode: i64)[src]

The axis to lock during [member fov]/[member size] adjustments. Can be either [constant KEEP_WIDTH] or [constant KEEP_HEIGHT].

pub fn set_orthogonal(&self, size: f64, z_near: f64, z_far: f64)[src]

Sets the camera projection to orthogonal mode (see [constant PROJECTION_ORTHOGONAL]), by specifying a [code]size[/code], and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units. (As a hint, 2D games often use this projection, with values specified in pixels.)

pub fn set_perspective(&self, fov: f64, z_near: f64, z_far: f64)[src]

Sets the camera projection to perspective mode (see [constant PROJECTION_PERSPECTIVE]), by specifying a [code]fov[/code] (field of view) angle in degrees, and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units.

pub fn set_projection(&self, arg0: i64)[src]

The camera's projection mode. In [constant PROJECTION_PERSPECTIVE] mode, objects' Z distance from the camera's local space scales their perceived size.

pub fn set_size(&self, arg0: f64)[src]

The camera's size measured as 1/2 the width or height. Only applicable in orthogonal mode. Since [member keep_aspect] locks on axis, [code]size[/code] sets the other axis' size length.

pub fn set_v_offset(&self, ofs: f64)[src]

The vertical (Y) offset of the camera viewport.

pub fn set_zfar(&self, arg0: f64)[src]

The distance to the far culling boundary for this camera relative to its local Z axis.

pub fn set_znear(&self, arg0: f64)[src]

The distance to the near culling boundary for this camera relative to its local Z axis.

pub fn unproject_position(
    &self,
    world_point: Vector3D<f32, UnknownUnit>
) -> Vector2D<f32, UnknownUnit>
[src]

Returns the 2D coordinate in the [Viewport] rectangle that maps to the given 3D point in worldspace.

Methods from Deref<Target = Spatial>

pub fn force_update_transform(&self)[src]

Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.

pub fn gizmo(&self) -> Option<Ref<SpatialGizmo, Shared>>[src]

The [SpatialGizmo] for this node. Used for example in [EditorSpatialGizmo] as custom visualization and editing handles in Editor.

pub fn global_transform(&self) -> Transform[src]

World space (global) [Transform] of this node.

pub fn get_parent_spatial(&self) -> Option<Ref<Spatial, Shared>>[src]

Returns the parent [Spatial], or an empty [Object] if no parent exists or parent is not of type [Spatial].

pub fn rotation(&self) -> Vector3D<f32, UnknownUnit>[src]

Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
			[b]Note:[/b] In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a [Vector3] data structure not because the rotation is a vector, but only because [Vector3] exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.

pub fn rotation_degrees(&self) -> Vector3D<f32, UnknownUnit>[src]

Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).

pub fn scale(&self) -> Vector3D<f32, UnknownUnit>[src]

Scale part of the local transformation.

pub fn transform(&self) -> Transform[src]

Local space [Transform] of this node, with respect to the parent node.

pub fn translation(&self) -> Vector3D<f32, UnknownUnit>[src]

Local translation of this node.

pub fn get_world(&self) -> Option<Ref<World, Shared>>[src]

Returns the current [World] resource this [Spatial] node is registered to.

pub fn global_rotate(&self, axis: Vector3D<f32, UnknownUnit>, angle: f64)[src]

Rotates the global (world) transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in global coordinate system.

pub fn global_scale(&self, scale: Vector3D<f32, UnknownUnit>)[src]

Scales the global (world) transformation by the given [Vector3] scale factors.

pub fn global_translate(&self, offset: Vector3D<f32, UnknownUnit>)[src]

Moves the global (world) transformation by [Vector3] offset. The offset is in global coordinate system.

pub fn hide(&self)[src]

Disables rendering of this node. Changes [member visible] to [code]false[/code].

pub fn is_local_transform_notification_enabled(&self) -> bool[src]

Returns whether node notifies about its local transformation changes. [Spatial] will not propagate this by default.

pub fn is_scale_disabled(&self) -> bool[src]

Returns whether this node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale.

pub fn is_set_as_toplevel(&self) -> bool[src]

Returns whether this node is set as Toplevel, that is whether it ignores its parent nodes transformations.

pub fn is_transform_notification_enabled(&self) -> bool[src]

Returns whether the node notifies about its global and local transformation changes. [Spatial] will not propagate this by default.

pub fn is_visible(&self) -> bool[src]

If [code]true[/code], this node is drawn. The node is only visible if all of its antecedents are visible as well (in other words, [method is_visible_in_tree] must return [code]true[/code]).

pub fn is_visible_in_tree(&self) -> bool[src]

Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree.

pub fn look_at(
    &self,
    target: Vector3D<f32, UnknownUnit>,
    up: Vector3D<f32, UnknownUnit>
)
[src]

Rotates itself so that the local -Z axis points towards the [code]target[/code] position.
				The transform will first be rotated around the given [code]up[/code] vector, and then fully aligned to the target by a further rotation around an axis perpendicular to both the [code]target[/code] and [code]up[/code] vectors.
				Operations take place in global space.

pub fn look_at_from_position(
    &self,
    position: Vector3D<f32, UnknownUnit>,
    target: Vector3D<f32, UnknownUnit>,
    up: Vector3D<f32, UnknownUnit>
)
[src]

Moves the node to the specified [code]position[/code], and then rotates itself to point toward the [code]target[/code] as per [method look_at]. Operations take place in global space.

pub fn orthonormalize(&self)[src]

Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node's [Transform].

pub fn rotate(&self, axis: Vector3D<f32, UnknownUnit>, angle: f64)[src]

Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians.

pub fn rotate_object_local(&self, axis: Vector3D<f32, UnknownUnit>, angle: f64)[src]

Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in object-local coordinate system.

pub fn rotate_x(&self, angle: f64)[src]

Rotates the local transformation around the X axis by angle in radians.

pub fn rotate_y(&self, angle: f64)[src]

Rotates the local transformation around the Y axis by angle in radians.

pub fn rotate_z(&self, angle: f64)[src]

Rotates the local transformation around the Z axis by angle in radians.

pub fn scale_object_local(&self, scale: Vector3D<f32, UnknownUnit>)[src]

Scales the local transformation by given 3D scale factors in object-local coordinate system.

pub fn set_as_toplevel(&self, enable: bool)[src]

Makes the node ignore its parents transformations. Node transformations are only in global space.

pub fn set_disable_scale(&self, disable: bool)[src]

Sets whether the node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale. Changes to the local transformation scale are preserved.

pub fn set_gizmo(&self, gizmo: impl AsArg<SpatialGizmo>)[src]

The [SpatialGizmo] for this node. Used for example in [EditorSpatialGizmo] as custom visualization and editing handles in Editor.

pub fn set_global_transform(&self, global: Transform)[src]

World space (global) [Transform] of this node.

pub fn set_identity(&self)[src]

Reset all transformations for this node (sets its [Transform] to the identity matrix).

pub fn set_ignore_transform_notification(&self, enabled: bool)[src]

Sets whether the node ignores notification that its transformation (global or local) changed.

pub fn set_notify_local_transform(&self, enable: bool)[src]

Sets whether the node notifies about its local transformation changes. [Spatial] will not propagate this by default.

pub fn set_notify_transform(&self, enable: bool)[src]

Sets whether the node notifies about its global and local transformation changes. [Spatial] will not propagate this by default.

pub fn set_rotation(&self, euler: Vector3D<f32, UnknownUnit>)[src]

Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
			[b]Note:[/b] In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a [Vector3] data structure not because the rotation is a vector, but only because [Vector3] exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.

pub fn set_rotation_degrees(&self, euler_degrees: Vector3D<f32, UnknownUnit>)[src]

Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).

pub fn set_scale(&self, scale: Vector3D<f32, UnknownUnit>)[src]

Scale part of the local transformation.

pub fn set_transform(&self, local: Transform)[src]

Local space [Transform] of this node, with respect to the parent node.

pub fn set_translation(&self, translation: Vector3D<f32, UnknownUnit>)[src]

Local translation of this node.

pub fn set_visible(&self, visible: bool)[src]

If [code]true[/code], this node is drawn. The node is only visible if all of its antecedents are visible as well (in other words, [method is_visible_in_tree] must return [code]true[/code]).

pub fn show(&self)[src]

Enables rendering of this node. Changes [member visible] to [code]true[/code].

pub fn to_global(
    &self,
    local_point: Vector3D<f32, UnknownUnit>
) -> Vector3D<f32, UnknownUnit>
[src]

Transforms [code]local_point[/code] from this node's local space to world space.

pub fn to_local(
    &self,
    global_point: Vector3D<f32, UnknownUnit>
) -> Vector3D<f32, UnknownUnit>
[src]

Transforms [code]global_point[/code] from world space to this node's local space.

pub fn translate(&self, offset: Vector3D<f32, UnknownUnit>)[src]

Changes the node's position by the given offset [Vector3].
				Note that the translation [code]offset[/code] is affected by the node's scale, so if scaled by e.g. [code](10, 1, 1)[/code], a translation by an offset of [code](2, 0, 0)[/code] would actually add 20 ([code]2 * 10[/code]) to the X coordinate.

pub fn translate_object_local(&self, offset: Vector3D<f32, UnknownUnit>)[src]

Changes the node's position by the given offset [Vector3] in local space.

pub fn update_gizmo(&self)[src]

Updates the [SpatialGizmo] of this node.

Trait Implementations

impl Debug for Camera[src]

impl Deref for Camera[src]

type Target = Spatial

The resulting type after dereferencing.

impl DerefMut for Camera[src]

impl GodotObject for Camera[src]

type RefKind = ManuallyManaged

The memory management kind of this type. This modifies the behavior of the Ref smart pointer. See its type-level documentation for more information. Read more

impl Instanciable for Camera[src]

impl QueueFree for Camera[src]

impl SubClass<Camera> for InterpolatedCamera[src]

impl SubClass<Camera> for ARVRCamera[src]

impl SubClass<Camera> for ClippedCamera[src]

impl SubClass<Node> for Camera[src]

impl SubClass<Object> for Camera[src]

impl SubClass<Spatial> for Camera[src]

Auto Trait Implementations

impl RefUnwindSafe for Camera

impl !Send for Camera

impl !Sync for Camera

impl Unpin for Camera

impl UnwindSafe for Camera

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.