/* draws a spline curve connecting two nodes */ void draw_spline(NODE n1, NODE n2) { int points[8]; int i; get_control_points(n1, n2, points); spline(screen, points, makecol(0,200,0)); if (show_control_points) for (i=1; i<=2; i++) circlefill(screen, points[i*2], points[i*2+1], 2, makecol(0,0,0)); }
/* draws a spline curve connecting two nodes */ void draw_spline(NODE n1, NODE n2) { int points[8]; int i; get_control_points(n1, n2, points); spline(screen, points, palette_color[255]); if (show_control_points) for (i=1; i<=2; i++) circlefill(screen, points[i*2], points[i*2+1], 2, palette_color[2]); }
int Prepare_Cross_Spline(int move_selected) { int points[8]; actual_step_node=dock_move_actual_step[move_selected]; //si tracker pas à l endroit de la memoire if(mover_params[0][0]!=(dock_move_xy[move_selected][actual_step_node][0]+xmover_window+20) || mover_params[1][0]!=(dock_move_xy[move_selected][actual_step_node][1]+ymover_window+20)) { nodes[actual_step_node].x=mover_params[0][0]+xmover_window+20; nodes[actual_step_node].y=mover_params[1][0]+ymover_window+20; } //next step et raffraichissement xy pour cycle mode next_step_node=next_step[move_selected]; if(next_step_node>dock_moves_contains_steps[move_selected]){next_step_node=1;} nodes[next_step_node].x=(dock_move_xy[move_selected][next_step_node][0]+xmover_window+20); nodes[next_step_node].y=(dock_move_xy[move_selected][next_step_node][1]+ymover_window+20); //dans le cas d un goto if(GotoMoves[move_selected][actual_step_node]!=0 && index_move_forward==1) { numero_de_dock_goto_spline=GotoMoves[move_selected][actual_step_node]; next_step_node=Moves_Inpoint[numero_de_dock_goto_spline]; nodes[next_step_node].x=(dock_move_xy[numero_de_dock_goto_spline][next_step_node][0]+xmover_window+20); nodes[next_step_node].y=(dock_move_xy[numero_de_dock_goto_spline][next_step_node][1]+ymover_window+20); for(int ro=1;ro<dock_moves_contains_steps[numero_de_dock_goto_spline];ro++) { if(ro!=actual_step_node) { nodes[ro].x=(dock_move_xy[numero_de_dock_goto_spline][ro][0]+xmover_window+20); nodes[ro].y=(dock_move_xy[numero_de_dock_goto_spline][ro][1]+ymover_window+20); } } } // pas besoin de re calcul des tangentes, il est fait pour l affichage. get_control_points(nodes[actual_step_node],nodes[next_step_node],points); if(index_move_back==1) { get_control_points_backward(nodes[actual_step_node],nodes[next_step_node],points);} calc_spline(points, SPLINE_MAX_RESOLUTION, my_spline_path_X, my_spline_path_Y); actual_spline_tick=0.0; spline_tick_fraction=((float)SPLINE_MAX_RESOLUTION)/dock_time[dock_move_selected][(dock_move_actual_step[dock_move_selected])]; return(0); }
void initialize() { srand(time(NULL)); int sdl_error = SDL_Init(SDL_INIT_EVERYTHING); if (sdl_error != false) { fileout << "Error in SDL initialization: " << sdl_error; problem(100); }else { fileout << "No SDL initialization errors." << endl << flush; } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); Uint32 flags = SDL_OPENGL; // Uint32 flags = SDL_OPENGL | SDL_FULLSCREEN; SDL_Surface* drawContext; drawContext = SDL_SetVideoMode(resolution[0] / 2, resolution[1] / 2, 0, flags); glClear(GL_COLOR_BUFFER_BIT); glClearColor(1.0, 1.0, 1.0, 0.0); glEnable(GL_TEXTURE_RECTANGLE_ARB); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); gluOrtho2D(-2.0, SCREENTW - 2.0, -2.0, SCREENTH - 2.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Sound::music("eatpellet"); // Sound::music("eatghost"); // Sound::music("pacdeath2"); Sound::music("moo_theme"); g_blinky.pers_status = ST_BLINKY; g_pinky.pers_status = ST_PINKY; g_inky.pers_status = ST_INKY; g_clyde.pers_status = ST_CLYDE; get_control_points(); }
void gradient::get_control_points(double &x1, double &y1, double &x2, double &y2, double &r) const { get_control_points(x1,y1,x2,y2); r=r_; }
/* moves a sprite along the spline path */ void walk(void) { #define MAX_POINTS 256 int points[8]; int x[MAX_POINTS], y[MAX_POINTS]; int n, i; int npoints; int ox, oy; acquire_screen(); clear_to_color(screen, makecol(255, 255, 255)); for (i=1; i<node_count-1; i++) draw_node(i); release_screen(); do { poll_mouse(); } while (mouse_b); clear_keybuf(); ox = -16; oy = -16; xor_mode(TRUE); for (n=1; n < node_count-2; n++) { npoints = (fixtoi(node_dist(nodes[n], nodes[n+1]))+3) / 4; if (npoints < 1) npoints = 1; else if (npoints > MAX_POINTS) npoints = MAX_POINTS; get_control_points(nodes[n], nodes[n+1], points); calc_spline(points, npoints, x, y); for (i=1; i<npoints; i++) { vsync(); acquire_screen(); circlefill(screen, ox, oy, 6, palette_color[2]); circlefill(screen, x[i], y[i], 6, palette_color[2]); release_screen(); ox = x[i]; oy = y[i]; poll_mouse(); if ((keypressed()) || (mouse_b)) goto getout; } } getout: xor_mode(FALSE); do { poll_mouse(); } while (mouse_b); clear_keybuf(); }
int main(int argc, char *argv[]) { char group[INAME_LEN], extension[INAME_LEN]; int order; /* ADDED WITH CRS MODIFICATIONS */ char *ipolname; /* name of interpolation method */ int method; int n, i, m, k = 0; int got_file = 0, target_overwrite = 0; char *overstr; struct Cell_head cellhd; struct Option *grp, /* imagery group */ *val, /* transformation order */ *ifile, /* input files */ *ext, /* extension */ *tres, /* target resolution */ *mem, /* amount of memory for cache */ *interpol; /* interpolation method: nearest neighbor, bilinear, cubic */ struct Flag *c, *a; struct GModule *module; G_gisinit(argv[0]); module = G_define_module(); module->keywords = _("imagery, rectify"); module->description = _("Rectifies an image by computing a coordinate " "transformation for each pixel in the image based on the " "control points."); grp = G_define_standard_option(G_OPT_I_GROUP); ifile = G_define_standard_option(G_OPT_R_INPUTS); ifile->required = NO; ext = G_define_option(); ext->key = "extension"; ext->type = TYPE_STRING; ext->required = YES; ext->multiple = NO; ext->description = _("Output raster map(s) suffix"); val = G_define_option(); val->key = "order"; val->type = TYPE_INTEGER; val->required = YES; val->description = _("Rectification polynom order (1-3)"); tres = G_define_option(); tres->key = "res"; tres->type = TYPE_DOUBLE; tres->required = NO; tres->description = _("Target resolution (ignored if -c flag used)"); mem = G_define_option(); mem->key = "memory"; mem->type = TYPE_DOUBLE; mem->key_desc = "memory in MB"; mem->required = NO; mem->answer = "300"; mem->description = _("Amount of memory to use in MB"); ipolname = make_ipol_list(); interpol = G_define_option(); interpol->key = "method"; interpol->type = TYPE_STRING; interpol->required = NO; interpol->answer = "nearest"; interpol->options = ipolname; interpol->description = _("Interpolation method to use"); c = G_define_flag(); c->key = 'c'; c->description = _("Use current region settings in target location (def.=calculate smallest area)"); a = G_define_flag(); a->key = 'a'; a->description = _("Rectify all raster maps in group"); if (G_parser(argc, argv)) exit(EXIT_FAILURE); /* get the method */ for (method = 0; (ipolname = menu[method].name); method++) if (strcmp(ipolname, interpol->answer) == 0) break; if (!ipolname) G_fatal_error(_("<%s=%s> unknown %s"), interpol->key, interpol->answer, interpol->key); interpolate = menu[method].method; G_strip(grp->answer); strcpy(group, grp->answer); strcpy(extension, ext->answer); order = atoi(val->answer); seg_mb = NULL; if (mem->answer) { if (atoi(mem->answer) > 0) seg_mb = mem->answer; } if (!ifile->answers) a->answer = 1; /* force all */ /* Find out how many files on command line */ if (!a->answer) { for (m = 0; ifile->answers[m]; m++) { k = m; } k++; } if (order < 1 || order > MAXORDER) G_fatal_error(_("Invalid order (%d); please enter 1 to %d"), order, MAXORDER); /* determine the number of files in this group */ if (I_get_group_ref(group, &ref) <= 0) G_fatal_error(_("Group <%s> does not exist"), grp->answer); if (ref.nfiles <= 0) { G_important_message(_("Group <%s> contains no raster maps; run i.group"), grp->answer); exit(EXIT_SUCCESS); } ref_list = (int *)G_malloc(ref.nfiles * sizeof(int)); if (a->answer) { for (n = 0; n < ref.nfiles; n++) { ref_list[n] = 1; } } else { char xname[GNAME_MAX], xmapset[GMAPSET_MAX], *name, *mapset; for (n = 0; n < ref.nfiles; n++) ref_list[n] = 0; for (m = 0; m < k; m++) { got_file = 0; if (G__name_is_fully_qualified(ifile->answers[m], xname, xmapset)) { name = xname; mapset = xmapset; } else { name = ifile->answers[m]; mapset = NULL; } got_file = 0; for (n = 0; n < ref.nfiles; n++) { if (mapset) { if (strcmp(name, ref.file[n].name) == 0 && strcmp(mapset, ref.file[n].mapset) == 0) { got_file = 1; ref_list[n] = 1; break; } } else { if (strcmp(name, ref.file[n].name) == 0) { got_file = 1; ref_list[n] = 1; break; } } } if (got_file == 0) err_exit(ifile->answers[m], group); } } /* read the control points for the group */ get_control_points(group, order); /* get the target */ get_target(group); /* Check the GRASS_OVERWRITE environment variable */ if ((overstr = getenv("GRASS_OVERWRITE"))) /* OK ? */ target_overwrite = atoi(overstr); if (!target_overwrite) { /* check if output exists in target location/mapset */ char result[GNAME_MAX]; select_target_env(); for (i = 0; i < ref.nfiles; i++) { if (!ref_list[i]) continue; strcpy(result, ref.file[i].name); strcat(result, extension); if (G_legal_filename(result) < 0) G_fatal_error(_("Extension <%s> is illegal"), extension); if (G_find_cell(result, G_mapset())) { G_warning(_("The following raster map already exists in")); G_warning(_("target LOCATION %s, MAPSET %s:"), G_location(), G_mapset()); G_warning("<%s>", result); G_fatal_error(_("Orthorectification cancelled.")); } } select_current_env(); } else G_debug(1, "Overwriting OK"); /* do not use current region in target location */ if (!c->answer) { double res = -1; if (tres->answer) { if (!((res = atof(tres->answer)) > 0)) G_warning(_("Target resolution must be > 0, ignored")); } /* Calculate smallest region */ if (a->answer) { if (G_get_cellhd(ref.file[0].name, ref.file[0].mapset, &cellhd) < 0) G_fatal_error(_("Unable to read header of raster map <%s>"), ref.file[0].name); } else { if (G_get_cellhd(ifile->answers[0], ref.file[0].mapset, &cellhd) < 0) G_fatal_error(_("Unable to read header of raster map <%s>"), ifile->answers[0]); } georef_window(&cellhd, &target_window, order, res); } G_verbose_message(_("Using region: N=%f S=%f, E=%f W=%f"), target_window.north, target_window.south, target_window.east, target_window.west); exec_rectify(order, extension, interpol->answer); G_done_msg(" "); exit(EXIT_SUCCESS); }