void CCameraHandler::SetCameraMode(const std::string& modeName) { const int modeNum = GetModeIndex(modeName); if (modeNum >= 0) { SetCameraMode(modeNum); } // do nothing if the name is not matched }
CCameraHandler::CCameraHandler() { cameraTime = 0.0f; cameraTimeLeft = 0.0f; // FPS camera must always be the first one in the list camControllers.resize(CAMERA_MODE_LAST); camControllers[CAMERA_MODE_FIRSTPERSON] = new CFPSController(); camControllers[CAMERA_MODE_OVERHEAD ] = new COverheadController(); camControllers[CAMERA_MODE_TOTALWAR ] = new CTWController(); camControllers[CAMERA_MODE_ROTOVERHEAD] = new CRotOverheadController(); camControllers[CAMERA_MODE_FREE ] = new CFreeController(); camControllers[CAMERA_MODE_SMOOTH ] = new SmoothController(); camControllers[CAMERA_MODE_ORBIT ] = new COrbitController(); camControllers[CAMERA_MODE_OVERVIEW ] = new COverviewController(); for (unsigned int i = 0; i < camControllers.size(); i++) { nameMap[camControllers[i]->GetName()] = i; } int modeIndex; const std::string modeName = configHandler->GetString("CamModeName", ""); if (!modeName.empty()) { modeIndex = GetModeIndex(modeName); } else { modeIndex = configHandler->Get("CamMode", 5); } const unsigned int mode = (unsigned int)std::max(0, std::min(modeIndex, (int)camControllers.size() - 1)); currCamCtrlNum = mode; currCamCtrl = camControllers[currCamCtrlNum]; const double z = 0.0; // casting problems... cameraTimeFactor = std::max(z, atof(configHandler->GetString("CamTimeFactor", "1.0").c_str())); cameraTimeExponent = std::max(z, atof(configHandler->GetString("CamTimeExponent", "4.0").c_str())); RegisterAction("viewfps"); RegisterAction("viewta"); RegisterAction("viewtw"); RegisterAction("viewrot"); RegisterAction("viewfree"); RegisterAction("viewov"); RegisterAction("viewlua"); RegisterAction("vieworbit"); RegisterAction("viewtaflip"); RegisterAction("toggleoverview"); RegisterAction("togglecammode"); RegisterAction("viewsave"); RegisterAction("viewload"); }
CCameraHandler::CCameraHandler() { cameraTimeStart = 0.0f; cameraTimeEnd = 0.0f; startCam.fov = 90.0f; // FPS camera must always be the first one in the list camControllers.resize(CAMERA_MODE_LAST); camControllers[CAMERA_MODE_FIRSTPERSON] = new CFPSController(); camControllers[CAMERA_MODE_OVERHEAD ] = new COverheadController(); camControllers[CAMERA_MODE_TOTALWAR ] = new CTWController(); camControllers[CAMERA_MODE_ROTOVERHEAD] = new CRotOverheadController(); camControllers[CAMERA_MODE_FREE ] = new CFreeController(); camControllers[CAMERA_MODE_SMOOTH ] = new SmoothController(); camControllers[CAMERA_MODE_ORBIT ] = new COrbitController(); camControllers[CAMERA_MODE_OVERVIEW ] = new COverviewController(); for (unsigned int i = 0; i < camControllers.size(); i++) { nameMap[camControllers[i]->GetName()] = i; } int modeIndex; const std::string modeName = configHandler->GetString("CamModeName"); if (!modeName.empty()) { modeIndex = GetModeIndex(modeName); } else { modeIndex = configHandler->GetInt("CamMode"); } currCamCtrlNum = modeIndex; currCamCtrl = camControllers[currCamCtrlNum]; cameraTimeFactor = configHandler->GetFloat("CamTimeFactor"); cameraTimeExponent = configHandler->GetFloat("CamTimeExponent"); RegisterAction("viewfps"); RegisterAction("viewta"); RegisterAction("viewtw"); RegisterAction("viewrot"); RegisterAction("viewfree"); RegisterAction("viewov"); RegisterAction("viewlua"); RegisterAction("vieworbit"); RegisterAction("viewtaflip"); RegisterAction("toggleoverview"); RegisterAction("togglecammode"); RegisterAction("viewsave"); RegisterAction("viewload"); }
CCameraHandler::CCameraHandler() { CreateGlobalCams(); camTransState.startFOV = 90.0f; camTransState.timeStart = 0.0f; camTransState.timeEnd = 0.0f; // FPS camera must always be the first one in the list camControllers.resize(CAMERA_MODE_LAST, nullptr); camControllers[CAMERA_MODE_FIRSTPERSON] = new CFPSController(); camControllers[CAMERA_MODE_OVERHEAD ] = new COverheadController(); camControllers[CAMERA_MODE_SPRING ] = new CSpringController(); camControllers[CAMERA_MODE_ROTOVERHEAD] = new CRotOverheadController(); camControllers[CAMERA_MODE_FREE ] = new CFreeController(); camControllers[CAMERA_MODE_OVERVIEW ] = new COverviewController(); for (unsigned int i = 0; i < camControllers.size(); i++) { nameModeMap[camControllers[i]->GetName()] = i; } const std::string& modeName = configHandler->GetString("CamModeName"); if (!modeName.empty()) { currCamCtrlNum = GetModeIndex(modeName); } else { currCamCtrlNum = configHandler->GetInt("CamMode"); } camTransState.timeFactor = configHandler->GetFloat("CamTimeFactor"); camTransState.timeExponent = configHandler->GetFloat("CamTimeExponent"); RegisterAction("viewfps"); RegisterAction("viewta"); RegisterAction("viewspring"); RegisterAction("viewrot"); RegisterAction("viewfree"); RegisterAction("viewov"); RegisterAction("viewtaflip"); RegisterAction("toggleoverview"); RegisterAction("togglecammode"); RegisterAction("viewsave"); RegisterAction("viewload"); SetCameraMode(currCamCtrlNum); }
static int SwitchRes(char inout, int x, int y, int w, int h, int *dw, int *dh) { static int vp_x, vp_y; XF86VidModeModeInfo *mode; int scr; scr = Dpy.screen; if (inout) { XF86VidModeModeLine curmode; int dotclock; int rx, ry; if (!XF86VidModeGetModeLine(disp, scr, &dotclock, &curmode)) return 0; XF86VidModeGetViewPort(disp, scr, &vp_x, &vp_y); mode = FindMode(w, h); if (mode) { #if USE_XRANDR int vw, vh; vw = WinGetW(VROOT); vh = WinGetH(VROOT); /* x and y relative to unrotated display */ if (Mode.screen.rotation == RR_Rotate_90) { rx = y; ry = vw - mode->vdisplay - x; } else if (Mode.screen.rotation == RR_Rotate_270) { rx = vh - mode->hdisplay - y; ry = x; } else if (Mode.screen.rotation == RR_Rotate_180) { rx = vw - mode->hdisplay - x; ry = vh - mode->vdisplay - y; } else #endif { rx = x; ry = y; } #if USE_XRANDR if ((Mode.screen.rotation == RR_Rotate_90) || (Mode.screen.rotation == RR_Rotate_270)) { *dw = mode->vdisplay; *dh = mode->hdisplay; } else #endif { *dw = mode->hdisplay; *dh = mode->vdisplay; } XF86VidModeLockModeSwitch(disp, scr, 0); std_vid_mode_cur = GetModeIndex(dotclock, &curmode); XF86VidModeSwitchToMode(disp, scr, mode); XF86VidModeSetViewPort(disp, scr, rx, ry); XF86VidModeLockModeSwitch(disp, scr, 1); return 1; } } else { mode = std_vid_modes[std_vid_mode_cur]; XF86VidModeLockModeSwitch(disp, scr, 0); XF86VidModeSwitchToMode(disp, scr, mode); XF86VidModeSetViewPort(disp, scr, vp_x, vp_y); #if 0 /* No, don't lock or we can't switch resolution */ XF86VidModeLockModeSwitch(disp, scr, 1); #endif } return 0; }