2 * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
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/>.
24 typedef struct _RoamView RoamView;
25 typedef struct _RoamPoint RoamPoint;
26 typedef struct _RoamTriangle RoamTriangle;
27 typedef struct _RoamDiamond RoamDiamond;
28 typedef struct _RoamSphere RoamSphere;
29 typedef gdouble (*RoamHeightFunc)(gdouble lat, gdouble lon, gpointer user_data);
44 gdouble x, y, z; /* Model coordinates */
45 gdouble px, py, pz; /* Projected coordinates */
46 gint pversion; /* Version of cached projection */
48 gint tris; /* Count of associated triangles */
49 gdouble norm[3]; /* Vertex normal */
51 /* For get_intersect */
52 gdouble lat, lon, elev;
55 RoamHeightFunc height_func;
58 RoamPoint *roam_point_new(double lat, double lon, double elev);
59 void roam_point_add_triangle(RoamPoint *point, RoamTriangle *triangle);
60 void roam_point_remove_triangle(RoamPoint *point, RoamTriangle *triangle);
61 void roam_point_update_height(RoamPoint *point);
62 void roam_point_update_projection(RoamPoint *point, RoamView *view);
67 struct _RoamTriangle {
69 /* Left, middle and right vertices */
70 struct { RoamPoint *l,*m,*r; } p;
72 /* Left, base, and right neighbor triangles */
73 struct { RoamTriangle *l,*b,*r; } t;
75 RoamPoint *split; /* Split point */
76 RoamDiamond *parent; /* Parent diamond */
77 double norm[3]; /* Surface normal */
78 double error; /* Screen space error */
81 /* For get_intersect */
82 struct { gdouble n,s,e,w; } edge;
83 RoamTriangle *kids[2];
85 RoamTriangle *roam_triangle_new(RoamPoint *l, RoamPoint *m, RoamPoint *r);
86 void roam_triangle_free(RoamTriangle *triangle);
87 void roam_triangle_add(RoamTriangle *triangle,
88 RoamTriangle *left, RoamTriangle *base, RoamTriangle *right,
90 void roam_triangle_remove(RoamTriangle *triangle, RoamSphere *sphere);
91 void roam_triangle_update_errors(RoamTriangle *triangle, RoamSphere *sphere);
92 void roam_triangle_split(RoamTriangle *triangle, RoamSphere *sphere);
93 void roam_triangle_draw(RoamTriangle *triangle);
94 void roam_triangle_draw_normal(RoamTriangle *triangle);
101 RoamTriangle *kids[4]; /* Child triangles */
102 RoamTriangle *parents[2]; /* Parent triangles */
103 double error; /* Screen space error */
104 gboolean active; /* For internal use */
105 GPQueueHandle handle;
107 RoamDiamond *roam_diamond_new(
108 RoamTriangle *parent0, RoamTriangle *parent1,
109 RoamTriangle *kid0, RoamTriangle *kid1,
110 RoamTriangle *kid2, RoamTriangle *kid3);
111 void roam_diamond_add(RoamDiamond *diamond, RoamSphere *sphere);
112 void roam_diamond_remove(RoamDiamond *diamond, RoamSphere *sphere);
113 void roam_diamond_merge(RoamDiamond *diamond, RoamSphere *sphere);
114 void roam_diamond_update_errors(RoamDiamond *diamond, RoamSphere *sphere);
121 GPQueue *triangles; /* List of triangles */
122 GPQueue *diamonds; /* List of diamonds */
123 RoamView *view; /* Current projection */
124 gint polys; /* Polygon count */
126 /* For get_intersect */
127 RoamTriangle *roots[8]; /* Original 8 triangles */
129 RoamSphere *roam_sphere_new();
130 void roam_sphere_update_view(RoamSphere *sphere);
131 void roam_sphere_update_errors(RoamSphere *sphere);
132 void roam_sphere_split_one(RoamSphere *sphere);
133 void roam_sphere_merge_one(RoamSphere *sphere);
134 gint roam_sphere_split_merge(RoamSphere *sphere);
135 void roam_sphere_draw(RoamSphere *sphere);
136 void roam_sphere_draw_normals(RoamSphere *sphere);
137 GList *roam_sphere_get_intersect(RoamSphere *sphere, gboolean all,
138 gdouble n, gdouble s, gdouble e, gdouble w);
139 void roam_sphere_free(RoamSphere *sphere);