29 static void init_stuff(
void);
34 float Octo[6][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0},
35 {-1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 0.0, -1.0}};
37 #define ONORM .57445626
63 {-1.0, -1.0, -1.0}, {1.0, -1.0, -1.0}, {1.0, 1.0, -1.0}, {-1.0, 1.0, -1.0},
64 {-1.0, -1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, 1.0}, {-1.0, 1.0, 1.0}};
68 #define UP_NORM Octo[2]
69 #define DOWN_NORM Octo[5]
84 static void init_stuff(
void)
93 cos45 = cos(atan(1.0));
95 for (i = 0; i < 8; i++) {
117 Pi = 4.0 * atan(1.0);
137 v1[
Z] = v2[
Z] = center[
Z];
139 v1[
X] = v2[
X] = center[
X];
140 v1[
Y] = center[
Y] - siz;
141 v2[
Y] = center[
Y] + siz;
147 v1[
Y] = v2[
Y] = center[
Y];
148 v1[
X] = center[
X] - siz;
149 v2[
X] = center[
X] + siz;
178 for (i = 0; i < np; i++) {
190 v2[
Z] = pts[np - 1][
Z];
222 pdraw = n < np ? n : np;
226 for (i = 0; i < pdraw; i++) {
233 pt[
X] = pts[i - 1][
X];
234 pt[
Y] = pts[i - 1][
Y];
238 v2[
Z] = pts[np - 1][
Z];
263 v1[
Z] = v2[
Z] = center[
Z];
265 v1[
X] = center[
X] - siz;
266 v2[
X] = center[
X] + siz;
267 v1[
Y] = center[
Y] - siz;
268 v2[
Y] = center[
Y] + siz;
280 v1[
X] = center[
X] - siz;
281 v2[
X] = center[
X] + siz;
282 v1[
Y] = center[
Y] + siz;
283 v2[
Y] = center[
Y] - siz;
407 void gsd_cube(
float *center,
unsigned long colr,
float siz)
654 for (i = 0; i < 6; i++) {
735 float costheta, theta, adjacent;
743 if (dx == 0 && dy == 0) {
751 costheta = dx / sqrt(dx * dx + dy * dy);
752 theta = acos(costheta);
756 theta = (2 *
Pi) - theta;
767 else if (dx == 0 && dy == 0) {
771 adjacent = sqrt(dx * dx + dy * dy);
772 costheta = adjacent / sqrt(adjacent * adjacent + dz * dz);
773 theta = acos(costheta);
783 *aspect = *aspect * (180. /
Pi);
784 *slope = *slope * (180. /
Pi);
804 unsigned long arw_clr,
unsigned long text_clr)
809 float Ntop[] = {0.0, 0.0, 1.0};
811 base[0][
Z] = base[1][
Z] = base[2][
Z] = pos2[
Z];
812 v[0][
Z] = v[1][
Z] = v[2][
Z] = v[3][
Z] = pos2[
Z];
814 base[0][
X] = pos2[
X] - len / 16.;
815 base[1][
X] = pos2[
X] + len / 16.;
816 base[0][
Y] = base[1][
Y] = pos2[
Y] - len / 2.;
817 base[2][
X] = pos2[
X];
818 base[2][
Y] = pos2[
Y] + .45 * len;
820 v[0][
X] = v[2][
X] = pos2[
X];
821 v[1][
X] = pos2[
X] + len / 8.;
822 v[3][
X] = pos2[
X] - len / 8.;
823 v[0][
Y] = pos2[
Y] + .2 * len;
824 v[1][
Y] = v[3][
Y] = pos2[
Y] + .1 * len;
825 v[2][
Y] = pos2[
Y] + .5 * len;
837 glVertex3fv(base[0]);
838 glVertex3fv(base[1]);
839 glVertex3fv(base[2]);
868 glRasterPos3fv(base[0]);
869 glListBase(fontbase);
870 glCallLists(strlen(txt), GL_UNSIGNED_BYTE, (
const GLvoid *)txt);
898 int gsd_arrow(
float *center,
unsigned long colr,
float siz,
float *dir,
903 static int first = 1;
914 if (
NULL != onsurf) {
915 float base[3], tip[3], len;
922 tip[
X] = center[
X] + dir[
X] * len * siz;
923 tip[
Y] = center[
Y] + dir[
Y] * len * siz;
973 static int first = 1;
983 G_debug(3,
"gsd_arrow_onsurf");
984 G_debug(3,
" %f %f -> %f %f", base[
X], base[
Y], tip[
X], tip[
Y]);
988 #ifdef DO_SPHERE_BASE
998 base[
Z] = tip[
Z] = 0.0;
1001 G_debug(3,
" dir0: %f %f %f", dir0[
X], dir0[
Y], dir0[
Z]);
1009 G_debug(3,
" a-dir1: %f %f %f", dir1[
X], dir1[
Y], dir1[
Z]);
1010 G_debug(3,
" a-dir2: %f %f %f", dir2[
X], dir2[
Y], dir2[
Z]);
1017 G_debug(3,
" b-dir1: %f %f %f", dir1[
X], dir1[
Y], dir1[
Z]);
1018 G_debug(3,
" b-dir2: %f %f %f", dir2[
X], dir2[
Y], dir2[
Z]);
1024 G_debug(3,
" %f %f -> ", tmp[
X], tmp[
Y]);
1032 G_debug(3,
" dir1: %f %f %f", dir1[
X], dir1[
Y], dir1[
Z]);
1033 G_debug(3,
" dir2: %f %f %f", dir2[
X], dir2[
Y], dir2[
Z]);
1057 void gsd_3darrow(
float *center,
unsigned long colr,
float siz1,
float siz2,
1058 float *dir,
float sz)
1060 float slope, aspect;
1062 static int first = 1;
1064 static int debugint = 1;
1071 if (debugint > 100) {
1073 G_debug(3,
" pt: %f,%f,%f dir: %f,%f,%f slope: %f aspect: %f",
1074 center[
X], center[
Y], center[
Z], dir[
X], dir[
Y], dir[
Z], slope,
1136 int gsd_scalebar(
float *pos2,
float len, GLuint fontbase,
unsigned long bar_clr,
1137 unsigned long text_clr)
1141 float Ntop[] = {0.0, 0.0, 1.0};
1143 base[0][
Z] = base[1][
Z] = base[2][
Z] = base[3][
Z] = pos2[
Z];
1146 base[0][
X] = base[1][
X] = pos2[
X] - len / 2.;
1147 base[2][
X] = base[3][
X] = pos2[
X] + len / 2.;
1149 base[0][
Y] = base[3][
Y] = pos2[
Y] - len / 16.;
1150 base[1][
Y] = base[2][
Y] = pos2[
Y] + len / 16.;
1163 glVertex3fv(base[0]);
1164 glVertex3fv(base[1]);
1165 glVertex3fv(base[2]);
1166 glVertex3fv(base[3]);
1167 glVertex3fv(base[0]);
1179 sprintf(txt,
"%g km", len / 1000);
1181 sprintf(txt,
"%g meters", len);
1185 sprintf(txt,
"%g miles", len / 5280);
1186 else if (len == 5280)
1187 sprintf(txt,
"1 mile");
1189 sprintf(txt,
"%g feet", len);
1199 glRasterPos3fv(base[0]);
1200 glListBase(fontbase);
1201 glCallLists(strlen(txt), GL_BYTE, (GLubyte *)txt);
1223 unsigned long bar_clr,
unsigned long text_clr
UNUSED)
1226 float Ntop[] = {0.0, 0.0, 1.0};
1228 base[0][
Z] = base[1][
Z] = base[2][
Z] = pos[
Z];
1229 base[3][
Z] = base[4][
Z] = base[5][
Z] = pos[
Z];
1232 base[0][
X] = base[2][
X] = base[3][
X] = pos[
X] - len / 2.;
1233 base[1][
X] = base[4][
X] = base[5][
X] = pos[
X] + len / 2.;
1234 base[0][
Y] = base[1][
Y] = pos[
Y];
1235 base[2][
Y] = base[4][
Y] = pos[
Y] - len / 12;
1236 base[3][
Y] = base[5][
Y] = pos[
Y] + len / 12;
1288 static int first = 1;
1295 tip[
X] = tip[
Y] = 0.0;
1324 static int first = 1;
1395 float Box[8][3] = {{1.0, 1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, 1.0, 1.0},
1396 {1.0, 1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, -1.0, -1.0},
1397 {-1.0, -1.0, 1.0}, {1.0, -1.0, 1.0}};
const char * G_database_unit_name(int)
Get units (localized) name for the current location.
int G_debug(int, const char *,...) __attribute__((format(printf
void gsd_endlist(void)
End list.
int GS_v3norm(float *)
Change v1 so that it is a unit vector (2D)
void GS_v3mult(float *, float)
Multiple vectors.
void gsd_endtfan(void)
ADD.
void gsd_endtmesh(void)
ADD.
void gsd_swaptmesh(void)
ADD.
void gsd_pushmatrix(void)
Push the current matrix stack.
void gsd_backface(int)
ADD.
void GS_set_draw(int)
Sets which buffer to draw to.
void gsd_scale(float, float, float)
Multiply the current matrix by a general scaling matrix.
void gsd_do_scale(int)
Set current scale.
void gsd_bgnqstrip(void)
ADD.
void GS_v3mag(float *, float *)
Magnitude of vector.
void gsd_shademodel(int)
Set shaded model.
float GS_P2distance(float *, float *)
Calculate distance in plane.
void gsd_sphere(float *, float)
ADD.
void gsd_circ(float, float, float)
ADD.
void gsd_bgnpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
void GS_v3add(float *, float *)
Sum vectors.
void gsd_bgnlist(int, int)
ADD.
int gsd_getshademodel(void)
Get shaded model.
int gsd_makelist(void)
ADD.
void gsd_calllist(int)
ADD.
void GS_v3eq(float *, float *)
Copy vector values.
int gsd_get_txtwidth(const char *, int)
Get text width.
void gsd_endqstrip(void)
ADD.
int gsd_get_txtheight(int size)
Get text height.
void gsd_color_func(unsigned int)
Set current color.
Point3 * gsdrape_get_segments(geosurf *, float *, float *, int *)
ADD.
void gsd_translate(float, float, float)
Multiply the current matrix by a translation matrix.
void gsd_popmatrix(void)
Pop the current matrix stack.
void gsd_flush(void)
Mostly for flushing drawing commands across a network.
void GS_v3cross(float *, float *, float *)
Get the cross product v3 = v1 cross v2.
void gsd_linewidth(short)
Set width of rasterized lines.
void gsd_endline(void)
End line.
void gsd_bgntfan(void)
ADD.
void gsd_disc(float, float, float, float)
ADD.
int GS_v3dir(float *, float *, float *)
Get a normalized direction from v1 to v2, store in v3.
void gsd_bgnline(void)
Begin line.
void GS_done_draw(void)
Draw done, swap buffers.
void gsd_rot(float, char)
ADD.
void gsd_vert_func(float *)
ADD.
void gsd_bgntmesh(void)
ADD.
void gsd_litvert_func2(float *, unsigned long, float *)
void gsd_endpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
void gsd_litvert_func(float *, unsigned long, float *)
Set the current normal vector & specify vertex.
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
void gsd_3dcursor(float *pt)
Draw 3d cursor.
void gsd_diamond(float *center, unsigned long colr, float siz)
Draw diamond symbol.
void primitive_cylinder(unsigned long col, int caps)
Primitives only called after transforms.
float Box[8][3]
Vertices for box.
void gsd_draw_box(float *center, unsigned long colr, float siz)
Draw box.
void gsd_3darrow(float *center, unsigned long colr, float siz1, float siz2, float *dir, float sz)
Draw 3d north arrow.
void gsd_line_onsurf(geosurf *gs, float *v1, float *v2)
Line on surface, fix z-values.
int gsd_arrow(float *center, unsigned long colr, float siz, float *dir, float sz, geosurf *onsurf)
ADD.
void gsd_x(geosurf *gs, float *center, int colr, float siz)
Draw X symbol.
void gsd_drawsphere(float *center, unsigned long colr, float siz)
Draw sphere.
int gsd_north_arrow(float *pos2, float len, GLuint fontbase, unsigned long arw_clr, unsigned long text_clr)
Draw North Arrow takes OpenGL coords and size.
int gsd_scalebar_v2(float *pos, float len, GLuint fontbase UNUSED, unsigned long bar_clr, unsigned long text_clr UNUSED)
Draw Scalebar (as lines)
float ogverts[8][3]
vertices & normals for octagon in xy plane
void gsd_cube(float *center, unsigned long colr, float siz)
Draw cube.
int gsd_nline_onsurf(geosurf *gs, float *v1, float *v2, float *pt, int n)
Multiline on surface, fix z-values.
void gsd_diamond_lines(void)
Draw diamond lines.
int gsd_arrow_onsurf(float *base, float *tip, unsigned long colr, int wid, geosurf *gs)
Draw north arrow on surface.
int gsd_scalebar(float *pos2, float len, GLuint fontbase, unsigned long bar_clr, unsigned long text_clr)
Draw Scalebar takes OpenGL coords and size.
float OctoN[8][3]
normals for flat-shaded octahedron
float ogvertsplus[8][3]
vertices for octagon in xy plane, z=1
void primitive_cone(unsigned long col)
Primitives only called after transforms.
void dir_to_slope_aspect(float *dir, float *slope, float *aspect, int degrees)
ADD.
float Octo[6][3]
vertices for octahedron
void gsd_draw_asterisk(float *center, unsigned long colr, float siz)
Draw asterisk.
void gsd_box(float *center, int colr, float *siz)
Draw box.
void gsd_draw_gyro(float *center, unsigned long colr, float siz)
Draw gyro.
void gsd_plus(float *center, int colr, float siz)
ADD.