目录

  • 一、结果图
  • 二、头文件
  • 三、cpp文件

说明:地形高度,也就是高程是通过arcview获取

一、结果图

二、头文件

#ifndef _HEADER_H_
#define _HEADER_H_#include <GL\glut.h>#define ncols         88
#define nrows         49
#define CELLSIZE  1000
#define xllcorner     -291908.345839
#define yllcorner     3154613.722214int dem[nrows][ncols] = {{4300, 4717, 4823, 4879, 4981, 4608, 4165, 3910, 4094, 4253, 4362, 4279, 4506, 4262, 4205, 4301, 3900, 3331, 3605, 3637, 3494, 3126, 2825, 2381, 1660, 1986, 2328, 2274, 2430, 2359, 2626, 3014, 3232, 3138, 3396, 3662, 4128, 4129, 4143, 4017, 4459, 4631, 4432, 4318, 3888, 3755, 3343, 2921, 2761, 2865, 2569, 2923, 3219, 3283, 2818, 2564, 2731, 3077, 3362, 3360, 3164, 2779, 2716, 2392, 2569, 2686, 2207, 2204, 1823, 2255, 2683, 2808, 2650, 2380, 2313, 2100, 2249, 1965, 1528, 1453, 1405, 1082, 994, 1139, 859, 850, 863, 1010},
{4186, 4351, 4637, 4963, 4851, 4356, 4072, 4172, 4386, 4334, 4466, 4445, 4724, 4691, 4455, 4114, 3735, 3741, 3967, 3581, 3021, 2546, 2203, 2079, 1616, 1764, 1831, 1989, 2203, 2387, 2950, 3315, 3445, 3316, 3654, 3930, 4251, 4378, 4335, 4266, 4241, 4844, 4769, 4512, 4355, 4060, 3525, 3105, 2779, 2581, 2493, 3042, 3236, 3126, 2782, 2523, 2695, 2956, 3169, 3457, 3088, 2478, 2307, 2169, 2250, 2288, 1981, 1761, 1886, 2338, 2436, 2357, 2285, 2166, 2415, 2587, 2426, 1876, 1691, 1503, 1316, 1151, 1135, 1065, 917, 821, 872, 1143},
{3786, 4145, 4742, 4730, 4823, 4493, 4338, 4302, 4566, 4536, 4558, 4726, 4872, 4740, 4247, 4079, 4213, 4120, 3812, 3246, 2691, 2488, 2478, 2142, 1652, 1575, 1937, 2136, 2081, 2376, 2694, 3020, 3515, 3548, 3832, 4110, 4532, 4530, 4510, 4633, 4355, 4667, 4865, 4808, 4507, 4210, 3861, 3469, 3008, 2689, 2451, 2732, 2734, 2892, 2854, 2611, 3012, 3113, 3374, 3366, 2954, 2550, 2177, 1959, 1969, 2089, 1722, 1793, 2165, 2100, 2119, 1935, 2057, 2278, 2407, 2543, 2351, 2064, 1887, 1659, 1294, 1274, 1263, 1127, 963, 888, 893, 1139},
{4026, 4363, 4566, 4817, 4852, 4673, 4663, 4620, 4535, 4543, 4542, 4759, 4563, 4417, 4356, 4486, 4346, 3923, 3418, 3091, 3146, 3062, 3071, 2648, 2064, 1665, 1605, 2158, 2391, 2434, 2562, 2888, 3154, 3630, 3839, 4191, 4505, 4719, 4755, 4652, 4403, 4438, 4569, 4740, 4357, 4024, 3891, 3540, 3047, 2922, 2496, 2383, 2673, 2963, 2935, 2450, 2730, 3023, 3385, 3117, 2727, 2440, 2292, 2283, 1924, 1761, 1740, 1591, 1801, 1737, 1877, 2150, 2487, 2528, 2746, 2651, 2421, 2116, 1727, 1508, 1422, 1427, 1252, 1033, 1001, 1041, 818, 969},
{3824, 4148, 4492, 4595, 4976, 4884, 5007, 4637, 4368, 4305, 4213, 4239, 4175, 4107, 4317, 4460, 4372, 3937, 3605, 3630, 3563, 3406, 2929, 2435, 2231, 1805, 1573, 2008, 2476, 2780, 2883, 3321, 3330, 3444, 3821, 4130, 4421, 4747, 4996, 4647, 4549, 4196, 4157, 4383, 4033, 3461, 3319, 3030, 2873, 2768, 2380, 2286, 2520, 2665, 2402, 2452, 2896, 3254, 3483, 3048, 2690, 2675, 2653, 2547, 2026, 2089, 1882, 1641, 1486, 1855, 2173, 2331, 2208, 2179, 2635, 2788, 2514, 2264, 2058, 1778, 1502, 1358, 1295, 1229, 1222, 1053, 815, 1067},
{3593, 3847, 4204, 4520, 4819, 5035, 4933, 4625, 4654, 4411, 3808, 3686, 3626, 3651, 3941, 4023, 4320, 4163, 4022, 3568, 3020, 2891, 2539, 2043, 1647, 1643, 1998, 2146, 2272, 2520, 2672, 3096, 3648, 3809, 3753, 4131, 4434, 4675, 4664, 4583, 4437, 3914, 3821, 4189, 3711, 3211, 2882, 2682, 2753, 2876, 2619, 2372, 2318, 2271, 2418, 2723, 3082, 3439, 3584, 3402, 3180, 3077, 3002, 2642, 2435, 2265, 2120, 2041, 1559, 1547, 1693, 1822, 2005, 2139, 2235, 2607, 2488, 2108, 1839, 1632, 1333, 1272, 1262, 1332, 1087, 1092, 1171, 919},
{3589, 3965, 4206, 4457, 4737, 5033, 5020, 4685, 4451, 4062, 4023, 3849, 3803, 3528, 3376, 3783, 4238, 4491, 4028, 3300, 2657, 2306, 2015, 1735, 1581, 1967, 2261, 2445, 2605, 2619, 2640, 3090, 3649, 4060, 3970, 4183, 4440, 4647, 4497, 4114, 4375, 3751, 3590, 3868, 3551, 3077, 2624, 2478, 2619, 2816, 2817, 2487, 2261, 2604, 2688, 2865, 3257, 3430, 3222, 2937, 2928, 3174, 3260, 3002, 2693, 2474, 2587, 2443, 1926, 1384, 1661, 1948, 1847, 1772, 2224, 2629, 2264, 1964, 1657, 1383, 1311, 1261, 1173, 1285, 1304, 1406, 1333, 1304},
{3461, 3825, 3909, 4148, 4599, 4844, 5014, 4666, 4337, 4491, 4406, 4207, 4188, 3757, 3511, 3332, 3703, 4105, 3940, 3468, 3172, 2782, 2240, 1678, 1585, 1757, 1829, 2125, 2489, 2741, 2780, 3295, 3599, 3863, 4171, 4140, 4463, 4594, 4127, 3775, 3956, 3814, 3270, 3363, 3198, 2842, 2428, 2374, 2582, 2489, 2608, 2195, 2223, 2582, 2892, 3116, 3397, 3029, 2648, 2478, 2755, 3088, 3205, 2850, 2501, 2256, 2401, 2198, 1898, 1336, 1641, 1691, 1479, 1906, 2309, 2466, 2179, 1986, 1655, 1508, 1387, 1287, 1120, 1239, 1397, 1351, 1311, 1332},
{3471, 3619, 3700, 4043, 4393, 4573, 4727, 4672, 4741, 4507, 4453, 4431, 4185, 4125, 3965, 3476, 3169, 3519, 3736, 3897, 3432, 2827, 2110, 1557, 1725, 2306, 2204, 1925, 2059, 2273, 2510, 2913, 3116, 3502, 4131, 4407, 4468, 4476, 3896, 3584, 3535, 3767, 3211, 3025, 3077, 2577, 2354, 2224, 2452, 2153, 2108, 2108, 2413, 2679, 2953, 3261, 3458, 3037, 2613, 2264, 2642, 2924, 3218, 2730, 2147, 1960, 2247, 1845, 1517, 1524, 1301, 1301, 1616, 1711, 1813, 2261, 2082, 1832, 1582, 1441, 1432, 1194, 1082, 1403, 1305, 1293, 1197, 1265},
{3165, 3380, 3795, 4155, 4405, 4659, 4559, 4427, 4147, 4000, 4322, 4444, 4504, 4535, 4192, 3674, 3035, 3006, 3485, 3764, 3255, 2712, 2144, 1546, 1907, 2506, 2592, 2060, 2178, 2482, 2581, 2769, 3241, 3727, 4041, 4480, 4314, 4165, 3699, 3246, 3296, 3659, 3115, 2673, 2770, 2737, 2566, 2357, 2094, 2006, 2228, 2357, 2470, 2647, 2942, 3213, 3431, 3019, 2575, 2123, 2435, 2669, 2877, 2741, 2215, 1785, 1751, 1537, 1713, 1913, 1435, 1348, 1260, 1301, 1735, 2185, 2070, 1697, 1341, 1228, 1367, 1165, 1123, 1404, 1243, 1183, 1018, 1096},
{3075, 3398, 3790, 4348, 4562, 4621, 4304, 4297, 3756, 3920, 4202, 4225, 4734, 4585, 4153, 3599, 3268, 2793, 2869, 3360, 3125, 2381, 1827, 1541, 2005, 2742, 2818, 2346, 2230, 2436, 2752, 3148, 3530, 3865, 4391, 4496, 3956, 3595, 3460, 2901, 3257, 3645, 3210, 2759, 2357, 2658, 2771, 2279, 1932, 2071, 2450, 2715, 2814, 2922, 3191, 3281, 3233, 2872, 2422, 2124, 2092, 2182, 2481, 2601, 2022, 1898, 1703, 1744, 2050, 1788, 1544, 1650, 1185, 1095, 1412, 1787, 1982, 1716, 1540, 1275, 1167, 1049, 1225, 1362, 1133, 954, 916, 933},
{3121, 3384, 3796, 4137, 4416, 4439, 4122, 4241, 3686, 3691, 3864, 4300, 4486, 4566, 4202, 3879, 3706, 3014, 2554, 2673, 2904, 2287, 1606, 1738, 1964, 2628, 2850, 2545, 2402, 2846, 3009, 3143, 3642, 4247, 4538, 4274, 3688, 3238, 3211, 2740, 3037, 3434, 3203, 2610, 2260, 2411, 2644, 2088, 1935, 2283, 2517, 2934, 3228, 3257, 3144, 2760, 2783, 2569, 2696, 2310, 1991, 1914, 2427, 2640, 2475, 2047, 1830, 2099, 2058, 1652, 1837, 1652, 1448, 1136, 1114, 1619, 1721, 1580, 1435, 1238, 1036, 1039, 1256, 1221, 942, 874, 895, 900},
{2861, 3337, 3618, 3812, 4202, 4273, 3912, 4106, 3703, 3222, 3453, 3732, 4100, 4282, 4437, 4162, 3654, 3262, 2859, 2291, 2259, 2095, 1600, 1665, 2175, 2472, 2933, 2673, 2556, 2946, 3445, 3723, 3859, 4327, 4584, 4079, 3597, 3112, 3038, 2678, 2826, 2995, 3078, 2675, 2226, 2318, 2416, 2037, 1987, 2412, 2703, 3018, 3152, 2841, 2954, 2496, 2277, 2297, 2790, 2611, 2147, 1729, 2195, 2311, 2716, 2515, 2112, 2215, 2065, 1813, 2008, 1977, 1582, 1295, 1117, 1199, 1360, 1316, 1300, 1164, 1133, 1184, 960, 981, 833, 802, 861, 897},
{2855, 3244, 3259, 3542, 3881, 3963, 3784, 3844, 3359, 3012, 2983, 3189, 3586, 3717, 4157, 4184, 3883, 3630, 3192, 2558, 2109, 1906, 1666, 1580, 2228, 2438, 2710, 2819, 2788, 3261, 3784, 4170, 4387, 4492, 4422, 4144, 3828, 3361, 2656, 2443, 2462, 2583, 2627, 2771, 2259, 2145, 2227, 1808, 2090, 2336, 2553, 2927, 2909, 2508, 2839, 2560, 2076, 2293, 2652, 2829, 2295, 1691, 1788, 2351, 2461, 2283, 2378, 2293, 2357, 2281, 2413, 2304, 1931, 1728, 1214, 994, 1075, 1034, 1172, 1206, 1298, 1203, 1034, 857, 800, 800, 837, 895},
{2732, 2909, 3131, 3393, 3912, 3913, 3475, 3718, 3126, 2728, 2488, 3029, 3000, 3554, 3800, 3947, 4098, 3911, 3306, 2916, 2678, 2356, 1699, 1473, 1944, 2552, 3004, 2910, 3093, 3466, 3751, 3959, 4175, 4439, 4154, 3617, 3392, 3059, 2587, 2353, 2069, 2210, 2645, 2648, 2216, 2046, 2192, 1903, 2195, 2384, 2749, 3144, 2779, 2288, 2402, 2560, 2083, 2036, 2610, 2724, 2155, 1694, 1688, 2197, 2077, 1886, 2050, 1944, 2347, 2490, 2433, 2315, 2119, 1779, 1326, 1017, 906, 1078, 1263, 1352, 1347, 1025, 886, 836, 800, 804, 879, 899},
{2865, 2728, 3073, 3473, 4003, 3916, 3273, 3528, 3347, 2783, 2196, 2418, 2813, 3538, 3322, 3322, 3707, 3865, 3593, 3317, 2994, 2352, 1656, 1530, 2006, 2343, 2916, 3075, 3310, 3792, 4128, 4198, 4368, 4476, 4442, 3852, 3387, 2963, 2891, 2714, 2123, 2063, 2573, 2426, 1938, 2242, 2047, 1858, 2316, 2673, 3071, 2990, 2654, 2420, 2165, 2358, 1947, 1846, 2160, 2485, 2382, 1876, 1501, 1784, 1826, 1671, 1770, 1963, 2032, 2220, 2161, 2170, 1980, 1699, 1462, 1148, 906, 1003, 1266, 1484, 1219, 1014, 838, 800, 800, 803, 879, 886},
{3096, 2689, 3043, 3455, 3900, 3787, 3234, 3048, 2917, 2330, 2564, 2180, 2634, 3167, 2871, 2929, 3152, 3418, 3065, 3212, 2928, 2185, 1573, 1656, 2236, 2659, 3096, 3249, 3422, 3959, 4391, 4314, 4577, 4620, 4693, 4370, 3845, 3510, 3103, 2509, 2191, 1923, 2225, 2444, 1873, 2064, 1761, 2140, 2357, 2820, 3095, 2954, 2480, 2244, 2027, 1884, 1919, 1613, 1949, 1958, 2143, 2095, 1556, 1425, 1571, 1557, 1923, 1735, 1596, 1934, 1788, 1775, 1650, 1511, 1590, 1297, 960, 999, 1409, 1349, 1084, 895, 814, 800, 803, 820, 856, 827},
{3086, 2686, 2813, 3175, 3736, 3543, 3030, 2578, 2376, 2432, 2959, 2455, 2177, 2583, 2388, 2406, 2997, 3183, 2503, 2648, 2571, 1952, 1533, 1712, 2198, 2580, 3016, 3422, 3662, 3988, 4456, 4500, 4639, 4326, 4425, 4357, 3901, 3514, 2804, 2569, 2357, 1984, 1833, 1934, 1871, 1711, 1943, 2432, 2589, 2536, 2691, 2889, 2608, 2481, 2365, 1925, 1772, 1732, 1578, 1634, 1824, 1774, 1419, 1286, 1447, 1534, 1825, 1526, 1518, 1630, 1665, 1507, 1393, 1315, 1385, 1264, 908, 1097, 1414, 1196, 961, 886, 851, 829, 838, 870, 892, 828},
{2992, 2733, 2779, 3391, 3566, 3475, 2941, 2425, 2657, 3133, 3209, 2706, 2336, 2048, 2017, 1931, 2357, 2551, 2219, 1812, 1884, 1762, 1448, 1940, 2465, 2764, 3154, 3442, 3528, 3773, 4311, 4606, 4390, 3965, 3950, 4298, 3835, 3235, 2701, 2361, 2188, 2293, 2184, 1888, 1882, 1586, 1822, 2208, 2202, 2166, 2703, 2963, 2955, 2527, 2139, 1987, 2134, 1866, 1767, 1580, 1487, 1549, 1351, 1235, 1474, 1807, 1832, 1469, 1250, 1289, 1343, 1131, 956, 924, 1025, 1101, 841, 1236, 1190, 1038, 908, 899, 893, 873, 879, 887, 852, 835},
{3306, 2959, 2664, 3081, 3101, 2874, 2578, 2565, 3163, 3655, 3553, 3437, 2663, 2729, 2628, 2126, 1767, 1873, 1748, 1795, 1702, 1687, 1526, 1757, 2213, 2689, 3283, 3456, 2983, 3371, 3761, 4295, 3987, 3531, 3519, 3779, 3564, 3178, 2722, 2684, 2656, 2719, 2462, 2310, 2142, 1731, 1585, 1898, 1929, 2296, 2501, 2853, 3007, 2466, 2286, 2294, 2273, 2242, 2132, 1757, 1482, 1459, 1549, 1417, 1157, 1531, 1623, 1253, 981, 987, 989, 945, 1229, 1252, 930, 839, 829, 1166, 973, 915, 900, 898, 888, 849, 848, 837, 803, 821},
{3355, 2892, 2570, 2592, 2616, 2656, 2623, 3041, 3460, 3932, 3962, 3373, 2919, 3268, 2854, 2208, 2208, 2063, 2156, 2429, 2089, 1775, 1517, 1597, 2199, 2841, 3360, 3190, 2724, 2954, 3431, 3940, 4044, 3421, 3198, 3466, 3117, 3074, 2635, 2434, 2675, 2986, 2822, 2746, 2414, 1884, 1507, 1702, 2160, 2190, 2354, 2544, 2747, 2903, 2562, 2644, 2630, 2635, 2411, 2007, 1761, 1917, 1832, 1687, 1369, 1206, 1167, 978, 1076, 1259, 1114, 1324, 1554, 1413, 1114, 962, 808, 918, 824, 860, 854, 873, 904, 889, 847, 829, 866, 874},
{3170, 2867, 2608, 2923, 3208, 3482, 3064, 3275, 3946, 4262, 3917, 3503, 3694, 3170, 2663, 2607, 2638, 2492, 2901, 2699, 1932, 1455, 1627, 1956, 2424, 2935, 3220, 2786, 2531, 2976, 3286, 3470, 3704, 3246, 2873, 2996, 2735, 3043, 2745, 2301, 2419, 2915, 3197, 2717, 2464, 2017, 1457, 1671, 1865, 2040, 2203, 2290, 2762, 2718, 2635, 2397, 2323, 2500, 2221, 2107, 1930, 1839, 1569, 1434, 1238, 1005, 962, 1254, 1600, 1647, 1554, 1649, 1571, 1354, 1209, 1073, 1040, 878, 800, 800, 820, 879, 914, 900, 922, 905, 886, 821},
{3261, 2884, 2680, 3132, 3601, 4054, 3619, 3502, 4302, 4641, 4183, 4093, 3858, 3204, 3047, 3083, 2877, 2974, 2941, 2224, 1755, 1724, 1444, 1574, 2062, 2749, 2725, 2504, 2473, 2658, 2805, 3226, 3711, 3366, 2937, 2557, 2511, 2825, 2626, 2169, 2387, 2804, 2954, 2540, 2127, 1652, 1702, 1411, 1767, 1950, 1998, 2566, 2909, 2425, 2173, 2082, 2028, 2381, 1904, 1840, 1705, 1439, 1315, 1080, 1036, 1103, 1156, 1509, 1834, 1787, 1653, 1566, 1480, 1222, 1137, 1047, 1166, 873, 800, 800, 826, 894, 865, 935, 946, 850, 893, 914},
{3111, 2791, 2719, 3333, 3605, 4108, 4289, 4047, 4545, 4994, 4644, 4467, 3883, 3586, 3499, 3569, 3426, 3345, 2707, 2056, 2302, 2144, 1636, 1415, 1958, 2584, 2395, 2336, 2360, 2661, 3121, 3509, 3678, 3448, 3271, 2729, 2355, 2437, 2567, 2336, 2146, 2579, 2384, 2172, 1779, 1813, 2019, 1505, 1444, 1642, 2059, 2601, 2903, 2677, 2254, 1799, 1862, 2145, 1855, 1517, 1353, 1171, 1055, 1103, 1291, 1439, 1442, 1732, 1702, 1461, 1355, 1488, 1544, 1449, 1218, 1046, 992, 852, 835, 816, 911, 891, 857, 837, 837, 804, 845, 908},
{3271, 2820, 2842, 3410, 3745, 4056, 4447, 4599, 4863, 5190, 5032, 4349, 3901, 4161, 4119, 4054, 3822, 3158, 2408, 2349, 2558, 2151, 1721, 1433, 1922, 2257, 2180, 2292, 2459, 2995, 3537, 3751, 3634, 3149, 2838, 2837, 2349, 2125, 2247, 2235, 1935, 1980, 1832, 1690, 1773, 2223, 2348, 2050, 1466, 1629, 1946, 2429, 2534, 2339, 2117, 1707, 1597, 1957, 1872, 1521, 1063, 1174, 1221, 1298, 1603, 1651, 1654, 1658, 1458, 1242, 1274, 1320, 1346, 1388, 1100, 950, 902, 907, 930, 905, 1045, 855, 802, 807, 809, 800, 816, 926},
{3125, 2777, 2894, 3419, 3879, 4073, 4449, 4712, 4910, 5319, 5153, 4620, 4424, 4645, 4621, 4212, 3587, 2747, 2594, 2828, 2444, 2265, 1914, 1467, 1569, 1796, 1974, 2163, 2387, 2832, 3348, 3771, 3752, 3391, 2873, 2551, 2441, 2195, 2023, 2012, 2217, 2365, 2141, 2121, 2254, 2489, 2740, 2132, 1540, 1446, 1959, 2379, 2316, 1948, 1947, 1607, 1593, 1856, 1520, 1071, 1178, 1492, 1721, 1543, 1738, 1632, 1490, 1457, 1498, 1186, 1090, 1044, 1044, 1071, 989, 900, 900, 949, 1086, 934, 935, 851, 733, 739, 727, 730, 751, 821},
{3049, 2805, 3009, 3443, 3911, 4163, 4309, 4613, 5000, 5373, 5534, 5234, 4947, 4665, 4220, 3714, 3072, 2828, 3074, 2935, 2635, 2033, 1837, 1474, 1425, 1836, 2263, 2561, 2739, 3002, 3367, 3644, 3670, 3149, 2877, 2674, 2518, 2507, 2232, 2359, 2585, 2649, 2443, 2617, 2665, 2712, 2754, 2307, 1672, 1320, 1811, 2022, 1874, 1712, 1518, 1561, 1326, 1349, 1117, 1126, 1269, 1504, 1731, 1815, 1692, 1445, 1269, 1265, 1265, 1100, 1282, 1348, 1206, 1010, 971, 992, 970, 957, 1028, 942, 937, 774, 733, 703, 700, 700, 700, 700},
{2920, 2814, 3034, 3411, 3829, 4116, 4396, 4480, 4683, 5086, 5519, 4932, 4458, 4160, 3754, 3263, 3096, 3359, 3338, 3057, 2517, 2369, 2047, 1592, 1590, 1463, 1933, 2371, 2740, 3116, 3651, 3865, 3796, 3231, 2950, 2939, 2778, 2876, 2531, 2665, 2894, 2891, 2994, 2933, 2915, 2620, 2365, 2142, 1610, 1290, 1338, 1424, 1379, 1247, 1138, 1152, 1139, 1187, 1235, 1212, 1443, 1524, 1885, 2087, 1743, 1567, 1608, 1387, 1150, 1237, 1393, 1527, 1293, 1123, 1096, 1229, 1158, 1046, 929, 1065, 1152, 963, 836, 764, 715, 724, 749, 732},
{3118, 2921, 3129, 3380, 3641, 3905, 4113, 4549, 4881, 5132, 5441, 4794, 4034, 3611, 3324, 3363, 3705, 3721, 3536, 2976, 2833, 2603, 2076, 1777, 1979, 1521, 1656, 1952, 2359, 2945, 3340, 3602, 3408, 3148, 3249, 3318, 3059, 3052, 2768, 2743, 2670, 2621, 2834, 2755, 2512, 2479, 2047, 1918, 1364, 1614, 1430, 1287, 1157, 1279, 1551, 1642, 1576, 1447, 1196, 1375, 1696, 1705, 2085, 2085, 1966, 1837, 1586, 1227, 1327, 1583, 1594, 1348, 1168, 1118, 1095, 1143, 1042, 965, 1045, 1312, 1304, 1057, 904, 854, 838, 817, 784, 710},
{3485, 2995, 3180, 3547, 3905, 4095, 4068, 4310, 4640, 4922, 5321, 4831, 3948, 3619, 3751, 4039, 4349, 4055, 3522, 3330, 3117, 2617, 2127, 2194, 2216, 1603, 1511, 2015, 2317, 2738, 3240, 3442, 3027, 2884, 2986, 3138, 2752, 2825, 2596, 2367, 2331, 2210, 2675, 2534, 2134, 2276, 1882, 1643, 1295, 1651, 1662, 1426, 1398, 1561, 1720, 1567, 1410, 1235, 1404, 1685, 1977, 2044, 2025, 1783, 1664, 1722, 1565, 1213, 1424, 1764, 1552, 1292, 1139, 1220, 1038, 1078, 1086, 1104, 1187, 1488, 1390, 1123, 944, 828, 860, 824, 725, 703},
{3642, 3123, 3094, 3452, 3766, 4067, 4225, 4629, 5008, 5313, 5329, 4739, 4370, 4490, 4574, 4549, 4752, 4365, 4010, 3602, 3138, 2623, 2325, 2381, 2246, 1641, 1427, 1757, 2131, 2658, 3094, 2917, 2656, 2773, 2812, 2780, 2665, 2463, 2577, 2148, 2084, 2082, 2336, 2386, 1860, 2019, 1760, 1446, 1316, 1745, 1774, 1612, 1840, 1900, 1605, 1351, 1496, 1402, 1396, 1698, 2048, 2228, 2075, 1792, 1659, 1437, 1359, 1290, 1523, 1821, 1645, 1324, 1332, 1223, 1120, 1270, 1215, 1283, 1369, 1450, 1454, 1087, 891, 744, 737, 718, 721, 758},
{3441, 3172, 3149, 3520, 3927, 4329, 4496, 4757, 5066, 5557, 5142, 5174, 5252, 5131, 4445, 3924, 4265, 4275, 3891, 3398, 3097, 2892, 2557, 2086, 1897, 1562, 1449, 1858, 2135, 2583, 2746, 2471, 2408, 2815, 2906, 2607, 2385, 2142, 2262, 1926, 1794, 1765, 2062, 2320, 1913, 1641, 1524, 1367, 1649, 1908, 1934, 2030, 2065, 1725, 1430, 1452, 1818, 1401, 1576, 1831, 1991, 2138, 2107, 1971, 1851, 1540, 1481, 1537, 1777, 1911, 1686, 1396, 1274, 1174, 1313, 1477, 1507, 1513, 1421, 1280, 1232, 993, 854, 863, 768, 714, 741, 926},
{3744, 3367, 3146, 3460, 3875, 4271, 4704, 5052, 5405, 5359, 5540, 5428, 4889, 4482, 4282, 3606, 3720, 3878, 3652, 3522, 3208, 2898, 2399, 2074, 1812, 1512, 1436, 1507, 1757, 2041, 2138, 2077, 2230, 2549, 3008, 2751, 2444, 2224, 1947, 1846, 1971, 1708, 1782, 1994, 1599, 1439, 1461, 1524, 1844, 2129, 2227, 2234, 1826, 1538, 1680, 1687, 1728, 1384, 1440, 1820, 2114, 2217, 2089, 1972, 1646, 1473, 1660, 1906, 2068, 1723, 1437, 1250, 1246, 1316, 1486, 1680, 1778, 1723, 1543, 1383, 1245, 1069, 951, 843, 751, 733, 760, 843},
{3777, 3377, 3228, 3589, 3899, 4300, 4647, 4993, 4999, 5027, 5529, 4989, 4346, 3877, 3694, 3478, 3267, 3433, 3304, 3146, 3134, 2735, 2770, 2565, 2289, 1823, 1565, 1449, 1780, 1913, 1921, 2200, 2547, 2796, 3005, 2846, 2707, 2374, 2215, 2042, 2074, 1609, 1635, 1614, 1568, 1661, 1657, 1472, 1786, 1984, 2234, 1984, 1677, 1686, 1994, 1822, 1484, 1430, 1699, 1697, 1958, 2139, 2054, 1852, 1540, 1720, 2002, 2119, 1889, 1528, 1260, 1291, 1448, 1502, 1689, 1856, 2000, 1882, 1729, 1496, 1396, 1226, 982, 877, 845, 707, 778, 890},
{3739, 3390, 3266, 3483, 3775, 4251, 4577, 4720, 4738, 4954, 5259, 5093, 4394, 3878, 3469, 3306, 2945, 3028, 3114, 2836, 3021, 2574, 2393, 2737, 2585, 2204, 1879, 1446, 1695, 2251, 2204, 2505, 2906, 3090, 3143, 3015, 2702, 2459, 2140, 2156, 1978, 1725, 1466, 1596, 1850, 2051, 1832, 1494, 1872, 2288, 2340, 1948, 1762, 1743, 2030, 1737, 1517, 1724, 1828, 1911, 1882, 2072, 1940, 1759, 1630, 1943, 2167, 1870, 1591, 1384, 1317, 1351, 1535, 1752, 1891, 2028, 2149, 1851, 1474, 1218, 1240, 1138, 937, 937, 814, 737, 932, 1161},
{3974, 3452, 3388, 3621, 3749, 4162, 4368, 4338, 4582, 4740, 5150, 5049, 4759, 4439, 4059, 3633, 2964, 2712, 2718, 2545, 2736, 2610, 2117, 2526, 2610, 2194, 1859, 1440, 1797, 2154, 2635, 2454, 2689, 2980, 3062, 2806, 2574, 2291, 2038, 2306, 2106, 1764, 1529, 1713, 2146, 2284, 1782, 1523, 1932, 2248, 2312, 2139, 1839, 2030, 2071, 1672, 1637, 1941, 1795, 2069, 2038, 1982, 1926, 1908, 1949, 2115, 2155, 2055, 1691, 1528, 1425, 1553, 1707, 1858, 1793, 1744, 1842, 1598, 1540, 1173, 993, 931, 785, 758, 706, 831, 1097, 1422},
{4046, 3429, 3590, 3783, 3814, 4033, 4123, 4295, 4529, 4721, 4802, 4902, 4538, 4000, 3601, 3226, 2895, 2588, 2477, 2292, 2132, 2084, 1885, 2001, 2177, 2166, 1950, 1444, 1703, 2240, 2880, 2827, 3080, 2984, 2686, 2479, 2408, 2150, 2206, 2400, 2179, 1768, 1531, 1770, 2153, 2326, 2083, 1660, 1648, 1838, 2196, 2292, 2120, 2094, 1847, 1605, 1628, 1923, 2034, 2052, 1930, 1802, 2029, 2109, 2020, 1849, 1843, 1815, 1745, 1764, 1556, 1746, 1892, 1686, 1517, 1570, 1607, 1255, 1113, 923, 849, 841, 875, 896, 812, 837, 1198, 1403},
{3695, 3490, 3863, 4098, 4050, 3948, 4087, 4232, 4303, 4395, 4796, 4970, 4618, 4030, 3739, 3527, 3069, 2850, 2861, 2668, 2631, 2400, 1971, 1854, 1697, 1925, 1829, 1439, 1640, 2222, 2844, 3261, 3426, 3002, 2656, 2381, 2329, 2309, 2501, 2448, 2110, 1683, 1596, 1811, 2213, 2329, 1966, 1754, 1886, 1826, 2131, 2255, 2229, 1931, 1812, 1706, 1825, 2051, 2111, 1998, 1894, 1814, 1814, 1858, 1941, 1564, 1533, 1694, 1868, 1774, 1604, 1881, 1825, 1584, 1495, 1321, 1136, 1016, 973, 1055, 1004, 914, 1195, 1131, 1115, 991, 854, 968},
{3602, 3752, 4214, 4406, 4228, 4048, 3950, 4049, 4100, 4341, 4506, 4825, 4852, 4488, 4157, 3777, 3370, 3196, 3063, 3164, 2890, 2407, 2287, 2188, 1742, 1716, 1499, 1443, 1858, 2081, 2458, 2985, 3520, 3178, 2892, 2675, 2672, 2609, 2454, 2263, 1931, 1638, 1909, 1952, 2132, 2254, 1975, 1876, 2175, 1879, 2183, 2264, 2296, 2013, 1970, 1928, 1936, 2076, 2007, 1830, 1802, 2081, 1910, 1596, 1566, 1384, 1393, 1470, 1572, 1717, 1864, 1964, 1855, 1833, 1659, 1229, 1108, 1126, 1190, 1273, 1083, 1112, 1257, 1136, 1056, 908, 781, 994},
{4176, 3968, 4337, 4553, 4331, 4126, 3858, 3859, 4021, 4088, 4375, 4601, 4525, 4444, 4135, 3976, 3712, 3562, 3380, 3217, 2778, 2488, 2479, 2139, 1754, 1531, 1398, 1712, 2267, 2621, 2794, 3188, 3381, 3022, 2938, 2743, 2420, 2520, 2380, 2101, 1845, 1727, 1971, 2274, 2280, 2083, 1806, 2130, 2212, 1975, 1952, 2085, 2285, 2271, 2184, 2045, 1966, 1929, 1928, 1837, 1709, 1883, 1893, 1586, 1467, 1748, 1669, 1406, 1479, 1803, 2025, 1960, 1741, 1612, 1318, 1236, 1256, 1279, 1374, 1381, 1132, 1249, 1271, 990, 878, 823, 824, 1056},
{4470, 4207, 4456, 4643, 4355, 4126, 3876, 3695, 3853, 4046, 4325, 4363, 4124, 3975, 3867, 3415, 3345, 3520, 3112, 2726, 2649, 2359, 2128, 1931, 1665, 1450, 1329, 1724, 2417, 2912, 3261, 3359, 2995, 2671, 2572, 2673, 2417, 2126, 2132, 1800, 1927, 1808, 2095, 2230, 2435, 2110, 1875, 2138, 2098, 2182, 2123, 2134, 2262, 2302, 2049, 1954, 1866, 1719, 1757, 1841, 1703, 1564, 1552, 1480, 1704, 1976, 1922, 1483, 1374, 1864, 2070, 1763, 1601, 1464, 1516, 1538, 1430, 1366, 1336, 1261, 1196, 1407, 1316, 1187, 1067, 858, 824, 930},
{4764, 4474, 4680, 4679, 4379, 4148, 3886, 3629, 3657, 3950, 4218, 4324, 4144, 3666, 3458, 3277, 2937, 3096, 3049, 2566, 2167, 2008, 1752, 1577, 1632, 1388, 1361, 1930, 2287, 2773, 3208, 3276, 2812, 2445, 2325, 2253, 2059, 1921, 1929, 1934, 2111, 1900, 2207, 2610, 2710, 2311, 1993, 2280, 2226, 2390, 2244, 2360, 2364, 2416, 2276, 2130, 1944, 1747, 1652, 1668, 1756, 1663, 1475, 1686, 1937, 1886, 1575, 1390, 1324, 1731, 1795, 1446, 1386, 1471, 1698, 1747, 1517, 1347, 1335, 1220, 1308, 1541, 1498, 1291, 1094, 937, 803, 931},
{4902, 4658, 4841, 4612, 4434, 4182, 3987, 3685, 3506, 3681, 3907, 4202, 4174, 3816, 3373, 3061, 2760, 2643, 2567, 2804, 2447, 1952, 1719, 1939, 1912, 1347, 1483, 1985, 2480, 2881, 3072, 3288, 2952, 2769, 2681, 2197, 2082, 2248, 2138, 2018, 2163, 2034, 2322, 2631, 2880, 2354, 2220, 2385, 2298, 2551, 2471, 2436, 2366, 2327, 2539, 2357, 2102, 1810, 1881, 1997, 1853, 1853, 1541, 1860, 2060, 1876, 1749, 1680, 1463, 1281, 1325, 1274, 1302, 1514, 1680, 1487, 1546, 1550, 1441, 1262, 1464, 1609, 1325, 1119, 975, 861, 848, 873},
{4950, 4953, 4882, 4531, 4231, 3981, 3799, 3472, 3427, 3437, 3776, 3886, 3940, 3811, 3716, 3304, 2926, 2613, 2395, 2363, 2312, 1841, 1890, 2114, 1710, 1338, 1560, 1815, 2285, 2629, 2842, 2879, 2937, 3026, 2614, 2194, 2376, 2585, 2318, 2186, 2271, 2250, 2525, 2705, 3047, 2683, 2635, 2632, 2511, 2515, 2509, 2303, 2126, 2100, 2283, 2299, 2060, 2056, 2211, 2088, 1993, 1747, 1624, 1907, 2040, 2004, 2013, 2007, 1670, 1206, 1125, 1138, 1314, 1520, 1575, 1289, 1399, 1550, 1438, 1396, 1593, 1550, 1271, 1109, 1075, 878, 848, 937},
{5138, 5166, 4847, 4535, 4232, 3998, 3748, 3448, 3197, 3191, 3425, 3585, 3753, 4006, 3941, 3627, 3256, 2944, 2533, 2162, 1977, 1880, 2154, 2307, 1678, 1339, 1791, 2152, 2541, 2639, 2508, 2506, 2749, 2863, 2491, 2350, 2661, 2772, 2511, 2306, 2509, 2519, 2697, 2891, 3208, 3189, 3154, 2916, 2352, 2234, 2155, 2313, 2110, 1939, 2016, 2080, 2146, 2220, 2055, 1914, 1801, 1611, 1734, 1785, 1961, 2011, 1851, 1733, 1459, 1254, 1156, 1147, 1351, 1580, 1550, 1340, 1179, 1461, 1588, 1612, 1455, 1306, 1174, 1037, 1023, 876, 922, 1136},
{5097, 5120, 4863, 4607, 4200, 3824, 3544, 3455, 3325, 3064, 3182, 3505, 3815, 4105, 4115, 3807, 3222, 2757, 2492, 2370, 2130, 2083, 2421, 2420, 1720, 1340, 1734, 2275, 2608, 2342, 2144, 2412, 2776, 2830, 2619, 2754, 2761, 2623, 2410, 2538, 2828, 2927, 2767, 2486, 2669, 2742, 2680, 2881, 2449, 1998, 1967, 2084, 2044, 1899, 1836, 1863, 2036, 2198, 1999, 1895, 1687, 1717, 2013, 2014, 2003, 1862, 1670, 1346, 1165, 1210, 1054, 1193, 1418, 1371, 1247, 1192, 1125, 1325, 1430, 1587, 1604, 1343, 1176, 1084, 949, 814, 892, 1210},
{5067, 5133, 4944, 4732, 4314, 3919, 3908, 3804, 3526, 3118, 3002, 3327, 3655, 3908, 4071, 3921, 3264, 3015, 2980, 2592, 2232, 2227, 2518, 2324, 1764, 1344, 1593, 1963, 2364, 2056, 2172, 2469, 2623, 2705, 2861, 3158, 2858, 2659, 2789, 2890, 3190, 3240, 2784, 2334, 2197, 2465, 2253, 2459, 2313, 1975, 1788, 1800, 1748, 1898, 1659, 1772, 1955, 2061, 2143, 1948, 1760, 1817, 2088, 2028, 1971, 1661, 1386, 1282, 1229, 1106, 1019, 1227, 1244, 1107, 1067, 1033, 1076, 1237, 1361, 1539, 1653, 1405, 1231, 1133, 995, 822, 863, 1101},
{5195, 5089, 4849, 4693, 4523, 4418, 4143, 3911, 3607, 3158, 2883, 3197, 3450, 3627, 3860, 4022, 3588, 3347, 2974, 2616, 2312, 2385, 2534, 2020, 1770, 1349, 1577, 2049, 2249, 1882, 1928, 2093, 2242, 2499, 2933, 3219, 3124, 2960, 3111, 3103, 3281, 3208, 2887, 2447, 2015, 2107, 2063, 2118, 2175, 1827, 1904, 1675, 1571, 1621, 1554, 1745, 1937, 2147, 2217, 2035, 2041, 2107, 2005, 1813, 1768, 1605, 1416, 1520, 1520, 1296, 1135, 1021, 953, 943, 956, 926, 1032, 1197, 1302, 1419, 1504, 1361, 1141, 1007, 906, 805, 815, 930},
{5475, 5347, 5163, 5026, 4829, 4362, 4098, 3785, 3514, 3130, 2804, 2980, 3397, 3744, 3936, 4036, 3533, 3076, 2865, 2654, 2441, 2648, 2609, 1889, 1516, 1325, 1687, 2150, 1956, 1743, 1801, 2041, 2284, 2668, 2879, 3040, 3230, 3019, 2924, 3000, 3024, 2760, 2728, 2477, 2004, 1826, 1757, 1878, 1941, 1752, 1794, 1929, 1703, 1459, 1628, 1868, 1922, 2045, 2215, 2238, 2160, 1945, 1704, 1797, 1527, 1579, 1680, 1772, 1643, 1404, 1169, 1059, 1219, 1043, 1175, 1095, 955, 999, 1127, 1279, 1396, 1212, 1226, 1151, 936, 801, 822, 1077}
};//填充模式
#define MODE_POINT 1
#define MODE_LINE 2
#define MODE_FILL 3
#define MODE_COLOR 4//点的坐标
float x = 0.0;  float y = 0.0;  float z = 0.0;
//画面的坐标
float x1 = 0.0;  float y1 = 0.0;  float z1 = 0.0;float T_y = -4615.0f;   //视点与图形的距离=y轴上平移的距离
float T_x = 250.0f;     //x轴上平移的距离
float T_z = -20.0f;     //z轴上平移的距离float R_x = 0.0;  //绕x轴旋转
float R_y = 0.0; //绕y轴旋转
float R_z = 0.0; //绕z轴旋转int Over_z = 1000;//夸张程度//绘制模式
GLint Mode = 0;
//是否分级
GLboolean isColorGrade = false;//视口大小
GLint WinWidth;
GLint WinHeight;void myInit();
void OnReshape(int, int);//绘图函数
void OnPointMode();
void OnLineMode();
void OnFaceMode();void OnDisplay(void);//设置颜色分级
void OnColorGrade(float);//创建菜单
void OnMenu(int);
void createMenu(void);//键盘控制
void proNormalKey(unsigned char, int, int);
void SetupLights();#endif

三、cpp文件

/*时间:2021年5月说明:a、A 绕 X 轴旋转;b、B 绕 Y 轴旋转;c、C 绕 Z 轴旋转o、O 物体上平移、下平移l、L 物体向右平移、左平移n、N 推进、拉远
*/
#include "header.h"int main(int argc, char* argv[]) {glutInit(&argc, argv);glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);glutInitWindowSize(600, 500);glutInitWindowPosition(100, 100);glutCreateWindow("三维地形动态显示程序设计");myInit();glutReshapeFunc(OnReshape);glutDisplayFunc(OnDisplay);glutKeyboardFunc(proNormalKey);createMenu();glutMainLoop();return 0;
}void myInit()
{glEnable(GL_DEPTH_TEST);SetupLights();
}void OnReshape(int w, int h)
{WinWidth = w;WinHeight = h;glViewport(0, 0, w, h);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(90, (GLsizei)w / (GLsizei)h, 1, 10000);glMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(0, 0, 1500, 0, 0, 0, 0.0, 1.0, 0.0);
}void OnPointMode()
{glPushMatrix();glPointSize(1.5);for (int i = 0; i < nrows; i++)  //行{glBegin(GL_POINTS);for (int j = 0; j < ncols; j++)  //列{x = (xllcorner + j * CELLSIZE) /1000;y = (yllcorner + (nrows - 1 - i) * CELLSIZE) / 1000;z = dem[i][j] / Over_z;OnColorGrade(z);glVertex3f(x, y, z);}glEnd();}glPopMatrix();
}void OnLineMode()
{glPushMatrix();for (int i = 0; i < nrows; i++)  //行{glBegin(GL_LINE_STRIP);for (int j = 0; j < ncols; j++)  //列{x = (xllcorner + j * CELLSIZE) / 1000;y = (yllcorner + (nrows - 1 - i) * CELLSIZE) / 1000;z = dem[i][j] /Over_z;OnColorGrade(z);glVertex3f(x, y, z);}glEnd();}for (int j = 0; j < ncols; j++){glBegin(GL_LINE_STRIP);for (int i = 0; i < nrows; i++){x = (xllcorner + j * CELLSIZE) / 1000;y = (yllcorner + (nrows - 1 - i) * CELLSIZE) / 1000;z = dem[i][j] /Over_z;OnColorGrade(z);glVertex3f(x, y, z);}glEnd();}glPopMatrix();
}void OnFaceMode()
{glPushMatrix();for (int i = 0; i < nrows - 1; i++)  //行{glBegin(GL_TRIANGLE_STRIP);for (int j = 0; j < ncols; j++)  //列{x = (xllcorner + j * CELLSIZE) / 1000;y = (yllcorner + (nrows - 1 - i) * CELLSIZE) / 1000;z = dem[i][j] /Over_z;x1 = (xllcorner + j * CELLSIZE) / 1000;y1 = (yllcorner + (nrows - 2 - i) * CELLSIZE) / 1000;z1 = dem[i + 1][j] /Over_z;OnColorGrade(z);glVertex3f(x, y, z);OnColorGrade(z1);glVertex3f(x1, y1, z1);}glEnd();}glPopMatrix();
}void OnColorGrade(float mz)
{if (isColorGrade) {glShadeModel(GL_SMOOTH);//分级设色,分为10个级if (mz < 1.2)glColor3f(0, 0.4588, 0.1529);else if (mz >= 1.2 && mz < 1.7)glColor3f(0.0549, 0.5921, 0.0431);else if (mz >= 1.7 && mz < 2.3)glColor3f(0.3372, 0.7254, 0.1137);else if (mz >= 2.3 && mz < 2.8)glColor3f(0.9960, 0.9568, 0.3137);else if (mz >= 2.8 && mz < 3.4)glColor3f(1.0, 0.8039, 0.1019);else if (mz >= 3.4 && mz < 3.9)glColor3f(0.8156, 0.5294, 0.1254);else if (mz >= 3.9 && mz < 4.4)glColor3f(0.6509, 0.4823, 0.3294);else if (mz >= 4.4 && mz < 5.0)glColor3f(0.6745, 0.5647, 0.4705);else if (mz >= 5.0 && mz < 5.6)glColor3f(1.0, 1.0, 1.0);}else{glColor3f(0.0, 1.0, 0.0);}}void OnDisplay(void)
{glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glRotated(-90, 1, 0, 0);glRotated(R_x, 1, 0, 0);glRotated(R_y, 0, 1, 0);glRotated(R_z, 0, 0, 1);glTranslatef(T_x, T_y, T_z);//相对世界坐标系而言,x指向右方,y指向屏幕里面,z指向上方switch (Mode){case 1:OnPointMode();break;case 2:OnLineMode();break;case 3:OnFaceMode();break;default:break;}glutSwapBuffers();
}void createMenu(void)
{GLint nMainMenu;nMainMenu = glutCreateMenu(OnMenu);glutAddMenuEntry("点样式", MODE_POINT);glutAddMenuEntry("线样式", MODE_LINE);glutAddMenuEntry("面样式", MODE_FILL);glutAddMenuEntry("分级色彩", MODE_COLOR);glutAttachMenu(GLUT_RIGHT_BUTTON);
}void OnMenu(int value)
{switch (value){case MODE_POINT:Mode = 1;isColorGrade = false;break;case MODE_LINE:Mode = 2;isColorGrade = false;break;case MODE_FILL:Mode = 3;isColorGrade = false;break;case MODE_COLOR:isColorGrade = true;break;}OnReshape(WinWidth, WinHeight);glutPostRedisplay();
}void proNormalKey(unsigned char key, int x, int y)
{switch (key) {//物体绕轴旋转case 120:    //"x"R_x -= 0.5f; //表现为向屏幕上方部分的里面转break;case 88: //"X"R_x += 0.5f; //表现为向屏幕下方部分的里面转break;case 121:   //"y"R_y -= 0.5f; //表现为面向屏幕逆时针break;case 122:    //"Y"R_y += 0.5f;break;case 99: //"z"R_z -= 0.5f; //表现为向屏幕右方部分的里面转break;case 90: //"Z"R_z += 0.5f;break;;case 110:   //"n"T_y -= 10.0f;break;case 78: //"N"T_y += 10.0f;break;//视点不动,动物体case 108: //"l"  右T_x += 10.0f;break;case 76: //"L"  左T_x -= 10.0f;break;case 111: //"o"  上T_z += 10.0f;break;case 79: //"O"  下T_z -= 10.0f;break;case 98: //"b" 减小夸张Over_z += 100;break;case 66://"B" 加大夸张Over_z -= 100;break;default:break;}OnReshape(WinWidth, WinHeight);glutPostRedisplay();
}void SetupLights()
{GLfloat ambientLight[] = { 0.6, 0.6, 0.6, 1.0 };GLfloat diffuseLight[] = { 1.0, 1.0, 1.0, 1.0 };GLfloat specularLight[] = { 1.0, 1.0, 1.0, 1.0 };GLfloat lightPos[] = { 10.0, 700.0, 200.0, 1.0 };glEnable(GL_LIGHTING);glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);glLightfv(GL_LIGHT0, GL_POSITION, lightPos);glEnable(GL_LIGHT0);glEnable(GL_COLOR_MATERIAL);glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);glMaterialfv(GL_FRONT, GL_SPECULAR, specularLight);glMateriali(GL_FRONT, GL_SHININESS, 100);
}

OpenGL读取灰度图生成地形相关推荐

  1. unity 读取灰度图生成按高程分层设色地形模型

    准备灰度图 1.高程按比例对应hue色相(hsv)生成mesh效果 o.color = float4(hsv2rgb(float3(v.vertex.y/100.0, 0.5, 0.75)), 1.0 ...

  2. blender导入灰度图生成地形模型

    安装软件 在此处下载blender并安装. 添加平面 1.打开blender,右键删除初始的立方体. 2.shift+a选择平面添加进场景: 3.按下s键鼠标拖动调节平面大小确定后按下鼠标左键: 4. ...

  3. unity读取灰度图生成等值线图

    准备灰度图 grayTest.png,放置于Assets下StreamingAssets文件夹中. 在场景中添加RawImage用于显示最后的等值线图. 生成等值线的过程,使用Marching squ ...

  4. python灰度图生成g代码_Artcam2009利用灰度图生成雕刻机所需的G代码

    双击桌面的artcam快捷方式图标打开软件首先看到如下 的界面.点击"通过图像产生模型" 利用ART CAM 软件制作浮雕刀路的方法 Artcam2009利用灰度图生成雕刻机所需的 ...

  5. python灰度图生成g代码_artcam pro 通过灰度图生成G代码详细图文教程

    本文是使用artcam pro 把灰度图转成G代码,看到喜欢的雕刻,可以自己先做成灰度图,然后转换成G代码,今天特地做了一个教程,仅供刚刚接触者使用! 新手可以看看,老手请高抬贵手,不要嘲笑.自己技术 ...

  6. UE4灰度图生成地图记录blender生成城市地形

    引擎:4.26 首先,在网上下载灰度地形图.这边先下载了如下的灰度地形图. 然后,使用ps来修改图片的格式,以适应UE4引擎的使用. 将图片修改成灰度,16位通道. 然后将图片导出成png格式(灰度, ...

  7. python读取灰度图_Python读取MRI并显示为灰度图像实例代码

    Python读取MRI并显示为灰度图像实例代码 本文实例主要关于Python实现读取MRI(核磁共振成像)为numpy数组,使用imshow显示为灰度. 代码如下: import matplotlib ...

  8. python image处理 读取image 读取灰度图边缘

    python提取彩色图像RGB三通道 OpenCV读取图像后,按照BGR方式排列图像矩阵 PIL(python image library)库读取图像后,按照RGB方式排列图像矩阵 RGB:red, ...

  9. 【UE4 C++】读取灰度图/RGB图中的像素值生成自定义形状的模型分布

    效果图 一.PS制作一张自定义形状的像素图 导出为PNG图片 二.UE4创建函数库读取图片像素颜色 1.新建C++类 2.头文件中添加函数 public:UFUNCTION(BlueprintCall ...

  10. matlab热度图确定色标_C++实现类似Matlab的colormap Jet(灰度图生成彩色热度图)

    Matlab使用colormap Jet 可以将灰度图像生成彩色的热度图,灰度值越高,色彩偏向暖色调.相反亦然. // ColorMap.h #ifndef COLORMAP_H #define CO ...

最新文章

  1. Django web : CSRF verification failed. Request aborted.
  2. 华为又一重拳!全球首款5G基站核心芯片“天罡”发布!
  3. thinkphp执行流程
  4. [译] Couchbase 使用 cbbackup 备份
  5. 鸟哥的Linux私房菜(基础篇)- 第二十六章、Linux 核心编译与管理
  6. php drive mssql,PHP 连接 MSSQL 2005/2008 以UTF8存取 并让ADODB支持的安装设置
  7. 限制用户不允许输入中文字符
  8. java中的hashcode方法作用以及内存泄漏问题
  9. 电影推荐之《哈利·波特与火焰杯》 隐私策略(Privacy policy)
  10. 【转】用MYSQL都可能会遇到的问题:MYSQL字符数字转换
  11. 记一次Mysql数据库Kill完之后启动不起来的解决方案
  12. C语言范例学习03-上
  13. 2015第35周六转相见恨晚的知识列表
  14. 信道、频段带宽等术语简介
  15. win10内置ubuntu, “指定的网络名不再可用”解决办法
  16. c语言if语句作用及应用场景,c语言if语句如何使用
  17. 数据结构创建有向图(C++语言)
  18. 从随机生成九宫格至随机生成数独游戏再至用回溯法实现数独的解
  19. 鱼眼和全向视图的图像深度学习方法
  20. GEF教程及demo源码

热门文章

  1. 如何下载安定门街道卫星地图高清版大图
  2. 3.7V转5V电路图芯片,3.7V升压5V的升压芯片
  3. 收费最低的云存储_营业收费系统|自来水管理系统|自来水公司收费管理系统|手机移动抄表|网上营业厅|短信服务平台...
  4. arma模型预测 matlab,MATLAB中ARMA模型预测差分问题
  5. 学习Globle和window对象学习心得+jquery中的$(#id)与document.getElementById(id)的区别+成功激活win10的方法
  6. 程序员福音,关于如何使用Markdown写出一份漂亮的简历 —— 程序员简历 | md文档简历制作教程
  7. 互亿无线python接口
  8. 用python编程分苹果_Python实现分苹果(递归)
  9. linux xampp使用教程,CentOS下安装XAMPP详细教程(学习记录使用)
  10. Linux入门及进阶学习推荐书籍