ofGUI doesn't show with ofxScene

Hi,
as says my title,
I’m trying to merge some addons to create my own project.

But ofGUI draws only the borders if I run the “setup” section of ofxScene.
(You can see the exact code in the example of ofxScene so I wont post it here)

And if I also run the “draw” section of ofxScene,
then the GUI simply doesn’t show anything… :confused:

I’ve looked at the setup section but there’s nothing I see that’s causing not to show the GUI,
maybe you guys understand better what can cause the GUI to dissapear / only show the outline?

(I’ve tried to disable depth test end enable alphablending but it didn’t do a thing :S)

Thanks, Ludovic.

this is probably because ofxScene is enabling depth testing, try disabling it before drawing the gui, using ofDisableDepthText() don’t forget to enable it later before drawing anything 3d using ofEnableDepthTest()

1 Like

Well I did try it and it doesn’t change a thing…
I’d usually understand but the “setup” function of ofxScene doesn’t contain any low level of[Enable/Disable]Something function that’d make me understant WHAT is not fitting with ofGUI. :frowning:

I’ll post the function here (its big, sorry) :

 void testApp::setup(){
    ofSetVerticalSync(true);
    globeImage.loadImage("earth_bw.png");
    oleImage.loadImage("ole.jpg");
    
//dynamicallly create a material. it'll be deleted when the destructor for it's mesh is called
    ofxScene::NormalMaterial* normalMat = new ofxScene::NormalMaterial();

//lights
    pointLights.resize(5);
    lightMeshes.resize(pointLights.size());
    for(int i=0; i<pointLights.size(); i++){
        //set pointLights color and attenuation
        pointLights[i].setColor( ofRandom(1.5), ofRandom(1.5), ofRandom(1.5) );
        pointLights[i].setAttenuation(1,.0001, .0001);//constaint, linear, quadratic
        scene.add( pointLights[i] );
        
        //create some meshes for drawing the point lights
        lightMeshes[i].init(sphereGeometry,
                            new ofxScene::FacingRatioMaterial(ofVec3f(1),                 // color1
                                                              pointLights[i].getColor(),  // color2
                                                              1,                          // alpha
                                                              4 ) );                      // exponent
        lightMeshes[i].scale.set( .1 );
        scene.add( lightMeshes[i] );
    }
    
    spotLight.setCutoff(.9);
    spotLight.setPosition(ofVec3f(0,300,0));
    spotLight.setColor( 1.1,1.1,1.2 );
    scene.add( spotLight );
    
    spotLightMesh.init(new ofxScene::ConeGeometry(12,30), new ofxScene::FlatMaterial() );
    spotLightMesh.position = spotLight.getPosition();
    spotLightMesh.wireframe = true;
    spotLightMesh.doubleSided = true;
    spotLightMesh.shader->setUniform( "Diffuse", spotLight.getColor() );
    scene.add( spotLightMesh );
    
//cube mesh
    cube.init(new ofxScene::CubeGeometry(60,60,60),
              new ofxScene::LambertMaterial(ofVec3f(1),                         //diffuse
                                            ofVec3f(.25,.25,0),                 //ambient
                                            1.,                                 //alpha
                                            &oleImage.getTextureReference()) ); //texture
    cube.position.set(150,150,0);
    scene.add( cube );
    
//sphere mesh
    ofxScene::Mesh* sphere = new ofxScene::Mesh(new ofxScene::SphereGeometry( 50, 20, 10 ),
                                                new ofxScene::PhongMaterial(ofVec3f(1),                             //diffuse
                                                                            ofVec3f(1.1),                           //specular
                                                                            ofVec3f(.1),                            //ambient
                                                                            1,                                      //alpha
                                                                            64,                                     //shineness
                                                                            &globeImage.getTextureReference() ) );  //texture map
    sphere->position.y += 150;
    scene.add( sphere );
    
//parenting
    ofxScene::CubeGeometry* nestedGeometry = new ofxScene::CubeGeometry( 30,30,30 );
    nestedMeshes.resize(100);
    
    for (int i=0; i<nestedMeshes.size(); i++) {
        nestedMeshes[i].init( nestedGeometry, lambertMaterial );
        nestedMeshes[i].position.set( -20, 20, 0 );
        nestedMeshes[i].scale.set( .96 );
        if(i > 0){
            nestedMeshes[i-1].addChild( nestedMeshes[i] );
        }
        scene.add( nestedMeshes[i] );
    }
    nestedMeshes[0].position.set( -150, 150, 0 );
    
    
    
//dynamic geometry
    dynamicSphere.init( 50 , 70, 40, false );
    dynamicMesh.init( dynamicSphere, sphere->getShader() );
    scene.add( dynamicMesh );
    
    normalMesh.init( dynamicSphere, normalMat );
    normalMesh.position.x = -150;
    normalMesh.scale.set(.5);
    scene.add( normalMesh );
    
    facingRatioMesh.init(dynamicSphere,
                         new ofxScene::FacingRatioMaterial(ofVec3f(1.5),                        //color1
                                                           ofVec3f(.2,.2,.3),                   //color2
                                                           1.,                                  //alpha
                                                           4,                                   //exponent
                                                           &oleImage.getTextureReference()));   //texture map
    facingRatioMesh.position.x = 150;
    facingRatioMesh.scale.set(.5);
    scene.add( facingRatioMesh );
    
    //copy the original positions and normals to deform later 
    orginalPositions = dynamicSphere.vertices;
    orginalNormals = dynamicSphere.normals;

    
//loading geometry from file
    waltHead.init(new ofxScene::Geometry(), new ofxScene::PhongMaterial(ofVec3f(.6,.6,.95)));
    waltHead.geometry->load( "waltHeads/walt_medium.obj" );//http://davidoreilly.com/post/18087489343/disneyhead
    waltHead.position.set( -150, -150, 0 );
    waltHead.scale.set( 1.75 );
    scene.add( waltHead );
    
    waltHead1.init( waltHead.geometry, new ofxScene::PhongMaterial(ofVec3f(235,180,173)/255.f));
    waltHead1.position.set( 0, -150, 0 );
    waltHead1.scale.set( 1.75 );
    scene.add( waltHead1 );
    
    waltHead2.init( waltHead.geometry, normalMat );
    waltHead2.position.set( 150, -150, 0 );
    waltHead2.scale.set( 1.75 );
    waltHead2.wireframe = true;
    scene.add( waltHead2 );
    
//ground plane
    plane.init(new ofxScene::PlaneGeometry(600,600,20,20), dynamicMesh.shader);
    plane.position.set(0.,-250, 0);
    plane.rotate(-90, 1, 0, 0);
    scene.add( plane );
    plane.doubleSided = true;
    plane.geometry->calcTangents();

    //a simple debugging mesh that displays a mesh's normal, tangent, binormal
    normalDisplayMesh.setup( plane );
    scene.add( normalDisplayMesh );

it could be the lighting. try disabling the lights before drawing the gui and then enabling them again

That’s not it either :frowning:

There’s a screenShot to show what it looks like :
http://imgur.com/t31mOZK

I’m gonna try to comment everything in the ofxScene::setup() function and enable 5-10 lines at a time to see what’s causing this… gonna be fuun! ^^’

(edit : that’s the correct GUI)
http://imgur.com/cQMZzNi

Well, I’ve got some wuick results…

apparently this :

 waltHead.init(new ofxScene::Geometry(), new ofxScene::PhongMaterial(ofVec3f(.6,.6,.95)));
    waltHead.geometry->load( "waltHeads/walt_medium.obj" );//http://davidoreilly.com/post/18087489343/disneyhead
    waltHead.position.set( -150, -150, 0 );
    waltHead.scale.set( 1.75 );
    scene.add( waltHead );

Causses is causing the problem…
I have no idea why lol, maybe I’ll look at scene.add();

(edit : its not scene.add()… i’ll look at the erst but it’ll be more complicated)

(Re-edit : its the line :
waltHead.init(new ofxScene::Geometry(), new ofxScene::PhongMaterial(ofVec3f(.6,.6,.95)));

that is causing problem, i’ll check what’s in it ^^’)

Problem solved! :slight_smile:

The source was glEnable(GL_CULL_FACE); From ofxScene::Mesh.

I just have to call ’ glDisable(GL_CULL_FACE);’ at the beginning of my GUI.draw()…

I’m leaving the ofEnableAlpha, etc but it works even without it…

I’m feeling like I’m talking alone a lot… whatever!

Now that the update’s function doesn’t hide my GUI ,
it’s the scene.draw() that gives me troubble…

I’ve found an error deeeep into the shader class.
glUseProgram(...); was called and since glUseProgram(0);was not called at the end of scene.draw() (I added it), It was Hiding the whole GUI.

… Well, I corrected that si now I have my dear GUI… BUT simple functions shuch as ofLine(…) doesn’t draw anything anymore :frowning:

any ideas?

-=-=-=-=-=
Detail

I’ve made a condition so scene.draw() isn’t called before 3-4 seconds,
then it switches on and off every 3 seconds…

Before scene.draw() is called for the 1st time, the lines are drawn with ofLine…
However, once scene.draw is called once ofLine never works again even if scene.draw isin’t called.

do you mean in ofShader class or another class? but maybe @arturo may help more here…

No, odxScene actually have a Shader.h file and there was the problem, but this class shader inherit ofShader, yes.

For now I can avoid the problem and use an other way so I might not come with an answer anywhere soon…

But I wouldn’t be surprised that this causses more issues later in my project :/…