libsc 2.8.7.187-a49fd
The SC library provides support for parallel scientific applications.
Loading...
Searching...
No Matches
sc_camera.h
Go to the documentation of this file.
1/*
2 This file is part of the SC Library.
3 The SC Library provides support for parallel scientific applications.
4
5 Copyright (C) 2010 The University of Texas System
6 Additional copyright (C) 2011 individual authors
7
8 The SC Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 The SC Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with the SC Library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
22*/
23
24#ifndef SC_CAMERA_H
25#define SC_CAMERA_H
26
107#include <sc_containers.h>
108
111/* p4est uses double, most computer graphic applications float on GPU.*/
112/* Using float here would result in implicit conversions. */
113typedef double sc_camera_coords_t;
114
118
122
127
132
137typedef enum sc_camera_plane
138{
139 SC_CAMERA_PLANE_NEAR,
140 SC_CAMERA_PLANE_FAR,
141 SC_CAMERA_PLANE_LEFT,
142 SC_CAMERA_PLANE_RIGHT,
143 SC_CAMERA_PLANE_TOP,
144 SC_CAMERA_PLANE_BOTTOM
146
179
188
206
215
222 const sc_camera_vec3_t position);
223
233void sc_camera_yaw (sc_camera_t * camera, double angle);
234
244void sc_camera_pitch (sc_camera_t * camera, double angle);
245
255void sc_camera_roll (sc_camera_t * camera, double angle);
256
267void sc_camera_walk (sc_camera_t * camera, double distance);
268
274void sc_camera_fov (sc_camera_t * camera, double angle);
275
283void sc_camera_aspect_ratio (sc_camera_t * camera, int width,
284 int height);
292 sc_camera_coords_t near_plane,
293 sc_camera_coords_t far_plane);
294
303 const sc_camera_vec3_t eye,
304 const sc_camera_vec3_t center,
305 const sc_camera_vec3_t up);
306
332 sc_array_t * points_in,
333 sc_array_t * points_out);
334
356 sc_camera_mat4x4_t view_matrix);
357
385 proj_matrix);
386
420 camera,
421 sc_array_t * points_in,
422 sc_array_t * points_out);
423
450 sc_array_t * planes);
451
472 sc_array_t * points,
473 sc_array_t * indices);
474
492 const sc_camera_vec3_t point,
493 sc_camera_coords_t distances[6]);
494
515 sc_array_t * indices);
516
541 sc_array_t * points_out);
542
543#endif
void sc_camera_position(sc_camera_t *camera, const sc_camera_vec3_t position)
Sets the position.
void sc_camera_aspect_ratio(sc_camera_t *camera, int width, int height)
Sets the aspect ratio.
void sc_camera_init(sc_camera_t *camera)
Initializes a camera with the default parameters.
void sc_camera_clipping_pre(const sc_camera_t *camera, sc_array_t *points, sc_array_t *indices)
Determines the indices of points that are visible within the camera's view frustum.
double sc_camera_coords_t
The data type of the coordinates for sc_camera.
Definition sc_camera.h:113
sc_camera_coords_t sc_camera_vec4_t[4]
Points in R^4 for sc_camera.
Definition sc_camera.h:121
sc_camera_coords_t sc_camera_vec3_t[3]
Points in R^3 for sc_camera.
Definition sc_camera.h:117
sc_camera_plane
Defines the order of the 6 planes of the camera's view frustum.
Definition sc_camera.h:138
void sc_camera_clipping_post(sc_array_t *points, sc_array_t *indices)
Performs clipping in normalized device coordinates (NDC) space.
void sc_camera_frustum_dist(const sc_camera_t *camera, const sc_camera_vec3_t point, sc_camera_coords_t distances[6])
Computes the signed distances of a point to the 6 planes of the camera's view frustum.
void sc_camera_get_frustum(const sc_camera_t *camera, sc_array_t *planes)
Returns the 6 planes of the view frustum.
void sc_camera_destroy(sc_camera_t *camera)
Destroys a camera structure.
sc_camera_coords_t sc_camera_mat3x3_t[9]
3 times 3 matrix for sc_camera.
Definition sc_camera.h:131
void sc_camera_get_projection_mat(const sc_camera_t *camera, sc_camera_mat4x4_t proj_matrix)
Returns the projection transformation matrix.
void sc_camera_roll(sc_camera_t *camera, double angle)
Rotating the camera around the backward axis.
struct sc_camera sc_camera_t
Represents a camera with parameters for rendering a 3D scene.
void sc_camera_yaw(sc_camera_t *camera, double angle)
Rotating the camera around the up axis.
sc_camera_t * sc_camera_new(void)
Creates a new camera structure with the default values (see sc_camera_init).
void sc_camera_view_transform(const sc_camera_t *camera, sc_array_t *points_in, sc_array_t *points_out)
Performs the view transformation from world space to view space.
void sc_camera_fov(sc_camera_t *camera, double angle)
Sets the horizontal field of view.
void sc_camera_perspective_division(sc_array_t *points_in, sc_array_t *points_out)
Performs perspective division.
void sc_camera_look_at(sc_camera_t *camera, const sc_camera_vec3_t eye, const sc_camera_vec3_t center, const sc_camera_vec3_t up)
Sets the position and rotation of the camera object.
void sc_camera_projection_transform(const sc_camera_t *camera, sc_array_t *points_in, sc_array_t *points_out)
Performs the projection transformation from view space to normalized device coordinates.
void sc_camera_pitch(sc_camera_t *camera, double angle)
Rotating the camera around the axis to the right.
void sc_camera_walk(sc_camera_t *camera, double distance)
Move the camera backward/forward along the view direction.
enum sc_camera_plane sc_camera_plane_t
Defines the order of the 6 planes of the camera's view frustum.
void sc_camera_get_view_mat(const sc_camera_t *camera, sc_camera_mat4x4_t view_matrix)
Returns the view transformation matrix.
sc_camera_coords_t sc_camera_mat4x4_t[16]
4 times 4 matrix for sc_camera.
Definition sc_camera.h:126
void sc_camera_clipping_dist(sc_camera_t *camera, sc_camera_coords_t near_plane, sc_camera_coords_t far_plane)
Sets the clipping distances.
Dynamic containers such as lists, arrays, and hash tables.
The sc_array object provides a dynamic array of equal-size elements.
Definition sc_containers.h:118
Represents a camera with parameters for rendering a 3D scene.
Definition sc_camera.h:156
sc_camera_coords_t far_plane
Distance to the far clipping plane.
Definition sc_camera.h:174
int width
Image width in pixels, used to determine the aspect ratio.
Definition sc_camera.h:168
double FOV
Horizontal field of view (in radians), defining the frustum's opening angle horizontally.
Definition sc_camera.h:164
int height
Image height in pixels, used to determine the aspect ratio.
Definition sc_camera.h:170
sc_camera_coords_t near_plane
Distance to the near clipping plane.
Definition sc_camera.h:173
sc_camera_vec4_t frustum_planes[6]
The bounding planes of the view frustum (see sc_camera_get_frustum).
Definition sc_camera.h:176
sc_camera_vec4_t rotation
Rotation from world space to view space, represented as a unit quaternion.
Definition sc_camera.h:160
sc_camera_vec3_t position
The position of the camera in world coordinates.
Definition sc_camera.h:157