SurvivalMode::SurvivalMode() { setup(); setupObjects(); setupTextures(); setupBall(); setupEnemies(); }
void RenderWidget0::initSceneEvent() { sceneManager = new SceneManager(); //create and position the camera setupCamera(); //create and position and objects in scene setupObjects(); // Trigger timer event every 5ms. timerId = startTimer(5); }
void Scene::setup(Sim* sim) { mSim = sim; mSim->scene = this; // Lighting and sky mSceneMgr->setAmbientLight(Ogre::ColourValue(0.4, 0.4, 0.4)); Ogre::Vector3 lightDir(0.55, -0.3f, 0.75); lightDir.normalise(); sun = mSceneMgr->createLight("SunLight"); sun->setType(Ogre::Light::LT_DIRECTIONAL); sun->setDirection(lightDir); sun->setDiffuseColour(Ogre::ColourValue::White); sun->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4)); mSceneMgr->setSkyDome(true, "CloudySky"); // Terrain mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions(); mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, terrSize, worldSize); configureTerrainDefaults(); defineTerrain(); mTerrainGroup->loadAllTerrains(true); Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator(); while (ti.hasMoreElements()) { Ogre::Terrain* t = ti.getNext()->instance; t->setVisibilityFlags(RV_Terrain); } mTerrainGroup->freeTemporaryResources(); createBulletTerrain(); // Road // setupRoad(); // Objects setupObjects(); }
GameplayModeScene::GameplayModeScene() { setup(); setupObjects(); setupTextures(); }
void Simulator::onAutopilotConnect() { autopilotConnectionStatus = true; setupObjects(); emit autopilotConnected(); }
// this is the code that actually draws the window // it puts a lot of the work into other routines to simplify things void TrainView::draw() { glViewport(0,0,w(),h()); // clear the window, be sure to clear the Z-Buffer too glClearColor(0,0,.3f,0); // background should be blue // we need to clear out the stencil buffer since we'll use // it for shadows glClearStencil(0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glEnable(GL_DEPTH); // Blayne prefers GL_DIFFUSE glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); // prepare for projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); setProjection(); // put the code to set up matrices here // TODO: you might want to set the lighting up differently // if you do, // we need to set up the lights AFTER setting up the projection // enable the lighting glEnable(GL_COLOR_MATERIAL); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // top view only needs one light if (tw->topCam->value()) { glDisable(GL_LIGHT1); glDisable(GL_LIGHT2); } else { glEnable(GL_LIGHT1); glEnable(GL_LIGHT2); } // set the light parameters GLfloat lightPosition1[] = {0,1,1,0}; // {50, 200.0, 50, 1.0}; GLfloat lightPosition2[] = {1, 0, 0, 0}; GLfloat lightPosition3[] = {0, -1, 0, 0}; GLfloat yellowLight[] = {0.5f, 0.5f, .1f, 1.0}; GLfloat whiteLight[] = {1.0f, 1.0f, 1.0f, 1.0}; GLfloat blueLight[] = {.1f,.1f,.3f,1.0}; GLfloat grayLight[] = {.3f, .3f, .3f, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition1); glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight); glLightfv(GL_LIGHT0, GL_AMBIENT, grayLight); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition2); glLightfv(GL_LIGHT1, GL_DIFFUSE, yellowLight); glLightfv(GL_LIGHT2, GL_POSITION, lightPosition3); glLightfv(GL_LIGHT2, GL_DIFFUSE, blueLight); // now draw the ground plane setupFloor(); glDisable(GL_LIGHTING); drawFloor(200,10); glEnable(GL_LIGHTING); setupObjects(); // we draw everything twice - once for real, and then once for // shadows drawStuff(); // this time drawing is for shadows (except for top view) if (!tw->topCam->value()) { setupShadows(); drawStuff(true); unsetupShadows(); } }
void Exporter::onAutopilotConnect() { autopilotConnectionStatus = true; setupObjects(); emit autopilotConnected(); }
OBJScene::OBJScene() { setupCamera(); setupObjects(); setupLights(); }
RiverMargin::RiverMargin(float x, float y, float z) : StaticObject(x, y, z) { cube = new Cube(); setupObjects(); }
// this is the code that actually draws the window // it puts a lot of the work into other routines to simplify things void TrainView::draw() { glViewport(0,0,w(),h()); // clear the window, be sure to clear the Z-Buffer too glClearColor(0,0,.3f,0); // background should be blue // we need to clear out the stencil buffer since we'll use // it for shadows glClearStencil(0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glEnable(GL_DEPTH); // Blayne prefers GL_DIFFUSE glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); // prepare for projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); setProjection(); // put the code to set up matrices here // TODO: you might want to set the lighting up differently // if you do, // we need to set up the lights AFTER setting up the projection // enable the lighting glEnable(GL_COLOR_MATERIAL); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // top view only needs one light if (tw->topCam->value()) { glDisable(GL_LIGHT1); glDisable(GL_LIGHT2); } else { glEnable(GL_LIGHT1); glEnable(GL_LIGHT2); } // set the light parameters GLfloat lightPosition1[] = {0,1,1,0}; // {50, 200.0, 50, 1.0}; GLfloat lightPosition2[] = {1, 0, 0, 0}; GLfloat lightPosition3[] = {0, -1, 0, 0}; GLfloat yellowLight[] = {0.5f, 0.5f, .1f, 1.0}; GLfloat whiteLight[] = {1.0f, 1.0f, 1.0f, 1.0}; GLfloat blueLight[] = {.1f,.1f,.3f,1.0}; GLfloat grayLight[] = {.3f, .3f, .3f, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition1); glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight); glLightfv(GL_LIGHT0, GL_AMBIENT, grayLight); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition2); glLightfv(GL_LIGHT1, GL_DIFFUSE, yellowLight); glLightfv(GL_LIGHT2, GL_POSITION, lightPosition3); glLightfv(GL_LIGHT2, GL_DIFFUSE, blueLight); // yk texture // Texture mapping setting for Microsoft's OpenGL implementation glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); // Texture mapping parameters for filter and repeatance glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // now draw the ground plane setupFloor(); //glDisable(GL_LIGHTING); //drawFloor(200,10); glEnable(GL_LIGHTING); setupObjects(); // we draw everything twice - once for real, and then once for // shadows drawStuff(); // ground drawGround(); // this time drawing is for shadows (except for top view) if (!tw->topCam->value()) { setupShadows(); drawStuff(true); // ground drawGround(); unsetupShadows(); } float fogColor[] = {0.7, 0.7, 0.7, 0.1}; glFogf(GL_FOG_MODE, GL_EXP); if (isFoggy == true) { //printf("fog on\n"); glEnable(GL_FOG); } else { //printf("fog off\n"); glDisable(GL_FOG); } glFogfv(GL_FOG_COLOR, fogColor); glFogf(GL_FOG_DENSITY, 0.02f); glFogf(GL_FOG_START, 20); glFogf(GL_FOG_END, 200); // yk running // angle 1 if (rand() % 10 == 1) angleFlag1 = !angleFlag1; if (angleFlag1 == 0) { angle1 += 0.1; } else { angle1 -= 0.1; } if (angle1 > 10 || angle1 < -10) angleFlag1 = !angleFlag1; // angle 2 if (rand() % 10 == 1) angleFlag2 = !angleFlag2; if (angleFlag2 == 0) { angle2 += 0.1; } else { angle2 -= 0.1; } if (angle2 > 10 || angle2 < -10) angleFlag2 = !angleFlag2; // angle3 angle3 += 0.6; if (angle3 >= 360) angle3 = 0; glFlush(); }
CubeScene::CubeScene() { setupCamera(); setupObjects(); setupLights(); }
SpiralScene::SpiralScene() { setupCamera(); setupObjects(); setupLights(); }
int doBaCParam (CoinParam *param) { assert (param != 0) ; CbcGenParam *genParam = dynamic_cast<CbcGenParam *>(param) ; assert (genParam != 0) ; CbcGenCtlBlk *ctlBlk = genParam->obj() ; assert (ctlBlk != 0) ; CbcModel *model = ctlBlk->model_ ; assert (model != 0) ; /* Setup to return nonfatal/fatal error (1/-1) by default. */ int retval ; if (CoinParamUtils::isInteractive()) { retval = 1 ; } else { retval = -1 ; } ctlBlk->setBaBStatus(CbcGenCtlBlk::BACAbandon, CbcGenCtlBlk::BACmInvalid, CbcGenCtlBlk::BACwNotStarted, false, 0) ; /* We ain't gonna do squat without a good model. */ if (!ctlBlk->goodModel_) { std::cout << "** Current model not valid!" << std::endl ; return (retval) ; } /* Start the clock ticking. */ double time1 = CoinCpuTime() ; double time2 ; /* Create a clone of the model which we can modify with impunity. Extract the underlying solver for convenient access. */ CbcModel babModel(*model) ; OsiSolverInterface *babSolver = babModel.solver() ; assert (babSolver != 0) ; # if CBC_TRACK_SOLVERS > 0 std::cout << "doBaCParam: initial babSolver is " << std::hex << babSolver << std::dec << ", log level " << babSolver->messageHandler()->logLevel() << "." << std::endl ; # endif /* Solve the root relaxation. Bail unless it solves to optimality. */ if (!solveRelaxation(&babModel)) { ctlBlk->setBaBStatus(&babModel, CbcGenCtlBlk::BACwBareRoot) ; return (0) ; } # if COIN_CBC_VERBOSITY > 0 std::cout << "doBaCParam: initial relaxation z = " << babSolver->getObjValue() << "." << std::endl ; # endif /* Are we up for fixing variables based on reduced cost alone? */ if (ctlBlk->djFix_.action_ == true) { reducedCostHack(babSolver, ctlBlk->djFix_.threshold_) ; } /* Time to consider preprocessing. We'll do a bit of setup before getting to the meat of the issue. preIppSolver will hold a clone of the unpreprocessed constraint system. We'll need it when we postprocess. ippSolver holds the preprocessed constraint system. Again, we clone it and give the clone to babModel for B&C. Presumably we need an unmodified copy of the preprocessed system to do postprocessing, but the copy itself is hidden inside the preprocess object. */ OsiSolverInterface *preIppSolver = 0 ; CglPreProcess ippObj ; bool didIPP = false ; int numberChanged = 0 ; int numberOriginalColumns = babSolver->getNumCols() ; CbcGenCtlBlk::IPPControl ippAction = ctlBlk->getIPPAction() ; if (!(ippAction == CbcGenCtlBlk::IPPOff || ippAction == CbcGenCtlBlk::IPPStrategy)) { double timeLeft = babModel.getMaximumSeconds() ; preIppSolver = babSolver->clone() ; OsiSolverInterface *ippSolver ; # if CBC_TRACK_SOLVERS > 0 std::cout << "doBaCParam: clone made prior to IPP is " << std::hex << preIppSolver << std::dec << ", log level " << preIppSolver->messageHandler()->logLevel() << "." << std::endl ; # endif preIppSolver->setHintParam(OsiDoInBranchAndCut, true, OsiHintDo) ; ippObj.messageHandler()->setLogLevel(babModel.logLevel()) ; CglProbing probingGen ; probingGen.setUsingObjective(true) ; probingGen.setMaxPass(3) ; probingGen.setMaxProbeRoot(preIppSolver->getNumCols()) ; probingGen.setMaxElements(100) ; probingGen.setMaxLookRoot(50) ; probingGen.setRowCuts(3) ; ippObj.addCutGenerator(&probingGen) ; /* For preProcessNonDefault, the 2nd parameter controls the conversion of clique and SOS constraints. 0 does nothing, -1 converts <= to ==, and 2 and 3 form SOS sets under strict and not-so-strict conditions, respectively. */ int convert = 0 ; if (ippAction == CbcGenCtlBlk::IPPEqual) { convert = -1 ; } else if (ippAction == CbcGenCtlBlk::IPPEqualAll) { convert = -2 ; } else if (ippAction == CbcGenCtlBlk::IPPSOS) { convert = 2 ; } else if (ippAction == CbcGenCtlBlk::IPPTrySOS) { convert = 3 ; } ippSolver = ippObj.preProcessNonDefault(*preIppSolver, convert, 10) ; # if CBC_TRACK_SOLVERS > 0 std::cout << "doBaCParam: solver returned from IPP is " << std::hex << ippSolver << std::dec ; if (ippSolver) { std::cout << ", log level " << ippSolver->messageHandler()->logLevel() ; } std::cout << "." << std::endl ; # endif /* ippSolver == 0 is success of a sort --- integer preprocess has found the problem to be infeasible or unbounded. Need to think about how to indicate status. */ if (!ippSolver) { std::cout << "Integer preprocess says infeasible or unbounded" << std::endl ; delete preIppSolver ; ctlBlk->setBaBStatus(&babModel, CbcGenCtlBlk::BACwIPP) ; return (0) ; } # if COIN_CBC_VERBOSITY > 0 else { std::cout << "After integer preprocessing, model has " << ippSolver->getNumRows() << " rows, " << ippSolver->getNumCols() << " columns, and " << ippSolver->getNumElements() << " elements." << std::endl ; } # endif preIppSolver->setHintParam(OsiDoInBranchAndCut, false, OsiHintDo) ; ippSolver->setHintParam(OsiDoInBranchAndCut, false, OsiHintDo) ; if (ippAction == CbcGenCtlBlk::IPPSave) { ippSolver->writeMps("presolved", "mps", 1.0) ; std::cout << "Integer preprocessed model written to `presolved.mps' " << "as minimisation problem." << std::endl ; } OsiSolverInterface *osiTmp = ippSolver->clone() ; babModel.assignSolver(osiTmp) ; babSolver = babModel.solver() ; # if CBC_TRACK_SOLVERS > 0 std::cout << "doBaCParam: clone of IPP solver passed to babModel is " << std::hex << babSolver << std::dec << ", log level " << babSolver->messageHandler()->logLevel() << "." << std::endl ; # endif if (!solveRelaxation(&babModel)) { delete preIppSolver ; ctlBlk->setBaBStatus(&babModel, CbcGenCtlBlk::BACwIPPRelax) ; return (0) ; } # if COIN_CBC_VERBOSITY > 0 std::cout << "doBaCParam: presolved relaxation z = " << babSolver->getObjValue() << "." << std::endl ; # endif babModel.setMaximumSeconds(timeLeft - (CoinCpuTime() - time1)) ; didIPP = true ; } /* At this point, babModel and babSolver hold the constraint system we'll use for B&C (either the original system or the preprocessed system) and we have a solution to the lp relaxation. If we're using the COSTSTRATEGY option, set up priorities here and pass them to the babModel. */ if (ctlBlk->priorityAction_ != CbcGenCtlBlk::BPOff) { setupPriorities(&babModel, ctlBlk->priorityAction_) ; } /* Install heuristics and cutting planes. */ installHeuristics(ctlBlk, &babModel) ; installCutGenerators(ctlBlk, &babModel) ; /* Set up status print frequency for babModel. */ if (babModel.getNumCols() > 2000 || babModel.getNumRows() > 1500 || babModel.messageHandler()->logLevel() > 1) babModel.setPrintFrequency(100) ; /* If we've read in a known good solution for debugging, activate the row cut debugger. */ if (ctlBlk->debugSol_.values_) { if (ctlBlk->debugSol_.numCols_ == babModel.getNumCols()) { babSolver->activateRowCutDebugger(ctlBlk->debugSol_.values_) ; } else { std::cout << "doBaCParam: debug file has incorrect number of columns." << std::endl ; } } /* Set ratio-based integrality gap, if specified by user. */ if (ctlBlk->setByUser_[CbcCbcParam::GAPRATIO] == true) { double obj = babSolver->getObjValue() ; double gapRatio = babModel.getDblParam(CbcModel::CbcAllowableFractionGap) ; double gap = gapRatio * (1.0e-5 + fabs(obj)) ; babModel.setAllowableGap(gap) ; std::cout << "doBaCParam: Continuous objective = " << obj << ", so allowable gap set to " << gap << std::endl ; } /* A bit of mystery code. As best I can figure, setSpecialOptions(2) suppresses the removal of warm start information when checkSolution runs an lp to check a solution. John's comment, ``probably faster to use a basis to get integer solutions'' makes some sense in this context. Didn't try to track down moreMipOptions just yet. */ babModel.setSpecialOptions(babModel.specialOptions() | 2) ; /* { int ndx = whichParam(MOREMIPOPTIONS,numberParameters,parameters) ; int moreMipOptions = parameters[ndx].intValue() ; if (moreMipOptions >= 0) { printf("more mip options %d\n",moreMipOptions); babModel.setSearchStrategy(moreMipOptions); } } */ /* Begin the final run-up to branch-and-cut. Make sure that objects are set up in the solver. It's possible that whoever loaded the model into the solver also set up objects. But it's also entirely likely that none exist to this point (and interesting to note that IPP doesn't need to know anything about objects). */ setupObjects(babSolver, didIPP, &ippObj) ; /* Set the branching method. We can't do this until we establish objects, because the constructor will set up arrays based on the number of objects, and there's no provision to set this information after creation. Arguably not good --- it'd be nice to set this in the prototype model that's cloned for this routine. In CoinSolve, shadowPriceMode is handled with the TESTOSI option. */ OsiChooseStrong strong(babSolver) ; strong.setNumberBeforeTrusted(babModel.numberBeforeTrust()) ; strong.setNumberStrong(babModel.numberStrong()) ; strong.setShadowPriceMode(ctlBlk->chooseStrong_.shadowPriceMode_) ; CbcBranchDefaultDecision decision ; decision.setChooseMethod(strong) ; babModel.setBranchingMethod(decision) ; /* Here I've deleted a huge block of code that deals with external priorities, branch direction, pseudocosts, and solution. (PRIORITYIN) Also a block of code that generates C++ code. */ /* Set up strategy for branch-and-cut. Note that the integer code supplied to setupPreProcessing is *not* compatible with the IPPAction enum. But at least it's documented. See desiredPreProcess_ in CbcStrategyDefault. `1' is accidentally equivalent to IPPOn. */ if (ippAction == CbcGenCtlBlk::IPPStrategy) { CbcStrategyDefault strategy(true, 5, 5) ; strategy.setupPreProcessing(1) ; babModel.setStrategy(strategy) ; } /* Yes! At long last, we're ready for the big call. Do branch and cut. In general, the solver used to return the solution will not be the solver we passed in, so reset babSolver here. */ int statistics = (ctlBlk->printOpt_ > 0) ? ctlBlk->printOpt_ : 0 ; # if CBC_TRACK_SOLVERS > 0 std::cout << "doBaCParam: solver at call to branchAndBound is " << std::hex << babModel.solver() << std::dec << ", log level " << babModel.solver()->messageHandler()->logLevel() << "." << std::endl ; # endif babModel.branchAndBound(statistics) ; babSolver = babModel.solver() ; # if CBC_TRACK_SOLVERS > 0 std::cout << "doBaCParam: solver at return from branchAndBound is " << std::hex << babModel.solver() << std::dec << ", log level " << babModel.solver()->messageHandler()->logLevel() << "." << std::endl ; # endif /* Write out solution to preprocessed model. */ if (ctlBlk->debugCreate_ == "createAfterPre" && babModel.bestSolution()) { CbcGenParamUtils::saveSolution(babSolver, "debug.file") ; } /* Print some information about branch-and-cut. */ # if COIN_CBC_VERBOSITY > 0 std::cout << "Cuts at root node changed objective from " << babModel.getContinuousObjective() << " to " << babModel.rootObjectiveAfterCuts() << std::endl ; for (int iGen = 0 ; iGen < babModel.numberCutGenerators() ; iGen++) { CbcCutGenerator *generator = babModel.cutGenerator(iGen) ; std::cout << generator->cutGeneratorName() << " was tried " << generator->numberTimesEntered() << " times and created " << generator->numberCutsInTotal() << " cuts of which " << generator->numberCutsActive() << " were active after adding rounds of cuts" ; if (generator->timing()) { std::cout << " ( " << generator->timeInCutGenerator() << " seconds)" ; } std::cout << std::endl ; } # endif time2 = CoinCpuTime(); ctlBlk->totalTime_ += time2 - time1; /* If we performed integer preprocessing, time to back it out. */ if (ippAction != CbcGenCtlBlk::IPPOff) { # if CBC_TRACK_SOLVERS > 0 std::cout << "doBaCParam: solver passed to IPP postprocess is " << std::hex << babSolver << std::dec << "." << std::endl ; # endif ippObj.postProcess(*babSolver); babModel.assignSolver(preIppSolver) ; babSolver = babModel.solver() ; # if CBC_TRACK_SOLVERS > 0 std::cout << "doBaCParam: solver in babModel after IPP postprocess is " << std::hex << babSolver << std::dec << "." << std::endl ; # endif } /* Write out postprocessed solution to debug file, if requested. */ if (ctlBlk->debugCreate_ == "create" && babModel.bestSolution()) { CbcGenParamUtils::saveSolution(babSolver, "debug.file") ; } /* If we have a good solution, detach the solver with the answer. Fill in the rest of the status information for the benefit of the wider world. */ bool keepAnswerSolver = false ; OsiSolverInterface *answerSolver = 0 ; if (babModel.bestSolution()) { babModel.setModelOwnsSolver(false) ; keepAnswerSolver = true ; answerSolver = babSolver ; } ctlBlk->setBaBStatus(&babModel, CbcGenCtlBlk::BACwBAC, keepAnswerSolver, answerSolver) ; /* And one last bit of information & statistics. */ ctlBlk->printBaBStatus() ; std::cout << " " ; if (keepAnswerSolver) { std::cout << "objective " << babModel.getObjValue() << "; " ; } std::cout << babModel.getNodeCount() << " nodes and " << babModel.getIterationCount() << " iterations - took " << time2 - time1 << " seconds" << std::endl ; return (0) ; }