本文整理汇总了C++中tdogl::Camera::offsetPositon方法的典型用法代码示例。如果您正苦于以下问题:C++ Camera::offsetPositon方法的具体用法?C++ Camera::offsetPositon怎么用?C++ Camera::offsetPositon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tdogl::Camera
的用法示例。
在下文中一共展示了Camera::offsetPositon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
//rotated and add keyboard and mouse callback
void Update(float secondsElapsed) {
//change the axis that rotated
if (glfwGetKey('7')){
Axis =glm::vec3(1,0,0);
}
if (glfwGetKey('8')){
Axis =glm::vec3(0,0,1);
}
if (glfwGetKey('9')){
Axis =glm::vec3(0,1,0);
}
//press "T" to stop rotate
GLfloat degreesPerSecond = 20.0f;
if (glfwGetKey('T')){
degreesPerSecond = 0.0f;
}
gDegreesRotated += secondsElapsed * degreesPerSecond;
while (gDegreesRotated > 360.0f) gDegreesRotated -= 360.0f;
const float moveSpeed = 3.0;
if (glfwGetKey('S')) {
gCamera.offsetPositon(secondsElapsed * moveSpeed * -gCamera.forward());
} else if (glfwGetKey('W')){
gCamera.offsetPositon(secondsElapsed * moveSpeed * gCamera.forward());
} else if (glfwGetKey('A')) {
gCamera.offsetPositon(secondsElapsed * moveSpeed * -gCamera.right());
} else if (glfwGetKey('D')) {
gCamera.offsetPositon(secondsElapsed * moveSpeed * gCamera.right());
}
if (glfwGetKey('Z')) {
gCamera.offsetPositon(secondsElapsed* moveSpeed * -glm::vec3(0,1,0));
} else if (glfwGetKey('X')) {
gCamera.offsetPositon(secondsElapsed * moveSpeed * glm::vec3(0,1,0));
}
// change light color
if(glfwGetKey('1'))
gLight.intensities = glm::vec3(0.8, 0.3, 0.0); //red
else if(glfwGetKey('2'))
gLight.intensities = glm::vec3(0.0, 0.8, 0.2); //green
else if (glfwGetKey('3'))
gLight.intensities = glm::vec3(0.1, 0.3, 0.8);
else if(glfwGetKey('4'))
gLight.intensities = glm::vec3(1,1,1); //white
//mouse movement with camera
const float mouseSensitivity = 0.1;
int mouseX, mouseY;
glfwGetMousePos(&mouseX, &mouseY);
gCamera.offsetOrientation(mouseSensitivity* mouseY, mouseSensitivity* mouseX);
glfwSetMousePos(0,0);
//mouse wheel with field of view
const float zoomSensitivity = -0.8;
float fieldOfView = gCamera.fieldOfView() + zoomSensitivity *(float)glfwGetMouseWheel();
if(fieldOfView < 5.0f) fieldOfView = 5.0f;
if(fieldOfView > 130.0f) fieldOfView = 130.0f;
gCamera.setFieldOfView(fieldOfView);
if (glfwGetMouseButton(0)) //press left button to reset the Fov;
gCamera.setFieldOfView(50.0f);
glfwSetMouseWheel(0);
}