//---------------------------- PROTECTED -----------------------------// wxFrameworkGLCanvas::wxFrameworkGLCanvas(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, wxInt32 *attrib) : wxBaseGLCanvas(parent, id, pos, size, style, name, attrib) , mSelection(-1) , mHitTest(false) , mFinalHit(false) { ResetCamera(); Controller::get().AddReceiver(shEventMapZoomIn, &wxFrameworkGLCanvas::OnMapZoomIn, this); Controller::get().AddReceiver(shEventMapZoomOut, &wxFrameworkGLCanvas::OnMapZoomOut, this); Controller::get().AddReceiver(shEventMapPanLeft, &wxFrameworkGLCanvas::OnMapPanLeft, this); Controller::get().AddReceiver(shEventMapPanRight, &wxFrameworkGLCanvas::OnMapPanRight, this); Controller::get().AddReceiver(shEventMapPanUp, &wxFrameworkGLCanvas::OnMapPanUp, this); Controller::get().AddReceiver(shEventMapPanDown, &wxFrameworkGLCanvas::OnMapPanDown, this); Controller::get().AddReceiver(shEventMapRotateLeft, &wxFrameworkGLCanvas::OnMapRotateLeft, this); Controller::get().AddReceiver(shEventMapRotateRight, &wxFrameworkGLCanvas::OnMapRotateRight, this); Controller::get().AddReceiver(shEventMapRotateUp, &wxFrameworkGLCanvas::OnMapRotateUp, this); Controller::get().AddReceiver(shEventMapRotateDown, &wxFrameworkGLCanvas::OnMapRotateDown, this); }
void onKeyPressed(unsigned char key, int x, int y) { ::key = toupper(key); switch (::key) { case ESCAPE: glutLeaveMainLoop(); break; case RESET_CAMERA: ResetCamera(); break; case PAUSE: isPause = !isPause; break; case ROTATE_X: isRotateX = !isRotateX; break; case ROTATE_Y: isRotateY = !isRotateY; break; case RESTART: InitWell(); break; } }
bool D3D11App::Create() { // If the sample didn't create a context already, the framework creates a default one if (m_context == NULL) { m_context = new D3D11Context(); if (!m_context->Create(_T("Sample"), DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_D16_UNORM, 1280, 720, 1, false)) return false; } // Load the font if (FAILED(m_mainFont.LoadFont(m_context->GetDevice(), FONT_PATH _T("Future.dds"), FONT_PATH _T("Future.font")))) return false; // Tool resources if ((m_toolsEffect = m_context->LoadEffect(SHADER_PATH _T("Tools.fx"))) == NULL) return false; if ((m_toolsVsCB = m_context->CreateEffectConstantBuffer(m_toolsEffect, "MainVS")) == NULL) return false; if ((m_toolsPsCB = m_context->CreateEffectConstantBuffer(m_toolsEffect, "MainPS")) == NULL) return false; D3D11_INPUT_ELEMENT_DESC layout0[] = { { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; if ((m_pos3Layout = m_context->CreateInputLayout(m_toolsEffect->GetTechniqueByIndex(0)->GetPassByIndex(0), layout0, elementsOf(layout0))) == NULL) return false; D3D11_INPUT_ELEMENT_DESC layout1[] = { { "SV_Position", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TexCoord", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; if ((m_pos2Tex3Layout = m_context->CreateInputLayout(m_toolsEffect->GetTechniqueByIndex(2)->GetPassByIndex(0), layout1, elementsOf(layout1))) == NULL) return false; ResetCamera(); return true; }
void PTXViewerWidget::OpenFile(const std::string& fileName) { // Read file this->PTX = PTXReader::Read(fileName); Display(); ResetCamera(); }
void ABrowserCharacter::Set3DEnabled(bool Enabled) { bEnable3D = Enabled; if (!Enabled) { SetParabolicZoomEnable(false); } ResetCamera(); }
void ScoreScreen::LoadLevel(Ogre::String levelName) { ResetCamera(); Ogre::DotSceneLoader a; a.parseDotScene(levelName + ".scene", "General", mSceneMgr.get()); labels.clear(); for (unsigned int i = 0; i < mGameClient->raceResults.size(); ++i) { //make the node char name[128]; sprintf_s(name, 128, "playerResult%i", i); if (mSceneMgr->hasSceneNode(name)) mSceneMgr->destroySceneNode(name); Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(name); Ogre::Entity* ent = mSceneMgr->createEntity("checkBox.mesh"); //Make the text char words[128]; sprintf_s(words, 128, "Player %i = %d:%d.%d", i + 1, mGameClient->raceResults[i].minutes, mGameClient->raceResults[i].seconds, mGameClient->raceResults[i].ms); Ogre::MovableText* text = new Ogre::MovableText(name, words); text->setTextAlignment(Ogre::MovableText::H_LEFT, Ogre::MovableText::V_CENTER); node->setPosition(-3, 1.5 - (i*0.6), -5); node->scale(1, 0.5, 1); std::shared_ptr<PlayerLabel> p = std::shared_ptr<PlayerLabel>(new PlayerLabel(node, ent, text)); labels.push_back(p); } //Reset the server mGameClient->SendString("reset"); //Reset the local client stuff mGameClient->raceComplete = false; mGameClient->raceResults.clear(); mGameClient->allReady = false; mGameClient->allDoneLoading = false; mGameClient->startingIndex = 999; mGameClient->totalPlayers = 0; mGameClient->mConnectedPlayers = NULL; mGameClient->id = 0; }
bool GoodsModelManager::OpenModel(const char *szModelFileName /*= "model"*/, bool IsFullPathName /*= false*/) { ReleaseModel();//创建前先销毁 ResetCamera(); string strFullPathFileName; //是否是完整路径名称 if(IsFullPathName == false) //不是 { strFullPathFileName = m_PathName; strFullPathFileName += '\\'; strFullPathFileName += szModelFileName;//strFullPathFileName = 路径+文件名 SetOpenModelFileName(szModelFileName); } else // 是 { strFullPathFileName = szModelFileName;//strFullPathFilename = 完整路径名称 //拆分路径和文件名 string strPathName = szModelFileName; string strFilename = szModelFileName; strFilename = strFilename.erase(0,strFilename.find("goods")+5); SetOpenModelFileName(strFilename.c_str()); //strPathName = strPathName.erase(strPathName.find_last_of("/\\")+1); //SetPathName(strPathName.c_str()); } // 判断输入的正确性 if (string(strFullPathFileName).find("model") == string::npos) { MessageBox(NULL, "输入的路径下没有找到 model 文件\n请确认路径是否正确", "Error:", MB_OK); return false; } //创建要显示的模型 m_DisplayModel = m_GameModelManager->CreateDisplayModel(strFullPathFileName,false); VERIFY(m_DisplayModel); if(m_DisplayModel==NULL) return false; m_DisplayModel->ShowAllGroup(false); m_DisplayModel->EnableParticleEmitter(TRUE); m_DisplayModel->EnableTrailEmitter(TRUE); //俩个函数组合使用,使模型大小单位化 ResetScaleCumulate(); ScaleCumulate(0.0f,0.0f,0.0f); m_cAnimInfo.GetActionInfo()->dwCurAction = 0; m_cAnimInfo.GetActionInfo()->bInterpolation = FALSE; m_cAnimInfo.SetTextureProjectiveTime(timeGetTime()); return true; }
void InitializeLevel(void) { Vec3 TextTint; ResetObjectList(); ResetCamera(); // Initialize the player InitializePlayer(&CurrentPlayer, Mayple, 0, -220); CurrentPlayer.PlayerCollider.Position = CurrentPlayer.Position; Vec3Set(&TextTint, 1, 1, 1); LevelName = CreateText("Level 4", 0, 300, 100, TextTint, Center, Border); ChangeTextVisibility(LevelName); }
//------------------------------------------------------------------------ // Purpose : This function is called automatically since we have registered // as Observer to the InputManager. //------------------------------------------------------------------------ void Camera::Update(InputState state) { switch (state) { case MOUSE_LEFTCLICK: // Zoom in Interpolation if (m_fov <= D3DX_PI / 8.0f) m_fov = D3DX_PI / 8.0f; else m_fov -= CAMERA_ZOOM_MULTIPLIER * CAMERA_ZOOM_ENHANCER; break; case MOUSE_RIGHTCLICK: // Zoom out interpolation if (m_fov < D3DX_PI / 2.0f) m_fov += CAMERA_ZOOM_MULTIPLIER * CAMERA_ZOOM_ENHANCER; else m_fov = (D3DX_PI / 2.0f); break; case MOUSE_MIDDLECLICK: MouseMovCam(800,600); break; case KEY_W: MoveCam(CAMERA_SPEED); break; case KEY_A: StrafeCam(-CAMERA_SPEED); break; case KEY_S: MoveCam(-CAMERA_SPEED); break; case KEY_D: StrafeCam(CAMERA_SPEED); break; case KEY_C: ResetCamera(); break; } }
void FSCSEditorViewportClient::InvalidatePreview(bool bResetCamera) { // Ensure that the editor is valid before continuing if(!BlueprintEditorPtr.IsValid()) { return; } // Destroy the preview BlueprintEditorPtr.Pin()->DestroyPreview(); if( bResetCamera ) { ResetCamera(); } }
bool GoodsModelManager::InitiliseCamera() { m_Camera = new render::Camera(); VERIFY(m_Camera); if(!m_Camera) return false; render::Interface *pInterface = render::Interface::GetInstance(); int iWidth = pInterface->GetWndWidth(); int iHeight = pInterface->GetWndHeight(); float fAspect = (float)iWidth / (float)iHeight; m_Camera->SetAspect(fAspect); m_Camera->SetFOVY(D3DXToRadian(60)); m_Camera->SetNearClipPlane(0.01f); m_Camera->SetFarClipPlane(1000.0f); ResetCamera(); return true; }
void D3D11App::UpdateCameraPosition(const float speed) { if (m_benchMark) { if (m_benchMarkTime >= m_camera.GetPathNodeCount()) { m_benchMark = false; } m_camera.SetCameraToPathTime(m_benchMarkTime, false); m_benchMarkTime += m_frameTime; } else { if (m_keys[VK_RETURN]) { ResetCamera(); } else { // Get current orientation float3 dx, dy, dz; m_camera.GetViewBaseVectorsXY(dx, dy, dz); // Camera control float3 dir(0, 0, 0); if (m_keys[VK_LEFT] || m_keys['A']) dir -= dx; if (m_keys[VK_RIGHT] || m_keys['D']) dir += dx; if (m_keys[VK_SHIFT]) dir -= dy; if (m_keys[VK_CONTROL]) dir += dy; if (m_keys[VK_DOWN] || m_keys['S']) dir -= dz; if (m_keys[VK_UP] || m_keys['W']) dir += dz; // Only update if camera actually moved float l = dot(dir, dir); if (l > 0.01f) { float s = speed / sqrtf(l); // Numpad0 controls sneak mode if (m_keys[VK_NUMPAD0]) s *= (1.0f / 16.0f); m_camera.SetPosition(m_camera.GetPosition() + s * dir); } } } }
void FSCSEditorViewportClient::InvalidatePreview(bool bResetCamera) { // Ensure that the editor is valid before continuing if(!BlueprintEditorPtr.IsValid()) { return; } UBlueprint* Blueprint = BlueprintEditorPtr.Pin()->GetBlueprintObj(); check(Blueprint); // Create or update the Blueprint actor instance in the preview scene UpdatePreviewActorForBlueprint(Blueprint, !IsPreviewSceneValid()); if( bResetCamera ) { ResetCamera(); } }
void Game::UpdateModelViewWindow(float p_deltaTime) { m_TestArea2.Update(); if (m_TestArea2.GetCMC() == CMC_FirstPerson) { UpdateFirstPersonCamera(p_deltaTime); } else if (m_TestArea2.GetCMC() == CMC_LaptopMode) { UpdateCameraLaptopMode(p_deltaTime); } else if (m_TestArea2.GetCMC() == CMC_MouseOnly) { UpdateMouseInput(p_deltaTime); } if (m_TestArea2.GetLeftMouseDoubleClicked()) { ResetCamera(); } }
void wxFrameworkGLCanvas::OnRButtonDblClk(wxMouseEvent &) { //reset eye position ResetCamera(); }
void RenderSpecialStuff() { if (bTrackingCamera && !bPause) ResetCamera(); DrawLanders(); }
void CFirstPersonCameraComponent::OnActivate() { m_EventMask |= EventToMask(EEntityEvent::Update); GetEntity()->UpdateComponentEventMask(this); ResetCamera(); }
void Game::UpdateMouseInput(float p_deltaTime) { float distanceToModel = m_Camera->GetPosition().z; if (distanceToModel < 0) distanceToModel *= -1; float rotationVariable = m_StartPos.z/distanceToModel; if (rotationVariable < 1.0) rotationVariable = 1.0f; float moveSpeed = p_deltaTime * 3.0f * rotationVariable; float rotationSpeed = p_deltaTime * 4.0f*rotationVariable; m_PrevMousePos = m_MousePos; m_MousePos = m_TestArea2.GetMousePos(); //Rotate the model around Y if (m_TestArea2.GetSpaceState()) { if (m_TestArea2.GetLeftMousePressed()) { glm::vec3 newPos = m_Camera->GetPosition(); glm::vec3 currentPos = m_Camera->GetPosition(); float x = m_PrevMousePos.x - m_MousePos.x; float y = m_PrevMousePos.y - m_MousePos.y; float moveCameraSpeed = moveSpeed * 8.0f; float rotateCameraSpeed = rotationSpeed * 1.2f; if (x != 0.0f) { if (x < 0.0f) { m_Camera->YawRelative(-rotateCameraSpeed); newPos.x -= (moveCameraSpeed); } else { m_Camera->YawRelative(rotateCameraSpeed); newPos.x += (moveCameraSpeed); } } if (y != 0.0f) { if (y < 0.0f) { m_Camera->PitchRelative(-rotateCameraSpeed); newPos.y += (moveCameraSpeed); } else { m_Camera->PitchRelative(rotateCameraSpeed); newPos.y -= (moveCameraSpeed); } } glm::vec3 finalPosition = glm::vec3(newPos.x - currentPos.x, newPos.y - currentPos.y, newPos.z - currentPos.z); m_Camera->MoveRelative(finalPosition); } //Move the model around in the viewspace if (m_TestArea2.GetRightMousePressed()) { float x = 0, y = 0; x = m_PrevMousePos.x - m_MousePos.x; y = m_PrevMousePos.y - m_MousePos.y; glm::vec3 newPos = m_Camera->GetPosition(); newPos.x += x * p_deltaTime; newPos.y -= y * p_deltaTime; glm::vec3 currentPos = m_Camera->GetPosition(); glm::vec3 finalPosition = glm::vec3(newPos.x - currentPos.x, newPos.y - currentPos.y, newPos.z - currentPos.z); m_Camera->MoveRelative(finalPosition); } //Manipulate scale by scrolling the mouse wheel m_Camera->MoveRelative(glm::vec3(0, 0, -m_TestArea2.GetMouseWheelState() * p_deltaTime * 100)); if (m_TestArea2.GetLeftMouseDoubleClicked() && m_StartPos == m_Camera->GetPosition() && !m_AutomaticRotate) { m_AutomaticRotate = true; } else if (m_TestArea2.GetLeftMouseDoubleClicked() && m_AutomaticRotate) { m_AutomaticRotate = false; } else if (m_TestArea2.GetLeftMouseDoubleClicked()) { ResetCamera(); } } //Rotates automatically if (m_AutomaticRotate) { glm::vec3 newPos = m_Camera->GetPosition(); glm::vec3 currentPos = m_Camera->GetPosition(); if (m_AutomaticRotateLeft) { m_Camera->YawRelative(-rotationSpeed * 0.3f); newPos.x -= (moveSpeed * 2.0f); glm::vec3 finalPosition = glm::vec3(newPos.x - currentPos.x, newPos.y - currentPos.y, newPos.z - currentPos.z); m_Camera->MoveRelative(finalPosition); } else { m_Camera->YawRelative(rotationSpeed * 0.3f); newPos.x += (moveSpeed * 2.0f); glm::vec3 finalPosition = glm::vec3(newPos.x - currentPos.x, newPos.y - currentPos.y, newPos.z - currentPos.z); m_Camera->MoveRelative(finalPosition); } } }
void Camera::HandleInput() { double deltaTime = GLOBAL::GetInstance().GetDeltaTime(); // Start moving the camera with the C key. if (InputManager::GetInstance()->IsKeyClicked(VkKeyScan('l')) && !GLOBAL::GetInstance().CAMERA_FLYING && FLAG_DEBUG == 1) { GLOBAL::GetInstance().CAMERA_FLYING = true; POINT position; GetCursorPos(&position); m_oldMouseX = (float)position.x; m_oldMouseY = (float)position.y; m_upVector = DirectX::XMFLOAT3(0.0f, 20.0f, 10.0f); DirectX::XMStoreFloat3(&m_upVector, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_upVector))); m_look = DirectX::XMFLOAT3(0.0f, -20.0f, 10.0f); DirectX::XMStoreFloat3(&m_look, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_look))); m_right = DirectX::XMFLOAT3(1.0f, 0.0f, 0.0f); DirectX::XMStoreFloat3(&m_right, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_right))); } if (GLOBAL::GetInstance().CAMERA_FLYING) { // Rotate and pitch the camera. POINT position; GetCursorPos(&position); float dx = DirectX::XMConvertToRadians(0.25f * static_cast<float>(position.x - m_oldMouseX)); float dy = DirectX::XMConvertToRadians(0.25f * static_cast<float>(position.y - m_oldMouseY)); Pitch(dy); Rotate(dx); SetCursorPos((int)m_oldMouseX, (int)m_oldMouseY); // Move the camera using W, S, A, D keys. if (InputManager::GetInstance()->IsKeyPressed(VK_UP)) { Walk(10.0f * (float)deltaTime); } if (InputManager::GetInstance()->IsKeyPressed(VK_DOWN)) { Walk(-10.0f * (float)deltaTime); } if (InputManager::GetInstance()->IsKeyPressed(VK_LEFT)) { Strafe(-10.0f * (float)deltaTime); } if (InputManager::GetInstance()->IsKeyPressed(VK_RIGHT)) { Strafe(10.0f * (float)deltaTime); } // Update the camera. UpdateMovedCamera(); // Set shader variables from the camera. GraphicsEngine::SetViewAndProjection(GetViewMatrix(), GetProjectionMatrix()); // Reset the camera when BACKSPACE key is pressed. if (GetAsyncKeyState(VK_BACK)) { GLOBAL::GetInstance().CAMERA_FLYING = false; ResetCamera(); } } }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // 分析菜单选择: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: 在此添加任意绘图代码... EndPaint(hWnd, &ps); break; case WM_MOUSEMOVE: moving = true; hovering = false; lastCursorPos = currentCursorPos; currentCursorPos.x = (float)GET_X_LPARAM(lParam); currentCursorPos.y = (float)GET_Y_LPARAM(lParam); TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_HOVER; tme.dwHoverTime = 100; tme.hwndTrack = hWnd; TrackMouseEvent(&tme); break; case WM_LBUTTONDOWN: currentCursorPos.x = (float)GET_X_LPARAM(lParam); currentCursorPos.y = (float)GET_Y_LPARAM(lParam); lastCursorPos = currentCursorPos; dragging = true; break; case WM_LBUTTONUP: dragging = false; break; case WM_MOUSEHOVER: lastCursorPos = currentCursorPos; currentCursorPos.x = (float)GET_X_LPARAM(lParam); currentCursorPos.y = (float)GET_Y_LPARAM(lParam); hovering = true; moving = false; break; case WM_KEYDOWN: switch(wParam) { case VK_ESCAPE: //按Esc退出 PostQuitMessage(0); break; case 'P': //按'P'暂停/恢复 Pause = Pause ? false : true; break; //camera 操作 case 'W': MoveCameraForward(3.0f); break; case 'S': MoveCameraBackward(3.0f); break; case 'A': MoveCameraLeft(3.0f); break; case 'D': MoveCameraRight(3.0f); break; case 'R': ResetCamera(); break; //参考:http://forums.codeguru.com/showthread.php?302925-Where-is-Page-Up-Down-Accelerator-Key&p=981700#post981700 //Page Up : VK_PRIOR //Page Down : VK_NEXT case VK_PRIOR: MoveCameraUpward(3.0f); break; case VK_NEXT: MoveCameraDownward(3.0f); break; case 'Q': RotateCameraHorizontally(-D3DX_PI/45); break; case 'E': RotateCameraHorizontally(D3DX_PI/45); break; case VK_HOME: RotateCameraVertically(-D3DX_PI/45); break; case VK_END: RotateCameraVertically(D3DX_PI/45); break; case VK_SPACE: bStepForward = true; break; } break; case WM_DESTROY: Destroy(); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// looks a lot like Dave's :-) bool GLPort::Initialize() { PIXELFORMATDESCRIPTOR pfd; int npf; // need the DC later HDC dc = GetDC(MainForm->pnlView->Handle); // this is what we want who knows what we get memset(&pfd, 0, sizeof pfd); pfd.nSize = sizeof pfd; pfd.nVersion = 1; pfd.dwFlags = /*PFD_SUPPORT_GDI|*/PFD_SUPPORT_OPENGL| PFD_DOUBLEBUFFER|PFD_DRAW_TO_WINDOW; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; // set the pixel format for the window npf = ChoosePixelFormat(dc, &pfd); SetPixelFormat(dc, npf, &pfd); DescribePixelFormat(dc, npf, sizeof pfd, &pfd); if (pfd.dwFlags & PFD_NEED_PALETTE) { ErrorMsg("Segeltuch does not yet support 8-bit video modes.\n\n" "Please increase your video depth to atleast 16-bit."); //return false; //for now, we allow the program to continue even though the //display will be very ugly.... } if (!(pfd.dwFlags & PFD_DOUBLEBUFFER)) { ErrorMsg("No available double buffering support."); } InfoMsg("Found graphics card with %d-bits of color resolution and a %d-bit depth buffer.", pfd.cColorBits, pfd.cDepthBits); // create the OpenGL interface hRC = wglCreateContext(dc); if (hRC == NULL) { ErrorBox("Unable to create OpenGL renderring context."); return false; } // start her up Activate(); ResetCamera(); // no more MainForm->pnlView->EraseBack = false; // Clear the screen initially glClearColor(ColBck.r, ColBck.g, ColBck.b, ColBck.a); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SwapBuffers(dc); // setup the new window ResetSize(false); // Our options glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glAlphaFunc(GL_GREATER, 0.5); glDisable(GL_ALPHA_TEST); // Utility Object qobj = gluNewQuadric(); // clean up our stuff Deactivate(); return (Created=true); }
// constructor GLPort::GLPort() { Created = false; const float s = 2.5f; hPal = NULL; hRC = NULL; UseLight = true; ColBck.r=ColBck.g=ColBck.b=0.40f; ColBck.a=1.0f; ColHull[0].r = ColHull[0].g = 1.0f; ColHull[0].b = 1.0f; ColHull[0].a = 0.4f; ColHull[1] = ColHull[0]; /*ColHull[1].r = ColHull[0].r/s; ColHull[1].g = ColHull[0].g/s; ColHull[1].b = ColHull[0].b/s; ColHull[1].a = ColHull[0].a;*/ ColObj[0].r = ColObj[0].a = 1.0f; ColObj[0].g = 0.666667f; ColObj[0].b = 0.2745f; ColObj[1].r = ColObj[0].r/s; ColObj[1].g = ColObj[0].g/s; ColObj[1].b = ColObj[0].b/s; ColObj[1].a = ColObj[0].a; ColGrid.a = 1.0f; ColGrid.r = ColGrid.g = ColGrid.b = 0.0f; ColShld[0].r = ColShld[0].g=1.0f; ColShld[0].b = 0.3f; ColShld[0].a = 0.6f; ColShld[1].r = ColShld[0].r/s; ColShld[1].g = ColShld[0].g/s; ColShld[1].b = ColShld[0].b/s; ColShld[1].a = ColShld[0].a; ColSelSing[0].g = 1.0; ColSelSing[0].a = 0.5f; ColSelSing[0].r = ColSelSing[0].b=0.1f; ColSelSing[1].r = ColSelSing[0].r/s; ColSelSing[1].g = ColSelSing[0].g/s; ColSelSing[1].b = ColSelSing[0].b/s; ColSelSing[1].a = ColSelSing[0].a; ColSelMult[0].r = 1.0; ColSelMult[0].a = 1.5f; ColSelMult[0].g = ColSelMult[0].b = 0.1f; ColSelMult[1].r = ColSelMult[0].r/s; ColSelMult[1].g = ColSelMult[0].g/s; ColSelMult[1].b = ColSelMult[0].b/s; ColSelMult[1].a = ColSelMult[0].a; ColSelResl[0].r = ColSelResl[0].g = 1.0; ColSelResl[0].a = 1.0f; ColSelResl[0].b = 0.1f; ColSelResl[1].r = ColSelResl[0].r/s; ColSelResl[1].g = ColSelResl[0].g/s; ColSelResl[1].b = ColSelResl[0].b/s; ColSelResl[1].a = ColSelResl[0].a; ResetCamera(); Active = false; }
void cDrawScenarioPoliEval::ResetCallback() { ResetCamera(); mTracer.Reset(); }
void InitializeMainMenu(void) { FILE *fp; Vec3 Tint; float xPos, yPos; //Animation variables initialize firstAnimated = TRUE; secondAnimated = FALSE; fadeOut = FALSE; firstMoveTimer = 0; secondMoveTimer = 0; firstStartLocation = rand() % 4; secondStartLocation = rand() % 4; firstTextureNum = MAX_TEXTURES + 1; secondTextureNum = MAX_TEXTURES + 1; // Reset the object list ResetObjectList(); deleteSave = FALSE; exitGame = FALSE; //Check if it is possible to load a game fp = fopen(GameData, "r"); if(fp) { canLoad = TRUE; fclose(fp); } else { canLoad = FALSE; } //Grabs the first starting location SetStartLocation(&xPos, &yPos, firstStartLocation); FirstBackground = (Sprite *) CreateSprite("TextureFiles/BlurFoxHall.png", 2560, 1440, 1, 1, 1, xPos, yPos); SecondBackground = (Sprite *) CreateSprite("TextureFiles/BlurFoxMansion.png", 2560, 1440, 1, 1, 1, xPos, yPos); //Randomizes the textures for the animation firstTextureNum = RandomNewTexture(FirstBackground, secondTextureNum); secondTextureNum = RandomNewTexture(SecondBackground, firstTextureNum); //Second background should not be seen SecondBackground->Alpha = 0.0f; //Nice looking things for the menu Overlay = (Sprite *) CreateSprite("TextureFiles/MenuOverlay.png", 1920, 1080, 2, 1, 1, 0, 0); Logo = (Sprite *) CreateSprite("TextureFiles/MansionMashersMainMenu.png", 1200, 675, 3, 1, 1, 0, 200); //Button backgrounds FoxScroll = (Sprite *) CreateSprite("TextureFiles/MenuBackFoxAnimationFix.png", 447, 500, 4, 18, 1, -300, -130); FoxScroll->AnimationSpeed = 2.0f; DogScroll = (Sprite *) CreateSprite("TextureFiles/MenuBackDogAnimationFix.png", 447, 500, 4, 18, 1, 300, -130); DogScroll->AnimationSpeed = 2.0f; //Sets the frame that the scrolls are on. prevFrame = FoxScroll->CurrentFrame; FoxScrollBottom = (Sprite *) CreateSprite("TextureFiles/ScrollBottom.png", 447, 44, 9, 1, 1, -300, 60); DogScrollBottom = (Sprite *) CreateSprite("TextureFiles/ScrollBottom.png", 447, 44, 9, 1, 1, 300, 60); //Menu buttons NewGameButton = CreateButton("TextureFiles/NewGameButton.png", 0, -130, 394, 394); LoadGameButton = CreateButton("TextureFiles/LoadGameButton.png", -290, -8, 439, 170); OptionsButton = CreateButton("TextureFiles/OptionsButton.png", 290, -8, 439, 170); CreditsButton = CreateButton("TextureFiles/CreditsButton.png", -290, -270, 439, 170); QuitGameButton = CreateButton("TextureFiles/QuitGameButton.png", 290, -270, 439, 170); //Update button Z index NewGameButton->ButtonSprite->ZIndex = 10; LoadGameButton->ButtonSprite->ZIndex = 8; OptionsButton->ButtonSprite->ZIndex = 8; CreditsButton->ButtonSprite->ZIndex = 8; QuitGameButton->ButtonSprite->ZIndex = 8; OptionsButton->ButtonSprite->Visible = FALSE; QuitGameButton->ButtonSprite->Visible = FALSE; CreditsButton->ButtonSprite->Visible = FALSE; LoadGameButton->ButtonSprite->Visible = FALSE; //Delete save game objects Vec3Set(&Tint, 0, 0, 0); BlackBackground = (Sprite *) CreateSprite("TextureFiles/BlankPlatform.png", 1920, 1080, 499, 1, 1, 0, 0); BlackBackground->Tint = Tint; BlackBackground->Alpha = 0.5f; DeleteText = (Sprite *) CreateSprite("TextureFiles/DeleteText.png", 651, 334, 500, 1, 1, 0, 100); YesButton = CreateButton("TextureFiles/DeleteButton.png", -300, -200, 400, 150); YesButton->ButtonSprite->ZIndex = 500; NoButton = CreateButton("TextureFiles/BackButton.png", 300, -200, 400, 150); NoButton->ButtonSprite->ZIndex = 500; //Exit Game Confirmation Vec3Set(&Tint, 0, 0, 0); ExitConfirm = (Sprite *) CreateSprite("TextureFiles/ExitConfirm.png", 639, 204, 500, 1, 1, 0, 100); ExitButton = CreateButton("TextureFiles/ExitButton.png", -300, -200, 400, 150); ExitButton->ButtonSprite->ZIndex = 500; //Should not be visible at the start BlackBackground->Visible = FALSE; DeleteText->Visible = FALSE; ExitConfirm->Visible = FALSE; YesButton->ButtonSprite->Visible = FALSE; NoButton->ButtonSprite->Visible = FALSE; ExitButton->ButtonSprite->Visible = FALSE; //Help out text GettingImpatientTimer = -2.5; TimerGoingUp = TRUE; Vec3Set(&Tint, 1, 1, 1); SillyGooseUseMouse = CreateText("Use the mouse to navigate the menu!", 0, -480, 100, Tint, Center, Border); ChangeTextZIndex(SillyGooseUseMouse, 600); ChangeTextAlpha(SillyGooseUseMouse, 0); ChangeTextVisibility(SillyGooseUseMouse); CreateBoundingBoxes(); // Set camera to (0,0) ResetCamera(); //Basically don't remake the sound because we only went to the options menu and came back if(GetPreviousState() != GS_Options) CreatePauseSound(&MenuBackSnd, "Sounds/MenuTheme.mp3", LargeSnd); }
int main( int argc, char ** argv) { uint32_t rtn = 0; uint32_t action = 0; CAMCameraListPtr pList = 0; CAMDeviceInfoPtr pDevInfo = 0; CAMHandle hCam = 0; CAMDevice device; OPTS opts; action = parse_options( &opts, argc, argv); if (!action) return 0; do { SetUsbDebug( verbose); rtn = InitUsb(); if (rtn) break; rtn = GetCameraList( &pList, (opts.flags & OPT_FORCE)); if (rtn) break; if (action == ACT_LIST_DEVICES) { list_devices( pList); break; } device = SelectCamera( &opts, pList); if (!device) break; if (action == ACT_DEVICE_RESET) { ResetCamera( device); break; } rtn = InitCamera( device, &hCam); if (rtn) break; rtn = GetDeviceInfo( hCam, &pDevInfo); if (rtn) break; switch (action) { case ACT_SHOW_INFO: show_info( pDevInfo); break; case ACT_LIST_OPERATIONS: list_operations( pDevInfo); break; case ACT_STORAGE_INFO: show_storage_info( hCam, pDevInfo); break; case ACT_LIST_PROPERTIES: list_properties( pDevInfo); break; case ACT_GETSET_PROPERTY: getset_property( hCam, pDevInfo, &opts); break; case ACT_LIST_FILES: list_files( hCam, pDevInfo); break; case ACT_LIST_HANDLES: list_handles( hCam, pDevInfo); break; case ACT_HANDLE_INFO: show_handle_info( hCam, pDevInfo, &opts); break; case ACT_GET_FILE: get_files( hCam, pDevInfo, &opts); break; case ACT_DELETE_FILE: delete_files( hCam, pDevInfo, &opts); break; } } while (0); if (rtn) camcli_error( GetErrorName( pDevInfo, rtn)); free( pDevInfo); free( pList); TermCamera( &hCam); TermUsb(); return 0; }
int main(int, char *[]) { const std::string file = "/home/mathieu/dev/cochleo/share/cochlee.wav"; const audiofile audio(file); filterbank fb(audio.sample_frequency(),100,6000,1000); const auto xaxis = audio.time(); const auto yaxis = fb.center_frequency(); auto cochleo = fb.compute(audio.channel(0)); normalization(cochleo); // Create the color palette auto palette = vtkSmartPointer<vtkLookupTable>::New(); palette->SetTableRange(0.0,1.0); palette->SetHueRange(0.67,0.); palette->SetSaturationRange(0.7,0.3); palette->Build(); // Create a c-style rgb image const std::size_t width = xaxis.size(); const std::size_t height = yaxis.size(); std::vector<unsigned char> cImage(3*width*height); for(std::size_t i=0; i<width; ++i) for(std::size_t j=0; j<height; ++j) { unsigned char* color = palette->MapValue(cochleo[i][j]); cImage[3*(i+width*j)] = color[0]; cImage[3*(i+width*j)+1] = color[1]; cImage[3*(i+width*j)+2] = color[2]; } // Convert the c-style image to a vtkImageData auto imageImport = vtkSmartPointer<vtkImageImport>::New(); imageImport->SetDataSpacing(0.07, 1, 1); imageImport->SetDataOrigin(0, 0, 0); imageImport->SetWholeExtent(0, width-1, 0, height-1, 0, 0); imageImport->SetDataExtentToWholeExtent(); imageImport->SetDataScalarTypeToUnsignedChar(); imageImport->SetNumberOfScalarComponents(3); imageImport->SetImportVoidPointer(cImage.data()); imageImport->Update(); // Create an actor auto actor = vtkSmartPointer<vtkImageActor>::New(); actor->SetInput(imageImport->GetOutput()); // Create a scalar bar auto scalarBar = vtkSmartPointer<vtkScalarBarActor>::New(); scalarBar->SetLookupTable(palette); scalarBar->SetTitle("gain"); scalarBar->SetNumberOfLabels(5); // Configure text of the scalar bar auto textBar = vtkSmartPointer<vtkTextProperty>::New(); textBar->SetFontSize(10); scalarBar->SetTitleTextProperty(textBar); scalarBar->SetLabelTextProperty(textBar); // Setup renderer auto renderer = vtkSmartPointer<vtkRenderer>::New(); renderer->AddActor(actor); renderer->AddActor(scalarBar); renderer->ResetCamera(); // Setup render window auto renderWindow = vtkSmartPointer<vtkRenderWindow>::New(); renderWindow->AddRenderer(renderer); // Setup render window interactor auto renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); auto style = vtkSmartPointer<vtkInteractorStyleImage>::New(); renderWindowInteractor->SetInteractorStyle(style); // Render and start interaction renderWindowInteractor->SetRenderWindow(renderWindow); renderWindowInteractor->Initialize(); renderWindowInteractor->Start(); return EXIT_SUCCESS; }
void MyCameraSingleton::SetCameraMode(CAMERAMODE a_nMode){ m_nMode = a_nMode; ResetCamera(); }