Easy3D 2.6.1
|
A collection of functions for rendering basic shapes. More...
Functions | |
Functions for drawing | |
void | draw_quad_wire (const Rect &rect, const vec4 &color, int width, int height, float depth) |
Draws a wire quad defined in the screen space. | |
void | draw_quad_filled (const Rect &rect, const vec4 &color, int width, int height, float depth) |
Draws a solid quad defined in the screen space. | |
void | draw_quad_filled (const Rect &rect, unsigned int texture, int width, int height, float depth) |
Draws a solid quad defined in the screen space. | |
void | draw_full_screen_quad (unsigned int texture, float depth) |
Draws a full screen textured quad. | |
void | draw_depth_texture (const Rect &rect, unsigned int texture, int width, int height, float depth) |
Draws a quad visualizing a depth texture in a region. | |
void | draw_quad (unsigned int position_attrib, unsigned int texcoord_attrib, int x, int y, int w, int h, int vpw, int vph, float depth) |
Draws a quad defined in the screen space using a bound shader. | |
void | draw_full_screen_quad (unsigned int position_attrib, unsigned int texcoord_attrib, float depth) |
Draws a full screen quad using the bound shader. | |
void | draw_polygon_wire (const Polygon2 &polygon, const vec4 &color, int width, int height, float depth) |
Draws a polygon (line loop) in the screen space. | |
void | draw_polygon_filled (const Polygon2 &polygon, const vec4 &color, int width, int height, float depth) |
Draws a filled polygon in the screen space. | |
void | draw_sphere_big_circles (LinesDrawable *drawable, const mat4 &mvp, const mat4 &m, bool axes=true) |
Draws the outline (the 3 big circles) of a sphere. | |
void | draw_box_wire (LinesDrawable *drawable, const mat4 &mvp, const mat4 &m, bool abstracted=false) |
Draws a box. | |
Functions for creating basic shapes (data preparation) | |
void | create_grid (int x_steps, int y_steps, std::vector< vec3 > &points, float depth=0.0f, float scale=0.5f) |
Generates data for a grid as a set of line segments. | |
void | create_box (std::vector< vec3 > &points, std::vector< vec3 > &colors, bool abstracted=false) |
Generates data for a unit box as a set of line segments. | |
void | create_circle (int slices, std::vector< vec3 > &points, std::vector< unsigned int > &indices) |
Generates data for a unit circle as a set of line segments. | |
void | create_sphere (const vec3 ¢er, double radius, int slices, int stacks, const vec3 &color, std::vector< vec3 > &points, std::vector< vec3 > &normals, std::vector< vec3 > &colors) |
Generates data (points, normals, and colors) for a 3D sphere. | |
void | create_checker_sphere (const vec3 ¢er, double radius, int slices, int stacks, int checker_size, const vec3 &color1, const vec3 &color2, std::vector< vec3 > &points, std::vector< vec3 > &normals, std::vector< vec3 > &colors) |
Generates data (points, normals, and colors) for a 3D checker sphere. | |
void | create_cylinder (double radius, int slices, const vec3 &s, const vec3 &t, const vec3 &color, std::vector< vec3 > &points, std::vector< vec3 > &normals, std::vector< vec3 > &colors) |
Prepares data (points, normals, and colors) for a 3D cylinder defined by two 3D points s and t. | |
void | create_cone (double radius, int slices, const vec3 &s, const vec3 &t, const vec3 &color, std::vector< vec3 > &points, std::vector< vec3 > &normals, std::vector< vec3 > &colors) |
Prepares data (points, normals, and colors) for a 3D cone defined by two 3D points b and t. | |
void | create_torus (double major_radius, double minor_radius, int major_slices, int minor_slices, std::vector< vec3 > &points, std::vector< vec3 > &normals) |
Prepares data for representing a torus. | |
void | create_camera (std::vector< vec3 > &points, float width, float fov, float hw_ratio=0.6f) |
Generates data (points) for representing a camera in the 3D world as a set of lines. | |
void | create_camera (std::vector< vec3 > &points, std::vector< unsigned int > &indices, float width, float fov, float hw_ratio=0.6f) |
Prepares data (points) for representing a camera in the 3D world as a set of triangles. | |
A collection of functions for rendering basic shapes.
void create_box | ( | std::vector< vec3 > & | points, |
std::vector< vec3 > & | colors, | ||
bool | abstracted = false ) |
Generates data for a unit box as a set of line segments.
The box is centered at vec3(0, 0, 0) and is aligned with the main axes.
points | The points to be returned. |
colors | The colors of the points. |
abstracted | true to draw an abstracted version (only part of its corners). |
void create_camera | ( | std::vector< vec3 > & | points, |
float | width, | ||
float | fov, | ||
float | hw_ratio = 0.6f ) |
Generates data (points) for representing a camera in the 3D world as a set of lines.
points | The points to be returned. |
width | The width of the camera. A good value can be 5% of the scene radius, or 10% of the character height (in walking mode). |
fov | The vertical field of view of the camera (in radians). |
hw_ratio | The aspect ratio of the base quad defined as height/width (default 0.6). |
void create_camera | ( | std::vector< vec3 > & | points, |
std::vector< unsigned int > & | indices, | ||
float | width, | ||
float | fov, | ||
float | hw_ratio = 0.6f ) |
Prepares data (points) for representing a camera in the 3D world as a set of triangles.
points | The points to be returned. |
indices | The vertex indices to be returned. |
width | The width of the camera. A good value can be 5% of the scene radius, or 10% of the character height (in walking mode). |
fov | The vertical field of view of the camera (in radians). |
hw_ratio | The aspect ratio of the base quad defined as height/width (default 0.6). |
void create_checker_sphere | ( | const vec3 & | center, |
double | radius, | ||
int | slices, | ||
int | stacks, | ||
int | checker_size, | ||
const vec3 & | color1, | ||
const vec3 & | color2, | ||
std::vector< vec3 > & | points, | ||
std::vector< vec3 > & | normals, | ||
std::vector< vec3 > & | colors ) |
Generates data (points, normals, and colors) for a 3D checker sphere.
center | the center of the sphere. |
radius | the radius of the sphere. |
slices | the number of subdivisions around the z axis (similar to lines of longitude). |
stacks | the number of subdivisions along the z axis(similar to lines of latitude). |
checker_size | how many tiles each checker will occupy. |
color1 | one of the two interchanging colors. |
color2 | the other one of the two interchanging colors. |
points | the points to be returned. |
normals | the normals to be returned. |
colors | the colors to be returned. |
void create_circle | ( | int | slices, |
std::vector< vec3 > & | points, | ||
std::vector< unsigned int > & | indices ) |
Generates data for a unit circle as a set of line segments.
The circle is centered at vec3(0, 0, 0) and lies on the XOY plane.
slices | The number of subdivisions. |
points | The points to be returned. |
indices | The indices of the points. |
void create_cone | ( | double | radius, |
int | slices, | ||
const vec3 & | s, | ||
const vec3 & | t, | ||
const vec3 & | color, | ||
std::vector< vec3 > & | points, | ||
std::vector< vec3 > & | normals, | ||
std::vector< vec3 > & | colors ) |
Prepares data (points, normals, and colors) for a 3D cone defined by two 3D points b and t.
radius | The radius of the cone. |
slices | The number of subdivisions around the z axis (similar to lines of longitude). |
s | The base center. |
t | The top center. |
color | The color of the cone. |
points | The points to be returned. |
normals | The normals to be returned. |
colors | The colors to be returned. |
void create_cylinder | ( | double | radius, |
int | slices, | ||
const vec3 & | s, | ||
const vec3 & | t, | ||
const vec3 & | color, | ||
std::vector< vec3 > & | points, | ||
std::vector< vec3 > & | normals, | ||
std::vector< vec3 > & | colors ) |
Prepares data (points, normals, and colors) for a 3D cylinder defined by two 3D points s and t.
radius | The radius of the cylinder. |
slices | The number of subdivisions around the z axis (similar to lines of longitude). |
s | The base center. |
t | The top center. |
color | The color of the cylinder. |
points | The points to be returned. |
normals | The normals to be returned. |
colors | The colors to be returned. |
void create_grid | ( | int | x_steps, |
int | y_steps, | ||
std::vector< vec3 > & | points, | ||
float | depth = 0.0f, | ||
float | scale = 0.5f ) |
Generates data for a grid as a set of line segments.
The grid is centered at vec3(0, 0, 0) and lies on the XOY plane.
x_steps | The number of subdivisions along X direction. |
y_steps | The number of subdivisions along Y direction. |
depth | The depth (Z value) of the generated points. |
points | The points to be returned. |
scale | The scaling factor |
void create_sphere | ( | const vec3 & | center, |
double | radius, | ||
int | slices, | ||
int | stacks, | ||
const vec3 & | color, | ||
std::vector< vec3 > & | points, | ||
std::vector< vec3 > & | normals, | ||
std::vector< vec3 > & | colors ) |
Generates data (points, normals, and colors) for a 3D sphere.
center | the center of the sphere. |
radius | the radius of the sphere. |
slices | the number of subdivisions around the z axis (similar to lines of longitude). |
stacks | the number of subdivisions along the z axis(similar to lines of latitude). |
color | the color of the sphere. |
points | the points to be returned. |
normals | the normals to be returned. |
colors | the colors to be returned. |
void create_torus | ( | double | major_radius, |
double | minor_radius, | ||
int | major_slices, | ||
int | minor_slices, | ||
std::vector< vec3 > & | points, | ||
std::vector< vec3 > & | normals ) |
Prepares data for representing a torus.
major_radius | The radius of major circle. |
minor_radius | The radius of minor circle. |
major_slices | The number of subdivisions along the major circle (suggested value 50). |
minor_slices | The number of subdivisions along the minor circle (suggested value 20). |
points | Returns the points. |
normals | Returns the normals. |
void draw_box_wire | ( | LinesDrawable * | drawable, |
const mat4 & | mvp, | ||
const mat4 & | m, | ||
bool | abstracted = false ) |
Draws a box.
drawable | The drawable. |
mvp | The model view projection matrix. |
m | The transformation matrix defining the box's location, sizes, and orientation. |
abstracted | true to draw an abstracted version (only part of its corners). |
void draw_depth_texture | ( | const Rect & | rect, |
unsigned int | texture, | ||
int | width, | ||
int | height, | ||
float | depth ) |
Draws a quad visualizing a depth texture in a region.
This is function is similar to draw_quad_filled(... int texture...). The only difference is that a depth texture is rendered as a gray scale image. For depth textures from off-screen rendering (usually from an FBO), the depth values are stored in the R component of the texture.
rect | The quad. |
texture | The texture. |
width | The width of the viewer. |
height | The height of the viewer. |
depth | The depth at which the quad will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
void draw_full_screen_quad | ( | unsigned int | position_attrib, |
unsigned int | texcoord_attrib, | ||
float | depth ) |
Draws a full screen quad using the bound shader.
It binds the vertex position and UVs arrays to the given attribute array indices and draws the quad.
position_attrib | The vertex attribute array index that represents position in the current shader. |
texcoord_attrib | The vertex attribute array index that represents 2D UVs in the current shader. |
depth | The depth at which the quad will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
void draw_full_screen_quad | ( | unsigned int | texture, |
float | depth ) |
Draws a full screen textured quad.
texture | The texture. |
depth | The depth at which the quad will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
void draw_polygon_filled | ( | const Polygon2 & | polygon, |
const vec4 & | color, | ||
int | width, | ||
int | height, | ||
float | depth ) |
Draws a filled polygon in the screen space.
polygon | The polygon. |
color | The color. |
width | The width of the viewer. |
height | The height of the viewer. |
depth | The depth at which the polygon will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
To make the polygon transparent, do the following
void draw_polygon_wire | ( | const Polygon2 & | polygon, |
const vec4 & | color, | ||
int | width, | ||
int | height, | ||
float | depth ) |
Draws a polygon (line loop) in the screen space.
polygon | The polygon. |
color | The color. |
width | The width of the viewer. |
height | The height of the viewer. |
depth | The depth at which the polygon will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
void draw_quad | ( | unsigned int | position_attrib, |
unsigned int | texcoord_attrib, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
int | vpw, | ||
int | vph, | ||
float | depth ) |
Draws a quad defined in the screen space using a bound shader.
It binds the vertex position and UVs arrays to the given attribute array indices and draws the quad.
position_attrib | The vertex attribute array index that represents position in the current shader. |
texcoord_attrib | The vertex attribute array index that represents 2D UVs in the current shader. |
x | The x coordinate of the min corner of the quad. |
y | The y coordinate of the min corner of the quad. |
w | The width of the quad. |
h | The height of the quad. |
vpw | The width of the viewport (of the viewer). |
vph | The height of the viewport (of the viewer). |
depth | The depth at which the quad will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
Draws a solid quad defined in the screen space.
rect | The quad. |
color | The color. |
width | The width of the viewer. |
height | The height of the viewer. |
depth | The depth at which the quad will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
void draw_quad_filled | ( | const Rect & | rect, |
unsigned int | texture, | ||
int | width, | ||
int | height, | ||
float | depth ) |
Draws a solid quad defined in the screen space.
rect | The quad. |
texture | The texture. |
width | The width of the viewer. |
height | The height of the viewer. |
depth | The depth at which the quad will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
Draws a wire quad defined in the screen space.
rect | The quad. |
color | The color. |
width | The width of the viewer. |
height | The height of the viewer. |
depth | The depth at which the quad will be drawn. The depth value is the Normalized Device Coordinates within the range [-1.0, 1.0], corresponding to the near and far clipping planes, respectively. |
void draw_sphere_big_circles | ( | LinesDrawable * | drawable, |
const mat4 & | mvp, | ||
const mat4 & | m, | ||
bool | axes = true ) |
Draws the outline (the 3 big circles) of a sphere.
drawable | The drawable. |
mvp | The model view projection matrix. |
m | The transformation matrix defining the sphere's location, radius, and orientation. |
axes | true will also draw the three main axes. |