本文整理汇总了C++中tdogl::Camera::up方法的典型用法代码示例。如果您正苦于以下问题:C++ Camera::up方法的具体用法?C++ Camera::up怎么用?C++ Camera::up使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tdogl::Camera
的用法示例。
在下文中一共展示了Camera::up方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
// update the scene based on the time elapsed since last update
void Update(float secondsElapsed) {
const GLfloat degreesPerSecond = 180.0f;
gDegreesRotated += secondsElapsed * degreesPerSecond;
while(gDegreesRotated > 360.0f) gDegreesRotated -= 360.0f;
// Move position of camera base on WASD keys
const float moveSpeed = 3.0; // Units per second;
if(glfwGetKey(gWindow, 'S'))
{
gCamera.offsetPosition(secondsElapsed * moveSpeed * -gCamera.forward());
}else if(glfwGetKey(gWindow, 'W'))
{
gCamera.offsetPosition(secondsElapsed * moveSpeed * gCamera.forward());
}
if(glfwGetKey(gWindow, 'A'))
{
gCamera.offsetPosition(secondsElapsed * moveSpeed * gCamera.right());
}else if(glfwGetKey(gWindow, 'D'))
{
gCamera.offsetPosition(secondsElapsed * moveSpeed * -gCamera.right());
}
if(glfwGetKey(gWindow, 'Z'))
{
gCamera.offsetPosition(secondsElapsed * moveSpeed * -gCamera.up());
}else if(glfwGetKey(gWindow, 'X'))
{
gCamera.offsetPosition(secondsElapsed * moveSpeed * gCamera.up());
}
//rotate camera based on mouse movement
const float mouseSensitivity = 0.1f;
double mouseX, mouseY;
glfwGetCursorPos(gWindow, &mouseX, &mouseY);
gCamera.offsetOrientation(mouseSensitivity * (float)mouseY, mouseSensitivity * (float)mouseX);
glfwSetCursorPos(gWindow, 0, 0); //reset the mouse, so it doesn't go out of the window
//increase or decrease field of view based on mouse wheel
const float zoomSensitivity = -0.2f;
float fieldOfView = gCamera.fieldOfView() + zoomSensitivity * (float)gScrollY;
if(fieldOfView < 5.0f) fieldOfView = 5.0f;
if(fieldOfView > 130.0f) fieldOfView = 130.0f;
gCamera.setFieldOfView(fieldOfView);
gScrollY = 0;
}