本文整理汇总了C++中ofMesh::getNumColors方法的典型用法代码示例。如果您正苦于以下问题:C++ ofMesh::getNumColors方法的具体用法?C++ ofMesh::getNumColors怎么用?C++ ofMesh::getNumColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofMesh
的用法示例。
在下文中一共展示了ofMesh::getNumColors方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
//----------------------------------------------------------
void ofGLRenderer::draw(ofMesh & vertexData, ofPolyRenderMode renderType, bool useColors, bool useTextures, bool useNormals){
if (bSmoothHinted) startSmoothing();
#ifndef TARGET_OPENGLES
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK, ofGetGLPolyMode(renderType));
draw(vertexData,useColors,useTextures,useNormals);
glPopAttrib(); //TODO: GLES doesnt support polygon mode, add renderType to gl renderer?
#else
if(vertexData.getNumVertices()){
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), vertexData.getVerticesPointer());
}
if(vertexData.getNumNormals() && useNormals){
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, vertexData.getNormalsPointer());
}
if(vertexData.getNumColors() && useColors){
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_FLOAT, sizeof(ofFloatColor), vertexData.getColorsPointer());
}
if(vertexData.getNumTexCoords() && useTextures){
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, vertexData.getTexCoordsPointer());
}
GLenum drawMode;
switch(renderType){
case OF_MESH_POINTS:
drawMode = GL_POINTS;
break;
case OF_MESH_WIREFRAME:
drawMode = GL_LINES;
break;
case OF_MESH_FILL:
drawMode = ofGetGLPrimitiveMode(vertexData.getMode());
break;
default:
drawMode = ofGetGLPrimitiveMode(vertexData.getMode());
break;
}
if(vertexData.getNumIndices()){
glDrawElements(drawMode, vertexData.getNumIndices(),GL_UNSIGNED_SHORT,vertexData.getIndexPointer());
}else{
glDrawArrays(drawMode, 0, vertexData.getNumVertices());
}
if(vertexData.getNumColors() && useColors){
glDisableClientState(GL_COLOR_ARRAY);
}
if(vertexData.getNumNormals() && useNormals){
glDisableClientState(GL_NORMAL_ARRAY);
}
if(vertexData.getNumTexCoords() && useTextures){
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
#endif
if (bSmoothHinted) endSmoothing();
}
示例2: setMesh
//--------------------------------------------------------------
void ofVboByteColor::setMesh(const ofMesh & mesh, int usage){
setVertexData(mesh.getVerticesPointer(),mesh.getNumVertices(),usage);
setColorData(mesh.getColorsPointer(),mesh.getNumColors(),usage);
setNormalData(mesh.getNormalsPointer(),mesh.getNumNormals(),usage);
setTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords(),usage);
setIndexData(mesh.getIndexPointer(), mesh.getNumIndices(), usage);
}
示例3: updateMesh
//--------------------------------------------------------------
void ofVboByteColor::updateMesh(const ofMesh & mesh){
ofMesh * nonconstMesh = (ofMesh*)&mesh;
if(nonconstMesh->haveVertsChanged()) updateVertexData(mesh.getVerticesPointer(),mesh.getNumVertices());
if(nonconstMesh->haveColorsChanged()) updateColorData(mesh.getColorsPointer(),mesh.getNumColors());
if(nonconstMesh->haveNormalsChanged()) updateNormalData(mesh.getNormalsPointer(),mesh.getNumNormals());
if(nonconstMesh->haveTexCoordsChanged()) updateTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords());
}
示例4: setMesh
//--------------------------------------------------------------
void ofVbo::setMesh(const ofMesh & mesh, int usage, bool useColors, bool useTextures, bool useNormals){
if(mesh.getVertices().empty()){
ofLogWarning("ofVbo") << "setMesh(): ignoring mesh with no vertices";
return;
}
setVertexData(mesh.getVerticesPointer(),mesh.getNumVertices(),usage);
if(mesh.hasColors() && useColors){
setColorData(mesh.getColorsPointer(),mesh.getNumColors(),usage);
enableColors();
}else{
disableColors();
}
if(mesh.hasNormals() && useNormals){
setNormalData(mesh.getNormalsPointer(),mesh.getNumNormals(),usage);
enableNormals();
}else{
disableNormals();
}
if(mesh.hasTexCoords() && useTextures){
setTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords(),usage);
enableTexCoords();
}else{
disableTexCoords();
}
if(mesh.hasIndices()){
setIndexData(mesh.getIndexPointer(), mesh.getNumIndices(), usage);
enableIndices();
}else{
disableIndices();
}
}
示例5: convertFromIndices
ofMesh convertFromIndices(const ofMesh& mesh) {
ofMesh result;
// have to do a const_cast because ofMesh::get*() is not const correct
ofMesh& cmesh = const_cast<ofMesh&>(mesh);
int vertices = mesh.getNumVertices();
int colors = mesh.getNumColors();
int normals = mesh.getNumNormals();
int texcoords = mesh.getNumTexCoords();
int indices = mesh.getNumIndices();
for(int i = 0; i < indices; i++) {
int cur = cmesh.getIndex(i);
if(vertices > 0) {
result.addVertex(cmesh.getVertex(cur));
}
if(colors > 0) {
result.addColor(cmesh.getColor(cur));
}
if(normals > 0) {
result.addNormal(cmesh.getNormal(cur));
}
if(texcoords > 0) {
result.addTexCoord(cmesh.getTexCoord(cur));
}
}
return result;
}
示例6: draw
//----------------------------------------------------------
void ofGLRenderer::draw(const ofMesh & vertexData, bool useColors, bool useTextures, bool useNormals) const{
if(vertexData.getNumVertices()){
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), &vertexData.getVerticesPointer()->x);
}
if(vertexData.getNumNormals() && useNormals){
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(ofVec3f), &vertexData.getNormalsPointer()->x);
}
if(vertexData.getNumColors() && useColors){
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_FLOAT, sizeof(ofFloatColor), &vertexData.getColorsPointer()->r);
}
if(vertexData.getNumTexCoords() && useTextures){
set<int>::iterator textureLocation = textureLocationsEnabled.begin();
for(;textureLocation!=textureLocationsEnabled.end();textureLocation++){
glActiveTexture(GL_TEXTURE0+*textureLocation);
glClientActiveTexture(GL_TEXTURE0+*textureLocation);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(ofVec2f), &vertexData.getTexCoordsPointer()->x);
}
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
}
if(vertexData.getNumIndices()){
#ifdef TARGET_OPENGLES
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(),GL_UNSIGNED_SHORT,vertexData.getIndexPointer());
#else
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(),GL_UNSIGNED_INT,vertexData.getIndexPointer());
#endif
}else{
glDrawArrays(ofGetGLPrimitiveMode(vertexData.getMode()), 0, vertexData.getNumVertices());
}
if(vertexData.getNumColors() && useColors){
glDisableClientState(GL_COLOR_ARRAY);
}
if(vertexData.getNumNormals() && useNormals){
glDisableClientState(GL_NORMAL_ARRAY);
}
if(vertexData.getNumTexCoords() && useTextures){
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
示例7: draw
//----------------------------------------------------------
void ofGLRenderer::draw(ofMesh & vertexData){
if(vertexData.getNumVertices()){
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), vertexData.getVerticesPointer());
}
if(vertexData.getNumNormals()){
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, vertexData.getNormalsPointer());
}
if(vertexData.getNumColors()){
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_FLOAT, sizeof(ofColor), vertexData.getColorsPointer());
}
if(vertexData.getNumTexCoords()){
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, vertexData.getTexCoordsPointer());
}
if(vertexData.getNumIndices()){
#ifdef TARGET_OPENGLES
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(),GL_UNSIGNED_SHORT,vertexData.getIndexPointer());
#else
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(),GL_UNSIGNED_INT,vertexData.getIndexPointer());
#endif
}else{
glDrawArrays(ofGetGLPrimitiveMode(vertexData.getMode()), 0, vertexData.getNumVertices());
}
if(vertexData.getNumColors()){
glDisableClientState(GL_COLOR_ARRAY);
}
if(vertexData.getNumNormals()){
glDisableClientState(GL_NORMAL_ARRAY);
}
if(vertexData.getNumTexCoords()){
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
示例8: convertToIndices
ofMesh convertToIndices(const ofMesh& mesh){
ofMesh result;
ofMesh& cmesh = const_cast<ofMesh&>(mesh);
int vertices = mesh.getNumVertices();
int colors = mesh.getNumColors();
int normals = mesh.getNumNormals();
int texcoords = mesh.getNumTexCoords();
//int indices = mesh.getNumIndices();
for (int i = 0; i < vertices; i++){
// check if this vertex already exists.
//int who = isPointInVector(
}
}
示例9: save
//--------------------------------------------------------------
void save(const string& path, const ofMesh& mesh)
{
ofFile file(path, ofFile::WriteOnly, true);
int numVerts = mesh.getNumVertices();
file.write((char *)(&numVerts), sizeof(int));
if (numVerts > 0) {
file.write((char *)(&(mesh.getVertices())[0]), sizeof(ofPoint) * numVerts);
}
int numNormals = mesh.getNumNormals();
file.write((char *)(&numNormals), sizeof(int));
if (numNormals > 0) {
file.write((char *)(&(mesh.getNormals())[0]), sizeof(ofPoint) * numNormals);
}
int numTexCoords = mesh.getNumTexCoords();
file.write((char *)(&numTexCoords), sizeof(int));
if (numTexCoords > 0) {
file.write((char *)(&(mesh.getTexCoords())[0]), sizeof(ofVec2f) * numTexCoords);
}
int numColors = mesh.getNumColors();
file.write((char *)(&numColors), sizeof(int));
if (numColors > 0) {
file.write((char *)(&(mesh.getColors())[0]), sizeof(ofFloatColor) * numColors);
}
int numIndices = mesh.getNumIndices();
file.write((char *)(&numIndices), sizeof(int));
if (numIndices > 0) {
file.write((char *)(&(mesh.getIndices())[0]), sizeof(ofIndexType) * numIndices);
}
file.close();
}
示例10: setMesh
//--------------------------------------------------------------
void ofVbo::setMesh(const ofMesh & mesh, int usage){
setVertexData(mesh.getVerticesPointer(),mesh.getNumVertices(),usage,sizeof(ofVec3f));
setColorData(mesh.getColorsPointer(),mesh.getNumColors(),usage,sizeof(ofColor));
setNormalData(mesh.getNormalsPointer(),mesh.getNumNormals(),usage,sizeof(ofVec3f));
setTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords(),usage,sizeof(ofVec2f));
}