//--------------------------------------------------------------
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();
	}
}
Exemple #2
0
void ofxMesh::fromMesh(const ofMesh & mesh){
    if (mesh.hasVertices()) {
        getVertices()=mesh.getVertices();
    }
    if (mesh.hasColors()) {
        getColors()=mesh.getColors();
    }
    if (mesh.hasNormals()) {
        getNormals()=mesh.getNormals();
    }
    if (mesh.hasTexCoords()) {
        getTexCoords()=mesh.getTexCoords();
    }
    if (mesh.hasIndices()) {
        getIndices()=mesh.getIndices();
    }
}
void ofxAlembic::transform(ofMesh &mesh, const ofMatrix4x4 &m)
{
	vector<ofVec3f>& vertices = mesh.getVertices();

	for (int i = 0; i < vertices.size(); i++)
	{
		vertices[i] = vertices[i] * m;
	}

	if (mesh.hasNormals())
	{
		vector<ofVec3f>& normals = mesh.getNormals();

		for (int i = 0; i < normals.size(); i++)
		{
			const ofVec3f& v = normals[i];
			normals[i] = ofVec4f(v.x, v.y, v.z, 0) * m;
		}
	}
}
//--------------------------------------------------------------
void ofVbo::setMesh(const ofMesh & mesh, int usage){
	setMesh(mesh,usage,mesh.hasColors(),mesh.hasTexCoords(),mesh.hasNormals());
}