Namespace for CPE classes. More...
Classes | |
class | matrix2 |
Matrix 2x2. More... | |
class | exception_matrix2 |
Special exception class for v3. More... | |
class | matrix3 |
Matrix 3x3. More... | |
class | exception_matrix3 |
Special exception class for v3. More... | |
class | matrix4 |
Matrix 4x4. More... | |
class | exception_matrix4 |
Special exception class for v3. More... | |
class | quaternion |
Quaternion class. More... | |
class | exception_quaternion |
Special exception class for v4. More... | |
class | vec2 |
Vectors/Points 2D. More... | |
class | exception_vec2 |
Special exception class for v2. More... | |
class | vec3 |
Vectors/Points 3D. More... | |
class | exception_vec3 |
Special exception class for v3. More... | |
class | vec4 |
Vectors/Points 4D. More... | |
class | exception_vec4 |
Special exception class for v4. More... | |
class | exception_cpe |
General exception class. More... | |
class | color |
Container class for (r,g,b) color. Each component is between [0,1]. More... | |
class | exception_color |
Exception class for color. More... | |
class | image |
Container for picture data. Data are stored as unsigned char [0,255]. More... | |
class | exception_image |
Special exception class for image. More... | |
class | pos2 |
Container for 2D integer positions (pixel position) More... | |
class | exception_p2d |
Exception class for p2d. More... | |
class | z_buffer |
Class to manage a depth-buffer. More... | |
class | mesh |
Container class for a generic mesh with normal, color, texture, ... More... | |
class | exception_mesh |
Special exception class for image. More... | |
class | mesh_io |
Helper class for I/O mesh. More... | |
class | object3d |
Generic container of a shape with intersect method. More... | |
class | plane |
Object3d of type (infinite) Plane (position+normal). Analytically compute intersection with a ray. More... | |
class | sphere |
Object3d of type Sphere (center+radius). Analytically compute intersection with a ray. More... | |
class | anti_aliasing_table |
Compute weights for anti-aliasing rays. More... | |
struct | intersection |
container for intersection data (position, normal, and relative position with respect to the ray) More... | |
class | ray |
Straight ray (initial position + direction) used for ray-tracing algorithm. More... | |
class | camera |
Storage of a camera and screen parameters. More... | |
struct | light |
Container of a light. More... | |
struct | material |
material associated to a given object (color+shading data) More... | |
class | scene |
Container of object3d+material and light to define a 3D scene. More... | |
class | exception_scene3d |
Special exception class for v3. More... | |
struct | shading |
Container for shading parameters (ambiant,diffuse,specular) More... | |
struct | vertex |
A vertex structure containing a position, normal, and a color. More... | |
Typedefs | |
typedef float | color_component |
Functions | |
matrix2 | operator+ (float s, const matrix2 &m) |
| |
matrix2 | operator- (float s, const matrix2 &m) |
| |
matrix2 | operator* (float s, const matrix2 &m) |
multiply by a scalar operator More... | |
std::ostream & | operator<< (std::ostream &stream, const matrix2 &m) |
output the vector in ostream More... | |
matrix3 | operator+ (float s, const matrix3 &m) |
| |
matrix3 | operator- (float s, const matrix3 &m) |
| |
matrix3 | operator* (float s, const matrix3 &m) |
multiply by a scalar operator More... | |
std::ostream & | operator<< (std::ostream &stream, const matrix3 &m) |
output the vector in ostream More... | |
matrix4 | operator+ (float s, const matrix4 &m) |
| |
matrix4 | operator- (float s, const matrix4 &m) |
| |
matrix4 | operator* (float s, const matrix4 &m) |
multiply by a scalar operator More... | |
std::ostream & | operator<< (std::ostream &stream, const matrix4 &m) |
output the vector in ostream More... | |
quaternion | operator* (float s, const quaternion &q) |
multiplication with scalar More... | |
vec2 | operator+ (float s, const vec2 &p) |
| |
vec2 | operator- (float s, const vec2 &p) |
| |
vec2 | operator* (float s, const vec2 &p) |
multiply by a scalar operator More... | |
std::ostream & | operator<< (std::ostream &stream, const vec2 &p) |
output the vector in ostream as (x,y,z) More... | |
vec3 | operator+ (float s, const vec3 &p) |
| |
vec3 | operator- (float s, const vec3 &p) |
| |
vec3 | operator* (float s, const vec3 &p) |
multiply by a scalar operator More... | |
std::ostream & | operator<< (std::ostream &stream, const vec3 &p) |
output the vector in ostream as (x,y,z) More... | |
vec4 | operator+ (float s, const vec4 &p) |
| |
vec4 | operator- (float s, const vec4 &p) |
| |
vec4 | operator* (float s, const vec4 &p) |
multiply by a scalar operator More... | |
std::ostream & | operator<< (std::ostream &stream, const vec4 &p) |
output the vector in ostream as (x,y,z) More... | |
std::ostream & | operator<< (std::ostream &stream, const color &c) |
standard output More... | |
color & | operator+= (color &c0, const color &c1) |
color & | operator-= (color &c0, const color &c1) |
color | operator+ (const color &c0, const color &c1) |
color | operator- (const color &c0, const color &c1) |
color & | operator*= (color &c0, float alpha) |
color & | operator*= (color &c0, const color &c1) |
color & | operator/= (color &c0, float alpha) |
color | operator* (const color &c0, float alpha) |
color | operator* (float alpha, const color &c0) |
color | operator* (const color &c0, const color &c1) |
color | operator/ (const color &c0, float alpha) |
void | export_ppm (const std::string &filename, const image &pic) |
Export the picture into ppm format (ascii) More... | |
void | export_ppm (const std::string &filename, const z_buffer &buffer) |
Export the z-buffer as a gray picture into ppm format (ascii) More... | |
image | read_ppm (const std::string &filename) |
read a ppm picture format More... | |
std::ostream & | operator<< (std::ostream &stream, const pos2 &u) |
standard output More... | |
pos2 & | operator+= (pos2 &u1, const pos2 &u2) |
internal sum between two positions More... | |
pos2 & | operator-= (pos2 &u1, const pos2 &u2) |
internal diff between two positions More... | |
pos2 | operator+ (const pos2 &u1, const pos2 &u2) |
sum between two positions More... | |
pos2 | operator- (const pos2 &u1, const pos2 &u2) |
diff between two positions More... | |
mesh | operator+ (const vec3 &x, const mesh &m) |
mesh | operator+ (const mesh &m, const vec3 &x) |
mesh | operator- (const mesh &m, const vec3 &x) |
mesh | operator* (const float &s, const mesh &m) |
mesh | operator* (const mesh &m, const float &s) |
std::ostream & | operator<< (std::ostream &stream, const intersection &inter) |
std::ostream & | operator<< (std::ostream &stream, const ray &r) |
exporting ray data More... | |
vec3 | reflected_direction (const vec3 &u, const vec3 &n) |
return the reflected direction from a given ray with respect to the normal n More... | |
ray | ray_generate (float kx, float ky, int Nx, int Ny, const camera &cam) |
build a ray starting from a camera center, and passing through the specific pixel (kx,ky) More... | |
void | render (image &image_parameter, const scene &scene_parameter) |
color | ray_trace (const ray &r, const scene &scene_parameter) |
Compute color associated to a single ray. More... | |
bool | compute_first_intersection (const ray &r, const scene &scene_parameter, intersection &inter, int &index) |
Compute the first intersection of a ray in the 3D scene. More... | |
bool | is_in_shadow (const vec3 &position, const vec3 &light_position, const scene &scene_parameter) |
Given a position in the 3D scene, and a position of a single light, the function check if the position is in the shadow of other objects or not. More... | |
vec3 | screen_position (const camera &cam, float u, float v) |
return the 3D position of the pixel (u,v) More... | |
color | apply_shading (const vec3 &p, const vec3 &n, const color &c, const vec3 &light_position, const vec3 &camera_position, const shading &shad) |
Apply gouraud shading. More... | |
Namespace for CPE classes.
typedef float cpe::color_component |
color cpe::apply_shading | ( | const vec3 & | p, |
const vec3 & | n, | ||
const color & | c, | ||
const vec3 & | light_position, | ||
const vec3 & | camera_position, | ||
const shading & | shading_param | ||
) |
Apply gouraud shading.
bool cpe::compute_first_intersection | ( | const ray & | r, |
const scene & | scene_parameter, | ||
intersection & | inter, | ||
int & | index | ||
) |
Compute the first intersection of a ray in the 3D scene.
ray,: | the ray in the scene. |
scene_parameter,: | the 3D scene |
inter,: | the intersection parameter that is filled if there is an intersection. |
index,: | the index of the intersected object that is filled if there is an intersection. |
References cpe::scene::get_object(), cpe::object3d::intersect(), and cpe::scene::N_object().
Referenced by ray_trace().
void cpe::export_ppm | ( | const std::string & | filename, |
const image & | pic | ||
) |
Export the picture into ppm format (ascii)
std::string | filename: file to store the picture |
image | pic: image to store |
References cpe::color::b(), cpe::color::clamp(), cpe::color::g(), MACRO_EXCEPTION_PARAMETER, cpe::image::Nx(), cpe::image::Ny(), and cpe::color::r().
Referenced by cpe::z_buffer::export_file(), and cpe::image::export_file().
void cpe::export_ppm | ( | const std::string & | filename, |
const z_buffer & | buffer | ||
) |
Export the z-buffer as a gray picture into ppm format (ascii)
std::string | filename: file to store the picture |
z_buffer | buffer: depth-map to store |
References cpe::color::b(), cpe::color::clamp(), cpe::color::g(), cpe::z_buffer::get_max(), cpe::z_buffer::get_min(), cpe::color::r(), cpe::z_buffer::size_x(), and cpe::z_buffer::size_y().
bool cpe::is_in_shadow | ( | const vec3 & | position, |
const vec3 & | light_position, | ||
const scene & | scene_parameter | ||
) |
Given a position in the 3D scene, and a position of a single light, the function check if the position is in the shadow of other objects or not.
mesh cpe::operator* | ( | const float & | s, |
const mesh & | m | ||
) |
mesh cpe::operator* | ( | const mesh & | m, |
const float & | s | ||
) |
matrix2 cpe::operator* | ( | float | s, |
const matrix2 & | m | ||
) |
multiply by a scalar operator
matrix3 cpe::operator* | ( | float | s, |
const matrix3 & | m | ||
) |
multiply by a scalar operator
vec2 cpe::operator* | ( | float | s, |
const vec2 & | p | ||
) |
multiply by a scalar operator
References cpe::vec2::x(), and cpe::vec2::y().
color cpe::operator* | ( | const color & | c0, |
float | alpha | ||
) |
color cpe::operator* | ( | float | alpha, |
const color & | c0 | ||
) |
color cpe::operator* | ( | const color & | c0, |
const color & | c1 | ||
) |
vec3 cpe::operator* | ( | float | s, |
const vec3 & | p | ||
) |
multiply by a scalar operator
References cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().
vec4 cpe::operator* | ( | float | s, |
const vec4 & | p | ||
) |
multiply by a scalar operator
References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
matrix4 cpe::operator* | ( | float | s, |
const matrix4 & | m | ||
) |
multiply by a scalar operator
References cpe::matrix4::pointer().
quaternion cpe::operator* | ( | float | s, |
const quaternion & | q | ||
) |
multiplication with scalar
color & cpe::operator*= | ( | color & | c0, |
float | alpha | ||
) |
References cpe::color::b(), cpe::color::g(), and cpe::color::r().
color & cpe::operator*= | ( | color & | c0, |
const color & | c1 | ||
) |
References cpe::color::b(), cpe::color::g(), and cpe::color::r().
pos2 cpe::operator+ | ( | const pos2 & | u1, |
const pos2 & | u2 | ||
) |
sum between two positions
mesh cpe::operator+ | ( | const vec3 & | x, |
const mesh & | m | ||
) |
mesh cpe::operator+ | ( | const mesh & | m, |
const vec3 & | x | ||
) |
matrix2 cpe::operator+ | ( | float | s, |
const matrix2 & | m | ||
) |
matrix3 cpe::operator+ | ( | float | s, |
const matrix3 & | m | ||
) |
color cpe::operator+ | ( | const color & | c0, |
const color & | c1 | ||
) |
vec2 cpe::operator+ | ( | float | s, |
const vec2 & | p | ||
) |
vec3 cpe::operator+ | ( | float | s, |
const vec3 & | p | ||
) |
References cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().
matrix4 cpe::operator+ | ( | float | s, |
const matrix4 & | m | ||
) |
vec4 cpe::operator+ | ( | float | s, |
const vec4 & | p | ||
) |
References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
pos2 & cpe::operator+= | ( | pos2 & | u1, |
const pos2 & | u2 | ||
) |
internal sum between two positions
References cpe::pos2::x(), and cpe::pos2::y().
color & cpe::operator+= | ( | color & | c0, |
const color & | c1 | ||
) |
References cpe::color::b(), cpe::color::g(), and cpe::color::r().
pos2 cpe::operator- | ( | const pos2 & | u1, |
const pos2 & | u2 | ||
) |
diff between two positions
mesh cpe::operator- | ( | const mesh & | m, |
const vec3 & | x | ||
) |
color cpe::operator- | ( | const color & | c0, |
const color & | c1 | ||
) |
matrix2 cpe::operator- | ( | float | s, |
const matrix2 & | m | ||
) |
matrix3 cpe::operator- | ( | float | s, |
const matrix3 & | m | ||
) |
vec2 cpe::operator- | ( | float | s, |
const vec2 & | p | ||
) |
vec3 cpe::operator- | ( | float | s, |
const vec3 & | p | ||
) |
References cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().
matrix4 cpe::operator- | ( | float | s, |
const matrix4 & | m | ||
) |
vec4 cpe::operator- | ( | float | s, |
const vec4 & | p | ||
) |
References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().
pos2 & cpe::operator-= | ( | pos2 & | u1, |
const pos2 & | u2 | ||
) |
internal diff between two positions
References cpe::pos2::x(), and cpe::pos2::y().
color & cpe::operator-= | ( | color & | c0, |
const color & | c1 | ||
) |
References cpe::color::b(), cpe::color::g(), and cpe::color::r().
color cpe::operator/ | ( | const color & | c0, |
float | alpha | ||
) |
References MACRO_EXCEPTION_PARAMETER.
color & cpe::operator/= | ( | color & | c0, |
float | alpha | ||
) |
References cpe::color::b(), cpe::color::g(), MACRO_EXCEPTION_PARAMETER, and cpe::color::r().
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const pos2 & | u | ||
) |
standard output
References cpe::pos2::x(), and cpe::pos2::y().
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const intersection & | inter | ||
) |
References cpe::intersection::n, cpe::intersection::t, and cpe::intersection::x.
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const ray & | r | ||
) |
exporting ray data
References cpe::ray::u, and cpe::ray::x0.
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const color & | c | ||
) |
standard output
References cpe::color::b(), cpe::color::g(), and cpe::color::r().
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const vec2 & | p | ||
) |
output the vector in ostream as (x,y,z)
References cpe::vec2::to_string().
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const matrix2 & | _m | ||
) |
output the vector in ostream
References cpe::matrix2::pointer().
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const matrix3 & | _m | ||
) |
output the vector in ostream
References cpe::matrix3::pointer().
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const vec3 & | p | ||
) |
output the vector in ostream as (x,y,z)
References cpe::vec3::to_string().
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const vec4 & | p | ||
) |
output the vector in ostream as (x,y,z)
References cpe::vec4::to_string().
std::ostream & cpe::operator<< | ( | std::ostream & | stream, |
const matrix4 & | _m | ||
) |
output the vector in ostream
References cpe::matrix4::pointer().
ray cpe::ray_generate | ( | float | kx, |
float | ky, | ||
int | Nx, | ||
int | Ny, | ||
const camera & | cam | ||
) |
build a ray starting from a camera center, and passing through the specific pixel (kx,ky)
References cpe::camera::get_center(), and screen_position().
Referenced by render().
color cpe::ray_trace | ( | const ray & | r, |
const scene & | scene_parameter | ||
) |
Compute color associated to a single ray.
References cpe::material::c, compute_first_intersection(), and cpe::scene::get_material().
Referenced by render().
image cpe::read_ppm | ( | const std::string & | filename | ) |
read a ppm picture format
std::string | filename: path of the file to read |
References MACRO_EXCEPTION_PARAMETER.
Referenced by cpe::image::image().
vec3 cpe::reflected_direction | ( | const vec3 & | u, |
const vec3 & | n | ||
) |
return the reflected direction from a given ray with respect to the normal n
References cpe::vec3::dot(), and cpe::vec3::norm2().
void cpe::render | ( | image & | image_parameter, |
const scene & | scene_parameter | ||
) |
run rendering using ray-tracing algorithm given an image to write and a 3D scene
References cpe::scene::get_camera(), cpe::image::Nx(), cpe::image::Ny(), ray_generate(), and ray_trace().
Referenced by main().
vec3 cpe::screen_position | ( | const camera & | cam, |
float | u, | ||
float | v | ||
) |
return the 3D position of the pixel (u,v)
References cpe::vec3::cross(), cpe::camera::get_center(), cpe::camera::get_direction(), cpe::camera::get_dist_screen(), cpe::camera::get_length_screen(), cpe::camera::get_up(), and cpe::vec3::normalized().
Referenced by ray_generate().