reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofVboMesh Class Reference

#include <ofVboMesh.h>

Inheritance diagram for ofVboMesh:
ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >

Public Member Functions

 ofVboMesh ()
 
 ofVboMesh (const ofMesh &mom)
 
void operator= (const ofMesh &mom)
 
virtual ~ofVboMesh ()
 
void setUsage (int usage)
 
void enableColors ()
 Enable mesh colors. Use disableColors() to turn colors off. Colors are enabled by default when they are added to the mesh.
 
void enableTextures ()
 Enable mesh textures. Use disableTextures() to turn textures off. Textures are enabled by default when they are added to the mesh.
 
void enableNormals ()
 Enable mesh normals. Use disableNormals() to turn normals off. Normals are enabled by default when they are added to the mesh.
 
void enableIndices ()
 Enable mesh indices. Use disableIndices() to turn indices off. Indices are enabled by default when they are added to the mesh.
 
void disableColors ()
 Disable mesh colors. Use enableColors() to turn colors back on.
 
void disableTextures ()
 Disable mesh textures. Use enableTextures() to turn textures back on.
 
void disableNormals ()
 Disable mesh normals. Use enableNormals() to turn normals back on.
 
void disableIndices ()
 Disable mesh indices. Use enableIndices() to turn indices back on.
 
virtual bool usingColors () const
 
virtual bool usingTextures () const
 
virtual bool usingNormals () const
 
virtual bool usingIndices () const
 
void draw (ofPolyRenderMode drawMode) const
 This draws the mesh using a defined renderType, overriding the renderType defined with setMode().
 
void drawInstanced (ofPolyRenderMode drawMode, int primCount) const
 
ofVbogetVbo ()
 
const ofVbogetVbo () const
 
- Public Member Functions inherited from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >
 ofMesh_ ()
 This creates the mesh, using OF_PRIMITIVE_TRIANGLES without any initial vertices.
 
 ofMesh_ (ofPrimitiveMode mode, const std::vector< ofDefaultVertexType > &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_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType > > &tris, bool bUseFaceNormal=false)
 
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.
 
void addVertex (const ofDefaultVertexType &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< ofDefaultVertexType > &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 ofDefaultVertexType *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 ofDefaultVertexType &v)
 
void clearVertices ()
 Removes all the vertices.
 
void clear ()
 Removes all the vertices, colors, and indices from the mesh.
 
std::size_t getNumVertices () const
 
ofDefaultVertexTypegetVerticesPointer ()
 
const ofDefaultVertexTypegetVerticesPointer () const
 
ofDefaultVertexType getVertex (ofIndexType i) const
 
std::vector< ofDefaultVertexType > & getVertices ()
 
const std::vector< ofDefaultVertexType > & 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 ()
 
ofDefaultVertexType getCentroid () const
 
ofDefaultNormalType getNormal (ofIndexType i) const
 \returns the normal at the index in the normals vector.
 
void addNormal (const ofDefaultNormalType &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< ofDefaultNormalType > &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 ofDefaultNormalType *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 ofDefaultNormalType &n)
 
void clearNormals ()
 Remove all the normals.
 
std::size_t getNumNormals () const
 This will tell you how many normals are contained in the mesh.
 
ofDefaultNormalTypegetNormalsPointer ()
 
const ofDefaultNormalTypegetNormalsPointer () const
 
std::vector< ofDefaultNormalType > & getNormals ()
 
const std::vector< ofDefaultNormalType > & getNormals () const
 
bool hasNormals () const
 /returnsWhether the mesh has any normals.
 
void smoothNormals (float angle)
 
void flatNormals ()
 Duplicates vertices and updates normals to get a low-poly look.
 
ofMeshFace_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordTypegetFace (ofIndexType faceId) const
 
std::vector< ofDefaultNormalTypegetFaceNormals (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_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType > > & getUniqueFaces () const
 
ofDefaultColorType getColor (ofIndexType i) const
 Get the color at the index in the colors vector.
 
void addColor (const ofDefaultColorType &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< ofDefaultColorType > &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 ofDefaultColorType *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 ofDefaultColorType &c)
 Set the color at the index in the colors vector.
 
void clearColors ()
 Clear all the colors.
 
std::size_t getNumColors () const
 
ofDefaultColorTypegetColorsPointer ()
 
const ofDefaultColorTypegetColorsPointer () const
 
std::vector< ofDefaultColorType > & getColors ()
 
const std::vector< ofDefaultColorType > & getColors () const
 
bool hasColors () const
 /returns Whether the mesh has any colors.
 
ofDefaultTexCoordType getTexCoord (ofIndexType i) const
 
void addTexCoord (const ofDefaultTexCoordType &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< ofDefaultTexCoordType > &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 ofDefaultTexCoordType *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 ofDefaultTexCoordType &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.
 
ofDefaultTexCoordTypegetTexCoordsPointer ()
 
const ofDefaultTexCoordTypegetTexCoordsPointer () const
 Get a pointer to the glm::vec2 texture coordinates that the mesh contains.
 
std::vector< ofDefaultTexCoordType > & 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< ofDefaultTexCoordType > & getTexCoords () const
 
bool hasTexCoords () const
 /returns Whether the mesh has any textures assigned to it.
 
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.
 
const std::vector< ofIndexType > & getIndices () const
 
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.
 
ofIndexTypegetIndexPointer ()
 
const ofIndexTypegetIndexPointer () 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.
 
void setColorForIndices (ofIndexType startIndex, ofIndexType endIndex, ofDefaultColorType color)
 
ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordTypegetMeshForIndices (ofIndexType startIndex, ofIndexType endIndex) const
 
ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordTypegetMeshForIndices (ofIndexType startIndex, ofIndexType endIndex, ofIndexType startVertIndex, ofIndexType endVertIndex) const
 
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.
 
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.
 

Additional Inherited Members

- Public Types inherited from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >
using VertexType = ofDefaultVertexType
 
using NormalType = ofDefaultNormalType
 
using ColorType = ofDefaultColorType
 
using TexCoordType = ofDefaultTexCoordType
 
- Static Public Member Functions inherited from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >
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 inherited from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >
bool haveVertsChanged ()
 
bool haveNormalsChanged ()
 
bool haveColorsChanged ()
 
bool haveTexCoordsChanged ()
 
bool haveIndicesChanged ()
 

Constructor & Destructor Documentation

◆ ofVboMesh() [1/2]

ofVboMesh::ofVboMesh ( )

◆ ofVboMesh() [2/2]

ofVboMesh::ofVboMesh ( const ofMesh mom)

◆ ~ofVboMesh()

ofVboMesh::~ofVboMesh ( )
virtual

Member Function Documentation

◆ disableColors()

void ofVboMesh::disableColors ( )
virtual

Disable mesh colors. Use enableColors() to turn colors back on.

Reimplemented from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ disableIndices()

void ofVboMesh::disableIndices ( )
virtual

Disable mesh indices. Use enableIndices() to turn indices back on.

Reimplemented from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ disableNormals()

void ofVboMesh::disableNormals ( )
virtual

Disable mesh normals. Use enableNormals() to turn normals back on.

Reimplemented from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ disableTextures()

void ofVboMesh::disableTextures ( )
virtual

Disable mesh textures. Use enableTextures() to turn textures back on.

Reimplemented from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ draw()

void ofVboMesh::draw ( ofPolyRenderMode  renderType) const
virtual

This draws the mesh using a defined renderType, overriding the renderType defined with setMode().

Reimplemented from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ drawInstanced()

void ofVboMesh::drawInstanced ( ofPolyRenderMode  drawMode,
int  primCount 
) const

◆ enableColors()

void ofVboMesh::enableColors ( )
virtual

Enable mesh colors. Use disableColors() to turn colors off. Colors are enabled by default when they are added to the mesh.

Reimplemented from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ enableIndices()

void 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 from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ enableNormals()

void 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 from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ enableTextures()

void 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 from ofMesh_< ofDefaultVertexType, ofDefaultNormalType, ofDefaultColorType, ofDefaultTexCoordType >.

◆ getVbo() [1/2]

ofVbo & ofVboMesh::getVbo ( )

◆ getVbo() [2/2]

const ofVbo & ofVboMesh::getVbo ( ) const

◆ operator=()

void ofVboMesh::operator= ( const ofMesh mom)

◆ setUsage()

void ofVboMesh::setUsage ( int  usage)

◆ usingColors()

bool ofVboMesh::usingColors ( ) const
virtual

◆ usingIndices()

bool ofVboMesh::usingIndices ( ) const
virtual

◆ usingNormals()

bool ofVboMesh::usingNormals ( ) const
virtual

◆ usingTextures()

bool ofVboMesh::usingTextures ( ) const
virtual

The documentation for this class was generated from the following files:
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/gl/ofVboMesh.h
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/gl/ofVboMesh.cpp