static void menu(int choice) { static bool wireframe = false; switch (choice) { case 'f': vertices.clear(); indices.clear(); generate_geometry(); break; case 's': vertices.clear(); indices.clear(); generate_geometry_smooth(); break; case 'n': vertices.clear(); indices.clear(); generate_geometry_naive_surface_nets(); break; case 'w': if (!wireframe) { // enable glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } else { // disable glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } wireframe = !wireframe; break; } }
void visual_unit_factory::create_piecharts( dataset_db &db, QGLFunctions qglf ){ // if( _active_visual_unit ) delete _active_visual_unit; // _active_visual_unit = new visual_unit(); // generate_geometry( db, qglf ); //generate_geometry_parallel( db, qglf ); }
int main(int argc, char** argv) { generate_voxels(); generate_geometry(); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800, 600); glutInitWindowPosition(100, 100); glutCreateWindow("Perspective's GLUT Template"); // register glut call backs glutKeyboardFunc(keyboardDown); glutKeyboardUpFunc(keyboardUp); glutSpecialFunc(keyboardSpecialDown); glutSpecialUpFunc(keyboardSpecialUp); glutMouseFunc(mouseClick); glutMotionFunc(mouseMotion); glutPassiveMotionFunc(mouseMotion); glutReshapeFunc(reshape); glutDisplayFunc(draw); glutIdleFunc(idle); glutIgnoreKeyRepeat(true); // ignore keys held down glutCreateMenu(menu); glutAddMenuEntry("Marching Cubes (flat shading)", 'f'); glutAddMenuEntry("Marching Cubes (smooth shading)", 's'); glutAddMenuEntry("Naive Surface Nets (smooth shading)", 'n'); glutAddMenuEntry("Toggle Wireframe", 'w'); glutAttachMenu(GLUT_RIGHT_BUTTON); initGL(800, 600); glutMainLoop(); return 0; }
void voxel_model::process_animation(GLfloat advance) { if(!anim_) { return; } if(anim_->duration > 0 && anim_time_ > anim_->duration) { set_animation("stand"); } anim_time_ += advance; const GLfloat TransitionTime = 0.5f; GLfloat ratio = 1.0f; if(old_anim_) { if(anim_time_ >= TransitionTime) { old_anim_.reset(); old_anim_time_ = 0.0f; } else { old_anim_time_ += advance; if(old_anim_->duration > 0.0f && old_anim_time_ > old_anim_->duration) { old_anim_time_ = old_anim_->duration; } ratio = anim_time_ / TransitionTime; } } clear_transforms(); game_logic::map_formula_callable_ptr callable(new game_logic::map_formula_callable); if(old_anim_) { callable->add("time", variant(decimal(old_anim_time_))); for(const AnimationTransform& transform : old_anim_->transforms) { glm::vec3 translate; if(transform.translation_formula) { const variant result = transform.translation_formula->execute(*callable); translate = variant_to_vec3(result)*(1.0f - ratio); } GLfloat rotation = 0.0; if(transform.rotation_formula) { rotation = transform.rotation_formula->execute(*callable).as_decimal().as_float(); } get_child(transform.layer)->accumulate_rotation(transform.pivot_src, transform.pivot_dst, rotation*(1.0-ratio), translate, transform.children_only); } } callable->add("time", variant(decimal(anim_time_))); for(const AnimationTransform& transform : anim_->transforms) { glm::vec3 translate; if(transform.translation_formula) { const variant result = transform.translation_formula->execute(*callable); translate = variant_to_vec3(result) * ratio; } GLfloat rotation = 0.0; if(transform.rotation_formula) { rotation = transform.rotation_formula->execute(*callable).as_decimal().as_float(); } get_child(transform.layer)->accumulate_rotation(transform.pivot_src, transform.pivot_dst, rotation*ratio, translate, transform.children_only); } generate_geometry(); }