36 if (width < 1 || height < 1) {
42 G_debug(1,
"Nviz_resize_window(): width = %d height = %d", width, height);
63 float zmin, zmax, exag;
80 zmax = zmin + (3. * dc->
xyrange / exag);
81 zmin = zmin - (2. * dc->
xyrange / exag);
83 if ((zmax - zmin) > dc->
zrange)
99 float xpos, ypos, from[3];
103 xpos = (xpos < 0) ? 0 : (xpos > 1.0) ? 1.0 : xpos;
105 ypos = (ypos < 0) ? 0 : (ypos > 1.0) ? 1.0 : ypos;
107 if (x_pos < 0.0 || x_pos > 1.0 || y_pos < 0.0 || y_pos > 1.0) {
108 G_debug(3,
"Invalid view position coordinates, using %f,%f", xpos,
112 G_debug(1,
"Nviz_set_viewpoint_position(): x = %f y = %f", x_pos, y_pos);
118 if ((from[
X] != tempx) || (from[
Y] != tempy)) {
140 *x_pos = (*x_pos < 0) ? 0 : (*x_pos > 1.0) ? 1.0 : *x_pos;
142 *y_pos = (*y_pos < 0) ? 0 : (*y_pos > 1.0) ? 1.0 : *y_pos;
144 if (xpos < 0.0 || xpos > 1.0 || ypos < 0.0 || ypos > 1.0) {
145 G_debug(3,
"Invalid view position coordinates, using %f,%f", *x_pos,
161 G_debug(1,
"Nviz_set_viewpoint_height(): value = %f", height);
165 if (height != from[
Z]) {
185 G_debug(1,
"Nviz_get_viewpoint_height():");
203 G_debug(1,
"Nviz_set_viewpoint_persp(): value = %d", persp);
205 fov = (int)(10 * persp);
222 G_debug(1,
"Nviz_set_viewpoint_twist(): value = %d", twist);
242 G_debug(1,
"Nviz_change_exag(): value = %f", exag);
264 G_debug(1,
"Nviz_look_here(): screen coordinates = %f %f", sx, sy);
274 glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
290 G_debug(3,
"Nviz_set_rotation(): angle = %f, x = %f, y = %f, z = %f", angle,
327 float dir[3], from[4], cur_from[4], cur_dir[4];
328 float speed, h, p, sh, ch, sp, cp;
329 float diff_x, diff_y, diff_z;
337 p = asin(cur_dir[
Z]);
338 h = atan2(-cur_dir[
X], -cur_dir[
Y]);
340 speed = scale[0] * fly_info[0];
342 h += scale[1] * fly_info[1];
344 p -= scale[1] * fly_info[2];
358 from[
X] = cur_from[
X] + speed * dir[
Y];
359 from[
Y] = cur_from[
Y] - speed * dir[
X];
360 from[
Z] = cur_from[
Z] + scale[0] * fly_info[2];
363 from[
X] = cur_from[
X] + speed * dir[
X];
364 from[
Y] = cur_from[
Y] + speed * dir[
Y];
366 from[
Z] = cur_from[
Z];
369 diff_x = fabs(cur_dir[
X] - dir[
X]);
370 diff_y = fabs(cur_dir[
Y] - dir[
Y]);
371 diff_z = fabs(cur_dir[
Z] - dir[
Z]);
374 (diff_x > quasi_zero) || (diff_y > quasi_zero) ||
375 (diff_z > quasi_zero) || (cur_from[
X] != from[
X]) ||
376 (cur_from[
Y] != from[
Y]) || (cur_from[
Z] != from[
Z])) {
int Nviz_set_viewpoint_height(double height)
Change viewpoint height.
int Nviz_update_ranges(nv_data *dc)
Update ranges.
int Nviz_look_here(double sx, double sy)
Change focused point.
void Nviz_init_rotation(void)
Stop scene rotation.
void Nviz_get_viewpoint_position(double *x_pos, double *y_pos)
void Nviz_get_viewpoint_height(double *height)
int Nviz_resize_window(int width, int height)
GL canvas resized.
void Nviz_get_modelview(double *modelMatrix)
Get current modelview matrix.
int Nviz_set_viewpoint_twist(int twist)
Change viewpoint twist.
int Nviz_set_viewpoint_position(double x_pos, double y_pos)
Change position of view.
int Nviz_set_viewpoint_persp(int persp)
Change viewpoint perspective (field of view)
void Nviz_set_rotation(double angle, double x, double y, double z)
Set rotation parameters.
void Nviz_unset_rotation(void)
Stop scene rotation.
int Nviz_change_exag(nv_data *data, double exag)
Change z-exag value.
void Nviz_flythrough(nv_data *data UNUSED, float *fly_info, int *scale, int lateral)
Fly through the scene.
int G_debug(int, const char *,...) __attribute__((format(printf
int GS_look_here(int, int)
Send screen coords sx and sy, lib traces through surfaces; sets new center to point of nearest inters...
void GS_set_rotation(double, double, double, double)
Set rotation params.
void GS_set_fov(int)
Set field of view.
void GS_get_viewdir(float *)
Get viewdir.
void GS_set_draw(int)
Sets which buffer to draw to.
void GS_get_from(float *)
Get viewpoint 'from' position.
void GS_alldraw_wire(void)
Draw all wires.
void GS_init_rotation(void)
Reset scene rotation.
int GS_get_longdim(float *)
Get largest dimension.
void GS_get_from_real(float *)
Get viewpoint 'from' real coordinates.
void GS_set_twist(int)
Set viewpoint twist value.
void GS_set_viewdir(float *)
Set viewdir.
void GS_get_zrange_nz(float *, float *)
Get Z extents for all loaded surfaces.
void GS_moveto(float *)
Move viewpoint.
void GS_unset_rotation(void)
Stop scene rotation.
void GS_set_global_exag(float)
Set global z-exag value.
void GS_moveto_real(float *)
Move position to (real)
void GS_done_draw(void)
Draw done, swap buffers.
void GS_set_viewport(int, int, int, int)
Set viewport.
float GS_global_exag(void)
Get global z-exag value.
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.