This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.
Represents a set of vertices in 3D spaces with normals, colors, and texture coordinates at those points. More...
#include <ofMesh.h>
Public Types | |
using | VertexType = V |
using | NormalType = N |
using | ColorType = C |
using | TexCoordType = T |
Public Member Functions | |
Construction | |
ofMesh_ () | |
This creates the mesh, using OF_PRIMITIVE_TRIANGLES without any initial vertices. | |
ofMesh_ (ofPrimitiveMode mode, const std::vector< V > &verts) | |
This allows to you to use one of the other ofPrimitiveModes: OF_PRIMITIVE_TRIANGLES, OF_PRIMITIVE_TRIANGLE_STRIP, OF_PRIMITIVE_TRIANGLE_FAN, OF_PRIMITIVE_LINES, OF_PRIMITIVE_LINE_STRIP, OF_PRIMITIVE_LINE_LOOP, OF_PRIMITIVE_POINTS. See ofGLUtils for more information on these types. | |
virtual | ~ofMesh_ () |
void | setFromTriangles (const std::vector< ofMeshFace_< V, N, C, T > > &tris, bool bUseFaceNormal=false) |
Mesh Mode | |
void | setMode (ofPrimitiveMode mode) |
Allows you to set the ofPrimitiveMode. The available modes are OF_PRIMITIVE_TRIANGLES, OF_PRIMITIVE_TRIANGLE_STRIP, OF_PRIMITIVE_TRIANGLE_FAN, OF_PRIMITIVE_LINES, OF_PRIMITIVE_LINE_STRIP, OF_PRIMITIVE_LINE_LOOP, OF_PRIMITIVE_POINTS. | |
ofPrimitiveMode | getMode () const |
\returns the primitive mode that the mesh is using. | |
Vertices | |
void | addVertex (const V &v) |
Add a new vertex at the end of the current list of vertices. It is important to remember that the order the vertices are added to the list determines how they link they form the polygons and strips (assuming you do not change their indeces). See the ofMesh class description for details. | |
void | addVertices (const std::vector< V > &verts) |
Add a vector of vertices to a mesh, allowing you to push out many at once rather than adding one at a time. The vector of vertices is added after the end of the current vertices list. | |
void | addVertices (const V *verts, std::size_t amt) |
Add an array of vertices to the mesh. Because you are using a pointer to the array you also have to define the length of the array as an int (amt). The vertices are added at the end of the current vertices list. | |
void | removeVertex (ofIndexType index) |
Removes the vertex at the index in the vector. | |
void | removeVertices (ofIndexType startIndex, ofIndexType endIndex) |
Removes the vertices at the startIndex in the vector and the endindex specified. | |
void | setVertex (ofIndexType index, const V &v) |
void | clearVertices () |
Removes all the vertices. | |
void | clear () |
Removes all the vertices, colors, and indices from the mesh. | |
std::size_t | getNumVertices () const |
V * | getVerticesPointer () |
const V * | getVerticesPointer () const |
V | getVertex (ofIndexType i) const |
std::vector< V > & | getVertices () |
const std::vector< V > & | getVertices () const |
bool | hasVertices () const |
void | append (const ofMesh_ &mesh) |
Add the vertices, normals, texture coordinates and indices of one mesh onto another mesh. Everything from the referenced mesh is simply added at the end of the current mesh's lists. | |
void | mergeDuplicateVertices () |
V | getCentroid () const |
Normals | |
N | getNormal (ofIndexType i) const |
\returns the normal at the index in the normals vector. | |
void | addNormal (const N &n) |
Add a normal to the mesh as a 3D vector, typically perpendicular to the plane of the face. A normal is a vector that defines how a surface responds to lighting, i.e. how it is lit. The amount of light reflected by a surface is proportional to the angle between the light's direction and the normal. The smaller the angle the brighter the surface will look. See the normalsExample for advice on computing the normals. addNormal adds the 3D vector to the end of the list, so you need to make sure you add normals at the same index of the matching vertex. | |
void | addNormals (const std::vector< N > &norms) |
Add a vector of normals to a mesh, allowing you to push out many normals at once rather than adding one at a time. The vector of normals is added after the end of the current normals list. | |
void | addNormals (const N *norms, std::size_t amt) |
Add an array of normals to the mesh. Because you are using a pointer to the array you also have to define the length of the array as an std::size_t (amt). The normals are added at the end of the current normals list. | |
void | removeNormal (ofIndexType index) |
Remove a normal. | |
void | removeNormals (ofIndexType startIndex, ofIndexType endIndex) |
Remove normal's from index to end index from normals vector. | |
void | setNormal (ofIndexType index, const N &n) |
void | clearNormals () |
Remove all the normals. | |
std::size_t | getNumNormals () const |
This will tell you how many normals are contained in the mesh. | |
N * | getNormalsPointer () |
const N * | getNormalsPointer () const |
std::vector< N > & | getNormals () |
const std::vector< N > & | getNormals () const |
bool | hasNormals () const |
/returnsWhether the mesh has any normals. | |
virtual void | enableNormals () |
Enable mesh normals. Use disableNormals() to turn normals off. Normals are enabled by default when they are added to the mesh. | |
virtual void | disableNormals () |
Disable mesh normals. Use enableNormals() to turn normals back on. | |
virtual bool | usingNormals () const |
void | smoothNormals (float angle) |
void | flatNormals () |
Duplicates vertices and updates normals to get a low-poly look. | |
Faces | |
ofMeshFace_< V, N, C, T > | getFace (ofIndexType faceId) const |
std::vector< N > | getFaceNormals (bool perVetex=false) const |
Get normals for each face As a default it only calculates the normal for the face as a whole but by setting (perVertex = true) it will return the same normal value for each of the three vertices making up a face. | |
const std::vector< ofMeshFace_< V, N, C, T > > & | getUniqueFaces () const |
Colors | |
C | getColor (ofIndexType i) const |
Get the color at the index in the colors vector. | |
void | addColor (const C &c) |
This adds a color to the mesh, the color will be associated with the vertex in the same position. | |
void | addColors (const std::vector< C > &cols) |
This adds colors using a reference to a vector of ofColors. For each color in the vector, this will put the colors at the corresponding vertex. | |
void | addColors (const C *cols, std::size_t amt) |
This adds a pointer of colors to the ofMesh instance with the amount passed as the second parameter. | |
void | removeColor (ofIndexType index) |
Remove a color at the index in the colors vector. | |
void | removeColors (ofIndexType startIndex, ofIndexType endIndex) |
Remove colors at the index to the end index of the colors vector. | |
void | setColor (ofIndexType index, const C &c) |
Set the color at the index in the colors vector. | |
void | clearColors () |
Clear all the colors. | |
std::size_t | getNumColors () const |
C * | getColorsPointer () |
const C * | getColorsPointer () const |
std::vector< C > & | getColors () |
const std::vector< C > & | getColors () const |
bool | hasColors () const |
/returns Whether the mesh has any colors. | |
virtual void | enableColors () |
Enable mesh colors. Use disableColors() to turn colors off. Colors are enabled by default when they are added to the mesh. | |
virtual void | disableColors () |
Disable mesh colors. Use enableColors() to turn colors back on. | |
virtual bool | usingColors () const |
Texture Coordinates | |
T | getTexCoord (ofIndexType i) const |
void | addTexCoord (const T &t) |
Add a Vec2f representing the texture coordinate. Because OF uses ARB textures these are in pixels rather than 0-1 normalized coordinates. | |
void | addTexCoords (const std::vector< T > &tCoords) |
Add a vector of texture coordinates to a mesh, allowing you to push out many at once rather than adding one at a time. The vector of texture coordinates is added after the end of the current texture coordinates list. | |
void | addTexCoords (const T *tCoords, std::size_t amt) |
Add an array of texture coordinates to the mesh. Because you are using a pointer to the array you also have to define the length of the array as an std::size_t (amt). The texture coordinates are added at the end of the current texture coordinates list. | |
void | removeTexCoord (ofIndexType index) |
Remove a Vec2f representing the texture coordinate. | |
void | removeTexCoords (ofIndexType startIndex, ofIndexType endIndex) |
void | setTexCoord (ofIndexType index, const T &t) |
void | clearTexCoords () |
Clear all the texture coordinates. | |
std::size_t | getNumTexCoords () const |
This will tell you how many texture coordinates are contained in the mesh. | |
T * | getTexCoordsPointer () |
const T * | getTexCoordsPointer () const |
Get a pointer to the glm::vec2 texture coordinates that the mesh contains. | |
std::vector< T > & | getTexCoords () |
Get a vector representing the texture coordinates of the mesh Because OF uses ARB textures these are in pixels rather than 0-1 normalized coordinates. Use this if you plan to change the texture coordinates as part of this call as it will force a reset of the cache. | |
const std::vector< T > & | getTexCoords () const |
bool | hasTexCoords () const |
/returns Whether the mesh has any textures assigned to it. | |
virtual void | enableTextures () |
Enable mesh textures. Use disableTextures() to turn textures off. Textures are enabled by default when they are added to the mesh. | |
virtual void | disableTextures () |
Disable mesh textures. Use enableTextures() to turn textures back on. | |
virtual bool | usingTextures () const |
Indices | |
void | setupIndicesAuto () |
Allow you to set up the indices automatically when you add a vertex. | |
std::vector< ofIndexType > & | getIndices () |
Use this if you plan to change the indices as part of this call as it will force a reset of the cache. | |
ofIndexType | getIndex (ofIndexType i) const |
void | addIndex (ofIndexType i) |
void | addIndices (const std::vector< ofIndexType > &inds) |
This adds a vector of indices. | |
void | addIndices (const ofIndexType *inds, std::size_t amt) |
This adds indices to the ofMesh by pointing to an array of indices. The "amt" defines the length of the array. | |
void | removeIndex (ofIndexType index) |
Removes an index. | |
void | removeIndices (ofIndexType startIndex, ofIndexType endIndex) |
void | setIndex (ofIndexType index, ofIndexType val) |
This sets the index at i. | |
void | clearIndices () |
Remove all the indices of the mesh. This means that your mesh will be a point cloud. | |
std::size_t | getNumIndices () const |
This will tell you how many indices are contained in the mesh. | |
ofIndexType * | getIndexPointer () |
const ofIndexType * | getIndexPointer () const |
const std::vector< ofIndexType > & | getIndices () const |
bool | hasIndices () const |
/returns Whether the mesh has any indices assigned to it. | |
void | addTriangle (ofIndexType index1, ofIndexType index2, ofIndexType index3) |
Adding a triangle means using three of the vertices that have already been added to create a triangle. This is an easy way to create triangles in the mesh. The indices refer to the index of the vertex in the vector of vertices. | |
virtual void | enableIndices () |
Enable mesh indices. Use disableIndices() to turn indices off. Indices are enabled by default when they are added to the mesh. | |
virtual void | disableIndices () |
Disable mesh indices. Use enableIndices() to turn indices back on. | |
virtual bool | usingIndices () const |
void | setColorForIndices (ofIndexType startIndex, ofIndexType endIndex, C color) |
ofMesh_< V, N, C, T > | getMeshForIndices (ofIndexType startIndex, ofIndexType endIndex) const |
ofMesh_< V, N, C, T > | getMeshForIndices (ofIndexType startIndex, ofIndexType endIndex, ofIndexType startVertIndex, ofIndexType endVertIndex) const |
Drawing | |
void | drawVertices () const |
This allows you draw just the vertices, meaning that you'll have a point cloud. | |
void | drawWireframe () const |
This draws the mesh as GL_LINES, meaning that you'll have a wireframe. | |
void | drawFaces () const |
This draws the mesh as faces, meaning that you'll have a collection of faces. | |
void | draw () const |
This draws the mesh using its primitive type, meaning that if you set them up to be triangles, this will draw the triangles. | |
virtual void | draw (ofPolyRenderMode renderType) const |
This draws the mesh using a defined renderType, overriding the renderType defined with setMode(). | |
Saving and loading | |
void | load (const of::filesystem::path &path) |
Loads a mesh from a file located at the provided path into the mesh. This will replace any existing data within the mesh. | |
void | save (const of::filesystem::path &path, bool useBinary=false) const |
Saves the mesh at the passed path in the PLY Format. | |
Static Public Member Functions | |
Primitive constructor helper methods | |
static ofMesh_ | plane (float width, float height, int columns=2, int rows=2, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP) |
static ofMesh_ | sphere (float radius, int res=12, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP) |
static ofMesh_ | icosahedron (float radius) |
static ofMesh_ | icosphere (float radius, std::size_t iterations=2) |
static ofMesh_ | cylinder (float radius, float height, int radiusSegments=12, int heightSegments=6, int numCapSegments=2, bool bCapped=true, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP) |
A helper method that returns a cylinder made of triangles. The resolution settings for the radius, height, and cap are optional (they are set at a default of 12 segments around the radius, 6 segments in the height, and 2 on the cap). You have the option to cap the cylinder or not. The only valid modes are the default OF_PRIMITIVE_TRIANGLE_STRIP and OF_PRIMITIVE_TRIANGLES. | |
static ofMesh_ | cone (float radius, float height, int radiusSegments=12, int heightSegments=6, int capSegments=2, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP) |
A helper method that returns a cone made of triangles. The resolution settings for the radius, height, and cap are optional (they are set at a default of 12 segments around the radius, 6 segments in the height, and 2 on the cap). The only valid modes are the default OF_PRIMITIVE_TRIANGLE_STRIP and OF_PRIMITIVE_TRIANGLES. | |
static ofMesh_ | box (float width, float height, float depth, int resX=2, int resY=2, int resZ=2) |
A helper method that returns a box made of triangles. The resolution settings for the width and height are optional (they are both set at a default of 2 triangles per side). | |
static ofMesh_ | axis (float size=1.0) |
Returns an ofMesh representing an XYZ coordinate system. | |
Protected Member Functions | |
bool | haveVertsChanged () |
bool | haveNormalsChanged () |
bool | haveColorsChanged () |
bool | haveTexCoordsChanged () |
bool | haveIndicesChanged () |
Detailed Description
class ofMesh_< V, N, C, T >
Represents a set of vertices in 3D spaces with normals, colors, and texture coordinates at those points.
Each of these different properties is stored in a vector. Vertices are passed to your graphics card and your graphics card fill in the spaces in between them in a processing usually called the rendering pipeline. The rendering pipeline goes more or less like this:
- Say how you're going to connect all the points.
- Make some points.
- Say that you're done making points.
You may be thinking: I'll just make eight vertices and voila: a cube. Not so quick. There's a hitch and that hitch is that the OpenGL renderer has different ways of connecting the vertices that you pass to it and none are as efficient as to only need eight vertices to create a cube.
You've probably seen a version of the following image somewhere before. Generally you have to create your points to fit the drawing mode that you've selected because of whats called winding. A vertex gets connected to another vertex in the order that the mode does its winding and this means that you might need multiple vertices in a given location to create the shape you want. The cube, for example, requires eighteen vertices, not the eight that you would expect. If you note the order of vertices in the GL chart above you'll see that all of them use their vertices slightly differently (in particular you should make note of the GL_TRIANGLE_STRIP example). Drawing a shape requires that you keep track of which drawing mode is being used and which order your vertices are declared in.
If you're thinking: it would be nice if there were an abstraction layer for this you're thinking right. Enter the mesh, which is really just an abstraction of the vertex and drawing mode that we started with but which has the added bonus of managing the draw order for you. That may seem insignificant at first, but it provides some real benefits when working with complex geometry.
A very typical usage is something like the following:
Now it's important to make sure that each vertex is correctly connected with the other vertices around it. This is done using indices, which you can set up like so:
Member Typedef Documentation
◆ ColorType
using ofMesh_< V, N, C, T >::ColorType = C |
◆ NormalType
using ofMesh_< V, N, C, T >::NormalType = N |
◆ TexCoordType
using ofMesh_< V, N, C, T >::TexCoordType = T |
◆ VertexType
using ofMesh_< V, N, C, T >::VertexType = V |
Constructor & Destructor Documentation
◆ ofMesh_() [1/2]
This creates the mesh, using OF_PRIMITIVE_TRIANGLES without any initial vertices.
◆ ofMesh_() [2/2]
ofMesh_< V, N, C, T >::ofMesh_ | ( | ofPrimitiveMode | mode, |
const std::vector< V > & | verts | ||
) |
This allows to you to use one of the other ofPrimitiveModes: OF_PRIMITIVE_TRIANGLES, OF_PRIMITIVE_TRIANGLE_STRIP, OF_PRIMITIVE_TRIANGLE_FAN, OF_PRIMITIVE_LINES, OF_PRIMITIVE_LINE_STRIP, OF_PRIMITIVE_LINE_LOOP, OF_PRIMITIVE_POINTS. See ofGLUtils for more information on these types.
◆ ~ofMesh_()
|
inlinevirtual |
Member Function Documentation
◆ addColor()
void ofMesh_< V, N, C, T >::addColor | ( | const C & | c | ) |
This adds a color to the mesh, the color will be associated with the vertex in the same position.
◆ addColors() [1/2]
void ofMesh_< V, N, C, T >::addColors | ( | const C * | cols, |
std::size_t | amt | ||
) |
This adds a pointer of colors to the ofMesh instance with the amount passed as the second parameter.
◆ addColors() [2/2]
void ofMesh_< V, N, C, T >::addColors | ( | const std::vector< C > & | cols | ) |
This adds colors using a reference to a vector of ofColors. For each color in the vector, this will put the colors at the corresponding vertex.
◆ addIndex()
void ofMesh_< V, N, C, T >::addIndex | ( | ofIndexType | i | ) |
Add an index to the index vector. Each index represents the order of connection for vertices. This determines the way that the vertices are connected according to the polygon type set in the primitiveMode. It important to note that a particular vertex might be used for several faces and so would be referenced several times in the index vector.
Will give you this shape:
◆ addIndices() [1/2]
void ofMesh_< V, N, C, T >::addIndices | ( | const ofIndexType * | inds, |
std::size_t | amt | ||
) |
This adds indices to the ofMesh by pointing to an array of indices. The "amt" defines the length of the array.
◆ addIndices() [2/2]
void ofMesh_< V, N, C, T >::addIndices | ( | const std::vector< ofIndexType > & | inds | ) |
This adds a vector of indices.
◆ addNormal()
void ofMesh_< V, N, C, T >::addNormal | ( | const N & | n | ) |
Add a normal to the mesh as a 3D vector, typically perpendicular to the plane of the face. A normal is a vector that defines how a surface responds to lighting, i.e. how it is lit. The amount of light reflected by a surface is proportional to the angle between the light's direction and the normal. The smaller the angle the brighter the surface will look. See the normalsExample for advice on computing the normals. addNormal adds the 3D vector to the end of the list, so you need to make sure you add normals at the same index of the matching vertex.
◆ addNormals() [1/2]
void ofMesh_< V, N, C, T >::addNormals | ( | const N * | norms, |
std::size_t | amt | ||
) |
Add an array of normals to the mesh. Because you are using a pointer to the array you also have to define the length of the array as an std::size_t (amt). The normals are added at the end of the current normals list.
◆ addNormals() [2/2]
void ofMesh_< V, N, C, T >::addNormals | ( | const std::vector< N > & | norms | ) |
Add a vector of normals to a mesh, allowing you to push out many normals at once rather than adding one at a time. The vector of normals is added after the end of the current normals list.
◆ addTexCoord()
void ofMesh_< V, N, C, T >::addTexCoord | ( | const T & | t | ) |
Add a Vec2f representing the texture coordinate. Because OF uses ARB textures these are in pixels rather than 0-1 normalized coordinates.
◆ addTexCoords() [1/2]
void ofMesh_< V, N, C, T >::addTexCoords | ( | const std::vector< T > & | tCoords | ) |
Add a vector of texture coordinates to a mesh, allowing you to push out many at once rather than adding one at a time. The vector of texture coordinates is added after the end of the current texture coordinates list.
◆ addTexCoords() [2/2]
void ofMesh_< V, N, C, T >::addTexCoords | ( | const T * | tCoords, |
std::size_t | amt | ||
) |
Add an array of texture coordinates to the mesh. Because you are using a pointer to the array you also have to define the length of the array as an std::size_t (amt). The texture coordinates are added at the end of the current texture coordinates list.
◆ addTriangle()
void ofMesh_< V, N, C, T >::addTriangle | ( | ofIndexType | index1, |
ofIndexType | index2, | ||
ofIndexType | index3 | ||
) |
Adding a triangle means using three of the vertices that have already been added to create a triangle. This is an easy way to create triangles in the mesh. The indices refer to the index of the vertex in the vector of vertices.
◆ addVertex()
void ofMesh_< V, N, C, T >::addVertex | ( | const V & | v | ) |
Add a new vertex at the end of the current list of vertices. It is important to remember that the order the vertices are added to the list determines how they link they form the polygons and strips (assuming you do not change their indeces). See the ofMesh class description for details.
◆ addVertices() [1/2]
void ofMesh_< V, N, C, T >::addVertices | ( | const std::vector< V > & | verts | ) |
Add a vector of vertices to a mesh, allowing you to push out many at once rather than adding one at a time. The vector of vertices is added after the end of the current vertices list.
◆ addVertices() [2/2]
void ofMesh_< V, N, C, T >::addVertices | ( | const V * | verts, |
std::size_t | amt | ||
) |
Add an array of vertices to the mesh. Because you are using a pointer to the array you also have to define the length of the array as an int (amt). The vertices are added at the end of the current vertices list.
◆ append()
void ofMesh_< V, N, C, T >::append | ( | const ofMesh_< V, N, C, T > & | mesh | ) |
Add the vertices, normals, texture coordinates and indices of one mesh onto another mesh. Everything from the referenced mesh is simply added at the end of the current mesh's lists.
◆ axis()
|
static |
Returns an ofMesh representing an XYZ coordinate system.
- Returns
- an ofMesh representing an XYZ coordinate system.
◆ box()
|
static |
A helper method that returns a box made of triangles. The resolution settings for the width and height are optional (they are both set at a default of 2 triangles per side).
◆ clear()
void ofMesh_< V, N, C, T >::clear | ( | ) |
Removes all the vertices, colors, and indices from the mesh.
◆ clearColors()
void ofMesh_< V, N, C, T >::clearColors | ( | ) |
Clear all the colors.
◆ clearIndices()
void ofMesh_< V, N, C, T >::clearIndices | ( | ) |
Remove all the indices of the mesh. This means that your mesh will be a point cloud.
◆ clearNormals()
void ofMesh_< V, N, C, T >::clearNormals | ( | ) |
Remove all the normals.
◆ clearTexCoords()
void ofMesh_< V, N, C, T >::clearTexCoords | ( | ) |
Clear all the texture coordinates.
◆ clearVertices()
void ofMesh_< V, N, C, T >::clearVertices | ( | ) |
Removes all the vertices.
◆ cone()
|
static |
A helper method that returns a cone made of triangles. The resolution settings for the radius, height, and cap are optional (they are set at a default of 12 segments around the radius, 6 segments in the height, and 2 on the cap). The only valid modes are the default OF_PRIMITIVE_TRIANGLE_STRIP and OF_PRIMITIVE_TRIANGLES.
◆ cylinder()
|
static |
A helper method that returns a cylinder made of triangles. The resolution settings for the radius, height, and cap are optional (they are set at a default of 12 segments around the radius, 6 segments in the height, and 2 on the cap). You have the option to cap the cylinder or not. The only valid modes are the default OF_PRIMITIVE_TRIANGLE_STRIP and OF_PRIMITIVE_TRIANGLES.
◆ disableColors()
|
virtual |
Disable mesh colors. Use enableColors() to turn colors back on.
Reimplemented in ofVboMesh.
◆ disableIndices()
|
virtual |
Disable mesh indices. Use enableIndices() to turn indices back on.
Reimplemented in ofVboMesh.
◆ disableNormals()
|
virtual |
Disable mesh normals. Use enableNormals() to turn normals back on.
Reimplemented in ofVboMesh.
◆ disableTextures()
|
virtual |
Disable mesh textures. Use enableTextures() to turn textures back on.
Reimplemented in ofVboMesh.
◆ draw() [1/2]
void ofMesh_< V, N, C, T >::draw | ( | ) | const |
This draws the mesh using its primitive type, meaning that if you set them up to be triangles, this will draw the triangles.
◆ draw() [2/2]
|
virtual |
◆ drawFaces()
void ofMesh_< V, N, C, T >::drawFaces | ( | ) | const |
This draws the mesh as faces, meaning that you'll have a collection of faces.
◆ drawVertices()
void ofMesh_< V, N, C, T >::drawVertices | ( | ) | const |
This allows you draw just the vertices, meaning that you'll have a point cloud.
◆ drawWireframe()
void ofMesh_< V, N, C, T >::drawWireframe | ( | ) | const |
This draws the mesh as GL_LINES, meaning that you'll have a wireframe.
◆ enableColors()
|
virtual |
Enable mesh colors. Use disableColors() to turn colors off. Colors are enabled by default when they are added to the mesh.
Reimplemented in ofVboMesh.
◆ enableIndices()
|
virtual |
Enable mesh indices. Use disableIndices() to turn indices off. Indices are enabled by default when they are added to the mesh.
Reimplemented in ofVboMesh.
◆ enableNormals()
|
virtual |
Enable mesh normals. Use disableNormals() to turn normals off. Normals are enabled by default when they are added to the mesh.
Reimplemented in ofVboMesh.
◆ enableTextures()
|
virtual |
Enable mesh textures. Use disableTextures() to turn textures off. Textures are enabled by default when they are added to the mesh.
Reimplemented in ofVboMesh.
◆ flatNormals()
void ofMesh_< V, N, C, T >::flatNormals | ( | ) |
Duplicates vertices and updates normals to get a low-poly look.
◆ getCentroid()
V ofMesh_< V, N, C, T >::getCentroid | ( | ) | const |
- Returns
- a glm::vec3 defining the centroid of all the vetices in the mesh.
◆ getColor()
C ofMesh_< V, N, C, T >::getColor | ( | ofIndexType | i | ) | const |
Get the color at the index in the colors vector.
- Returns
- the color at the index in the colors vector.
◆ getColors() [1/2]
std::vector< C > & ofMesh_< V, N, C, T >::getColors | ( | ) |
Use this if you plan to change the colors as part of this call as it will force a reset of the cache.
- Returns
- the vector that contains all of the colors of the mesh, if it has any.
◆ getColors() [2/2]
const std::vector< C > & ofMesh_< V, N, C, T >::getColors | ( | ) | const |
- Returns
- the vector that contains all of the colors of the mesh, if it has any. (read only)
◆ getColorsPointer() [1/2]
C * ofMesh_< V, N, C, T >::getColorsPointer | ( | ) |
Use this if you plan to change the colors as part of this call as it will force a reset of the cache.
- Returns
- a pointer that contains all of the colors of the mesh, if it has any.
◆ getColorsPointer() [2/2]
const C * ofMesh_< V, N, C, T >::getColorsPointer | ( | ) | const |
- Returns
- a pointer that contains all of the colors of the mesh, if it has any. (read only)
◆ getFace()
ofMeshFace_< V, N, C, T > ofMesh_< V, N, C, T >::getFace | ( | ofIndexType | faceId | ) | const |
- Returns
- the vector that contains all of the faces of the mesh. This isn't currently implemented.
◆ getFaceNormals()
std::vector< N > ofMesh_< V, N, C, T >::getFaceNormals | ( | bool | perVetex = false | ) | const |
Get normals for each face As a default it only calculates the normal for the face as a whole but by setting (perVertex = true) it will return the same normal value for each of the three vertices making up a face.
- Returns
- a vector containing the calculated normals of each face in the mesh.
◆ getIndex()
ofIndexType ofMesh_< V, N, C, T >::getIndex | ( | ofIndexType | i | ) | const |
- Returns
- the index from the index vector. Each index represents the index of the vertex in the vertices vector. This determines the way that the vertices are connected into the polgoynon type set in the primitiveMode.
◆ getIndexPointer() [1/2]
ofIndexType * ofMesh_< V, N, C, T >::getIndexPointer | ( | ) |
- Returns
- a pointer to the indices that the mesh contains.
◆ getIndexPointer() [2/2]
const ofIndexType * ofMesh_< V, N, C, T >::getIndexPointer | ( | ) | const |
- Returns
- a pointer to the indices that the mesh contains.
◆ getIndices() [1/2]
std::vector< ofIndexType > & ofMesh_< V, N, C, T >::getIndices | ( | ) |
Use this if you plan to change the indices as part of this call as it will force a reset of the cache.
- Returns
- the vector that contains all of the indices of the mesh, if it has any.
◆ getIndices() [2/2]
const std::vector< ofIndexType > & ofMesh_< V, N, C, T >::getIndices | ( | ) | const |
- Returns
- the vector that contains all of the indices of the mesh, if it has any. (read only)
◆ getMeshForIndices() [1/2]
ofMesh_< V, N, C, T > ofMesh_< V, N, C, T >::getMeshForIndices | ( | ofIndexType | startIndex, |
ofIndexType | endIndex | ||
) | const |
The new mesh includes the mesh mode, colors, textures, and normals of the original mesh (assuming any were added).
- Returns
- a mesh made up of a range of indices from startIndex to the endIndex.
◆ getMeshForIndices() [2/2]
ofMesh_< V, N, C, T > ofMesh_< V, N, C, T >::getMeshForIndices | ( | ofIndexType | startIndex, |
ofIndexType | endIndex, | ||
ofIndexType | startVertIndex, | ||
ofIndexType | endVertIndex | ||
) | const |
◆ getMode()
ofPrimitiveMode ofMesh_< V, N, C, T >::getMode | ( | ) | const |
\returns the primitive mode that the mesh is using.
◆ getNormal()
N ofMesh_< V, N, C, T >::getNormal | ( | ofIndexType | i | ) | const |
\returns the normal at the index in the normals vector.
◆ getNormals() [1/2]
std::vector< N > & ofMesh_< V, N, C, T >::getNormals | ( | ) |
Use this if you plan to change the normals as part of this call as it will force a reset of the cache.
- Returns
- the vector that contains all of the normals of the mesh, if it has any.
◆ getNormals() [2/2]
const std::vector< N > & ofMesh_< V, N, C, T >::getNormals | ( | ) | const |
- Returns
- the vector that contains all of the normals of the mesh, if it has any. (read only)
◆ getNormalsPointer() [1/2]
N * ofMesh_< V, N, C, T >::getNormalsPointer | ( | ) |
- Returns
- a pointer to the normals that the mesh contains.
◆ getNormalsPointer() [2/2]
const N * ofMesh_< V, N, C, T >::getNormalsPointer | ( | ) | const |
- Returns
- a pointer to the normals that the mesh contains.
◆ getNumColors()
std::size_t ofMesh_< V, N, C, T >::getNumColors | ( | ) | const |
- Returns
- the size of the colors vector for the mesh. This will tell you how many colors are contained in the mesh.
◆ getNumIndices()
std::size_t ofMesh_< V, N, C, T >::getNumIndices | ( | ) | const |
This will tell you how many indices are contained in the mesh.
- Returns
- the size of the indices vector for the mesh.
◆ getNumNormals()
std::size_t ofMesh_< V, N, C, T >::getNumNormals | ( | ) | const |
This will tell you how many normals are contained in the mesh.
- Returns
- the size of the normals vector for the mesh.
◆ getNumTexCoords()
std::size_t ofMesh_< V, N, C, T >::getNumTexCoords | ( | ) | const |
This will tell you how many texture coordinates are contained in the mesh.
- Returns
- the size of the texture coordinates vector for the mesh.
◆ getNumVertices()
std::size_t ofMesh_< V, N, C, T >::getNumVertices | ( | ) | const |
- Returns
- the size of the vertices vector for the mesh. This will tell you how many vertices are contained in the mesh.
◆ getTexCoord()
T ofMesh_< V, N, C, T >::getTexCoord | ( | ofIndexType | i | ) | const |
- Returns
- the Vec2f representing the texture coordinate. Because OF uses ARB textures these are in pixels rather than 0-1 normalized coordinates.
◆ getTexCoords() [1/2]
std::vector< T > & ofMesh_< V, N, C, T >::getTexCoords | ( | ) |
Get a vector representing the texture coordinates of the mesh Because OF uses ARB textures these are in pixels rather than 0-1 normalized coordinates. Use this if you plan to change the texture coordinates as part of this call as it will force a reset of the cache.
- Returns
- a vector of Vec2f representing the texture coordinates for the whole mesh.
◆ getTexCoords() [2/2]
const std::vector< T > & ofMesh_< V, N, C, T >::getTexCoords | ( | ) | const |
Because OF uses ARB textures these are in pixels rather than 0-1 normalized coordinates.
- Returns
- a vector of Vec2f representing the texture coordinates for the whole mesh. (read only)
◆ getTexCoordsPointer() [1/2]
T * ofMesh_< V, N, C, T >::getTexCoordsPointer | ( | ) |
- Returns
- a pointer to the texture coords that the mesh contains.
◆ getTexCoordsPointer() [2/2]
const T * ofMesh_< V, N, C, T >::getTexCoordsPointer | ( | ) | const |
Get a pointer to the glm::vec2 texture coordinates that the mesh contains.
◆ getUniqueFaces()
const std::vector< ofMeshFace_< V, N, C, T > > & ofMesh_< V, N, C, T >::getUniqueFaces | ( | ) | const |
- Returns
- the mesh as a vector of unique ofMeshFace_s a list of triangles that do not share vertices or indices
◆ getVertex()
V ofMesh_< V, N, C, T >::getVertex | ( | ofIndexType | i | ) | const |
- Returns
- the vertex at the index.
◆ getVertices() [1/2]
std::vector< V > & ofMesh_< V, N, C, T >::getVertices | ( | ) |
- Returns
- the vector that contains all of the vertices of the mesh.
◆ getVertices() [2/2]
const std::vector< V > & ofMesh_< V, N, C, T >::getVertices | ( | ) | const |
- Returns
- the vector that contains all of the vertices of the mesh.
◆ getVerticesPointer() [1/2]
V * ofMesh_< V, N, C, T >::getVerticesPointer | ( | ) |
- Returns
- a pointer to the vertices that the mesh contains.
◆ getVerticesPointer() [2/2]
const V * ofMesh_< V, N, C, T >::getVerticesPointer | ( | ) | const |
- Returns
- a pointer to the vertices that the mesh contains.
◆ hasColors()
bool ofMesh_< V, N, C, T >::hasColors | ( | ) | const |
/returns Whether the mesh has any colors.
◆ hasIndices()
bool ofMesh_< V, N, C, T >::hasIndices | ( | ) | const |
/returns Whether the mesh has any indices assigned to it.
◆ hasNormals()
bool ofMesh_< V, N, C, T >::hasNormals | ( | ) | const |
/returnsWhether the mesh has any normals.
◆ hasTexCoords()
bool ofMesh_< V, N, C, T >::hasTexCoords | ( | ) | const |
/returns Whether the mesh has any textures assigned to it.
◆ hasVertices()
bool ofMesh_< V, N, C, T >::hasVertices | ( | ) | const |
- Returns
- Whether the mesh has any vertices.
◆ haveColorsChanged()
|
protected |
- Returns
- If the colors of the mesh have changed, been added or removed.
◆ haveIndicesChanged()
|
protected |
- Returns
- If the indices of the mesh have changed, been added or removed.
◆ haveNormalsChanged()
|
protected |
- Returns
- If the normals of the mesh have changed, been added or removed.
◆ haveTexCoordsChanged()
|
protected |
- Returns
- If the texture coords of the mesh have changed, been added or removed.
◆ haveVertsChanged()
|
protected |
- Returns
- If the vertices of the mesh have changed, been added or removed.
◆ icosahedron()
|
static |
◆ icosphere()
|
static |
Step 1 : Generate icosahedron
Step 2 : tessellate
Step 3 : generate texcoords
Step 4 : fix texcoords
◆ load()
void ofMesh_< V, N, C, T >::load | ( | const of::filesystem::path & | path | ) |
Loads a mesh from a file located at the provided path into the mesh. This will replace any existing data within the mesh.
It expects that the file will be in the PLY Format. It will only load meshes saved in the PLY ASCII format; the binary format is not supported.
flag to distinguish between uchar (more common) and float (less common) color format in ply file
◆ mergeDuplicateVertices()
void ofMesh_< V, N, C, T >::mergeDuplicateVertices | ( | ) |
◆ plane()
|
static |
◆ removeColor()
void ofMesh_< V, N, C, T >::removeColor | ( | ofIndexType | index | ) |
Remove a color at the index in the colors vector.
◆ removeColors()
void ofMesh_< V, N, C, T >::removeColors | ( | ofIndexType | startIndex, |
ofIndexType | endIndex | ||
) |
Remove colors at the index to the end index of the colors vector.
◆ removeIndex()
void ofMesh_< V, N, C, T >::removeIndex | ( | ofIndexType | index | ) |
Removes an index.
◆ removeIndices()
void ofMesh_< V, N, C, T >::removeIndices | ( | ofIndexType | startIndex, |
ofIndexType | endIndex | ||
) |
◆ removeNormal()
void ofMesh_< V, N, C, T >::removeNormal | ( | ofIndexType | index | ) |
Remove a normal.
◆ removeNormals()
void ofMesh_< V, N, C, T >::removeNormals | ( | ofIndexType | startIndex, |
ofIndexType | endIndex | ||
) |
Remove normal's from index to end index from normals vector.
◆ removeTexCoord()
void ofMesh_< V, N, C, T >::removeTexCoord | ( | ofIndexType | index | ) |
Remove a Vec2f representing the texture coordinate.
◆ removeTexCoords()
void ofMesh_< V, N, C, T >::removeTexCoords | ( | ofIndexType | startIndex, |
ofIndexType | endIndex | ||
) |
◆ removeVertex()
void ofMesh_< V, N, C, T >::removeVertex | ( | ofIndexType | index | ) |
Removes the vertex at the index in the vector.
◆ removeVertices()
void ofMesh_< V, N, C, T >::removeVertices | ( | ofIndexType | startIndex, |
ofIndexType | endIndex | ||
) |
Removes the vertices at the startIndex in the vector and the endindex specified.
◆ save()
void ofMesh_< V, N, C, T >::save | ( | const of::filesystem::path & | path, |
bool | useBinary = false |
||
) | const |
Saves the mesh at the passed path in the PLY Format.
There are two format options for PLY: a binary format and an ASCII format. By default, it will save using the ASCII format. Passing true
into the useBinary
parameter will save it in the binary format.
If you're planning on reloading the mesh into ofMesh, ofMesh currently only supports loading the ASCII format.
For more information, see the PLY format specification.
◆ setColor()
void ofMesh_< V, N, C, T >::setColor | ( | ofIndexType | index, |
const C & | c | ||
) |
Set the color at the index in the colors vector.
◆ setColorForIndices()
void ofMesh_< V, N, C, T >::setColorForIndices | ( | ofIndexType | startIndex, |
ofIndexType | endIndex, | ||
C | color | ||
) |
◆ setFromTriangles()
void ofMesh_< V, N, C, T >::setFromTriangles | ( | const std::vector< ofMeshFace_< V, N, C, T > > & | tris, |
bool | bUseFaceNormal = false |
||
) |
◆ setIndex()
void ofMesh_< V, N, C, T >::setIndex | ( | ofIndexType | index, |
ofIndexType | val | ||
) |
This sets the index at i.
◆ setMode()
void ofMesh_< V, N, C, T >::setMode | ( | ofPrimitiveMode | mode | ) |
Allows you to set the ofPrimitiveMode. The available modes are OF_PRIMITIVE_TRIANGLES, OF_PRIMITIVE_TRIANGLE_STRIP, OF_PRIMITIVE_TRIANGLE_FAN, OF_PRIMITIVE_LINES, OF_PRIMITIVE_LINE_STRIP, OF_PRIMITIVE_LINE_LOOP, OF_PRIMITIVE_POINTS.
◆ setNormal()
void ofMesh_< V, N, C, T >::setNormal | ( | ofIndexType | index, |
const N & | n | ||
) |
- Todo:
- Documentation.
◆ setTexCoord()
void ofMesh_< V, N, C, T >::setTexCoord | ( | ofIndexType | index, |
const T & | t | ||
) |
◆ setupIndicesAuto()
void ofMesh_< V, N, C, T >::setupIndicesAuto | ( | ) |
Allow you to set up the indices automatically when you add a vertex.
◆ setVertex()
void ofMesh_< V, N, C, T >::setVertex | ( | ofIndexType | index, |
const V & | v | ||
) |
◆ smoothNormals()
void ofMesh_< V, N, C, T >::smoothNormals | ( | float | angle | ) |
◆ sphere()
|
static |
◆ usingColors()
|
virtual |
Reimplemented in ofVboMesh.
◆ usingIndices()
|
virtual |
Reimplemented in ofVboMesh.
◆ usingNormals()
|
virtual |
Reimplemented in ofVboMesh.
◆ usingTextures()
|
virtual |
Reimplemented in ofVboMesh.
The documentation for this class was generated from the following files:
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/3d/ofMesh.h
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/3d/ofMesh.inl