21 #include <grass/gis.h>
22 #include <grass/glocale.h>
23 #include <grass/gstypes.h>
41 #define DEBUG_ARROW (0)
46 #define SET_SCOLOR(sf) \
49 tx = points[sf][i][X] - gsurfs[sf]->x_trans; \
50 ty = points[sf][i][Y] - gsurfs[sf]->y_trans; \
51 offset = XY2OFF(gsurfs[sf], tx, ty); \
52 colors[sf] = gs_mapcolor(cobuf[sf], coloratt[sf], offset); \
55 static int transpoint_is_masked(geosurf *, Point3);
56 static int get_point_below(Point3 **, geosurf **,
int,
int,
int,
int *);
85 G_debug(5,
"gsd_surf(): id=%d", surf->gsurf_id);
142 int check_mask, check_color, check_transp;
143 int check_material, check_emis, check_shin;
144 typbuff *
buff, *cobuff, *trbuff, *embuff, *shbuff;
145 int xmod, ymod, row, col, cnt, xcnt, ycnt;
146 long offset, y1off, y2off;
147 float x1, x2, y1, y2, tx, ty, tz, ttr;
148 float n[3], pt[4], xres, yres,
ymax, zexag;
149 int em_src, sh_src, trans_src, col_src, curcolor;
150 gsurf_att *ematt, *shatt, *tratt, *coloratt;
154 GLdouble modelMatrix[16], projMatrix[16];
159 float sz, mag, tedge1[3], tedge2[3], crossp[3], triv[3][3];
160 double asurf = 0.0, axsurf = 0.0;
163 int zeros, dr1, dr2, dr3, dr4;
164 int datarow1, datacol1, datarow2, datacol2;
166 float kem, ksh, pkem, pksh;
169 G_debug(3,
"gsd_surf_map_old");
187 check_mask = surf->curmask ? 1 : 0;
195 xres = xmod * surf->xres;
196 yres = ymod * surf->yres;
197 ymax = (surf->rows - 1) * surf->yres;
205 window[0] += (
int)(yres * 2);
206 window[1] -= (
int)(yres * 2);
207 window[2] -= (
int)(xres * 2);
208 window[3] += (
int)(xres * 2);
214 zexag = surf->z_exag;
230 tratt = &(surf->att[ATT_TRANSP]);
231 ktrans = (255 << 24);
232 trans_src = surf->att[ATT_TRANSP].att_src;
234 if (CONST_ATT == trans_src && surf->att[ATT_TRANSP].constant != 0.0) {
235 ktrans = (255 - (
int)surf->att[ATT_TRANSP].constant) << 24;
239 else if (MAP_ATT == trans_src) {
241 check_transp = trbuff ? 1 : 0;
247 ematt = &(surf->att[ATT_EMIT]);
250 em_src = surf->att[ATT_EMIT].att_src;
252 if (CONST_ATT == em_src) {
253 kem = surf->att[ATT_EMIT].constant / 255.;
255 else if (MAP_ATT == em_src) {
257 check_emis = embuff ? 1 : 0;
261 shatt = &(surf->att[ATT_SHINE]);
264 sh_src = surf->att[ATT_SHINE].att_src;
266 if (CONST_ATT == sh_src) {
267 ksh = surf->att[ATT_SHINE].constant / 255.;
270 else if (MAP_ATT == sh_src) {
272 check_shin = shbuff ? 1 : 0;
278 coloratt = &(surf->att[ATT_COLOR]);
279 col_src = surf->att[ATT_COLOR].att_src;
281 if (col_src != MAP_ATT) {
282 if (col_src == CONST_ATT) {
283 curcolor = (
int)surf->att[ATT_COLOR].constant;
286 curcolor = surf->wire_color;
292 check_material = (check_shin || check_emis || (kem && check_color));
298 for (row = 0; row < ycnt; row++) {
307 datarow1 = row * ymod;
308 datarow2 = (row + 1) * ymod;
310 y1 = ymax - row * yres;
311 y2 = ymax - (row + 1) * yres;
312 y1off = row * ymod * surf->cols;
313 y2off = (row + 1) * ymod * surf->cols;
318 dr1 = dr2 = dr3 = dr4 = 1;
321 if (
BM_get(surf->curmask, 0, datarow1)) {
326 if (
BM_get(surf->curmask, 0, datarow2)) {
334 FNORM(surf->norms[offset], n);
346 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
347 ktrans = (char)(255 - ktrans) << 24;
359 FNORM(surf->norms[offset], n);
371 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
372 ktrans = (char)(255 - ktrans) << 24;
375 if (check_material) {
386 if (pksh != ksh || pkem != kem || (kem && check_color)) {
404 for (col = 0; col < xcnt; col++) {
405 datacol1 = col * xmod;
406 datacol2 = (col + 1) * xmod;
409 x2 = (col + 1) * xres;
412 dr1 = dr2 = dr3 = dr4 = 1;
415 if (
BM_get(surf->curmask, datacol1, datarow1)) {
420 if (
BM_get(surf->curmask, datacol1, datarow2)) {
425 if (
BM_get(surf->curmask, datacol2, datarow2)) {
430 if (
BM_get(surf->curmask, datacol2, datarow1)) {
435 if ((zeros > 1) && cnt) {
450 offset = y1off + datacol1;
451 FNORM(surf->norms[offset], n);
458 (pt, window, viewport, modelMatrix, projMatrix)) {
471 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
472 ktrans = (char)(255 - ktrans) << 24;
475 if (check_material) {
486 if (pksh != ksh || pkem != kem
487 || (kem && check_color)) {
505 offset = y2off + datacol1;
506 FNORM(surf->norms[offset], n);
513 (pt, window, viewport, modelMatrix, projMatrix)) {
526 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
527 ktrans = (char)(255 - ktrans) << 24;
530 if (check_material) {
541 if (pksh != ksh || pkem != kem
542 || (kem && check_color)) {
561 offset = y1off + datacol2;
562 FNORM(surf->norms[offset], n);
569 (pt, window, viewport, modelMatrix, projMatrix)) {
582 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
583 ktrans = (char)(255 - ktrans) << 24;
586 if (check_material) {
597 if (pksh != ksh || pkem != kem || (kem && check_color)) {
630 offset = y2off + datacol2;
631 FNORM(surf->norms[offset], n);
638 (pt, window, viewport, modelMatrix, projMatrix)) {
651 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
652 ktrans = (char)(255 - ktrans) << 24;
655 if (check_material) {
666 if (pksh != ksh || pkem != kem || (kem && check_color)) {
709 G_debug(5,
" Surface Area: %.12lf", asurf);
710 G_debug(5,
" Exaggerated Surface Area: %.12lf", axsurf);
731 int do_diff, check_mask, check_color;
733 int xmod, ymod, row, col, cnt, xcnt, ycnt;
734 long offset, y1off, y2off;
735 float x1, x2, y1, y2, tx, ty, tz;
736 float n[3], pt[4], xres, yres,
ymax, zexag;
737 int col_src, curcolor;
741 GLdouble modelMatrix[16], projMatrix[16];
745 int zeros, dr1, dr2, dr3, dr4;
746 int datarow1, datacol1, datarow2, datacol2;
748 unsigned int ktrans = 255;
750 G_debug(5,
"gsd_surf_const(): id=%d", surf->gsurf_id);
759 check_mask = surf->curmask ? 1 : 0;
768 xres = xmod * surf->xres;
769 yres = ymod * surf->yres;
773 ymax = (surf->rows - 1) * surf->yres;
778 window[0] += (
int)(yres * 2);
779 window[1] -= (
int)(yres * 2);
780 window[2] -= (
int)(xres * 2);
781 window[3] += (
int)(xres * 2);
799 zexag = surf->z_exag;
801 if (CONST_ATT == surf->att[ATT_TRANSP].att_src) {
803 ktrans = 255 - (
int)surf->att[ATT_TRANSP].constant;
807 ktrans = (ktrans << 24);
813 coloratt = &(surf->att[ATT_COLOR]);
814 col_src = surf->att[ATT_COLOR].att_src;
816 if (col_src != MAP_ATT) {
817 if (col_src == CONST_ATT) {
818 curcolor = (
int)surf->att[ATT_COLOR].constant;
821 curcolor = surf->wire_color;
834 if (!check_color && !check_mask && !do_diff) {
859 for (row = 0; row < ycnt; row++) {
868 datarow1 = row * ymod;
869 datarow2 = (row + 1) * ymod;
871 y1 = ymax - row * yres;
872 y2 = ymax - (row + 1) * yres;
873 y1off = row * ymod * surf->cols;
874 y2off = (row + 1) * ymod * surf->cols;
879 dr1 = dr2 = dr3 = dr4 = 1;
882 if (
BM_get(surf->curmask, 0, datarow1)) {
887 if (
BM_get(surf->curmask, 0, datarow2)) {
925 for (col = 0; col < xcnt; col++) {
926 datacol1 = col * xmod;
927 datacol2 = (col + 1) * xmod;
930 x2 = (col + 1) * xres;
933 dr1 = dr2 = dr3 = dr4 = 1;
936 if (
BM_get(surf->curmask, datacol1, datarow1)) {
941 if (
BM_get(surf->curmask, datacol1, datarow2)) {
946 if (
BM_get(surf->curmask, datacol2, datarow2)) {
951 if (
BM_get(surf->curmask, datacol2, datarow1)) {
956 if ((zeros > 1) && cnt) {
971 offset = y1off + datacol1;
976 (pt, window, viewport, modelMatrix, projMatrix)) {
996 offset = y2off + datacol1;
1001 (pt, window, viewport, modelMatrix, projMatrix)) {
1022 offset = y1off + datacol2;
1027 (pt, window, viewport, modelMatrix, projMatrix)) {
1047 offset = y2off + datacol2;
1052 (pt, window, viewport, modelMatrix, projMatrix)) {
1112 geosurf * surf2, Point3 * points1, Point3 * points2,
1115 int i, i1, i2, nlong, offset, col_src;
1116 int check_color1, check_color2, color1, color2;
1117 typbuff *cobuf1, *cobuf2;
1118 gsurf_att *coloratt1, *coloratt2;
1120 check_color1 = check_color2 = 1;
1122 col_src = surf1->att[ATT_COLOR].att_src;
1124 if (col_src != MAP_ATT) {
1125 if (col_src == CONST_ATT) {
1126 color1 = (
int)surf1->att[ATT_COLOR].constant;
1129 color1 = surf1->wire_color;
1135 coloratt1 = &(surf1->att[ATT_COLOR]);
1138 col_src = surf2->att[ATT_COLOR].att_src;
1139 if (col_src != MAP_ATT) {
1140 if (col_src == CONST_ATT) {
1141 color2 = (
int)surf2->att[ATT_COLOR].constant;
1144 color2 = surf2->wire_color;
1150 coloratt2 = &(surf2->att[ATT_COLOR]);
1159 for (nlong = (npts1 > npts2 ? npts1 : npts2), i = 0; i < nlong; i++) {
1160 i1 = i * npts1 / nlong;
1161 i2 = i * npts2 / nlong;
1162 offset =
XY2OFF(surf1, points1[i1][
X], points1[i1][
Y]);
1168 offset =
XY2OFF(surf1, points2[i2][X], points2[i2][Y]);
1175 if (npts1 > npts2) {
1176 points1[i1][
X] += surf1->x_trans;
1177 points1[i1][
Y] += surf1->y_trans;
1178 points1[i1][Z] += surf1->z_trans;
1180 points2[i2][
X] += surf2->x_trans;
1181 points2[i2][
Y] += surf2->y_trans;
1182 points2[i2][Z] += surf2->z_trans;
1186 points2[i2][
X] += surf2->x_trans;
1187 points2[i2][
Y] += surf2->y_trans;
1188 points2[i2][Z] += surf2->z_trans;
1190 points1[i1][
X] += surf1->x_trans;
1191 points1[i1][
Y] += surf1->y_trans;
1192 points1[i1][Z] += surf1->z_trans;
1233 static int transpoint_is_masked(geosurf * surf, Point3
point)
1237 tp[
X] = point[
X] - surf->x_trans;
1238 tp[
Y] = point[
Y] - surf->y_trans;
1258 static int get_point_below(Point3 ** points, geosurf ** gsurfs,
int ptn,
1259 int cursurf,
int numsurfs,
int *belowsurf)
1262 float nearz = 0.0, diff;
1264 if (gsurfs[cursurf]->curmask) {
1265 if (transpoint_is_masked(gsurfs[cursurf], points[cursurf][ptn])) {
1270 for (n = 0; n < numsurfs; ++
n) {
1271 diff = points[cursurf][ptn][Z] - points[
n][ptn][Z];
1274 if (!nearz || diff < nearz) {
1275 if (gsurfs[n]->curmask) {
1276 if (transpoint_is_masked(gsurfs[n], points[n][ptn])) {
1330 int n, i, offset, col_src, check_color[MAX_SURFS];
1331 int color, colors[MAX_SURFS], nocolor;
1332 typbuff *cobuf[MAX_SURFS];
1333 gsurf_att *coloratt[MAX_SURFS];
1335 nocolor = FCmode == FC_GREY ? 1 : 0;
1338 for (n = 0; n < ns; ++
n) {
1341 col_src = gsurfs[
n]->att[ATT_COLOR].att_src;
1343 if (col_src != MAP_ATT) {
1344 if (col_src == CONST_ATT) {
1345 colors[
n] = (
int)gsurfs[n]->att[ATT_COLOR].constant;
1348 colors[
n] = gsurfs[
n]->wire_color;
1354 coloratt[
n] = &(gsurfs[
n]->att[ATT_COLOR]);
1384 int bn, bnl, ctop, cbot, ctopl, cbotl, bsret;
1388 ctop = cbot = ctopl = cbotl =
color;
1391 for (n = 0; n < ns; ++
n) {
1392 for (i = 0; i < np; i++) {
1395 get_point_below(points, gsurfs, i, n, ns, &bn))) {
1402 if (FCmode == FC_ABOVE) {
1403 ctop = cbot = colors[
n];
1405 else if (FCmode == FC_BELOW) {
1406 ctop = cbot = colors[bn];
1416 if (!transpoint_is_masked(gsurfs[n], points[n][i - 1])
1417 && !transpoint_is_masked(gsurfs[bn],
1418 points[bn][i - 1])) {
1421 points[n][i][Z], 0.0,
1422 points[bn][i - 1][Z], 1.0,
1423 points[bn][i][Z], &tx, &ty)) {
1425 xing[
Y] = points[
n][i - 1][
Y] + tx *
1426 (points[
n][i][
Y] - points[
n][i - 1][
Y]);
1427 xing[
X] = points[
n][i - 1][
X] + tx *
1428 (points[
n][i][
X] - points[
n][i - 1][
X]);
1430 xing[Z] = points[bn][i - 1][Z] + tx *
1431 (points[bn][i][Z] - points[bn][i - 1][Z]);
1443 while (i < np && 0 < (bsret =
1444 get_point_below(points, gsurfs, i,
1462 if (FCmode == FC_ABOVE) {
1463 ctop = cbot = colors[
n];
1465 else if (FCmode == FC_BELOW) {
1466 ctop = cbot = colors[bn];
1495 if (bnl >= 0 && bnl != bn) {
1500 if (!transpoint_is_masked(gsurfs[n],
1501 points[n][i - 1]) &&
1502 !transpoint_is_masked(gsurfs[bnl],
1503 points[bnl][i - 1]) &&
1504 !transpoint_is_masked(gsurfs[bn],
1505 points[bn][i - 1])) {
1508 points[n][i - 1][Z],
1509 1.0, points[n][i][Z],
1511 points[bn][i - 1][Z],
1512 1.0, points[bn][i][Z],
1517 "crossing going up at surf %d no. %d",
1522 xing[
Y] = points[
n][i - 1][
Y] + tx *
1524 points[
n][i - 1][
Y]);
1526 points[
n][i - 1][
X] +
1527 tx * (points[
n][i][
X] -
1528 points[
n][i - 1][
X]);
1531 xing[Z] = points[bnl][i - 1][Z] + tx *
1532 (points[bnl][i][Z] -
1533 points[bnl][i - 1][Z]);
1554 "crossing going down at surf %d no. %d",
1559 xing[
Y] = points[
n][i - 1][
Y] + tx *
1561 points[
n][i - 1][
Y]);
1563 points[
n][i - 1][
X] +
1564 tx * (points[
n][i][
X] -
1565 points[
n][i - 1][
X]);
1568 xing[Z] = points[bnl][i - 1][Z] + tx *
1569 (points[bnl][i][Z] -
1570 points[bnl][i - 1][Z]);
1576 xing[Z] = points[bn][i - 1][Z] + tx *
1578 points[bn][i - 1][Z]);
1584 !transpoint_is_masked(gsurfs[bn],
1585 points[bn][i - 1]) &&
1586 !transpoint_is_masked(gsurfs[bnl],
1587 points[bnl][i - 1])) {
1590 points[bn][i - 1][Z],
1591 1.0, points[bn][i][Z],
1593 points[bnl][i - 1][Z],
1603 "lower crossing at surf %d no. %d between surfs %d & %d",
1607 xing[
Y] = points[bn][i - 1][
Y] + tx *
1609 points[bn][i - 1][
Y]);
1610 xing[
X] = points[bn][i - 1][
X] + tx *
1612 points[bn][i - 1][
X]);
1614 z1 = xing[Z] = points[
n][i - 1][Z] + tx *
1616 points[
n][i - 1][Z]);
1631 if (!upper && !lower) {
1633 "Crossing NOT found or masked:");
1635 " current surf: %d [ %.2f %.2f %.2f -> %.2f %.2f %f",
1636 n, points[n][i - 1][
X],
1637 points[n][i - 1][
Y],
1638 points[n][i - 1][Z],
1639 points[n][i][
X], points[n][i][
Y],
1642 " below surf: %d [ %.2f %.2f %.2f -> %.2f %.2f %f\n",
1643 bn, points[bn][i - 1][X],
1644 points[bn][i - 1][Y],
1645 points[bn][i - 1][Z],
1650 " last below surf: %d [ %.2f %.2f %.2f -> %.2f %.2f %f\n",
1651 bnl, points[bnl][i - 1][X],
1652 points[bnl][i - 1][Y],
1653 points[bnl][i - 1][Z],
1670 if (!transpoint_is_masked(gsurfs[n], points[n][i - 1])
1671 && !transpoint_is_masked(gsurfs[bn],
1672 points[bn][i - 1])) {
1675 points[n][i][Z], 0.0,
1676 points[bn][i - 1][Z], 1.0,
1677 points[bn][i][Z], &tx, &ty)) {
1679 xing[
Y] = points[
n][i - 1][
Y] + tx *
1680 (points[
n][i][
Y] - points[
n][i - 1][
Y]);
1681 xing[
X] = points[
n][i - 1][
X] + tx *
1682 (points[
n][i][
X] - points[
n][i - 1][
X]);
1717 geosurf *gsurfs[MAX_SURFS];
1718 Point3 *points[MAX_SURFS], *tmp;
1719 int nsurfs, ret, npts, npts1,
n, i,
err = 0;
1720 float bgn1[2], end1[2];
1722 if (norm[Z] > 0.0001 || norm[Z] < -.0001) {
1726 if (FCmode == FC_OFF) {
1732 for (n = 0; n < nsurfs; n++) {
1734 bgn1[
X] = bgn[
X] - gsurfs[
n]->x_trans;
1735 bgn1[
Y] = bgn[
Y] - gsurfs[
n]->y_trans;
1736 end1[
X] = end[
X] - gsurfs[
n]->x_trans;
1737 end1[
Y] = end[
Y] - gsurfs[
n]->y_trans;
1741 if (npts != npts1) {
1742 G_warning(_(
"Cut-plane points mis-match between surfaces. "
1743 "Check resolution(s)."));
1753 if (n == nsurfs - 1) {
1757 for (i = 0; i < npts1; i++) {
1759 points[
n][i][
X] += gsurfs[
n]->x_trans;
1760 points[
n][i][
Y] += gsurfs[
n]->y_trans;
1761 points[
n][i][Z] += gsurfs[
n]->z_trans;
1768 points[
n] = (Point3 *) G_calloc(npts1,
sizeof(Point3));
1770 for (i = 0; i < npts1; i++) {
1771 GS_v3eq(points[n][i], tmp[i]);
1774 points[
n][i][
X] += gsurfs[
n]->x_trans;
1775 points[
n][i][
Y] += gsurfs[
n]->y_trans;
1776 points[
n][i][Z] += gsurfs[
n]->z_trans;
1781 for (n = 0; n < nsurfs; n++) {
1792 for (n = 0; n < nsurfs - 1; n++) {
1812 typbuff *
buff, *cobuff;
1813 int check_mask, check_color;
1814 int xmod, ymod, row, col, cnt, xcnt, ycnt;
1815 long offset, y1off, y2off;
1816 float x1, x2, y1, y2, tx, ty, tz, sz;
1817 float n[3], pt[4], xres, yres,
ymax, zexag;
1818 int col_src, curcolor;
1819 gsurf_att *coloratt;
1821 int zeros, dr1, dr2, dr3, dr4;
1822 int datarow1, datacol1, datarow2, datacol2;
1824 G_debug(3,
"gsd_norm_arrows");
1840 check_mask = surf->curmask ? 1 : 0;
1843 coloratt = &(surf->att[ATT_COLOR]);
1844 col_src = surf->att[ATT_COLOR].att_src;
1846 if (col_src != MAP_ATT) {
1847 if (col_src == CONST_ATT) {
1848 curcolor = (
int)surf->att[ATT_COLOR].constant;
1851 curcolor = surf->wire_color;
1862 xres = xmod * surf->xres;
1863 yres = ymod * surf->yres;
1864 ymax = (surf->rows - 1) * surf->yres;
1873 zexag = surf->z_exag;
1876 #ifdef DO_ARROW_SOLID
1884 for (row = 0; row < ycnt; row++) {
1891 datarow1 = row * ymod;
1892 datarow2 = (row + 1) * ymod;
1894 y1 = ymax - row * yres;
1895 y2 = ymax - (row + 1) * yres;
1896 y1off = row * ymod * surf->cols;
1897 y2off = (row + 1) * ymod * surf->cols;
1900 dr1 = dr2 = dr3 = dr4 = 1;
1903 if (
BM_get(surf->curmask, 0, datarow1)) {
1908 if (
BM_get(surf->curmask, 0, datarow2)) {
1916 FNORM(surf->norms[offset], n);
1926 #ifdef DO_ARROW_SOLID
1927 gsd_3darrow(pt, curcolor, xres * 2, xres / 2, n, sz);
1930 gsd_arrow(pt, 0x000000, xres * 2, n, sz, surf);
1937 FNORM(surf->norms[offset], n);
1947 #ifdef DO_ARROW_SOLID
1948 gsd_3darrow(pt, curcolor, xres * 2, xres / 2, n, sz);
1951 gsd_arrow(pt, 0x000000, xres * 2, n, sz, surf);
1958 for (col = 0; col < xcnt; col++) {
1959 datacol1 = col * xmod;
1960 datacol2 = (col + 1) * xmod;
1963 x2 = (col + 1) * xres;
1966 dr1 = dr2 = dr3 = dr4 = 1;
1969 if (
BM_get(surf->curmask, datacol1, datarow1)) {
1974 if (
BM_get(surf->curmask, datacol1, datarow2)) {
1979 if (
BM_get(surf->curmask, datacol2, datarow2)) {
1984 if (
BM_get(surf->curmask, datacol2, datarow1)) {
1989 if ((zeros > 1) && cnt) {
1997 offset = y1off + datacol2;
1998 FNORM(surf->norms[offset], n);
2008 #ifdef DO_ARROW_SOLID
2009 gsd_3darrow(pt, curcolor, xres * 2, xres / 2, n, sz);
2012 gsd_arrow(pt, 0x000000, xres * 2, n, sz, surf);
2020 offset = y2off + datacol2;
2021 FNORM(surf->norms[offset], n);
2031 #ifdef DO_ARROW_SOLID
2032 gsd_3darrow(pt, curcolor, xres * 2, xres / 2, n, sz);
2035 gsd_arrow(pt, 0x000000, xres * 2, n, sz, surf);
2064 int check_mask, check_color, check_transp;
2065 int check_material, check_emis, check_shin;
2066 typbuff *
buff, *cobuff, *trbuff, *embuff, *shbuff;
2068 int row, col, cnt, xcnt, ycnt;
2069 long y1off, y2off, y3off;
2073 float x1, x2, x3, y1, y2, y3, tx, ty, tz, ttr;
2074 float n[3], pt[4], xres, yres,
ymax, zexag;
2075 int em_src, sh_src, trans_src, col_src, curcolor;
2076 gsurf_att *ematt, *shatt, *tratt, *coloratt;
2080 GLdouble modelMatrix[16], projMatrix[16];
2083 int cnt1 = 0, cnt2 = 0;
2085 int datarow1, datacol1, datarow2, datacol2, datarow3, datacol3;
2087 float kem, ksh, pkem, pksh;
2088 unsigned int ktrans;
2109 check_mask = surf->curmask ? 1 : 0;
2117 xres = xmod * surf->xres;
2118 yres = ymod * surf->yres;
2119 ymax = (surf->rows - 1) * surf->yres;
2132 zexag = surf->z_exag;
2135 window[0] += (
int)(yres * 4 * zexag);
2136 window[1] -= (
int)(yres * 4 * zexag);
2137 window[2] -= (
int)(xres * 4 * zexag);
2138 window[3] += (
int)(xres * 4 * zexag);
2147 tratt = &(surf->att[ATT_TRANSP]);
2148 ktrans = (255 << 24);
2149 trans_src = surf->att[ATT_TRANSP].att_src;
2151 if (CONST_ATT == trans_src && surf->att[ATT_TRANSP].constant != 0.0) {
2152 ktrans = (255 - (
int)surf->att[ATT_TRANSP].constant) << 24;
2156 else if (MAP_ATT == trans_src) {
2158 check_transp = trbuff ? 1 : 0;
2164 ematt = &(surf->att[ATT_EMIT]);
2167 em_src = surf->att[ATT_EMIT].att_src;
2169 if (CONST_ATT == em_src) {
2170 kem = surf->att[ATT_EMIT].constant / 255.;
2172 else if (MAP_ATT == em_src) {
2174 check_emis = embuff ? 1 : 0;
2178 shatt = &(surf->att[ATT_SHINE]);
2181 sh_src = surf->att[ATT_SHINE].att_src;
2183 if (CONST_ATT == sh_src) {
2184 ksh = surf->att[ATT_SHINE].constant / 255.;
2187 else if (MAP_ATT == sh_src) {
2189 check_shin = shbuff ? 1 : 0;
2195 coloratt = &(surf->att[ATT_COLOR]);
2196 col_src = surf->att[ATT_COLOR].att_src;
2198 if (col_src != MAP_ATT) {
2199 if (col_src == CONST_ATT) {
2200 curcolor = (
int)surf->att[ATT_COLOR].constant;
2203 curcolor = surf->wire_color;
2209 check_material = (check_shin || check_emis || (kem && check_color));
2215 for (row = start_val; row < ycnt; row += step_val) {
2236 datarow1 = row * ymod;
2237 datarow2 = (row - (step_val / 2)) * ymod;
2238 datarow3 = (row + (step_val / 2)) * ymod;
2241 y1 = ymax - row * yres;
2242 y2 = ymax - (row - (step_val / 2)) * yres;
2243 y3 = ymax - (row + (step_val / 2)) * yres;
2245 y1off = row * ymod * surf->cols;
2246 y2off = (row - (step_val / 2)) * ymod * surf->cols;
2247 y3off = (row + (step_val / 2)) * ymod * surf->cols;
2250 for (col = start_val; col < xcnt; col += step_val) {
2251 datacol1 = col * xmod;
2252 datacol2 = (col - (step_val / 2)) * xmod;
2253 datacol3 = (col + (step_val / 2)) * xmod;
2256 x2 = (col - (step_val / 2)) * xres;
2257 x3 = (col + (step_val / 2)) * xres;
2273 offset2[0] = y1off + datacol1;
2283 (pt, window, viewport, modelMatrix, projMatrix))
2288 offset2[1] = y2off + datacol2;
2289 offset2[2] = y2off + datacol1;
2290 offset2[3] = y2off + datacol3;
2291 offset2[4] = y1off + datacol3;
2292 offset2[5] = y3off + datacol3;
2293 offset2[6] = y3off + datacol1;
2294 offset2[7] = y3off + datacol2;
2295 offset2[8] = y1off + datacol2;
2296 offset2[9] = y2off + datacol2;
2320 for (ii = 0; ii < 10; ii++) {
2330 FNORM(surf->norms[offset2[ii]], n);
2333 curcolor =
gs_mapcolor(cobuff, coloratt, offset2[ii]);
2337 ktrans = (char)
SCALE_ATT(tratt, ttr, 0, 255);
2338 ktrans = (char)(255 - ktrans) << 24;
2341 if (check_material) {
2352 if (pksh != ksh || pkem != kem || (kem && check_color)) {
2356 ksh, kem, curcolor);
void gsd_zwritemask(unsigned long n)
Write out z-mask.
int BM_get(struct BM *map, int x, int y)
Gets 'val' from the bitmap.
void G_free(void *buf)
Free allocated memory.
void gsd_bgntmesh(void)
ADD.
int gs_point_is_masked(geosurf *gs, float *pt)
Check if point is masked.
void gsd_do_scale(int doexag)
Set current scale.
#define SET_SCOLOR(sf)
MACROS for use in gsd_ortho_wall ONLY !!!
void gsd_bgnpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
void gsd_set_material(int set_shin, int set_emis, float sh, float em, int emcolor)
Set material.
int gsd_surf_const(geosurf *surf, float k)
Using tmesh - not confident with qstrips portability.
#define XY2OFF(gs, px, py)
void GS_v3sub(float *v1, float *v2)
Subtract vectors.
int gs_calc_normals(geosurf *gs)
Calculate normals.
void gsd_colormode(int cm)
Set color mode.
int GS_check_cancel(void)
Check for cancel.
void GS_v3cross(float *v1, float *v2, float *v3)
Get the cross product v3 = v1 cross v2.
void gsd_endtmesh(void)
ADD.
int gsd_surf_map(geosurf *surf)
Draw surface using triangle fan instead of strip.
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
void gsd_litvert_func(float *norm, unsigned long col, float *pt)
Set the current normal vector & specify vertex.
int gsd_wall(float *bgn, float *end, float *norm)
ADD.
int gsd_surf_map_old(geosurf *surf)
ADD.
int gsd_ortho_wall(int np, int ns, geosurf **gsurfs, Point3 **points, float *norm)
ADD.
geosurf * gsdiff_get_SDref(void)
ADD.
void gsd_bgntfan(void)
ADD.
int gsd_norm_arrows(geosurf *surf)
ADD.
void gsd_pushmatrix(void)
Push the current matrix stack.
int gsd_surf(geosurf *surf)
ADD.
typbuff * gs_get_att_typbuff(geosurf *gs, int desc, int to_write)
Get attribute data buffer.
void gsd_endtfan(void)
ADD.
Point3 * gsdrape_get_allsegments(geosurf *gs, float *bgn, float *end, int *num)
Get all segments.
int gsd_checkpoint(float pt[4], int window[4], int viewport[4], double modelMatrix[16], double projMatrix[16])
ADD.
void gsd_getwindow(int *window, int *viewport, double *modelMatrix, double *projMatrix)
Get viewport.
int gs_getall_surfaces(geosurf **gsurfs)
Get array of geosurf structs.
void gsd_blend(int yesno)
Specify pixel arithmetic.
int gsd_surf_func(geosurf *gs, int(*user_func)())
Define user function.
void gsd_setfc(int mode)
ADD.
void GS_v3eq(float *v1, float *v2)
Copy vector values.
void gsd_endpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
void show_colormode(void)
Print color mode to stderr.
int gsd_triangulated_wall(int npts1, int npts2, geosurf *surf1, geosurf *surf2, Point3 *points1, Point3 *points2, float *norm)
ADD.
int G_debug(int level, const char *msg,...)
Print debugging message.
int gs_get_att_src(geosurf *gs, int desc)
Get attribute source.
float gsdiff_do_SD(float val, int offset)
ADD.
void gsd_popmatrix(void)
Pop the current matrix stack.
#define SCALE_ATT(att, val, low, high)
int gs_mapcolor(typbuff *cobuff, gsurf_att *coloratt, int offset)
Call this one when you already know att_src is MAP_ATT.
void gsd_3darrow(float *center, unsigned long colr, float siz1, float siz2, float *dir, float sz)
Draw 3d north arrow.
float GS_global_exag(void)
Get global z-exag value.
void GS_set_draw(int where)
Sets which buffer to draw to.
int gs_update_curmask(geosurf *surf)
Update current maps.
int segs_intersect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float *x, float *y)
Line intersect.
int gsd_arrow(float *center, unsigned long colr, float siz, float *dir, float sz, geosurf *onsurf)
ADD.
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.
void GS_v3mag(float *v1, float *mag)
Magnitude of vector.
#define GET_MAPATT(buff, offset, att)