-
Notifications
You must be signed in to change notification settings - Fork 1
/
tessellator.h
67 lines (62 loc) · 4.36 KB
/
tessellator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include <tess/triangle_mesh.h>
namespace tess
{
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
// rectangular-base pyramid
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
triangle_mesh tessellate_box(const vec3& extents);
triangle_mesh tessellate_pyramid(const vec2& top_extents, const vec2& bottom_extents, float height, const vec2& offset = {0.0f, 0.0f});
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
// truncated cone
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
triangle_mesh tessellate_cylinder(float radius, float height,
int segment_count = 16, bool with_caps = true);
triangle_mesh tessellate_cylinder_offset(float radius, float height, const vec2& offset,
int segment_count = 16, bool with_caps = true);
triangle_mesh tessellate_cylinder_slope(float radius, float height, const vec2& top_slope_angles, const vec2& bottom_slope_angles,
int segment_count = 16, const bool with_caps = true);
triangle_mesh tessellate_cylinder_slope_offset(float radius, float height, const vec2& top_slope_angles, const vec2& bottom_slope_angles, const vec2& offset,
int segment_count = 16, bool with_caps = true);
triangle_mesh tessellate_cone(float top_radius, float bottom_radius, float height,
int segment_count = 16, bool with_caps = true);
triangle_mesh tessellate_cone_offset(float top_radius, float bottom_radius, float height, const vec2& offset,
int segment_count = 16, bool with_caps = true);
triangle_mesh tessellate_cone_slope(float top_radius, float bottom_radius, float height, const vec2& top_slope_angles, const vec2& bottom_slope_angles,
int segment_count = 16, const bool with_caps = true);
triangle_mesh tessellate_cone_slope_offset(float top_radius, float bottom_radius, float height, const vec2& top_slope_angles, const vec2& bottom_slope_angles,
const vec2& offset, int segment_count = 16, bool with_caps = true);
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
// truncated toroid
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
triangle_mesh tessellate_circular_torus(float in_radius, float out_radius, float sweep_angle,
int segment_count = 16, int sweep_count = 8, bool with_caps = false);
triangle_mesh tessellate_rectangular_torus(float in_radius, float out_radius, float in_height, float sweep_angle,
int sweep_count = 8, bool with_caps = false);
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
// ellipsoid
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
triangle_mesh tessellate_dish(float radius, float height, int horizontal_count = 16, int vertical_count = 8, bool with_cap = false);
triangle_mesh tessellate_sphere(float radius, int horizontal_count = 16, int vertical_count = 16);
triangle_mesh tessellate_ellipsoid(const vec3& radii, int horizontal_count = 16, int vertical_count = 16,
float max_vertical_angle = math::PI, bool bottom_cap = true);
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
// polygonal mesh
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
struct point
{
vec3 vertex;
vec3 normal;
};
struct contour
{
vector<point> points;
};
struct polygon
{
vector<contour> contours;
};
void tessellate_polygonal_begin();
void tessellate_polygonal_add(const polygon& poly);
triangle_mesh tessellate_polygonal_end();
} // namespace tess