void DemoApp::RenderMiniWindow() { //Set Buffers, Layout, Topology and Render States UINT stride = sizeof(Vertex::VertexPNT); UINT offset = 0; md3dImmediateContext->IASetVertexBuffers(0, 1, &m_pScreenQuadVB, &stride, &offset); md3dImmediateContext->IASetIndexBuffer(m_pScreenQuadIB, DXGI_FORMAT_R32_UINT, 0); md3dImmediateContext->IASetInputLayout(InputLayouts::VertexPNT); md3dImmediateContext->RSSetState(RenderStates::NoCullRS); //Resize mini window and translate to upper left corner XMMATRIX scale = XMMatrixScaling(1.0f / AspectRatio(), 1.0f, 1.0f); XMMATRIX world = XMMATRIX( 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.25 / AspectRatio() - 1, 0.75f, 0.0f, 1.0f); CBPerFrameScreenQuad cbScreenQuadPerFrame; cbScreenQuadPerFrame.wvp = XMMatrixTranspose(scale * world); md3dImmediateContext->UpdateSubresource(m_pCBPerFrameScreenQuad, 0, NULL, &cbScreenQuadPerFrame, 0, 0); md3dImmediateContext->VSSetShader(m_pDebugTextureVS, NULL, 0); md3dImmediateContext->VSSetConstantBuffers(0, 1, &m_pCBPerFrameScreenQuad); md3dImmediateContext->PSSetShader(m_pDebugTexturePS, NULL, 0); md3dImmediateContext->PSSetShaderResources(0, 1, &m_pDepthSRV); md3dImmediateContext->PSSetSamplers(0, 1, &m_pSampleLinear); md3dImmediateContext->DrawIndexed(6, 0, 0); }
void DuckHuntMain::OnScroll(WPARAM btnState) { SetCapture(mhMainWnd); if (btnState == WHEEL_DELTA) { if (zoom != 0.25) { zoom -= 0.25; mCam.ChangeZoom(zoom, AspectRatio()); } } else if (btnState > WHEEL_DELTA) { if (zoom != 1) { zoom += 0.25; mCam.ChangeZoom(zoom, AspectRatio()); } } ReleaseCapture(); }
void wam::OnResize() { D3DApp::OnResize(); XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); mCam.SetLens(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); XMStoreFloat4x4(&mProj, P); }
void TextureDemo::OnResize() { D3DApp::OnResize(); m_proj = XMMatrixPerspectiveFovLH(0.25f * MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); }
void Simulation::OnResize() { Game::OnResize(); m_Camera.SetLens(0.25f * 3.1415926535f, AspectRatio(), 0.1f, 200.0f); XMStoreFloat4x4(&(matrixBufferData.projection), XMMatrixTranspose(m_Camera.Proj())); }
void InitDirect3DApp::OnResize() { D3DApp::OnResize(); XMMATRIX newProjMtx = XMMatrixPerspectiveFovLH(0.25f * PI, AspectRatio(), 1.0f, 1000.0f); projMtx = newProjMtx; }
void DuckHuntMain::OnMouseDown(WPARAM btnState, int x, int y) { mLastMousePos.x = x; mLastMousePos.y = y; if ((btnState & MK_RBUTTON) != 0) { mZoomed = true; zoom = 1; mCam.Zoom(AspectRatio()); } if ((btnState & MK_LBUTTON) != 0) { result = mSystem->playSound(mGunFire, 0, false, &channel); pickedModel = pick(mScreenViewport.Width / 2, mScreenViewport.Height / 2, mModelInstances); if (pickedModel != -1) { score++; mModelInstances.erase(mModelInstances.begin() + pickedModel); } } SetCapture(mhMainWnd); }
void LightSkull::OnResize() { D3DApp::OnResize(); m_proj = XMMatrixPerspectiveFovLH(0.25f * MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); }
void SuperSolarSystemApp::OnResize( ) { D3dBase::OnResize( ); // 当窗口大小调整的时候, 重新计算宽高比和更新投影矩阵 mCamera.SetProj( 0.25f*MathHelper::Pi, AspectRatio( ), 1.0f, 5000.0f ); }
void Box::OnResize() { D3DApp::OnResize(); m_proj = XMMatrixPerspectiveFovLH((float)0.25f*XM_PI, AspectRatio(), 1.0f, 1000.0f); }
void BoxApp::OnResize() { D3DApp::OnResize(); // The window resized, so update the aspect ratio and recompute the projection matrix. XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); XMStoreFloat4x4(&mProj, P); }
void SpotlightSample::InitializeCamera() { mCamera.mTransform = new Transform(); mCamera.mTransform->mPosition = { 0, 50, -50 }; mCamera.mTransform->RotatePitch(XMConvertToRadians(45.f)); mCamera.Update(); mCamera.UpdateProjection(0.25f * 3.1415926535f, AspectRatio(), 0.1f, 100.0f); }
void InstancingAndCullingApp::OnResize() { D3DApp::OnResize(); mCam.SetLens(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); // Build the frustum from the projection matrix in view space. ComputeFrustumFromProjection(&mCamFrustum, &mCam.Proj()); }
void Assignment5::OnResize() { D3DApp::OnResize(); // The window resized, so update the aspect ratio and recompute the projection matrix. XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); XMStoreFloat4x4(&mProj, P); m_Phone.resizeScreen(XMFLOAT2(static_cast<float>(mClientWidth), static_cast<float>(mClientHeight)), md3dDevice); }
void Projekt::OnResize() { D3D11App::OnResize(); //mPlayer.GetCamera()->setLens(0.25f*MathHelper::pi, AspectRatio(), 1.0f, 1000.0f); mPlayer.GetCamera()->setLens(0.25f*MathHelper::pi, AspectRatio(), 1.0f, 1000.0f); // Build the frustum from the projection matrix in view space ComputeFrustumFromProjection(&mCamFrustum, &mPlayer.GetCamera()->getProjMatrix()); }
void DuckHuntMain::OnResize() { D3DApp::OnResize(); mCam.SetLens(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); if (mSsao) { mSsao->OnSize(mClientWidth, mClientHeight, mCam.GetFovY(), mCam.GetFarZ()); } }
void InClassProj::OnResize() { D3DApp::OnResize(); // The window resized, so update the aspect ratio and recompute the projection matrix. XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); XMStoreFloat4x4(&mProj, P); P = XMMatrixOrthographicOffCenterLH(0.0f, mClientWidth, 0.0f, mClientHeight, 0.0001f, 1000.0f); XMStoreFloat4x4(&m2DProj, P); }
// Handles resizing the window and updating our projection matrix to match void MyDemoGame::OnResize() { // Handle base-level DX resize stuff DirectXGame::OnResize(); wind->windowWidth = windowWidth; wind->windowHeight = windowHeight; // Update our projection matrix since the window size changed XMMATRIX P = XMMatrixPerspectiveFovLH( 0.25f * 3.1415926535f, AspectRatio(), 0.1f, 50); XMStoreFloat4x4(&projectionMatrix, XMMatrixTranspose(P)); }
void CubeMap::OnResize(){ WinApp::OnResize(); m_camera.setProjParam(0.25 * XM_PI, AspectRatio(), 1.0f, 1000.0f); }
// Initialize GLUT & OpenSG and set up the scene int main(int argc, char **argv) { // OSG init osgInit(argc,argv); getDefaultVideoManager()->init(argc, argv); TheVideo = getDefaultVideoManager()->createVideoWrapper(); TutorialVideoListener TheVideoListener; TheVideo->addVideoListener(&TheVideoListener); //TheVideo->open(Path("./Data/ExampleVideo.avi")); TheVideo->open(Path("./Data/ExampleVideo.avi")); TheVideo->pause(); // GLUT init int winid = setupGLUT(&argc, argv); // the connection between GLUT and OpenSG GLUTWindowPtr gwin= GLUTWindow::create(); gwin->setId(winid); gwin->init(); // create the scene TheVideo->updateImage(); Real32 AspectRatio(static_cast<Real32>(TheVideo->getImage()->getWidth())/static_cast<Real32>(TheVideo->getImage()->getHeight())); MaterialPtr VideoMaterial = createVideoMaterial(); //Plane Geometry GeometryPtr PlaneGeometry = makePlaneGeo(10.0*AspectRatio,10.0,10,10); beginEditCP(PlaneGeometry, Geometry::MaterialFieldMask); PlaneGeometry->setMaterial(VideoMaterial); endEditCP(PlaneGeometry, Geometry::MaterialFieldMask); NodePtr PlaneGeometryNode = Node::create(); beginEditCP(PlaneGeometryNode, Node::CoreFieldMask); PlaneGeometryNode->setCore(PlaneGeometry); endEditCP(PlaneGeometryNode, Node::CoreFieldMask); //Box Geometry GeometryPtr BoxGeometry = makeBoxGeo(10.0*AspectRatio,10.0,10.0,2,2,2); beginEditCP(BoxGeometry, Geometry::MaterialFieldMask); BoxGeometry->setMaterial(VideoMaterial); endEditCP(BoxGeometry, Geometry::MaterialFieldMask); NodePtr BoxGeometryNode = Node::create(); beginEditCP(BoxGeometryNode, Node::CoreFieldMask); BoxGeometryNode->setCore(BoxGeometry); endEditCP(BoxGeometryNode, Node::CoreFieldMask); //Sphere Geometry GeometryPtr SphereGeometry = makeSphereGeo(2,5.0); beginEditCP(SphereGeometry, Geometry::MaterialFieldMask); SphereGeometry->setMaterial(VideoMaterial); endEditCP(SphereGeometry, Geometry::MaterialFieldMask); NodePtr SphereGeometryNode = Node::create(); beginEditCP(SphereGeometryNode, Node::CoreFieldMask); SphereGeometryNode->setCore(SphereGeometry); endEditCP(SphereGeometryNode, Node::CoreFieldMask); //Torus Geometry GeometryPtr TorusGeometry = makeTorusGeo(2.0,5.0,32,32); beginEditCP(TorusGeometry, Geometry::MaterialFieldMask); TorusGeometry->setMaterial(VideoMaterial); endEditCP(TorusGeometry, Geometry::MaterialFieldMask); NodePtr TorusGeometryNode = Node::create(); beginEditCP(TorusGeometryNode, Node::CoreFieldMask); TorusGeometryNode->setCore(TorusGeometry); endEditCP(TorusGeometryNode, Node::CoreFieldMask); //Switch Node GeometryNodeSwitch = Switch::create(); beginEditCP(GeometryNodeSwitch, Switch::ChoiceFieldMask); GeometryNodeSwitch->setChoice(0); endEditCP(GeometryNodeSwitch, Switch::ChoiceFieldMask); SwitchNode = Node::create(); beginEditCP(SwitchNode, Node::CoreFieldMask | Node::ChildrenFieldMask); SwitchNode->setCore(GeometryNodeSwitch); SwitchNode->addChild(PlaneGeometryNode); SwitchNode->addChild(BoxGeometryNode); SwitchNode->addChild(SphereGeometryNode); SwitchNode->addChild(TorusGeometryNode); endEditCP(SwitchNode, Node::CoreFieldMask | Node::ChildrenFieldMask); NodePtr scene = Node::create(); trans = Transform::create(); beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask); { scene->setCore(trans); scene->addChild(SwitchNode); } endEditCP (scene, Node::CoreFieldMask | Node::ChildrenFieldMask); // To check OpenGL extensions, the Window needs to have run through // frameInit at least once. This automatically happens when rendering, // but we don't don't to wait for that here. gwin->activate(); gwin->frameInit(); // Now we can check for OpenGL extensions hasNPOT = gwin->hasExtension("GL_ARB_texture_rectangle"); // Print what we've got SLOG << "Got " << (isPOT?"":"non-") << "power-of-two images and " << (hasNPOT?"can":"cannot") << " use NPOT textures, changing " << (changeOnlyPart?"part":"all") << " of the screen" << endLog; // create the SimpleSceneManager helper mgr = new SimpleSceneManager; // tell the manager what to manage mgr->setWindow(gwin ); mgr->setRoot (scene); mgr->setStatistics(true); // show the whole scene mgr->showAll(); //Start playing video TheVideo->play(); // GLUT main loop glutMainLoop(); //DeInit TheVideo->stop(); TheVideo->close(); getDefaultVideoManager()->exit(); osgExit(); return 0; }
void TextureWave::OnResize() { D3DApp::OnResize(); m_proj = XMMatrixPerspectiveFovLH(0.25f * XM_PI, AspectRatio(), 1.0f, 1000.0f); }
void AmbientOcclusionApp::OnResize() { D3DApp::OnResize(); mCam.SetLens(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); }
int main(int argc, char **argv) { // OSG init osgInit(argc,argv); { // Set up Window WindowEventProducerRecPtr TutorialWindow = createNativeWindow(); TutorialWindow->initWindow(); // Create the SimpleSceneManager helper SimpleSceneManager sceneManager; TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager)); TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager)); //Attach to events TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager)); TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager)); TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager)); TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager)); // Tell the Manager what to manage sceneManager.setWindow(TutorialWindow); VideoWrapperRecPtr TheVideo = getDefaultVideoManager()->createVideoWrapper(); TheVideo->attachUpdateProducer(TutorialWindow); TheVideo->connectStarted(boost::bind(handleVideoStarted, _1)); TheVideo->connectPaused(boost::bind(handleVideoPaused, _1)); TheVideo->connectUnpaused(boost::bind(handleVideoUnpaused, _1)); TheVideo->connectStopped(boost::bind(handleVideoStopped, _1)); TheVideo->connectClosed(boost::bind(handleVideoClosed, _1)); TheVideo->connectSeeked(boost::bind(handleVideoSeeked, _1)); TheVideo->connectCycled(boost::bind(handleVideoCycled, _1)); TheVideo->connectOpened(boost::bind(handleVideoOpened, _1)); TheVideo->connectEnded(boost::bind(handleVideoEnded, _1)); BoostPath VideoFilePath("./Data/ExampleVideo.avi"); if(argc >= 2) { VideoFilePath = BoostPath(argv[1]); if(!boost::filesystem::exists(VideoFilePath)) { std::cerr << "Could not load file: "<< VideoFilePath.string() << ", because no such files exists."<< std::endl; VideoFilePath = BoostPath("./Data/ExampleVideo.avi"); } } TheVideo->open(VideoFilePath, TutorialWindow); TheVideo->pause(); if(TheVideo->hasAudio()) { TheVideo->enableAudio(); TheVideo->setAudioVolume(0.5f); } //Wait for the video to initialize std::cout << "Dimensions: " << TheVideo->getWidth() << "x" << TheVideo->getHeight() << std::endl; Real32 AspectRatio(static_cast<Real32>(TheVideo->getWidth())/static_cast<Real32>(TheVideo->getHeight())); //Real32 AspectRatio(4.0f/3.0f); // Set filtering modes. LINEAR is cheap and good if the image size // changes very little (i.e. the window is about the same size as // the images). //TheVideo->setMinFilter(GL_LINEAR); TheVideo->setMinFilter(GL_NEAREST); TheVideo->setMagFilter(GL_LINEAR); //TheVideo->setMagFilter(GL_NEAREST); // Set the wrapping modes. We don't need repetition, it might actually // introduce artifactes at the borders, so switch it off. TheVideo->setWrapS(GL_CLAMP_TO_EDGE); TheVideo->setWrapT(GL_CLAMP_TO_EDGE); TheVideo->setScale(false); ChunkMaterialUnrecPtr VideoMaterial = ChunkMaterial::create(); VideoMaterial->addChunk(TheVideo); StateChunkUnrecPtr pMChunk = MaterialChunk::create(); VideoMaterial->addChunk(pMChunk); // create the scene //Plane Geometry GeometryRecPtr PlaneGeometry = makePlaneGeo(10.0*AspectRatio,10.0,10,10); PlaneGeometry->setMaterial(VideoMaterial); NodeRecPtr PlaneGeometryNode = Node::create(); PlaneGeometryNode->setCore(PlaneGeometry); //Box Geometry GeometryRecPtr BoxGeometry = makeBoxGeo(10.0*AspectRatio,10.0,10.0,2,2,2); BoxGeometry->setMaterial(VideoMaterial); NodeRecPtr BoxGeometryNode = Node::create(); BoxGeometryNode->setCore(BoxGeometry); //Sphere Geometry GeometryRecPtr SphereGeometry = makeSphereGeo(2,5.0); SphereGeometry->setMaterial(VideoMaterial); NodeRecPtr SphereGeometryNode = Node::create(); SphereGeometryNode->setCore(SphereGeometry); //Torus Geometry GeometryRecPtr TorusGeometry = makeTorusGeo(2.0,5.0,32,32); TorusGeometry->setMaterial(VideoMaterial); NodeRecPtr TorusGeometryNode = Node::create(); TorusGeometryNode->setCore(TorusGeometry); //Switch Node SwitchRecPtr GeometryNodeSwitch = Switch::create(); GeometryNodeSwitch->setChoice(0); NodeRecPtr SwitchNode = Node::create(); SwitchNode->setCore(GeometryNodeSwitch); SwitchNode->addChild(PlaneGeometryNode); SwitchNode->addChild(BoxGeometryNode); SwitchNode->addChild(SphereGeometryNode); SwitchNode->addChild(TorusGeometryNode); NodeRecPtr scene = Node::create(); TransformRecPtr trans = Transform::create(); scene->setCore(trans); scene->addChild(SwitchNode); TutorialWindow->connectKeyTyped(boost::bind(handleKeyTyped, _1, TheVideo.get(), GeometryNodeSwitch.get())); sceneManager.setRoot(scene); // Show the whole Scene sceneManager.showAll(); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "01PlayVideo"); commitChanges(); //Enter main Loop TutorialWindow->mainLoop(); } osgExit(); return 0; }
bool DuckHuntMain::Init() { if (!D3DApp::Init()) return false; // Must init Effects first since InputLayouts depend on shader signatures. Effects::InitAll(md3dDevice); InputLayouts::InitAll(md3dDevice); RenderStates::InitAll(md3dDevice); mCrosshair = new Crosshair(md3dDevice); mTexMgr.Init(md3dDevice); DuckHuntMain::ShowCursors(false); mSky = new Sky(md3dDevice, L"Textures/desertcube1024.dds", 5000.0f); mSmap = new ShadowMap(md3dDevice, SMapSize, SMapSize); Terrain::InitInfo tii; tii.HeightMapFilename = L"Textures/myT5.raw"; tii.LayerMapFilename0 = L"Textures/grass.dds"; tii.LayerMapFilename1 = L"Textures/darkdirt.dds"; tii.LayerMapFilename2 = L"Textures/stone.dds"; tii.LayerMapFilename3 = L"Textures/lightdirt.dds"; tii.LayerMapFilename4 = L"Textures/snow.dds"; tii.BlendMapFilename = L"Textures/blend.dds"; tii.HeightScale = 50.0f; tii.HeightmapWidth = 2049; tii.HeightmapHeight = 2049; tii.CellSpacing = 0.5f; mTerrain.Init(md3dDevice, md3dImmediateContext, tii); //Sound result = FMOD::System_Create(&mSystem); result = mSystem->init(32, FMOD_INIT_NORMAL, 0); result = mSystem->createSound("Sounds/GunFire.wav", FMOD_DEFAULT, 0, &mGunFire); result = mGunFire->setMode(FMOD_LOOP_OFF); mCam.SetLens(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); mSsao = new Ssao(md3dDevice, md3dImmediateContext, mClientWidth, mClientHeight, mCam.GetFovY(), mCam.GetFarZ()); BuildScreenQuadGeometryBuffers(); testModelDuck = new BasicModel(md3dDevice, mTexMgr, "Models\\duck.obj", L"Textures\\DUCK.jpg"); BasicModelInstance testInstanceDuck; BasicModelInstance testInstanceDuck2; BasicModelInstance testInstanceDuck3; BasicModelInstance testInstanceDuck4; testInstanceDuck.Model = testModelDuck; testInstanceDuck2.Model = testModelDuck; testInstanceDuck3.Model = testModelDuck; testInstanceDuck4.Model = testModelDuck; //Duck 1 XMMATRIX modelScale = XMMatrixScaling(1.0f, 1.0f, -1.0f); XMMATRIX modelRot = XMMatrixRotationY(0.0f); XMMATRIX modelOffset = XMMatrixTranslation(0.0f, 0.0f, 0.0f); //Duck 2 XMMATRIX modelScale2 = XMMatrixScaling(2.0f, 2.0f, -1.0f); XMMATRIX modelRot2 = XMMatrixRotationY(-1.0f); XMMATRIX modelOffset2 = XMMatrixTranslation(1.0f, 1.0f, -1.0f); //Duck3 XMMATRIX modelScale3 = XMMatrixScaling(1.5f, 1.5f, 1.5f); XMMATRIX modelRot3 = XMMatrixRotationY(0.5f); XMMATRIX modelOffset3 = XMMatrixTranslation(2.0f, 1.0f, -1.0f); //Duck4 XMMATRIX modelScale4 = XMMatrixScaling(0.5f, 0.5f, -1.0f); XMMATRIX modelRot4 = XMMatrixRotationY(1.0f); XMMATRIX modelOffset4 = XMMatrixTranslation(0.5f, 1.0f, -1.0f); //Duck 1 XMStoreFloat4x4(&testInstanceDuck.World, modelScale*modelRot*modelOffset); mModelInstances.push_back(testInstanceDuck); //Duck 2 XMStoreFloat4x4(&testInstanceDuck2.World, modelScale2*modelRot2*modelOffset2); mModelInstances.push_back(testInstanceDuck2); //Duck 3 XMStoreFloat4x4(&testInstanceDuck3.World, modelScale3*modelRot3*modelOffset3); mModelInstances.push_back(testInstanceDuck3); //Duck 4 XMStoreFloat4x4(&testInstanceDuck4.World, modelScale4*modelRot4*modelOffset4); mModelInstances.push_back(testInstanceDuck4); //create collision box for (unsigned i = 0; i < mModelInstances.size(); i++) { mModelInstances[i].Model->CreateCollisionBox(mModelInstances[i].Model->BasicVertices); } // // Compute scene bounding box. // XMFLOAT3 minPt(+MathHelper::Infinity, +MathHelper::Infinity, +MathHelper::Infinity); XMFLOAT3 maxPt(-MathHelper::Infinity, -MathHelper::Infinity, -MathHelper::Infinity); for (UINT i = 0; i < mModelInstances.size(); ++i) { for (UINT j = 0; j < mModelInstances[i].Model->BasicVertices.size(); ++j) { XMFLOAT3 P = mModelInstances[i].Model->BasicVertices[j].Pos; minPt.x = MathHelper::Min(minPt.x, P.x); minPt.y = MathHelper::Min(minPt.x, P.x); minPt.z = MathHelper::Min(minPt.x, P.x); maxPt.x = MathHelper::Max(maxPt.x, P.x); maxPt.y = MathHelper::Max(maxPt.x, P.x); maxPt.z = MathHelper::Max(maxPt.x, P.x); } } // // Derive scene bounding sphere from bounding box. // mSceneBounds.Center = XMFLOAT3( 0.5f*(minPt.x + maxPt.x), 0.5f*(minPt.y + maxPt.y), 0.5f*(minPt.z + maxPt.z)); XMFLOAT3 extent( 0.5f*(maxPt.x - minPt.x), 0.5f*(maxPt.y - minPt.y), 0.5f*(maxPt.z - minPt.z)); mSceneBounds.Radius = sqrtf(extent.x*extent.x + extent.y*extent.y + extent.z*extent.z); return true; }
void ZombieForce::OnResize() { DX11App::OnResize(); mCam.SetLens(0.25f*MathHelper::Pi, AspectRatio(), .20f, 1000.0f); }
inline int MapGridCtrl::CompareAspectRatio(const MapData* a, const MapData* b) { CMP2(AspectRatio(a->info), AspectRatio(b->info)); }
void D3DPBRApp::OnResize() { D3DApp::OnResize(); mCam.SetLens(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); }
void SpotlightSample::OnResize() { DirectXGame::OnResize(); mCamera.UpdateProjection(0.25f * 3.1415926535f, AspectRatio(), 0.1f, 100.0f); }
int VisionControl::ProcessImage() { if(m_camera->IsFreshImage()) { ColorImage *image = NULL; m_camera->GetImage(image); Threshold threshold(60,100,90,255,20,255); ParticleFilterCriteria2 criteria[] = {IMAQ_MT_AREA,AREA_MINIMUM,65535,false,false}; BinaryImage *thresholdImage = image->ThresholdHSV(threshold); BinaryImage *convexHullImage = thresholdImage->ConvexHull(false); BinaryImage *filteredImage = convexHullImage->ParticleFilter(criteria, 1); vector<ParticleAnalysisReport> *reports = filteredImage->GetOrderedParticleAnalysisReports(); for (unsigned int i = 0; i < reports->size(); i++) { ParticleAnalysisReport *report = &(reports->at(i)); // first, determine if this is a particle we are looking at. if(report->boundingRect.left > 320/2 || report->boundingRect.left + report->boundingRect.width < 320/2) { // particle is not lined up with center of vision // note: may not want to do this for autonomous! continue; } double aspectRatio = AspectRatio(filteredImage, report); double difference3ptGoal = fabs(1-(aspectRatio / ((54.f+4+4)/(12.f+4+4)))); double difference2ptGoal = fabs(1-(aspectRatio / ((54.f+4+4)/(21.f+4+4)))); if(difference2ptGoal < 0.25 && difference2ptGoal < difference3ptGoal) { m_elevation = 0; m_distance = ComputeDistance(thresholdImage, report, true); m_relativeAzimuth = 0; } else if(difference3ptGoal < 0.25 && difference3ptGoal < difference2ptGoal) { m_elevation = 0; m_distance = ComputeDistance(thresholdImage, report, false); m_relativeAzimuth = 0; } else { // didn't sufficiently match a target! } } /* Scores *scores = new Scores[reports->size()]; //Iterate through each particle, scoring it and determining whether it is a target or not for (unsigned i = 0; i < reports->size(); i++) { ParticleAnalysisReport *report = &(reports->at(i)); scores[i].rectangularity = ScoreRectangularity(report); scores[i].aspectRatioOuter = ScoreAspectRatio(filteredImage, report, true); scores[i].aspectRatioInner = ScoreAspectRatio(filteredImage, report, false); scores[i].xEdge = ScoreXEdge(thresholdImage, report); scores[i].yEdge = ScoreYEdge(thresholdImage, report); if(ScoreCompare(scores[i], false)) { printf("particle: %d is a High Goal centerX: %f centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized); printf("Distance: %f \n", ComputeDistance(thresholdImage, report, false)); } else if (ScoreCompare(scores[i], true)) { printf("particle: %d is a Middle Goal centerX: %f centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized); printf("Distance: %f \n", ComputeDistance(thresholdImage, report, true)); } else { printf("particle: %d is not a goal centerX: %f centerY: %f \n", i, report->center_mass_x_normalized, report->center_mass_y_normalized); } printf("rect: %f ARinner: %f \n", scores[i].rectangularity, scores[i].aspectRatioInner); printf("ARouter: %f xEdge: %f yEdge: %f \n", scores[i].aspectRatioOuter, scores[i].xEdge, scores[i].yEdge); } */ delete image; delete thresholdImage; delete convexHullImage; delete filteredImage; delete reports; //delete scores; return 1; } return 0; }