1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903
|
/*!
\mainpage ogsflib GRASS openGL gsurf OGSF Library
<!-- doxygenized from "GRASS 5 Programmer's Manual"
by M. Neteler 2/2004
-->
<title>GRASS openGL gsurf OGSF Library</title>
\section ogsfintro OGSF Library for OpenGL programming (gsurf)
<P>
Author: Bill Brown GMSL/University of Illinois
<b>Overview</b>
<P>
The OGSF (gsurf) library, consisting of approximately 20,000 lines of
C code, contains some 180 public functions and about twice as many
internal functions for run-time data storage, manipulation, querying,
and visualization using OpenGL. The library handles all drawing and
lighting operations, including use of user-defined clipping planes and
drawing various style "fences" on clipping planes when drawing
multiple surfaces, and treats datasets as objects which can be used
for various attributes of the rendering. It allows data sharing
(e.g., same data for more than one attribute of same or different
surfaces) , separate masking for each surface, multiple surfaces,
vector sets, or point sets, and will also allow multiple volumes. The
library provides all query features such as 3D "point on surface",
keyframe animation routines, and full state saving functionality.
Database-specific routines for interfacing with the GRASS GISlib are
kept isolated for easier library reuse with other databases. The
gsurf library is not dependent upon any particular interface library,
and has been used successfully with both Motif and Tcl/Tk. It is used
for NVIZ visualization tool.
<P>
The library is designed to provide a unique "handle" or identifier
number to the calling program for each new geographic object added to
the model. The object could be a surface, vector set, or point set,
which could each be defined by one or more database files. Once
created, the application only needs to keep track of the "handles" to
the objects (which are returned by the creation routines) ; for
example, to draw a surface the application would make the call:
<BR>
<P>
GS_draw_surf(id)
<BR>
<P>
where <I>id</I> is the handle number. To associate a vector set with
a surface and then draw all surfaces with the vector set draped over
the one selected, the application would use the calls:
<BR>
<P>
GV_select_surf(vid, sid)
<BR>
<P>
GS_alldraw_surf()
<BR>
<P>
GV_draw_vect(vid)
<BR>
<P>
where <I>vid</I> and <I>sid</I> are the handles for the vector set and
surface. Similarly, to query or change attributes of the object, the
handle is used in conjunction with the new attribute, as in:
GV_set_vectmode(id, mem, color, width)
\subsection Naming_Conventions Naming Conventions
<P>
The following naming conventions for function prefixes are used:
<UL>
<LI><B>GS_</B>
Functions which have to do with loading & manipulating
surfaces. Also functions for library initialization,
setting global variables, viewer positioning, and lighting.
</LI>
<LI><B>GSU_</B>
Utility functions for distance calculations, common 2D & 3D
unit vector operations such as cross product or vector arithmetic.
</LI>
<LI><B>GV_</B>
Functions which have to do with loading & manipulating
vector sets.
</LI>
<LI><B>GP_</B>
Functions which have to do with loading & manipulating
point sets.
</LI>
<LI><B>GVL_</B>
Functions which have to do with loading & manipulating 3D
volumes.
</LI>
<LI><B>GK_</B>
Functions which have to do with setting & manipulating
keyframes for viewer position animation (fly-bys) .
</LI>
</UL>
<P>
Programmers' documentation is currently incomplete, but see the
following for more details of the library design and capabilities in
the appendix (PLEASE ADD EXPLANATIONS!!):
<P>
<UL>
<LI>public function prototypes
</LI>
<LI>public include file gsurf.h
</LI>
<LI>public include file keyframe.h
</LI>
<LI>public color packing utility macros rgbpack.h
</LI>
<LI>private types and defines gstypes.h
</LI>
<LI>private utilities gsget.h
</LI>
</UL>
<P>
\section Public_function_prototypes Public function prototypes
\subsection Function_Prototypes_for_gsurf_Library Function Prototypes
for gsurf Library
\subsection gs_init Initialization and positioning (GS)
Functions which have to do with loading & manipulating surfaces.
Also functions for library initialization, setting global variables,
viewer positioning, and lighting.
<P>
void *GS_Get_ClientData(int id)
<P>
float GS_P2distance (float *from, float *to)
<P>
GS_Set_ClientData(int id, void *clientd)
<P>
GS_alldraw_cplane_fences()
<P>
GS_alldraw_surf()
<P>
GS_alldraw_wire()
<P>
GS_background_color()
<P>
int GS_check_cancel()
<P>
GS_clear(int col)
<P>
GS_default_draw_color()
<P>
GS_delete_surface(int id)
<P>
GS_distance (float *from, *to)
<P>
GS_done_draw()
<P>
int GS_draw_X(int id, float *pt) pt only has to have an X & Y value
in true world coordinates
<P>
GS_draw_cplane(int num)
<P>
GS_draw_cplane_fence(int hs1, int hs2, int num)
<P>
GS_draw_lighting_model()
<P>
GS_draw_line_onsurf(int id, float x1, float y1, float x2, float y2)
<P>
GS_draw_surf(int id)
<P>
GS_draw_wire(int id)
<P>
int GS_dv3norm(double dv1[3])
Changes dv1 so that it is a unit vector
<P>
double GS_geodistance(double *from, double *to, char
*units) distance between 2 coordinates
Returns distance between two geographic coordinates in current
projection.
<P>
Units is one of:
"meters",
"miles",
"kilometers",
"feet",
"yards",
"nmiles" (nautical miles),
"rods",
"inches",
"centimeters",
"millimeters",
"micron",
"nanometers",
"cubits",
"hands",
"furlongs",
"chains".
<P>
Default is meters.
<P>
GS_get_SDscale(float *scale)
<P>
GS_get_SDsurf(int id)
<P>
double GS_get_aspect()
<P>
GS_get_att(int id, int att, int *set, float *constant, char *mapname)
<P>
GS_get_cat_at_xy(int id, int att, char *catstr, float x, float y)
<P>
GS_get_dims(int id, int *rows, int *cols)
<P>
int GS_get_distance_alongsurf(int hs, int use_exag, float x1, float
y1, float x2, float y2, float *dist) Returns distance following terrain.
<P>
GS_get_drawmode(int id, int mode)
<P>
GS_get_drawres(int id, int *xres, int *yres, int *xwire, int *ywire)
<P>
GS_get_exag_guess(int id, float *exag)
<P>
int GS_get_fencecolor()
<P>
GS_get_focus(float *realto)
<P>
int GS_get_fov() Returns field of view, in 10ths of degrees.
<P>
GS_get_from(float *fr)
<P>
GS_get_from_real(float *fr)
<P>
GS_get_longdim(float *dim)
<P>
GS_get_maskmode(int id, int mode)
<P>
int GS_get_modelposition(float *siz, float pos[3])
Retrieves coordinates for lighting model position, at center of view,
(nearclip * 2) from eye.
<P>
GS_get_nozero(int id, int att, int *mode)
<P>
GS_get_region(float *n, float *s, float *w, float *e)
<P>
GS_get_scale(float *sx, float *sy, float *sz, int doexag)
<P>
int GS_get_selected_point_on_surface(int sx, int sy, int *id, float
*x, float *y, float *z)
Given screen coordinates sx & sy, find closest intersection of
view ray with surfaces and return coordinates of intersection in x, y,
z, and identifier of surface in id.
<P>
Returns 0 if no intersections found, otherwise number of intersections.
<P>
GS_get_surf_list(int *numsurfs)
<P>
GS_get_to(float *to)
<P>
GS_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
<P>
int GS_get_twist()
<P>
int GS_get_val_at_xy(int id, char *att, char *valstr, float x, float
y) Prints "NULL" or the value (i.e., "921.5") to valstr.
<P>
Colors are translated to rgb and returned as Rxxx Gxxx Bxxx
<P>
Usually call after GS_get_selected_point_on_surface
<P>
Returns -1 if point outside of window or masked, otherwise 1
<P>
GS_get_viewdir(float dir[3])
<P>
GS_get_wire_color(int id, int *colr)
<P>
int GS_get_zextents(int id, float *min, float *max, float
*mid) Returns Z extents for a single surface.
<P>
int GS_get_zrange(float *min, float *max, int doexag) Returns Z
extents for all loaded surfaces.
<P>
int GS_get_zrange_nz(float *min, float *max) Returns Z extents for
all loaded surfaces, treating zeros as "no data".
<P>
float GS_global_exag()
<P>
int GS_has_transparency()
<P>
GS_init_view()
<P>
GS_is_masked(int id, float *pt)
<P>
GS_libinit()
<P>
GS_lights_off()
<P>
GS_lights_on()
<P>
GS_load_3dview(char *vname, int surfid)
<P>
GS_load_att_map(int id, char *filename, int att)
<P>
int GS_look_here(int sx, int sy) Reset center of view to screen
coordinates sx, sy.
<P>
Send screen coords sx & sy, lib traces through surfaces & sets
new center to point of nearest intersection. If no intersection, uses
line of sight with length of current view ray (eye to center) to set
new center.
<P>
GS_moveto(float *pt)
<P>
GS_moveto_real(float *pt)
<P>
int GS_new_light()
<P>
GS_new_surface()
<P>
int GS_num_surfs()
<P>
GS_ready_draw()
<P>
GS_save_3dview(char *vname, int surfid)
<P>
GS_set_SDscale(float scale)
<P>
GS_set_SDsurf(int id)
<P>
GS_set_att_const(int id, int att, float constant)
<P>
GS_set_att_defaults(float defs[MAX_ATTS], null_defs[MAX_ATTS])
<P>
GS_set_cancel(int c)
<P>
GS_set_cplane(int num)
<P>
GS_set_cplane_rot(int num, float dx, float dy, float dz)
<P>
GS_set_cplane_trans(int num, float dx, float dy, float dz)
<P>
GS_set_cxl_func(void (*f) () )
<P>
int GS_set_draw(int where) Sets which buffer to draw to.
<P>
where should be one of: GSD_BOTH, GSD_FRONT, GSD_BACK
<P>
GS_set_drawmode(int id, int mode)
<P>
GS_set_drawres(int id, int xres, int yres, int xwire, int ywire)
<P>
GS_set_exag(int id, float exag)
<P>
GS_set_fencecolor(int mode)
<P>
GS_set_focus(float *realto)
<P>
GS_set_focus_center_map(int id)
<P>
GS_set_fov(int fov)
<P>
GS_set_global_exag(float exag)
<P>
GS_set_maskmode(int id, int mode)
<P>
GS_set_nofocus()
<P>
GS_set_nozero(int id, int att, int mode)
<P>
GS_set_swap_func(void (*f) () )
<P>
GS_set_trans(int id, float xtrans, float ytrans, float ztrans)
<P>
int GS_set_twist(int t) t is tenths of degrees clockwise from 12:00.
<P>
GS_set_viewdir(float dir[3])
<P>
GS_set_viewport(int left, int right, int bottom, int top)
<P>
GS_set_wire_color(int id, int colr)
<P>
GS_setall_drawmode(int mode)
<P>
GS_setall_drawres(int xres, int yres, int xwire, int ywire)
<P>
int GS_setlight_ambient(int num, float red, float green, float
blue) Red, green, blue from 0.0 to 1.0
<P>
int GS_setlight_color(int num, float red, float green, float
blue) Red, green, blue from 0.0 to 1.0
<P>
GS_setlight_position(int num, float xpos, float ypos, float zpos, int
local)
<P>
GS_surf_exists(int id)
<P>
GS_switchlight(int num, int on)
<P>
GS_transp_is_set()
<P>
GS_unset_SDsurf()
<P>
GS_unset_att(int id, int att)
<P>
GS_unset_cplane(int num)
<P>
GS_update_curmask(int id)
<P>
GS_update_normals(int id)
<P>
GS_v2dir(float v1[2], float v2[2], float v3[2])
<P>
GS_v3add(float v1[3], float v2[3])
<P>
int GS_v3cross(float v1[3], float v2[3], float v3[3]) returns the
cross product v3 = v1 cross v2
<P>
GS_v3dir(float v1[3], float v2[3], float v3[3)
<P>
GS_v3eq(float v1[3], float v2[3])
<P>
GS_v3mag(float v1[3], float *mag)
<P>
int GS_v3mult(float v1[3], float k) v1 *= k
<P>
int GS_v3norm(float v1[3]) Changes v1 so that it is a unit vector
<P>
int GS_v3normalize(float v1[3], float v2[3]) Changes v2 so that v1v2 is a
unit vector
<P>
int GS_v3sub(float v1[3], float v2[3]) v1 -= v2
\subsection gv_vect Loading and manipulation of vector maps (GV)
Functions which have to do with loading & manipulating vector
sets.
<P>
void *GV_Get_ClientData(int id)
<P>
GV_Set_ClientData(int id, int clientd)
<P>
GV_alldraw_vect()
<P>
GV_delete_vector(int id)
<P>
GV_draw_fastvect(int vid)
<P>
GV_draw_vect(int vid)
<P>
GV_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
<P>
int *GV_get_vect_list(int *numvects) USER must free when no longer needed!
<P>
GV_get_vectmode(int id, int *mem, int *color, int *width)
<P>
GV_get_vectname(int id, char *filename)
<P>
GV_load_vector(int id, char *filename)
<P>
int GV_new_vector()
<P>
int GV_num_vects()
<P>
int GV_select_surf(int hv, int hs) Select surface identified by hs
to have vector identified by hv draped over it.
<P>
GV_set_trans(int id, float xtrans, float ytrans, float ztrans)
<P>
GV_set_vectmode(int id, int mem, int color, int width)
<P>
GV_surf_is_selected(int hv, int hs)
<P>
GV_unselect_surf(int hv, int hs)
<P>
GV_vect_exists(int id)
\subsection gp_points Loading and manipulation of point maps (GP)
Functions which have to do with loading & manipulating point sets.
<P>
void *GP_Get_ClientData(int id)
<P>
GP_Set_ClientData(int id, void *clientd)
<P>
GP_alldraw_site()
<P>
GP_attmode_color(int id, char *filename)
<P>
GP_attmode_none(int id)
<P>
GP_delete_site(int id)
<P>
GP_draw_site(int id)
<P>
int *GP_get_site_list(int *numsites) USER must free when no
longer needed!
<P>
GP_get_sitemode(int id, int *atmod, int *color, int *width, float *size,
int *marker)
<P>
GP_get_sitename(int id, char *filename)
<P>
GP_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
<P>
GP_get_zmode(int id, int *use_z)
<P>
GP_load_site(int id, char *filename)
<P>
int GP_new_site()
<P>
int GP_num_sites()
<P>
GP_select_surf(int hp, int hs)
<P>
GP_set_sitemode(int id, int atmod, int color, int width, float size, int
marker)
<P>
GP_set_trans(int id, float *xtrans, float *ytrans, float *ztrans)
<P>
GP_set_zmode(int id, int use_z)
<P>
GP_site_exists(int id)
<P>
GP_surf_is_selected(int hp, int hs)
<P>
GP_unselect_surf(int hp, int hs)
\subsection gk_keyframes Keyframe animation
Functions which have to do with setting & manipulating keyframes
for viewer position animation (fly-bys).
<P>
int GK_add_key(float pos, unsigned long fmask, int force_replace,
float precis)
The pos value is the relative position in the animation for this
particular keyframe - used to compare relative distance to neighboring
keyframes, it can be any floating point value.
<P>
The fmask value can be any of the following or'd together:
KF_FROMX_MASK
KF_FROMY_MASK
KF_FROMZ_MASK
KF_FROM_MASK (KF_FROMX_MASK | KF_FROMY_MASK | KF_FROMZ_MASK)
<P>
KF_DIRX_MASK
KF_DIRY_MASK
KF_DIRZ_MASK
KF_DIR_MASK (KF_DIRX_MASK | KF_DIRY_MASK | KF_DIRZ_MASK)
<P>
KF_FOV_MASK
KF_TWIST_MASK
<P>
KF_ALL_MASK (KF_FROM_MASK | KF_DIR_MASK | KF_FOV_MASK | KF_TWIST_MASK)
<P>
Other fields will be added later.
<P>
The value precis and the boolean force_replace are used to determine
if a keyframe should be considered to be at the same position as a
pre-existing keyframe. e.g., if anykey.pos - newkey.pos <= precis,
GK_add_key() will fail unless force_replace is TRUE.
<P>
Returns 1 if key is added, otherwise -1.
<P>
void GK_clear_keys() Deletes all keyframes, resets field masks.
Doesn't change number of frames requested.
<P>
int GK_delete_key(float pos, float precis, int justone)
The values pos & precis are used to determine which keyframes to
delete. Any keyframes with their position within precis of pos will
be deleted if justone is zero. If justone is non-zero, only the first
(lowest pos) keyframe in the range will be deleted.
<P>
Returns number of keys deleted.
<P>
int GK_do_framestep(int step, int render)
Moves the animation to frame number "step". Step should be a value
between 1 and the number of frames. If render is non-zero, calls
draw_all.
<P>
int GK_move_key(float oldpos, float precis, float newpos)
Precis works as in other functions - to identify keyframe to move.
Only the first keyframe in the precis range will be moved.
<P>
Returns number of keys moved (1 or 0) .
<P>
int GK_set_interpmode(int mode) Sets interpolation mode to
KF_LINEAR or KF_SPLINE
<P>
void GK_set_numsteps(int newsteps) Sets the number of frames to be
interpolated from keyframes.
<P>
int GK_set_tension(float tens) Sets value for tension when interpmode
is KF_SPLINE. The value tens should be between 0.0 & 1.0.
<P>
void GK_show_path(int flag) Draws the current path.
<P>
GK_show_site(int flag)
<P>
GK_show_vect(int flag)
<P>
void GK_showtension_start()
<P>
void GK_showtension_stop() Use
GK_showtension_start/GK_update_tension/GK_showtension_stop to
initialize & stop multi-view display of path when changing
tension.
<P>
void GK_update_frames() Recalculates path using the current number of
frames requested. Call after changing number of frames or when
Keyframes change.
<P>
void GK_update_tension()
\subsection gvl_volume Loading and manipulation of volume maps (GVL)
Functions which have to do with loading & manipulating 3D volumes.
<P>
void *GVL_Get_ClientData(int id)
<P>
GVL_Set_ClientData(int id, void *clientd)
<P>
GVL_alldraw_vol()
<P>
GVL_delete_volume(int id)
<P>
GVL_draw_fastvol(int vid)
<P>
GVL_draw_vol(int vid)
<P>
GVL_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
<P>
int *GVL_get_vol_list(int *numvols)
<P>
GVL_get_volmode(int id, int *viztype)
<P>
GVL_get_volname(int id, char *filename)
<P>
GVL_load_volume(int id, char *filename)
<P>
int GVL_new_vol()
<P>
int GVL_num_vol()
<P>
GVL_set_trans(int id, float xtrans, float ytrans, float ztrans)
<P>
GVL_set_volmode(int id, int viztype)
<P>
int GVL_vol_exists(int id)
<P>
\subsection gsurf_h Public include file gsurf.h
See src/libes/ogsf/gsurf.h
\subsection keyframe_h Public include file keyframe.h
See src/libes/ogsf/keyframe.h
\subsection rgbpack_h Public color packing utility macros rgbpack.h
See src/libes/ogsf/rgbpack.h
\subsection gstypes_h Private types and defines gstypes.h
See src/libes/ogsf/gstypes.h
\subsection gsget_h Private utilities gsget.h
See src/libes/ogsf/gsget.h
*/
|