예제 #1
0
void scotland_update() {
  
  camera* cam = entity_get("camera");
  light* sun = entity_get("sun");
  static_object* skydome = entity_get("skydome");
  landscape* world = entity_get("world");
  
  sun_orbit += frame_time() * 0.01;
  
  sun->position.x = 512 + sin(sun_orbit) * 512;
  sun->position.y = cos(sun_orbit) * 512;
  sun->position.z = 512;
  sun->target = vec3_new(512, 0, 512);
  
  if (w_held || s_held) {
    
    vec3 cam_dir = vec3_normalize(vec3_sub(cam->target, cam->position));
    float speed = 0.5;
    if (!freecam) speed = 0.05;
    if (w_held) {
      cam->position = vec3_add(cam->position, vec3_mul(cam_dir, speed));
    }
    if (s_held) {
      cam->position = vec3_sub(cam->position, vec3_mul(cam_dir, speed));
    }
    
    if (!freecam) {
      float height = terrain_height(asset_hndl_ptr(world->terrain), vec2_new(cam->position.x, cam->position.z));
      cam->position.y = height + 1;
    }
    
    cam->target = vec3_add(cam->position, cam_dir);
  }
  
  Uint8 keystate = SDL_GetMouseState(NULL, NULL);
  if(keystate & SDL_BUTTON(1)){
  
    float a1 = -(float)mouse_x * 0.005;
    float a2 = (float)mouse_y * 0.005;
    
    vec3 cam_dir = vec3_normalize(vec3_sub(cam->target, cam->position));
    
    cam_dir.y += -a2;
    vec3 side_dir = vec3_normalize(vec3_cross(cam_dir, vec3_new(0,1,0)));
    cam_dir = vec3_add(cam_dir, vec3_mul(side_dir, -a1));
    cam_dir = vec3_normalize(cam_dir);
    
    cam->target = vec3_add(cam->position, cam_dir);
  }
  
  mouse_x = 0;
  mouse_y = 0;
  
  ui_button* framerate = ui_elem_get("framerate");
  ui_button_set_label(framerate, frame_rate_string());
}
예제 #2
0
ui_dialog* ui_dialog_new() {
  
  ui_dialog* d = malloc(sizeof(ui_dialog));
  
  int width  = graphics_viewport_width();
  int height = graphics_viewport_height();
  
  d->back = ui_button_new();
  ui_button_move(d->back, vec2_new(width/2 - 200, height/2 - 100));
  ui_button_resize(d->back, vec2_new(400, 200));
  ui_button_set_label(d->back, "");
  ui_button_disable(d->back);
  
  d->title = ui_text_new();
  ui_text_move(d->title, vec2_new(width/2, height/2 - 50));
  ui_text_align(d->title, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
  ui_text_set_scale(d->title, vec2_new(1.25, 1.25));
  ui_text_set_color(d->title, vec4_light_grey());
  ui_text_draw_string(d->title, "Title");
  
  d->contents = ui_text_new();
  ui_text_move(d->contents, vec2_new(width/2, height/2 - 00));
  ui_text_align(d->contents, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
  ui_text_set_color(d->contents, vec4_light_grey());
  ui_text_draw_string(d->contents, "Contents");
  
  d->left = ui_button_new();
  ui_button_move(d->left, vec2_new(width/2 - 175, height/2 + 40));
  ui_button_resize(d->left, vec2_new(150, 40));
  ui_button_set_label(d->left, "Left");
  
  d->right = ui_button_new();
  ui_button_move(d->right, vec2_new(width/2 + 20, height/2 + 40)); 
  ui_button_resize(d->right, vec2_new(150, 40));
  ui_button_set_label(d->right, "Right");
  
  dialog_count++;
  
  return d;
  
}
예제 #3
0
파일: sea.c 프로젝트: RicoP/Corange
void sea_update() {

    camera* cam = entity_get("camera");
    light* sun = entity_get("sun");

    wave_time += frame_time();
    static_object* corvette = entity_get("corvette");
    corvette->position.y = (sin(wave_time) + 1) / 2;
    corvette->rotation = v4_quaternion_pitch(sin(wave_time * 1.123) / 50);
    corvette->rotation = v4_quaternion_mul(corvette->rotation, v4_quaternion_yaw(sin(wave_time * 1.254) / 25));
    corvette->rotation = v4_quaternion_mul(corvette->rotation, v4_quaternion_roll(sin(wave_time * 1.355) / 100));

    static_object* center_sphere = entity_get("center_sphere");

    physics_object* balls[100];
    int num_balls;
    entities_get(balls, &num_balls, physics_object);
    for(int i = 0; i < num_balls; i++) {
        physics_object_collide_static(balls[i], center_sphere, frame_time());
        physics_object_collide_static(balls[i], corvette, frame_time());
        physics_object_update(balls[i], frame_time());
    }

    Uint8 keystate = SDL_GetMouseState(NULL, NULL);
    if(keystate & SDL_BUTTON(1)) {
        float a1 = -(float)mouse_x * 0.01;
        float a2 = (float)mouse_y * 0.01;

        cam->position = v3_sub(cam->position, cam->target);
        cam->position = m33_mul_v3(m33_rotation_y( a1 ), cam->position );
        cam->position = v3_add(cam->position, cam->target);

        cam->position = v3_sub(cam->position, cam->target);
        vector3 rotation_axis = v3_normalize(v3_cross( v3_sub(cam->position, v3_zero()) , v3(0,1,0) ));
        cam->position = m33_mul_v3(m33_rotation_axis_angle(rotation_axis, a2 ), cam->position );
        cam->position = v3_add(cam->position, cam->target);

    }

    if(keystate & SDL_BUTTON(3)) {
        sun->position.x += (float)mouse_y / 2;
        sun->position.z -= (float)mouse_x / 2;
    }

    mouse_x = 0;
    mouse_y = 0;

    ui_button* framerate = ui_elem_get("framerate");
    ui_button_set_label(framerate, frame_rate_string());

}
예제 #4
0
void metaballs_update() {

  camera* cam = entity_get("camera");
  light* sun = entity_get("sun");

  Uint8 keystate = SDL_GetMouseState(NULL, NULL);
  if(keystate & SDL_BUTTON(1)){
    float a1 = -(float)mouse_x * frame_time() * 0.25;
    float a2 = (float)mouse_y * frame_time() * 0.25;
    
    cam->position = v3_sub(cam->position, cam->target);
    cam->position = m33_mul_v3(m33_rotation_y( a1 ), cam->position );
    cam->position = v3_add(cam->position, cam->target);
    
    cam->position = v3_sub(cam->position, cam->target);
    vector3 rotation_axis = v3_normalize(v3_cross( v3_sub(cam->position, v3_zero()) , v3(0,1,0) ));
    cam->position = m33_mul_v3(m33_rotation_axis_angle(rotation_axis, a2 ), cam->position );
    cam->position = v3_add(cam->position, cam->target);
  }
  
  if(keystate & SDL_BUTTON(3)){
    sun->position.x += (float)mouse_y / 2;
    sun->position.z -= (float)mouse_x / 2;
  }

  mouse_x = 0;
  mouse_y = 0;

  particles_update(frame_time());
  
  ui_button* framerate = ui_elem_get("framerate");
  ui_button_set_label(framerate, frame_rate_string());
  
#ifdef MARCHING_CUBES
  marching_cubes_metaball_data( particle_positions_memory(), particles_count() );
  marching_cubes_clear();
  marching_cubes_update();
#endif

#ifdef VOLUME_RENDERER
  volume_renderer_metaball_data( particle_positions_memory(), particles_count() );
  volume_renderer_update();
#endif
  
}
예제 #5
0
void platformer_update() {
  
  character* main_char = entity_get("main_char");
  
  if (left_held) {
    main_char->velocity.x -= 0.1;
    main_char->facing_left = true;
  } else if (right_held) {
    main_char->velocity.x += 0.1;
    main_char->facing_left = false;
  } else {
    main_char->velocity.x *= 0.95;
  }
  
  /* Give the player some gravity speed */
  const float gravity = 0.2;
  main_char->velocity.y += gravity;
  
  /* Update moves position based on velocity */
  character_update(main_char);
  
  /* Two phases of collision detection */
  collision_detection();
  collision_detection_coins();
  
  /* Camera follows main character */
  camera_position = vec2_new(main_char->position.x, -main_char->position.y);
  
  /* Update the framerate text */
  ui_button* framerate = ui_elem_get("framerate");
  ui_button_set_label(framerate, frame_rate_string());
  
  /* Update the time text */
  ui_button* victory = ui_elem_get("victory");
  if (!victory->active) {
    level_time += frame_time();
    ui_button* time = ui_elem_get("time");
    sprintf(time->label->string, "Time %06i", (int)level_time);
      ui_text_draw(time->label);
  }
  
}
예제 #6
0
파일: sea.c 프로젝트: AntonioCS/Corange
void sea_update() {

  camera* cam = entity_get("camera");
  light* sun = entity_get("sun");
  
  wave_time += frame_time();
  static_object* corvette = entity_get("corvette");
  corvette->position.y = (sin(wave_time) + 1) / 2;
  corvette->rotation = quaternion_pitch(sin(wave_time * 1.123) / 50);
  corvette->rotation = quaternion_mul(corvette->rotation, quaternion_yaw(sin(wave_time * 1.254) / 25));
  corvette->rotation = quaternion_mul(corvette->rotation, quaternion_roll(sin(wave_time * 1.355) / 100));
  
  static_object* center_sphere = entity_get("center_sphere");
  
  physics_object* balls[100];
  int num_balls;
  entities_get(balls, &num_balls, physics_object);
  for(int i = 0; i < num_balls; i++) {
    physics_object_collide_static(balls[i], center_sphere, frame_time());
    physics_object_collide_static(balls[i], corvette, frame_time());
    physics_object_update(balls[i], frame_time());
  }
  
  Uint8 keystate = SDL_GetMouseState(NULL, NULL);
  
  if(keystate & SDL_BUTTON(3)){
    sun->position.x += (float)mouse_y / 2;
    sun->position.z -= (float)mouse_x / 2;
  }

  mouse_x = 0;
  mouse_y = 0;
  
  ui_button* framerate = ui_elem_get("framerate");
  ui_button_set_label(framerate, frame_rate_string());
  
}
예제 #7
0
void scotland_init() {
  
  graphics_viewport_set_dimensions(1280, 720);
  graphics_viewport_set_title("Scotland");
  
  ui_button* loading = ui_elem_new("loading", ui_button);
  ui_button_move(loading, vec2_new(graphics_viewport_width() / 2 - 40,graphics_viewport_height() / 2 - 13));
  ui_button_resize(loading, vec2_new(80,25));
  ui_button_set_label(loading, "Loading...");
  ui_button_disable(loading);
  
  ui_spinner* load_spinner = ui_elem_new("load_spinner", ui_spinner);
  load_spinner->color = vec4_white();
  load_spinner->top_left = vec2_new(graphics_viewport_width() / 2 + 50, graphics_viewport_height() / 2 - 13);
  load_spinner->bottom_right = vec2_add(load_spinner->top_left, vec2_new(24,24));
  
  ui_button* framerate = ui_elem_new("framerate", ui_button);
  ui_button_move(framerate, vec2_new(10,10));
  ui_button_resize(framerate, vec2_new(30,25));
  ui_button_set_label(framerate, "FRAMERATE");
  ui_button_disable(framerate);
  framerate->active = false;
  
  ui_button* wireframe = ui_elem_new("wireframe", ui_button);
  ui_button_move(wireframe, vec2_new(50,10));
  ui_button_resize(wireframe, vec2_new(80,25));
  ui_button_set_label(wireframe, "wireframe");
  wireframe->active = false;
  
  ui_elem_add_event("wireframe", toggle_wireframe);
  
  ui_button* freecam = ui_elem_new("freecam", ui_button);
  ui_button_move(freecam, vec2_new(140,10));
  ui_button_resize(freecam, vec2_new(65,25));
  ui_button_set_label(freecam, "freecam");
  freecam->active = false;
  
  ui_elem_add_event("freecam", toggle_freecam);
  
  loading_resources = true;
  SDL_Thread* load_thread = SDL_GL_CreateThread(load_resources, NULL);
  
  /* New Camera and light */
  
  camera* cam = entity_new("camera", camera);
  cam->position = vec3_new(512.0, 200.0, 512.0);
  cam->target =  vec3_new(0.0, 0.0, 0.0);
  
  light* sun = entity_new("sun", light);
  light_set_type(sun, light_type_sun);
  sun->position = vec3_new(0, 512, 0);
  sun->target = vec3_new(512, 0, 512);
  
  /* Renderer Setup */
  
  shadow_mapper_init(sun);
  
  forward_renderer_init();
  forward_renderer_set_camera(cam);
  forward_renderer_set_shadow_light(sun);
  forward_renderer_set_shadow_texture( shadow_mapper_depth_texture() );
  forward_renderer_add_light(sun);
  
}
예제 #8
0
파일: noise.c 프로젝트: yanbin-ha/Corange
int main(int argc, char **argv) {

#ifdef _WIN32
    FILE* ctt = fopen("CON", "w" );
    FILE* fout = freopen( "CON", "w", stdout );
    FILE* ferr = freopen( "CON", "w", stderr );
#endif

    corange_init("../../assets_core");

    graphics_viewport_set_size(1280, 720);
    graphics_viewport_set_title("Noise");

    folder_load(P("./"));
    file_load(P("$CORANGE/textures/random.dds"));

    glClearColor(1.0, 0.0, 0.0, 1.0);

    ui_button* info_button = ui_elem_new("info_button", ui_button);
    ui_button_move(info_button, vec2_new(10, 10));
    ui_button_resize(info_button, vec2_new(460,25));
    ui_button_set_label(info_button, "Procedural texture from perlin noise and feedback functions");

    ui_button* save_button = ui_elem_new("save_button", ui_button);
    ui_button_move(save_button, vec2_new(480, 10));
    ui_button_resize(save_button, vec2_new(380,25));
    ui_button_set_label(save_button, "Click Here to save tileable perlin noise to file");
    ui_button_set_onclick(save_button, save_noise_to_file);

    ui_button* spinner_box = ui_elem_new("spinner_box", ui_button);
    ui_button_resize(spinner_box, vec2_new(32, 32));
    ui_button_move(spinner_box, vec2_new(870, 7));
    ui_button_set_label(spinner_box, "");

    ui_spinner* save_spinner = ui_elem_new("save_spinner", ui_spinner);
    save_spinner->color = vec4_new(1,1,1,0);
    save_spinner->top_left = vec2_new(874, 11);
    save_spinner->bottom_right = vec2_add(save_spinner->top_left, vec2_new(24,24));

    srand(time(NULL));
    shader_time = (float)rand() / (RAND_MAX / 1000);

    bool running = true;
    while(running) {
        frame_begin();

        SDL_Event event;
        while(SDL_PollEvent(&event)) {

            switch(event.type) {
            case SDL_KEYDOWN:
            case SDL_KEYUP:
                if (event.key.keysym.sym == SDLK_ESCAPE) {
                    running = 0;
                }
                if (event.key.keysym.sym == SDLK_PRINTSCREEN) {
                    graphics_viewport_screenshot();
                }
                break;
            case SDL_QUIT:
                running = 0;
                break;
                break;
            }

            ui_event(event);

        }

        shader_time += frame_time();
        ui_update();

        noise_render();
        ui_render();

        graphics_swap();

        frame_end();

    }

    SDL_WaitThread(save_thread, NULL);

    corange_finish();

    return 0;
}
예제 #9
0
파일: sea.c 프로젝트: RicoP/Corange
void sea_init() {

    graphics_viewport_set_dimensions(1280, 720);
    graphics_viewport_set_title("Sea");

    camera* cam = entity_new("camera", camera);
    cam->position = v3(50.0, 50.0, 50.0);
    cam->target = v3(0, 5, 0);
    cam->near_clip = 0.1;

    light* sun = entity_new("sun", light);
    light_set_type(sun, light_type_spot);
    sun->position = v3(20,23,16);
    sun->ambient_color = v3(0.5, 0.5, 0.5);
    sun->diffuse_color = v3(1.0,  0.894, 0.811);
    sun->specular_color = v3_mul(v3(1.0,  0.894, 0.811), 4);
    sun->power = 5;

    light* backlight = entity_new("backlight", light);
    light_set_type(backlight, light_type_point);
    backlight->position = v3(-22,10,-13);
    backlight->ambient_color = v3(0.2, 0.2, 0.2);
    backlight->diffuse_color = v3(0.729, 0.729, 1.0);
    backlight->specular_color = v3_mul(v3(0.729, 0.729, 1.0), 1);
    backlight->power = 2;

    shadow_mapper_init(sun);

    forward_renderer_init();
    forward_renderer_set_camera(cam);
    forward_renderer_set_shadow_light(sun);
    forward_renderer_set_shadow_texture( shadow_mapper_depth_texture() );
    forward_renderer_add_light(sun);
    forward_renderer_add_light(backlight);

    load_folder("./resources/");

    texture* noise1 = asset_get("./resources/noise1.dds");
    texture* noise2 = asset_get("./resources/noise2.dds");
    texture* noise3 = asset_get("./resources/noise3.dds");
    texture* noise4 = asset_get("./resources/noise4.dds");
    texture* noise5 = asset_get("./resources/noise5.dds");

    texture* skydome_tex = asset_get("./resources/skybox_cloud_10.dds");

    texture* water_calm = asset_get("./resources/water_calm.dds");
    texture* water_foam = asset_get("./resources/water_foam.dds");

    material* seaplane_mat = asset_get("./resources/seaplane.mat");

    material_set_property(seaplane_mat, "tex_noise1", noise1, mat_type_texture);
    material_set_property(seaplane_mat, "tex_noise2", noise2, mat_type_texture);
    material_set_property(seaplane_mat, "tex_noise3", noise3, mat_type_texture);
    material_set_property(seaplane_mat, "tex_noise4", noise4, mat_type_texture);
    material_set_property(seaplane_mat, "tex_noise5", noise5, mat_type_texture);

    material_set_property(seaplane_mat, "tex_skybox", skydome_tex, mat_type_texture);

    material_set_property(seaplane_mat, "tex_calm_water", water_calm, mat_type_texture);
    material_set_property(seaplane_mat, "tex_foam_water", water_foam, mat_type_texture);

    renderable* r_seaplane = asset_get("./resources/seaplane.obj");
    renderable_set_material(r_seaplane, seaplane_mat);
    static_object* s_seaplane = entity_new("seaplane", static_object);
    s_seaplane->renderable = r_seaplane;
    s_seaplane->scale = v3(3,1,3);

    static_object* skydome = entity_new("skydome", static_object);
    skydome->renderable = asset_get("./resources/skydome.obj");
    renderable_set_material(skydome->renderable, asset_get("./resources/skydome.mat"));
    skydome->position = v3(0, -512, 0);
    skydome->scale = v3(1024, 1024, 1024);

    load_folder("./resources/corvette/");

    renderable* r_corvette = asset_get("./resources/corvette/corvette.obj");
    multi_material* m_corvette = asset_get("./resources/corvette/corvette.mmat");
    renderable_set_multi_material(r_corvette, m_corvette);

    static_object* s_corvette = entity_new("corvette", static_object);
    s_corvette->renderable = r_corvette;
    s_corvette->collision_body = collision_body_new_mesh(asset_get("./resources/corvette/corvette.col"));
    s_corvette->scale = v3(1.5, 1.5, 1.5);
    s_corvette->position = v3(0, 0.5, 0);

    static_object* center_sphere = entity_new("center_sphere", static_object);
    center_sphere->position = v3(0, 5, 0);
    center_sphere->renderable = asset_get("./resources/ball.obj");
    center_sphere->collision_body = collision_body_new_sphere(sphere_new(v3_zero(), 1.0f));

    ui_button* framerate = ui_elem_new("framerate", ui_button);
    ui_button_move(framerate, v2(10,10));
    ui_button_resize(framerate, v2(30,25));
    ui_button_set_label(framerate, "FRAMERATE");
    ui_button_disable(framerate);

}
예제 #10
0
void platformer_init() {
  
  /* Set the viewport title */
  graphics_viewport_set_title("Platformer");
  
  /* Register functions for loading/unloading files with the extension .level */
  asset_handler(level, "level", level_load_file, level_delete);
  
  /* Load Assets */
  folder_load(P("./tiles/"));
  folder_load(P("./backgrounds/"));
  folder_load(P("./sounds/"));
  folder_load(P("./levels/"));
  
  /* Register some handlers for creating and destroying entity types */
  entity_handler(character, character_new, character_delete);
  entity_handler(coin, coin_new, coin_delete);
  
  /* Create our main character */
  character* main_char = entity_new("main_char", character);
  
  /* Add some UI elements */
  ui_button* framerate = ui_elem_new("framerate", ui_button);
  ui_button_move(framerate, vec2_new(10,10));
  ui_button_resize(framerate, vec2_new(30,25));
  ui_button_set_label(framerate, " ");
  ui_button_disable(framerate);
  
  ui_button* score = ui_elem_new("score", ui_button);
  ui_button_move(score, vec2_new(50, 10));
  ui_button_resize(score, vec2_new(120, 25));
  ui_button_set_label(score, "Score 000000");
  ui_button_disable(score);
  
  ui_button* time = ui_elem_new("time", ui_button);
  ui_button_move(time, vec2_new(180, 10));
  ui_button_resize(time, vec2_new(110, 25));
  ui_button_set_label(time, "Time 000000");
  ui_button_disable(time);
  
  ui_button* victory = ui_elem_new("victory", ui_button);
  ui_button_move(victory, vec2_new(365, 200));
  ui_button_resize(victory, vec2_new(70, 25));
  ui_button_set_label(victory, "Victory!");
  ui_button_disable(victory);
  
  ui_button* new_game_but = ui_elem_new("new_game", ui_button);
  ui_button_move(new_game_but, vec2_new(365, 230));
  ui_button_resize(new_game_but, vec2_new(70, 25));
  ui_button_set_label(new_game_but, "New Game");
  
  
  void on_newgame(ui_button* b, void* unused) {
    reset_game();
  }
  
  ui_button_set_onclick(new_game_but, on_newgame);
  
  /* Reset all the game variables */
  reset_game();
  
}
예제 #11
0
void ui_dialog_set_button_right(ui_dialog* d, char* right, void (*onright)(ui_button*, void*)) {
  ui_button_set_label(d->right, right);
  ui_button_set_onclick(d->right, onright);
}
예제 #12
0
void ui_dialog_set_button_left(ui_dialog* d, char* left, void (*onleft)(ui_button*, void*)) {
  ui_button_set_label(d->left, left);
  ui_button_set_onclick(d->left, onleft);
}
예제 #13
0
파일: sea.c 프로젝트: AntonioCS/Corange
void sea_init() {
  
  graphics_viewport_set_dimensions(1280, 720);
  graphics_viewport_set_title("Sea");

  camera* cam = entity_new("camera", camera);
  cam->position = vec3_new(50.0, 50.0, 50.0);
  cam->target = vec3_new(0, 5, 0);
  cam->near_clip = 0.1;
  
  light* sun = entity_new("sun", light);
  light_set_type(sun, light_type_spot);
  sun->position = vec3_new(20,23,16);
  sun->ambient_color = vec3_new(0.5, 0.5, 0.5);
  sun->diffuse_color = vec3_new(1.0,  0.894, 0.811);
  sun->specular_color = vec3_mul(vec3_new(1.0,  0.894, 0.811), 4);
  sun->power = 5;
  
  light* backlight = entity_new("backlight", light);
  light_set_type(backlight, light_type_point);
  backlight->position = vec3_new(-22,10,-13);
  backlight->ambient_color = vec3_new(0.2, 0.2, 0.2);
  backlight->diffuse_color = vec3_new(0.729, 0.729, 1.0);
  backlight->specular_color = vec3_mul(vec3_new(0.729, 0.729, 1.0), 1);
  backlight->power = 2;
  
  shadow_mapper_init(sun);  
  
  forward_renderer_init();
  forward_renderer_set_camera(cam);
  forward_renderer_set_shadow_light(sun);
  forward_renderer_set_shadow_texture( shadow_mapper_depth_texture() );
  forward_renderer_add_light(sun);
  forward_renderer_add_light(backlight);
  
  folder_load(P("./resources/"));
  
  renderable* r_seaplane = asset_get(P("./resources/seaplane.obj"));
  r_seaplane->material = asset_hndl_new(P("./resources/seaplane.mat"));
  
  static_object* s_seaplane = entity_new("seaplane", static_object);
  s_seaplane->renderable = asset_hndl_new_ptr(r_seaplane);
  s_seaplane->scale = vec3_new(3,1,3);
  
  renderable* r_skydome = asset_get(P("./resources/skydome.obj"));
  r_skydome->material = asset_hndl_new_load(P("$CORANGE/shaders/skydome.mat"));
  
  static_object* skydome = entity_new("skydome", static_object);
  skydome->renderable = asset_hndl_new_ptr(r_skydome);
  skydome->position = vec3_new(0, -512, 0);
  skydome->scale = vec3_new(1024, 1024, 1024);
  
  folder_load(P("./resources/corvette/"));
  
  renderable* r_corvette = asset_get(P("./resources/corvette/corvette.obj"));
  r_corvette->material = asset_hndl_new_load(P("./resources/corvette/corvette.mat"));
  
  static_object* s_corvette = entity_new("corvette", static_object);
  s_corvette->renderable = asset_hndl_new_ptr(r_corvette);
  //s_corvette->collision_body = collision_body_new_mesh(asset_get("./resources/corvette/corvette.col"));
  s_corvette->scale = vec3_new(1.5, 1.5, 1.5);
  s_corvette->position = vec3_new(0, 0.5, 0);
  
  static_object* center_sphere = entity_new("center_sphere", static_object);
  center_sphere->position = vec3_new(0, 5, 0);
  //center_sphere->renderable = asset_get("./resources/ball.obj");
  //center_sphere->collision_body = collision_body_new_sphere(sphere_new(v3_zero(), 1.0f));
  
  ui_button* framerate = ui_elem_new("framerate", ui_button);
  ui_button_move(framerate, vec2_new(10,10));
  ui_button_resize(framerate, vec2_new(30,25));
  ui_button_set_label(framerate, "FRAMERATE");
  ui_button_disable(framerate);
  
}
예제 #14
0
void metaballs_init() {
  
  graphics_viewport_set_title("Metaballs");
  graphics_viewport_set_dimensions(1280, 720);
  graphics_set_multisamples(16);
  
#ifdef OPEN_GL_CPU
  kernels_init_with_cpu();
#else 
  kernels_init_with_opengl();
#endif
  
  asset_manager_handler(kernel_program, "cl", cl_load_file, kernel_program_delete);
  
  load_folder("./kernels/");
  
  particles_init();
  
  load_folder("./resources/podium/");
  load_folder("./resources/particles/");
  
  renderable* r_podium = asset_get("./resources/podium/podium.obj");
  renderable_set_material(r_podium, asset_get("./resources/podium/podium.mat"));
  
  static_object* s_podium = entity_new("podium", static_object);
  s_podium->renderable = r_podium;
  s_podium->position = v3(32, 10, 32);
  
  camera* cam = entity_new("camera", camera);
  cam->position = v3(50, 50, 50);
  cam->target = v3(32, 20, 32);
  
  light* sun = entity_new("sun", light);
  sun->position = v3(50,40,50);
  sun->ambient_color = v3(0.5, 0.5, 0.5);
  sun->diffuse_color = v3_mul(v3_one(), 2);
  sun->specular_color = v3_mul(v3_one(), 5);
  light_set_type(sun, light_type_spot);  
  
  ui_button* framerate = ui_elem_new("framerate", ui_button);
  ui_button_move(framerate, v2(10,10));
  ui_button_resize(framerate, v2(30,25));
  ui_button_set_label(framerate, "");
  ui_button_disable(framerate);
  
  ui_button* score = ui_elem_new("score", ui_button);
  ui_button_move(score, v2(50, 10));
#ifdef VOLUME_RENDERER
  ui_button_resize(score, v2(125, 25));
  ui_button_set_label(score, "Volume Renderer");
#endif
#ifdef MARCHING_CUBES
  ui_button_resize(score, v2(120, 25));
  ui_button_set_label(score, "Marching Cubes");
#endif
#ifndef VOLUME_RENDERER
#ifndef MARCHING_CUBES
  ui_button_resize(score, v2(80, 25));
  ui_button_set_label(score, "Particles");
#endif
#endif
  ui_button_disable(score);
  
#ifdef VOLUME_RENDERER
  volume_renderer_init();
  volume_renderer_set_camera(cam);
  volume_renderer_set_light(sun);
#endif
 
#ifdef MARCHING_CUBES
  shadow_mapper_init(sun);  
  
  forward_renderer_init();
  forward_renderer_set_camera(cam);
  forward_renderer_set_shadow_light(sun);
  forward_renderer_set_shadow_texture( shadow_mapper_depth_texture() );
  forward_renderer_add_light(sun);

  marching_cubes_init();
#endif
  
}