void runTerrainDestructionDemo() { isRunning = true; EngineInterface::createEngine("Data/Scripts/config.lua"); EngineInterface::addRenderTask("renderSprites"); EngineInterface::addUpdateTask("performFrustumCulling"); EngineInterface::addGameLoopTask("updateTerrain",updateTerrain); EngineInterface::connectKeyboardAction(Escape,exitTerrainDestructionDemo); EngineInterface::connectMouseAction(LeftButton,fireMissile); FlightCamera* camera = new FlightCamera(Vector3D(0.0f,2000.0f,0.0f),Vector3D(0.0f,0.0f,-1.0f)); EngineInterface::connectKeyboardAction(W,boost::bind(&FlightCamera::moveCameraForward,camera)); EngineInterface::connectMouseMoveAction(boost::bind(&FlightCamera::changeViewTarget,camera,_1,_2)); EngineInterface::addSceneCamera(camera); SceneEntity* terrain = new SceneEntity("Terrain","Terrain","Terrain"); terrain->initializeSceneEntity(); terrain->setEntityPosition(-128.0f*50.0f,0.0f,-128.0f*50.0f); EngineInterface::addIndependentToScene(terrain); SceneEntity* skyDome = new SceneEntity("Sky","SkyDome","SkyDome"); skyDome->initializeSceneEntity(); skyDome->setEntityOrientation(-90.0f,0.0f,0.0f); skyDome->setEntityScale(10000.0f,10000.0f,10000.0f); EngineInterface::addIndependentToScene(skyDome); SceneEntity* flight = new SceneEntity("F16","F16","F16"); flight->initializeSceneEntity(); flight->setEntityScale(0.1f,0.1f,0.1f); flight->setEntityPosition(0.0f,1600.0f,-10.0f); flight->setEntityOrientation(0.0f,180.0f,180.0f); flight->setFunctionUpdating(updateFlight); flight->entityPhysics.velocity.set(20.0f,20.0f,20.0f); flight->entityPhysics.isKinematic = true; EngineInterface::addEntityToScene(flight); Missile* missile = new Missile("Missile","Missile","Missile"); missile->initializeSceneEntity(); missile->setEntityScale(20.0f,20.0f,20.0f); missile->setExtendingUpdating(); missile->entityPhysics.isKinematic = true; missile->entityPhysics.velocity.set(200.0f,200.0f,200.0f); EngineInterface::addEntityToScene(missile); EngineInterface::initializeFont("Font",32); EngineInterface::addSprite("AyumiLogo",Vector3D(-500.0f,-500.0f,0.0f),Vector3D(256.0f,47.0f,0.0f)); EngineInterface::addSprite("Crosshair",Vector3D(0.0f,0.0f,0.0f),Vector3D(64.0f,64.0f,0.0f)); EngineInterface::addDynamicActor(flight,BOX,CollisionFilter::AIRCRAFT,CollisionFilter::TERRAIN); EngineInterface::addDynamicActor(missile,BOX,CollisionFilter::MISSILE,CollisionFilter::TERRAIN); EngineInterface::addCollisionCallback("F16","Terrain",flightCollision); EngineInterface::addCollisionCallback("Missile","Terrain",missileCollision); destruction = EngineInterface::createDestructibleTerrain(terrain,"Data/Mesh/terrainDemo.raw",Vector4D(256.0,50.0,50.0,1500.0),CollisionFilter::TERRAIN,CollisionFilter::MISSILE | CollisionFilter::AIRCRAFT); EngineInterface::runGameLoop(&isRunning); EngineInterface::releaseDestructibleTerrain(destruction); EngineInterface::releaseEngine(); }
void runFrustumCullingDemo() { isRunning = true; visible = 0; EngineInterface::createEngine("Data/Scripts/config.lua"); EngineInterface::addGameLoopTask("Frustum",updateFrustum); EngineInterface::connectKeyboardAction(Escape,exitFrustumDemo); EngineInterface::addUpdateTask("performFrustumCulling"); EngineInterface::addRenderTask("renderSprites"); FreeCamera* camera = new FreeCamera(Vector3D(50.0f,50.0f,50.0f),Vector3D(0.0f,0.0f,1.0f)); camera->setVelocity(100.0f,100.0f,100.0f); camera->setRotateVelocity(10.0f,10.0f,10.0f); EngineInterface::connectKeyboardAction(W,boost::bind(&FreeCamera::moveCameraForward,camera)); EngineInterface::connectKeyboardAction(S,boost::bind(&FreeCamera::moveCameraBack,camera)); EngineInterface::connectKeyboardAction(A,boost::bind(&FreeCamera::rotateCameraLeft,camera)); EngineInterface::connectKeyboardAction(D,boost::bind(&FreeCamera::rotateCameraRight,camera)); EngineInterface::connectKeyboardAction(Q,boost::bind(&FreeCamera::moveCameraUp,camera)); EngineInterface::connectKeyboardAction(E,boost::bind(&FreeCamera::moveCameraDown,camera)); EngineInterface::connectMouseMoveAction(boost::bind(&FreeCamera::changeViewTarget,camera,_1,_2)); EngineInterface::addSceneCamera(camera); for(int i = 0; i < 10; ++i) { for(int j = 0; j < 10; ++j) { for(int k = 0; k < 10; ++k) { SceneEntity* box = new SceneEntity("Box","Box","Box"); box->initializeSceneEntity(); box->setEntityPosition(10.0f*i,10.0f*j,10.0f*k); EngineInterface::addEntityToScene(box); } } } EngineInterface::initializeFont("Font",32); EngineInterface::addText("Message","Visible objects: ",Vector3D(-750.0f,560.0f,0.0f)); EngineInterface::addText("Visible",lexical_cast<string>(visible),Vector3D(-150.0f,560.0f,0.0f)); EngineInterface::addSprite("AyumiLogo",Vector3D(-450.0f,-500.0f,0.0f),Vector3D(256.0f,47.0f,0.0f)); EngineInterface::runGameLoop(&isRunning); EngineInterface::releaseEngine(); }