#include "camera_3d.h"
#include "core/math/projection.h"
#include "core/math/transform_interpolator.h"
#include "scene/main/viewport.h"
#include "servers/rendering/rendering_server_constants.h"
void Camera3D::_update_audio_listener_state() { … }
void Camera3D::_request_camera_update() { … }
void Camera3D::_update_camera_mode() { … }
void Camera3D::_validate_property(PropertyInfo &p_property) const { … }
void Camera3D::_update_camera() { … }
void Camera3D::_physics_interpolated_changed() { … }
void Camera3D::_physics_interpolation_ensure_data_flipped() { … }
void Camera3D::_physics_interpolation_ensure_transform_calculated(bool p_force) const { … }
void Camera3D::set_desired_process_modes(bool p_process_internal, bool p_physics_process_internal) { … }
void Camera3D::_update_process_mode() { … }
void Camera3D::_notification(int p_what) { … }
Transform3D Camera3D::_get_adjusted_camera_transform(const Transform3D &p_xform) const { … }
Transform3D Camera3D::get_camera_transform() const { … }
Projection Camera3D::_get_camera_projection(real_t p_near) const { … }
Projection Camera3D::get_camera_projection() const { … }
void Camera3D::set_perspective(real_t p_fovy_degrees, real_t p_z_near, real_t p_z_far) { … }
void Camera3D::set_orthogonal(real_t p_size, real_t p_z_near, real_t p_z_far) { … }
void Camera3D::set_frustum(real_t p_size, Vector2 p_offset, real_t p_z_near, real_t p_z_far) { … }
void Camera3D::set_projection(ProjectionType p_mode) { … }
RID Camera3D::get_camera() const {
return camera;
};
void Camera3D::make_current() { … }
void Camera3D::clear_current(bool p_enable_next) { … }
void Camera3D::set_current(bool p_enabled) { … }
bool Camera3D::is_current() const { … }
Vector3 Camera3D::project_ray_normal(const Point2 &p_pos) const {
Vector3 ray = project_local_ray_normal(p_pos);
return get_camera_transform().basis.xform(ray).normalized();
};
Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const {
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
Size2 viewport_size = get_viewport()->get_camera_rect_size();
Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
Vector3 ray;
if (mode == PROJECTION_ORTHOGONAL) {
ray = Vector3(0, 0, -1);
} else {
Projection cm = _get_camera_projection(_near);
Vector2 screen_he = cm.get_viewport_half_extents();
ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -_near).normalized();
}
return ray;
};
Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const {
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
Size2 viewport_size = get_viewport()->get_camera_rect_size();
Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
ERR_FAIL_COND_V(viewport_size.y == 0, Vector3());
if (mode == PROJECTION_ORTHOGONAL) {
Vector2 pos = cpos / viewport_size;
real_t vsize, hsize;
if (keep_aspect == KEEP_WIDTH) {
vsize = size / viewport_size.aspect();
hsize = size;
} else {
hsize = size * viewport_size.aspect();
vsize = size;
}
Vector3 ray;
ray.x = pos.x * (hsize)-hsize / 2;
ray.y = (1.0 - pos.y) * (vsize)-vsize / 2;
ray.z = -_near;
ray = get_camera_transform().xform(ray);
return ray;
} else {
return get_camera_transform().origin;
};
};
bool Camera3D::is_position_behind(const Vector3 &p_pos) const { … }
Vector<Vector3> Camera3D::get_near_plane_points() const { … }
Point2 Camera3D::unproject_position(const Vector3 &p_pos) const { … }
Vector3 Camera3D::project_position(const Point2 &p_point, real_t p_z_depth) const { … }
void Camera3D::set_environment(const Ref<Environment> &p_environment) { … }
Ref<Environment> Camera3D::get_environment() const { … }
void Camera3D::set_attributes(const Ref<CameraAttributes> &p_attributes) { … }
Ref<CameraAttributes> Camera3D::get_attributes() const { … }
void Camera3D::_attributes_changed() { … }
void Camera3D::set_compositor(const Ref<Compositor> &p_compositor) { … }
Ref<Compositor> Camera3D::get_compositor() const { … }
void Camera3D::set_keep_aspect_mode(KeepAspect p_aspect) { … }
Camera3D::KeepAspect Camera3D::get_keep_aspect_mode() const { … }
void Camera3D::set_doppler_tracking(DopplerTracking p_tracking) { … }
Camera3D::DopplerTracking Camera3D::get_doppler_tracking() const { … }
void Camera3D::_bind_methods() { … }
real_t Camera3D::get_fov() const { … }
real_t Camera3D::get_size() const { … }
real_t Camera3D::get_near() const { … }
Vector2 Camera3D::get_frustum_offset() const { … }
real_t Camera3D::get_far() const { … }
Camera3D::ProjectionType Camera3D::get_projection() const { … }
void Camera3D::set_fov(real_t p_fov) { … }
void Camera3D::set_size(real_t p_size) { … }
void Camera3D::set_near(real_t p_near) { … }
void Camera3D::set_frustum_offset(Vector2 p_offset) { … }
void Camera3D::set_far(real_t p_far) { … }
void Camera3D::set_cull_mask(uint32_t p_layers) { … }
uint32_t Camera3D::get_cull_mask() const { … }
void Camera3D::set_cull_mask_value(int p_layer_number, bool p_value) { … }
bool Camera3D::get_cull_mask_value(int p_layer_number) const { … }
Vector<Plane> Camera3D::get_frustum() const { … }
TypedArray<Plane> Camera3D::_get_frustum() const { … }
bool Camera3D::is_position_in_frustum(const Vector3 &p_position) const { … }
void Camera3D::set_v_offset(real_t p_offset) { … }
real_t Camera3D::get_v_offset() const { … }
void Camera3D::set_h_offset(real_t p_offset) { … }
real_t Camera3D::get_h_offset() const { … }
Vector3 Camera3D::get_doppler_tracked_velocity() const { … }
RID Camera3D::get_pyramid_shape_rid() { … }
Camera3D::Camera3D() { … }
Camera3D::~Camera3D() { … }