// ********************************************************************** // init int World::vinit(void) { // set lighting variables float ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f }; // ambient element of light float diffuseLight[] = { 0.85f, 0.85f, 0.85f, 1.0f }; // diffuse element of light float fogColor[] = { 0.50f, 0.50f, 0.50f, 1.0f }; int rockTex = -1; int stoneTex = -1; int marbTex = -1; int wallTex = -1; // load the textures for this world m_targas = new TgaList(6); marbTex = m_targas->add("textures/marbrose.tga"); wallTex = m_targas->add("textures/rockwall.tga"); rockTex = m_targas->add("textures/rocky256.tga"); stoneTex = m_targas->add("textures/walls064.tga"); // init and place objects in world m_floor->vinit(m_targas->getPtr(marbTex), m_targas->getWidth(marbTex), m_targas->getHeight(marbTex)); m_dome->vinit(m_targas->getPtr(stoneTex), m_targas->getWidth(stoneTex), m_targas->getHeight(stoneTex), m_targas->getPtr(rockTex), m_targas->getWidth(rockTex), m_targas->getHeight(rockTex)); m_lamp->vinit(); m_endTable->vinit(); m_endTable->setPosition(Vec3D(-8.0f, 0.0f, -2.0f), 10.0f); m_torus->vinit(); m_torus->setPosition(Vec3D(1.0f, 0.02f, -5.0f)); m_pawn->vinit(); m_pawn->setPosition(Vec3D(-5.8f, 0.0f, -4.1f)); // insert into view list glEnable(GL_LIGHTING); // set light0 glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); glEnable(GL_LIGHT0); glEnable(GL_FOG); // remember to disable for shadows glFogf(GL_FOG_DENSITY, 0.033f); glFogfv(GL_FOG_COLOR, fogColor); glClearColor(fogColor[0], fogColor[1], fogColor[2], fogColor[3]); glEnable(GL_TEXTURE_2D); // create some boring walls that should be replaced later createWalls(m_targas->getPtr(wallTex), m_targas->getWidth(wallTex), m_targas->getHeight(wallTex)); return 1; }
bool BattleScene::init(PreloadBattleScene* preloaderScene, std::vector<int> parameters) { if (!AbstractWorldScene::init("nodes/Table_Battle.csb")) { return false; } _modeGame = BATTLE_MODE(parameters.at(0)); int countPlayer = parameters.at(1) + 2; _preloaderScene = preloaderScene; _blackLayer = LayerColor::create(Color4B(0,0,0,0)); _mapLayer = Layer::create(); _debugLayer = Layer::create(); schedule(schedule_selector(BattleScene::update), 0.01f); _mapLayer->setTag(SIMPLE); _borderNode = CSLoader::createNode("nodes/WorldSceneSimple_1.csb"); _timer->setTime(180); for (int i = 0; i < 5; i++) { auto text = static_cast<ui::Text*>(_tableNode->getChildByName("Text_" + myUtils::to_string(i))); text->setString(""); _texts.push_back(text); } _mapLayer->addChild(_borderNode, 0); _currentIndexLevel = 1; createPlayers(countPlayer); createControll(GameSettings::Instance().getControlType()); for (int i = 0; i < countPlayer; i++) { _texts.at(i)->setString(myUtils::to_string(GameSettings::Instance().getCountWinPlayer(_players.at(i)->getColorID()))); } _mapLayer->addChild(_debugLayer, 100); createWalls(2, _modeGame == NORMAL ? 10 : 16); createNPCs(); for (auto player : _players) { _control->showControlPlayer(player->getColorID(), true); player->_collisions = _borderNode->getChildren(); player->setBricks(_bricks); } addChild(_mapLayer); addChild(_blackLayer, 1000); return true; }
void World::setup() { m_CellSpace = new CellSpacePartition<Vehicle*>(WORLD_WIDTH, WORLD_HEIGHT, WORLD_DEPTH, 15, 9, 15, 1000); //trialway = new Pathway(20, ofVec3f(-200, 20, 200), ofVec3f(200, 30, -200), Pathway::looped); //creates Player Ship playerShip = new GameActor(ofVec3f(0.1, 20.0, 40), 2.5, v_Zero, .03, v_HeadUp, 1000, v_One, 0.1, 10); //creates First Leader leaderShip = new Vehicle(this, ofVec3f(ofRandom(-30,30), 20.0, ofRandom(-20,20)), 2.5, v_Zero, .05, v_HeadUp, 1000, v_One, 0.1, 25, ofColor::fuchsia, ofColor::mediumPurple); leaderShip->SetEntityType(BaseEntity::master); leaderShip->Steering()->setCloseDistance(10); leaderShip->Steering()->WallAvoidanceOn(); leaderShip->Steering()->ObstacleAvoidanceOn(); leaderShip->Steering()->CreateRandomPath(10, ofVec3f(-100, -30, 100), ofVec3f(100, 30, -100)); leaderShip->Steering()->PathLoopOn(); leaderShip->Steering()->FollowPathOn(); leaderShip->Steering()->setWanderJitter(0.001); leaderShip->WrapAround(); //leaderShip->Steering()->WanderOn(); //creates Second In Command secondShip = new Vehicle(this, ofVec3f(ofRandom(-30, 30), 20.0, ofRandom(-20, 20)), 2.5, v_Zero, .05, v_HeadUp, 1000, v_One, 0.1, 25); secondShip->Steering()->WallAvoidanceOn(); secondShip->Steering()->setCloseDistance(10); secondShip->Steering()->ObstacleAvoidanceOn(); secondShip->Steering()->CreateRandomPath(10, ofVec3f(-100, -30, 100), ofVec3f(100, 30, -100)); secondShip->Steering()->PathLoopOn(); secondShip->Steering()->FollowPathOn(); secondShip->Steering()->setWanderJitter(0.001); secondShip->WrapAround(); //secondShip->Steering()->WanderOn(); //creates Swarms createSwarm_1(); createSwarm_2(); //createSwarm_3(); //createSwarm_4(); //Swarm_vs_Swarm(Swarm_1, Swarm_2); //creates Static Geometry createObstacles(); createWalls(); /* ....................................................... Creates Camera .......................................................*/ cameraMan = new Vehicle(this,ofVec3f(0.0, 30.0, 50.0), 2.5, ofVec3f::zero(), .03, ofVec3f(0, 0, -1), 1200, ofVec3f::one(), .1, 10); cameraMan->setTarget(playerShip); cameraMan->Steering()->ArriveOn(); cameraMan->Steering()->setCloseDistance(20); //cameraMan->Steering()->WanderOn(); cameraMan->SetWrapAround(false); //creates camera #ifdef CAMERAMAN camera.setParent(*cameraMan->Node()); camera.setPosition(ofVec3f(0.0, 5.0, 5.0)); camera.setFov(60); #endif #ifdef FIXED_CAMERA camera.setPosition(ofVec3f(200.0, 60.0, 200.0)); camera.setFov(65); #endif #ifdef TOPDOWN_CAMERA camera.setPosition(ofVec3f(0.1, 200, 0.0)); camera.lookAt(ofVec3f(0.1, 0.1, -0.1)); camera.setFov(90); #endif #ifdef TOPDOWNCLOSE_CAMERA camera.setPosition(ofVec3f(0.1, 80.0, -80.0)); camera.lookAt(ofVec3f(0.1, 0.1, -0.1)); camera.setFov(70); #endif #ifdef SIDE_CAMERA camera.setPosition(ofVec3f(100, 100.0, 0.1)); camera.lookAt(ofVec3f(0.1, 0.00, -0.1)); camera.setFov(90); #endif #ifdef EASY_CAMERA easyCam.setPosition(0, 0, 10); easyCam.setFov(60.0); #endif /* ....................................................... Lights! .......................................................*/ light.enable(); light.setAreaLight(WORLD_DEPTH, WORLD_HEIGHT); light.setPosition(0, 0, 0); }
void GameApplication::createScene(void) { mMapCamera = mSceneMgr->createCamera("MapCamera"); // set up map animations mViewportAnimationValues = mSceneMgr->createLight(); mViewportAnimationValues->setDiffuseColour(Ogre::ColourValue(0.7, 0.3, 0.0, 0.0)); // 'open' animation Ogre::Animation* namedAnim1 = mSceneMgr->createAnimation("MapAnimation_open", mapOpenDuration); namedAnim1->setInterpolationMode(Ogre::Animation::IM_SPLINE); const Ogre::StringVector& valueNames = mViewportAnimationValues->getAnimableValueNames(); Ogre::AnimableValuePtr AVPtr = mViewportAnimationValues->createAnimableValue(valueNames[0]); Ogre::NumericAnimationTrack* track_open = namedAnim1->createNumericTrack(0, AVPtr); AVPtr->setValue(Ogre::ColourValue::Black); AVPtr->setCurrentStateAsBaseValue(); track_open->createNumericKeyFrame(0)->setValue(Ogre::AnyNumeric(Ogre::ColourValue(0.7, 0.3, 0.0, 0.0))); track_open->createNumericKeyFrame(mapOpenDuration)->setValue(Ogre::AnyNumeric(Ogre::ColourValue(0.0, 1.0, 0.0, 0.0))); mMapAnimation_open = mSceneMgr->createAnimationState("MapAnimation_open"); mMapAnimation_open->setEnabled(false); mMapAnimation_open->setLoop(false); mMapAnimation_open->setTimePosition(0); // 'close' animation Ogre::Animation* namedAnim2 = mSceneMgr->createAnimation("MapAnimation_close", mapOpenDuration); namedAnim2->setInterpolationMode(Ogre::Animation::IM_SPLINE); AVPtr = mViewportAnimationValues->createAnimableValue(valueNames[0]); Ogre::NumericAnimationTrack* track_close = namedAnim2->createNumericTrack(0, AVPtr); AVPtr->setValue(Ogre::ColourValue::Black); AVPtr->setCurrentStateAsBaseValue(); track_close->createNumericKeyFrame(0)->setValue(Ogre::AnyNumeric(Ogre::ColourValue(0.0, 1.0, 0.0, 0.0))); track_close->createNumericKeyFrame(mapOpenDuration)->setValue(Ogre::AnyNumeric(Ogre::ColourValue(0.7, 0.3, 0.0, 0.0))); mMapAnimation_close = mSceneMgr->createAnimationState("MapAnimation_close"); mMapAnimation_close->setEnabled(false); mMapAnimation_close->setLoop(false); mMapAnimation_close->setTimePosition(0); mViewportAnimationValues->setDiffuseColour(Ogre::ColourValue(0.7, 0.3, 0.0, 0.0)); // Set ambient light mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); // Create a light Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20,80,50); new DebugDisplay(mSceneMgr, 0.5f); DebugDisplay::getSingleton().setEnabled(false); mDebugOverlay = new DebugOverlay(); new OgreConsole; OgreConsole::getSingleton().init(mRoot); OgreConsole::getSingleton().setVisible(false); createDynamicWorld(Vector3(0.0f, -9.81f, 0.0f), AxisAlignedBox (Ogre::Vector3 (-10000, -10000, -10000), Ogre::Vector3 (10000, 10000, 10000))); createWalls(); // now create navigation graph new NavigationGraph(mSceneMgr, -500, -500, 1000, 1000); NavigationGraph::getSingleton().calcGraph(mWorld); NavigationGraph::getSingleton().setDebugDisplayEnabled(mShowNavigationGraph); createSpacecrafts(); Ogre::LogManager::getSingletonPtr()->logMessage("running script file now"); mScriptingManager = new scripting::Manager(); mScriptingManager->runScriptFile("../../media/AIController.lua"); Ogre::Viewport* vpMiniMap = mWindow->addViewport(mMapCamera, 2, 0.7, 0.7, 0.3, 0.3); vpMiniMap->setBackgroundColour(Ogre::ColourValue(0,0,0)); mMapCamera->setNearClipDistance(1.0f); mMapCamera->setFarClipDistance(100000.0f); mMapCamera->setPosition(0,200,0); mMapCamera->lookAt(0,0,30); mMapCamera->rotate(Ogre::Quaternion(Ogre::Radian(Ogre::Degree(180)), Ogre::Vector3::UNIT_Y)); mMapCamera->setProjectionType(Ogre::ProjectionType::PT_ORTHOGRAPHIC); mMapCamera->setOrthoWindow(vpMiniMap->getActualWidth(), vpMiniMap->getActualHeight()); try { Ogre::CompositorManager::getSingleton().addCompositor(vpMiniMap, "Sepia"); Ogre::CompositorManager::getSingleton().setCompositorEnabled(vpMiniMap, "Sepia", true); } catch(...) { Ogre::LogManager::getSingleton().logMessage("Could not load compositor"); } }