- english
- /
- japanese
methods
- addIndex()
- addTriangle()
- clear()
- clearColors()
- clearIndices()
- clearNormals()
- clearTexCoords()
- clearVertices()
- disableColors()
- disableIndices()
- disableNormals()
- disableTextures()
- draw()
- drawFaces()
- drawVertices()
- drawWireframe()
- enableColors()
- enableIndices()
- enableNormals()
- enableTextures()
- getCentroid()
- getColor()
- getColors()
- getColorsPointer()
- getFace()
- getIndex()
- getIndexPointer()
- getIndices()
- getMode()
- getNormal()
- getNormals()
- getNormalsPointer()
- getNumColors()
- getNumIndices()
- getNumNormals()
- getNumTexCoords()
- getNumVertices()
- getTexCoord()
- getTexCoords()
- getTexCoordsPointer()
- getVertex()
- getVertices()
- getVerticesPointer()
- hasColors()
- hasIndices()
- hasNormals()
- hasTexCoords()
- hasVertices()
- haveColorsChanged()
- haveIndicesChanged()
- haveNormalsChanged()
- haveTexCoordsChanged()
- haveVertsChanged()
- load()
- removeColor()
- removeIndex()
- removeNormal()
- removeTexCoord()
- removeVertex()
- save()
- setIndex()
- setMode()
- setName()
- setupIndicesAuto()
- usingColors()
- usingIndices()
- usingNormals()
- usingTextures()
An ofMesh represents a set of vertices in 3D spaces, and normals at those points, colors at those points, 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.
addIndex(...)
void ofMesh::addIndex(ofIndexType i)
Add an 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.
addTriangle(...)
void ofMesh::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.
clearIndices()
void ofMesh::clearIndices()
Remove all the indices of the mesh. This means that your mesh will be a point cloud.
draw()
void ofMesh::draw()
This draws the mesh using its primitive type, meaning that if you set them up to be triangles, this will draw the triangles.
drawFaces()
void ofMesh::drawFaces()
This draws the mesh as faces, meaning that you'll have a collection of faces.
drawVertices()
void ofMesh::drawVertices()
This allows you draw just the vertices, meaning that you'll have a point cloud.
drawWireframe()
void ofMesh::drawWireframe()
This draws the mesh as GL_LINES, meaning that you'll have a wireframe.
getColors()
ofFloatColor ofMesh::getColors()
Get the vector that contains all of the colors of the mesh, if it has any.
getColorsPointer()
ofFloatColor ofMesh::getColorsPointer()
Get a pointer to the colors that the mesh contains. Get a pointer to the colors that the mesh contains.
getFace(...)
vector< int > & ofMesh::getFace(int faceId)
Get the vector that contains all of the faces of the mesh. This isn't currently implemented.
getIndex(...)
ofIndexType ofMesh::getIndex(int i)
Get 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()
ofIndexType ofMesh::getIndexPointer()
Get a pointer to the indices that the mesh contains. Get a pointer to the indices that the mesh contains.
getIndices()
ofIndexType ofMesh::getIndices()
Get the vector that contains all of the indices of the mesh, if it has any.
getNormals()
ofVec3f ofMesh::getNormals()
Get the vector that contains all of the normals of the mesh, if it has any.
getNormalsPointer()
ofVec3f ofMesh::getNormalsPointer()
Get a pointer to the normals that the mesh contains. Get a pointer to the normals that the mesh contains.
getNumTexCoords()
int ofMesh::getNumTexCoords()
How many texture coordinates that the mesh contains.
getTexCoord(...)
ofVec2f ofMesh::getTexCoord(int i)
Get the Vec2f representing the texture coordinate. Because OF uses ARB textures these are in pixels rather than 0-1 normalized coordinates.
getTexCoords()
ofVec2f ofMesh::getTexCoords()
Get the vector that contains all of the vertices of the tex coords, if it has any.
getTexCoordsPointer()
ofVec2f ofMesh::getTexCoordsPointer()
Get a pointer to the texture coords that the mesh contains. Get a pointer to the ofVec2f texture coordinates that the mesh contains.
getVertices()
ofVec3f ofMesh::getVertices()
Get the vector that contains all of the vertices of the mesh.
getVerticesPointer()
ofVec3f ofMesh::getVerticesPointer()
Get a pointer to the vertices that the mesh contains. Get a pointer to the vertices that the mesh contains.
haveColorsChanged()
bool ofMesh::haveColorsChanged()
If the colors of the mesh have changed, been added or removed.
haveIndicesChanged()
bool ofMesh::haveIndicesChanged()
If the indices of the mesh have changed, been added or removed.
haveNormalsChanged()
bool ofMesh::haveNormalsChanged()
If the normals of the mesh have changed, been added or removed.
haveTexCoordsChanged()
bool ofMesh::haveTexCoordsChanged()
If the texture coords of the mesh have changed, been added or removed.
haveVertsChanged()
bool ofMesh::haveVertsChanged()
If the vertices of the mesh have changed, been added or removed.
removeColor(...)
void ofMesh::removeColor(int index)
Remove a color at the index in the colors vector.
removeTexCoord(...)
void ofMesh::removeTexCoord(int index)
Remove a Vec2f representing the texture coordinate.
removeVertex(...)
void ofMesh::removeVertex(int index)
Removes the vertex at the index in the vector.
setMode(...)
void ofMesh::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
setupIndicesAuto()
void ofMesh::setupIndicesAuto()
Allow you to set up the indices automatically when you add a vertex.
Last updated
Thursday, 16 May 2013 14:01:08 UTC
-
cbf0910627a25e6153f2452833c5313fe6067059

