19 #include <grass/config.h>
21 #if defined(OPENGL_X11) || defined(OPENGL_WINDOWS)
24 #elif defined(OPENGL_AQUA)
25 #include <OpenGL/gl.h>
26 #include <OpenGL/glu.h>
29 #include <grass/gstypes.h>
42 double fx, fy, fz, tx, ty, tz;
43 GLdouble modelMatrix[16], projMatrix[16];
50 glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
51 glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
52 glGetIntegerv(GL_VIEWPORT, viewport);
57 gluUnProject((GLdouble) sx, (GLdouble) sy, 0.0, modelMatrix,
58 projMatrix, viewport, &fx, &fy, &fz);
59 gluUnProject((GLdouble) sx, (GLdouble) sy, 1.0, modelMatrix,
60 projMatrix, viewport, &tx, &ty, &tz);
70 glDrawBuffer((1) ? GL_FRONT : GL_BACK);
77 glBegin(GL_LINE_STRIP);
78 glVertex3fv(vect[
FROM]);
79 glVertex3fv(vect[TO]);
86 glDrawBuffer((0) ? GL_FRONT : GL_BACK);
112 glGetIntegerv(GL_MATRIX_MODE, &mm);
113 glMatrixMode(GL_PROJECTION);
115 gluPerspective((
double).1 * (gv->fov), (
double)gd->aspect,
116 (
double)gd->nearclip, (
double)gd->farclip);
123 glRotatef((
float)(gv->twist / 10.), 0.0, 0.0, 1.0);
126 gluLookAt((
double)gv->from_to[
FROM][
X], (
double)gv->from_to[
FROM][
Y],
127 (
double)gv->from_to[
FROM][Z], (
double)gv->from_to[TO][X],
128 (
double)gv->from_to[TO][Y], (
double)gv->from_to[TO][Z],
129 (
double)up[X], (
double)up[Y], (
double)up[Z]);
150 GS_v3eq(gv->from_to[TO], gv->real_to);
151 gv->from_to[TO][Z] -= zmin;
153 gv->from_to[TO][Z] *= gv->vert_exag;
170 float zup[3], fup[3];
174 (2.0 * atan(1.0)) - acos(gv->from_to[
FROM][Z] - gv->from_to[TO][Z]);
176 zup[
X] = gv->from_to[TO][
X];
177 zup[
Y] = gv->from_to[TO][
Y];
180 zup[Z] = gv->from_to[TO][Z] + 1 / sin(alpha);
183 zup[Z] = gv->from_to[
FROM][Z] + 1.0;
205 float look_theta, pi;
207 float zup[3], yup[3], zupmag, yupmag;
209 pi = 4.0 * atan(1.0);
220 GS_v3eq(fr_to[TO], gv->from_to[TO]);
223 alpha = pi / 2.0 - acos(fr_to[FROM][Z] - fr_to[TO][Z]);
225 zup[
X] = fr_to[TO][
X];
226 zup[
Y] = fr_to[TO][
Y];
229 zup[Z] = fr_to[TO][Z] + 1 / sin(alpha);
232 zup[Z] = fr_to[
FROM][Z] + 1.0;
237 yup[
X] = fr_to[TO][
X];
238 yup[Z] = fr_to[TO][Z];
241 beta = pi / 2.0 - acos(fr_to[TO][
Y] - fr_to[FROM][
Y]);
244 yup[
Y] = fr_to[TO][
Y] - 1 / sin(beta);
247 yup[
Y] = fr_to[
FROM][
Y] + 1.0;
252 look_theta = (1800.0 / pi) *
253 acos(((zup[
X] - fr_to[FROM][
X]) * (yup[X] - fr_to[FROM][X])
254 + (zup[Y] - fr_to[FROM][Y]) * (yup[Y] - fr_to[FROM][Y])
255 + (zup[Z] - fr_to[FROM][Z]) * (yup[Z] - fr_to[FROM][Z])) /
258 if (fr_to[TO][X] - fr_to[FROM][X] < 0.0) {
259 look_theta = -look_theta;
262 if (fr_to[TO][Z] - fr_to[FROM][Z] < 0.0) {
264 if (fr_to[TO][Y] - fr_to[FROM][Y] < 0.0) {
265 look_theta = 1800 - look_theta;
270 if (fr_to[TO][Y] - fr_to[FROM][Y] > 0.0) {
271 look_theta = 1800 - look_theta;
275 return ((
int)(gv->twist + 1800 + look_theta));
309 point[
X] = (point[
X] -
w) * sx;
310 point[
Y] = (point[
Y] -
s) * sy;
311 point[Z] = (point[Z] -
min) * sz;
329 point[
X] = (sx ? point[
X] / sx : 0.0) +
w;
330 point[
Y] = (sy ? point[
Y] / sy : 0.0) +
s;
331 point[Z] = (sz ? point[Z] / sz : 0.0) +
min;
344 float min,
max, sx, sy, sz;
355 point[Z] = (sz ? point[Z] / sz : 0.0) +
min;
358 point[
X] = (sx ? point[
X] / sx : 0.0);
359 point[
Y] = (sy ? point[
Y] / sy : 0.0);