void Bullet::beginContact(QFixture *other, b2Contact *) { if (other->isSensor()) return; destroyLater(); ParticleSystem *p = static_cast<World *>(world())->particleSystem(); p->addExplosion(worldCenter(), 5, 0.1, 20); if (QChain *chain = dynamic_cast<QChain *>(other->body())) { chain->cutCircle(Circle(Vector2d(worldCenter()), 5)); } }
//---------------------------------------------------------------------------- bool Castle::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } mCamera->SetFrustum(45.0f, GetAspectRatio(), 1.0f, 44495.0f); CreateScene(); mScene->Update(); // Center-and-fit the scene. The hard-coded center/position are based // on a priori knowledge of the data set. APoint worldCenter(1.3778250f,-0.70154405f,2205.9973f); mTrnNode->LocalTransform.SetTranslate(-worldCenter); APoint camPosition(527.394f, 86.8992f, -2136.00f); AVector camDVector(1.0f, 0.0f, 0.0f); AVector camUVector(0.0f, 0.0f, 1.0f); AVector camRVector = camDVector.Cross(camUVector); mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); mScene->Update(); mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(0.5f, 0.001f); InitializeObjectMotion(mScene); MoveForward(); return true; }
void Geometry::setupView() { Ogre::Camera * mCamera = OgreTrip::getCamera(); // put camera at world center, so that it's difficult to reach the edge Vector3 worldCenter( (ENDLESS_PAGE_MAX_X + ENDLESS_PAGE_MIN_X) / 2 * TERRAIN_WORLD_SIZE, 0, -(ENDLESS_PAGE_MAX_Y + ENDLESS_PAGE_MIN_Y) / 2 * TERRAIN_WORLD_SIZE ); //mCamera->setPosition(mTerrainPos + worldCenter); //mCamera->lookAt(mTerrainPos); mCamera->setNearClipDistance(0.1); mCamera->setFarClipDistance(8000); /* if (OgreTrip::getRoot()->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) { mCamera->setFarClipDistance(0); // enable infinite far clip distance if we can }*/ }
void begin_terrain(BATB& batb) { // http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+3 // http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre+Terrain+System // libs/ogre/Samples/EndlessWorld/include/EndlessWorld.h #ifdef USE_SAMPLE_TERRAIN if (!Ogre::ResourceGroupManager::getSingleton().resourceGroupExists("Terrain")) Ogre::ResourceGroupManager::getSingleton().createResourceGroup("Terrain"); #endif // create object, which becomes a singleton // Terrain::setResourceGroup overrides this (??) terrain_globals = OGRE_NEW TerrainGlobalOptions(); MaterialManager::getSingleton().setDefaultTextureFiltering(TFO_ANISOTROPIC); MaterialManager::getSingleton().setDefaultAnisotropy(7); #ifdef USE_SAMPLE_ENDLESSWORLD scenemgr->setFog(FOG_LINEAR, ColourValue(0.7, 0.7, 0.8), 0, 4000, 10000); #endif #ifdef USE_SAMPLE_TERRAIN scenemgr->setFog(FOG_LINEAR, ColourValue(0.7, 0.7, 0.8), 0, 10000, 25000); // Terrain #endif //LogManager::getSingleton().setLogDetail(LL_BOREME); // ?? Vector3 lightdir(0.55, -0.3, 0.75); lightdir.normalise(); Light* l = scenemgr->createLight("tstLight"); l->setType(Light::LT_DIRECTIONAL); l->setDirection(lightdir); l->setDiffuseColour(ColourValue::White); #ifdef USE_SAMPLE_ENDLESSWORLD l->setSpecularColour(ColourValue(0.1, 0.1, 0.1)); #endif #ifdef USE_SAMPLE_TERRAIN l->setSpecularColour(ColourValue(0.4, 0.4, 0.4)); #endif scenemgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); terrain_group = OGRE_NEW TerrainGroup(scenemgr, Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE); #ifdef USE_SAMPLE_ENDLESSWORLD terrain_group->setFilenameConvention(ENDLESS_TERRAIN_FILE_PREFIX, ENDLESS_TERRAIN_FILE_SUFFIX); terrain_group->setAutoUpdateLod( TerrainAutoUpdateLodFactory::getAutoUpdateLod(BY_DISTANCE) ); #endif #ifdef USE_SAMPLE_TERRAIN terrain_group->setFilenameConvention(TERRAIN_FILE_PREFIX, TERRAIN_FILE_SUFFIX); terrain_group->setResourceGroup("Terrain"); #endif //////////////////////////////////////////////////////////////////////////////// // configureTerrainDefaults // // Configure global terrain_globals->setMaxPixelError(8); // testing composite map terrain_globals->setCompositeMapDistance(3000); //terrain_globals->setUseRayBoxDistanceCalculation(true); terrain_globals->getDefaultMaterialGenerator()->setLightmapEnabled(false); terrain_globals->setCompositeMapAmbient(scenemgr->getAmbientLight()); terrain_globals->setCompositeMapDiffuse(l->getDiffuseColour()); terrain_globals->setLightMapDirection(l->getDerivedDirection()); // Configure default import settings for if we use imported image Terrain::ImportData& defaultimp = terrain_group->getDefaultImportSettings(); defaultimp.terrainSize = TERRAIN_SIZE; defaultimp.worldSize = TERRAIN_WORLD_SIZE; defaultimp.inputScale = 600; defaultimp.minBatchSize = 33; defaultimp.maxBatchSize = 65; // textures // see 'initBlendMaps' below defaultimp.layerList.resize(3); defaultimp.layerList[0].worldSize = 100; // scale layer defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_diffusespecular.dds"); defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_normalheight.dds"); defaultimp.layerList[1].worldSize = 30; // scale layer defaultimp.layerList[1].textureNames.push_back("grass_green-01_diffusespecular.dds"); defaultimp.layerList[1].textureNames.push_back("grass_green-01_normalheight.dds"); defaultimp.layerList[2].worldSize = 200; // scale layer defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_diffusespecular.dds"); defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_normalheight.dds"); //////////////////////////////////////////////////////////////////////////////// // Paging setup #ifndef USE_SAMPLE_TERRAIN page_manager = OGRE_NEW PageManager(); // Since we're not loading any pages from .page files, we need a way just // to say we've loaded them without them actually being loaded page_manager->setPageProvider(&dummy_page_provider); page_manager->addCamera(camera); page_manager->setDebugDisplayLevel(0); terrain_paging = OGRE_NEW TerrainPaging(page_manager); paged_world = page_manager->createWorld(); paged_world_section = terrain_paging->createWorldSection(paged_world, terrain_group, #ifdef USE_SAMPLE_ENDLESSWORLD 400, 500, ENDLESS_PAGE_MIN_X, ENDLESS_PAGE_MIN_Y, ENDLESS_PAGE_MAX_X, ENDLESS_PAGE_MAX_Y); #endif #ifdef USE_SAMPLE_TERRAIN 400, 500, ENDLESS_PAGE_MIN_X, ENDLESS_PAGE_MIN_Y, ENDLESS_PAGE_MAX_X, ENDLESS_PAGE_MAX_Y); //2000, 3000, //TERRAIN_PAGE_MIN_X, TERRAIN_PAGE_MIN_Y, //TERRAIN_PAGE_MAX_X, TERRAIN_PAGE_MAX_Y); #endif #endif #ifdef USE_SAMPLE_ENDLESSWORLD perlin_noise = OGRE_NEW PerlinNoiseTerrainGenerator( 3.3, 2.2, 10, 128, 0.4 ); paged_world_section->setDefiner( perlin_noise ); // paged_world_section->setDefiner( OGRE_NEW SimpleTerrainDefiner ); TerrainGroup::TerrainIterator ti = terrain_group->getTerrainIterator(); while(ti.hasMoreElements()) { Terrain* t = ti.getNext()->instance; initBlendMaps(t); } #endif #ifdef USE_SAMPLE_TERRAIN bool blankTerrain = false; for (long x = TERRAIN_PAGE_MIN_X; x <= TERRAIN_PAGE_MAX_X; ++x) for (long y = TERRAIN_PAGE_MIN_Y; y <= TERRAIN_PAGE_MAX_Y; ++y) defineTerrain(x, y, blankTerrain); // sync load since we want everything in place when we start terrain_group->loadAllTerrains(true); // ^FIXME: // loadAllTerrains does something to our GL context/state, causing wrong output until // OGRE::output called. the error is caused in OgreTerrainGroup::loadTerrainImpl when // a work request is added to Ogre. The request handler is OgreTerrainGroup, but I // have not tracked the error there and further down. if (terrains_imported) { TerrainGroup::TerrainIterator ti = terrain_group->getTerrainIterator(); while(ti.hasMoreElements()) { Terrain* t = ti.getNext()->instance; initBlendMaps(t); } } #endif terrain_group->freeTemporaryResources(); scenemgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); #ifdef USE_SAMPLE_TERRAIN camera->setPosition(terrain_pos + Vector3(1683, 50, 2116)); camera->lookAt(Vector3(1963, 50, 1660)); camera->setNearClipDistance(0.1); camera->setFarClipDistance(50000); #endif #ifdef USE_SAMPLE_ENDLESSWORLD // view Vector3 worldCenter( (ENDLESS_PAGE_MAX_X+ENDLESS_PAGE_MIN_X) / 2 * TERRAIN_WORLD_SIZE, 0, -(ENDLESS_PAGE_MAX_Y+ENDLESS_PAGE_MIN_Y) / 2 * TERRAIN_WORLD_SIZE ); camera->setPosition(terrain_pos +worldCenter); camera->lookAt(terrain_pos); camera->setNearClipDistance(0.1); camera->setFarClipDistance(50000); #endif if (batb.ogre.ogre_root->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) { camera->setFarClipDistance(0); // enable infinite far clip distance if we can } }