当前位置: 首页>>代码示例>>C++>>正文


C++ target_camera类代码示例

本文整理汇总了C++中target_camera的典型用法代码示例。如果您正苦于以下问题:C++ target_camera类的具体用法?C++ target_camera怎么用?C++ target_camera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了target_camera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render

bool render() {
  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Bind effect
    renderer::bind(eff);
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    auto V = cam.get_view();
    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
                       1,                               // Number of values - 1 mat4
                       GL_FALSE,                        // Transpose the matrix?
                       value_ptr(MVP));                 // Pointer to matrix data

    // *********************************
    // Set N matrix uniform - remember - 3x3 matrix
	glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(m.get_transform().get_transform_matrix()));
    // Set material colour - all objects red
	glUniform4fv(eff.get_uniform_location("material_colour"), 1, value_ptr(vec4(1.0f, 0.0f, 0.0f, 1.0f)));
    // Set light colour- (1.0, 1.0, 1.0, 1.0)
	glUniform4fv(eff.get_uniform_location("light_colour"), 1, value_ptr(vec4(1.0f, 1.0f, 1.0f, 1.0f)));
    // Set light direction - (1.0, 1.0, -1.0)
	glUniform3fv(eff.get_uniform_location("light_dir"), 1, value_ptr(vec3(1.0f, 1.0f, -1.0f)));

    // *********************************
    // Render mesh
    renderer::render(m);
  }

  return true;
}
开发者ID:40167459,项目名称:set08116,代码行数:34,代码来源:44_Diffuse_Light_2.cpp

示例2: 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;
}
开发者ID:dooglz,项目名称:set08116,代码行数:26,代码来源:17_Full_Transformation.cpp

示例3: 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;
}
开发者ID:40167459,项目名称:set08116,代码行数:31,代码来源:59_Tarnished_Object.cpp

示例4: render

bool render() {
  // Bind effect
  renderer::bind(eff);
  // Create MVP matrix
  auto M = m.get_transform().get_transform_matrix();
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
                     1,                               // Number of values - 1 mat4
                     GL_FALSE,                        // Transpose the matrix?
                     value_ptr(MVP));                 // Pointer to matrix data

  // *********************************
  // Bind texture to renderer
  renderer::bind(tex, 1);
  // Set the texture value for the shader here
  glUniform1i(eff.get_uniform_location(" tex"), 0);
  // *********************************

  // Render the mesh
  renderer::render(m);

  return true;
}
开发者ID:40167459,项目名称:set08116,代码行数:26,代码来源:28_Repeat_Textures.cpp

示例5: render

bool render()
{
	// Bind effect
	renderer::bind(eff);
	// Create MVP matrix
	auto M = m.get_transform().get_transform_matrix();
	auto V = cam.get_view();
	auto P = cam.get_projection();
	auto MVP = P * V * M;
	// Set MVP matrix uniform
	glUniformMatrix4fv(
		eff.get_uniform_location("MVP"),
		1,
		GL_FALSE,
		value_ptr(MVP));

	// Bind and set texture
	renderer::bind(tex, 0);
	glUniform1i(eff.get_uniform_location("tex"), 0);

	// Render mesh
	renderer::render(m);

	return true;
}
开发者ID:Zoeoeh,项目名称:Coursework-ComputerGraphics,代码行数:25,代码来源:main.cpp

示例6: 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;
}
开发者ID:40167459,项目名称:set08116,代码行数:25,代码来源:33_Dissolve.cpp

示例7: render

bool render() {
  // Bind effect
  renderer::bind(eff);

  // Create MVP matrix
  auto M = m.get_transform().get_transform_matrix();
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;

  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
                     1,                               // Number of values - 1 mat4
                     GL_FALSE,                        // Transpose the matrix?
                     value_ptr(MVP));                 // Pointer to matrix data

  // *********************************
  // Set the dissolve_factor uniform value

  // Bind the two textures - use different index for each


  // Set the uniform values for textures - use correct index


  // *********************************

  // Set UV_scroll uniform, adds cool movent (Protip: This is a super easy way to do fire effects;))
  glUniform2fv(eff.get_uniform_location("UV_SCROLL"), 1, value_ptr(uv_scroll));
  // Render the mesh
  renderer::render(m);

  return true;
}
开发者ID:40167459,项目名称:set08116,代码行数:34,代码来源:33_Dissolve.cpp

示例8: 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;
}
开发者ID:Zoeoeh,项目名称:Coursework-ComputerGraphics,代码行数:27,代码来源:main.cpp

示例9: render

bool render() {
  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Bind effect
    renderer::bind(eff);
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    auto V = cam.get_view();
    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));

    // *********************************
    // Set material colour - all objects red
	glUniform4fv(eff.get_uniform_location("material_colour"), 1, value_ptr(vec4(1.0f, 0.0f, 0.0f, 1.0f)));
    // Set ambient intensity - (0.3, 0.3, 0.3, 1.0)
	glUniform4fv(eff.get_uniform_location("ambient_intensity"), 1, value_ptr(vec4(0.3f, 0.3f, 0.3f, 1.0)));
    // *********************************
    // Render mesh
    renderer::render(m);
  }

  return true;
}
开发者ID:DelbyPicnic,项目名称:set08116,代码行数:26,代码来源:42_Simple_Ambient_Light.cpp

示例10: render

bool render() {
	// *********************************
	// Set render target to frame buffer
	renderer::set_render_target(frame);
	// Clear frame
	renderer::clear();
	// *********************************

	// Render meshes
	for (auto &e : meshes) {
		auto m = e.second;
		// Bind effect
		renderer::bind(eff);
		// Create MVP matrix
		auto M = m.get_transform().get_transform_matrix();
		auto V = cam.get_view();
		auto P = cam.get_projection();
		auto MVP = P * V * M;
		// Set MVP matrix uniform
		glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
		// Create MV matrix
		auto MV = V * M;
		// Set MV matrix uniform
		glUniformMatrix4fv(eff.get_uniform_location("MV"), 1, GL_FALSE, value_ptr(MV));
		// Set M matrix uniform
		glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(M));
		// Set N matrix uniform
		glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(m.get_transform().get_normal_matrix()));
		// Bind material
		renderer::bind(m.get_material(), "mat");
		// Bind light
		renderer::bind(light, "light");
		// Bind texture
		renderer::bind(tex, 0);
		// Set tex uniform
		glUniform1i(eff.get_uniform_location("tex"), 0);
		// Set eye position
		glUniform3fv(eff.get_uniform_location("eye_pos"), 1, value_ptr(cam.get_position()));
		// Render mesh
		renderer::render(m);
	}

	// *********************************
	// Set render target back to the screen
	renderer::set_render_target();
	// Bind Tex effect
	renderer::bind(tex_eff);
	// MVP is now the identity matrix
	auto MVP = glm::mat4();
	// Set MVP matrix uniform
	glUniformMatrix4fv(tex_eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
	// Bind texture from frame buffer
	renderer::bind(frame.get_frame(), 0);
	// Set the tex uniform
	glUniform1i(tex_eff.get_uniform_location("tex"), 0);
	// Render the screen quad
	renderer::render(screen_quad);
	// *********************************
	return true;
}
开发者ID:40167459,项目名称:set08116,代码行数:60,代码来源:71_Greyscale.cpp

示例11: render

bool render() {
  // Render meshes
  for (auto &e : meshes) {
    auto m = e.second;
    // Bind effect
    renderer::bind(eff);
    // Create MVP matrix
    auto M = m.get_transform().get_transform_matrix();
    auto V = cam.get_view();
    auto P = cam.get_projection();
    auto MVP = P * V * M;
    // Set MVP matrix uniform
    glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
    // *********************************
    // Set M matrix uniform
	glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(m.get_transform().get_transform_matrix()));
    // Set N matrix uniform - remember - 3x3 matrix
	glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(m.get_transform().get_normal_matrix()));
    // Set material colour - specular material is white
	glUniform4fv(eff.get_uniform_location("material_colour"), 1, value_ptr(vec4(1.0f, 1.0f, 1.0f, 1.0f)));
    // Set shininess - Use 50.0f
	glUniform1f(eff.get_uniform_location("shininess"), 50.0f);
    // Set light colour - (1.0, 1.0, 1.0, 1.0)
	glUniform4fv(eff.get_uniform_location("light_colour"), 1, value_ptr(vec4(1.0f, 1.0f, 1.0f, 1.0f)));
    // Set light direction- (1.0, 1.0, -1.0)
	glUniform3fv(eff.get_uniform_location("light_dir"), 1, value_ptr(vec3(1.0f, 1.0f, -1.0f)));
    // Set eye position - Get this from active camera
	glUniform3fv(eff.get_uniform_location("eye_pos"), 1, value_ptr(vec3(cam.get_position())));
    // *********************************
    // Render mesh
    renderer::render(m);
  }

  return true;
}
开发者ID:40167459,项目名称:set08116,代码行数:35,代码来源:45_Specular_Light.cpp

示例12: 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;
}
开发者ID:40167459,项目名称:set08116,代码行数:8,代码来源:34_Simple_Cell_Shading.cpp

示例13: 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;
}
开发者ID:rossco292,项目名称:set08116,代码行数:55,代码来源:53_Shadow_Mapping.cpp

示例14: 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;
}
开发者ID:dooglz,项目名称:set08116,代码行数:55,代码来源:22_Indexed_Cube.cpp

示例15: render

bool render() {
  // Bind effect
  renderer::bind(eff);
  // Create MVP matrix
  mat4 M = eulerAngleXZ(theta, rho);
  auto V = cam.get_view();
  auto P = cam.get_projection();
  auto MVP = P * V * M;
  // Set MVP matrix uniform
  glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
  // Render geometry
  renderer::render(geom);
  return true;
}
开发者ID:dooglz,项目名称:set08116,代码行数:14,代码来源:22_Indexed_Cube.cpp


注:本文中的target_camera类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。