Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LiangliangNan committed Feb 5, 2025
1 parent 89ec94e commit da8f72b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion easy3d/algo/text_mesher.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace easy3d {
* @param y The y-coordinate of the starting position.
* @param font_size The size of the font.
* @param contours The contours of the text (each character may have multiple contours). The generated contours
* are simply appended to his variable.
* are simply appended to this variable.
* @param collision_free If true, the generated contours will be free of intersections between characters.
*/
bool generate(const std::string &text, float x, float y, int font_size,
Expand Down
2 changes: 1 addition & 1 deletion easy3d/util/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace easy3d {
#define EASY3D_VERSION_NR 1020601

/// Easy3D release date, in the format YYYYMMDD.
#define EASY3D_RELEASE_DATE 20250203
#define EASY3D_RELEASE_DATE 20250205


#endif // EASY3D_UTIL_VERSION_H
13 changes: 9 additions & 4 deletions tutorials/Tutorial_310_TextMesher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,26 @@ int main(int argc, char **argv) {
SurfaceMesh* mesh = mesher.generate("Easy3D", 0, 0, 48, 15, true);
if (mesh)
viewer.add_model(std::shared_ptr<SurfaceMesh>(mesh)); // Add the mesh to the viewer.

// Generate surface for "Makes 3D Easy!".
// Generate a surface mesh for "Makes 3D Easy!".
mesher.set_font(resource::directory() + "/fonts/en_Roboto-Regular.ttf");
mesher.generate(mesh,"Makes 3D Easy!", 350, 0, 25, 15, true);

#else // extract and visualize the 2D contours of the text
std::vector< std::vector<Polygon2> > contours;
mesher.set_font(font_file);
// Generate the contours for "Easy3D".
mesher.generate("Easy3D", 0, -60, 48, contours, true);
mesher.set_font(resource::directory() + "/fonts/en_Roboto-Regular.ttf");
// Generate the contours for "Makes 3D Easy!".
mesher.generate("Makes 3D Easy!", 350, -60, 25, contours, true);
// Prepare data for the rendering drawable.
std::vector<vec3> points, colors;
std::vector<unsigned int> indices;
int offset = 0;
for (auto &cha : contours) {
for (auto &con : cha) {
vec3 c = con.is_clockwise() ? vec3(1, 0, 0) : vec3(0, 1, 0);
const vec3 c = con.is_clockwise() ? vec3(1, 0, 0) : vec3(0, 1, 0);
for (int i = 0; i < con.size(); ++i) {
points.push_back(vec3(con[i], 0.0f));
colors.push_back(c);
Expand All @@ -84,13 +87,15 @@ int main(int argc, char **argv) {
offset += con.size();
}
}
// Create the rendering drawable and transfer data into the buffers.
LinesDrawable *d = new LinesDrawable;
d->update_vertex_buffer(points);
d->update_color_buffer(colors);
d->update_element_buffer(indices);
d->set_impostor_type(LinesDrawable::CONE);
d->set_line_width(2);
d->set_line_width(3);
d->set_property_coloring(easy3d::State::VERTEX);
// Add the drawable to the viewer.
viewer.add_drawable(std::shared_ptr<LinesDrawable>(d));
#endif

Expand Down

0 comments on commit da8f72b

Please sign in to comment.