本文整理汇总了C++中target_camera::set_position方法的典型用法代码示例。如果您正苦于以下问题:C++ target_camera::set_position方法的具体用法?C++ target_camera::set_position怎么用?C++ target_camera::set_position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类target_camera
的用法示例。
在下文中一共展示了target_camera::set_position方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_content
bool load_content() {
// *********************************
// Create a sphere
// Create box geometry for skybox
// Scale box by 100 - allows a distance
// Load the cubemap - create array of six filenames +x, -x, +y, -y, +z, -z
// Create cube_map
// Load in tarnish texture
// Load in environment map shader
// Build effect
// Load in skybox effect
// Build effect
// *********************************
// Set camera properties
cam.set_position(vec3(0.0f, 0.0f, 10.0f));
cam.set_projection(quarter_pi<float>(), renderer::get_screen_aspect(), 0.1f, 1000.0f);
return true;
}
示例2: load_content
bool load_content()
{
// *************
// Load in model
// *************
m = mesh(geometry("..\\resources\\models\\teapot.obj"));
// ***************
// Load in texture
// ***************
tex = texture("..\\resources\\textures\\checked.gif", false, false);
// Load in shaders
eff.add_shader("..\\resources\\shaders\\simple_texture.vert", GL_VERTEX_SHADER);
eff.add_shader("..\\resources\\shaders\\simple_texture.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(200.0f, 200.0f, 200.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
示例3: update
bool update(float delta_time) {
// *********************************
// Use keyboard to change camera location
// 1 - (50, 10, 50)
if (glfwGetKey(renderer::get_window(), GLFW_KEY_UP)) {
cam.set_position(vec3(50.0f, 10.0f, 50.0f));
}
// 2 - (-50, 10, 50)
// 3 - (-50, 10, -50)
// 4 - (50, 10, -50)
// Update the camera
// *********************************
return true;
}
示例4: load_content
bool load_content() {
geom.set_type(GL_TRIANGLE_STRIP);
// Create quad data
// Positions
vector<vec3> positions{vec3(-1.0f, -1.0f, 0.0f), vec3(1.0f, -1.0f, 0.0f), vec3(-1.0f, 1.0f, 0.0f),
vec3(1.0f, 1.0f, 0.0f)};
// Colours
vector<vec4> colours{vec4(1.0f, 0.0f, 0.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f),
vec4(1.0f, 0.0f, 0.0f, 1.0f)};
// Add to the geometry
geom.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
geom.add_buffer(colours, BUFFER_INDEXES::COLOUR_BUFFER);
// Load in shaders
eff.add_shader("shaders/basic.vert", GL_VERTEX_SHADER);
eff.add_shader("shaders/basic.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(10.0f, 10.0f, 10.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
示例5: load_content
bool load_content() {
// Create mesh object, cheating and using the mesh builder for now
m = mesh(geometry_builder::create_box());
// Scale geometry
m.get_transform().scale = vec3(10.0f);
// Load in dissolve shader
eff.add_shader("33_Dissolve/dissolve.vert", GL_VERTEX_SHADER);
eff.add_shader("33_Dissolve/dissolve.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Load in textures
tex = texture("textures/checker.png");
dissolve = texture("textures/blend_map2.jpg");
// Set camera properties
cam.set_position(vec3(30.0f, 30.0f, 30.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
示例6: update
bool update(float delta_time) {
if (glfwGetKey(renderer::get_window(), '1'))
cam.set_position(vec3(50, 10, 50));
if (glfwGetKey(renderer::get_window(), '2'))
cam.set_position(vec3(-50, 10, 50));
if (glfwGetKey(renderer::get_window(), '3'))
cam.set_position(vec3(-50, 10, -50));
if (glfwGetKey(renderer::get_window(), '4'))
cam.set_position(vec3(50, 10, -50));
// Rotate the sphere
meshes["sphere"].get_transform().rotate(vec3(0.0f, half_pi<float>(), 0.0f) * delta_time);
cam.update(delta_time);
return true;
}
示例7: update
bool update(float delta_time) {
// Update camera
static float x = 0.0f;
x += delta_time;
cam.set_position(vec3(10.0f * sinf(x), 10.0f, 10.0f * cosf(x)));
cam.update(delta_time);
return true;
}
示例8: update
bool update(float delta_time) {
if (glfwGetKey(renderer::get_window(), '1')) {
cam.set_position(vec3(50, 10, 50));
}
if (glfwGetKey(renderer::get_window(), '2')) {
cam.set_position(vec3(-50, 10, 50));
}
if (glfwGetKey(renderer::get_window(), '3')) {
cam.set_position(vec3(-50, 10, -50));
}
if (glfwGetKey(renderer::get_window(), '4')) {
cam.set_position(vec3(50, 10, -50));
}
cam.update(delta_time);
return true;
}
示例9: load_content
bool load_content() {
// *********************************
// Create shadow map- use screen size
shadow = shadow_map(renderer::get_screen_width(), renderer::get_screen_height());
// Create plane mesh
meshes["plane"] = mesh(geometry_builder::create_plane());
// Create "teapot" mesh by loading in models/teapot.obj
meshes["teapot"] = mesh(geometry("models/teapot.obj"));
// Need to rotate the teapot on x by negative pi/2
meshes["teapot"].get_transform().rotate(vec3(-90.0, 0.0, 0.0));
// Scale the teapot - (0.1, 0.1, 0.1)
meshes["teapot"].get_transform().scale = vec3(0.1,0.1,0.1);
// ***********************
// Set materials
// - all emissive is black
// - all specular is white
// - all shininess is 25
// ***********************
// White plane
meshes["plane"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["plane"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["plane"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["plane"].get_material().set_shininess(25.0f);
// Red teapot
meshes["teapot"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["teapot"].get_material().set_diffuse(vec4(1.0f, 0.0f, 0.0f, 1.0f));
meshes["teapot"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["teapot"].get_material().set_shininess(25.0f);
// *********************************
// Set spot properties
// Pos (20, 30, 0), White
// Direction (-1, -1, 0) normalized
// 50 range, 10 power
spot.set_position(vec3(20.0f, 30.0f, 0.0f));
spot.set_light_colour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
spot.set_direction(normalize(vec3(-1.0f, -1.0f, 0.0f)));
spot.set_range(50.0f);
spot.set_power(10.0f);
// Load in shaders
shadow_eff.add_shader("50_Spot_Light/spot.vert", GL_VERTEX_SHADER);
shadow_eff.add_shader("50_Spot_Light/spot.frag", GL_FRAGMENT_SHADER);
// Build effect
shadow_eff.build();
// Set camera properties
cam.set_position(vec3(0.0f, 20.0f, -30.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
cam.set_projection(quarter_pi<float>(), renderer::get_screen_aspect(), 0.1f, 1000.0f);
return true;
}
示例10: load_content
bool load_content() {
// Create cube data - eight corners
// Positions
vector<vec3> positions{
// *********************************
// Add the position data for cube corners here (8 total)
// *********************************
};
// Colours
vector<vec4> colours;
for (auto i = 0; i < positions.size(); ++i) {
colours.push_back(vec4((i + 1) % 2, 0.0f, i % 2, 1.0f));
}
// Create the index buffer
vector<GLuint> indices{
// *********************************
// Add index information here - 3 per triangle, 6 per face, 12 triangles
// Front
// Back
// Right
// Left
// Top
// Bottom
// *********************************
};
// Add to the geometry
geom.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
geom.add_buffer(colours, BUFFER_INDEXES::COLOUR_BUFFER);
// ****************************
// Add index buffer to geometry
// ****************************
geom.add_index_buffer(indices);
// Load in shaders
eff.add_shader("shaders/basic.vert", GL_VERTEX_SHADER);
eff.add_shader("shaders/basic.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(10.0f, 10.0f, 10.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
示例11: load_content
bool load_content() {
// Construct geometry object
geometry geom;
// Create triangle data
// Positions
vector<vec3> positions{vec3(0.0f, 1.0f, 0.0f), vec3(-1.0f, -1.0f, 0.0f), vec3(1.0f, -1.0f, 0.0f)};
// *********************************
// Define texture coordinates for triangle
vector<vec2> UVs{ vec2(0.0f, 1.0f),
vec2(-1.0f, -1.0f),
vec2(1.0f, -1.0f) };
// *********************************
// Add to the geometry
geom.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
// *********************************
// Add texture coordinate buffer to geometry
geom.add_buffer(positions, BUFFER_INDEXES::TEXTURE_COORDS_0);
// *********************************
// Create mesh object
m = mesh(geom);
m2 = mesh(geom);
m2.get_transform().translate(vec3(5.0f, 1.0f, 1.0f));
// Load in texture shaders here
eff.add_shader("27_Texturing_Shader/simple_texture.vert", GL_VERTEX_SHADER);
eff.add_shader("27_Texturing_Shader/simple_texture.frag", GL_FRAGMENT_SHADER);
// *********************************
// Build effect
eff.build();
// Load texture "textures/sign.jpg"
tex = texture("textures/sign.jpg");
tex2 = texture("textures/stonygrass.jpg");
// *********************************
// Set camera properties
cam.set_position(vec3(10.0f, 10.0f, 10.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
示例12: load_content
bool load_content() {
// Create plane mesh
meshes["plane"] = mesh(geometry_builder::create_plane());
// Create scene
meshes["box"] = mesh(geometry_builder::create_box());
meshes["tetra"] = mesh(geometry_builder::create_tetrahedron());
meshes["pyramid"] = mesh(geometry_builder::create_pyramid());
meshes["disk"] = mesh(geometry_builder::create_disk(20));
meshes["cylinder"] = mesh(geometry_builder::create_cylinder(20, 20));
meshes["sphere"] = mesh(geometry_builder::create_sphere(20, 20));
meshes["torus"] = mesh(geometry_builder::create_torus(20, 20, 1.0f, 5.0f));
// Transform objects
meshes["box"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["box"].get_transform().translate(vec3(-10.0f, 2.5f, -30.0f));
meshes["tetra"].get_transform().scale = vec3(4.0f, 4.0f, 4.0f);
meshes["tetra"].get_transform().translate(vec3(-30.0f, 10.0f, -10.0f));
meshes["pyramid"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["pyramid"].get_transform().translate(vec3(-10.0f, 7.5f, -30.0f));
meshes["disk"].get_transform().scale = vec3(3.0f, 1.0f, 3.0f);
meshes["disk"].get_transform().translate(vec3(-10.0f, 11.5f, -30.0f));
meshes["disk"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
meshes["cylinder"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["cylinder"].get_transform().translate(vec3(-25.0f, 2.5f, -25.0f));
meshes["sphere"].get_transform().scale = vec3(2.5f, 2.5f, 2.5f);
meshes["sphere"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
// Load texture
tex = texture("textures/checker.png");
// Load in shaders
eff.add_shader("27_Texturing_Shader/simple_texture.vert", GL_VERTEX_SHADER);
eff.add_shader("27_Texturing_Shader/simple_texture.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(50.0f, 10.0f, 50.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
cam.set_projection(quarter_pi<float>(), renderer::get_screen_aspect(), 0.1f, 1000.0f);
return true;
}
示例13: load_content
bool load_content() {
// Construct geometry object
geometry geom;
// Required buffers
vector<vec3> positions;
vector<vec3> normals;
// Define the initial tetrahedron - 4 points
vector<vec3> v{vec3(0.0f, 0.0f, 1.0f), vec3(0.0f, 0.942809f, -0.333333f), vec3(-0.816497f, -0.471405f, -0.333333f),
vec3(0.816497f, -0.471405f, 0.333333f)};
// Divide the triangles
divide_triangle({v[0], v[1], v[2]}, subdivisions, positions);
divide_triangle({v[3], v[2], v[1]}, subdivisions, positions);
divide_triangle({v[0], v[3], v[1]}, subdivisions, positions);
divide_triangle({v[0], v[2], v[3]}, subdivisions, positions);
// Copy positions (already normalized) into normals buffer
normals.insert(normals.end(), positions.begin(), positions.end());
// Add buffers to geometry
geom.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
geom.add_buffer(normals, BUFFER_INDEXES::NORMAL_BUFFER);
// Create mesh object
m = mesh(geom);
// Load in simple cell shader
eff.add_shader("34_Simple_Cell_Shading/simple_cell.vert", GL_VERTEX_SHADER);
eff.add_shader("34_Simple_Cell_Shading/simple_cell.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Colour scale from red to black
vector<vec4> colour_data{vec4(0.12f, 0.0f, 0.0f, 1.0f), vec4(0.25f, 0.0f, 0.0f, 1.0f), vec4(0.5f, 0.0f, 0.0f, 1.0f),
vec4(1.0f, 0.0f, 0.0f, 1.0f)};
// Create 1D 4x1 texture from colour_data
tex = texture(colour_data, 4, 1, false, false);
// Set camera properties
cam.set_position(vec3(10.0f, 10.0f, 10.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
示例14: load_content
bool load_content() {
// Set to points type
geom.set_type(GL_POINTS);
// Create sierpinski gasket
create_sierpinski(geom);
// Load in shaders
eff.add_shader("shaders/basic.vert", GL_VERTEX_SHADER);
eff.add_shader("shaders/basic.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(2.0f, 2.0f, 2.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
示例15: load_content
bool load_content() {
// *********************************
// Load in model, models/teapot.obj
mesh m(geometry("models/teapot.obj"));
// Load in texture, textures/checker.png
tex = texture("textures/checker.png");
// *********************************
// Load in shaders
eff.add_shader("27_Texturing_Shader/simple_texture.vert", GL_VERTEX_SHADER);
eff.add_shader("27_Texturing_Shader/simple_texture.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(200.0f, 200.0f, 200.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
cam.set_projection(quarter_pi<float>(), renderer::get_screen_aspect(), 0.1f, 1000.0f);
return true;
}