本文整理汇总了C++中CameraController::setFar方法的典型用法代码示例。如果您正苦于以下问题:C++ CameraController::setFar方法的具体用法?C++ CameraController::setFar怎么用?C++ CameraController::setFar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CameraController
的用法示例。
在下文中一共展示了CameraController::setFar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initScene
void initScene() {
camera.setFar(1000.0f);
// load scene.obj from disk and create renderable MeshObj //
objLoader.loadObjFile("../meshes/testbox.obj", "sceneObject");
// init materials //
Material mat;
mat.ambient_color = glm::vec3(1.0, 1.0, 1.0);
mat.diffuse_color = glm::vec3(0.8, 1.0, 0.5);
mat.specular_color = glm::vec3(1.0, 1.0, 1.0);
mat.specular_shininess = 5.0;
materials.push_back(mat);
// save material count for later and select first material //
materialCount = materials.size();
materialIndex = 0;
// init light //
light.ambient_color = glm::vec3(0.05, 0.05, 0.05);
light.diffuse_color = glm::vec3(1.0, 1.0, 1.0);
light.specular_color = glm::vec3(1.0, 1.0, 1.0);
light.position = initialLightPos;
}
示例2: keyboardEvent
void keyboardEvent(unsigned char key, int x, int y) {
switch (key) {
case 'x':
case 27 : {
exit(0);
break;
}
case 'w': {
// move forward //
camera.move(CameraController::MOVE_FORWARD);
break;
}
case 's': {
// move backward //
camera.move(CameraController::MOVE_BACKWARD);
break;
}
case 'a': {
// move left //
camera.move(CameraController::MOVE_LEFT);
break;
}
case 'd': {
// move right //
camera.move(CameraController::MOVE_RIGHT);
break;
}
case 'z': {
camera.setOpeningAngle(camera.getOpeningAngle() + 0.1f);
break;
}
case 'h': {
camera.setOpeningAngle(std::min(std::max(camera.getOpeningAngle() - 0.1f, 1.0f), 180.0f));
break;
}
case 'r': {
camera.setNear(std::min(camera.getNear() + 0.1f, camera.getFar() - 0.01f));
break;
}
case 'f': {
camera.setNear(std::max(camera.getNear() - 0.1f, 0.1f));
break;
}
case 't': {
camera.setFar(camera.getFar() + 0.1f);
break;
}
case 'g': {
camera.setFar(std::max(camera.getFar() - 0.1f, camera.getNear() + 0.01f));
break;
}
case 'm': {
materialIndex++;
if (materialIndex >= materialCount) materialIndex = 0;
break;
}
case '5': {
// reset light pos //
light.position = initialLightPos;
lightSourcePosUpdate = true;
break;
}
case '4': {
// move light source left //
light.position.x -= 0.05f;
lightSourcePosUpdate = true;
break;
}
case '6': {
// move light source right //
light.position.x += 0.05f;
lightSourcePosUpdate = true;
break;
}
case '2': {
// move light source backward //
light.position.z += 0.05f;
lightSourcePosUpdate = true;
break;
}
case '8': {
// move light source forward //
light.position.z -= 0.05f;
lightSourcePosUpdate = true;
break;
}
case '+': {
// move light source up //
light.position.y += 0.05f;
lightSourcePosUpdate = true;
break;
}
case '-': {
// move light source down //
light.position.y -= 0.05f;
lightSourcePosUpdate = true;
break;
}
}
glutPostRedisplay();
//.........这里部分代码省略.........
示例3: keyboardEvent
void keyboardEvent(unsigned char key, int x, int y) {
switch (key) {
case 'x':
case 27 : {
exit(0);
break;
}
case 'w': {
// move forward //
camera.move(CameraController::MOVE_FORWARD);
break;
}
case 's': {
// move backward //
camera.move(CameraController::MOVE_BACKWARD);
break;
}
case 'a': {
// move left //
camera.move(CameraController::MOVE_LEFT);
break;
}
case 'd': {
// move right //
camera.move(CameraController::MOVE_RIGHT);
break;
}
case 'z': {
camera.setOpeningAngle(camera.getOpeningAngle() + 0.1f);
break;
}
case 'h': {
camera.setOpeningAngle(std::min(std::max(camera.getOpeningAngle() - 0.1f, 1.0f), 180.0f));
break;
}
case 'r': {
camera.setNear(std::min(camera.getNear() + 0.1f, camera.getFar() - 0.01f));
break;
}
case 'f': {
camera.setNear(std::max(camera.getNear() - 0.1f, 0.1f));
break;
}
case 't': {
camera.setFar(camera.getFar() + 0.1f);
break;
}
case 'g': {
camera.setFar(std::max(camera.getFar() - 0.1f, camera.getNear() + 0.01f));
break;
}
case 'm': {
materialIndex++;
if (materialIndex >= materialCount) materialIndex = 0;
break;
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': {
int lightIdx;
std::stringstream keyStr;
keyStr << key;
keyStr >> lightIdx;
if (lightIdx == 0) lightIdx = 10;
if (lightIdx > 0) toggleLightSource(lightIdx - 1);
break;
}
}
glutPostRedisplay();
}
示例4: keyboardEvent
void keyboardEvent(unsigned char key, int x, int y) {
switch (key) {
case 'x':
case 27 : {
exit(0);
break;
}
case 'w': {
// move forward //
camera.move(CameraController::MOVE_FORWARD);
break;
}
case 's': {
// move backward //
camera.move(CameraController::MOVE_BACKWARD);
break;
}
case 'a': {
// move left //
camera.move(CameraController::MOVE_LEFT);
break;
}
case 'd': {
// move right //
camera.move(CameraController::MOVE_RIGHT);
break;
}
case 'z': {
camera.setOpeningAngle(camera.getOpeningAngle() + 0.1f);
break;
}
case 'h': {
camera.setOpeningAngle(std::min(std::max(camera.getOpeningAngle() - 0.1f, 1.0f), 180.0f));
break;
}
case 'r': {
camera.setNear(std::min(camera.getNear() + 0.1f, camera.getFar() - 0.01f));
break;
}
case 'f': {
camera.setNear(std::max(camera.getNear() - 0.1f, 0.1f));
break;
}
case 't': {
camera.setFar(camera.getFar() + 0.1f);
break;
}
case 'g': {
camera.setFar(std::max(camera.getFar() - 0.1f, camera.getNear() + 0.01f));
break;
}
case 'm': {
materialIndex++;
if (materialIndex >= materialCount) materialIndex = 0;
break;
}
case 'l': {
lightIndex++;
if (lightIndex >= lightCount) lightIndex = 0;
break;
}
}
glutPostRedisplay();
}