2 * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "gis-world.h"
22 #include "gis-prims.h"
25 * - Manage normals for GisPoint
29 GisPoint *gis_point_new()
31 return g_new0(GisPoint, 1);
34 void gis_point_set_lle(GisPoint *self, gdouble lat, gdouble lon, gdouble elev)
39 lle2xyz(self->lat, self->lon, self->elev,
40 &self->x, &self->y, &self->z);
43 void gis_point_set_xyz(GisPoint *self, gdouble x, gdouble y, gdouble z)
50 void gis_point_set_coords(GisPoint *self, gdouble x, gdouble y)
56 void gis_point_project(GisPoint *self, GisProjection *proj)
58 gluProject(self->x, self->y, self->z,
59 proj->model, proj->proj, proj->view,
60 &self->px, &self->py, &self->pz);
63 GisPoint *gis_point_ref(GisPoint *self)
69 void gis_point_unref(GisPoint *self)
78 GisTriangle *gis_triangle_new(GisPoint *a, GisPoint *b, GisPoint *c, guint tex)
80 GisTriangle *self = g_new0(GisTriangle, 1);
81 gis_point_set_xyz(&GIS_PRIMITIVE(self)->center,
82 (a->x + b->x + c->x)/3,
83 (a->y + b->y + c->y)/3,
84 (a->z + b->z + c->z)/3);
85 self->verts[0] = gis_point_ref(a);
86 self->verts[1] = gis_point_ref(b);
87 self->verts[2] = gis_point_ref(c);
92 void gis_triangle_free(GisTriangle *self)
94 gis_point_unref(self->verts[0]);
95 gis_point_unref(self->verts[1]);
96 gis_point_unref(self->verts[2]);
102 GisQuad *gis_quad_new(GisPoint *a, GisPoint *b, GisPoint *c, GisPoint *d, guint tex)
104 GisQuad *self = g_new0(GisQuad, 1);
105 gis_point_set_xyz(&GIS_PRIMITIVE(self)->center,
106 (a->x + b->x + c->x + d->x)/4,
107 (a->y + b->y + c->y + d->y)/4,
108 (a->z + b->z + c->z + d->z)/4);
109 self->verts[0] = gis_point_ref(a);
110 self->verts[1] = gis_point_ref(b);
111 self->verts[2] = gis_point_ref(c);
112 self->verts[3] = gis_point_ref(d);
117 void gis_quad_free(GisQuad *self)
119 gis_point_unref(self->verts[0]);
120 gis_point_unref(self->verts[1]);
121 gis_point_unref(self->verts[2]);
122 gis_point_unref(self->verts[3]);
128 GisCallback *gis_callback_new(GisCallbackFunc callback, gpointer user_data)
130 GisCallback *self = g_new0(GisCallback, 1);
131 self->callback = callback;
132 self->user_data = user_data;
136 void gis_callback_free(GisCallback *self)