Hi,
I’m building a 3d scene with multiple meshes of point clouds that I am aligning in view with rotation and x,y translation.
when I come to save the meshes to ply or obj i use mesh.append but this does not include any translation so the appended meshes are all centred around their own origin.
drawing works file like this using a vector of meshes, each having a mesh, z rotation and x,y translation.
void ofApp::draw() {
ofPushMatrix();
glPointSize(pointSize);
for(int i = 0; i < streetview.size(); i++){
ofRotateZ(streetview[i].getDirection()+rotOffset[i]);
ofTranslate(streetview[i].getLon()*longOffset[i], streetview[i].getLat()*latOffset[i], 0);
streetview[i].draw();
}
ofPopMatrix();
}
void ofApp::exportOBJ(ofMesh &mesh){
mesh.clear();
for(int i = 0; i < streetview.size(); i++){ //build new mesh to export
mesh.append(streetview[i].getDethMesh());
}
//obj.open(ofToDataPath(name),ofFile::WriteOnly);
obj << "#vertices\n";
for(int i = 0 ; i < mesh.getNumVertices(); i++) {
ofVec3f v = mesh.getVertex(i);
obj << "v " + ofToString(v.x) + " " + ofToString(v.y) + " " + ofToString(v.z) + "\n";
}
obj << "#faces\n";
for(int i = 0 ; i < mesh.getNumIndices(); i += 3)
obj << "f " + ofToString(mesh.getIndex(i)) + " " + ofToString(mesh.getIndex(i+1)) + " " + ofToString(mesh.getIndex(i+2)) + "\n";
obj << "\n";
obj.close();
cout << "wrote obj file" << endl;
}
but when i export I cant apply the transformations -
does anyone know
a) a way to do the equivalent of pushmatrix // popmatrix and translate between each mesh.append when saving the file
b) a way to save the matrix view to a single file ?