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-object.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_OBJECT(self)->type = GIS_TYPE_TRIANGLE;
82 gis_point_set_xyz(&GIS_OBJECT(self)->center,
83 (a->x + b->x + c->x)/3,
84 (a->y + b->y + c->y)/3,
85 (a->z + b->z + c->z)/3);
86 self->verts[0] = gis_point_ref(a);
87 self->verts[1] = gis_point_ref(b);
88 self->verts[2] = gis_point_ref(c);
93 void gis_triangle_free(GisTriangle *self)
95 gis_point_unref(self->verts[0]);
96 gis_point_unref(self->verts[1]);
97 gis_point_unref(self->verts[2]);
103 GisQuad *gis_quad_new(GisPoint *a, GisPoint *b, GisPoint *c, GisPoint *d, guint tex)
105 GisQuad *self = g_new0(GisQuad, 1);
106 GIS_OBJECT(self)->type = GIS_TYPE_QUAD;
107 gis_point_set_xyz(&GIS_OBJECT(self)->center,
108 (a->x + b->x + c->x + d->x)/4,
109 (a->y + b->y + c->y + d->y)/4,
110 (a->z + b->z + c->z + d->z)/4);
111 self->verts[0] = gis_point_ref(a);
112 self->verts[1] = gis_point_ref(b);
113 self->verts[2] = gis_point_ref(c);
114 self->verts[3] = gis_point_ref(d);
119 void gis_quad_free(GisQuad *self)
121 gis_point_unref(self->verts[0]);
122 gis_point_unref(self->verts[1]);
123 gis_point_unref(self->verts[2]);
124 gis_point_unref(self->verts[3]);
130 GisCallback *gis_callback_new(GisCallbackFunc callback, gpointer user_data)
132 GisCallback *self = g_new0(GisCallback, 1);
133 GIS_OBJECT(self)->type = GIS_TYPE_CALLBACK;
134 self->callback = callback;
135 self->user_data = user_data;
139 void gis_callback_free(GisCallback *self)
146 GisMarker *gis_marker_new(const gchar *label)
148 GisMarker *self = g_new0(GisMarker, 1);
149 GIS_OBJECT(self)->type = GIS_TYPE_MARKER;
150 self->label = g_strdup(label);;
154 void gis_marker_free(GisMarker *self)