Easy3D 2.5.3
|
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. More... | |
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. More... | |
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. More... | |
void | draw_full_screen_quad (unsigned int texture, float depth) |
Draws a full screen textured quad. More... | |
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. More... | |
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. More... | |
void | draw_full_screen_quad (unsigned int position_attrib, unsigned int texcoord_attrib, float depth) |
Draws a full screen quad using the bound shader. More... | |
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. More... | |
void | draw_polygon_filled (const Polygon2 &polygon, const vec4 &color, int width, int height, float depth) |
Draws a filled polygon in the screen space. More... | |
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. More... | |
void | draw_box_wire (LinesDrawable *drawable, const mat4 &mvp, const mat4 &m, bool abstracted=false) |
Draws a box. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. s is the base center and t is the tip. | |
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. More... | |
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. More... | |
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. More... | |
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.
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.
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.
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.
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 | and color2: the two interchanging colors |
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. |
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. |
scale | The scaling factor |
points | The points to be returned. |
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.
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). |
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,y) | The position (i.e., min corner) of the quad. |
(w,h) | The size (i.e., width and height) of the quad. |
(vpw,vph) | The size (i.e., width and 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. |