void obj::scene::initialize() { glClearColor(.1, .16, .19, 0); glClearDepth(1.0); GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; glShadeModel(GL_SMOOTH); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glLineWidth(3); glPointSize(20); glScalef(2, 2, 5); glutSetCursor(GLUT_CURSOR_CROSSHAIR); current_time = timebase = elapsed_time(); camera = new obj::camera(90); reset_camera(); }
int keys_listener(int keycode, t_env *e) { double step; step = (e->arg == 3) ? 20 : 0.3 / e->zoom; if (keycode == SPACEBAR) e->fixed = e->fixed == 0 ? 1 : 0; if (keycode == ZERO_KEY) reset_camera(e); if (keycode == ESC_CODE) exit(0); if (keycode == LEFT_ARR) e->move_x -= step; if (keycode == UP_ARR) e->move_y -= step; if (keycode == RIGHT_ARR) e->move_x += step; if (keycode == DOWN_ARR) e->move_y += step; if (keycode == PLUS_KEY) (e->arg == 3) ? (e->depth += 1) : (e->max_i += 4); if (keycode == MINUS_KEY && e->max_i > 16) (e->arg == 3) ? (e->depth -= 1) : (e->max_i -= 4); if (needs_rerender(keycode)) render_fract(e); return (0); }
view::view(int x,int y,int w,int h, World* world) : GlWindow(x,y,w,h-25), m_hasAllExtensions(false) { if (!world) throw new SnowSim::Exceptions::ArgumentException("parameter world can not be NULL!"); this->m_world = world; // gets called from window //this->m_world->Changed += event_handler(this, &view::Refresh); init_ok =false; ortho_sh=false; basemesh_drawable = NULL; modifiedmesh_drawable = NULL; m = cgv::math::linalg::fix_diag_mat<float,4>(1.0f); vec_mouse = cgv::math::linalg::fix_col_vec<float,4>(0.0f); mouse_x_old = 0; mouse_y_old = 0; reset_camera(); fltk::Item* item; interaction_mode=VIEWPOINT; choice_1 = new fltk::Choice(x+100,h,150,20,"interaction mode"); choice_1->begin(); item = new fltk::Item("change camera"); //item = new fltk::Item("mark vertex/edge (hoppe rules)"); //item = new fltk::Item("translate vertex"); //item = new fltk::Item("split edge"); //item = new fltk::Item("insert edge (select vertices)"); choice_1->end(); choice_1->value(interaction_mode); choice_1->callback(choice_1_cb,this); vertex_drag_mode=X; choice_2 = new fltk::Choice(x+255,h,150,20); choice_2->begin(); item = new fltk::Item("X (right mouse button)"); item = new fltk::Item("Y (right mouse button)"); item = new fltk::Item("XY (right mouse button)"); item = new fltk::Item("Z (right mouse button)"); item = new fltk::Item("XZ (right mouse button)"); item = new fltk::Item("YZ (right mouse button)"); choice_2->end(); choice_2->value(vertex_drag_mode-1); choice_2->callback(choice_2_cb,this); output = new fltk::Output(x+410,h,190,20,""); end(); if (interaction_mode!=TRANSLATE) { choice_2->hide(); } else { choice_2->show(); } }
Camera::Camera() { xrot = 0; yrot = 0; button_presses[0] = 0; button_presses[1] = 0; button_presses[2] = 0; button_presses[3] = 0; reset_camera(); }
void Camera::keypressdown(unsigned char key, int x, int y){ if(key == 'w'){ button_presses[W] = 10; } if(key == 'a'){ button_presses[A] = 10; } if(key == 's'){ button_presses[S] = 10; } if(key == 'd'){ button_presses[D] = 10; } if(key == 'r'){ reset_camera(); } if (key==27) { exit(0); } }
void keyboard( unsigned char key, int x, int y ) { if( isupper(key) ) key = tolower(key); switch( key ) { case 'a': if( anim ) stop(); else start(); break; case 'c': reset_camera(); break; case 'f': fps_status = !fps_status; break; case 'g': gridon = !gridon; break; case 'p': planeon = !planeon; break; case 'h': half = !half; break; case 'l': lights = !lights; if( lights ) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING); break; case 'b': cull = !cull; if( cull ) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); break; case 'o': ortho = !ortho; set_projection(); break; case 's': smooth = !smooth; glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); break; case 'w': wire = !wire; glPolygonMode(GL_FRONT_AND_BACK, wire ? GL_LINE : GL_FILL); break; case ' ': fullscreen = !fullscreen; set_fullscreen(); break; case '\t': printf("\ncamera:\n" "-------------------\n" "%3.3f elev\n" "%3.3f azim\n" "%3.3f dist\n" "%3.3f x\n" "%3.3f y\n", cam_elev, cam_azim, cam_dist, cam_panx, cam_pany ); break; case 'q': exit(0); break; default: print_help(); break; } // refresh after a command glutPostRedisplay(); }
void obj::scene::reshape() { reset_camera(); }
void Application::keyboard_event(int key, int event, unsigned char mods) { switch (mode) { case RENDER_MODE: if (event == EVENT_PRESS) { switch (key) { case 'e': case 'E': to_edit_mode(); break; case 'v': case 'V': pathtracer->stop(); pathtracer->start_visualizing(); mode = VISUALIZE_MODE; break; case 's': case 'S': pathtracer->save_image(); break; case '[': case ']': case '+': case '=': case '-': case '_': case '.': case '>': case ',': case '<': pathtracer->stop(); pathtracer->key_press(key); pathtracer->start_raytracing(); break; case 'r': case 'R': pathtracer->stop(); pathtracer->start_raytracing(); break; } } break; case VISUALIZE_MODE: if (event == EVENT_PRESS) { switch(key) { case 'e': case 'E': to_edit_mode(); break; case 'r': case 'R': pathtracer->stop(); pathtracer->start_raytracing(); mode = RENDER_MODE; break; case ' ': reset_camera(); break; default: pathtracer->key_press(key); } } break; case EDIT_MODE: if (event == EVENT_PRESS) { switch(key) { case 'r': case 'R': set_up_pathtracer(); pathtracer->start_raytracing(); mode = RENDER_MODE; break; case 'v': case 'V': set_up_pathtracer(); pathtracer->start_visualizing(); mode = VISUALIZE_MODE; break; case ' ': reset_camera(); break; case 'h': case 'H': show_hud = !show_hud; break; case 'u': case 'U': scene->upsample_selected_mesh(); break; case 'd': case 'D': scene->downsample_selected_mesh(); break; case 'i': case 'I': // i for isotropic. scene->resample_selected_mesh(); break; case 'f': case 'F': scene->flip_selected_edge(); break; case 's': case 'S': scene->split_selected_edge(); break; case 'c': case 'C': scene->collapse_selected_edge(); break; default: break; } } break; } }