fileOpenSaveDialogExample, but for a 3D ?

A bug a day, keep the doctor away !

The question is in the title, i’m trying to use ofxAssimpModelLoader, but i want it with some dialog box (open and save).
Does anyone know how to do that? Really, i try in every ways, but… no :(, even with a video like this:

i was trying with tree movies in some OfFbo, is that the same for a 3D?:

  
  
  
ofEasyCam cam, cam2, cam3;  
  
//--------------------------------------------------------------  
void testApp::setup(){  
      
    ofSetLogLevel(OF_LOG_VERBOSE);  
  
    ofBackground(0);  
	ofSetFrameRate(40);  
      
    bFullscreen	= 0;  
  
    //fbo  
	fbo1.allocate(ofGetWidth(), ofGetHeight(), GL_RGB);  
    fbo2.allocate(ofGetWidth(), ofGetHeight(), GL_RGB);  
    Mainfbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGB);  
      
      
    //first triangle in the mesh //OK  
    mesh1.addTexCoord(ofVec2f(0,0));//T1  
    mesh1.addVertex(ofVec3f(0,0,0));//v1  
      
    mesh1.addTexCoord(ofVec2f(fbo1.getWidth()/2, 0));//T2  
    mesh1.addVertex(ofVec3f(ofGetWidth()/2.0, 0, 0));//v2  
      
    mesh1.addTexCoord(ofVec2f(0, fbo1.getHeight()));//T3  
    mesh1.addVertex(ofVec3f(0, ofGetHeight(), 0));//v3  
      
      
      
    //Second triangle in the mesh //OK  
    mesh2.addTexCoord(ofVec2f(fbo2.getWidth(),0));//T1  
    mesh2.addVertex(ofVec3f(ofGetWidth(),0,0));//v1  
      
    mesh2.addTexCoord(ofVec2f(fbo2.getWidth()/2, 0));//T2  
    mesh2.addVertex(ofVec3f(ofGetWidth()/2.0, 0, 0));//v2  
      
    mesh2.addTexCoord(ofVec2f(fbo2.getWidth(), fbo2.getHeight()));//T3  
    mesh2.addVertex(ofVec3f(ofGetWidth(), ofGetHeight(), 0));//v3*/  
      
      
      
    //Main triangle in the mesh // OK  
    MainMesh.addTexCoord(ofVec2f(0,Mainfbo.getHeight()));//T1  
    MainMesh.addVertex(ofVec3f(0,ofGetHeight(),0));//v1  
      
    MainMesh.addTexCoord(ofVec2f(Mainfbo.getWidth(), Mainfbo.getHeight()));//T2  
    MainMesh.addVertex(ofVec3f(ofGetWidth(), ofGetHeight(), 0));//v2  
      
    MainMesh.addTexCoord(ofVec2f(Mainfbo.getWidth()/2, 0));//T3  
    MainMesh.addVertex(ofVec3f(ofGetWidth()/2, 0, 0));//v3  
      
      
    Mpause = false;  
      
    saveFile = false;  
    fileM = true;  
    file1 = true;  
    file2 = true;  
  
    //////////MAIN FILM:  
    if (fileM == true) {  
    }  
    //Open the Open File Dialog  
    ofFileDialogResult mainMovie= ofSystemLoadDialog("Select a avi or other");  
      
    //Check if the user opened a file  
    if (mainMovie.bSuccess){  
          
        ofLogVerbose("User selected a file");  
          
        //We have a file, check it and process it  
        processOpenFileSelection(mainMovie);  
    }else {  
        ofLogVerbose("User hit cancel");  
    }  
      
      
    //////////FILM 1 :  
    if (file1 == true) {  
    }  
    //Open the Open File Dialog  
    ofFileDialogResult Movie1= ofSystemLoadDialog("Select a avi or other");  
      
    //Check if the user opened a file  
    if (Movie1.bSuccess){  
          
        ofLogVerbose("User selected a file");  
          
        //We have a file, check it and process it  
        processOpenFileSelection1(Movie1);  
    }else {  
        ofLogVerbose("User hit cancel");  
    }  
      
      
    ////////// FILM 2:  
    if (file2 == true) {  
    }  
    //Open the Open File Dialog  
    ofFileDialogResult Movie2= ofSystemLoadDialog("Select a avi or other");  
      
    //Check if the user opened a file  
    if (Movie2.bSuccess){  
          
        ofLogVerbose("User selected a file");  
          
        //We have a file, check it and process it  
        processOpenFileSelection2(Movie2);  
    }else {  
        ofLogVerbose("User hit cancel");  
    }  
      
      
      
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
      
	//Dessin des fbo  
      
    fbo1.begin();  
    drawFbo1();  
    fbo1.end();  
      
    fbo2.begin();  
    drawFbo2();  
    fbo2.end();  
      
      
    Mainfbo.begin();  
    drawMainFbo();  
    Mainfbo.end();  
      
    if(bFullscreen){  
		ofHideCursor();  
	}else{  
		ofShowCursor();  
	}  
      
  
      
  
      
//////////Savegarde :  
    if (saveFile == true) {  
          
		//  
		ofFileDialogResult saveFileResult = ofSystemSaveDialog(ofGetTimestampString() + "." + ofToLower(originalFileExtension), "Save your file");  
		if (saveFileResult.bSuccess){  
			processedImages[0].saveImage(saveFileResult.filePath);  
		}  
  
          
    }  
}  
  
//--------------------------Charger le filmM en mémoire-----------------------------  
  
  
void testApp::processOpenFileSelection(ofFileDialogResult mainMovie){  
	  
    fileM = false;  
      
	ofLogVerbose("getName(): "  + mainMovie.getName());  
	ofLogVerbose("getPath(): "  + mainMovie.getPath());  
	  
	ofFile mainMov (mainMovie.getPath());  
    //nom du film: mainMov'  
  
}  
  
//--------------------------Charger le film1 en mémoire-----------------------------  
  
  
void testApp::processOpenFileSelection1(ofFileDialogResult Movie1){  
	  
    file1 = false;  
      
	ofLogVerbose("getName(): "  + Movie1.getName());  
	ofLogVerbose("getPath(): "  + Movie1.getPath());  
	  
	ofFile Mov1 (Movie1.getPath());  
    //nom du film: Mov1'  
      
}  
  
//--------------------------Charger le film2 en mémoire-----------------------------  
  
  
void testApp::processOpenFileSelection2(ofFileDialogResult Movie2){  
	  
    file2 = false;  
      
	ofLogVerbose("getName(): "  + Movie2.getName());  
	ofLogVerbose("getPath(): "  + Movie2.getPath());  
	  
	ofFile Mov2 (Movie2.getPath());  
    //nom du film: Mov2'  
      
}  
  
      
//-------------------------- FBO 1 -----------------------------  
void testApp::drawFbo1(){  
      
    //écran clair  
	ofClear(0,0,0, 0);  
      
    ofPushMatrix();  
  
    Movie1.loadMovie("Mov1");  
	Movie1.play();  
    Movie1.setPaused(Mpause);  
      
    // Changer leur taille !  
      
    ofPopMatrix();  
      
      
}  
//-------------------------- FBO 2 -----------------------------  
  
void testApp::drawFbo2(){  
      
    //écran clair  
    ofClear(0,0,0, 0);  
      
    ofPushMatrix();  
  
    Movie2.loadMovie("Mov2");  
	Movie2.play();  
    Movie2.setPaused(Mpause);  
  
  
    ofPopMatrix();  
      
      
}  
//------------------------- MAIN FBO ---------------------------  
  
void testApp::drawMainFbo(){  
      
    //écran clair  
    ofClear(0,0,0, 0);  
      
    ofPushMatrix();  
  
    mainMovie.loadMovie("mainMov");  
	mainMovie.play();  
    mainMovie.setPaused(Mpause);  
      
      
    ofPopMatrix();  
   }  
  
  
//--------------------------------------------------------------  
void testApp::draw(){  
      
    // OK  
    ofClear(30);  
      
      
    fbo1.getTextureReference().bind();  
    mesh1.draw();  
    fbo1.getTextureReference().unbind();  
      
      
    fbo2.getTextureReference().bind();  
    mesh2.draw();  
    fbo2.getTextureReference().unbind();  
      
      
    Mainfbo.getTextureReference().bind();  
    MainMesh.draw();  
    Mainfbo.getTextureReference().unbind();  
    //  
      
    ofSetColor(255, 100, 0);  
    ofCircle(ofGetMouseX(), ofGetMouseY(), 10);  
      
   if(file2 == true){  
          
		bFullscreen = !bFullscreen;  
		  
		if(!bFullscreen){  
			ofSetWindowShape(300,300);  
			ofSetFullscreen(false);  
			// figure out how to put the window in the center:  
			int screenW = ofGetScreenWidth();  
			int screenH = ofGetScreenHeight();  
			//ofSetWindowPosition(screenW/2-300/2, screenH/2-300/2);  
		} else if(bFullscreen == 1){  
			ofSetFullscreen(true);  
		}  
	}  
  
      
      
}  
  
//--------------------------------------------------------------  
void testApp::keyPressed(int key){  
      
    if (key == ' ')  
        Mpause == true;  
}  
  
//--------------------------------------------------------------  
void testApp::keyReleased(int key){  
      
}  
  
//--------------------------------------------------------------  
void testApp::mouseMoved(int x, int y ){  
      
      
}  
  
//--------------------------------------------------------------  
void testApp::mouseDragged(int x, int y, int button){  
      
    ofVec3f mousePoint(x,y,0);  
    points.push_back(mousePoint);  
      
      
}  
  
//--------------------------------------------------------------  
void testApp::mousePressed(int x, int y, int button){  
      
}  
  
//--------------------------------------------------------------  
void testApp::mouseReleased(int x, int y, int button){  
      
}  
  
//--------------------------------------------------------------  
void testApp::windowResized(int w, int h){  
      
}  
  
//--------------------------------------------------------------  
void testApp::gotMessage(ofMessage msg){  
      
}  
  
//--------------------------------------------------------------  
void testApp::dragEvent(ofDragInfo dragInfo){   
      
}  

this might be of interest to you…
https://github.com/openframeworks/openFrameworks/issues/2599

Are you on a PC? if so, there is a known bug indeed - when you try to save and then load again, the dialog brakes the path of OF print it to see for your self.

I see a couple more mistakes in your code, but I think the major problem is probably the above issue.

:slight_smile:

i’m trying…

if you want to tell me where are the mistakes, you’re welcome :wink:

i see it rigth now !

well first mistake is that you spelled memory wrong : mémoire :stuck_out_tongue:

I kid lad, your code seems to be ok. except from the spot were you have

saveFileResult.filePath

have you printed that? Meke sure it is a legit path / does it have a path /a file name /and an extension?

if so and you are on a PC it’s probably the other thing

declare

an extern string GLOBAL_PATH;

make it global, you are probably going to need this in other classes as well…

if you don’t like extern just declare it in your testApp.h

first thing in your setup put:

  
  
cout<<getCurrentWorkingDirectory() <<endl; //before loading files!!  
//and then:  
DEFAULT_DIRECTORY = ofToDataPath("",true);  
  

that will be your default directory.

then after the setup

in your update // or in ofMouseReleased etc put:

cout<<getCurrentWorkingDirectory() <<endl;

play a bit with your program
and compare the results
to the first that we printed…

if it’s different then

put at the end of your setup and maybe after each system dialogue in your loop

ofSetDataPathRoot(DEFAULT_DIRECTORY);