void FGLRenderer::DrawScene(int drawmode) { static int recursion=0; if (camera != nullptr) { ActorRenderFlags savedflags = camera->renderflags; if (drawmode != DM_PORTAL && !r_showviewer) { camera->renderflags |= RF_INVISIBLE; } CreateScene(); camera->renderflags = savedflags; } else { CreateScene(); } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. RenderScene(recursion); // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; GLPortal::EndFrame(); recursion--; RenderTranslucent(); }
void FGLRenderer::DrawScene(int drawmode) { static int recursion=0; static int ssao_portals_available = 0; bool applySSAO = false; if (drawmode == DM_MAINVIEW) { ssao_portals_available = gl_ssao_portals; applySSAO = true; } else if (drawmode == DM_OFFSCREEN) { ssao_portals_available = 0; } else if (ssao_portals_available > 0) { applySSAO = true; ssao_portals_available--; } if (camera != nullptr) { ActorRenderFlags savedflags = camera->renderflags; CreateScene(); camera->renderflags = savedflags; } else { CreateScene(); } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. RenderScene(recursion); if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS) { gl_RenderState.EnableDrawBuffers(1); AmbientOccludeScene(); mBuffers->BindSceneFB(true); gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount()); gl_RenderState.Apply(); gl_RenderState.ApplyMatrices(); } // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; GLPortal::EndFrame(); recursion--; RenderTranslucent(); }
GeometryShadersWindow::GeometryShadersWindow(Parameters& parameters) : Window3(parameters) { if (!SetEnvironment() || !CreateScene()) { parameters.created = false; return; } mEngine->SetClearColor({ 1.0f, 1.0f, 1.0f, 1.0f }); InitializeCamera(); mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f); Vector4<float> camPosition{ 2.8f, 0.0f, 0.0f, 1.0f }; Vector4<float> camDVector{ -1.0f, 0.0f, 0.0f, 0.0f }; Vector4<float> camUVector{ 0.0f, 0.0f, 1.0f, 0.0f }; Vector4<float> camRVector = Cross(camDVector, camUVector); mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); #if defined(SAVE_RENDERING_TO_DISK) mTarget = std::make_shared<DrawTarget>(1, DF_R8G8B8A8_UNORM, mXSize, mYSize); mTarget->GetRTTexture(0)->SetCopyType(Resource::COPY_STAGING_TO_CPU); #endif }
//---------------------------------------------------------------------------- bool IntersectConvexPolyhedra::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up the camera. mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 1000.0f); APoint camPosition(16.0f, 0.0f, 0.0f); 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); CreateScene(); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(0.01f, 0.001f); InitializeObjectMotion(mScene); return true; }
//---------------------------------------------------------------------------- bool BouncingSpheres::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up the camera. mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f); float angle = 0.02f*Mathf::PI; float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle); APoint camPosition(27.5f, 8.0f, 8.9f); AVector camDVector(-cs, 0.0f, -sn); AVector camUVector(-sn, 0.0f, cs); AVector camRVector = camDVector.Cross(camUVector); mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); CreateScene(); // Initial update of objects. mScene->Update(); // Initialize balls with correct transformations. PhysicsTick(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); return true; }
int main (int argc, char *argv[]) { try { timer mainStartTime = gettimer(); global_window_title = window_title_string (argc, (const char**)argv); argoptions opt = ParseCommandLine(argc, (const char**)argv); if ( CreateScene(opt) != 0 ) return -1; tachyon_video tachyon; tachyon.threaded = true; tachyon.init_console(); tachyon.title = global_window_title; // always using window even if(!global_usegraphics) global_usegraphics = tachyon.init_window(global_xwinsize, global_ywinsize); if(!tachyon.running) return -1; video = &tachyon; tachyon.main_loop(); utility::report_elapsed_time(timertime(mainStartTime, gettimer())); return 0; } catch ( std::exception& e ) { std::cerr<<"error occurred. error text is :\"" <<e.what()<<"\"\n"; return 1; } }
//---------------------------------------------------------------------------- bool BouncingBall::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up the camera. mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f); float angle = 0.1f*Mathf::PI; float cs = Mathf::Cos(angle); float sn = Mathf::Sin(angle); APoint camPosition(6.75f, 0.0f, 2.3f); AVector camDVector(-cs, 0.0f, -sn); AVector camUVector(-sn, 0.0f, cs); AVector camRVector = camDVector.Cross(camUVector); mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); CreateScene(); // Initial update of objects. mScene->Update(); mBallNode->Update(); // Initialize ball with correct transformations. PhysicsTick(); mSimTime = 0.0f; // All objects are visible. mSceneVisibleSet.Insert(mWall); mBallNodeVisibleSet.Insert(mBall->GetMesh()); InitializeCameraMotion(0.1f, 0.01f); return true; }
BOOL CSceneManager::OnCmdCreateSceneReq( UINT16 wCommandID, UINT64 u64ConnID, CBufferHelper *pBufferHelper ) { StSvrCreateSceneReq CreateSceneReq; pBufferHelper->Read(CreateSceneReq); StSvrCreateSceneAck CreateSceneAck; CreateSceneAck.dwCreateParam = CreateSceneReq.CreateParam; CreateSceneAck.dwSceneID = CreateSceneReq.dwSceneID; CreateSceneAck.dwServerID= CGameService::GetInstancePtr()->GetServerID(); if (!CreateScene(CreateSceneReq.dwSceneID)) { ASSERT_FAIELD; CreateSceneAck.dwAckCode = E_FAILED; } else { CreateSceneAck.dwAckCode = E_SUCCESSED; } CBufferHelper WriteHelper(TRUE, &m_WriteBuffer); WriteHelper.BeginWrite(CMD_SVR_CREATE_SCENE_ACK, 0, 0); WriteHelper.Write(CreateSceneAck); WriteHelper.EndWrite(); ServiceBase::GetInstancePtr()->SendCmdToConnection(u64ConnID, &m_WriteBuffer); return TRUE; }
//---------------------------------------------------------------------------- bool RoughPlaneSolidBox::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up the camera. mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 100.0f); float angle = 0.1f*Mathf::PI; float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle); APoint camPosition(17.695415f, 0.0f, 6.4494629f); AVector camDVector(-cs, 0.0f, -sn); AVector camUVector(-sn, 0.0f, cs); AVector camRVector = camDVector.Cross(camUVector); mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); InitializeModule(); CreateScene(); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(0.001f, 0.001f); InitializeObjectMotion(mScene); return true; }
//---------------------------------------------------------------------------- bool ExtremalQuery::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up an orthogonal camera. This projection type is used to make it // clear that the displayed extreme points really are extreme! (The // perspective projection is deceptive.) mCamera = new0 Camera(false); mRenderer->SetCamera(mCamera); mCamera->SetFrustum(1.0f, 1000.0f, -1.5f, 1.5f, -2.0, 2.0f); APoint camPosition(4.0f, 0.0f, 0.0f); 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); // Set up the scene. CreateScene(); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeObjectMotion(mScene); return true; }
//---------------------------------------------------------------------------- bool ShadowMaps::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up the camera. mCamera->SetFrustum(60.0f, 1.0f, 0.1f, 100.0f); APoint camPosition(8.0f, 0.0f, 4.0f); AVector camDVector = APoint::ORIGIN - camPosition; // look at origin camDVector.Normalize(); AVector camUVector(camDVector[2], 0, -camDVector[0]); AVector camRVector(0.0f, 1.0f, 0.0f); mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); CreateScene(); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(0.01f, 0.001f); InitializeObjectMotion(mScene); return true; }
//---------------------------------------------------------------------------- bool NonuniformScale::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up the camera. mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 100.0f); float cs = 0.866025f, sn = 0.5f; APoint camPosition(0.0f, -4.0f, 2.0f); AVector camDVector(0.0f, cs, -sn); AVector camUVector(0.0f, sn, cs); AVector camRVector = camDVector.Cross(camUVector); mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); CreateScene(); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(0.01f, 0.001f); InitializeObjectMotion(mScene); return true; }
ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent) : QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), parent) , m_Light() , m_World() , m_GlView() , m_MoverController() , m_ModelBoundingBox() , m_MotionTimer() , acFilename() , bgFilename() , vboEnable(false) { connect(&m_GlView, SIGNAL(updateOpenGL()), this, SLOT(updateGL())); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_Light.setPosition(4000.0, 40000.0, 80000.0); // m_GlView.setBackgroundColor(Qt::white); m_Light.setAmbientColor(Qt::lightGray); m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS); m_GlView.cameraHandle()->setRearView(); QColor repColor; repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0); m_MoverController = GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView); CreateScene(); // Get required UAVObjects ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); attState = AttitudeActual::GetInstance(objManager); connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude())); }
//---------------------------------------------------------------------------- PerformanceAMDWindow::PerformanceAMDWindow(Parameters& parameters) : Window(parameters), mTextColor({ 0.0f, 0.0f, 0.0f, 1.0f }), mPerformance(mEngine->GetDevice()) { if (!SetEnvironment()) { parameters.created = false; return; } CreateCamera(); CreateTextureGenerator(); CreateScene(); // Disable back-face culling. mNoCullingState.reset(new RasterizerState()); mNoCullingState->cullMode = RasterizerState::CULL_NONE; mEngine->SetRasterizerState(mNoCullingState); mPerformance.SaveCounterInformation("AMD7970Counters.txt"); mPerformance.Register(Listener); mPerformance.SetAllCounters(); UpdateCW(); }
//---------------------------------------------------------------------------- bool GelatinCube::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } CreateScene(); // Center-and-fit for camera viewing. mScene->Update(); mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter()); mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f); AVector camDVector(0.0f, 1.0f, 0.0f); AVector camUVector(0.0f, 0.0f, 1.0f); AVector camRVector = camDVector.Cross(camUVector); APoint camPosition = APoint::ORIGIN - 2.0f*mScene->WorldBound.GetRadius()*camDVector; mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); // Sort the box faces based on current camera parameters. mBox->SortFaces(mCamera->GetDVector()); InitializeCameraMotion(0.01f, 0.001f); InitializeObjectMotion(mScene); return true; }
//---------------------------------------------------------------------------- bool Terrains::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up the camera. Position the camera in the middle of page[0][0]. // Orient it to look diagonally across the terrain pages. mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1500.0f); APoint camPosition(64.0f, 64.0f, mHeightAboveTerrain); AVector camDVector(Mathf::INV_SQRT_2, Mathf::INV_SQRT_2, 0.0f); AVector camUVector(0.0f, 0.0f, 1.0f); AVector camRVector = camDVector.Cross(camUVector); mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); CreateScene(); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(1.0f, 0.01f); MoveForward(); return true; }
BSplineSurfaceFitterWindow::BSplineSurfaceFitterWindow(Parameters& parameters) : Window3(parameters) { if (!SetEnvironment()) { parameters.created = false; return; } mNoCullState = std::make_shared<RasterizerState>(); mNoCullState->cullMode = RasterizerState::CULL_NONE; mNoCullWireState = std::make_shared<RasterizerState>(); mNoCullWireState->cullMode = RasterizerState::CULL_NONE; mNoCullWireState->fillMode = RasterizerState::FILL_WIREFRAME; mBlendState = std::make_shared<BlendState>(); mBlendState->target[0].enable = true; mBlendState->target[0].srcColor = BlendState::BM_SRC_ALPHA; mBlendState->target[0].dstColor = BlendState::BM_INV_SRC_ALPHA; mBlendState->target[0].srcAlpha = BlendState::BM_SRC_ALPHA; mBlendState->target[0].dstAlpha = BlendState::BM_INV_SRC_ALPHA; mEngine->SetRasterizerState(mNoCullState); mEngine->SetClearColor({ 0.0f, 0.5f, 0.75f, 1.0f }); CreateScene(); InitializeCamera(); }
int main (int argc, char *argv[]) { try { if ( CreateScene() != 0 ) return -1; tachyon_video tachyon; tachyon.threaded = true; tachyon.init_console(); global_usegraphics = tachyon.init_window(global_xwinsize, global_ywinsize); if(!tachyon.running) return -1; //TODO: add a demo loop. video = &tachyon; if (video)video->running = true; memset(g_pImg, 0, sizeof(unsigned int) * global_xsize * global_ysize); tachyon.main_loop(); video->running=false; return NULL; } catch ( std::exception& e ) { std::cerr<<"error occurred. error text is :\"" <<e.what()<<"\"\n"; return 1; } }
//---------------------------------------------------------------------------- bool DefaultShader::OnInitialize() { if( !SEWindowApplication3::OnInitialize() ) { return false; } m_spCamera->SetFrustum(-0.55f, 0.55f, -0.4125f, 0.4125f, 1.0f, 100.0f); SEVector3f tempCLoc(0.0f, 0.0f, -10.0f); SEVector3f tempCDir(0.0f, 0.0f, 1.0f); SEVector3f tempCUp(0.0f, 1.0f, 0.0f); SEVector3f tempCRight = tempCUp.Cross(tempCDir); m_spCamera->SetFrame(tempCLoc, tempCRight, tempCUp, tempCDir); CreateScene(); // initial update of objects m_spScene->UpdateGS(); m_spScene->UpdateRS(); // initial culling of scene m_Culler.SetCamera(m_spCamera); m_Culler.ComputeUnculledSet(m_spScene); InitializeCameraMotion(0.01f, 0.001f); InitializeObjectMotion(m_spScene); return true; }
ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent) : QGLWidget(new GLC_Context(QGLFormat(QGL::SampleBuffers)), parent) , m_Light() , m_World() , m_GlView(this) , m_MoverController() , m_ModelBoundingBox() , m_MotionTimer() , acFilename() , bgFilename() , vboEnable(false) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); CreateScene(); QColor repColor; repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0); m_MoverController = GLC_Factory::instance()->createDefaultMoverController(repColor, &m_GlView); // Get required UAVObjects ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); attActual = AttitudeActual::GetInstance(objManager); connect(&m_MotionTimer, SIGNAL(timeout()), this, SLOT(updateAttitude())); }
void VkRenderBuffers::BeginFrame(int width, int height, int sceneWidth, int sceneHeight) { VkSampleCountFlagBits samples = GetBestSampleCount(); if (width != mWidth || height != mHeight || mSamples != samples) { auto fb = GetVulkanFrameBuffer(); fb->GetRenderPassManager()->RenderBuffersReset(); fb->GetPostprocess()->RenderBuffersReset(); } if (width != mWidth || height != mHeight) CreatePipeline(width, height); if (width != mWidth || height != mHeight || mSamples != samples) CreateScene(width, height, samples); CreateShadowmap(); mWidth = width; mHeight = height; mSamples = samples; mSceneWidth = sceneWidth; mSceneHeight = sceneHeight; }
//---------------------------------------------------------------------------- bool ConvexHull3D::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // The scene creation involves culling, so mCuller needs to know its // camera now. mCuller.SetCamera(mCamera); CreateScene(); // Center-and-fit for camera viewing. mScene->Update(); mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter()); mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 10000.0f); AVector camDVector(0.0f, 0.0f, 1.0f); AVector camUVector(0.0f, 1.0f, 0.0f); AVector camRVector = camDVector.Cross(camUVector); APoint camPosition = APoint::ORIGIN - 2.5f*mScene->WorldBound.GetRadius()*camDVector; mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(1.0f, 0.01f); InitializeObjectMotion(mScene); return true; }
//---------------------------------------------------------------------------- bool Rope::OnInitialize () { if ( !Application::OnInitialize() ) return false; CreateScene(); // center-and-fit for camera viewing m_spkScene->UpdateGS(0.0f); Bound kWBound = m_spkScene->WorldBound(); m_spkTrnNode->Translate() = -kWBound.Center(); ms_spkCamera->SetFrustum(1.0f,100.0f,-0.55f,0.55f,0.4125f,-0.4125f); Vector3f kCLeft(1.0f,0.0f,0.0f); Vector3f kCUp(0.0f,0.0f,1.0f); Vector3f kCDir(0.0f,-1.0f,0.0f); Vector3f kCLoc = -3.0f*kWBound.Radius()*kCDir - 0.5f*kCUp; ms_spkCamera->SetFrame(kCLoc,kCLeft,kCUp,kCDir); // initial update of objects ms_spkCamera->Update(); m_spkScene->UpdateGS(0.0f); m_spkScene->UpdateRS(); // camera turret and tumble mode m_spkMotionObject = m_spkScene; m_fTrnSpeed = 0.01f; m_fRotSpeed = 0.01f; m_bTurretActive = true; SetTurretAxes(); return true; }
int _tmain(int argc, _TCHAR* argv[]) { osgDB::FilePathList filepath; char* ptr = getenv( "SIGMAOSG_DATA_PATH" ); if ( ptr ) { osgDB::convertStringPathIntoFilePathList( ptr, filepath ); osgDB::appendPlatformSpecificResourceFilePaths(filepath); osgDB::setDataFilePathList(filepath); } // construct the viewer osg::ref_ptr<osgViewer::Viewer> rViewer = new osgViewer::Viewer; rViewer->setThreadingModel( osgViewer::ViewerBase::SingleThreaded ); rViewer->setUpViewInWindow( 32, 32, 800, 600 ); osg::Group* pScene = CreateScene( rViewer ); rViewer->setSceneData( pScene ); // execute main loop return rViewer->run(); }
//---------------------------------------------------------------------------- bool WaterDropFormation::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } CreateScene(); // Center-and-fit for camera viewing. mScene->Update(); mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter()); mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 1000.0f); float angle = 0.01f*Mathf::PI; float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle); AVector camDVector(-cs, 0.0f, -sn); AVector camUVector(sn, 0.0f, -cs); AVector camRVector = camDVector.Cross(camUVector); APoint camPosition = APoint::ORIGIN - 0.9f*mScene->WorldBound.GetRadius()*camDVector; mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); // Initial update of objects. mScene->Update(); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(0.01f, 0.001f); InitializeObjectMotion(mScene); mLastSeconds = (float)GetTimeInSeconds(); return true; }
Delaunay3DWindow::Delaunay3DWindow(Parameters& parameters) : Window3(parameters), mLightGray({ 0.75f, 0.75f, 0.75f, 1.0f }) { if (!SetEnvironment() || !CreateScene()) { parameters.created = false; return; } InitializeCamera(); mNoCullState = std::make_shared<RasterizerState>(); mNoCullState->cullMode = RasterizerState::CULL_NONE; mNoCullWireState = std::make_shared<RasterizerState>(); mNoCullWireState->cullMode = RasterizerState::CULL_NONE; mNoCullWireState->fillMode = RasterizerState::FILL_WIREFRAME; mBlendState = std::make_shared<BlendState>(); mBlendState->target[0].enable = true; mBlendState->target[0].srcColor = BlendState::BM_SRC_ALPHA; mBlendState->target[0].dstColor = BlendState::BM_INV_SRC_ALPHA; mBlendState->target[0].srcAlpha = BlendState::BM_SRC_ALPHA; mBlendState->target[0].dstAlpha = BlendState::BM_INV_SRC_ALPHA; }
//---------------------------------------------------------------------------- bool SphereMaps::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } CreateScene(); // Center-and-fit for camera viewing. mScene->Update(); mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter()); mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f); AVector camDVector(0.0f, 1.0f, 0.0f); AVector camUVector(0.0f, 0.0f, 1.0f); AVector camRVector = camDVector.Cross(camUVector); APoint camPosition = APoint::ORIGIN - 3.0f*mScene->WorldBound.GetRadius()*camDVector; mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector); // Initial update of objects. mScene->Update(); CopyNormalToTCoord1(mScene); // Initial culling of scene. mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(0.001f, 0.001f); InitializeObjectMotion(mScene); return true; }
//---------------------------------------------------------------------------- bool ScreenPolygons::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } CreateScene(); // Set up the camera. mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f); APoint camPosition(80.0f, 0.0f, 23.0f); 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); // Initial update of objects. mScene->Update(); mCuller.SetCamera(mCamera); mCuller.ComputeVisibleSet(mScene); InitializeCameraMotion(0.01f, 0.01f); InitializeObjectMotion(mScene); return true; }
//---------------------------------------------------------------------------- bool ReflectionsAndShadows::OnInitialize () { if (!WindowApplication3::OnInitialize()) { return false; } // Set up the camera. mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f); APoint camPosition(180.0f, 0.0f, 23.0f); 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); CreateScene (); // Initial update of objects. mScene->Update(); mBiped->Update(mUpdateTime); // Initial culling of scene, mSceneCuller.SetCamera(mCamera); mSceneCuller.ComputeVisibleSet(mScene); mBipedCuller.SetCamera(mCamera); mBipedCuller.ComputeVisibleSet(mBiped); InitializeCameraMotion(0.1f, 0.01f); InitializeObjectMotion(mScene); return true; }
//////////////////////////////////////////////////////////////////////// // Called by GLut when there are keyboard messages. void KeyboardInput(unsigned char key, int, int) { switch(key) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': sceneID = key - '0'; scene.Clear(); CreateScene(scene); PreprocessScene(scene); glutIdleFunc(&Update); break; case 'g': scene.UseOpenGLRendering = !scene.UseOpenGLRendering; glutIdleFunc(&Update); break; case 'a': scene.UseAntiAliasing = !scene.UseAntiAliasing; glutIdleFunc(&Update); break; case 27: // Escape key case 'q': exit(EXIT_SUCCESS); } }