Generate a 3D surface mesh from a text string.
More...
#include <easy3d/algo/text_mesher.h>
|
| TextMesher (const std::string &font_file, unsigned short quality=4) |
| Create an instance of TextMesher.
|
|
| ~TextMesher () |
| Destructor.
|
|
void | set_font (const std::string &font_file) |
| Change the font.
|
|
SurfaceMesh * | generate (const std::string &text, float x, float y, int font_size, float height, bool collision_free=false) |
| Generate a 3D surface mesh of a text.
|
|
bool | generate (SurfaceMesh *mesh, const std::string &text, float x, float y, int font_size, float height, bool collision_free=false) |
| Generate 3D surface representation of a text and append the surface to an existing mesh.
|
|
bool | generate (const std::string &text, float x, float y, int font_size, std::vector< std::vector< Polygon2 > > &contours, bool collision_free) |
| Generate contours from a text.
|
|
Generate a 3D surface mesh from a text string.
- Examples
- Tutorial_310_TextMesher/main.cpp.
◆ TextMesher()
TextMesher |
( |
const std::string & | font_file, |
|
|
unsigned short | quality = 4 ) |
|
explicit |
Create an instance of TextMesher.
- Parameters
-
font_file | The full path name to a TrueType font file (normally with a "ttf" extension). |
quality | This parameter controls the smoothness of the curved corners. A greater value results in a smoother transitions but more vertices. The suggested value is 4. |
- Note
- The font will be used in all subsequent generation until being modified by calling to set_font().
◆ generate() [1/3]
SurfaceMesh * generate |
( |
const std::string & | text, |
|
|
float | x, |
|
|
float | y, |
|
|
int | font_size, |
|
|
float | height, |
|
|
bool | collision_free = false ) |
Generate a 3D surface mesh of a text.
- Parameters
-
text | The input text. |
x | The x-coordinate of the starting position. |
y | The y-coordinate of the starting position. |
font_size | The size of the font. |
height | The height (in the Z direction) of the 3D model. |
collision_free | If true, the final mesh will be free of intersections between characters. |
- Returns
- The generated triangular surface mesh.
◆ generate() [2/3]
bool generate |
( |
const std::string & | text, |
|
|
float | x, |
|
|
float | y, |
|
|
int | font_size, |
|
|
std::vector< std::vector< Polygon2 > > & | contours, |
|
|
bool | collision_free ) |
Generate contours from a text.
- Parameters
-
text | The input text. |
x | The x-coordinate of the starting position. |
y | The y-coordinate of the starting position. |
font_size | The size of the font. |
contours | The contours of the text (each character may have multiple contours). The generated contours are simply appended to this variable. |
collision_free | If true, the generated contours will be free of intersections between characters. |
- Returns
true
on success and false
on failure.
◆ generate() [3/3]
bool generate |
( |
SurfaceMesh * | mesh, |
|
|
const std::string & | text, |
|
|
float | x, |
|
|
float | y, |
|
|
int | font_size, |
|
|
float | height, |
|
|
bool | collision_free = false ) |
Generate 3D surface representation of a text and append the surface to an existing mesh.
- Parameters
-
mesh | The existing mesh to which the generated mesh will be appended. |
text | The input text. |
x | The x-coordinate of the starting position. |
y | The y-coordinate of the starting position. |
font_size | The size of the font. |
height | The height (in the Z direction) of the 3D model. |
collision_free | If true, the final mesh will be free of intersections between characters. |
- Returns
true
on success and false
on failure.
◆ set_font()
void set_font |
( |
const std::string & | font_file | ) |
|
Change the font.
- Parameters
-
font_file | The full path name to a TrueType font file (normally with a "ttf" extension). |
- Note
- The font will be used in all subsequent generation until being modified by calling to set_font().
The documentation for this class was generated from the following files:
- G:/3_code/Easy3D/easy3d/algo/text_mesher.h
- G:/3_code/Easy3D/easy3d/algo/text_mesher.cpp