hello
i try to test ofxSceneManager addon to switch some sketch and examples, but when I compile, change scenes, they will copy!
when compile, show the first scene normal:
change to the second scene, normal.
change to the first scene again. double gui…
change to the second scene… double particle system.
change to the first scene… triple.
the code:
#include "ofApp.h"
#include "msafluids/FirstScene.h"
#include "wiiacuarium/SecondScene.h"
//--------------------------------------------------------------
void ofApp::setup(){
server.setName("The Floor");
FirstScene* firstScene = new FirstScene;
firstScene->setSceneDuration(0.5, 1.5, 0.5);
SecondScene* secondScene = new SecondScene;
secondScene->setSceneDuration(0.5, 3.0, 0.5);
sceneManager.addScene(ofPtr<ofxScene>(firstScene));
sceneManager.addScene(ofPtr<ofxScene>(secondScene));
//sceneManager.setExitByTime(true);
sceneManager.setTransitionDissolve();
//sceneManager.setTransitionFade();
sceneManager.run();
}
//--------------------------------------------------------------
void ofApp::update(){
sceneManager.update();
}
//--------------------------------------------------------------
void ofApp::draw(){
sceneManager.draw();
server.publishScreen();
ofSetColor(255);
ofDrawBitmapString("scenes: "+ofToString(sceneManager.scenes.size()), 10,10);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if (key == ' ') {
sceneManager.changeScene();
} else if (key == '0') {
sceneManager.changeScene(0);
} else if (key == '1') {
sceneManager.changeScene(1);
}
}
anything work with this addon? eny help?
thanks community!!!
talaron
November 5, 2015, 6:20am
#2
Hi
You should show here the first scene code
talaron
November 5, 2015, 8:24am
#3
My guess is you’re calling GUI construction in setup() method of your scene,
and setup() in ofxScene is called each time this scene is called (when you call changeScene)
gui and particle system called in setup() of scene scene
#include "FirstScene.h"
//--------------------------------------------------------------
void FirstScene::setup() {
ofSetLogLevel(OF_LOG_VERBOSE);
isGui = true;
// setup fluid stuff
fluidSolver.setup(100, 100);
fluidSolver.enableRGB(true).setFadeSpeed(0.002).setDeltaT(0.5).setVisc(0.00015).setColorDiffusion(0);
fluidDrawer.setup(&fluidSolver);
fluidCellsX = 150;
drawFluid = true;
drawParticles = true;
tuioXScaler = 1;
tuioYScaler = 1;
ofSetFrameRate(60);
ofBackground(0, 0, 0);
ofSetVerticalSync(false);
tuioClient.start(3333);
gui.addSlider("fluidCellsX", fluidCellsX, 20, 400);
gui.addButton("resizeFluid", resizeFluid);
gui.addSlider("colorMult", colorMult, 0, 100);
gui.addSlider("velocityMult", velocityMult, 0, 100);
gui.addSlider("fs.viscocity", fluidSolver.viscocity, 0.0, 0.01);
gui.addSlider("fs.colorDiffusion", fluidSolver.colorDiffusion, 0.0, 0.0003);
gui.addSlider("fs.fadeSpeed", fluidSolver.fadeSpeed, 0.0, 0.1);
gui.addSlider("fs.solverIterations", fluidSolver.solverIterations, 1, 50);
gui.addSlider("fs.deltaT", fluidSolver.deltaT, 0.1, 5);
gui.addComboBox("fd.drawMode", (int&)fluidDrawer.drawMode, msa::fluid::getDrawModeTitles());
gui.addToggle("fs.doRGB", fluidSolver.doRGB);
gui.addToggle("fs.doVorticityConfinement", fluidSolver.doVorticityConfinement);
gui.addToggle("drawFluid", drawFluid);
gui.addToggle("drawParticles", drawParticles);
gui.addToggle("fs.wrapX", fluidSolver.wrap_x);
gui.addToggle("fs.wrapY", fluidSolver.wrap_y);
gui.addSlider("tuioXScaler", tuioXScaler, 0, 2);
gui.addSlider("tuioYScaler", tuioYScaler, 0, 2);
gui.currentPage().setXMLName("ofxMSAFluidSettings.xml");
gui.loadFromXML();
gui.setDefaultKeys(true);
gui.setAutoSave(true);
gui.show();
//windowResized(ofGetWidth(), ofGetHeight()); // force this at start (cos I don't think it is called)
pMouse = msa::getWindowCenter();
resizeFluid = true;
ofEnableAlphaBlending();
ofSetBackgroundAuto(false);
}
tsin
November 6, 2015, 1:49am
#6
you should use single instance
talaron
November 6, 2015, 4:58am
#8
[quote=“talaron, post:3, topic:21262”]
and setup() in ofxScene is called each time this scene is called (when you call changeScene)[/quote]
As I said, you must not create your gui in setup() of your ofxScene, it is called each time the scene is changed.
sceneManager.changeScene(0);
-> calls setup()
You should create an init() or initGUI() method and call it when you create your scene
FirstScene* firstScene = new FirstScene;
firstScene->setSceneDuration(0.5, 1.5, 0.5);
firstScene->initGUI()