コード例 #1
0
ファイル: Scene.cpp プロジェクト: kbladin/shading_tests
Scene::Scene(Camera* cam) : cam_(cam)
{
  //meshes_.push_back(new MyMesh("../data/meshes/bunny.obj"));
  render_textures_.push_back(new RenderTexture(4*640,4*480));
  render_textures_.push_back(new RenderTexture(4*640,4*480));
  render_textures_.push_back(new RenderTexture(4*640,4*480));
  render_textures_.push_back(new RenderTexture(640/2,480/2));
  render_textures_.push_back(new RenderTexture(640/2,480/2));

  for (int i = 0; i < SettingsManager::Instance()->N_LIGHTSOURCES; ++i)
  {
    light_sources_.push_back(LightSource());
    light_source_meshes_.push_back(new MyMesh("../data/meshes/icosphere.obj"));
  }
}
コード例 #2
0
CAMLprim value lightsource_process(value record_lightsource,
                                   value list_polygon_objects,
                                   value polygon_view) {
  CAMLparam3(record_lightsource, list_polygon_objects, polygon_view);
  CAMLlocal5(polygon_prev_head, list_polygon_head, vector_prev_head,
             list_vector_head, tmp_polygon);
  CAMLlocal1(tmp_vector);
  LightSource l = LightSource(Vector_val(Field(record_lightsource, 0)),
                              Double_val(Field(record_lightsource, 1)),
                              Double_val(Field(record_lightsource, 2)));
  std::vector<Polygon> tmp_polygon_list = std::vector<Polygon>();
  polygon_list_to_std_vector(list_polygon_objects, &tmp_polygon_list);
  std::vector<Vector> tmp_vector_list = std::vector<Vector>();
  vector_list_to_std_vector(Field(polygon_view, 0), &tmp_vector_list);
  Polygon polygon = Polygon(tmp_vector_list);
  // auto start = std::chrono::steady_clock::now();
  std::vector<Polygon> list_polygon = l.process(tmp_polygon_list);
  // auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
  //     std::chrono::steady_clock::now() - start);
  // printf("--> %lld\n", duration.count());
  polygon_prev_head = Val_unit;
  for (Polygon p : list_polygon) {
    vector_prev_head = Val_unit;
    for (Vector v : p.get_vertices()) {
      tmp_vector = caml_alloc_small(2, Double_array_tag);
      Double_field(tmp_vector, 0) = v.x;
      Double_field(tmp_vector, 1) = v.y;
      list_vector_head = caml_alloc_small(2, 0);
      Field(list_vector_head, 0) = tmp_vector;
      Field(list_vector_head, 1) = vector_prev_head;
      vector_prev_head = list_vector_head;
    }
    tmp_polygon = caml_alloc_small(1, 0);
    Field(tmp_polygon, 0) = list_vector_head;

    list_polygon_head = caml_alloc_small(2, 0);
    Field(list_polygon_head, 0) = tmp_polygon;
    Field(list_polygon_head, 1) = polygon_prev_head;
    polygon_prev_head = list_polygon_head;
  }
  CAMLreturn(list_polygon_head);
}
コード例 #3
0
ファイル: NewHorizon.cpp プロジェクト: Starkus/NewHorizon
#define RADIANS(i) i * 2 * 3.1415 / 360.0


int window;

long timer = 0;

GLuint programID;

bool left_button = false;
bool right_button = false;
int last_x, last_y;
float zoom = 5;

Camera camera;
LightSource light0 = LightSource(GL_LIGHT0);

Mesh mesh;
GLuint vboi = 0;
GLuint iboi = 0;
VBO vbo;
Object obj((char*) "car", &vbo);

GLuint test_texture;


glm::mat4 projection, view, model;
glm::vec4 lightPos, lightDiff, lightSpec;
// Uniforms
GLuint uTex;
GLuint uProjection, uView, uModel;