Extension class from image_drawable in adding Z-buffer. More...
Public Member Functions | |
image_drawable_zbuffer () | |
empty constructor | |
image_drawable_zbuffer (const unsigned int &N) | |
create square picture of size NxN | |
image_drawable_zbuffer (const unsigned int &Nx, const unsigned int &Ny) | |
create picture of size Nx x Ny | |
image_drawable_zbuffer (const std::string &filename) | |
import pre-existing picture from file filename | |
void | line (const p2d &u1, const p2d &u2, const color &c1, const color &c2, const double &z1, const double &z2) |
draw line on image with interpolated color and z-coordinate | |
void | triangle (const p2d &u1, const p2d &u2, const p2d &u3, const color &c1, const color &c2, const color &c3, const double &z1, const double &z2, const double &z3) |
draw triangle on image with interpolated color and z-coordinate | |
Private Attributes | |
std::vector< double > | internal_Zbuffer |
Z-buffer storage based on z-coordinate. |
Extension class from image_drawable in adding Z-buffer.
cpe::image_drawable_zbuffer::image_drawable_zbuffer | ( | ) |
empty constructor
cpe::image_drawable_zbuffer::image_drawable_zbuffer | ( | const unsigned int & | N | ) |
create square picture of size NxN
unsigned | int N: size (width & height) of the picture |
References internal_Zbuffer.
cpe::image_drawable_zbuffer::image_drawable_zbuffer | ( | const unsigned int & | Nx, | |
const unsigned int & | Ny | |||
) |
create picture of size Nx x Ny
unsigned | int Nx: picture width | |
unsigned | int Ny: picture height |
References internal_Zbuffer.
cpe::image_drawable_zbuffer::image_drawable_zbuffer | ( | const std::string & | filename | ) |
import pre-existing picture from file filename
std::string | filename: path to the file to load |
References cpe::image::get_Nx(), cpe::image::get_Ny(), and internal_Zbuffer.
void cpe::image_drawable_zbuffer::line | ( | const p2d & | u1, | |
const p2d & | u2, | |||
const color & | c1, | |||
const color & | c2, | |||
const double & | z1, | |||
const double & | z2 | |||
) |
draw line on image with interpolated color and z-coordinate
p2d | u1,u2: extreme positions of the segment in pixel-coordinates | |
color | c1,c2: color values of the pixels | |
double | z1,z2: z-value of the pixels |
References cpe::image::check_position(), and cpe::image::set_pixel().
Referenced by triangle().
void cpe::image_drawable_zbuffer::triangle | ( | const p2d & | u1, | |
const p2d & | u2, | |||
const p2d & | u3, | |||
const color & | c1, | |||
const color & | c2, | |||
const color & | c3, | |||
const double & | z1, | |||
const double & | z2, | |||
const double & | z3 | |||
) |
draw triangle on image with interpolated color and z-coordinate
p2d | u1,u2,u3: extreme positions of the triangle in pixel-coordinates | |
color | c1,c2,c3: color values of the pixels | |
double | z1,z2,z3: z-value of the pixels |
References line().
Referenced by cpe::render_engine::render_triangle().
std::vector<double> cpe::image_drawable_zbuffer::internal_Zbuffer [private] |
Z-buffer storage based on z-coordinate.
The z-buffer has the same size than the image, and is initialized to +infinity
Referenced by image_drawable_zbuffer().