1 /* crater.h - headers for processing craters 2 * 3 * Copyright (C) 2003 Patrice St-Gelais 4 * patrstg@users.sourceforge.net 5 * www.oricom.ca/patrice.st-gelais 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 22 #ifndef _CRATERS 23 #define _CRATERS 1 24 25 #include <gtk/gtk.h> 26 #include "hf.h" 27 #include "view_area.h" 28 29 // Craters types 30 #ifndef IRREGULAR_CRATER 31 #define IRREGULAR_CRATER 1 32 #endif 33 #ifndef PEAK_CRATER 34 #define PEAK_CRATER 2 35 #endif 36 #ifndef STANDARD_CRATER 37 #define STANDARD_CRATER 3 38 #endif 39 40 // Upper boundary of the slope threshold scale 41 #ifndef MAX_SLOPE_THRESHOLD 42 #define MAX_SLOPE_THRESHOLD 50 43 #endif 44 45 // Maximum number of attempts to draw one crater, 46 // when there is a "slope threshold" 47 #define MAX_ATTEMPTS 10 48 49 typedef struct { 50 gint type; // IRREGULAR_CRATER, PEAK_..., STANDARD_... 51 gint diameter; // In % of current HF size 52 gboolean random_diameter; // TRUE if diameter is to be randomized 53 // between diam_bound1 and diam_bound2 54 gint diam_bound1; 55 gint diam_bound2; 56 gint distribution; // From 1 to 10, exponent of D in K / pow(D,distribution) 57 // D = diameter, K = number of craters generated 58 // Applies when we generate craters randomly 59 // between diam_bound1 and diam_bound2 60 gboolean default_depth; // If TRUE, we use: 61 // 7% for IRREGULAR (allegedly very big ~ 75 km), 62 // 10% for PEAK (supposed to be big ~ 30 km), 63 // 20% for STANDARD (supposed to be small ~ 7 km) 64 gint depth; // in % of diameter (2*radius), if default_depth not used 65 gboolean if_smooth; // Do we smooth the zone before applying the crater? 66 // (craters are supposed to replace existing objects - other craters) 67 gint radial_noise; // Random variation of the radius, % from 0 to 10% 68 gint surface_noise; // Noise kept from the original surface, it smoothed 69 // A radius, from 0 to 10 pixels, 0 meaning we don't keep noise at all 70 gint wrap; // TILING_AUTO, TILING_YES, TILING_NO 71 view_struct *preview; 72 gint seed; // If we want to keep the seed between each use or rand()... 73 } draw_crater_struct; 74 75 // The maps 76 extern gfloat irregular_crater[], peak_crater[], standard_crater[]; 77 #ifndef MAP_LENGTH 78 #define MAP_LENGTH 256 79 #endif 80 81 // Prototypes 82 83 draw_crater_struct *crater_struct_new(); 84 void crater_struct_free(); 85 86 void draw_crater (draw_crater_struct *dcs, hf_struct_type *hf, 87 gint x, gint y, gdouble** gauss_list); 88 gint draw_many_craters (draw_crater_struct *dcs, 89 hf_struct_type *hf, 90 gint qty, 91 gint peak_threshold, 92 gint slope_threshold, 93 gdouble **gauss_list); 94 gint *get_sqrmap (draw_crater_struct *dcs, gint diam, gint depth); 95 void init_radial_noise(); 96 97 #endif // _CRATERS 98 99 100 101 102 103 104 105 106 107