Compare commits
1049 Commits
hotfix/v0.
...
develop
Author | SHA1 | Date | |
---|---|---|---|
|
c986c9f0b1 | ||
|
9a71004b1e | ||
|
f4c4bf984c | ||
|
fe2c29e013 | ||
|
98cce0ea26 | ||
|
c57cb96e80 | ||
|
817c799fcf | ||
|
09c3c2e12f | ||
|
dcbc3bd995 | ||
|
92c900b774 | ||
|
4f8ae5acea | ||
|
615c1dc00a | ||
|
3caa86a462 | ||
|
b5e8b63810 | ||
|
5103563365 | ||
|
e0b00fc5ac | ||
|
92981f3599 | ||
|
21e6b435a1 | ||
|
5644f837ca | ||
|
8d9fffd4c6 | ||
|
156bcef9c0 | ||
|
0fe41fe28c | ||
|
e433a697cb | ||
|
3d01a8412e | ||
|
abfe63a525 | ||
|
85b1bbb641 | ||
|
eef0bebacf | ||
|
4d2a27ea8e | ||
|
6a12a3dc7f | ||
|
f4ebd4c6a9 | ||
|
75a2831ae7 | ||
|
c0b72b6a55 | ||
|
1444f187a6 | ||
|
8678d741b3 | ||
|
64c4c8ce86 | ||
|
d544de6dd1 | ||
|
e89a55d154 | ||
|
b3ca051878 | ||
|
9a8e816485 | ||
|
1e9fdf074a | ||
|
403189f357 | ||
|
354b6aa9d0 | ||
|
4fdecf42eb | ||
|
74dfaa293f | ||
|
9e600c0bcb | ||
|
43bb832c46 | ||
|
9617197893 | ||
|
65a973f94e | ||
|
28a3d78354 | ||
|
ed94fc6f25 | ||
|
7fc9990b79 | ||
|
20ff44c814 | ||
|
280c2fdeaa | ||
|
6d2dcc7d02 | ||
|
67a9d90c0b | ||
|
735b0ab6b1 | ||
|
920c78f4d1 | ||
|
f8e1bb8452 | ||
|
14cac713bd | ||
|
ff567aa9f8 | ||
|
5aa631da8f | ||
|
8c35399fc6 | ||
|
a0c32e22b7 | ||
|
96e747d0c3 | ||
|
942bb37981 | ||
|
ebab89b9ad | ||
|
2fa291d16f | ||
|
f32bb1d1ed | ||
|
92db006250 | ||
|
01963bd462 | ||
|
68bdd9ca99 | ||
|
ac7bec0c45 | ||
|
6493e88d4c | ||
|
edd1af14ca | ||
|
ccedb0e294 | ||
|
baf5cf2cab | ||
|
48a6929a7a | ||
|
04c4e49aa1 | ||
|
37db0bac52 | ||
|
e4ef845045 | ||
|
b3ce982ef3 | ||
|
d353685ce9 | ||
|
1d51ee8d0a | ||
|
c384fbfea8 | ||
|
96ec47a972 | ||
|
13be35aac9 | ||
|
e0ce93acb1 | ||
|
b353cd1ce8 | ||
|
ecc06ba986 | ||
|
f4941fb73c | ||
|
c8124097e3 | ||
|
efb9844fe2 | ||
|
a34eda6250 | ||
|
69349d95cd | ||
|
eb3727de30 | ||
|
32df8be8da | ||
|
4e9b0e374b | ||
|
8e9e122c03 | ||
|
304e3d8f7a | ||
|
cee15a145f | ||
|
5b84c5a9a5 | ||
|
762c9a5090 | ||
|
50cf939e8a | ||
|
50a8bebfa9 | ||
|
711c262004 | ||
|
2a7eb51653 | ||
|
b19de819e2 | ||
|
797689acea | ||
|
f178dc084b | ||
|
9a68582530 | ||
|
ccb76bc6d7 | ||
|
a39b7f6a9f | ||
|
1a1ae75766 | ||
|
0e8c90c6ee | ||
|
227b11a764 | ||
|
b4267b11f5 | ||
|
71adc7292c | ||
|
89508f8b2b | ||
|
f53efa1d64 | ||
|
e912950317 | ||
|
49683b4b48 | ||
|
54f235e09a | ||
|
5974a1de9b | ||
|
13fc8c5ba9 | ||
|
c4ce66dec5 | ||
|
2b22213bec | ||
|
5ce0d9c3e0 | ||
|
3937dc3c61 | ||
|
16fca2529b | ||
|
65b0d1c3c5 | ||
|
040dc37057 | ||
|
c2bb64d055 | ||
|
09253a7bcc | ||
|
3c31643e4f | ||
|
4887fc2701 | ||
|
a61d4556c1 | ||
|
e9bde59fbc | ||
|
64fa004102 | ||
|
ed64106237 | ||
|
d8a422955d | ||
|
b36548ff20 | ||
|
2a8e0a5f7b | ||
|
64c30044b0 | ||
|
f16a247934 | ||
|
4dadbbffd1 | ||
|
1d925a59a1 | ||
|
9947425169 | ||
|
cd752b4459 | ||
|
6ff7b46e26 | ||
|
32c30471a6 | ||
|
12fdeb8e52 | ||
|
1e0e8a8c16 | ||
|
f7c1962773 | ||
|
143c9fd08d | ||
|
37c35a08db | ||
|
8757f1e53e | ||
|
5dd46c4bcf | ||
|
64be18cd14 | ||
|
af70096fcc | ||
|
99390580dd | ||
|
c4cccf9043 | ||
|
f35581506c | ||
|
54903150e9 | ||
|
c562341db0 | ||
|
b90f0d4e15 | ||
|
8bd013f28e | ||
|
887ecc1aaa | ||
|
a2fe1944af | ||
|
27a59f34bc | ||
|
4c24d61408 | ||
|
c887d1444f | ||
|
d521b08cf9 | ||
|
dec06bcfe4 | ||
|
77db90ac30 | ||
|
0d36c416f2 | ||
|
3ca0222b19 | ||
|
d1bcaec2c5 | ||
|
d41a7d2747 | ||
|
135aa96bdf | ||
|
056cae39b5 | ||
|
b518978cd6 | ||
|
65f39e7b57 | ||
|
5d220c5d57 | ||
|
60612c5583 | ||
|
afd0650230 | ||
|
120b8e84cc | ||
|
d34c1d227c | ||
|
5847219331 | ||
|
b415e5c5f3 | ||
|
d000616d3e | ||
|
413bb95b1a | ||
|
7f96005985 | ||
|
d3b2dab1ac | ||
|
d99ed5e624 | ||
|
1c17a7147b | ||
|
9256f3deb5 | ||
|
322bedc009 | ||
|
1d24b189ca | ||
|
931c6cd3ec | ||
|
6516c00e62 | ||
|
3facd4df41 | ||
|
d6c708f869 | ||
|
b027cf1a0c | ||
|
778238d11d | ||
|
d477bec540 | ||
|
672c375a7a | ||
|
5fc0317260 | ||
|
92eaaae765 | ||
|
ceeb8f70ce | ||
|
0c619ebec7 | ||
|
f574563672 | ||
|
fd451be2dd | ||
|
905ec27f47 | ||
|
0d638f9837 | ||
|
0e995b5140 | ||
|
69f6f4ac37 | ||
|
6419c5827b | ||
|
8bd8f8ba7a | ||
|
cd48c6f611 | ||
|
e82d6beca1 | ||
|
d305038c27 | ||
|
741234e4a5 | ||
|
99d0a226c8 | ||
|
72abcd8e9c | ||
|
639eb6620f | ||
|
c98ad8c948 | ||
|
43c203a2c9 | ||
|
aaa6b1dc15 | ||
|
5a5b2b3875 | ||
|
2c0d9cb9e7 | ||
|
c804190d84 | ||
|
89550fcd44 | ||
|
61bffc9783 | ||
|
1213a4047a | ||
|
bd6efe8c3c | ||
|
d3618ca688 | ||
|
396d1cfc59 | ||
|
e7f41b7e0f | ||
|
bfc7dfdc1b | ||
|
7e03c3e05b | ||
|
09c15173f9 | ||
|
41d5ea6178 | ||
|
d9dae773dc | ||
|
32b07659a8 | ||
|
969310f327 | ||
|
65f966555d | ||
|
cb1cd58288 | ||
|
f262c0e8f5 | ||
|
416ae8eb7f | ||
|
1853a0fc4e | ||
|
6817899e6a | ||
|
3ace735619 | ||
|
64d010527b | ||
|
42e8b2cf44 | ||
|
917d3b8c95 | ||
|
7ac652e92b | ||
|
f7af804ccf | ||
|
1f3dc558da | ||
|
2ec29e33b7 | ||
|
fbb7ff4728 | ||
|
e985dce075 | ||
|
d3b71a92b9 | ||
|
9547824f14 | ||
|
7262ca313e | ||
|
838407ba4f | ||
|
9c93c5fc36 | ||
|
565aa21799 | ||
|
3f849e19a4 | ||
|
92daf9a0c0 | ||
|
28c516b5ad | ||
|
7e19706681 | ||
|
f87966686d | ||
|
1cbc0605fd | ||
|
feb9b6bdc6 | ||
|
41498cfcb8 | ||
|
ec80bfe740 | ||
|
f042584ed5 | ||
|
c62bde0066 | ||
|
d9da93b6c0 | ||
|
d875ff33ce | ||
|
74089437b3 | ||
|
72be03262a | ||
|
7946e55357 | ||
|
049a77cd0c | ||
|
16a75d0606 | ||
|
97bd3a232a | ||
|
6e2004d9c5 | ||
|
a296807ed9 | ||
|
630affbf4d | ||
|
c3305ea14b | ||
|
5d54c881a1 | ||
|
c3f2e5217e | ||
|
9d9e3996a3 | ||
|
07f1593561 | ||
|
4325ffabc4 | ||
|
6e8d9dfb75 | ||
|
8cff2bb2da | ||
|
eb45c97a61 | ||
|
d480935e38 | ||
|
8065b709d1 | ||
|
ecb3439d22 | ||
|
6d6b190743 | ||
|
2e98414fd3 | ||
|
436e8d479c | ||
|
4ed75cd174 | ||
|
66fdc19fe9 | ||
|
86357d66b7 | ||
|
c560e84be5 | ||
|
6a6e1e49e1 | ||
|
75df6621bd | ||
|
db2e62d2a8 | ||
|
f95cc6bfca | ||
|
3a56a70f38 | ||
|
ccb9f8d564 | ||
|
ae0c5b3702 | ||
|
33ec5e1d79 | ||
|
d6a7b83698 | ||
|
db9a74fdb4 | ||
|
71035029d1 | ||
|
0ab7f27f0f | ||
|
f3a18befad | ||
|
8d7d88a7df | ||
|
ede35435a0 | ||
|
880dcd8645 | ||
|
4779f91787 | ||
|
6f08184fcb | ||
|
25a1d95387 | ||
|
3a08487dc2 | ||
|
2602b00103 | ||
|
b08974c197 | ||
|
d2bbd6beba | ||
|
8dd026e095 | ||
|
38b8764129 | ||
|
e88466ad4d | ||
|
277b6c7b9b | ||
|
916fe310ad | ||
|
177eb16bec | ||
|
daa93aab19 | ||
|
98526d38d3 | ||
|
37f1ddaed2 | ||
|
5b59bc2d8c | ||
|
2b47c959a5 | ||
|
704eeaf948 | ||
|
47ace554cc | ||
|
3cf8f38793 | ||
|
5ff54c041f | ||
|
c0a22de2df | ||
|
302c6e688b | ||
|
bfe03142b7 | ||
|
4781ca5c42 | ||
|
882798ccb8 | ||
|
a9f1a29868 | ||
|
40a290bfce | ||
|
25860122b0 | ||
|
09e68d923e | ||
|
089303f02f | ||
|
d06dbdf054 | ||
|
d49db280d5 | ||
|
528873bcd3 | ||
|
9a1c6784df | ||
|
083c65ecd5 | ||
|
1fb82f40b3 | ||
|
ad73caf368 | ||
|
0ff0234ce1 | ||
|
83c287727f | ||
|
5f8e3df5df | ||
|
20815b6083 | ||
|
46358adfbc | ||
|
d9f328cadb | ||
|
d0aa7cd60f | ||
|
458a534bf3 | ||
|
4482538f9e | ||
|
43e0d6f417 | ||
|
33c5fe7526 | ||
|
17ee7982d5 | ||
|
9b88e97599 | ||
|
349009c67e | ||
|
72f696652a | ||
|
c75b0d58ce | ||
|
e2051ed713 | ||
|
c0added385 | ||
|
ec9b06ef0f | ||
|
4b3b940b91 | ||
|
0863d82068 | ||
|
502b21c3bd | ||
|
5e7c4fbc12 | ||
|
be47aec7f7 | ||
|
3c82652f46 | ||
|
ba6685289d | ||
|
5c30aa20f9 | ||
|
1f5c074364 | ||
|
6c30f34089 | ||
|
0ccc268b16 | ||
|
aa4591d206 | ||
|
93fdd36f8f | ||
|
f1ed0c1be2 | ||
|
d4118a2052 | ||
|
ed4bdf08c4 | ||
|
0b5e7071ae | ||
|
ccc9a3c158 | ||
|
e2f43ebc5d | ||
|
64ba3f20f8 | ||
|
11845c1d31 | ||
|
4b3c8a1648 | ||
|
eaea74b7f8 | ||
|
29baac9d6d | ||
|
94d1b57b81 | ||
|
c5cf71b161 | ||
|
52dd0189d5 | ||
|
37757da98c | ||
|
e1cdf0ca06 | ||
|
112b277452 | ||
|
2b7ef5b966 | ||
|
f9ee5a10b4 | ||
|
8326aa8668 | ||
|
bfa14a32df | ||
|
98e722271e | ||
|
972bc3a456 | ||
|
79c62be039 | ||
|
4a42535f13 | ||
|
dd5e34bc92 | ||
|
9b84c9d07d | ||
|
c68a48df6b | ||
|
b1c03c9f9c | ||
|
6bedd40694 | ||
|
70b04a055e | ||
|
b7be2ff7ab | ||
|
06540d6c97 | ||
|
ffdf606ad6 | ||
|
5701e7a6cc | ||
|
78d750a0f2 | ||
|
e6dc0716cd | ||
|
9b19ea656b | ||
|
31e5a6e346 | ||
|
9fd52e3494 | ||
|
0bff22fbf5 | ||
|
82f9d6ad6f | ||
|
d7d1d99ca9 | ||
|
4fa2400ef2 | ||
|
80d9feb5ea | ||
|
b259b60de2 | ||
|
392ccab703 | ||
|
78ac1d12b5 | ||
|
4f1863eccb | ||
|
224c27de50 | ||
|
2c916300ea | ||
|
a6a1c4dbb7 | ||
|
e40eb6d762 | ||
|
8604d1209e | ||
|
f945fd4ce4 | ||
|
b635e9d29d | ||
|
2090b0087c | ||
|
85c5686ff9 | ||
|
e9ba998f2f | ||
|
c26686476d | ||
|
35049b7a53 | ||
|
37ba9ab338 | ||
|
1790d8338f | ||
|
764c9ac97c | ||
|
140cbc0fc7 | ||
|
1d8fc25cb7 | ||
|
321d3eb7d4 | ||
|
ba58cff815 | ||
|
5a23299634 | ||
|
fd3879faeb | ||
|
40e528d782 | ||
|
4ae25d6b1e | ||
|
e9c8daa9cb | ||
|
2a072f9347 | ||
|
9e835a1110 | ||
|
b97bf52214 | ||
|
ec08b28002 | ||
|
499db6a185 | ||
|
22869e4861 | ||
|
b63a09cab3 | ||
|
6738c4fc9e | ||
|
349dc2b0e6 | ||
|
e80c88a5ec | ||
|
eb39f0bb4c | ||
|
f78aad8abd | ||
|
99cf75e902 | ||
|
07b9cf05fa | ||
|
aace1f2e36 | ||
|
f65edddd81 | ||
|
6cbb2d44bf | ||
|
34f57911a7 | ||
|
d34fd6b3c8 | ||
|
4f7e1e6846 | ||
|
9f5b2e1659 | ||
|
37bdf8e3ac | ||
|
79acf814db | ||
|
e8313a683b | ||
|
4aae00e4a8 | ||
|
da8f294847 | ||
|
4cec89de38 | ||
|
ab741583e4 | ||
|
f8ce3a5f3d | ||
|
16cbb94d90 | ||
|
7d55e00f76 | ||
|
51e93fdabc | ||
|
7fc954a6bf | ||
|
ef61480c3d | ||
|
f2ba500c4c | ||
|
1e0b8e97eb | ||
|
d69e840055 | ||
|
5191c3c068 | ||
|
a34c106382 | ||
|
1bff5c207c | ||
|
217aa93720 | ||
|
95a3e2e9ce | ||
|
347028199c | ||
|
a51eaa4a02 | ||
|
573c36db87 | ||
|
ae87dbee77 | ||
|
b0a8ca8a64 | ||
|
4c2aea3db1 | ||
|
12246d1633 | ||
|
5dfa7e2562 | ||
|
2da902d5f9 | ||
|
fe3f2d589e | ||
|
45302fde02 | ||
|
d79ac03fb6 | ||
|
7b5e1cd1d5 | ||
|
a78508a79f | ||
|
19387fd62e | ||
|
1f1cc67fb7 | ||
|
464d713c2a | ||
|
ac16dfd325 | ||
|
f05d54b985 | ||
|
d06650172a | ||
|
868fbb84a0 | ||
|
00d1b8e10c | ||
|
cec740f429 | ||
|
e52e9e373e | ||
|
0bbb648925 | ||
|
d50b910a45 | ||
|
163e520e9f | ||
|
d8bcd09d9b | ||
|
acbfb184b8 | ||
|
529e97f71e | ||
|
0755961750 | ||
|
67ec0d2db8 | ||
|
b416dc933f | ||
|
1cf5f4c899 | ||
|
c5780dd8e2 | ||
|
60396a2699 | ||
|
2458f94feb | ||
|
aeefe7f938 | ||
|
0e8973e722 | ||
|
bc17c802bb | ||
|
376ce595d6 | ||
|
74be82e8cf | ||
|
f2dd852bd2 | ||
|
906d685f5f | ||
|
248a5c3e29 | ||
|
109bfb7e9e | ||
|
af9eacef37 | ||
|
2955b35743 | ||
|
f4e03cc537 | ||
|
84921f4d0b | ||
|
20576d7a6f | ||
|
2ae5667986 | ||
|
4c29d59430 | ||
|
e0e860c45c | ||
|
832a45013a | ||
|
a9238051fa | ||
|
52e25f2b3d | ||
|
f58161c748 | ||
|
c177891e5d | ||
|
8d5f6af7cd | ||
|
d96dcaa531 | ||
|
1cb486cb33 | ||
|
31b59702be | ||
|
15b170696c | ||
|
3db5e1b2f6 | ||
|
f2ecb667e8 | ||
|
5294efc473 | ||
|
85d8bdb30c | ||
|
1c5a3f7ef5 | ||
|
2d6bb91d96 | ||
|
afddb59d69 | ||
|
3fe92086f1 | ||
|
8943822046 | ||
|
8a07d93b54 | ||
|
29bded222f | ||
|
21001d6862 | ||
|
1531e1cd00 | ||
|
4d683627da | ||
|
d17c1b404b | ||
|
ef615cc838 | ||
|
dcea5ccc54 | ||
|
498f21f63f | ||
|
a4e09c2481 | ||
|
29ca1e763f | ||
|
513c3a90b0 | ||
|
319a0ce352 | ||
|
f63bb510b3 | ||
|
4ee2a61a15 | ||
|
f81b42747b | ||
|
886c66d7c3 | ||
|
55dc066a3f | ||
|
61e957314f | ||
|
07f1ca42d2 | ||
|
6fb30a40f5 | ||
|
fcf5b2b055 | ||
|
6a009825b5 | ||
|
b9546ddcfa | ||
|
7c74e1faff | ||
|
2f99964606 | ||
|
9ad4c3fcf7 | ||
|
a308102585 | ||
|
acf5bef5e7 | ||
|
e485265dd8 | ||
|
dcf86a905c | ||
|
6f17e0faa6 | ||
|
9503d975c1 | ||
|
e35b58ba18 | ||
|
4478e365c9 | ||
|
fa8813ba86 | ||
|
d1138dcdb1 | ||
|
020ac9655a | ||
|
a4fc814a51 | ||
|
00fab818cc | ||
|
0c8013317e | ||
|
a10fcf8ecc | ||
|
ef59f329b6 | ||
|
f54532a905 | ||
|
c3c4ead1f3 | ||
|
b767d9b896 | ||
|
f4f85551c6 | ||
|
cf9b54e5ab | ||
|
b07dafc9fa | ||
|
69066a068e | ||
|
7c11a53484 | ||
|
7146b5ecdb | ||
|
7ee913c8a8 | ||
|
3971e6415c | ||
|
63dfaa5a13 | ||
|
7cd115b33d | ||
|
ef6bd31651 | ||
|
88cbeb309c | ||
|
1e986f9aa6 | ||
|
404f12a43e | ||
|
5b99854c02 | ||
|
dea7e6a4e9 | ||
|
b5d930062b | ||
|
3904c9aa8f | ||
|
0cfb9f5196 | ||
|
2acb98bdcb | ||
|
a00574351f | ||
|
00eb281990 | ||
|
0d92bc6c8c | ||
|
9ff95f7061 | ||
|
e6cbc09e83 | ||
|
884fe04c12 | ||
|
abd1920d80 | ||
|
a589c6e4ac | ||
|
056064409d | ||
|
0c55938242 | ||
|
2f2475ad0c | ||
|
8027f9904d | ||
|
9f7f893b68 | ||
|
bd60f34bd7 | ||
|
26f512eba7 | ||
|
c843e7e705 | ||
|
aab1149e8f | ||
|
edf1f5d665 | ||
|
059a4b9465 | ||
|
e38aa3b1b9 | ||
|
839f366174 | ||
|
7cad8388b9 | ||
|
0d839c4a51 | ||
|
f3ec94dd75 | ||
|
97a501e3da | ||
|
72b3cd5154 | ||
|
885a50e781 | ||
|
56cf423bfd | ||
|
1064ea1c47 | ||
|
acb43d54d9 | ||
|
938eea7c8e | ||
|
44d525f591 | ||
|
8ab6d73f0a | ||
|
0cf3de4e76 | ||
|
900e4e0ecd | ||
|
a2210fc3f0 | ||
|
6b92a5ab51 | ||
|
baed7ddccc | ||
|
c346d19d77 | ||
|
59505d47e9 | ||
|
e80fa3de7d | ||
|
785ac611b9 | ||
|
5643140882 | ||
|
d9ebe96c5a | ||
|
288b448b9f | ||
|
77a340f2b3 | ||
|
5664e2f681 | ||
|
20db75fb75 | ||
|
51f9898467 | ||
|
6781462b59 | ||
|
3e1539fc62 | ||
|
a14de4a72e | ||
|
414a012230 | ||
|
f86ec57e14 | ||
|
42ce6ace77 | ||
|
a1d773f5e7 | ||
|
c91b10ce73 | ||
|
1e55859107 | ||
|
dc7c7eb552 | ||
|
6e8030f4b5 | ||
|
62f273bd74 | ||
|
0a4ffc2351 | ||
|
28f81a8ae1 | ||
|
2f62a7de8d | ||
|
27833ee03f | ||
|
3249562d97 | ||
|
efb6d12fc8 | ||
|
45af7a4246 | ||
|
3a9b393459 | ||
|
7276b872c4 | ||
|
60d6658e1a | ||
|
1f2b7e4742 | ||
|
d98856b276 | ||
|
292b21dcdf | ||
|
3d82b9643f | ||
|
8ed5edf85f | ||
|
900b693e25 | ||
|
745f24eab8 | ||
|
6bc379f0df | ||
|
2b03e84f83 | ||
|
073c415a38 | ||
|
de8c69456f | ||
|
0c7002a1ce | ||
|
869f5f6c49 | ||
|
61dd59c9bc | ||
|
a56005478d | ||
|
dd7be8e7c3 | ||
|
d34ff02b0b | ||
|
60205425db | ||
|
2b3e9ca206 | ||
|
d12a81d345 | ||
|
fcb38f0796 | ||
|
c1461e7582 | ||
|
d7d3df2197 | ||
|
b12e6d045c | ||
|
b50d3a299b | ||
|
6c77e778dd | ||
|
f3b0183013 | ||
|
efd4878450 | ||
|
ea4d6d3168 | ||
|
fa8e7c390f | ||
|
4765390ef6 | ||
|
617834bed4 | ||
|
db1c2bf0f8 | ||
|
c806da9bb7 | ||
|
618b09df46 | ||
|
fa29a83ebd | ||
|
9fa0cc8a2a | ||
|
7d0fc3e3d2 | ||
|
afd5f0efc6 | ||
|
2010b46709 | ||
|
2203e30f39 | ||
|
a1355f6d50 | ||
|
1010052ea6 | ||
|
e405b46b61 | ||
|
ee299a45f0 | ||
|
62d164ef8a | ||
|
edd2aecea2 | ||
|
22a6714875 | ||
|
2a839e583d | ||
|
f98959f92a | ||
|
cb808ab593 | ||
|
cc430ae129 | ||
|
60826b4c85 | ||
|
7473cd4458 | ||
|
1d643becc5 | ||
|
055539ef75 | ||
|
5eedb9f21c | ||
|
5cab70b24c | ||
|
fcdb175f1c | ||
|
6374ebf092 | ||
|
23042c3fcb | ||
|
df5c339f64 | ||
|
b4fcb3daf8 | ||
|
74b4caba6b | ||
|
d12db9906f | ||
|
a7e49a1394 | ||
|
c28fa9a0ca | ||
|
4534f721b5 | ||
|
7e50dcbd93 | ||
|
9ec2ebd78c | ||
|
80025eaa46 | ||
|
62370868c8 | ||
|
c42270f165 | ||
|
e770baeb05 | ||
|
f70498e806 | ||
|
34671130fb | ||
|
81eab0ebfb | ||
|
eb8ace0c54 | ||
|
1a39577ec0 | ||
|
f517137991 | ||
|
328d40f712 | ||
|
b7eeda3370 | ||
|
6bf9105e56 | ||
|
7327220b1c | ||
|
66bdf0e5a9 | ||
|
608777bb9b | ||
|
7e08ed7aec | ||
|
c5023ff623 | ||
|
a38ac6b895 | ||
|
c3801db4e2 | ||
|
e4f1a5f0ce | ||
|
36968bdd79 | ||
|
687dbe40cb | ||
|
50c1c7c64b | ||
|
8d2061bdb5 | ||
|
aef5373e8b | ||
|
09c6e2bf26 | ||
|
a5b768e5f9 | ||
|
3d66db50e0 | ||
|
dadcf03d8d | ||
|
46e38c4714 | ||
|
a81ec68714 | ||
|
36676433be | ||
|
924744c5e6 | ||
|
a1cdf78250 | ||
|
804a766037 | ||
|
f76be64d6b | ||
|
d3aed35d81 | ||
|
8ad0cae89a | ||
|
d50e9dfebc | ||
|
4df159dfd7 | ||
|
6e93048c9f | ||
|
bab3c32ec5 | ||
|
e90215b0fc | ||
|
1d1dcc875a | ||
|
e05cb1fefc | ||
|
7b64c0c3c0 | ||
|
68ee094cec | ||
|
7bb7be0dec | ||
|
c7937b176d | ||
|
a8383b47db | ||
|
a5d55d4415 | ||
|
1f466d4931 | ||
|
a0cd1d09b3 | ||
|
575f4824cc | ||
|
bf5a9f7ab8 | ||
|
8fe824eb58 | ||
|
4b45bb297f | ||
|
25fae419f3 | ||
|
7bbaa0d559 | ||
|
a4b6339689 | ||
|
97024ba9b2 | ||
|
1e9bb88337 | ||
|
c05293844f | ||
|
ff789d296d | ||
|
4ee55bba2e | ||
|
29720c4568 | ||
|
4fcc8a15d7 | ||
|
858a9c0e1b | ||
|
8e5a09d0fc | ||
|
7e8af71e52 | ||
|
195a7a17a8 | ||
|
d5b03cdbc3 | ||
|
0c78d97ba5 | ||
|
9273094ebd | ||
|
161835f42b | ||
|
d6c4cfb9f3 | ||
|
5be6a8ba44 | ||
|
2b70f81a9a | ||
|
9051e7558e | ||
|
9c970bd11a | ||
|
50c9934376 | ||
|
d9dcf8a33c | ||
|
ed614802fe | ||
|
607febb673 | ||
|
4f7a6256a9 | ||
|
de26bb4b9c | ||
|
95f0aa22c1 | ||
|
81a4294a7d | ||
|
25a4ff1c8e | ||
|
9ca84dc0e1 | ||
|
ecad915001 | ||
|
64cd6e31b0 | ||
|
cc0b3ae2c0 | ||
|
59d415e305 | ||
|
3653528ae5 | ||
|
9e7bb75687 | ||
|
03de39b8dd | ||
|
bc8240fe63 | ||
|
a419c4f4e6 | ||
|
a3cb8f7a76 | ||
|
f5ea8878c2 | ||
|
e17271a2c7 | ||
|
c74c1a2b44 | ||
|
c78a8595fb | ||
|
831689bd17 | ||
|
eb380b84c7 | ||
|
ef4cb38fbe | ||
|
b0b0216e67 | ||
|
74f25eac23 | ||
|
fc74ec5f0f | ||
|
f22410ed9a | ||
|
2ae111a67f | ||
|
d61ea322c7 | ||
|
edfbac122c | ||
|
b71b4dd032 | ||
|
898aa24126 | ||
|
44dcb0ba89 | ||
|
933c211d47 | ||
|
4396c609bb | ||
|
8b018be2dc | ||
|
1c61329e67 | ||
|
2a12bcd6d6 | ||
|
db16a3d602 | ||
|
8473b1e3e6 | ||
|
342efec3fa | ||
|
a1ac75022c | ||
|
c0d4b2a36f | ||
|
1af088b81e | ||
|
46ca04704b | ||
|
d32d692810 | ||
|
1f6cbb79a9 | ||
|
298fb951b0 | ||
|
2bc8e8e201 | ||
|
ca45d49e0c | ||
|
c06bfa9c09 | ||
|
c69417a72b | ||
|
2d7045ddd1 | ||
|
a8bc3081fb | ||
|
ab6ec9380d | ||
|
d8da6a7b7f | ||
|
dac0e5449f | ||
|
8a376fa396 | ||
|
416fdbb1d2 | ||
|
fa69584411 | ||
|
414d242701 | ||
|
a502e84764 | ||
|
8b91e55c84 | ||
|
20a6095d75 | ||
|
14bf239a5b | ||
|
ec203c6954 | ||
|
b93ceca542 | ||
|
c49caa1511 | ||
|
fbdee1a9eb | ||
|
4c4a0f9f5c | ||
|
4be54c6dd1 | ||
|
eb0c7e7a9f | ||
|
e7e1f80e74 | ||
|
d0c9b7ba3d | ||
|
fea429a79a | ||
|
ab6898c4c5 | ||
|
1f9264a9f8 | ||
|
19a1f99723 | ||
|
d19f16ef64 | ||
|
93958998f6 | ||
|
3f87fc780f | ||
|
d5a5242409 | ||
|
78cdf9acd6 | ||
|
4ed8d4303b | ||
|
5a3d24e09b | ||
|
829e91ddf9 | ||
|
9d79035890 | ||
|
9a05f04f85 | ||
|
7e38fc135e | ||
|
57b78e148b | ||
|
f4917e5001 | ||
|
47e8f4a86d | ||
|
e7f4c69102 | ||
|
8792d1bd48 | ||
|
c37997bfe2 | ||
|
597b28d271 | ||
|
9e8e976bfe | ||
|
f9250a778b | ||
|
649e3dddb9 | ||
|
e5aab77cda | ||
|
ff3395643d | ||
|
f310e51318 | ||
|
90e279d7a4 | ||
|
5859281c62 | ||
|
7b6fd11a06 | ||
|
ba827d446b | ||
|
9c71c3fa30 | ||
|
b57cec96a3 | ||
|
256e289c8f | ||
|
b53fee2627 | ||
|
fab995225c | ||
|
a026546bb4 | ||
|
b10b995a84 | ||
|
bbdee0db25 | ||
|
a7d7f64554 | ||
|
c98f65c9a5 | ||
|
7636b6fb55 | ||
|
153d0afc77 | ||
|
61cd1d3a29 | ||
|
312a3def68 | ||
|
79cc521666 | ||
|
6e296b010f | ||
|
3ed3ac6998 | ||
|
37fbe16939 | ||
|
fd3ce69187 | ||
|
9960a757e5 | ||
|
fbc39e1cc3 | ||
|
b2642ec5c6 | ||
|
8f27c8fa9e | ||
|
bd00c8e572 | ||
|
f5b638957c | ||
|
e32d47ed8d | ||
|
1b207325c4 | ||
|
dec3f67a5a | ||
|
02b6421ab8 | ||
|
6d7246f907 | ||
|
e048f7c2f6 | ||
|
bb3d3c4b68 | ||
|
e7daab5bbc | ||
|
edf2bf87d4 | ||
|
63e0298fbf | ||
|
a932d060f2 | ||
|
7fbe92e1e7 | ||
|
6e729ded56 | ||
|
cbddc9cba4 | ||
|
9671f19444 | ||
|
c9df34336b | ||
|
d2cc4da68d | ||
|
8bc10530d2 | ||
|
9226337756 | ||
|
beee8850e9 | ||
|
08ceb9df1d | ||
|
3d9f44af90 | ||
|
cb992b7c34 | ||
|
24dcdcb97d | ||
|
e56fd3ce4f | ||
|
989cd453fe | ||
|
9f5fe452c9 | ||
|
989e6ea589 | ||
|
dbb5832d52 | ||
|
4b2c899dc6 | ||
|
c8657943c8 | ||
|
3902e00a0f | ||
|
596bf12877 | ||
|
a24fcc0c03 | ||
|
c981ed2706 | ||
|
d28c2aa61d | ||
|
3e79e0bfaa | ||
|
0f838d54b6 | ||
|
839e5374b6 | ||
|
88c8c4014a | ||
|
3577a56eb3 | ||
|
bef6a7746e | ||
|
addbf9f365 |
20
.gitattributes
vendored
Normal file
20
.gitattributes
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Based on GitHub sample: https://help.github.com/articles/dealing-with-line-endings
|
||||||
|
|
||||||
|
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Explicitly declare text files you want to always be normalized and converted
|
||||||
|
# to native line endings on checkout.
|
||||||
|
*.c text
|
||||||
|
*.cpp text
|
||||||
|
*.h text
|
||||||
|
*.inl text
|
||||||
|
*.txt text
|
||||||
|
*.i text
|
||||||
|
|
||||||
|
# Declare files that will always have CRLF line endings on checkout.
|
||||||
|
#*.sln text eol=crlf
|
||||||
|
|
||||||
|
# Denote all files that are truly binary and should not be modified.
|
||||||
|
#*.png binary
|
||||||
|
#*.jpg binary
|
192
CHANGELOG.txt
192
CHANGELOG.txt
@ -1,57 +1,135 @@
|
|||||||
Changes for PolyVox version 0.2
|
Changes for PolyVox version 0.3
|
||||||
===============================
|
===============================
|
||||||
This is the first revision for which we have produced a changelog, as we are now trying to streamline our development and release process. Hence this changelog entry is not going to be as structured as we hope they will be in the future. We're writing it from memory, rather than having carefully kept track of all the relevant changes as we made them.
|
This release has focused on... (some introduction here).
|
||||||
|
|
||||||
Deprecated functionality
|
*** Quick braindump of some changes ***
|
||||||
------------------------
|
|
||||||
The following functionality is considered deprecated in this release of PolyVox and will probably be removed in future versions.
|
* SimpleVolume is now PagedVolume (slightly slower but can go larger).
|
||||||
|
* MarchingCubesSurfaceExtractor class is now a free function extractMarchingCubesSurface()
|
||||||
MeshDecimator: The mesh decimator was intended to reduce the amount of triangles in generated meshes but it has always had problems. It's far too slow and not very robust. For cubic meshes it is no longer needed anyway as the CubicSurfaceExtractor has built in decimation which is much more effective. For smooth (marching cubes) meshes there is no single alternative. You can consider downsampling the volume before you run the surface extractor (see the SmoothLODExample), and in the future we may add support for an external mesh processing library.
|
* Meshes are more templatized (e.g. on IndexType) and extracted meshes are encoded to save space. A 'decode' function is provided for these (or you can do it on the GPU).
|
||||||
|
* Generally more templatization - you will want to use a lot of the 'auto' keyword to stay sane.
|
||||||
SimpleInterface: This was added so that people could create volumes without knowing about templates, and also to provide a target which was easier to wrap with SWIG. But overall we'd rather focus on getting the real SWIG bindings to work. The SimpleInterface is also extremely limited in the functionality it provides.
|
* MarchingCubesController class gives more control over extraction process, but defaults should be fine for primative voxel types.
|
||||||
|
* Requires VS2013 on Windows (GCC 4.7/Clang should be ok).
|
||||||
Serialisation: This is a difficult one. The current serialisation is rather old and only deals with loading/saving a whole volume at a time. It would make much more sense if it could serialise regions instead of whole volumes, and if it could handle compression. It would then be useful for serialising the data which is paged into and out of the LargeVolume, as well as other uses. Both these changes would likely require breaking the current format and interface. It is likely that serialisation will return to PolyVox in the future, but for now we would suggest just implementing your own.
|
* Support for 'WrapModes' when accessing outside volumes but I think these have bought a performance impact.
|
||||||
|
* Documentation is as poor (or wrong) as ever but all tests and examples work.
|
||||||
VolumeChangeTracker: The idea behind this was was to provide a utility class to help the user keep track of which regions have been modified so they know when they need the surface extractor to be run again. But overall we'd rather keep such higher level functionality in user code as there are multiple ways it can be implemented. The current implementation is also old and does not support very large/infinite volumes, for example.
|
* New Array class is much faster
|
||||||
|
|
||||||
Refactor of basic voxel types
|
*** End of braindump ***
|
||||||
-----------------------------
|
|
||||||
Previous versions of PolyVox provided classes representing voxel data, such as MaterialDensityPair88. These classes were required to expose certain functions such as getDensity() and getMaterial(). This is no longer the case as now even primitive data types such as floats and ints can be used as voxels. You can also create new classes to represent voxel data and it is entirely up to you what kind of properties they have.
|
|
||||||
|
This line was added just for testing.
|
||||||
As an example, imagine you might want to store lighting values in a volume and propagate them according to some algorithm you devise. In this case the voxel data has no concept of densities or materials and there is no need to provide them. Algorithms which conceptually operate on densities (such as the MarchingCubesSurfaceExtractor) will not be able to operate on your lighting data but this would not make sense anyway.
|
|
||||||
|
Voxel access
|
||||||
Because algorithms now know nothing about the structure of the underlying voxels, some utility functions/classes are required. The principle is similar to the std::sort algorithm, which knows nothing about the type of data it is operating on but is told how to compare any two values via a comparator function object. In this sense, it will be useful to have an understanding of how algorithms such as std::sort are used.
|
------------
|
||||||
|
The getVoxelAt() and setVoxelAt() functions have been deprecated and replaced by getVoxel() and setVoxel(). These new functions provide more control over how edge cases are handled and can potentially be faster as well. Please see the 'Volumes' section of the user manual for more information about how voxel access should be performed.
|
||||||
We have continued to provide the Density, Material, and MaterialDensityPair classes to ease the transition into the new system, but really they should just be considered as examples of how you might create your own voxel types.
|
|
||||||
|
LargeVolume
|
||||||
Some algorithms assume that basic mathematical operations can be applied to voxel types. For example, the LowPassFilter needs to compute the average of a set of voxels, and to do this it needs to be possible to add voxels together and divide by an integer. Obviously these operations are provided by primitive types, but it means that if you want to use the LowPassfilter on custom voxel types then these types need to provide operator+=, operator/=, etc. These have been added to the Density and MaterialDensityPair classes, but not to the Material class. This reflects the fact that applying a low pass filter to a material volume does not make conceptual sense.
|
-----------
|
||||||
|
Behaviour and interface of the LargeVolume has changed significantly and code which uses it will certainly need to be updated. Plese see the LargeVolume API docs for full details of how it now works.
|
||||||
Changes to build system
|
|
||||||
-----------------------
|
It is now possible to provide custom compressors for the data which is stored in a LargeVolume. Two compressor implementation are provided with PolyVox - RLECompressor which is suitable for cubic-style terrain, and MinizCompressor which uses the 'miniz' zlib implementation for smooth terrain or general purpose use. Users can provide their own implementation of the compressor interface if they wish.
|
||||||
In order to make the build system easier to use, a number of CMake variables were changed to be more consistent. See :doc:`install` for details on the new variable naming.
|
|
||||||
|
Note that the setCompressionEnabled() functionality has been removed and a compressor must always be provided when constructing the volume. The ability to disable compression was of questionable benefit and was complicating the logic in the code.
|
||||||
Changes to CubicSurfaceExtractor
|
|
||||||
--------------------------------
|
The LargeVolume also supports custom paging code which can be supplied by providing a subclass of Pager and implementing the relevant methods. This replaces the dataRequiredHandler() and dataOverflowHandler() functions.
|
||||||
The behaviour of the CubicSurfaceExtractor has been changed such that it no longer handles some edge cases. Because each generated quad lies between two voxels it can be unclear which region should 'own' a quad when the two voxels are from different regions. The previous version of the CubicSurfaceExtractor would attempt to handle this automatically, but as a result it was possible to get two quads existing at the same position in space. This can cause problems with transparency and with physics, as well as making it harder to decide which regions need to be updated when a voxel is changed.
|
|
||||||
|
These changes regarding compression and paging have also affected the LargeVolume constructors(s). Please see the API docs to see how they look now.
|
||||||
The new system simplifies the behaviour of this surface extractor but does require a bit of care on the part of the user. You should be clear on the rules controlling when quads are generated and to which regions they will belong. To aid with this we have significantly improved the API documentation for the CubicSurfaceExtractor so be sure to have a look.
|
|
||||||
|
Error Handling
|
||||||
Changes to Raycast
|
--------------
|
||||||
------------------
|
PolyVox now has it's own POLYVOX_ASSERT() macro rather than using the standard assert(). This has some advantages such as allowing a message to be printed and providing file/line information, and it is also possible to enable/disable it independantly of whether you are making a debug or release build.
|
||||||
The raycasting functionality was previously in a class (Raycast) but now it is provided by standalone functions. This is basically because there is no need for it to be a class, and it complicated usage. The new functions are called 'raycastWithDirection' and 'raycastWithEndpoints' which helps remove the previous ambiguity regarding the meaning of the two vectors which are passed as parameters.
|
|
||||||
|
A simple logging system has also been added, and the output can be redirected by user code.
|
||||||
The callback functionality (called for each processed voxel to determine whether to continue and also perform additional processing) is no longer implemented as an std::function. Instead the standard STL approach is used, in which a function or function object is used a a template parameter. This is faster than the std::function solution and should also be easier to integrate with other languages.
|
|
||||||
|
Please see the 'Error Handling' section of the user manual for more information about these changes.
|
||||||
Usage of the new raycasting is demonstrated by a unit test.
|
|
||||||
|
Volume wrap modes
|
||||||
Changes to AmbientOcclusionCalculator
|
-----------------
|
||||||
-------------------------------------
|
This release has seen a overhaul of the way PolyVox handles voxel positions which are outside of the volume. It used to be the case that you could specify a border value which would be returned whenever an out-of-volume access was performed, but this was not flexible enough for all use cases. You can now choose between different wrapping modes (border, clamp, etc) and apply them to both the volume itself or to samplers. If you have multiple samplers pointing at the same volume then you can choose to have different wrap modes for each of them.
|
||||||
The AmbientOcclusionCalculator has also been unclassed and is now called calculateAmbientOcclusion. The unit test has been updated to demonstrate the new usage.
|
|
||||||
|
Within the Volume class the getVoxelAt() and setBorderValue() functions have been deprecated. Please see the 'Volumes' section of the user manual for more information about how voxel access should now be performed.
|
||||||
Changes to A* pathfinder
|
|
||||||
------------------------
|
Various algorithms have also been updated to allow wrap modes to be specified when executing them.
|
||||||
The A* pathfinder has always had different (but equally valid) results when building in Visual Studio vs. GCC. This is now fixed and results are consistent between platforms.
|
|
||||||
|
Region class
|
||||||
Copy and move semantics
|
------------
|
||||||
-----------------------
|
The Region class has been tidied up and enhanced with new functionality. It now contains functions for growing and shrinking regions, as well as 'accumulate()' functions which ensure the Region contains a given point. The concept of an invalid region has also been introduced - this is one whose lower corner is greater than it's upper corner.
|
||||||
All volume classes now have protected copy constructors and assignment operators to prevent you from accidentally copying them (which is expensive). Look at the VolumeResampler if you really do want to copy some volume data.
|
|
||||||
|
Vector class
|
||||||
|
------------
|
||||||
|
The Vector class has been tidied up. Most notably it now makes use of an 'OperationType' which is used for internal calculations and some results. The documentation has also been updated.
|
||||||
|
|
||||||
|
Deprecated functionality
|
||||||
|
------------------------
|
||||||
|
Vector::operator<() has been deprecated. It was only present to allow Vectors to be used as the key to an std::map, but it makes more sense for this to be specified seperatly as a std::map comparison function. This is now done in the OpenGLExample (search for VectorCompare).
|
||||||
|
|
||||||
|
getVoxelAt() and setBorderValue() have been deprecated in the Volume class. See the section of this file on 'Volume wrap modes' for details.
|
||||||
|
|
||||||
|
Removed functionality
|
||||||
|
--------------------
|
||||||
|
Functionality deprecated for the previous release has now been removed. This includes:
|
||||||
|
|
||||||
|
- Region::getWidth() and related functions. You should now use Region::getWidthInVoxels() or Region::getWidthInCells.
|
||||||
|
- The MeshDecimator. We don't have a direct replacement for this so you should consider an alternative such as downsampling the volume or using an external mesh processing library.
|
||||||
|
- The SimpleInterface. This was primarily for the bindings, and we are making other efforts to get those working.
|
||||||
|
- Serialisation. You should implement any required serialisation yourself.
|
||||||
|
- This had a number of problems and was a little too high-level for PolyVox. You should implement change tracking yourself.
|
||||||
|
|
||||||
|
|
||||||
|
Changes for PolyVox version 0.2
|
||||||
|
===============================
|
||||||
|
This is the first revision for which we have produced a changelog, as we are now trying to streamline our development and release process. Hence this changelog entry is not going to be as structured as we hope they will be in the future. We're writing it from memory, rather than having carefully kept track of all the relevant changes as we made them.
|
||||||
|
|
||||||
|
Deprecated functionality
|
||||||
|
------------------------
|
||||||
|
The following functionality is considered deprecated in this release of PolyVox and will probably be removed in future versions.
|
||||||
|
|
||||||
|
MeshDecimator: The mesh decimator was intended to reduce the amount of triangles in generated meshes but it has always had problems. It's far too slow and not very robust. For cubic meshes it is no longer needed anyway as the CubicSurfaceExtractor has built in decimation which is much more effective. For smooth (marching cubes) meshes there is no single alternative. You can consider downsampling the volume before you run the surface extractor (see the SmoothLODExample), and in the future we may add support for an external mesh processing library.
|
||||||
|
|
||||||
|
SimpleInterface: This was added so that people could create volumes without knowing about templates, and also to provide a target which was easier to wrap with SWIG. But overall we'd rather focus on getting the real SWIG bindings to work. The SimpleInterface is also extremely limited in the functionality it provides.
|
||||||
|
|
||||||
|
Serialisation: This is a difficult one. The current serialisation is rather old and only deals with loading/saving a whole volume at a time. It would make much more sense if it could serialise regions instead of whole volumes, and if it could handle compression. It would then be useful for serialising the data which is paged into and out of the LargeVolume, as well as other uses. Both these changes would likely require breaking the current format and interface. It is likely that serialisation will return to PolyVox in the future, but for now we would suggest just implementing your own.
|
||||||
|
|
||||||
|
VolumeChangeTracker: The idea behind this was was to provide a utility class to help the user keep track of which regions have been modified so they know when they need the surface extractor to be run again. But overall we'd rather keep such higher level functionality in user code as there are multiple ways it can be implemented. The current implementation is also old and does not support very large/infinite volumes, for example.
|
||||||
|
|
||||||
|
Refactor of basic voxel types
|
||||||
|
-----------------------------
|
||||||
|
Previous versions of PolyVox provided classes representing voxel data, such as MaterialDensityPair88. These classes were required to expose certain functions such as getDensity() and getMaterial(). This is no longer the case as now even primitive data types such as floats and ints can be used as voxels. You can also create new classes to represent voxel data and it is entirely up to you what kind of properties they have.
|
||||||
|
|
||||||
|
As an example, imagine you might want to store lighting values in a volume and propagate them according to some algorithm you devise. In this case the voxel data has no concept of densities or materials and there is no need to provide them. Algorithms which conceptually operate on densities (such as the MarchingCubesSurfaceExtractor) will not be able to operate on your lighting data but this would not make sense anyway.
|
||||||
|
|
||||||
|
Because algorithms now know nothing about the structure of the underlying voxels, some utility functions/classes are required. The principle is similar to the std::sort algorithm, which knows nothing about the type of data it is operating on but is told how to compare any two values via a comparator function object. In this sense, it will be useful to have an understanding of how algorithms such as std::sort are used.
|
||||||
|
|
||||||
|
We have continued to provide the Density, Material, and MaterialDensityPair classes to ease the transition into the new system, but really they should just be considered as examples of how you might create your own voxel types.
|
||||||
|
|
||||||
|
Some algorithms assume that basic mathematical operations can be applied to voxel types. For example, the LowPassFilter needs to compute the average of a set of voxels, and to do this it needs to be possible to add voxels together and divide by an integer. Obviously these operations are provided by primitive types, but it means that if you want to use the LowPassfilter on custom voxel types then these types need to provide operator+=, operator/=, etc. These have been added to the Density and MaterialDensityPair classes, but not to the Material class. This reflects the fact that applying a low pass filter to a material volume does not make conceptual sense.
|
||||||
|
|
||||||
|
Changes to build system
|
||||||
|
-----------------------
|
||||||
|
In order to make the build system easier to use, a number of CMake variables were changed to be more consistent. See :doc:`install` for details on the new variable naming.
|
||||||
|
|
||||||
|
Changes to CubicSurfaceExtractor
|
||||||
|
--------------------------------
|
||||||
|
The behaviour of the CubicSurfaceExtractor has been changed such that it no longer handles some edge cases. Because each generated quad lies between two voxels it can be unclear which region should 'own' a quad when the two voxels are from different regions. The previous version of the CubicSurfaceExtractor would attempt to handle this automatically, but as a result it was possible to get two quads existing at the same position in space. This can cause problems with transparency and with physics, as well as making it harder to decide which regions need to be updated when a voxel is changed.
|
||||||
|
|
||||||
|
The new system simplifies the behaviour of this surface extractor but does require a bit of care on the part of the user. You should be clear on the rules controlling when quads are generated and to which regions they will belong. To aid with this we have significantly improved the API documentation for the CubicSurfaceExtractor so be sure to have a look.
|
||||||
|
|
||||||
|
Changes to Raycast
|
||||||
|
------------------
|
||||||
|
The raycasting functionality was previously in a class (Raycast) but now it is provided by standalone functions. This is basically because there is no need for it to be a class, and it complicated usage. The new functions are called 'raycastWithDirection' and 'raycastWithEndpoints' which helps remove the previous ambiguity regarding the meaning of the two vectors which are passed as parameters.
|
||||||
|
|
||||||
|
The callback functionality (called for each processed voxel to determine whether to continue and also perform additional processing) is no longer implemented as an std::function. Instead the standard STL approach is used, in which a function or function object is used a a template parameter. This is faster than the std::function solution and should also be easier to integrate with other languages.
|
||||||
|
|
||||||
|
Usage of the new raycasting is demonstrated by a unit test.
|
||||||
|
|
||||||
|
Changes to AmbientOcclusionCalculator
|
||||||
|
-------------------------------------
|
||||||
|
The AmbientOcclusionCalculator has also been unclassed and is now called calculateAmbientOcclusion. The unit test has been updated to demonstrate the new usage.
|
||||||
|
|
||||||
|
Changes to A* pathfinder
|
||||||
|
------------------------
|
||||||
|
The A* pathfinder has always had different (but equally valid) results when building in Visual Studio vs. GCC. This is now fixed and results are consistent between platforms.
|
||||||
|
|
||||||
|
Copy and move semantics
|
||||||
|
-----------------------
|
||||||
|
All volume classes now have protected copy constructors and assignment operators to prevent you from accidentally copying them (which is expensive). Look at the VolumeResampler if you really do want to copy some volume data.
|
||||||
|
214
CMakeLists.txt
214
CMakeLists.txt
@ -1,127 +1,87 @@
|
|||||||
# Copyright (c) 2007-2012 Matt Williams
|
################################################################################
|
||||||
# Copyright (c) 2007-2012 David Williams
|
# The MIT License (MIT)
|
||||||
#
|
#
|
||||||
# This software is provided 'as-is', without any express or implied
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
#
|
||||||
# arising from the use of this software.
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
#
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
# in the Software without restriction, including without limitation the rights
|
||||||
# including commercial applications, and to alter it and redistribute it
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
# freely, subject to the following restrictions:
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
#
|
# furnished to do so, subject to the following conditions:
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
#
|
||||||
# claim that you wrote the original software. If you use this software
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
# copies or substantial portions of the Software.
|
||||||
# appreciated but is not required.
|
#
|
||||||
#
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# misrepresented as being the original software.
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
#
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# 3. This notice may not be removed or altered from any source
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# distribution.
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
|
################################################################################
|
||||||
|
|
||||||
PROJECT(PolyVox)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6)
|
||||||
|
|
||||||
SET(POLYVOX_VERSION_MAJOR "0")
|
PROJECT(PolyVox)
|
||||||
SET(POLYVOX_VERSION_MINOR "2")
|
|
||||||
SET(POLYVOX_VERSION_PATCH "1")
|
SET(POLYVOX_VERSION_MAJOR "0")
|
||||||
SET(POLYVOX_VERSION "${POLYVOX_VERSION_MAJOR}.${POLYVOX_VERSION_MINOR}.${POLYVOX_VERSION_PATCH}" CACHE STRING "PolyVox version")
|
SET(POLYVOX_VERSION_MINOR "2")
|
||||||
MARK_AS_ADVANCED(FORCE POLYVOX_VERSION)
|
SET(POLYVOX_VERSION_PATCH "1")
|
||||||
|
SET(POLYVOX_VERSION "${POLYVOX_VERSION_MAJOR}.${POLYVOX_VERSION_MINOR}.${POLYVOX_VERSION_PATCH}" CACHE STRING "PolyVox version")
|
||||||
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
|
MARK_AS_ADVANCED(FORCE POLYVOX_VERSION)
|
||||||
include(FeatureSummary)
|
|
||||||
|
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
FIND_PACKAGE(Doxygen)
|
include(FeatureSummary)
|
||||||
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)
|
|
||||||
|
IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") #Maybe "OR MINGW"
|
||||||
SET(LIBRARY_TYPE "DYNAMIC" CACHE STRING "Should the library be STATIC or DYNAMIC")
|
ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode
|
||||||
SET_PROPERTY(CACHE LIBRARY_TYPE PROPERTY STRINGS DYNAMIC STATIC)
|
ENDIF()
|
||||||
IF(WIN32)
|
|
||||||
SET(LIBRARY_TYPE "STATIC")
|
IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
ENDIF()
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
ENDIF()
|
||||||
# Qt is required for building the tests, the example and optionally for bundling the documentation
|
|
||||||
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL QtTest)
|
ADD_SUBDIRECTORY(include)
|
||||||
INCLUDE(${QT_USE_FILE})
|
|
||||||
if(CMAKE_VERSION VERSION_LESS "2.8.6")
|
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)
|
||||||
set_package_info(Doxygen "API documentation generator" http://www.doxygen.org "Building the API documentation")
|
IF(ENABLE_EXAMPLES)
|
||||||
set_package_info(Qt4 "C++ framework" http://qt-project.org "Building the examples and tests")
|
ADD_SUBDIRECTORY(examples)
|
||||||
else()
|
ELSE()
|
||||||
set_package_properties(Doxygen PROPERTIES URL http://www.doxygen.org DESCRIPTION "API documentation generator" TYPE OPTIONAL PURPOSE "Building the API documentation")
|
SET(BUILD_EXAMPLES OFF)
|
||||||
set_package_properties(Qt4 PROPERTIES DESCRIPTION "C++ framework" URL http://qt-project.org)
|
ENDIF()
|
||||||
set_package_properties(Qt4 PROPERTIES TYPE RECOMMENDED PURPOSE "Building the examples")
|
|
||||||
set_package_properties(Qt4 PROPERTIES TYPE OPTIONAL PURPOSE "Building the tests")
|
INCLUDE(Packaging.cmake)
|
||||||
endif()
|
|
||||||
|
OPTION(ENABLE_TESTS "Should the tests be built" ON)
|
||||||
if(MSVC AND (MSVC_VERSION LESS 1600))
|
IF(ENABLE_TESTS)
|
||||||
# Require boost for older (pre-vc2010) Visual Studio compilers
|
INCLUDE(CTest)
|
||||||
# See library/include/polyvoxcore/impl/TypeDef.h
|
MARK_AS_ADVANCED(FORCE BUILD_TESTING)
|
||||||
find_package(Boost REQUIRED)
|
ADD_SUBDIRECTORY(tests)
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
ELSE()
|
||||||
endif()
|
SET(BUILD_TESTS OFF)
|
||||||
|
ENDIF()
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX) #Maybe "OR MINGW"
|
|
||||||
ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode
|
ADD_SUBDIRECTORY(documentation)
|
||||||
ENDIF()
|
|
||||||
if(CMAKE_CXX_COMPILER MATCHES "clang")
|
ADD_SUBDIRECTORY(bindings)
|
||||||
ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode
|
|
||||||
endif()
|
add_feature_info("Examples" BUILD_EXAMPLES "Examples of PolyVox usage")
|
||||||
|
add_feature_info("Tests" BUILD_TESTS "Unit tests")
|
||||||
ADD_SUBDIRECTORY(library)
|
add_feature_info("Bindings" BUILD_BINDINGS "SWIG bindings")
|
||||||
|
add_feature_info("API docs" BUILD_DOCS "HTML documentation of the API")
|
||||||
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)
|
add_feature_info("Manual" BUILD_MANUAL "HTML user's manual")
|
||||||
IF(ENABLE_EXAMPLES AND QT_QTOPENGL_FOUND)
|
|
||||||
ADD_SUBDIRECTORY(examples/Basic)
|
feature_summary(WHAT ALL)
|
||||||
ADD_SUBDIRECTORY(examples/Paging)
|
|
||||||
ADD_SUBDIRECTORY(examples/OpenGL)
|
# Option summary
|
||||||
ADD_SUBDIRECTORY(examples/SmoothLOD)
|
MESSAGE(STATUS "")
|
||||||
SET(BUILD_EXAMPLES ON)
|
MESSAGE(STATUS "Summary")
|
||||||
ELSE()
|
MESSAGE(STATUS "-------")
|
||||||
SET(BUILD_EXAMPLES OFF)
|
MESSAGE(STATUS "Build examples: " ${BUILD_EXAMPLES})
|
||||||
ENDIF()
|
MESSAGE(STATUS "Build tests: " ${BUILD_TESTS})
|
||||||
|
MESSAGE(STATUS "Build bindings: " ${BUILD_BINDINGS})
|
||||||
INCLUDE(Packaging.cmake)
|
MESSAGE(STATUS "API Docs available: " ${BUILD_DOCS})
|
||||||
|
MESSAGE(STATUS "Build manual: " ${BUILD_MANUAL})
|
||||||
OPTION(ENABLE_TESTS "Should the tests be built" ON)
|
MESSAGE(STATUS "")
|
||||||
IF(ENABLE_TESTS AND QT_QTTEST_FOUND)
|
|
||||||
INCLUDE(CTest)
|
|
||||||
MARK_AS_ADVANCED(FORCE DART_TESTING_TIMEOUT) #This is only needed to hide the variable in the GUI (CMake bug) until 2.8.5
|
|
||||||
MARK_AS_ADVANCED(FORCE BUILD_TESTING)
|
|
||||||
ADD_SUBDIRECTORY(tests)
|
|
||||||
SET(BUILD_TESTS ON)
|
|
||||||
ELSE()
|
|
||||||
SET(BUILD_TESTS OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
#Check if we will building _and_ bundling the docs
|
|
||||||
IF(DOXYGEN_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
|
||||||
SET(BUILD_AND_BUNDLE_DOCS ON)
|
|
||||||
ELSE()
|
|
||||||
SET(BUILD_AND_BUNDLE_DOCS OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(documentation)
|
|
||||||
|
|
||||||
add_feature_info("Examples" BUILD_EXAMPLES "Examples of PolyVox usage")
|
|
||||||
add_feature_info("Tests" BUILD_TESTS "Unit tests")
|
|
||||||
add_feature_info("Bindings" BUILD_BINDINGS "SWIG bindings")
|
|
||||||
add_feature_info("API docs" DOXYGEN_FOUND "HTML documentation of the API")
|
|
||||||
add_feature_info("Qt Help" BUILD_AND_BUNDLE_DOCS "API docs in Qt Help format")
|
|
||||||
add_feature_info("Manual" BUILD_MANUAL "HTML user's manual")
|
|
||||||
|
|
||||||
feature_summary(WHAT ALL)
|
|
||||||
|
|
||||||
# Option summary
|
|
||||||
MESSAGE(STATUS "")
|
|
||||||
MESSAGE(STATUS "Summary")
|
|
||||||
MESSAGE(STATUS "-------")
|
|
||||||
MESSAGE(STATUS "Library type: " ${LIBRARY_TYPE})
|
|
||||||
MESSAGE(STATUS "Build examples: " ${BUILD_EXAMPLES})
|
|
||||||
MESSAGE(STATUS "Build tests: " ${BUILD_TESTS})
|
|
||||||
MESSAGE(STATUS "Build bindings: " ${BUILD_BINDINGS})
|
|
||||||
MESSAGE(STATUS "API Docs available: " ${DOXYGEN_FOUND})
|
|
||||||
MESSAGE(STATUS " - Qt Help bundling: " ${BUILD_AND_BUNDLE_DOCS})
|
|
||||||
MESSAGE(STATUS "Build manual: " ${BUILD_MANUAL})
|
|
||||||
MESSAGE(STATUS "")
|
|
||||||
|
10
CREDITS.txt
10
CREDITS.txt
@ -1,3 +1,7 @@
|
|||||||
David Williams - Lead programmer.
|
David Williams - Lead programmer.
|
||||||
Matthew Williams - Linux port, build system, support and maintenance.
|
Matthew Williams - Linux port, build system, support and maintenance.
|
||||||
Oliver Schneider - Very large Volumes
|
Oliver Schneider - Very large Volumes
|
||||||
|
|
||||||
|
Acknowledgements
|
||||||
|
----------------
|
||||||
|
PolyVox uses the 'miniz' for data compression. 'miniz' is public domain software and does not affect the license of PolyVox or of code using PolyVox. More details here: http://code.google.com/p/miniz/
|
@ -1,28 +1,31 @@
|
|||||||
# Copyright (c) 2010-2012 Matt Williams
|
################################################################################
|
||||||
#
|
# The MIT License (MIT)
|
||||||
# This software is provided 'as-is', without any express or implied
|
#
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
# arising from the use of this software.
|
#
|
||||||
#
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# including commercial applications, and to alter it and redistribute it
|
# in the Software without restriction, including without limitation the rights
|
||||||
# freely, subject to the following restrictions:
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
#
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
# furnished to do so, subject to the following conditions:
|
||||||
# claim that you wrote the original software. If you use this software
|
#
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# appreciated but is not required.
|
# copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# misrepresented as being the original software.
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# 3. This notice may not be removed or altered from any source
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# distribution.
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
set(CTEST_PROJECT_NAME "PolyVox")
|
# SOFTWARE.
|
||||||
set(CTEST_NIGHTLY_START_TIME "00:00:00 GMT")
|
################################################################################
|
||||||
|
|
||||||
set(CTEST_DROP_METHOD "http")
|
set(CTEST_PROJECT_NAME "PolyVox")
|
||||||
set(CTEST_DROP_SITE "my.cdash.org")
|
set(CTEST_NIGHTLY_START_TIME "00:00:00 GMT")
|
||||||
set(CTEST_DROP_LOCATION "/submit.php?project=PolyVox")
|
|
||||||
set(CTEST_DROP_SITE_CDASH TRUE)
|
set(CTEST_DROP_METHOD "http")
|
||||||
|
set(CTEST_DROP_SITE "my.cdash.org")
|
||||||
|
set(CTEST_DROP_LOCATION "/submit.php?project=PolyVox")
|
||||||
|
set(CTEST_DROP_SITE_CDASH TRUE)
|
||||||
|
265
INSTALL.txt
265
INSTALL.txt
@ -1,129 +1,136 @@
|
|||||||
****************
|
****************
|
||||||
Building PolyVox
|
Building PolyVox
|
||||||
****************
|
****************
|
||||||
|
|
||||||
Requirements
|
.. warning ::
|
||||||
============
|
Before reading this information, be aware that *you may not actually need to build PolyVox in order to use it*. PolyVox is a header-only library and in many cases it is sufficient to simply copy the ``include/PolyVox`` folder into your source tree. This folder contains all the PolyVox header files, and you can probably then include them directly with ``#include "PolyVox/SomeHeaderHere.h"`` without even needing to change your compiler search paths.
|
||||||
|
|
||||||
To build PolyVox you need:
|
That said, you *will* need to read the instructions below if you want to build the examples, tests, bindings or documentation which may be helpful in getting you started with PolyVox.
|
||||||
|
|
||||||
* `CMake <http://cmake.org>`_ 2.8.3 or greater
|
Requirements
|
||||||
* A C++ compiler with support for some C++0x features (GCC 4.3 or VC 2010 seem to work)
|
============
|
||||||
|
|
||||||
With the following optional packages:
|
To build PolyVox you need:
|
||||||
|
|
||||||
* `Qt <http://qt.nokia.com>`_ for building the tests and the example applications
|
* `CMake <http://cmake.org>`_ (tested on version 2.8.12.2, later versions should also work)
|
||||||
* ``qcollectiongenerator`` which comes with Qt Assistant is used for bundling the docs for installation
|
* A C++ compiler with support for some C++11 features (tested on GCC 4.8 and VC 2013)
|
||||||
* `Doxygen <http://doxygen.org>`_ for building the documentation. Version 1.5.7 is needed to build the Qt Assistant docs. 1.7.0 or greater is recommended
|
|
||||||
* `Python <http://python.org>`_, `Sphinx <http://sphinx.pocoo.org>`_ and `PyParsing <http://pyparsing.wikispaces.com/>`_ for generating the PolyVox manual in HTML
|
With the following optional packages:
|
||||||
* `Python development libraries <http://python.org>`_, `SWIG <http://swig.org/>`_ for generating the Python bindings
|
|
||||||
|
* `Qt version 5.2 of later <https://www.qt.io/>`_ for building the tests and the example applications
|
||||||
Linux
|
* ``qcollectiongenerator`` which comes with Qt Assistant is used for bundling the docs for installation
|
||||||
=====
|
* `Doxygen <http://doxygen.org>`_ for building the documentation. Version 1.5.7 is needed to build the Qt Assistant docs. 1.7.0 or greater is recommended
|
||||||
|
* `Python <http://python.org>`_, `Sphinx <http://sphinx.pocoo.org>`_ and `PyParsing <http://pyparsing.wikispaces.com/>`_ for generating the PolyVox manual in HTML
|
||||||
Navigate to the PolyVox source directory (the directory containing ``INSTALL.txt`` etc.) with and then enter the build directory with::
|
* Version 2 required - see note below.
|
||||||
|
* `Python development libraries <http://python.org>`_, `SWIG <http://swig.org/>`_ for generating the Python bindings
|
||||||
cd build
|
* Version 3 required - see note below.
|
||||||
|
|
||||||
CMake
|
.. note ::
|
||||||
-----
|
Currently we use different versions of Python for generating the documentation (version 2) vs. building the bindings (version 3). However, it is unlikely that you as a user will want to build the documentation as it is available online, or you can view the source *.rst files directly. But if you do want to build both the documentation and the bindings yourself then you will need both versions of Python installed.
|
||||||
|
|
||||||
Now, we use CMake to generate the makefiles with::
|
Linux
|
||||||
|
=====
|
||||||
cmake ..
|
|
||||||
|
Navigate to the PolyVox source directory (the directory containing ``INSTALL.txt`` etc.) with and then enter the build directory with::
|
||||||
The ``..`` tells CMake to look in the parent directory for the source.
|
|
||||||
|
cd build
|
||||||
By default this will set it to be installed in ``/usr/local`` so if you want to install it elsewhere, set the ``CMAKE_INSTALL_PREFIX`` variable to the path you want to install to.
|
|
||||||
|
CMake
|
||||||
You can set CMake variables by passing ``-D<variable>:<type>=<value>`` to the ``cmake`` command (the ``:<type>`` part is optional but recommended). For example, to set the install prefix, pass::
|
-----
|
||||||
|
|
||||||
-DCMAKE_INSTALL_PREFIX:PATH=/whatever/you/want
|
Now, we use CMake to generate the makefiles with::
|
||||||
|
|
||||||
The other available settings for PolyVox are:
|
cmake ..
|
||||||
|
|
||||||
``ENABLE_EXAMPLES`` (``ON`` or ``OFF``)
|
The ``..`` tells CMake to look in the parent directory for the source.
|
||||||
Build the example applications that come with PolyVox. Defaults to ``ON``.
|
|
||||||
|
By default this will set it to be installed in ``/usr/local`` so if you want to install it elsewhere, set the ``CMAKE_INSTALL_PREFIX`` variable to the path you want to install to.
|
||||||
``ENABLE_TESTS`` (``ON`` or ``OFF``)
|
|
||||||
Build the test applications that come with PolyVox. Running the tests is detailed in the next section. Defaults to ``ON``.
|
You can set CMake variables by passing ``-D<variable>:<type>=<value>`` to the ``cmake`` command (the ``:<type>`` part is optional but recommended). For example, to set the install prefix, pass::
|
||||||
|
|
||||||
``ENABLE_BINDINGS`` (``ON`` or ``OFF``)
|
-DCMAKE_INSTALL_PREFIX:PATH=/whatever/you/want
|
||||||
Should the Python bindings to PolyVox be built. This requires the Python development libraries and SWIG to be installed. Defaults to ``ON``.
|
|
||||||
|
The other available settings for PolyVox are:
|
||||||
``LIBRARY_TYPE`` (``DYNAMIC`` or ``STATIC``)
|
|
||||||
Choose whether static (``.a``) or dynamic libraries (``.so``) should be built. On Linux ``DYNAMIC`` is the default and on Windows ``STATIC`` is the default.
|
``ENABLE_EXAMPLES`` (``ON`` or ``OFF``)
|
||||||
|
Build the example applications that come with PolyVox. Defaults to ``ON``.
|
||||||
``CMAKE_BUILD_TYPE`` (``Debug``, ``Release``, ``RelWithDebInfo`` or ``MinSizeRel``)
|
|
||||||
String option to set the type of build. This will automatically set some compilation flags such as the optimisation level or define ``NDEBUG``.
|
``ENABLE_TESTS`` (``ON`` or ``OFF``)
|
||||||
|
Build the test applications that come with PolyVox. Running the tests is detailed in the next section. Defaults to ``ON``.
|
||||||
For development work against the library
|
|
||||||
Use ``Debug`` or ``RelWithDebInfo``
|
``ENABLE_BINDINGS`` (``ON`` or ``OFF``)
|
||||||
|
Should the Python bindings to PolyVox be built. This requires the Python development libraries and SWIG to be installed. Defaults to ``ON``.
|
||||||
For your final version
|
|
||||||
Use ``Release``
|
``CMAKE_BUILD_TYPE`` (``Debug``, ``Release``, ``RelWithDebInfo`` or ``MinSizeRel``)
|
||||||
|
String option to set the type of build. This will automatically set some compilation flags such as the optimisation level or define ``NDEBUG``.
|
||||||
For building packages (e.g. for Linux distributions)
|
|
||||||
Use ``RelWithDebInfo``
|
For development work against the library
|
||||||
|
Use ``Debug`` or ``RelWithDebInfo``
|
||||||
Building and installing
|
|
||||||
-----------------------
|
For your final version
|
||||||
|
Use ``Release``
|
||||||
Once this has completed successfully, simply run::
|
|
||||||
|
For building packages (e.g. for Linux distributions)
|
||||||
make install
|
Use ``RelWithDebInfo``
|
||||||
|
|
||||||
and all should work.
|
Building and installing
|
||||||
|
-----------------------
|
||||||
Testing
|
|
||||||
-------
|
Once this has completed successfully, simply run::
|
||||||
|
|
||||||
To run the tests you do not need to have run ``make install``. Simply run::
|
make install
|
||||||
|
|
||||||
make
|
and all should work.
|
||||||
make test
|
|
||||||
|
Testing
|
||||||
API Documentation
|
-------
|
||||||
-----------------
|
|
||||||
|
To run the tests you do not need to have run ``make install``. Simply run::
|
||||||
If you want to generate the API documentation, you'll need Doxygen installed. If you saw ``API Docs available: YES`` at the end of the CMake output then you're all set. To generate the docs, just run::
|
|
||||||
|
make
|
||||||
make doc
|
make test
|
||||||
|
|
||||||
and the documentation can be browsed in plain HTML form at ``<build directory>/library/doc/html/index.html``.
|
API Documentation
|
||||||
|
-----------------
|
||||||
On top of this, if ``qcollectiongenerator`` is installed, PolyVox can also compile and install this documentation as a *Qt Help Collection* file to ``<prefix>/share/doc/packages/polyvox/qthelp/polyvox.qhc`` (this file is in the build directory as ``<build directory>/library/doc/qthelp/polyvox.qhc``). To view this file you need Qt Assistant installed. You can open it with::
|
|
||||||
|
If you want to generate the API documentation, you'll need Doxygen installed. If you saw ``API Docs available: YES`` at the end of the CMake output then you're all set. To generate the docs, just run::
|
||||||
assistant -collectionFile library/doc/qthelp/polyvox.qhc
|
|
||||||
|
make doc
|
||||||
This allows indexed searching of the documentation and easier browsing.
|
|
||||||
|
and the documentation can be browsed in plain HTML form at ``<build directory>/library/doc/html/index.html``.
|
||||||
Manual
|
|
||||||
------
|
On top of this, if ``qcollectiongenerator`` is installed, PolyVox can also compile and install this documentation as a *Qt Help Collection* file to ``<prefix>/share/doc/packages/polyvox/qthelp/polyvox.qhc`` (this file is in the build directory as ``<build directory>/library/doc/qthelp/polyvox.qhc``). To view this file you need Qt Assistant installed. You can open it with::
|
||||||
|
|
||||||
As well as the API documentation, PolyVox also provides a user manual. This is written using `Sphinx <http://sphinx.pocoo.org>`_ and so to convert the documentation sources to HTML requires Sphinx and Python to be installed. If these are installed and found then you will see ``Build manual: YES`` in the CMake summary output. If this is the case then just run::
|
assistant -collectionFile library/doc/qthelp/polyvox.qhc
|
||||||
|
|
||||||
make manual
|
This allows indexed searching of the documentation and easier browsing.
|
||||||
|
|
||||||
and the HTML manual will be available at ``<build directory>/documentation/index.html``.
|
Manual
|
||||||
|
------
|
||||||
If you have Sphinx installed but you do not get the confirmation in the CMake output, you may need to set ``SPHINXBUILD_EXECUTABLE`` to the location of your ``sphinx-build`` executable.
|
|
||||||
|
As well as the API documentation, PolyVox also provides a user manual. This is written using `Sphinx <http://sphinx.pocoo.org>`_ and so to convert the documentation sources to HTML requires Sphinx and Python to be installed. If these are installed and found then you will see ``Build manual: YES`` in the CMake summary output. If this is the case then just run::
|
||||||
If you do not have Python and Sphinx installed and do not want to install them then the manual is just plain text (``.rst`` files) which are readable in their plain form in the ``documentation`` directory of the source distribution.
|
|
||||||
|
make manual
|
||||||
Windows
|
|
||||||
=======
|
and the HTML manual will be available at ``<build directory>/documentation/index.html``.
|
||||||
|
|
||||||
For information about the dependencies, CMake configuration variables and buildable targets look at the Linux build information in the section above.
|
If you have Sphinx installed but you do not get the confirmation in the CMake output, you may need to set ``SPHINXBUILD_EXECUTABLE`` to the location of your ``sphinx-build`` executable.
|
||||||
|
|
||||||
CMake
|
If you do not have Python and Sphinx installed and do not want to install them then the manual is just plain text (``.rst`` files) which are readable in their plain form in the ``documentation`` directory of the source distribution.
|
||||||
-----
|
|
||||||
|
Windows
|
||||||
You need CMake installed so get the binary distribution from `CMake.org <http://cmake.org/cmake/resources/software.html>`_. Install it and run the CMake GUI.
|
=======
|
||||||
|
|
||||||
Point the source directory to the directory holding this file and the build directory to the ``build`` subdirectory. Then, click the ``Configure`` button. Click through the dialog box that appears and once you've clicked ``Finish`` you should see text appearing in the bottom text area. Once this has finished, some options will appear in the top area. The purpose of these options in detailed in the Linux→CMake section above. Once you have set these options to what you please, click ``Configure`` again. If it completes without errors then you can click ``Generate`` which will generate your compilers project files in the build directory.
|
The earlier information about the dependencies, CMake configuration variables and buildable targets is still valid for Windows, so look at the Linux build information in the section above. Then see the notes below on using the CMake GUI.
|
||||||
|
|
||||||
Building
|
CMake
|
||||||
--------
|
-----
|
||||||
|
|
||||||
Open the project files in your IDE and build the project as you normally would.
|
You need CMake installed so get the binary distribution from `CMake.org <http://cmake.org/cmake/resources/software.html>`_. Install it and run the CMake GUI.
|
||||||
|
|
||||||
|
Point the source directory to the PolyVox root directory (the directory holding the 'INSTALL.txt' file) and the build directory to the ``build`` subdirectory. Then, click the ``Configure`` button. Click through the dialog box that appears and once you've clicked ``Finish`` you should see text appearing in the bottom text area. Once this has finished, some options will appear in the top area. The purpose of these options in detailed in the Linux→CMake section above. Once you have set these options to what you please, click ``Configure`` again. If it completes without errors then you can click ``Generate`` which will generate your compilers project files in the build directory.
|
||||||
|
|
||||||
|
Building
|
||||||
|
--------
|
||||||
|
|
||||||
|
Open the project files in your IDE and build the project as you normally would.
|
||||||
|
20
LICENSE.TXT
20
LICENSE.TXT
@ -1,20 +0,0 @@
|
|||||||
Copyright (c) 2005-2012 David Williams and Matthew Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 David Williams and Matthew Williams
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
113
Packaging.cmake
113
Packaging.cmake
@ -1,55 +1,58 @@
|
|||||||
# Copyright (c) 2009-2012 Matt Williams
|
################################################################################
|
||||||
#
|
# The MIT License (MIT)
|
||||||
# This software is provided 'as-is', without any express or implied
|
#
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
# arising from the use of this software.
|
#
|
||||||
#
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# including commercial applications, and to alter it and redistribute it
|
# in the Software without restriction, including without limitation the rights
|
||||||
# freely, subject to the following restrictions:
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
#
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
# furnished to do so, subject to the following conditions:
|
||||||
# claim that you wrote the original software. If you use this software
|
#
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# appreciated but is not required.
|
# copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# misrepresented as being the original software.
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# 3. This notice may not be removed or altered from any source
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# distribution.
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
#INCLUDE(InstallRequiredSystemLibraries)
|
# SOFTWARE.
|
||||||
|
################################################################################
|
||||||
SET(CPACK_PACKAGE_NAME "PolyVox SDK")
|
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "PolyVox SDK")
|
#INCLUDE(InstallRequiredSystemLibraries)
|
||||||
SET(CPACK_PACKAGE_VENDOR "Thermite 3D Team")
|
|
||||||
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
|
SET(CPACK_PACKAGE_NAME "PolyVox SDK")
|
||||||
#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "PolyVox SDK")
|
||||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${POLYVOX_VERSION_MAJOR})
|
SET(CPACK_PACKAGE_VENDOR "Thermite 3D Team")
|
||||||
SET(CPACK_PACKAGE_VERSION_MINOR ${POLYVOX_VERSION_MINOR})
|
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
|
||||||
SET(CPACK_PACKAGE_VERSION_PATCH ${POLYVOX_VERSION_PATCH})
|
#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
|
||||||
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "PolyVox SDK ${POLYVOX_VERSION}")
|
SET(CPACK_PACKAGE_VERSION_MAJOR ${POLYVOX_VERSION_MAJOR})
|
||||||
IF(WIN32 AND NOT UNIX)
|
SET(CPACK_PACKAGE_VERSION_MINOR ${POLYVOX_VERSION_MINOR})
|
||||||
# There is a bug in NSIS that does not handle full unix paths properly.
|
SET(CPACK_PACKAGE_VERSION_PATCH ${POLYVOX_VERSION_PATCH})
|
||||||
# Make sure there is at least one set of four backslashes.
|
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "PolyVox SDK ${POLYVOX_VERSION}")
|
||||||
#SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
|
IF(WIN32 AND NOT UNIX)
|
||||||
#SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
|
# There is a bug in NSIS that does not handle full unix paths properly.
|
||||||
SET(CPACK_NSIS_DISPLAY_NAME "PolyVox SDK ${POLYVOX_VERSION}")
|
# Make sure there is at least one set of four backslashes.
|
||||||
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\thermite3d.org/phpBB/")
|
#SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
|
||||||
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\thermite3d.org")
|
#SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
|
||||||
SET(CPACK_NSIS_CONTACT "matt@milliams.com")
|
SET(CPACK_NSIS_DISPLAY_NAME "PolyVox SDK ${POLYVOX_VERSION}")
|
||||||
SET(CPACK_NSIS_MODIFY_PATH ON)
|
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\thermite3d.org/phpBB/")
|
||||||
ELSE(WIN32 AND NOT UNIX)
|
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\thermite3d.org")
|
||||||
#SET(CPACK_STRIP_FILES "bin/MyExecutable")
|
SET(CPACK_NSIS_CONTACT "matt@milliams.com")
|
||||||
#SET(CPACK_SOURCE_STRIP_FILES "")
|
SET(CPACK_NSIS_MODIFY_PATH ON)
|
||||||
ENDIF(WIN32 AND NOT UNIX)
|
ELSE(WIN32 AND NOT UNIX)
|
||||||
#SET(CPACK_PACKAGE_EXECUTABLES "MyExecutable" "My Executable")
|
#SET(CPACK_STRIP_FILES "bin/MyExecutable")
|
||||||
|
#SET(CPACK_SOURCE_STRIP_FILES "")
|
||||||
INCLUDE(CPack)
|
ENDIF(WIN32 AND NOT UNIX)
|
||||||
|
#SET(CPACK_PACKAGE_EXECUTABLES "MyExecutable" "My Executable")
|
||||||
CPACK_ADD_COMPONENT(library DISPLAY_NAME "Library" DESCRIPTION "The runtime libraries" REQUIRED)
|
|
||||||
CPACK_ADD_COMPONENT(development DISPLAY_NAME "Development" DESCRIPTION "Files required for developing with PolyVox" DEPENDS library)
|
INCLUDE(CPack)
|
||||||
CPACK_ADD_COMPONENT(example DISPLAY_NAME "OpenGL Example" DESCRIPTION "A PolyVox example application using OpenGL" DEPENDS library)
|
|
||||||
cpack_add_component_group(bindings DISPLAY_NAME "Bindings" DESCRIPTION "Language bindings")
|
CPACK_ADD_COMPONENT(library DISPLAY_NAME "Library" DESCRIPTION "The runtime libraries" REQUIRED)
|
||||||
CPACK_ADD_COMPONENT(python DISPLAY_NAME "Python Bindings" DESCRIPTION "PolyVox bindings for the Python language" DISABLED GROUP bindings DEPENDS library)
|
CPACK_ADD_COMPONENT(development DISPLAY_NAME "Development" DESCRIPTION "Files required for developing with PolyVox" DEPENDS library)
|
||||||
|
CPACK_ADD_COMPONENT(example DISPLAY_NAME "OpenGL Example" DESCRIPTION "A PolyVox example application using OpenGL" DEPENDS library)
|
||||||
|
cpack_add_component_group(bindings DISPLAY_NAME "Bindings" DESCRIPTION "Language bindings")
|
||||||
|
CPACK_ADD_COMPONENT(python DISPLAY_NAME "Python Bindings" DESCRIPTION "PolyVox bindings for the Python language" DISABLED GROUP bindings DEPENDS library)
|
||||||
|
11
README.rst
11
README.rst
@ -1,5 +1,8 @@
|
|||||||
PolyVox - The voxel management and manipulation library
|
PolyVox - The voxel management and manipulation library
|
||||||
=======================================================
|
=======================================================
|
||||||
PolyVox is the core technology which lies behind our games. It is a fast, lightweight C++ library for the storage and processing of volumetric (voxel-based) environments. It has applications in both games and medical/scientific visualisation, and is released under the terms of the `zlib license <http://www.tldrlegal.com/l/ZLIB>`_.
|
.. attention ::
|
||||||
|
This system is no longer under active development. For more details please see this blog post: http://www.volumesoffun.com/wrapping-up-polyvox-development-to-focus-on-cubiquity-2/
|
||||||
|
|
||||||
|
PolyVox is the core technology which lies behind our games. It is a fast, lightweight C++ library for the storage and processing of volumetric (voxel-based) environments. It has applications in both games and medical/scientific visualisation, and is released under the terms of the `MIT license <https://www.tldrlegal.com/l/mit>`_.
|
||||||
|
|
||||||
PolyVox is a relatively low-level library, and you will need experience in C++ and computer graphics/shaders to use it effectively. It is designed to be easily integrated into existing applications and is independent of your chosen graphics API. For more details please see `this page <http://www.volumesoffun.com/polyvox-about/>`_ on our website.
|
PolyVox is a relatively low-level library, and you will need experience in C++ and computer graphics/shaders to use it effectively. It is designed to be easily integrated into existing applications and is independent of your chosen graphics API. For more details please see `this page <http://www.volumesoffun.com/polyvox-about/>`_ on our website.
|
130
TODO.txt
130
TODO.txt
@ -1,65 +1,65 @@
|
|||||||
Discussed on forums
|
Discussed on forums
|
||||||
===================
|
===================
|
||||||
Implement RLE compressor, and use it for blocks in memory and saving to disk.
|
Implement RLE compressor, and use it for blocks in memory and saving to disk.
|
||||||
Replace shared_ptr's with intrinsic_ptrs?
|
Replace shared_ptr's with intrinsic_ptrs?
|
||||||
Make decimator work with cubic mesh
|
Make decimator work with cubic mesh
|
||||||
Raycaster.
|
Raycaster.
|
||||||
|
|
||||||
Short term
|
Short term
|
||||||
==========
|
==========
|
||||||
Sort awkward use of 'offset'
|
Sort awkward use of 'offset'
|
||||||
Replace float with uchar for material.
|
Replace float with uchar for material.
|
||||||
Mesh smoothing (surface nets?)
|
Mesh smoothing (surface nets?)
|
||||||
Mesh filters/modifiers - A 'translate' modifier?
|
Mesh filters/modifiers - A 'translate' modifier?
|
||||||
|
|
||||||
|
|
||||||
For Version 1.0
|
For Version 1.0
|
||||||
===============
|
===============
|
||||||
Implement Memory Pool
|
Implement Memory Pool
|
||||||
Clean up normal code - make normal generation a seperate pass.
|
Clean up normal code - make normal generation a seperate pass.
|
||||||
Implement mesh smoothing.
|
Implement mesh smoothing.
|
||||||
Refine interface to mesh generateion - flags structure?
|
Refine interface to mesh generateion - flags structure?
|
||||||
Refine interface to volumes and iterators.
|
Refine interface to volumes and iterators.
|
||||||
Implement block volume tidy() funtion.
|
Implement block volume tidy() funtion.
|
||||||
Remove hard-coded region size.
|
Remove hard-coded region size.
|
||||||
Seperate namespaces - PolyVoxCore, PolyVoxUtil, PolyVoxImpl
|
Seperate namespaces - PolyVoxCore, PolyVoxUtil, PolyVoxImpl
|
||||||
Move getChangedRegionGeometry() out of PolyVon and into Thermite?
|
Move getChangedRegionGeometry() out of PolyVon and into Thermite?
|
||||||
Remove/refactor IndexedSurfacePatch? Incorporate into RegionGeometry?
|
Remove/refactor IndexedSurfacePatch? Incorporate into RegionGeometry?
|
||||||
Change vertex format to ints?
|
Change vertex format to ints?
|
||||||
Check licensing, #regions, etc.
|
Check licensing, #regions, etc.
|
||||||
Decimated version of marching cubes should use less memory.
|
Decimated version of marching cubes should use less memory.
|
||||||
Unit test - compare output to reference implementation
|
Unit test - compare output to reference implementation
|
||||||
Sort awkward use of 'offset' in decimated marching cubes.
|
Sort awkward use of 'offset' in decimated marching cubes.
|
||||||
Use of LinearVolume instead of arrays.
|
Use of LinearVolume instead of arrays.
|
||||||
Add API docs
|
Add API docs
|
||||||
Add manual
|
Add manual
|
||||||
Finish OpenGL sample.
|
Finish OpenGL sample.
|
||||||
VolumeChangeTracker can be more conservitive regarding when neighbouring regions are modified.
|
VolumeChangeTracker can be more conservitive regarding when neighbouring regions are modified.
|
||||||
|
|
||||||
For Version 2.0
|
For Version 2.0
|
||||||
===============
|
===============
|
||||||
Detect detatched regions.
|
Detect detatched regions.
|
||||||
Handle mesh generation for detatched regions.
|
Handle mesh generation for detatched regions.
|
||||||
Generate ambient lighting from volume?
|
Generate ambient lighting from volume?
|
||||||
Utility function for closing outside surfaces?
|
Utility function for closing outside surfaces?
|
||||||
Consider how seperate surface should be generated for a single region.
|
Consider how seperate surface should be generated for a single region.
|
||||||
Consider transparent materials like glass.
|
Consider transparent materials like glass.
|
||||||
Allow writing meshes into volumes?
|
Allow writing meshes into volumes?
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
=============
|
=============
|
||||||
Define the following terms:
|
Define the following terms:
|
||||||
-Voxel
|
-Voxel
|
||||||
-Cell
|
-Cell
|
||||||
-Volume
|
-Volume
|
||||||
-Region
|
-Region
|
||||||
-Block
|
-Block
|
||||||
|
|
||||||
Packaging
|
Packaging
|
||||||
=========
|
=========
|
||||||
Create components for the NSIS installer (Library, bindings, examples, documentation) - Half done
|
Create components for the NSIS installer (Library, bindings, examples, documentation) - Half done
|
||||||
Add License
|
Add License
|
||||||
Add images for installer (and icons)
|
Add images for installer (and icons)
|
||||||
Set LZMA compression
|
Set LZMA compression
|
||||||
Find a way to include both debug and release builds?
|
Find a way to include both debug and release builds?
|
||||||
The .lib files should be part of the 'development' configuration?
|
The .lib files should be part of the 'development' configuration?
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
%module Array
|
%module Array
|
||||||
%{
|
%{
|
||||||
#include "PolyVoxImpl\SubArray.h"
|
#include "PolyVoxImpl\SubArray.h"
|
||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "PolyVoxImpl\SubArray.h"
|
%include "PolyVoxImpl\SubArray.h"
|
||||||
%include "Array.h"
|
%include "Array.h"
|
||||||
|
|
||||||
%template(Array3IndexAndMaterial) PolyVox::Array<3, PolyVox::IndexAndMaterial>;
|
%template(Array3IndexAndMaterial) PolyVox::Array<3, PolyVox::IndexAndMaterial>;
|
8
bindings/BaseVolume.i
Normal file
8
bindings/BaseVolume.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module SimpleVolume
|
||||||
|
%{
|
||||||
|
#include "BaseVolume.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "BaseVolume.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(BaseVolume)
|
9
bindings/Block.i
Normal file
9
bindings/Block.i
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
%module Block
|
||||||
|
%{
|
||||||
|
#include "Block.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "Block.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(Block)
|
||||||
|
|
8
bindings/BlockCompressor.i
Normal file
8
bindings/BlockCompressor.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module BlockCompressor
|
||||||
|
%{
|
||||||
|
#include "BlockCompressor.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "BlockCompressor.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(BlockCompressor)
|
68
bindings/CMakeLists.txt
Normal file
68
bindings/CMakeLists.txt
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
################################################################################
|
||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
option(ENABLE_BINDINGS "Build bindings" OFF) #Off by default
|
||||||
|
if(ENABLE_BINDINGS)
|
||||||
|
find_package(SWIG)
|
||||||
|
mark_as_advanced(SWIG_DIR SWIG_VERSION)
|
||||||
|
find_package(PythonLibs 3)
|
||||||
|
if(CMAKE_VERSION VERSION_LESS "2.8.6")
|
||||||
|
set_package_info(SWIG "Bindings generator" http://www.swig.org)
|
||||||
|
set_package_info(PythonLibs "Programming language" http://www.python.org)
|
||||||
|
else()
|
||||||
|
set_package_properties(SWIG PROPERTIES DESCRIPTION "Bindings generator" URL http://www.swig.org)
|
||||||
|
set_package_properties(PythonLibs PROPERTIES DESCRIPTION "Programming language" URL http://www.python.org)
|
||||||
|
endif()
|
||||||
|
if(SWIG_FOUND)
|
||||||
|
set(BUILD_BINDINGS ON CACHE BOOL "Will the bindings be built" FORCE)
|
||||||
|
include(${SWIG_USE_FILE})
|
||||||
|
|
||||||
|
set(CMAKE_SWIG_FLAGS "")
|
||||||
|
set_source_files_properties(PolyVoxCore.i PROPERTIES CPLUSPLUS ON)
|
||||||
|
|
||||||
|
include_directories(${PolyVoxHeaders_SOURCE_DIR} ${PolyVoxHeaders_SOURCE_DIR}/PolyVox)
|
||||||
|
if(PYTHONLIBS_FOUND)
|
||||||
|
include_directories(${PYTHON_INCLUDE_PATH})
|
||||||
|
link_directories(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
|
#set_source_files_properties(PolyVoxCore.i PROPERTIES SWIG_FLAGS "-builtin")
|
||||||
|
set(SWIG_MODULE_PolyVoxCorePython_EXTRA_FLAGS "-py3")
|
||||||
|
swig_add_module(PolyVoxCorePython python PolyVoxCore.i)
|
||||||
|
swig_link_libraries(PolyVoxCorePython ${PYTHON_LIBRARIES})
|
||||||
|
set_target_properties(${SWIG_MODULE_PolyVoxCorePython_REAL_NAME} PROPERTIES OUTPUT_NAME _PolyVoxCore)
|
||||||
|
#set_target_properties(${SWIG_MODULE_PolyVoxCore_REAL_NAME} PROPERTIES SUFFIX ".pyd")
|
||||||
|
SET_PROPERTY(TARGET ${SWIG_MODULE_PolyVoxCorePython_REAL_NAME} PROPERTY FOLDER "Bindings")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SWIG_MODULE_PolyVoxCoreCSharp_EXTRA_FLAGS "-dllimport;PolyVoxCoreCSharp") #This _should_ be inside UseSWIG.cmake - http://www.cmake.org/Bug/view.php?id=13814
|
||||||
|
swig_add_module(PolyVoxCoreCSharp csharp PolyVoxCore.i)
|
||||||
|
swig_link_libraries(PolyVoxCoreCSharp)
|
||||||
|
SET_PROPERTY(TARGET ${SWIG_MODULE_PolyVoxCoreCSharp_REAL_NAME} PROPERTY FOLDER "Bindings")
|
||||||
|
else()
|
||||||
|
set(BUILD_BINDINGS OFF CACHE BOOL "Will the bindings be built" FORCE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(BUILD_BINDINGS OFF CACHE BOOL "Will the bindings be built" FORCE)
|
||||||
|
endif()
|
||||||
|
mark_as_advanced(FORCE BUILD_BINDINGS)
|
9
bindings/Chunk.i
Normal file
9
bindings/Chunk.i
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
%module Chunk
|
||||||
|
%{
|
||||||
|
#include "Chunk.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "Chunk.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(Chunk)
|
||||||
|
|
8
bindings/CompressedBlock.i
Normal file
8
bindings/CompressedBlock.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module CompressedBlock
|
||||||
|
%{
|
||||||
|
#include "CompressedBlock.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "CompressedBlock.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(CompressedBlock)
|
9
bindings/CubicSurfaceExtractor.i
Normal file
9
bindings/CubicSurfaceExtractor.i
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
%module CubicSurfaceExtractor
|
||||||
|
%{
|
||||||
|
#include "CubicSurfaceExtractor.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "CubicSurfaceExtractor.h"
|
||||||
|
|
||||||
|
%template(extractCubicMeshSimpleVolumeuint8) extractCubicMesh<PolyVox::PagedVolume<uint8_t> >;
|
||||||
|
//EXTRACTORS(CubicSurfaceExtractor)
|
8
bindings/CubicSurfaceExtractorWithNormals.i
Normal file
8
bindings/CubicSurfaceExtractorWithNormals.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module CubicSurfaceExtractorWithNormals
|
||||||
|
%{
|
||||||
|
#include "CubicSurfaceExtractorWithNormals.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "CubicSurfaceExtractorWithNormals.h"
|
||||||
|
|
||||||
|
%template(CubicSurfaceExtractorWithNormalsSimpleVolumeuint8) PolyVox::CubicSurfaceExtractorWithNormals<PolyVox::SimpleVolume<uint8_t>, PolyVox::DefaultIsQuadNeeded<uint8_t> >;
|
6
bindings/FilePager.i
Normal file
6
bindings/FilePager.i
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%module FilePager
|
||||||
|
%{
|
||||||
|
#include "FilePager.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "FilePager.h"
|
8
bindings/LargeVolume.i
Normal file
8
bindings/LargeVolume.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module LargeVolume
|
||||||
|
%{
|
||||||
|
#include "LargeVolume.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "LargeVolume.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(LargeVolume)
|
8
bindings/MarchingCubesSurfaceExtractor.i
Normal file
8
bindings/MarchingCubesSurfaceExtractor.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module MarchingCubesSurfaceExtractor
|
||||||
|
%{
|
||||||
|
#include "MarchingCubesSurfaceExtractor.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "MarchingCubesSurfaceExtractor.h"
|
||||||
|
|
||||||
|
EXTRACTORS(MarchingCubesSurfaceExtractor)
|
@ -5,5 +5,5 @@
|
|||||||
|
|
||||||
%include "MeshDecimator.h"
|
%include "MeshDecimator.h"
|
||||||
|
|
||||||
%template(MeshDecimatorMaterial8) PolyVox::MeshDecimator<PolyVox::Material8>;
|
%template(MeshDecimatorMaterial8) PolyVox::MeshDecimator<PolyVox::Material8>;
|
||||||
%template(MeshDecimatorDensity8) PolyVox::MeshDecimator<PolyVox::Density8>;
|
%template(MeshDecimatorDensity8) PolyVox::MeshDecimator<PolyVox::Density8>;
|
6
bindings/MinizBlockCompressor.i
Normal file
6
bindings/MinizBlockCompressor.i
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%module MinizBlockCompressor
|
||||||
|
%{
|
||||||
|
#include "MinizBlockCompressor.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "MinizBlockCompressor.h"
|
50
bindings/PagedVolume.i
Normal file
50
bindings/PagedVolume.i
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
%module PagedVolume
|
||||||
|
|
||||||
|
#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS
|
||||||
|
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
class PolyVox::PagedVolume_Chunk {
|
||||||
|
public:
|
||||||
|
PagedVolume_Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, PolyVox::PagedVolume_Pager* pPager = nullptr);
|
||||||
|
~PagedVolume_Chunk();
|
||||||
|
|
||||||
|
VoxelType* getData(void) const;
|
||||||
|
uint32_t getDataSizeInBytes(void) const;
|
||||||
|
|
||||||
|
VoxelType getVoxel(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const;
|
||||||
|
VoxelType getVoxel(const Vector3DUint16& v3dPos) const;
|
||||||
|
|
||||||
|
void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue);
|
||||||
|
void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
class PolyVox::PagedVolume_Pager {
|
||||||
|
public:
|
||||||
|
/// Constructor
|
||||||
|
PagedVolume_Pager() {};
|
||||||
|
/// Destructor
|
||||||
|
virtual ~PagedVolume_Pager() {};
|
||||||
|
|
||||||
|
virtual void pageIn(const Region& region, PagedVolume_Chunk* pChunk) = 0;
|
||||||
|
virtual void pageOut(const Region& region, PagedVolume_Chunk* pChunk) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "PagedVolume.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "PagedVolume.h"
|
||||||
|
|
||||||
|
%{
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
// SWIG thinks that Inner is a global class, so we need to trick the C++
|
||||||
|
// compiler into understanding this so called global type.
|
||||||
|
typedef PagedVolume<int8_t>::Pager PagedVolume_Pager;
|
||||||
|
typedef PagedVolume<int8_t>::Chunk PagedVolume_Chunk;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
VOLUMETYPES(PagedVolume)
|
6
bindings/Pager.i
Normal file
6
bindings/Pager.i
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%module Pager
|
||||||
|
%{
|
||||||
|
#include "Pager.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "Pager.h"
|
8
bindings/Picking.i
Normal file
8
bindings/Picking.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module Picking
|
||||||
|
%{
|
||||||
|
#include "Picking.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "Picking.h"
|
||||||
|
|
||||||
|
EXTRACTORS(pickVoxel)
|
93
bindings/PolyVoxCore.i
Normal file
93
bindings/PolyVoxCore.i
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
%module PolyVoxCore
|
||||||
|
|
||||||
|
#define POLYVOX_API
|
||||||
|
%include "Impl/PlatformDefinitions.h"
|
||||||
|
#define __attribute__(x) //Silence DEPRECATED errors
|
||||||
|
|
||||||
|
//This macro allows us to use Python properties on our classes
|
||||||
|
%define PROPERTY(type,name,getter,setter)
|
||||||
|
%extend type {
|
||||||
|
%pythoncode %{
|
||||||
|
__swig_getmethods__["name"] = getter
|
||||||
|
__swig_setmethods__["name"] = setter
|
||||||
|
if _newclass: name = property(getter, setter)
|
||||||
|
%}
|
||||||
|
};
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
//Put this in an %extend section to wrap operator<< as __str__
|
||||||
|
%define STR()
|
||||||
|
const char* __str__() {
|
||||||
|
std::ostringstream out;
|
||||||
|
out << *$self;
|
||||||
|
return out.str().c_str();
|
||||||
|
}
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
//Centralise this to avoid repeating ourselves
|
||||||
|
//This macro will be called in the volume interface files to define the various volume types.
|
||||||
|
%define VOLUMETYPES(class)
|
||||||
|
%template(class ## int8) PolyVox::class<int8_t>;
|
||||||
|
//%template(class ## int16) PolyVox::class<int16_t>;
|
||||||
|
//%template(class ## int32) PolyVox::class<int32_t>;
|
||||||
|
//%template(class ## uint8) PolyVox::class<uint8_t>;
|
||||||
|
//%template(class ## uint16) PolyVox::class<uint16_t>;
|
||||||
|
//%template(class ## uint32) PolyVox::class<uint32_t>;
|
||||||
|
//%template(class ## float) PolyVox::class<float>;
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
//Template based on voxel type
|
||||||
|
%define EXTRACTOR(class, volumetype)
|
||||||
|
%template(class ## volumetype ## int8) PolyVox::class<PolyVox::volumetype<int8_t> >;
|
||||||
|
//%template(class ## volumetype ## int16) PolyVox::class<PolyVox::volumetype<int16_t> >;
|
||||||
|
//%template(class ## volumetype ## int32) PolyVox::class<PolyVox::volumetype<int32_t> >;
|
||||||
|
//%template(class ## volumetype ## uint8) PolyVox::class<PolyVox::volumetype<uint8_t> >;
|
||||||
|
//%template(class ## volumetype ## uint16) PolyVox::class<PolyVox::volumetype<uint16_t> >;
|
||||||
|
//%template(class ## volumetype ## uint32) PolyVox::class<PolyVox::volumetype<uint32_t> >;
|
||||||
|
//%template(class ## volumetype ## float) PolyVox::class<PolyVox::volumetype<float> >;
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
//Template based on volume type
|
||||||
|
%define EXTRACTORS(shortname)
|
||||||
|
EXTRACTOR(shortname, PagedVolume)
|
||||||
|
EXTRACTOR(shortname, RawVolume)
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
%feature("autodoc", "1");
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
//This will rename "operator=" to "assign" since Python doesn't have assignment
|
||||||
|
%rename(assign) *::operator=;
|
||||||
|
#endif
|
||||||
|
#ifdef SWIGCSHARP
|
||||||
|
//These operators are not wrappable in C# and their function is provided by other means
|
||||||
|
%ignore *::operator=;
|
||||||
|
%ignore *::operator+=;
|
||||||
|
%ignore *::operator-=;
|
||||||
|
%ignore *::operator*=;
|
||||||
|
%ignore *::operator/=;
|
||||||
|
%ignore *::operator<<; //This is covered by STR()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%include "stdint.i"
|
||||||
|
%include "std_vector.i"
|
||||||
|
%include "Vector.i"
|
||||||
|
%include "DefaultMarchingCubesController.i"
|
||||||
|
%include "Region.i"
|
||||||
|
//%include "Chunk.i"
|
||||||
|
//%include "CompressedBlock.i"
|
||||||
|
//%include "UncompressedBlock.i"
|
||||||
|
//%include "BlockCompressor.i"
|
||||||
|
//%include "Pager.i"
|
||||||
|
//%include "FilePager.i"
|
||||||
|
//%include "MinizBlockCompressor.i"
|
||||||
|
//%include "RLEBlockCompressor.i"
|
||||||
|
%include "BaseVolume.i"
|
||||||
|
//%include "RawVolume.i"
|
||||||
|
//%include "PagedVolume.i"
|
||||||
|
//%include "VertexTypes.i"
|
||||||
|
//%include "SurfaceMesh.i"
|
||||||
|
////%include "MarchingCubesSurfaceExtractor.i"
|
||||||
|
////%include "CubicSurfaceExtractor.i"
|
||||||
|
//%include "Raycast.i"
|
||||||
|
//%include "Picking.i"
|
6
bindings/RLEBlockCompressor.i
Normal file
6
bindings/RLEBlockCompressor.i
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%module RLEBlockCompressor
|
||||||
|
%{
|
||||||
|
#include "RLEBlockCompressor.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "RLEBlockCompressor.h"
|
8
bindings/RawVolume.i
Normal file
8
bindings/RawVolume.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module RawVolume
|
||||||
|
%{
|
||||||
|
#include "RawVolume.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "RawVolume.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(RawVolume)
|
61
bindings/Raycast.i
Normal file
61
bindings/Raycast.i
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
%module Raycast
|
||||||
|
%{
|
||||||
|
#include "Raycast.h"
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
|
||||||
|
template<typename VolumeType>
|
||||||
|
class PyCallback
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
PyObject *func;
|
||||||
|
PyCallback& operator=(const PyCallback&); // Not allowed
|
||||||
|
public:
|
||||||
|
PyCallback(const PyCallback& o) : func(o.func)
|
||||||
|
{
|
||||||
|
Py_XINCREF(func);
|
||||||
|
}
|
||||||
|
PyCallback(PyObject *func) : func(func)
|
||||||
|
{
|
||||||
|
Py_XINCREF(this->func);
|
||||||
|
assert(PyCallable_Check(this->func));
|
||||||
|
}
|
||||||
|
~PyCallback()
|
||||||
|
{
|
||||||
|
Py_XDECREF(func);
|
||||||
|
}
|
||||||
|
bool operator()(const typename VolumeType::Sampler& sampler)
|
||||||
|
{
|
||||||
|
if (!func || Py_None == func || !PyCallable_Check(func))
|
||||||
|
{
|
||||||
|
return false; //Make this raise a Python exception
|
||||||
|
}
|
||||||
|
PyObject *args = Py_BuildValue("(l)", sampler.getVoxel()); //TODO pass the sampler object itself in
|
||||||
|
PyObject *result = PyObject_Call(func,args,0);
|
||||||
|
Py_DECREF(args);
|
||||||
|
Py_XDECREF(result);
|
||||||
|
return (PyInt_AsLong(result) == 0) ? false : true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename VolumeType, typename Callback>
|
||||||
|
PolyVox::RaycastResult raycastWithEndpointsPython(VolumeType* volData, const PolyVox::Vector3DFloat& v3dStart, const PolyVox::Vector3DFloat& v3dEnd, PyObject *callback)
|
||||||
|
{
|
||||||
|
PyCallback<VolumeType> newCallback(callback);
|
||||||
|
return PolyVox::raycastWithEndpoints(volData, v3dStart, v3dEnd, newCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "Raycast.h"
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
|
||||||
|
template<typename VolumeType, typename Callback>
|
||||||
|
PolyVox::RaycastResult raycastWithEndpointsPython(VolumeType* volData, const PolyVox::Vector3DFloat& v3dStart, const PolyVox::Vector3DFloat& v3dEnd, PyObject *callback);
|
||||||
|
|
||||||
|
%template(raycastWithEndpointsSimpleVolumeuint8) raycastWithEndpointsPython<PolyVox::SimpleVolume<uint8_t>, PyCallback<PolyVox::SimpleVolume<uint8_t> > >;
|
||||||
|
|
||||||
|
#endif
|
@ -4,6 +4,10 @@
|
|||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%extend PolyVox::Region {
|
||||||
|
STR()
|
||||||
|
};
|
||||||
|
|
||||||
%ignore depth;
|
%ignore depth;
|
||||||
%ignore height;
|
%ignore height;
|
||||||
%ignore width;
|
%ignore width;
|
8
bindings/SimpleVolume.i
Normal file
8
bindings/SimpleVolume.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module SimpleVolume
|
||||||
|
%{
|
||||||
|
#include "SimpleVolume.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "SimpleVolume.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(SimpleVolume)
|
@ -1,9 +1,9 @@
|
|||||||
%module SimpleVolumeSampler
|
%module SimpleVolumeSampler
|
||||||
%{
|
%{
|
||||||
#include "SimpleVolume.h"
|
#include "SimpleVolume.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "SimpleVolume.h"
|
%include "SimpleVolume.h"
|
||||||
|
|
||||||
%template(SimpleVolumeSamplerMaterial8) PolyVox::SimpleVolume::Sampler<PolyVox::Material8>;
|
%template(SimpleVolumeSamplerMaterial8) PolyVox::SimpleVolume::Sampler<PolyVox::Material8>;
|
||||||
%template(SimpleVolumeSamplerDensity8) PolyVox::SimpleVolume::Sampler<PolyVox::Density8>;
|
%template(SimpleVolumeSamplerDensity8) PolyVox::SimpleVolume::Sampler<PolyVox::Density8>;
|
@ -1,9 +1,9 @@
|
|||||||
%module SubArray
|
%module SubArray
|
||||||
%{
|
%{
|
||||||
#include "PolyVoxImpl\SubArray.h"
|
#include "PolyVoxImpl\SubArray.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "PolyVoxImpl\SubArray.h"
|
%include "PolyVoxImpl\SubArray.h"
|
||||||
|
|
||||||
//%template(SubArray) PolyVox::SubArray<uint32_t, PolyVox::IndexAndMaterial>;
|
//%template(SubArray) PolyVox::SubArray<uint32_t, PolyVox::IndexAndMaterial>;
|
||||||
//%template(SubArray) PolyVox::SubArray<uint32_t, PolyVox::IndexAndMaterial>;
|
//%template(SubArray) PolyVox::SubArray<uint32_t, PolyVox::IndexAndMaterial>;
|
20
bindings/SurfaceMesh.i
Normal file
20
bindings/SurfaceMesh.i
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
%module SurfaceMesh
|
||||||
|
%{
|
||||||
|
#include "Region.h"
|
||||||
|
#include "Vertex.h"
|
||||||
|
#include "Mesh.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "Region.h"
|
||||||
|
%include "Vertex.h"
|
||||||
|
%include "Mesh.h"
|
||||||
|
|
||||||
|
//%template(VertexTypeVector) std::vector<PolyVox::VertexType>;
|
||||||
|
//%template(PositionMaterialVector) std::vector<PolyVox::PositionMaterial>;
|
||||||
|
//%template(PositionMaterialNormalVector) std::vector<PolyVox::PositionMaterialNormal>;
|
||||||
|
//%template(LodRecordVector) std::vector<PolyVox::LodRecord>;
|
||||||
|
//%template(uint8Vector) std::vector<uint8_t>;
|
||||||
|
//%template(uint32Vector) std::vector<uint32_t>;
|
||||||
|
|
||||||
|
%template(MeshPositionMaterial) PolyVox::Mesh<PolyVox::CubicVertex<uint8_t>, uint16_t >;
|
||||||
|
%template(MeshPositionMaterialNormal) PolyVox::Mesh<PolyVox::MarchingCubesVertex<uint8_t>, uint16_t >;
|
@ -1,6 +1,6 @@
|
|||||||
%module TypeDef
|
%module TypeDef
|
||||||
%{
|
%{
|
||||||
#include "PolyVoxImpl/TypeDef.h"
|
#include "PolyVoxImpl/TypeDef.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "PolyVoxImpl/TypeDef.h"
|
%include "PolyVoxImpl/TypeDef.h"
|
8
bindings/UncompressedBlock.i
Normal file
8
bindings/UncompressedBlock.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module UncompressedBlock
|
||||||
|
%{
|
||||||
|
#include "UncompressedBlock.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "UncompressedBlock.h"
|
||||||
|
|
||||||
|
VOLUMETYPES(UncompressedBlock)
|
121
bindings/Vector.i
Normal file
121
bindings/Vector.i
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
%module Vector
|
||||||
|
%{
|
||||||
|
#include "Vector.h"
|
||||||
|
#include <sstream>
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "Vector.h"
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
PROPERTY(PolyVox::Vector, x, getX, setX)
|
||||||
|
PROPERTY(PolyVox::Vector, y, getY, setY)
|
||||||
|
PROPERTY(PolyVox::Vector, z, getZ, setZ)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%rename(Plus) operator +;
|
||||||
|
%rename(Minus) operator -;
|
||||||
|
%rename(Multiply) operator *;
|
||||||
|
%rename(Divide) operator /;
|
||||||
|
%rename(Equal) operator ==;
|
||||||
|
%rename(NotEqual) operator !=;
|
||||||
|
|
||||||
|
%extend PolyVox::Vector {
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
PolyVox::Vector __add__(const PolyVox::Vector& rhs) {
|
||||||
|
return *$self + rhs;
|
||||||
|
}
|
||||||
|
PolyVox::Vector __sub__(const PolyVox::Vector& rhs) {
|
||||||
|
return *$self - rhs;
|
||||||
|
}
|
||||||
|
PolyVox::Vector __div__(const PolyVox::Vector& rhs) {
|
||||||
|
return *$self / rhs;
|
||||||
|
}
|
||||||
|
PolyVox::Vector __div__(const StorageType& rhs) {
|
||||||
|
return *$self / rhs;
|
||||||
|
}
|
||||||
|
PolyVox::Vector __mul__(const PolyVox::Vector& rhs) {
|
||||||
|
return *$self * rhs;
|
||||||
|
}
|
||||||
|
PolyVox::Vector __mul__(const StorageType& rhs) {
|
||||||
|
return *$self * rhs;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
STR()
|
||||||
|
};
|
||||||
|
|
||||||
|
%feature("pythonprepend") PolyVox::Vector::operator< %{
|
||||||
|
import warnings
|
||||||
|
warnings.warn("deprecated", DeprecationWarning)
|
||||||
|
%}
|
||||||
|
|
||||||
|
//%csattributes PolyVox::Vector::operator< "[System.Obsolete(\"deprecated\")]"
|
||||||
|
|
||||||
|
%define VECTOR3(StorageType,OperationType,ReducedStorageType)
|
||||||
|
#if SWIGCSHARP
|
||||||
|
%extend PolyVox::Vector<3,StorageType,OperationType> {
|
||||||
|
PolyVox::Vector<3,StorageType,OperationType> operator+(const PolyVox::Vector<3,StorageType,OperationType>& rhs) {return *$self + rhs;}
|
||||||
|
PolyVox::Vector<3,StorageType,OperationType> operator-(const PolyVox::Vector<3,StorageType,OperationType>& rhs) {return *$self - rhs;}
|
||||||
|
PolyVox::Vector<3,StorageType,OperationType> operator*(const PolyVox::Vector<3,StorageType,OperationType>& rhs) {return *$self * rhs;}
|
||||||
|
PolyVox::Vector<3,StorageType,OperationType> operator/(const PolyVox::Vector<3,StorageType,OperationType>& rhs) {return *$self / rhs;}
|
||||||
|
PolyVox::Vector<3,StorageType,OperationType> operator*(const StorageType& rhs) {return *$self * rhs;}
|
||||||
|
PolyVox::Vector<3,StorageType,OperationType> operator/(const StorageType& rhs) {return *$self / rhs;}
|
||||||
|
};
|
||||||
|
%typemap(cscode) PolyVox::Vector<3,StorageType,OperationType> %{
|
||||||
|
public static Vector3D##StorageType operator+(Vector3D##StorageType lhs, Vector3D##StorageType rhs) {
|
||||||
|
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||||
|
newVec = lhs.Plus(rhs);
|
||||||
|
return newVec;
|
||||||
|
}
|
||||||
|
public static Vector3D##StorageType operator-(Vector3D##StorageType lhs, Vector3D##StorageType rhs) {
|
||||||
|
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||||
|
newVec = lhs.Minus(rhs);
|
||||||
|
return newVec;
|
||||||
|
}
|
||||||
|
public static Vector3D##StorageType operator*(Vector3D##StorageType lhs, Vector3D##StorageType rhs) {
|
||||||
|
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||||
|
newVec = lhs.Multiply(rhs);
|
||||||
|
return newVec;
|
||||||
|
}
|
||||||
|
public static Vector3D##StorageType operator/(Vector3D##StorageType lhs, Vector3D##StorageType rhs) {
|
||||||
|
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||||
|
newVec = lhs.Divide(rhs);
|
||||||
|
return newVec;
|
||||||
|
}
|
||||||
|
public static Vector3D##StorageType operator*(Vector3D##StorageType lhs, $typemap(cstype, StorageType) rhs) {
|
||||||
|
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||||
|
newVec = lhs.Multiply(rhs);
|
||||||
|
return newVec;
|
||||||
|
}
|
||||||
|
public static Vector3D##StorageType operator/(Vector3D##StorageType lhs, $typemap(cstype, StorageType) rhs) {
|
||||||
|
Vector3D##StorageType newVec = new Vector3D##StorageType();
|
||||||
|
newVec = lhs.Divide(rhs);
|
||||||
|
return newVec;
|
||||||
|
}
|
||||||
|
public bool Equals(Vector3D##StorageType rhs) {
|
||||||
|
if ((object)rhs == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Equal(rhs);
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::operator<; //This is deprecated
|
||||||
|
#endif
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::Vector(ReducedStorageType,ReducedStorageType,ReducedStorageType,ReducedStorageType);
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::Vector(ReducedStorageType,ReducedStorageType);
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::getW() const;
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::setW(ReducedStorageType);
|
||||||
|
%ignore PolyVox::Vector<3,StorageType,OperationType>::setElements(ReducedStorageType,ReducedStorageType,ReducedStorageType,ReducedStorageType);
|
||||||
|
%template(Vector3D ## StorageType) PolyVox::Vector<3,StorageType,OperationType>;
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
VECTOR3(float,float,float)
|
||||||
|
VECTOR3(double,double,double)
|
||||||
|
VECTOR3(int8_t,int32_t,signed char)
|
||||||
|
VECTOR3(uint8_t,int32_t,unsigned char)
|
||||||
|
VECTOR3(int16_t,int32_t,signed short)
|
||||||
|
VECTOR3(uint16_t,int32_t,unsigned short)
|
||||||
|
VECTOR3(int32_t,int32_t,signed int)
|
||||||
|
VECTOR3(uint32_t,int32_t,unsigned int)
|
||||||
|
|
||||||
|
//%rename(assign) Vector3DFloat::operator=;
|
@ -1,13 +1,13 @@
|
|||||||
%module VertexTypes
|
%module VertexTypes
|
||||||
%{
|
%{
|
||||||
#include "Impl/TypeDef.h"
|
#include "Impl/TypeDef.h"
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
#include "VertexTypes.h"
|
#include "Vertex.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "Impl/TypeDef.h"
|
%include "Impl/TypeDef.h"
|
||||||
%include "Vector.h"
|
%include "Vector.h"
|
||||||
%include "VertexTypes.h"
|
%include "Vertex.h"
|
||||||
|
|
||||||
//%template (PositionMaterial) PolyVox::PositionMaterial;
|
//%template (PositionMaterial) PolyVox::PositionMaterial;
|
||||||
//%template (PositionMaterialNormal) PolyVox::PositionMaterialNormal;
|
//%template (PositionMaterialNormal) PolyVox::PositionMaterialNormal;
|
@ -1,49 +1,52 @@
|
|||||||
# Copyright (c) 2010-2012 Matt Williams
|
################################################################################
|
||||||
#
|
# The MIT License (MIT)
|
||||||
# This software is provided 'as-is', without any express or implied
|
#
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
# arising from the use of this software.
|
#
|
||||||
#
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# including commercial applications, and to alter it and redistribute it
|
# in the Software without restriction, including without limitation the rights
|
||||||
# freely, subject to the following restrictions:
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
#
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
# furnished to do so, subject to the following conditions:
|
||||||
# claim that you wrote the original software. If you use this software
|
#
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# appreciated but is not required.
|
# copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# misrepresented as being the original software.
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# 3. This notice may not be removed or altered from any source
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# distribution.
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
find_program(SPHINXBUILD_EXECUTABLE sphinx-build DOC "The location of the sphinx-build executable")
|
# SOFTWARE.
|
||||||
|
################################################################################
|
||||||
#if(SPHINXBUILD_EXECUTABLE AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
|
||||||
if(SPHINXBUILD_EXECUTABLE)
|
find_program(SPHINXBUILD_EXECUTABLE sphinx-build DOC "The location of the sphinx-build executable")
|
||||||
message(STATUS "Found `sphinx-build` at ${SPHINXBUILD_EXECUTABLE}")
|
|
||||||
set(BUILD_MANUAL ON PARENT_SCOPE)
|
#if(SPHINXBUILD_EXECUTABLE AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||||
|
if(SPHINXBUILD_EXECUTABLE)
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.in.py ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
|
message(STATUS "Found `sphinx-build` at ${SPHINXBUILD_EXECUTABLE}")
|
||||||
#Generates the HTML docs and the Qt help file which can be opened with "assistant -collectionFile thermite.qhc"
|
set(BUILD_MANUAL ON PARENT_SCOPE)
|
||||||
#add_custom_target(manual ${SPHINXBUILD_EXECUTABLE} -b qthelp ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${QT_QCOLLECTIONGENERATOR_EXECUTABLE} polyvox.qhcp -o polyvox.qhc)
|
|
||||||
add_custom_target(manual
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.in.py ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
|
||||||
${SPHINXBUILD_EXECUTABLE} -b html
|
#Generates the HTML docs and the Qt help file which can be opened with "assistant -collectionFile thermite.qhc"
|
||||||
-c ${CMAKE_CURRENT_BINARY_DIR} #Load the conf.py from the binary dir
|
#add_custom_target(manual ${SPHINXBUILD_EXECUTABLE} -b qthelp ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${QT_QCOLLECTIONGENERATOR_EXECUTABLE} polyvox.qhcp -o polyvox.qhc)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
add_custom_target(manual
|
||||||
COMMENT "Building PolyVox manual"
|
${SPHINXBUILD_EXECUTABLE} -b html
|
||||||
)
|
-c ${CMAKE_CURRENT_BINARY_DIR} #Load the conf.py from the binary dir
|
||||||
add_dependencies(manual doc)
|
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
set_target_properties(manual PROPERTIES PROJECT_LABEL "Manual") #Set label seen in IDE
|
COMMENT "Building PolyVox manual"
|
||||||
SET_PROPERTY(TARGET manual PROPERTY FOLDER "Documentation")
|
)
|
||||||
else()
|
add_dependencies(manual doc)
|
||||||
if(NOT SPHINXBUILD_EXECUTABLE)
|
set_target_properties(manual PROPERTIES PROJECT_LABEL "Manual") #Set label seen in IDE
|
||||||
message(STATUS "`sphinx-build` was not found. Try setting SPHINXBUILD_EXECUTABLE to its location.")
|
SET_PROPERTY(TARGET manual PROPERTY FOLDER "Documentation")
|
||||||
endif()
|
else()
|
||||||
if(NOT QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
if(NOT SPHINXBUILD_EXECUTABLE)
|
||||||
message(STATUS "`qhelpgenerator` was not found. Try setting QT_QCOLLECTIONGENERATOR_EXECUTABLE to its location.")
|
message(STATUS "`sphinx-build` was not found. Try setting SPHINXBUILD_EXECUTABLE to its location.")
|
||||||
endif()
|
endif()
|
||||||
set(BUILD_MANUAL OFF PARENT_SCOPE)
|
if(NOT QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||||
endif()
|
message(STATUS "`qhelpgenerator` was not found. Try setting QT_QCOLLECTIONGENERATOR_EXECUTABLE to its location.")
|
||||||
|
endif()
|
||||||
|
set(BUILD_MANUAL OFF PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
70
documentation/ErrorHandling.rst
Normal file
70
documentation/ErrorHandling.rst
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
**************
|
||||||
|
Error Handling
|
||||||
|
**************
|
||||||
|
PolyVox includes a number of error handling features designed to help you identify and/or recover from problematic scenarios. This document describes these features and how they affect you as a user of the library.
|
||||||
|
|
||||||
|
Logging
|
||||||
|
=======
|
||||||
|
PolyVox has a simple logging mechanism which allows it to write messages with an associated severity (from Debug up to Fatal). This logging mechanism is not really intended for use by client code (i.e. calling the logging macros from your own application) but you can of course do so at your own risk. However, it is possible to redirect the output of these logging functions so you can integrate them with your application's logging framework or suppress them completely.
|
||||||
|
|
||||||
|
Fatal messages are only issued in non-recoverable scenarios when the application is about to crash, and may provide the last piece of information you have about what went wrong. Error messages are issued when something has happened which prevents successful completion of a task, for example if you provide invalid parameters to a function (error messages are also issued whenever an exception is thrown). Warning messages mean the system was able to continue but the results may not be what you expected. Info messages are used for general information about what PolyVox is doing. Debug and trace messages produce very verbose output and a lot of detail about what PolyVox is doing internally. In general, debug messages are used for tasks the user has directly initiated (e.g. they might provide timing information for surface extraction) while trace messages are used for things which happen spontaneously (such as data being paged out of memory).
|
||||||
|
|
||||||
|
To redirect log messages you can subclass Logger, create an instance, and set it as active as follows:
|
||||||
|
|
||||||
|
.. sourcecode :: c++
|
||||||
|
|
||||||
|
class CustomLogger : public Logger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CustomLogger() : Logger() {}
|
||||||
|
virtual ~CustomLogger() {}
|
||||||
|
|
||||||
|
void logTraceMessage(const std::string& message) { /* Do something with the message */ }
|
||||||
|
void logDebugMessage(const std::string& message) { /* Do something with the message */ }
|
||||||
|
void logInfoMessage(const std::string& message) { /* Do something with the message */ }
|
||||||
|
void logWarningMessage(const std::string& message) { /* Do something with the message */ }
|
||||||
|
void logErrorMessage(const std::string& message) { /* Do something with the message */ }
|
||||||
|
void logFatalMessage(const std::string& message) { /* Do something with the message */ }
|
||||||
|
};
|
||||||
|
|
||||||
|
CustomLogger* myCustomLogger = new CustomLogger();
|
||||||
|
|
||||||
|
setLogger(myCustomLogger);
|
||||||
|
|
||||||
|
Note that the default implementation (DefaultLogger) sends the fatal, error and warning streams to std::cerr, the info stream to std:cout, and that the debug and trace streams are suppressed.
|
||||||
|
|
||||||
|
PolyVox logging can be disabled completely in Config.h by undefining POLYVOX_LOG_TRACE_ENABLED through to POLYVOX_LOG_FATAL_ENABLED. Each of these can be disabled individually and the corresponding code will then be completely stripped from PolyVox. This is a compile-time setting - if you wish to change the log level at run-time then in your own implementation you could implement a filtering mechanism which only does something with the messages if some 'log severity' setting is greater than a certain threshold which can be changed at runtime.
|
||||||
|
|
||||||
|
Exceptions
|
||||||
|
==========
|
||||||
|
Error handling in PolyVox is provided by using the C++ exception mechanism. Exceptions can be thrown for a variety of reasons and your code should be prepared to handle them to prevent your application from crashing. It is possible to disable the throwing of exceptions if they are not supported by your compiler.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
Most functions in PolyVox will validate their input parameters and throw an exception if the provided values do not meet the function's requirements (which should be specified in the API documentation). However, in certain performance critical cases we choose not to spend time validating the parameters and an exception will not be thrown, though we do still use an assertion if these are enabled.
|
||||||
|
|
||||||
|
The most notable example of this is when accessing volume data through the get/setVoxel() functions, as these are designed to be very fast. Validating an input position would require multiple conditional operations which we chose to avoid. Therefore, **accessing a voxel outside of a volume will cause undefined behaviour.**
|
||||||
|
|
||||||
|
Disabling exceptions
|
||||||
|
--------------------
|
||||||
|
Some platforms may not support the use of C++ exceptions (older Android SDKs are the only place we have seen this) so you may need to disable them completely. This is highly undesirable but you may have no choice. To do this you should undefine 'POLYVOX_THROW_ENABLED' in Config.h (we may expose this through CMake in the future).
|
||||||
|
|
||||||
|
If exceptions are disabled then PolyVox will call a 'ThrowHandler' instead of throwing an exception. This is defined as follows:
|
||||||
|
|
||||||
|
.. sourcecode :: c++
|
||||||
|
|
||||||
|
typedef void (*ThrowHandler)(std::exception& e, const char* file, int line);
|
||||||
|
|
||||||
|
The default throw handler will print an error and then terminate, but you can provide a custom throw handler matching the function definition above:
|
||||||
|
|
||||||
|
.. sourcecode :: c++
|
||||||
|
|
||||||
|
setThrowHandler(&myThrowHandler);
|
||||||
|
|
||||||
|
Asserts
|
||||||
|
=======
|
||||||
|
In addition to the C++ exception handling mechanism, PolyVox also makes use of assertions to verify the internal state of the library at various points. This functionality is provided by out own POLYVOX_ASSERT() macro rather than the standard C++ assert() as this has a number of advantages described `here <http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/>`_.
|
||||||
|
|
||||||
|
Assertions inside PolyVox are enabled by defining 'POLYVOX_ASSERTS_ENABLED' in Config.h and again we may expose this through CMake. Note that the presence of assertions is independant of whether you are building a debug or release version of your application.
|
||||||
|
|
||||||
|
As a user you are not really expected to encounter an assertion inside PolyVox - they are mostly there for our purposes as developers of the library. So if you hit one in PolyVox then there is a good chance it is a bug in the library, as user errors should have been prevented by throwing an exceptions. Again, there are exceptions to this rule as some speed-critical functions (getVoxel(), etc) do not validate their parameters.
|
@ -1,25 +1,25 @@
|
|||||||
**************************
|
**************************
|
||||||
Frequently Asked Questions
|
Frequently Asked Questions
|
||||||
**************************
|
**************************
|
||||||
|
|
||||||
Should I store my environment in a single big volume or break it down into several smaller ones?
|
Should I store my environment in a single big volume or break it down into several smaller ones?
|
||||||
------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------
|
||||||
In most cases you should store you data in a single big volume, unless you are sure you understand the implications of doing otherwise.
|
In most cases you should store you data in a single big volume, unless you are sure you understand the implications of doing otherwise.
|
||||||
|
|
||||||
Most algorithms in PolyVox operate on only a single volume (the exception to this are some of the image processing algorithms which use source and destination volumes, but even they use a *single* source and a *single* destination). The reason for this is that many algorithms require fast access to the neighbours of any given voxel. As an example, the surface extractors need to look at the neighbours of a voxel in order to determine whether triangles should be generated.
|
Most algorithms in PolyVox operate on only a single volume (the exception to this are some of the image processing algorithms which use source and destination volumes, but even they use a *single* source and a *single* destination). The reason for this is that many algorithms require fast access to the neighbours of any given voxel. As an example, the surface extractors need to look at the neighbours of a voxel in order to determine whether triangles should be generated.
|
||||||
|
|
||||||
PolyVox volumes make it easy to access these neighbours, but the situation gets complex on the edge of a volume because the neighbouring voxels may not exist. It is possible to define a border value (which will be returned whenever you try to read a voxel outside the volume) but this doesn't handle all scenarios in the desired way. Often the most practical solution is to make the volume slightly larger than the data it needs to contain, and then avoid having your algorithms go right to the edge.
|
PolyVox volumes make it easy to access these neighbours, but the situation gets complex on the edge of a volume because the neighbouring voxels may not exist. It is possible to define a border value (which will be returned whenever you try to read a voxel outside the volume) but this doesn't handle all scenarios in the desired way. Often the most practical solution is to make the volume slightly larger than the data it needs to contain, and then avoid having your algorithms go right to the edge.
|
||||||
|
|
||||||
Having established that edge cases can be problematic, we can now see that storing your data as a set of adjacent volumes is undesirable because these edge cases then exist throughout the data set. This causes a lot of problems such as gaps between pieces of extracted terrain or discontinuities in the computed normals.
|
Having established that edge cases can be problematic, we can now see that storing your data as a set of adjacent volumes is undesirable because these edge cases then exist throughout the data set. This causes a lot of problems such as gaps between pieces of extracted terrain or discontinuities in the computed normals.
|
||||||
|
|
||||||
The usual reason why people attempt to break their terrain into separate volumes is so that they can perform some more advanced memory management for very big terrain, for example by only loading particular volumes into memory when they are within a certain distance from the camera. However, this kind of paging behaviour is already implemented by the LargeVolume class. The LargeVolume internally stores its data as a set of blocks, and does it in such a way that it is able to perform neighbourhood access across block boundaries. Whenever you find yourself trying to break terrain data into separate volumes you should probably use the LargeVolume instead.
|
The usual reason why people attempt to break their terrain into separate volumes is so that they can perform some more advanced memory management for very big terrain, for example by only loading particular volumes into memory when they are within a certain distance from the camera. However, this kind of paging behaviour is already implemented by the PagedVolume class. The PagedVolume internally stores its data as a set of blocks, and does it in such a way that it is able to perform neighbourhood access across block boundaries. Whenever you find yourself trying to break terrain data into separate volumes you should probably use the PagedVolume instead.
|
||||||
|
|
||||||
Note that although you should only use a single volume for your data, it is still recommended that you split the mesh data into multiple pieces so that they can be culled against the view frustum, and so that you can update the smaller pieces more quickly when you need to. You can extract meshes from different parts of the volume by passing a Region to the surface extractor.
|
Note that although you should only use a single volume for your data, it is still recommended that you split the mesh data into multiple pieces so that they can be culled against the view frustum, and so that you can update the smaller pieces more quickly when you need to. You can extract meshes from different parts of the volume by passing a Region to the surface extractor.
|
||||||
|
|
||||||
Lastly, note that there are exceptions to the 'one volume' rule. An example might be if you had a number of planets in space, in which case each planet could safely be a separate volume. These planets never touch, and so the artifacts which would occur on volume boundaries do not cause a problem.
|
Lastly, note that there are exceptions to the 'one volume' rule. An example might be if you had a number of planets in space, in which case each planet could safely be a separate volume. These planets never touch, and so the artifacts which would occur on volume boundaries do not cause a problem.
|
||||||
|
|
||||||
Can I combine smooth meshes with cubic ones?
|
Can I combine smooth meshes with cubic ones?
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
We have never attempted to do this but in theory it should be possible. One option is simply to generate two meshes (one using the MarchingCubesSurfaceExtractor and the other using the CubicSurfaceExtractor) and render them on top of each other while allowing the depth buffer to resolve the intersections. Combining these two meshes into a single mesh is likely to be difficult as they use different vertex formats and have different texturing requirements (see the document on texture mapping).
|
We have never attempted to do this but in theory it should be possible. One option is simply to generate two meshes (one using extractMarchingCubesSurface() and the other using extractCubicSurface()) and render them on top of each other while allowing the depth buffer to resolve the intersections. Combining these two meshes into a single mesh is likely to be difficult as they use different vertex formats and have different texturing requirements (see the document on texture mapping).
|
||||||
|
|
||||||
An alternative possibility may be to create a new surface extractor based on the Surface Nets (link) algorithm. The idea here is that the mesh would start with a cubic shape, but as the net was stretched it would be smoothed. The degree of smoothing could be controlled by a voxel property which could allow the full range from cubic to smooth to exist in a single mesh. As mentioned above, this may mean that some extra work has to be put into a fragment shader which is capable of texturing this kind of mesh. Come by the forums of you want to discuss this further.
|
An alternative possibility may be to create a new surface extractor based on the Surface Nets (link) algorithm. The idea here is that the mesh would start with a cubic shape, but as the net was stretched it would be smoothed. The degree of smoothing could be controlled by a voxel property which could allow the full range from cubic to smooth to exist in a single mesh. As mentioned above, this may mean that some extra work has to be put into a fragment shader which is capable of texturing this kind of mesh. Come by the forums of you want to discuss this further.
|
@ -1,48 +1,42 @@
|
|||||||
***************
|
***************
|
||||||
Level of Detail
|
Level of Detail
|
||||||
***************
|
***************
|
||||||
When the PolyVox surface extractors are applied to volume data the resulting mesh can contain a very high number of triangles. For large voxel worlds this can cause both performance and memory problems. The performance problems occur due the the load on the vertex shader which has to process a large number of vertices, and also due to the setup costs of a large number of tiny (possibly sub-pixel) triangles. The memory costs result simply from having a large amount of data which does not actually contribute to the visual appearance of the scene.
|
When the PolyVox surface extractors are applied to volume data the resulting mesh can contain a very high number of triangles. For large voxel worlds this can cause both performance and memory problems. The performance problems occur due the the load on the vertex shader which has to process a large number of vertices, and also due to the setup costs of a large number of tiny (possibly sub-pixel) triangles. The memory costs result simply from having a large amount of data which does not actually contribute to the visual appearance of the scene.
|
||||||
|
|
||||||
For these reasons it is desirable to reduce the triangle count of the meshes as far as possible, especially as meshes move away from the camera. This document describes the various approaches which are available within PolyVox to achieve this. Generally these approaches are different for cubic meshes vs smooth meshes and so we address these cases separately.
|
For these reasons it is desirable to reduce the triangle count of the meshes as far as possible, especially as meshes move away from the camera. This document describes the various approaches which are available within PolyVox to achieve this. Generally these approaches are different for cubic meshes vs smooth meshes and so we address these cases separately.
|
||||||
|
|
||||||
Cubic Meshes
|
Cubic Meshes
|
||||||
============
|
============
|
||||||
A naive implementation of a cubic surface extractor would generate a mesh containing a quad for voxel face which lies on the boundary between a solid and an empty voxel. The CubicSurfaceExtractor is indeed capable of generating such a mesh, but it also provides the option to merge adjacent quads into a single quad subject to various conditions being satisfied (e.g. the faces must have the same material). This merging process drastically reduces the amount of geometry which must be drawn but does not modify the shape of the mesh. Because of these desirable properties such merging is performed by default, but it can be disabled if necessary.
|
A naive implementation of a cubic surface extractor would generate a mesh containing a quad for each voxel face which lies on the boundary between a solid and an empty voxel. Our extractCubicSurface() function is indeed capable of generating such a mesh, but it also provides the option to merge adjacent quads into a single quad subject to various conditions being satisfied (e.g. the faces must have the same material). This merging process drastically reduces the amount of geometry which must be drawn but does not modify the shape of the mesh. Because of these desirable properties such merging is performed by default, but it can be disabled if necessary.
|
||||||
|
|
||||||
To our knowledge the only drawback of performing this quad merging is that it can create T-junctions in the resulting mesh. T-junctions are an undesirable property of mesh geometry because they can cause tiny cracks (usually just seen as flickering pixels) to occur between quads. The figure below shows a mesh before quad merging, a mesh where the merged quads have caused T-junctions, and how the resulting rendering might look (note the single pixel holes along the quad border).
|
To our knowledge the only drawback of performing this quad merging is that it can create T-junctions in the resulting mesh. T-junctions are an undesirable property of mesh geometry because they can cause tiny cracks (usually just seen as flickering pixels) to occur between quads. Whether it's a problem in practice depends on hardware precision (16/32 bit), distance from origin, number of transforms which are applied, and probably a number of other factors. We have yet to investigate.
|
||||||
|
|
||||||
*Add figure here...*
|
We don't currently have a real solution to this problem. In Voxeliens the borders between voxels were darkened to simulate ambient occlusion and this had the desirable side effect of making any flickering pixels very hard to see. It's also possible that anti-aliasing strategies can reduce the problem, and storing vertex positions as integers may help as well. Lastly, it may be possible to construct some kind of post-process which would repair the image where it identifies single pixel discontinuities in the depth buffer.
|
||||||
|
|
||||||
Vertices C and D are supposed to lie exactly along the line which has A and B as its end points, so in theory the mesh should be valid and should render correctly. The reason T-junctions cause a problem in practice is due to limitations of the floating point number representation. Depending on the transformations which are applied, it may be that the positions of C and/or D can not be represented precisely enough to exactly lie on the line between A and B.
|
For more information on this topic we suggest the following article series: `Meshing in Voxel Engines <https://blackflux.wordpress.com/2014/02/23/meshing-in-voxel-engines-part-1/>`_
|
||||||
|
|
||||||
*Demo correct mesh. mention we don't have a solution to generate it.*
|
Smooth Meshes
|
||||||
|
=============
|
||||||
Whether it's a problem in practice depends on hardware precision (16/32 bit), distance from origin, number of transforms which are applied, and probably a number of other factors. We have yet to investigate.
|
Level of detail for smooth meshes is a lot more complex than for cubic ones, and we'll admit upfront that we do not currently have a good solution to this problem. None the less, we do have a couple of partial solutions which you might be able to use or adapt for your specific scenario.
|
||||||
|
|
||||||
We don't currently have a real solution to this problem. In Voxeliens the borders between voxels were darkened to simulate ambient occlusion and this had the desirable side effect of making any flickering pixels very hard to see. It's also possible that anti-aliasing strategies can reduce the problem, and storing vertex positions as integers may help as well. Lastly, it may be possible to construct some kind of post-process which would repair the image where it identifies single pixel discontinuities in the depth buffer.
|
Techniques for performing level of detail on smooth meshes basically fall into two categories. The first category involves reducing the resolution of the volume data and then running the surface extractor on the smaller volume. This naturally generates a lower detail mesh which must then be scaled up to match the other meshes in the scene. The second category involves generating the mesh at full detail and then using traditional mesh simplification techniques to reduces the number of triangles. Both techniques are explored in more detail below.
|
||||||
|
|
||||||
Smooth Meshes
|
Volume Reduction
|
||||||
=============
|
----------------
|
||||||
Level of detail for smooth meshes is a lot more complex than for cubic ones, and we'll admit upfront that we do not currently have a good solution to this problem. None the less, we do have a couple of partial solutions which you might be able to use or adapt for your specific scenario.
|
The VolumeResampler class can be used to copy volume data from a source region to a destination region, and it handles the resampling of the voxel values in the event that the source and destination regions are not the same size. This is exactly what we need for implementing level of detail and the principle is demonstrated by the SmoothLOD sample (see the documentation for the SmoothLOD sample for more information).
|
||||||
|
|
||||||
Techniques for performing level of detail on smooth meshes basically fall into two categories. The first category involves reducing the resolution of the volume data and then running the surface extractor on the smaller volume. This naturally generates a lower detail mesh which must then be scaled up to match the other meshes in the scene. The second category involves generating the mesh at full detail and then using traditional mesh simplification techniques to reduces the number of triangles. Both techniques are explored in more detail below.
|
One of the problems with this approach is that the lower resolution mesh does not *exactly* line up with the higher resolution mesh, and this can cause cracks to be visible where the two meshes meet. The SmoothLOD sample attempts to avoid this problem by overlapping the meshes slightly but this may not be effective in all situations or from all viewpoints.
|
||||||
|
|
||||||
Volume Reduction
|
An alternative is the `Transvoxel algorithm <http://www.terathon.com/voxels/>`_ developed by Eric Lengyel. This essentially extends the original Marching Cubes lookup table with additional entries which handle seamless transitions between LOD levels, and it is a very promising solution to level of detail for voxel terrain. At this point in time we do not have an implementation of this algorithm.
|
||||||
----------------
|
|
||||||
The VolumeResampler class can be used to copy volume data from a source region to a destination region, and it handles the resampling of the voxel values in the event that the source and destination regions are not the same size. This is exactly what we need for implementing level of detail and the principle is demonstrated by the SmoothLOD sample (see the documentation for the SmoothLOD sample for more information).
|
However, in all volume reduction approaches there is some uncertainty about how materials should be handled. Creating a lower resolution volume means that several voxel values from the high resolution volume need to be combined into a single value. For density values this is straightforward as a simple average gives good results, but it is not clear how this extends to material identifiers. Averaging them doesn't make sense, and it is hard to imagine an approach which would not lead to visible artifacts as LOD levels change. Perhaps the visible effects can be reduced by blending between two LOD levels, but more investigation needs to be done here.
|
||||||
|
|
||||||
One of the problems with this approach is that the lower resolution mesh does not *exactly* line up with the higher resolution mesh, and this can cause cracks to be visible where the two meshes meet. The SmoothLOD sample attempts to avoid this problem by overlapping the meshes slightly but this may not be effective in all situations or from all viewpoints.
|
Mesh Simplification
|
||||||
|
-------------------
|
||||||
An alternative is the Transvoxel algorithm (link) developed by Eric Lengyel. This essentially extends the original Marching Cubes lookup table with additional entries which handle seamless transitions between LOD levels, and it is a very promising solution to level of detail for voxel terrain. At this point in time we do not have an implementation of this algorithm but work is being undertaking in the area. For the latest developments see: http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=338
|
The other main approach is to generate the mesh at the full resolution and then reduce the number of triangles using a postprocessing step. This can draw on the large body of mesh simplification research and typically involves merging adjacent faces or collapsing vertices. When using this approach there are a couple of additional complications compared to the implementations which are normally seen.
|
||||||
|
|
||||||
However, in all volume reduction approaches there is some uncertainty about how materials should be handled. Creating a lower resolution volume means that several voxel values from the high resolution volume need to be combined into a single value. For density values this is straightforward as a simple average gives good results, but it is not clear how this extends to material identifiers. Averaging them doesn't make sense, and it is hard to imagine an approach which would not lead to visible artifacts as LOD levels change. Perhaps the visible effects can be reduced by blending between two LOD levels, but more investigation needs to be done here.
|
The first additional complication is that the decimation algorithm needs to preserve material boundaries so that they don't move between LOD levels. When choosing whether a particular simplification can be made (i.e deciding if one vertex can be collapsed on to another or whether two faces can be merged) a metric is usually used to determine how much the simplification would affect the visual appearance of the mesh. When working with smooth voxel meshes this metric needs to also consider the material identifiers.
|
||||||
|
|
||||||
Mesh Simplification
|
We also need to ensure that the metric preserves the geometric boundary of the mesh, so that no cracks are visible when a simplified mesh is placed next to an original one. Maintaining this geometric boundary can be difficult, as the straightforward approach of locking the edge vertices in place will tend to limit the amount of simplification which can be performed. Alternatively, cracks can be allowed to develop if they are later hidden through the use of 'skirts' around the resulting mesh.
|
||||||
-------------------
|
|
||||||
The other main approach is to generate the mesh at the full resolution and then reduce the number of triangles using a postprocessing step. This can draw on the large body of mesh simplification research (link to survey) and typically involves merging adjacent faces or collapsing vertices. When using this approach there are a couple of additional complications compared to the implementations which are normally seen.
|
PolyVox used to contain code for performing simplification of the smooth voxel meshes, but unfortunately it had significant performance and functionality issues and so it has been removed. We will instead investigate the use of external mesh simplification libraries and `OpenMesh <http://www.openmesh.org/>`_ may be a good candidate here.
|
||||||
|
|
||||||
The first additional complication is that the decimation algorithm needs to preserve material boundaries so that they don't move between LOD levels. When choosing whether a particular simplification can be made (i.e deciding if one vertex can be collapsed on to another or whether two faces can be merged) a metric is usually used to determine how much the simplification would affect the visual appearance of the mesh. When working with smooth voxel meshes this metric needs to also consider the material identifiers.
|
|
||||||
|
|
||||||
We also need to ensure that the metric preserves the geometric boundary of the mesh, so that no cracks are visible when a simplified mesh is place next to an original one. Maintaining this geometric boundary can be difficult, as the straightforward approach of locking the edge vertices in place will tend to limit the amount of simplification which can be performed. Alternatively, cracks can be allowed to develop if they are later hidden through the use of 'skirts' around the resulting mesh.
|
|
||||||
|
|
||||||
PolyVox used to contain code for performing simplification of the smooth voxel meshes, but unfortunately it had significant performance and functionality issues. Therefore it has been deprecated and it will be removed in a future version of the library. We will instead investigate the use of external mesh simplification libraries and OpenMesh (link) may be a good candidate here.
|
|
||||||
|
@ -1,45 +1,44 @@
|
|||||||
********
|
********
|
||||||
Lighting
|
Lighting
|
||||||
********
|
********
|
||||||
Lighting is an important part of creating a realistic scene, and fortunately most common lighting solutions can be easily applied to PolyVox meshes. In this document we describe how to implement dynamic lighting and ambient occlusion with PolyVox.
|
Lighting is an important part of creating a realistic scene, and fortunately most common lighting solutions can be easily applied to PolyVox meshes. In this document we describe how to implement dynamic lighting and ambient occlusion with PolyVox.
|
||||||
|
|
||||||
Dynamic Lighting
|
Dynamic Lighting
|
||||||
================
|
================
|
||||||
In general, any lighting solution for real-time 3D graphics should be directly applicable to PolyVox meshes.
|
In general, any lighting solution for real-time 3D graphics should be directly applicable to PolyVox meshes.
|
||||||
|
|
||||||
Normal Calculation for Smooth Meshes
|
Normal Calculation for Smooth Meshes
|
||||||
------------------------------------
|
------------------------------------
|
||||||
When working with smooth voxel terrain meshes, PolyVox provides vertex normals as part of the extracted surface mesh. A common approach for computing these normals would be to compute normals for each face in the mesh, and then compute the vertex normals as a weighted average of the normals of the faces which share it. Actually this is not the approach used by PolyVox, as PolyVox instead computes the vertex normals directly from the underlying volume data.
|
When working with smooth voxel terrain meshes, PolyVox provides vertex normals as part of the extracted surface mesh. A common approach for computing these normals would be to compute normals for each face in the mesh, and then compute the vertex normals as a weighted average of the normals of the faces which share it. Actually this is not the approach used by PolyVox, as PolyVox instead computes the vertex normals directly from the underlying volume data.
|
||||||
|
|
||||||
More specifically, PolyVox is able to compute the *gradient* of the volume data at any given point using well established image processing methods. The normalised gradient value is used as the vertex normal and in general it is smoother than the value computed by averaging neighbouring faces. Actually there are two approaches to this gradient computation known as *Central Differencing* and *Sobel Filter*. The central differencing approach is generally recommended but the Sobel filter can be used to obtain slightly smoother results but with lower performance. See the MarchingCubesSurfaceExtractor documentation for details on how to select between these (check this exists...).
|
More specifically, PolyVox is able to compute the *gradient* of the volume data at any given point using well established image processing methods. The normalised gradient value is used as the vertex normal and in general it is smoother than the value computed by averaging neighbouring faces.
|
||||||
|
|
||||||
Normal Calculation for Cubic Meshes
|
Normal Calculation for Cubic Meshes
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
For cubic meshes PolyVox doesn't actually generate any vertex normals at all, and this is often a source of confusion for new users. The reason for this is that we wish to to perform per-face lighting rather than per-vertex lighting. Considering the case of a single cube, if we wanted to perform per-face lighting based on per-vertex normals then the normals cannot be shared between adjacent faces and so each vertex needs to be duplicated three times (one for each face which uses it). This means we would need 24 vertices to represent a cube which intuitively should only need eight vertices.
|
For cubic meshes PolyVox doesn't actually generate any vertex normals at all, and this is often a source of confusion for new users. The reason for this is that we wish to to perform per-face lighting rather than per-vertex lighting. Considering the case of a single cube, if we wanted to perform per-face lighting based on per-vertex normals then the normals cannot be shared between adjacent faces and so each vertex needs to be duplicated three times (one for each face which uses it). This means we would need 24 vertices to represent a cube which intuitively should only need eight vertices.
|
||||||
|
|
||||||
Therefore PolyVox does not generate per-vertex normals for cubic meshes, and as a result the cubic mesh's vertices are both smaller and less numerous. Of course, we still need a way to obtain normals for lighting calculations and so our suggestion is to compute the normals in a fragment program using the *derivative operations* which are provided by modern graphics hardware.
|
Therefore PolyVox does not generate per-vertex normals for cubic meshes, and as a result the cubic mesh's vertices are both smaller and less numerous. Of course, we still need a way to obtain normals for lighting calculations and so our suggestion is to compute the normals in a fragment program using the *derivative operations* which are provided by modern graphics hardware.
|
||||||
|
|
||||||
The description here is rather oversimplified, but the idea behind these operation is that they can tell you how much a variable has changed between two adjacent pixels. If we use our fragment world space position as the input to these derivative operations then we can obtain two vectors which lie on the surface of our face. The cross product of these then gives us a vector which is perpendicular to both and which is therefore our normal.
|
The description here is rather oversimplified, but the idea behind these operations is that they can tell you how much a variable has changed between two adjacent pixels. If we use our fragment world space position as the input to these derivative operations then we can obtain two vectors which lie on the surface of our face. The cross product of these then gives us a vector which is perpendicular to both and which is therefore our normal.
|
||||||
|
|
||||||
Further information about the derivative operations can be found in the OpenGL/Direct3D API documentation, but the implementation in code is quite simple. Firstly you need to make sure that you have access to the fragments world space position in your shader, which means you need to pass it through from the vertex shader. Then you can use the following code in your fragment shader:
|
Further information about the derivative operations can be found in the OpenGL/Direct3D API documentation, but the implementation in code is quite simple. Firstly you need to make sure that you have access to the fragment's world space position in your shader, which means you need to pass it through from the vertex shader. Then you can use the following code in your fragment shader:
|
||||||
|
|
||||||
.. code-block:: glsl
|
.. sourcecode:: glsl
|
||||||
|
|
||||||
vec3 worldNormal = cross(dFdy(inWorldPosition.xyz), dFdx(inWorldPosition.xyz));
|
vec3 worldNormal = cross(dFdy(inWorldPosition.xyz), dFdx(inWorldPosition.xyz));
|
||||||
worldNormal = normalize(worldNormal);
|
worldNormal = normalize(worldNormal);
|
||||||
|
|
||||||
**TODO: Check the normal direction**
|
.. note ::
|
||||||
|
Depending on your graphics API and/or engine setup, you may actually need to flip the resulting normal.
|
||||||
Similar code can be implemented in HLSL but you may need to invert the normal due to coordinate system differences between the two APIs. Also, be aware that it may be necessary to use OpenGL ES XXX extension in order to access this derivative functionality on mobile hardware.
|
|
||||||
|
Shadows
|
||||||
Shadows
|
-------
|
||||||
-------
|
To date we have only experimented with shadow maps as a solution to the real time shadowing problem and have found they work very well for both casting and receiving. The approach is essentially the same as for any other geometry and the usual approaches can be used for setting up the projection and for filtering the result. One PolyVox specific tip we can give is that you don't need to take account of materials when rendering into the shadow map as you always draw in black, so if you are splitting you geometry for material blending or for handling a large number of materials then you don't need to do this when rendering shadows. Using separate shadow geometry with all materials combined may decrease your batch count in this case.
|
||||||
To date we have only experimented with shadow maps as a solution to the real time shadowing problem and have found they work very well for both casting and receiving. The approach is essentially the same as for any other geometry and the usual approaches can be used for setting up the projection and for filtering the result. One PolyVox specific tip we can give is that you don't need to take account of materials when rendering into the shadow map as you always draw in black, so if you are splitting you geometry for material blending or for handling a large number of materials then you don't need to do this when rendering shadows. Using separate shadow geometry with all materials combined may decrease your batch count in this case.
|
|
||||||
|
The most widely used alternative to shadow maps is shadow volumes but we have not tested these with PolyVox. We do not expect these will provide a good solution because meshes usually require additional edge information to allow the shadow volume to be extruded from the silhouette and PolyVox does not provide this. Even if this edge information could be calculated, it would be invalidated each time the mesh changed which would make dynamic terrain more difficult.
|
||||||
The most widely used alternative to shadow maps is shadow volumes but we have not tested these with PolyVox. We do not expect these will provide a good solution because meshes usually require additional edge information to allow the shadow volume to be extruded from the silhouette and PolyVox does not provide this. Even if this edge information could be calculated, it would be invalidated each time the mesh changed which would make dynamic terrain more difficult.
|
|
||||||
|
Overall we would recommend you make use of shadow maps for dynamic shadows.
|
||||||
Overall we would recommend you make use of shadow maps for dynamic shadows.
|
|
||||||
|
Ambient Occlusion
|
||||||
Ambient Occlusion
|
=================
|
||||||
=================
|
|
||||||
This is an area in which we want to undertake more research in order to get effective ambient occlusion into PolyVox scenes. In the mean time SSAO has proved to be a popular solution.
|
This is an area in which we want to undertake more research in order to get effective ambient occlusion into PolyVox scenes. In the mean time SSAO has proved to be a popular solution.
|
@ -1,4 +1,4 @@
|
|||||||
=================
|
=================
|
||||||
Modifying Terrain
|
Modifying Terrain
|
||||||
=================
|
=================
|
||||||
This document has yet to be written.
|
This document has yet to be written.
|
@ -1,38 +1,38 @@
|
|||||||
*************
|
*************
|
||||||
Prerequisites
|
Prerequisites
|
||||||
*************
|
*************
|
||||||
The PolyVox library is aimed at experienced games and graphics programmers who wish to incorporate voxel environments into their applications. It is not a drop in solution, but instead provides a set of building blocks which you can use to construct a complete system. Most of the functionality could be considered quite low-level. For example, it provides mesh extractors to generate a surface from volume data but requires the application developer to handle all tasks related to scene management and rendering of such data.
|
The PolyVox library is aimed at experienced games and graphics programmers who wish to incorporate voxel environments into their applications. It is not a drop in solution, but instead provides a set of building blocks which you can use to construct a complete system. Most of the functionality could be considered quite low-level. For example, it provides mesh extractors to generate a surface from volume data but requires the application developer to handle all tasks related to scene management and rendering of such data.
|
||||||
|
|
||||||
As a result you will need a decent amount of graphics programming experience to effectively make use of the library. The purpose of this document is to highlight some of the core areas with which you will need to be familiar. In some cases we also provide links to places where you can find more information about the subject in question.
|
As a result you will need a decent amount of graphics programming experience to effectively make use of the library. The purpose of this document is to highlight some of the core areas with which you will need to be familiar. In some cases we also provide links to places where you can find more information about the subject in question.
|
||||||
|
|
||||||
You should also be aware that voxel terrain is still an open research area and has not yet seen widespread adoption in games and simulations. There are many questions to which we do not currently know the best answer and so you may have to do some research and experimentation yourself when trying to obtain your desired result. Please do let us know if you come up with a trick or technique which you think could benefit other users.
|
You should also be aware that voxel terrain is still an open research area which is only just seeing widespread adoption in games and simulations. There are many questions to which we do not currently know the best answer and so you may have to do some research and experimentation yourself when trying to obtain your desired result. Please do let us know if you come up with a trick or technique which you think could benefit other users.
|
||||||
|
|
||||||
Programming
|
Programming
|
||||||
===========
|
===========
|
||||||
This section describes some of the programming concepts with which you will need to be familiar:
|
This section describes some of the programming concepts with which you will need to be familiar:
|
||||||
|
|
||||||
**C++:** PolyVox is written using the C++ language and we expect this is what the majority of our users will be developing in. You will need to be familiar with the basic process of building and linking against external libraries as well as setting up your development environment. Note that you do have the option of working with other languages via the SWIG bindings but you may not have as much flexibility with this approach.
|
**C++:** PolyVox is written using the C++ language and we expect this is what the majority of our users will be developing in. Note that you do have the option of working with other languages via the SWIG bindings but you may not have as much flexibility with this approach, and you will need to undertake additional work as the bindings are not currently complete.
|
||||||
|
|
||||||
**Templates:** PolyVox also makes heavy use of template programming in order to be both fast and generic, so familiarity with templates will be very useful. You shouldn't need to do much template programming yourself but an understanding of them will help you understand errors and resolve any problems.
|
**Templates:** PolyVox also makes heavy use of template programming in order to be both fast and generic, so familiarity with templates will be very useful. You shouldn't need to do much template programming yourself but an understanding of them will help you understand errors and resolve any problems.
|
||||||
|
|
||||||
**Callbacks:** Several of the algorithms in PolyVox can be customised through the use of callbacks. In general there are sensible defaults provided, but for maximum control you may wish to learn how to define you own. In general the principle is similar to the way in which callbacks are used in the STL.
|
**Callbacks:** Several of the algorithms in PolyVox can be customised through the use of callbacks. In general there are sensible defaults provided, but for maximum control you may wish to learn how to define you own. In general the principle is similar to the way in which callbacks are used in the STL.
|
||||||
|
|
||||||
Graphics Concepts
|
Graphics Concepts
|
||||||
=================
|
=================
|
||||||
Several core graphics principles will be useful in understanding and using PolyVox:
|
Several core graphics principles will be useful in understanding and using PolyVox:
|
||||||
|
|
||||||
**Volume representation:** PolyVox revolves around the idea of storing and manipulating volume data and using this as a representation of a 3d world. This is a fairly intuitive extension of traditional heightmap terrain but does require the ability to 'think in 3D'. You will need to understand that data stored in this way can become very large, and understand the idea that paging and compression can be used to combat this.
|
**Volume representation:** PolyVox revolves around the idea of storing and manipulating volume data and using this as a representation of a 3d world. This is a fairly intuitive extension of traditional heightmap terrain but does require the ability to 'think in 3D'. You will need to understand that data stored in this way can become very large, and understand the idea that paging and compression can be used to combat this.
|
||||||
|
|
||||||
**Mesh representation:** Most PolyVox projects will involve using one of the surface extractors, which output their data as index and vertex buffers. Therefore you will need to understand this representation in order to pass the data to your rendering engine or in order to perform further modifications to it. You can find out about more about this here: (ADD LINK)
|
**Mesh representation:** Most PolyVox projects will involve using one of the surface extractors, which output their data as index and vertex buffers. Therefore you will need to understand this representation in order to pass the data to your rendering engine or in order to perform further modifications to it. You can find out about more about this in the Wikipedia article on `Polygon Meshes <https://en.wikipedia.org/wiki/Polygon_mesh>`_
|
||||||
|
|
||||||
**Image processing:** For certain advanced application an understanding of image processing methods can be useful. For example the process of blurring an image via a low pass filter can be used to effectively smooth out voxel terrain. There are plans to add more image processing operations to PolyVox particularly with regard to morphological operations which you might want to use to modify your environment.
|
**Image processing:** For certain advanced applications an understanding of image processing methods can be useful. For example, the process of blurring an image via a low pass filter can be used to effectively smooth out voxel terrain. There are plans to add more image processing operations to PolyVox particularly with regard to morphological operations which you might want to use to modify your environment.
|
||||||
|
|
||||||
Rendering
|
Rendering
|
||||||
=========
|
=========
|
||||||
**Runtime geometry creation:** PolyVox is independent of any particular graphics API which means it outputs its data using API-neutral structures such as index and vertex buffers (as mentioned above). You will need to write the code which converts these structures into a format which your API or engine can understand. This is not a difficult task but does require some knowledge of the rendering technology which you are using.
|
**Runtime geometry creation:** PolyVox is independent of any particular graphics API which means it outputs its data using API-neutral structures such as index and vertex buffers (as mentioned above). You will need to write the code which converts these structures into a format which your API or engine can understand. This is not a difficult task but does require some knowledge of the rendering technology which you are using.
|
||||||
|
|
||||||
**Scene management:** PolyVox is only responsible for providing you with the mesh data to be displayed, so you application or engine will need to make sensible decisions about how this data should be organised in terms of a spatial structure (octree, bounding volumes tree, etc). It will also need to provide some approach to visibility determination such as frustum culling or a more advanced approach. If you are integrating PolyVox with an existing rendering engine then you should find that many of these aspects are already handled for you.
|
**Scene management:** PolyVox is only responsible for providing you with the mesh data to be displayed, so your application or engine will need to make sensible decisions about how this data should be organised in terms of a spatial structure (octree, bounding volumes tree, etc). It will also need to provide some approach to visibility determination such as frustum culling or a more advanced approach. If you are integrating PolyVox with an existing rendering engine then you should find that many of these aspects are already handled for you.
|
||||||
|
|
||||||
**Shader programming:** The meshes which are generated by PolyVox are very basic in terms of the vertex data they provide. You get vertex positions, a material identifier, and sometimes vertex normals. It is the responsibility of application programmer to decide how to use this data to create visually interesting renderings. This means you will almost certainly want to make use of shader programs. Of course, in our texturing (LINK) and lighting (LINK) documents you will find many ideas and common solutions, but you will need strong shader programming experience to make effective use of these.
|
**Shader programming:** The meshes which are generated by PolyVox are very basic in terms of the vertex data they provide. You get vertex positions, sometimes vertex normals, and sometimes additional data copied/interpolated from the volume. It is the responsibility of application programmer to decide how to use this data to create visually interesting renderings. This means you will almost certainly want to make use of shader programs. Of course, in our :doc:`texturing <texturing>` and :doc:`lighting <lighting>` documents you will find many ideas and common solutions, but you will need strong shader programming experience to make effective use of these.
|
||||||
|
|
||||||
If you don't have much experience with shader programming then there are many free resources available. The Cg Tutorial (LINK) provides a good introduction here (the concepts are applicable to other shader languages) as does the documentation for the main graphics (LINK to OpenGL docs) APIs (Link to D3D docs). there is nothing special about PolyVox meshes so you would be advised to practice development on simple meshes such as spheres and cubes before trying to apply it to the output of the mesh extractors.
|
If you don't have much experience with shader programming then there are many free resources available. The Wikipedia page on `Shaders <https://en.wikipedia.org/wiki/Shader>`_ may provide a starting point, as may the documentation for the `OpenGL <https://www.opengl.org/documentation/>`_ and `Direct3D <https://msdn.microsoft.com/en-us/library/windows/desktop/ff476080>`_ libraries. There is nothing special about PolyVox meshes so you would be advised to practice development on simple meshes such as spheres and cubes before trying to apply it to the output of the mesh extractors.
|
@ -1,151 +1,147 @@
|
|||||||
***************
|
***************
|
||||||
Texture Mapping
|
Texture Mapping
|
||||||
***************
|
***************
|
||||||
The PolyVox library is only concerned with operations on volume data (such as extracting a mesh from from a volume) and deliberately avoids the issue of rendering any resulting polygon meshes. This means PolyVox is not tied to any particular graphics API or rendering engine, and makes it much easier to integrate PolyVox with existing technology, because in general a PolyVox mesh can be treated the same as any other mesh. However, the texturing of a PolyVox mesh is usually handled a little differently, and so the purpose of this document is to provide some ideas about where to start with this process.
|
The PolyVox library is only concerned with operations on volume data (such as extracting a mesh from from a volume) and deliberately avoids the issue of rendering any resulting polygon meshes. This means PolyVox is not tied to any particular graphics API or rendering engine, and makes it much easier to integrate PolyVox with existing technology, because in general a PolyVox mesh can be treated the same as any other mesh. However, the texturing of a PolyVox mesh is usually handled a little differently, and so the purpose of this document is to provide some ideas about where to start with this process.
|
||||||
|
|
||||||
This document is aimed at readers in one of two positions:
|
This document is aimed at readers in one of two positions:
|
||||||
|
|
||||||
1. You are trying to texture 'Minecraft-style' terrain with cubic blocks and a number of different materials.
|
1. You are trying to texture 'Minecraft-style' terrain with cubic blocks and a number of different materials.
|
||||||
2. You are trying to texture smooth terrain produced by the Marching Cubes (or similar) algorithm.
|
2. You are trying to texture smooth terrain produced by the Marching Cubes (or similar) algorithm.
|
||||||
|
|
||||||
These are certainly not the limit of PolyVox, and you can choose much more advanced texturing approaches if you wish. For example, in the past we have texture mapped a voxel Earth from a cube map and used an animated *procedural* texture (based on Perlin noise) for the magma at the center of the Earth. However, if you are aiming for such advanced techniques then we assume you understand the basics in this document and have enough knowledge to expand the ideas yourself. But do feel free to drop by and ask questions on our forum.
|
These are certainly not the limit of PolyVox, and you can choose much more advanced texturing approaches if you wish. For example, in the past we have texture mapped a voxel Earth from a cube map and used an animated *procedural* texture (based on Perlin noise) for the magma at the center of the Earth. However, if you are aiming for such advanced techniques then we assume you understand the basics in this document and have enough knowledge to expand the ideas yourself. But do feel free to drop by and ask questions on our forum.
|
||||||
|
|
||||||
Traditionally meshes are textured by providing a pair of UV texture coordinates for each vertex, and these UV coordinates determine which parts of a texture maps to each vertex. The process of texturing PolyVox meshes is more complex for a couple of reasons:
|
Traditionally meshes are textured by providing a pair of UV texture coordinates for each vertex, and these UV coordinates determine which parts of a texture maps to each vertex. The process of texturing PolyVox meshes is more complex for a couple of reasons:
|
||||||
|
|
||||||
1. PolyVox does not provide UV coordinates for each vertex.
|
1. PolyVox does not provide UV coordinates for each vertex.
|
||||||
2. Voxel terrain (particularly Minecraft-style) often involves many more textures than the GPU can read at a time.
|
2. Voxel terrain (particularly Minecraft-style) often involves many more textures than the GPU can read at a time.
|
||||||
|
|
||||||
By reading this document you should learn how to work around the above problems, though you will almost certainly need to follow provided links and do some further reading as we have only summarised the key ideas here.
|
By reading this document you should learn how to work around the above problems, though you will almost certainly need to follow provided links and do some further reading as we have only summarised the key ideas here.
|
||||||
|
|
||||||
Mapping textures to mesh geometry
|
Mapping textures to mesh geometry
|
||||||
=================================
|
=================================
|
||||||
The lack of UV coordinates means some lateral thinking is required in order to apply texture maps to meshes. But before we get to that, we will first try to explain the rational behind PolyVox not providing UV coordinates in the first place. This rational is different for the smooth voxel meshes vs the cubic voxel meshes.
|
The lack of UV coordinates means some lateral thinking is required in order to apply texture maps to meshes. But before we get to that, we will first try to explain the rational behind PolyVox not providing UV coordinates in the first place. This rational is different for the smooth voxel meshes vs the cubic voxel meshes.
|
||||||
|
|
||||||
Rational
|
Rational
|
||||||
--------
|
--------
|
||||||
The problem with texturing smooth voxel meshes is that the geometry can get very complex and it is not clear how the mapping between mesh geometry and a texture should be performed. In a traditional heightmap-based terrain this relationship is obvious as the texture map and heightmap simply line up directly. But for more complex shapes some form of 'UV unwrapping' is usually performed to define this relationship. This is usually done by an artist with the help of a 3D modeling package and so is a semi-automatic process, but it is time consuming and driven by the artists idea of what looks right for their particular scene. Even though fully automatic UV unwrapping is possible it is usually prohibitively slow.
|
The problem with texturing smooth voxel meshes is that the geometry can get very complex and it is not clear how the mapping between mesh geometry and a texture should be performed. In a traditional heightmap-based terrain this relationship is obvious as the texture map and heightmap simply line up directly. But for more complex shapes some form of 'UV unwrapping' is usually performed to define this relationship. This is usually done by an artist with the help of a 3D modeling package and so is a semi-automatic process, but it is time consuming and driven by the artists idea of what looks right for their particular scene. Even though fully automatic UV unwrapping is possible it is usually prohibitively slow.
|
||||||
|
|
||||||
Even if such an unwrapping were possible in a reasonable time frame, the next problem is that it would be invalidated as soon as the mesh changed. Enabling dynamic manipulation is one of the appealing factors of voxel terrain, and if this use case were discarded then the user may as well just model their terrain in an existing 3D modelling package and texture there. For these reasons we do not attempt to generate UV coordinates for smooth voxel meshes.
|
Even if such an unwrapping were possible in a reasonable time frame, the next problem is that it would be invalidated as soon as the mesh changed. Enabling dynamic manipulation is one of the appealing factors of voxel terrain, and if this use case were discarded then the user may as well just model their terrain in an existing 3D modelling package and texture there. For these reasons we do not attempt to generate UV coordinates for smooth voxel meshes.
|
||||||
|
|
||||||
The rational in the cubic case is almost the opposite. For Minecraft style terrain you want to simply line up an instance of a texture with each face of a cube, and generating the texture coordinates for this is very easy. In fact it's so easy that there's no point in doing it - the logic can instead be implemented in a shader which in turn allows the amount of data in each vertex to be reduced.
|
The rational in the cubic case is almost the opposite. For Minecraft style terrain you want to simply line up an instance of a texture with each face of a cube, and generating the texture coordinates for this is very easy. In fact it's so easy that there's no point in doing it - the logic can instead be implemented in a shader which in turn allows the amount of data in each vertex to be reduced.
|
||||||
|
|
||||||
Triplanar Texturing
|
Triplanar Texturing
|
||||||
-------------------
|
-------------------
|
||||||
The most common approach to texture mapping smooth voxel terrain is to use *triplanar texturing*. The basic idea is to project a texture along all three main axes and blend between the three texture samples according to the surface normal. As an example, suppose that we wish to write a fragment shader to apply a single texture to our terrain, and assume that we have access to both the world space position of the fragment and also its normalised surface normal. Also, note that your textures should be set to wrap because the world space position will quickly go outside the bounds of 0.0-1.0. The world space position will need to have been passed through from earlier in the pipeline while the normal can be computed using one of the approaches in the lighting (link) document. The shader code would then look something like this [footnote: code is untested as is simplified compared to real world code. hopefully it compiles, but if not it should still give you an idea of how it works]:
|
The most common approach to texture mapping smooth voxel terrain is to use *triplanar texturing*. The basic idea is to project a texture along all three main axes and blend between the three texture samples according to the surface normal. As an example, suppose that we wish to write a fragment shader to apply a single texture to our terrain, and assume that we have access to both the world space position of the fragment and also its normalised surface normal. Also, note that your textures should be set to wrap because the world space position will quickly go outside the bounds of 0.0-1.0. The world space position will need to have been passed through from earlier in the pipeline while the normal can be computed using one of the approaches in the :doc:`lighting <Lighting>` document. The shader code would then look something like this [footnote: code is untested as is simplified compared to real world code. hopefully it compiles, but if not it should still give you an idea of how it works]:
|
||||||
|
|
||||||
.. code-block:: glsl
|
.. sourcecode:: glsl
|
||||||
|
|
||||||
// Take the three texture samples
|
// Take the three texture samples
|
||||||
vec4 sampleX = texture2d(inputTexture, worldSpacePos.yz); // Project along x axis
|
vec4 sampleX = texture2d(inputTexture, worldSpacePos.yz); // Project along x axis
|
||||||
vec4 sampleY = texture2d(inputTexture, worldSpacePos.xz); // Project along y axis
|
vec4 sampleY = texture2d(inputTexture, worldSpacePos.xz); // Project along y axis
|
||||||
vec4 sampleZ = texture2d(inputTexture, worldSpacePos.xy); // Project along z axis
|
vec4 sampleZ = texture2d(inputTexture, worldSpacePos.xy); // Project along z axis
|
||||||
|
|
||||||
// Blend the samples according to the normal
|
// Blend the samples according to the normal
|
||||||
vec4 blendedColour = sampleX * normal.x + sampleY * normal.y + sampleZ * normal.z;
|
vec4 blendedColour = sampleX * normal.x + sampleY * normal.y + sampleZ * normal.z;
|
||||||
|
|
||||||
Note that this approach will lead to the texture repeating once every world unit, and so in practice you may wish to scale the world space positions to make the texture appear the desired size. Also this technique can be extended to work with normal mapping though we won't go into the details here.
|
Note that this approach will lead to the texture repeating once every world unit, and so in practice you may wish to scale the world space positions to make the texture appear the desired size. Also this technique can be extended to work with normal mapping though we won't go into the details here.
|
||||||
|
|
||||||
This idea of triplanar texturing can be applied to the cubic meshes as well, and in some ways it can be considered to be even simpler. With cubic meshes the normal always points exactly along one of the main axes, and so it is not necessary to sample the texture three times nor to blend the results. Instead you can use conditional branching in the fragment shader to determine which pair of values out of {x,y,z} should be used as the texture coordinates. Something like:
|
This idea of triplanar texturing can be applied to the cubic meshes as well, and in some ways it can be considered to be even simpler. With cubic meshes the normal always points exactly along one of the main axes, and so it is not necessary to sample the texture three times nor to blend the results. Instead you can use conditional branching in the fragment shader to determine which pair of values out of {x,y,z} should be used as the texture coordinates. Something like:
|
||||||
|
|
||||||
.. code-block:: glsl
|
.. sourcecode:: glsl
|
||||||
|
|
||||||
vec4 sample = vec4(0, 0, 0, 0); // We'll fill this in below
|
vec4 sample = vec4(0, 0, 0, 0); // We'll fill this in below
|
||||||
// Assume the normal is normalised.
|
// Assume the normal is normalised.
|
||||||
if(normal.x > 0.9) // x must be one while y and z are zero
|
if(normal.x > 0.9) // x must be one while y and z are zero
|
||||||
{
|
{
|
||||||
//Project onto yz plane
|
//Project onto yz plane
|
||||||
sample = texture2D(inputTexture, worldSpacePos.yz);
|
sample = texture2D(inputTexture, worldSpacePos.yz);
|
||||||
}
|
}
|
||||||
// Now similar logic for the other two axes.
|
// Now similar logic for the other two axes.
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
|
|
||||||
You might also choose to sample a different texture for each of the axes, in order to apply a different texture to each face of your cube. If so, you probably want to pack your different face textures together using an approach similar to those described later in this document for multiple material textures. Another (untested) idea would be to use the normal to select a face on a 1x1x1 cubemap, and have the cubemap face contain an index value for addressing the correct face texture. This could bypass the conditional logic above.
|
You might also choose to sample a different texture for each of the axes, in order to apply a different texture to each face of your cube. If so, you probably want to pack your different face textures together using an approach similar to those described later in this document for multiple material textures. Another (untested) idea would be to use the normal to select a face on a 1x1x1 cubemap, and have the cubemap face contain an index value for addressing the correct face texture. This could bypass the conditional logic above.
|
||||||
|
|
||||||
Using the material identifier
|
Using the material identifier
|
||||||
-----------------------------
|
-----------------------------
|
||||||
So far we have assumed that only a single material is being used for the entire voxel world, but this is seldom the case. It is common to associate a particular material with each voxel so that it can represent rock, wood, sand or any other type of material as required. The usual approach is to store a simple integer identifier with each voxel, and then map this identifier to material properties within your application.
|
So far we have assumed that only a single material is being used for the entire voxel world, but this is seldom the case. It is common to associate a particular material with each voxel so that it can represent rock, wood, sand or any other type of material as required. The usual approach is to store a simple integer identifier with each voxel, and then map this identifier to material properties within your application.
|
||||||
|
|
||||||
Both the CubicSurfaceExtractor and the MarchingCubesSurfacExtractor understand the concept of a material being associated with a voxel, and they will take this into account when generating a mesh. Specifically, they will both copy the material identifier into the vertex data of the output mesh, so you can pass it through to your shaders and use it to affect the way the surface is rendered.
|
Both extractCubicSurface() and the extractMarchingCubesSurface() include a 'data' member in their vertices, and this is copied/interpolated directly from the corresponding voxels. Therefore you can store a material identifier as part of your voxel type, and then pass this through to your shader as a vertex attribute. You can then use this to affect the way the surface is rendered.
|
||||||
|
|
||||||
The following code snippet assumes that you have passed the material identifier to your shaders and that you can access it in the fragment shader. It then chooses which colour to draw the polygon based on this identifier:
|
The following code snippet assumes that you have passed a material identifier to your shaders and that you can access it in the fragment shader. It then chooses which colour to draw the polygon based on this identifier:
|
||||||
|
|
||||||
.. code-block:: glsl
|
.. sourcecode:: glsl
|
||||||
|
|
||||||
vec4 fragmentColour = vec4(1, 1, 1, 1); // Default value
|
vec4 fragmentColour = vec4(1, 1, 1, 1); // Default value
|
||||||
if(materialId < 0.5) //Avoid '==' when working with floats.
|
if(materialId < 0.5) //Avoid '==' when working with floats.
|
||||||
{
|
{
|
||||||
fragmentColour = vec4(1, 0, 0, 1) // Draw material 0 as red.
|
fragmentColour = vec4(1, 0, 0, 1) // Draw material 0 as red.
|
||||||
}
|
}
|
||||||
else if(materialId < 1.5) //Avoid '==' when working with floats.
|
else if(materialId < 1.5) //Avoid '==' when working with floats.
|
||||||
{
|
{
|
||||||
fragmentColour = vec4(0, 1, 0, 1) // Draw material 1 as green.
|
fragmentColour = vec4(0, 1, 0, 1) // Draw material 1 as green.
|
||||||
}
|
}
|
||||||
else if(materialId < 2.5) //Avoid '==' when working with floats.
|
else if(materialId < 2.5) //Avoid '==' when working with floats.
|
||||||
{
|
{
|
||||||
fragmentColour = vec4(0, 0, 1, 1) // Draw material 2 as blue.
|
fragmentColour = vec4(0, 0, 1, 1) // Draw material 2 as blue.
|
||||||
}
|
}
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
|
|
||||||
This is a very simple example, and such use of conditional branching within the shader may not be the best approach as it incurs some performance overhead and becomes unwieldy with a large number of materials. Other approaches include encoding a colour directly into the material identifier, or using the identifier as an index into a texture atlas or array.
|
This is a very simple example, and such use of conditional branching within the shader may not be the best approach as it incurs some performance overhead and becomes unwieldy with a large number of materials. Other approaches include encoding a colour directly into the material identifier, or using the identifier as an index into a texture atlas or array.
|
||||||
|
|
||||||
Note that PolyVox currently stores that material identifier for the vertex as a float, but this will probably change in the future to use the same type as is stored in the volume. It will then be up to you which type you pass to the GPU (older GPUs may not support integer values) but if you do use floats then watch out for precision issues and avoid equality comparisons.
|
Blending between materials
|
||||||
|
--------------------------
|
||||||
Blending between materials
|
An additional complication when working with smooth voxel terrain is that it is usually desirable to blend smoothly between adjacent voxels with different materials. This situation does not occur with cubic meshes because the texture is considered to be per-face instead of per-vertex, and PolyVox enforces this by ensuring that all the vertices of a given face have the same material.
|
||||||
--------------------------
|
|
||||||
An additional complication when working with smooth voxel terrain is that it is usually desirable to blend smoothly between adjacent voxels with different materials. This situation does not occur with cubic meshes because the texture is considered to be per-face instead of per-vertex, and PolyVox enforces this by ensuring that all the vertices of a given face have the same material.
|
With a smooth mesh it is possible for each of the three vertices of any given triangle to have different material identifiers. If this is not explicitly handled then the graphics hardware will interpolate these material values across the face of the triangle. Fundamentally, the concept of interpolating between material identifiers does not make sense, because if we have (for example) 1='grass', 2='rock' and 3='sand' then it does not make sense to say rock is the average of grass and sand.
|
||||||
|
|
||||||
With a smooth mesh it is possible for each of the three vertices of any given triangle to have different material identifiers. If this is not explicitly handled then the graphics hardware will interpolate these material values across the face of the triangle. Fundamentally, the concept of interpolating between material identifiers does not make sense, because if we have (for example) 1='grass', 2='rock' and 3='sand' then it does not make sense to say rock is the average of grass and sand.
|
Correctly handling of this is a surprising difficult problem. For now, one approach is described in our article 'Volumetric representation of virtual terrain' which appeared in Game Engine Gems Volume 1 and which is freely available through the Google Books preview here: http://books.google.com/books?id=WNfD2u8nIlIC&lpg=PR1&dq=game%20engine%20gems&pg=PA39#v=onepage&q&f=false
|
||||||
|
|
||||||
Correctly handling of this is a surprising difficult problem. For now, the best approach is described in our article 'Volumetric representation of virtual terrain' which appeared in Game Engine Gems Volume 1 and which is freely available through the Google Books preview here: http://books.google.com/books?id=WNfD2u8nIlIC&lpg=PR1&dq=game%20engine%20gems&pg=PA39#v=onepage&q&f=false
|
Actual implementation of these material blending approaches is left as an exercise to the reader, though it is possible that in the future we will add some utility functions to PolyVox to assist with tasks such as splitting the mesh or adding the required extra vertex attributes. Our test implementations have performed the mesh processing on the CPU before the mesh is uploaded to the graphics card, but it does seem like there is a lot of potential for implementing these approaches in the geometry shader.
|
||||||
|
|
||||||
As off October 2012 we are actively researching alternative solutions to this problem though it will be some time before the results become available.
|
Storage of textures
|
||||||
|
===================
|
||||||
Actual implementation of these material blending approaches is left as an exercise to the reader, though it is possible that in the future we will add some utility functions to PolyVox to assist with tasks such as splitting the mesh or adding the required extra vertex attributes. Our test implementations have performed the mesh processing on the CPU before the mesh is uploaded to the graphics card, but it does seem like there is a lot of potential for implementing these approaches in the geometry shader.
|
The other major challenge in texturing voxel based geometry is handling the large number of textures which such environments often require. As an example, a game like Minecraft has hundreds of different material types each with their own texture. The traditional approach to mesh texturing is to bind textures to *texture units* on the GPU before rendering a batch, but even modern GPUs only allow between 16-64 textures to be bound at a time. In this section we discuss various solutions to overcoming this limitation.
|
||||||
|
|
||||||
Storage of textures
|
There are various trade offs involved, but if you are targeting hardware with support for *texture arrays* (available from OpenGL 3 and Direct3D 10 onwards) then we can save you some time and tell you that they are almost certainly the best solution. Otherwise you have to understand the various pros and cons of the other approaches described below.
|
||||||
===================
|
|
||||||
The other major challenge in texturing voxel based geometry is handling the large number of textures which such environments often require. As an example, a game like Minecraft has hundreds of different material types each with their own texture. The traditional approach to mesh texturing is to bind textures to *texture units* on the GPU before rendering a batch, but even modern GPUs only allow between 16-64 textures to be bound at a time. In this section we discuss various solutions to overcoming this limitation.
|
Separate texture units
|
||||||
|
----------------------
|
||||||
There are various trade offs involved, but if you are targeting hardware with support for *texture arrays* (available from OpenGL 3 and Direct3D 10 on-wards) then we can save you some time and tell you that they are almost certainly the best solution. Otherwise you have to understand the various pros and cons of the other approaches described below.
|
Before we make things unnecessarily complicated, you should consider whether you do actually need the hundreds of textures discussed earlier. If you actually only need a few textures then the simplest solution may indeed be to pass them in via different texture units. You can then select the desired textures using a series of if statements, or a switch statement if the material identifiers are integer values. There is probably some performance overhead here, but you may find it is acceptable for a small number of textures. Keep in mind that you may need to reserve some texture units for additional texture data such as normal maps or shadow maps.
|
||||||
|
|
||||||
Separate texture units
|
Splitting the mesh
|
||||||
----------------------
|
------------------
|
||||||
Before we make things unnecessarily complicated, you should consider whether you do actually need the hundreds of textures discussed earlier. If you actually only need a few textures then the simplest solution may indeed be to pass them in via different texture units. You can then select the desired textures using a series of if statements, or a switch statement if the material identifiers are integer values. There is probably some performance overhead here, but you may find it is acceptable for a small number of textures. Keep in mind that you may need to reserve some texture units for additional texture data such as normal maps or shadow maps.
|
If your required number of textures do indeed exceed the available number of textures units then one option is to break the mesh down into a number of pieces. Let's say you have a mesh which contains one hundred different materials. As an extreme solution you could break it down into one hundred separate meshes, and for each mesh you could then bind the required single texture before drawing the geometry. Obviously this will dramatically increase the batch count of your scene and so is not recommended.
|
||||||
|
|
||||||
Splitting the mesh
|
A more practical approach would be to break the mesh into a smaller number of pieces such that each mesh uses several textures but less than the maximum number of texture units. For example, our mesh with one hundred materials could be split into ten meshes, the first of which contains those triangles using materials 0-9, the seconds contains those triangles using materials 10-19, and so forth. There is a trade off here between the number of batches and the number of textures units used per batch.
|
||||||
------------------
|
|
||||||
If your required number of textures do indeed exceed the available number of textures units then one option is to break the mesh down into a number of pieces. Let's say you have a mesh which contains one hundred different materials. As an extreme solution you could break it down into one hundred separate meshes, and for each mesh you could then bind the required single texture before drawing the geometry. Obviously this will dramatically increase the batch count of your scene and so is not recommended.
|
Furthermore, you could realise that although your terrain may use hundreds of different textures, any given region is likely to use only a small fraction of those. We have yet to experiment with this, but it seems if you region uses only (for example) materials 12, 47, and 231, then you could conceptually map these materials to the first three textures slots. This means that for each region you draw the mapping between material IDs and texture units would be different. This may require some complex logic in the application but could allow you to do much more with only a few texture units.
|
||||||
|
|
||||||
A more practical approach would be to break the mesh into a smaller number of pieces such that each mesh uses several textures but less than the maximum number of texture units. For example, our mesh with one hundred materials could be split into ten meshes, the first of which contains those triangles using materials 0-9, the seconds contains those triangles using materials 10-19, and so forth. There is a trade off here between the number of batches and the number of textures units used per batch.
|
Texture atlases
|
||||||
|
---------------
|
||||||
Furthermore, you could realise that although your terrain may use hundreds of different textures, any given region is likely to use only a small fraction of those. We have yet to experiment with this, but it seems if you region uses only (for example) materials 12, 47, and 231, then you could conceptually map these materials to the first three textures slots. This means that for each region you draw the mapping between material IDs and texture units would be different. This may require some complex logic in the application but could allow you to do much more with only a few texture units. We will investigate this further in the future.
|
Probably the most widely used method is to pack a number of textures together into a single large texture, and to our knowledge this is the approach used by Minecraft. For example, if each of your textures are 256x256 texels, and if the maximum texture size supported by your target hardware is 4096x4096 texels, then you can pack 16 x 16 = 256 small textures into the larger one. If this isn't enough (or if your input textures are larger than 256x256) then you can also combine this approach with multiple texture units or with the mesh splitting described previously.
|
||||||
|
|
||||||
Texture atlases
|
However, there are a number of problems with packing textures like this. Most obviously, it limits the size of your textures as they now have to be significantly smaller then the maximum texture size. Whether this is a problem will really depend on your application.
|
||||||
---------------
|
|
||||||
Probably the most widely used method is to pack a number of textures together into a single large texture, and to our knowledge this is the approach used by Minecraft. For example, if each of your textures are 256x256 texels, and if the maximum texture size supported by your target hardware is 4096x4096 texels, then you can pack 16 x 16 = 256 small textures into the larger one. If this isn't enough (or if your input textures are larger than 256x256) then you can also combine this approach with multiple texture units or with the mesh splitting described previously.
|
Next, it means you have to adjust your UV coordinates to correctly address a given texture inside the atlas. UV coordinates for a single texture would normally vary between 0.0 and 1.0 in both dimensions, but when packed into a texture atlas each texture uses only a small part of this range. You will need to apply offsets and scaling factors to your UV coordinates to address your texture correctly.
|
||||||
|
|
||||||
However, there are a number of problems with packing textures like this. Most obviously, it limits the size of your textures as they now have to be significantly smaller then the maximum texture size. Whether this is a problem will really depend on your application.
|
However, the biggest problem with texture atlases is that they causes problems with texture filtering and with mipmaps. The filtering problem occurs because graphics hardware usually samples the surrounding texels and performs linear interpolation to compute the colour of a given sample point, but when multiple textures are packed together these surrounding texels can actually come from a neighbouring packed texture rather than wrapping round to sample on the other side of the same packed texture. The mipmap problem occurs because for the highest mipmap levels (such as 1x1 or 2x2) multiple textures are being are being averaged together.
|
||||||
|
|
||||||
Next, it means you have to adjust your UV coordinates to correctly address a given texture inside the atlas. UV coordinates for a single texture would normally vary between 0.0 and 1.0 in both dimensions, but when packed into a texture atlas each texture uses only a small part of this range. You will need to apply offsets and scaling factors to your UV coordinates to address your texture correctly.
|
It is possible to combat these problems but the solutions are non-trivial. You will want to limit the number of miplevels which you use, and probably provide custom shader code to handle the wrapping of texture coordinates, the sampling of MIP maps, and the calculation of interpolated values. You can also try adding a border around all your packed textures, perhaps by duplicating each texture and offsetting by half its size. Even so, it's not clear to us at this point whether the the various artifacts can be completely removed. Minecraft handles it by completely disabling texture filtering and using the resulting pixelated look as part of its aesthetic.
|
||||||
|
|
||||||
However, the biggest problem with texture atlases is that they causes problems with texture filtering and with mipmaps. The filtering problem occurs because graphics hardware usually samples the surrounding texels and performs linear interpolation to compute the colour of a given sample point, but when multiple textures are packed together these surrounding texels can actually come from a neighbouring packed texture rather than wrapping round to sample on the other side of the same packed texture. The mipmap problem occurs because for the highest mipmap levels (such as 1x1 or 2x2) multiple textures are being are being averaged together.
|
3D texture slices
|
||||||
|
-----------------
|
||||||
It is possible to combat these problems but the solutions are non-trivial. You will want to limit the number of miplevels which you use, and probably provide custom shader code to handle the wrapping of texture coordinates, the sampling of MIP maps, and the calculation of interpolated values. You can also try adding a border around all your packed textures, perhaps by duplicating each texture and offsetting by half its size. Even so, it's not clear to us at this point whether the the various artifacts can be completely removed. Minecraft handles it by completely disabling texture filtering and using the resulting pixelated look as part of its aesthetic.
|
The idea here is similar to the texture atlas approach, but rather than packing textures side-by-side in an atlas they are instead packed as slices in a 3D texture. We haven't actually tested this but in theory it may have a couple of benefits. Firstly, it simplifies the addressing of the texture as there is no need to offset/scale the UV coordinates, and the W coordinate (the slice index) can be more easily computed from the material identifier. Secondly, a single volume texture will usually be able to hold more texels than a single 2D texture (for example, 512x512x512 is bigger than 4096x4096). Lastly, it should simplify the filtering problem as packed textures are no longer tiled and so should wrap correctly.
|
||||||
|
|
||||||
3D texture slices
|
However, MIP mapping will probably be more complex than the texture atlas case because even the first MIP level will involve combining adjacent slices. Volume textures are also not so widely supported and may be particularly problematic on mobile hardware.
|
||||||
-----------------
|
|
||||||
The idea here is similar to the texture atlas approach, but rather than packing texture side-by-side in an atlas they are instead packed as slices in a 3D texture. We haven't actually tested this but in theory it may have a couple of benefits. Firstly, it simplifies the addressing of the texture as there is no need to offset/scale the UV coordinates, and the W coordinate (the slice index) can be more easily computed from the material identifier. Secondly, a single volume texture will usually be able to hold more texels than a single 2D texture (for example, 512x512x512 is bigger than 4096x4096). Lastly, it should simplify the filtering problem as packed textures are no longer tiled and so should wrap correctly.
|
Texture arrays
|
||||||
|
--------------
|
||||||
However, MIP mapping will probably be more complex than the texture atlas case because even the first MIP level will involve combining adjacent slices. Volume textures are also not so widely supported and may be particularly problematic on mobile hardware.
|
These provide the perfect solution to the problem of handling a large number of textures... at least if they are supported by your hardware. They were introduced with OpenGL 3 and Direct3D 10 but older versions of OpenGL may still be able to access the functionality via extensions. They allow you to bind an array of textures to the shader, and the advantage compared to a texture atlas is that the hardware understands that the textures are separate and so avoids the filtering and mipmapping issues. Beyond the hardware requirements, the only real limitation is that all the textures must be the same size.
|
||||||
|
|
||||||
Texture arrays
|
Bindless rendering
|
||||||
--------------
|
------------------
|
||||||
These provide the perfect solution to the problem of handling a large number of textures... at least if they are supported by your hardware. They were introduced with OpenGL 3 and Direct3D 10 but older versions of OpenGL may still be able to access the functionality via extensions. They allow you to bind an array of textures to the shader, and the advantage compared to a texture atlas is that the hardware understands that the textures are separate and so avoids the filtering and mipmapping issues. Beyond the hardware requirements, the only real limitation is that all the textures must be the same size.
|
|
||||||
|
|
||||||
Bindless rendering
|
|
||||||
------------------
|
|
||||||
We don't have much to say about this option as it needs significant research, but bindless rendering is one of the new OpenGL extensions to come out of Nvidia. The idea is that it removes the abstraction of needing to 'bind' a texture to a particular texture unit, and instead allows more direct access to the texture data on the GPU. This means you can have access to a much larger number of textures from your shader. Sounds useful, but we've yet to investigate it.
|
We don't have much to say about this option as it needs significant research, but bindless rendering is one of the new OpenGL extensions to come out of Nvidia. The idea is that it removes the abstraction of needing to 'bind' a texture to a particular texture unit, and instead allows more direct access to the texture data on the GPU. This means you can have access to a much larger number of textures from your shader. Sounds useful, but we've yet to investigate it.
|
@ -1,67 +1,67 @@
|
|||||||
*********
|
*********
|
||||||
Threading
|
Threading
|
||||||
*********
|
*********
|
||||||
Modern computing hardware typically contains a large number of processors, and so users of PolyVox often want to know how they can best make use of these from their applications.
|
Modern computing hardware typically contains a large number of processors, and so users of PolyVox often want to know how they can best make use of these from their applications.
|
||||||
|
|
||||||
PolyVox does not make any guarantees about thread-safety, and does not contain any threading primitives to protect access to data structures. You can still make use of PolyVox from multiple threads, but you will have to take responsibility for enforcing thread safety yourself (e.g. by providing thread safe wrappers around the volume classes). If you do want to use PolyVox is a multi-threaded context then this document provides some tips and tricks that you might find useful.
|
PolyVox does not make any guarantees about thread-safety, and does not contain any threading primitives to protect access to data structures. You can still make use of PolyVox from multiple threads, but you will have to take responsibility for enforcing thread safety yourself (e.g. by providing thread safe wrappers around the volume classes). If you do want to use PolyVox is a multi-threaded context then this document provides some tips and tricks that you might find useful.
|
||||||
|
|
||||||
However, be aware that we do not have a lot of expertise in threading, and this is part of the reason why it is not explicitly addressed within PolyVox. If you do have more experience and believe any of this information to be misleading then please do post on the forums to discuss it.
|
However, be aware that we do not have a lot of expertise in threading, and this is part of the reason why it is not explicitly addressed within PolyVox. If you do have more experience and believe any of this information to be misleading then please do post on the forums to discuss it.
|
||||||
|
|
||||||
Volumes
|
Volumes
|
||||||
=======
|
=======
|
||||||
Volumes are a core aspect of PolyVox, and so a natural question is whether it is safe to simultaneously access a given volume from multiple threads. The answer to this is actually fairly complex and is also dependent on the type of volume which is being used.
|
Volumes are a core aspect of PolyVox, and so a natural question is whether it is safe to simultaneously access a given volume from multiple threads. The answer to this is actually fairly complex and is also dependent on the type of volume which is being used.
|
||||||
|
|
||||||
RawVolume
|
RawVolume
|
||||||
---------
|
---------
|
||||||
The RawVolume has a very simple internal structure in which the data is stored as a single array which is never moved or resized. Because of this property it is indeed safe to perform multiple simultaneous *reads* of the data from different threads. However, it is generally not safe to perform simultaneous writes from different threads, or even to write from only one thread while other threads are reading.
|
The RawVolume has a very simple internal structure in which the data is stored as a single array which is never moved or resized. Because of this property it is indeed safe to perform multiple simultaneous *reads* of the data from different threads. However, it is generally not safe to perform simultaneous writes from different threads, or even to write from only one thread while other threads are reading.
|
||||||
|
|
||||||
The reason why simultaneous writes can be problematic should be fairly obvious - if two different threads try to write to the same voxel then the result will depend on which thread writes first. But why can't we write from one thread and read from another one? The problem here is that the the CPU may implement some kind of caching mechanism and/or choose to store data in registers. If a write operation occurs before a read, then the read *may* still obtain the old value because the cache has not been updated yet. There may even be a cache for each thread (particularly if running on multiple processors).
|
The reason why simultaneous writes can be problematic should be fairly obvious - if two different threads try to write to the same voxel then the result will depend on which thread writes first. But why can't we write from one thread and read from another one? The problem here is that the the CPU may implement some kind of caching mechanism and/or choose to store data in registers. If a write operation occurs before a read, then the read *may* still obtain the old value because the cache has not been updated yet. There may even be a cache for each thread (particularly if running on multiple processors).
|
||||||
|
|
||||||
If we assume for a moment that each voxel is a simple integer, then the rules for accessing a single voxel from multiple threads are the same as the rules for accessing integers from multiple threads. There is some useful information about this available on the web, including a discussion on StackOverflow: http://stackoverflow.com/questions/4588915/can-an-integer-be-shared-between-threads-safely
|
If we assume for a moment that each voxel is a simple integer, then the rules for accessing a single voxel from multiple threads are the same as the rules for accessing integers from multiple threads. There is some useful information about this available on the web, including a discussion on StackOverflow: http://stackoverflow.com/questions/4588915/can-an-integer-be-shared-between-threads-safely
|
||||||
|
|
||||||
If nothing else, this serves to illustrate that multi-threaded access even to something as simple as an integer can be surprisingly complex and architecture dependant.
|
If nothing else, this serves to illustrate that multi-threaded access even to something as simple as an integer can be surprisingly complex and architecture dependant.
|
||||||
|
|
||||||
However, all this has been in the context of accessing a *single* voxel from multiple threads... what if we carefully design our algorithm such that different threads access different parts of the volume which never overlap? Unfortunately I don't believe this is a solution either. Caching mechanisms seldom operate on individual elements but instead tend to cache larger chunks of data on the grounds that data accesses are usually localised. So it's quite possible that accessing a given voxel will cause another voxel to be cached.
|
However, all this has been in the context of accessing a *single* voxel from multiple threads... what if we carefully design our algorithm such that different threads access different parts of the volume which never overlap? Unfortunately I don't believe this is a solution either. Caching mechanisms seldom operate on individual elements but instead tend to cache larger chunks of data on the grounds that data accesses are usually localised. So it's quite possible that accessing a given voxel will cause another voxel to be cached.
|
||||||
|
|
||||||
C++ does provide the 'volatile' keyword which can be used to ensure a variable is updated immediately (rather than being cached) but this is still not sufficient for thread safe code. It also has performance implications which we would like to avoid. More information about volatile and multitheaded programming can be found here: http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/
|
C++ does provide the 'volatile' keyword which can be used to ensure a variable is updated immediately (rather than being cached) but this is still not sufficient for thread safe code. It also has performance implications which we would like to avoid. More information about volatile and multitheaded programming can be found here: http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/
|
||||||
|
|
||||||
Lastly, note that PolyVox volumes are templatised which means the voxel type might be something other than a simple int. However we don't think this actually makes a difference given that so few guarantees are made anyway, and it should still be safe to perform multiple concurrent reads for more complex types.
|
Lastly, note that PolyVox volumes are templatised which means the voxel type might be something other than a simple int. However we don't think this actually makes a difference given that so few guarantees are made anyway, and it should still be safe to perform multiple concurrent reads for more complex types.
|
||||||
|
|
||||||
LargeVolume
|
PagedVolume
|
||||||
-----------
|
-----------
|
||||||
The LargeVolume provides even less thread safety than the RawVolume, in that even concurrent read operations can cause problems. The reason for this is the more complex memory management which is performed behind the scenes, and which allows pieces of volume data to be moved around and deleted. For example, a read of a single voxel may mean that the block of data associated with that voxel has to be paged in to memory, which in turn may mean that another block of data has to be paged out of memory. If second thread was halfway through reading a voxel in this second block of data then a problem will occur.
|
The PagedVolume provides even less thread safety than the RawVolume, in that even concurrent read operations can cause problems. The reason for this is the more complex memory management which is performed behind the scenes, and which allows pieces of volume data to be moved around and deleted. For example, a read of a single voxel may mean that the block of data associated with that voxel has to be paged in to memory, which in turn may mean that another block of data has to be paged out of memory. If second thread was halfway through reading a voxel in this second block of data then a problem will occur.
|
||||||
|
|
||||||
In the future we may do a more comprehensive analysis of thread safety in the LargeVolume, but for now you should assume that any multithreaded access can cause problems.
|
In the future we may do a more comprehensive analysis of thread safety in the PagedVolume, but for now you should assume that any multithreaded access can cause problems.
|
||||||
|
|
||||||
Consequences of abuse
|
Consequences of abuse
|
||||||
---------------------
|
---------------------
|
||||||
We have outlined above the rules for multithreaded access of volumes, but what actually happens if you violate these? There's a couple of things to watch out for:
|
We have outlined above the rules for multithreaded access of volumes, but what actually happens if you violate these? There's a couple of things to watch out for:
|
||||||
|
|
||||||
- As mentioned, performing unprotected writes to the volume can cause problems because the data may be copied into the CPU cache and/or registers, and so a subsequent read could retrieve the old value. This is not what you want but probably won't be fatal (i.e. it shouldn't crash). It would basically manifest itself as data corruption.
|
- As mentioned, performing unprotected writes to the volume can cause problems because the data may be copied into the CPU cache and/or registers, and so a subsequent read could retrieve the old value. This is not what you want but probably won't be fatal (i.e. it shouldn't crash). It would basically manifest itself as data corruption.
|
||||||
- If you access the LargeVolume in a multithreaded fashion then you risk trying to access data which has been removed by another thread, and in this case you will get undefined behaviour. This will probably be a crash (out of bounds access) but really anything could happen.
|
- If you access the PagedVolume in a multithreaded fashion then you risk trying to access data which has been removed by another thread, and in this case you will get undefined behaviour. This will probably be a crash (out of bounds access) but really anything could happen.
|
||||||
|
|
||||||
Surface Extraction
|
Surface Extraction
|
||||||
==================
|
==================
|
||||||
Despite the lack of thread safety built in to PolyVox, it is still possible and often desirable to make use of multiple threads for tasks such as surface extraction. Performing surface extraction does not require write access to the data, and we've already established that you can safely perform reads from different threads *provided you are not using the LargeVolume*.
|
Despite the lack of thread safety built in to PolyVox, it is still possible and often desirable to make use of multiple threads for tasks such as surface extraction. Performing surface extraction does not require write access to the data, and we've already established that you can safely perform reads from different threads *provided you are not using the PagedVolume*.
|
||||||
|
|
||||||
Combining multiple surface extraction threads with the *LargeVolume* is something we will need to experiment with in the future, to determine how it can be improved.
|
Combining multiple surface extraction threads with the *PagedVolume* is something we will need to experiment with in the future, to determine how it can be improved.
|
||||||
|
|
||||||
In the future we will expand this section to discuss how to split surface extraction across a number of threads, but for now please see Section XX of the book chapter 'Volumetric Representation of Virtual environments', available for free here: http://books.google.nl/books?id=WNfD2u8nIlIC&lpg=PR1&dq=game+engine+gems&pg=PA39&redir_esc=y#v=onepage&q&f=false
|
In the future we will expand this section to discuss how to split surface extraction across a number of threads, but for now please see Section 3.4.3 of the book chapter 'Volumetric Representation of Virtual environments', available for free here: http://books.google.nl/books?id=WNfD2u8nIlIC&lpg=PR1&dq=game+engine+gems&pg=PA39&redir_esc=y#v=onepage&q&f=false
|
||||||
|
|
||||||
GPU thread safety
|
GPU thread safety
|
||||||
=================
|
=================
|
||||||
Be aware that even if you successfully perform surface across multiple threads you still need to take care when uploading the data to the GPU. For Direct3D 9.0 and OpenGL 2.0 it is only possible to upload data from the main thread (or more accurately the one which owns the rendering context). So after you have performed your multi-threaded surface extraction you need to bring the data back to the main thread for uploading to the GPU.
|
Be aware that even if you successfully perform surface extraction across multiple threads then you still need to take care when uploading the data to the GPU. For Direct3D 9.0 and OpenGL 2.0 it is only possible to upload data from the main thread (or more accurately the one which owns the rendering context). So after you have performed your multi-threaded surface extraction you need to bring the data back to the main thread for uploading to the GPU.
|
||||||
|
|
||||||
More recent versions of the Direct3D and OpenGL APIs lift this restriction and provide means of accessing GPU resources from multiple threads. Please consult the documentation for your API for details.
|
More recent versions of the Direct3D and OpenGL APIs lift this restriction and provide means of accessing GPU resources from multiple threads. Please consult the documentation for your API for details.
|
||||||
|
|
||||||
Future work
|
Future work
|
||||||
===========
|
===========
|
||||||
Threading support is not a high priority for PolyVox because it can be implemented by the user at a higher level. However, there are a couple of areas we may investigate in the future.
|
Threading support is not a high priority for PolyVox because it can be implemented by the user at a higher level. However, there are a couple of areas we may investigate in the future.
|
||||||
|
|
||||||
Thread safe volume wrapper
|
Thread safe volume wrapper
|
||||||
--------------------------
|
--------------------------
|
||||||
It might be useful to provide a thread safe wrapper around the volume classes, and this could possibly be included in the PolyVox utilities or as a extra library. This thread safe wrapper could be templatised to work with any internal volume type, and could itself be a volume so that it can be used directly with the existing algorithms.
|
It might be useful to provide a thread safe wrapper around the volume classes, and this could possibly be included in the PolyVox utilities or as a extra library. This thread safe wrapper could be templatised to work with any internal volume type, and could itself be a volume so that it can be used directly with the existing algorithms.
|
||||||
|
|
||||||
OpenMP
|
OpenMP
|
||||||
------
|
------
|
||||||
This is a standard for extending C++ with compiler directives which allow the compiler to automatically parallelise sections of code. Most likely this could be used to parallelise some of the loops which occur in image processing tasks.
|
This is a standard for extending C++ with compiler directives which allow the compiler to automatically parallelise sections of code. Most likely this could be used to parallelise some of the loops which occur in image processing tasks.
|
62
documentation/Volumes.rst
Normal file
62
documentation/Volumes.rst
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
*******
|
||||||
|
Volumes
|
||||||
|
*******
|
||||||
|
The volume classes are the heart and soul of Polyvox, providing storage for the huge amounts of data which volumetric environments often require.
|
||||||
|
|
||||||
|
Volume concepts
|
||||||
|
===============
|
||||||
|
|
||||||
|
The main volume classes
|
||||||
|
=======================
|
||||||
|
|
||||||
|
Basic access to volume data
|
||||||
|
===========================
|
||||||
|
At the simplest level, individual voxels can be read and written by the getVoxel() and setVoxel() member functions which exist for each volume. We will focus on reading voxels first.
|
||||||
|
|
||||||
|
Reading voxels
|
||||||
|
--------------
|
||||||
|
The easiest way to read a particular voxel is as follows:
|
||||||
|
|
||||||
|
.. sourcecode :: c++
|
||||||
|
|
||||||
|
RawVolume<uint8_t>* volume = ... // Get a volume from somewhere.
|
||||||
|
uint8_t uVoxelValue = volume->getVoxel(x, y, z); // Read the voxel at the given position.
|
||||||
|
|
||||||
|
This works great as long as the provided position (x, y, z) does actually represent a valid position inside the volume. If this is not the case then the default behaviour is to throw an exception, so you should be prepared to handle this if you are not certain the position is valid.
|
||||||
|
|
||||||
|
Alternatively you can modify the behaviour which occurs when a position is outside the volume by providing a WrapMode as a fourth parameter to getVoxel(). For example:
|
||||||
|
|
||||||
|
.. sourcecode :: c++
|
||||||
|
|
||||||
|
// This will return the voxel, or '42' if the position is outside the volume
|
||||||
|
uint8_t uVoxelValue = volume->getVoxel(x, y, z, WrapModes::Border, 42);
|
||||||
|
|
||||||
|
Please see the documentation for WrapMode for more information on the avaiable options here. Note in particular that WrapModes::AssumeValid can be used to skip any bounds checking and so you should use this *if you are certain* that you are accessing a valid position, as it may be noticably faster in some cases.
|
||||||
|
|
||||||
|
.. sourcecode :: c++
|
||||||
|
|
||||||
|
// This will result in undefined behaviour if the position is outside the volume
|
||||||
|
uint8_t uVoxelValue = volume->getVoxel(x, y, z, WrapModes::AssumeValid);
|
||||||
|
|
||||||
|
Fast access to voxel data is very important in PolyVox, but the above functions have a drawback in that they need to contain logic to evaluate the provided WrapMode and decide how to proceed. This introduces branching into the execution flow and results in larger functions which may prevent inlining. For even more speed you can use version of the above functions which are templatised on the WrapMode rather than taking it as a parameter. This means the condition can be evaluated at compile time rather than run time: For example:
|
||||||
|
|
||||||
|
.. sourcecode :: c++
|
||||||
|
|
||||||
|
// This will return the voxel, or '42' if the position is outside the volume
|
||||||
|
uint8_t uVoxelValue = volume->getVoxel<WrapModes::Border>(x, y, z, 42);
|
||||||
|
|
||||||
|
Writing voxels
|
||||||
|
--------------
|
||||||
|
The setVoxel() function is used for writting to voxels instread of reading from them, and besides this it has two main behavoural differences when compared to getVoxel(). The first difference is that it is not templatised because the speed of setVoxel() is typically less important than getVoxel() (as writing to voxels is much less common than reading from them). However, we could add these temlatised version in the future if they are needed.
|
||||||
|
|
||||||
|
The second difference is that certain wrap modes such as WrapModes::Border or WrapModes::Clamp do not make much sense when writting to voxel data, and so these are no permitted and will result in an exception being thrown. You should only use WrapModes::Validate (the default) and WrapModes::AssumeValid. For example:
|
||||||
|
|
||||||
|
.. sourcecode :: c++
|
||||||
|
|
||||||
|
RawVolume<uint8_t>* volume = ... // Get a volume from somewhere.
|
||||||
|
volume->setVoxel(x, y, z, 57); // Write the voxel at the given position.
|
||||||
|
volume->setVoxel(x, y, z, 57, WrapMopdes::AssumeValid); // No bounds checks
|
||||||
|
|
||||||
|
Notes on error handling and performance
|
||||||
|
---------------------------------------
|
||||||
|
Overall, you should set the wrap mode to WrapModes::AssumeValid for maximum performance (and use templatised versions where available), but note that even this fast version does still contain a POLYVOX_ASSERT() to try and catch mistakes. It appears that this assert prevents inlining (probably due to the logging it performs), but it is anticipated that you will disable such asserts in the final build of your software.
|
@ -1,4 +1,4 @@
|
|||||||
Changelog
|
Changelog
|
||||||
#########
|
#########
|
||||||
|
|
||||||
.. include:: ../CHANGELOG.txt
|
.. include:: ../CHANGELOG.txt
|
||||||
|
@ -1,232 +1,232 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# PolyVox documentation build configuration file, created by
|
# PolyVox documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Tue Jul 6 14:46:57 2010.
|
# sphinx-quickstart on Tue Jul 6 14:46:57 2010.
|
||||||
#
|
#
|
||||||
# This file is execfile()d with the current directory set to its containing dir.
|
# This file is execfile()d with the current directory set to its containing dir.
|
||||||
#
|
#
|
||||||
# Note that not all possible configuration values are present in this
|
# Note that not all possible configuration values are present in this
|
||||||
# autogenerated file.
|
# autogenerated file.
|
||||||
#
|
#
|
||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
sys.path.append('@CMAKE_CURRENT_SOURCE_DIR@/_extensions')
|
sys.path.append('@CMAKE_CURRENT_SOURCE_DIR@/_extensions')
|
||||||
|
|
||||||
# -- General configuration -----------------------------------------------------
|
# -- General configuration -----------------------------------------------------
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
#needs_sphinx = '1.0'
|
#needs_sphinx = '1.0'
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||||
extensions = ['sphinxcontrib.doxylink']
|
extensions = ['sphinxcontrib.doxylink']
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
templates_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_templates']
|
templates_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_templates']
|
||||||
|
|
||||||
# The suffix of source filenames.
|
# The suffix of source filenames.
|
||||||
source_suffix = '.rst'
|
source_suffix = '.rst'
|
||||||
|
|
||||||
# The encoding of source files.
|
# The encoding of source files.
|
||||||
#source_encoding = 'utf-8-sig'
|
#source_encoding = 'utf-8-sig'
|
||||||
|
|
||||||
# The master toctree document.
|
# The master toctree document.
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'PolyVox'
|
project = u'PolyVox'
|
||||||
copyright = u'2010, David Williams, Matt Williams'
|
copyright = u'2013, David Williams, Matt Williams'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '@POLYVOX_VERSION@'
|
version = '@POLYVOX_VERSION@'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '@POLYVOX_VERSION@'
|
release = '@POLYVOX_VERSION@'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
language = "en"
|
language = "en"
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
# There are two options for replacing |today|: either, you set today to some
|
||||||
# non-false value, then it is used:
|
# non-false value, then it is used:
|
||||||
#today = ''
|
#today = ''
|
||||||
# Else, today_fmt is used as the format for a strftime call.
|
# Else, today_fmt is used as the format for a strftime call.
|
||||||
#today_fmt = '%B %d, %Y'
|
#today_fmt = '%B %d, %Y'
|
||||||
|
|
||||||
# List of patterns, relative to source directory, that match files and
|
# List of patterns, relative to source directory, that match files and
|
||||||
# directories to ignore when looking for source files.
|
# directories to ignore when looking for source files.
|
||||||
exclude_patterns = ['_build']
|
exclude_patterns = ['_build']
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||||
#default_role = None
|
#default_role = None
|
||||||
|
|
||||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||||
#add_function_parentheses = True
|
#add_function_parentheses = True
|
||||||
|
|
||||||
# If true, the current module name will be prepended to all description
|
# If true, the current module name will be prepended to all description
|
||||||
# unit titles (such as .. function::).
|
# unit titles (such as .. function::).
|
||||||
#add_module_names = True
|
#add_module_names = True
|
||||||
|
|
||||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||||
# output. They are ignored by default.
|
# output. They are ignored by default.
|
||||||
#show_authors = False
|
#show_authors = False
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
pygments_style = 'sphinx'
|
pygments_style = 'sphinx'
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
# A list of ignored prefixes for module index sorting.
|
||||||
#modindex_common_prefix = []
|
#modindex_common_prefix = []
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ---------------------------------------------------
|
# -- Options for HTML output ---------------------------------------------------
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
html_theme = 'default'
|
html_theme = 'default'
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
# further. For a list of options available for each theme, see the
|
# further. For a list of options available for each theme, see the
|
||||||
# documentation.
|
# documentation.
|
||||||
#html_theme_options = {}
|
#html_theme_options = {}
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
# Add any paths that contain custom themes here, relative to this directory.
|
||||||
#html_theme_path = []
|
#html_theme_path = []
|
||||||
|
|
||||||
# The name for this set of Sphinx documents. If None, it defaults to
|
# The name for this set of Sphinx documents. If None, it defaults to
|
||||||
# "<project> v<release> documentation".
|
# "<project> v<release> documentation".
|
||||||
#html_title = None
|
#html_title = None
|
||||||
|
|
||||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||||
#html_short_title = None
|
#html_short_title = None
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top
|
# The name of an image file (relative to this directory) to place at the top
|
||||||
# of the sidebar.
|
# of the sidebar.
|
||||||
#html_logo = None
|
#html_logo = None
|
||||||
|
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
# The name of an image file (within the static path) to use as favicon of the
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
#html_favicon = None
|
#html_favicon = None
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static']
|
html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static']
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||||
# using the given strftime format.
|
# using the given strftime format.
|
||||||
#html_last_updated_fmt = '%b %d, %Y'
|
#html_last_updated_fmt = '%b %d, %Y'
|
||||||
|
|
||||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||||
# typographically correct entities.
|
# typographically correct entities.
|
||||||
#html_use_smartypants = True
|
#html_use_smartypants = True
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
# Custom sidebar templates, maps document names to template names.
|
||||||
#html_sidebars = {}
|
#html_sidebars = {}
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
# Additional templates that should be rendered to pages, maps page names to
|
||||||
# template names.
|
# template names.
|
||||||
#html_additional_pages = {}
|
#html_additional_pages = {}
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#html_domain_indices = True
|
#html_domain_indices = True
|
||||||
|
|
||||||
# If false, no index is generated.
|
# If false, no index is generated.
|
||||||
#html_use_index = True
|
#html_use_index = True
|
||||||
|
|
||||||
# If true, the index is split into individual pages for each letter.
|
# If true, the index is split into individual pages for each letter.
|
||||||
#html_split_index = False
|
#html_split_index = False
|
||||||
|
|
||||||
# If true, links to the reST sources are added to the pages.
|
# If true, links to the reST sources are added to the pages.
|
||||||
#html_show_sourcelink = True
|
#html_show_sourcelink = True
|
||||||
|
|
||||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||||
#html_show_sphinx = True
|
#html_show_sphinx = True
|
||||||
|
|
||||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||||
#html_show_copyright = True
|
#html_show_copyright = True
|
||||||
|
|
||||||
# If true, an OpenSearch description file will be output, and all pages will
|
# If true, an OpenSearch description file will be output, and all pages will
|
||||||
# contain a <link> tag referring to it. The value of this option must be the
|
# contain a <link> tag referring to it. The value of this option must be the
|
||||||
# base URL from which the finished HTML is served.
|
# base URL from which the finished HTML is served.
|
||||||
#html_use_opensearch = ''
|
#html_use_opensearch = ''
|
||||||
|
|
||||||
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
|
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
|
||||||
#html_file_suffix = ''
|
#html_file_suffix = ''
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
#htmlhelp_basename = 'PolyVoxdoc'
|
#htmlhelp_basename = 'PolyVoxdoc'
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output --------------------------------------------------
|
# -- Options for LaTeX output --------------------------------------------------
|
||||||
|
|
||||||
# The paper size ('letter' or 'a4').
|
# The paper size ('letter' or 'a4').
|
||||||
#latex_paper_size = 'letter'
|
#latex_paper_size = 'letter'
|
||||||
|
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
#latex_font_size = '10pt'
|
#latex_font_size = '10pt'
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
('index', 'PolyVox.tex', u'PolyVox Documentation',
|
('index', 'PolyVox.tex', u'PolyVox Documentation',
|
||||||
u'David Williams, Matt Williams', 'manual'),
|
u'David Williams, Matt Williams', 'manual'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
# the title page.
|
# the title page.
|
||||||
#latex_logo = None
|
#latex_logo = None
|
||||||
|
|
||||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||||
# not chapters.
|
# not chapters.
|
||||||
#latex_use_parts = False
|
#latex_use_parts = False
|
||||||
|
|
||||||
# If true, show page references after internal links.
|
# If true, show page references after internal links.
|
||||||
#latex_show_pagerefs = False
|
#latex_show_pagerefs = False
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
#latex_show_urls = False
|
#latex_show_urls = False
|
||||||
|
|
||||||
# Additional stuff for the LaTeX preamble.
|
# Additional stuff for the LaTeX preamble.
|
||||||
#latex_preamble = ''
|
#latex_preamble = ''
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
#latex_appendices = []
|
#latex_appendices = []
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#latex_domain_indices = True
|
#latex_domain_indices = True
|
||||||
|
|
||||||
|
|
||||||
# -- Options for manual page output --------------------------------------------
|
# -- Options for manual page output --------------------------------------------
|
||||||
|
|
||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
('index', 'polyvox', u'PolyVox Documentation',
|
('index', 'polyvox', u'PolyVox Documentation',
|
||||||
[u'David Williams, Matt Williams'], 1)
|
[u'David Williams, Matt Williams'], 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Example configuration for intersphinx: refer to the Python standard library.
|
# Example configuration for intersphinx: refer to the Python standard library.
|
||||||
#intersphinx_mapping = {'http://docs.python.org/': None}
|
#intersphinx_mapping = {'http://docs.python.org/': None}
|
||||||
|
|
||||||
doxylink = {
|
doxylink = {
|
||||||
'polyvox' : ('@CMAKE_CURRENT_BINARY_DIR@/../library/PolyVox.tag', '../library/doc/html/') #Make this '../api/' for uploading
|
'polyvox' : ('@CMAKE_CURRENT_BINARY_DIR@/../library/PolyVox.tag', '../library/doc/html/') #Make this '../api/' for uploading
|
||||||
}
|
}
|
||||||
|
|
||||||
#This must be lowercase for QtHelp
|
#This must be lowercase for QtHelp
|
||||||
qthelp_basename = "polyvox"
|
qthelp_basename = "polyvox"
|
||||||
|
|
||||||
primary_domain = "c++"
|
primary_domain = "c++"
|
||||||
|
|
||||||
# Default higlighting scheme to use for `code-block` directives
|
# Default higlighting scheme to use for `code-block` directives
|
||||||
highlight_language = "c++"
|
highlight_language = "c++"
|
||||||
|
@ -1,40 +1,41 @@
|
|||||||
Welcome to PolyVox's documentation!
|
Welcome to PolyVox's documentation!
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
User Guide:
|
User Guide:
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
Prerequisites
|
Prerequisites
|
||||||
install
|
install
|
||||||
principles
|
principles
|
||||||
Lighting
|
Lighting
|
||||||
TextureMapping
|
TextureMapping
|
||||||
ModifyingTerrain
|
ModifyingTerrain
|
||||||
LevelOfDetail
|
LevelOfDetail
|
||||||
Threading
|
Threading
|
||||||
|
ErrorHandling
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
tutorial1
|
tutorial1
|
||||||
|
python-bindings
|
||||||
Other Information:
|
|
||||||
|
Other Information:
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 1
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
changelog
|
|
||||||
FAQ
|
changelog
|
||||||
|
FAQ
|
||||||
|
|
||||||
Indices and tables
|
|
||||||
==================
|
Indices and tables
|
||||||
|
==================
|
||||||
* :ref:`genindex`
|
|
||||||
* :ref:`search`
|
* :ref:`genindex`
|
||||||
|
* :ref:`search`
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
.. include:: ../INSTALL.txt
|
.. include:: ../INSTALL.txt
|
||||||
|
@ -1,155 +1,155 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
|
|
||||||
REM Command file for Sphinx documentation
|
REM Command file for Sphinx documentation
|
||||||
|
|
||||||
if "%SPHINXBUILD%" == "" (
|
if "%SPHINXBUILD%" == "" (
|
||||||
set SPHINXBUILD=sphinx-build
|
set SPHINXBUILD=sphinx-build
|
||||||
)
|
)
|
||||||
set BUILDDIR=_build
|
set BUILDDIR=_build
|
||||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||||
if NOT "%PAPER%" == "" (
|
if NOT "%PAPER%" == "" (
|
||||||
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "" goto help
|
if "%1" == "" goto help
|
||||||
|
|
||||||
if "%1" == "help" (
|
if "%1" == "help" (
|
||||||
:help
|
:help
|
||||||
echo.Please use `make ^<target^>` where ^<target^> is one of
|
echo.Please use `make ^<target^>` where ^<target^> is one of
|
||||||
echo. html to make standalone HTML files
|
echo. html to make standalone HTML files
|
||||||
echo. dirhtml to make HTML files named index.html in directories
|
echo. dirhtml to make HTML files named index.html in directories
|
||||||
echo. singlehtml to make a single large HTML file
|
echo. singlehtml to make a single large HTML file
|
||||||
echo. pickle to make pickle files
|
echo. pickle to make pickle files
|
||||||
echo. json to make JSON files
|
echo. json to make JSON files
|
||||||
echo. htmlhelp to make HTML files and a HTML help project
|
echo. htmlhelp to make HTML files and a HTML help project
|
||||||
echo. qthelp to make HTML files and a qthelp project
|
echo. qthelp to make HTML files and a qthelp project
|
||||||
echo. devhelp to make HTML files and a Devhelp project
|
echo. devhelp to make HTML files and a Devhelp project
|
||||||
echo. epub to make an epub
|
echo. epub to make an epub
|
||||||
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
||||||
echo. text to make text files
|
echo. text to make text files
|
||||||
echo. man to make manual pages
|
echo. man to make manual pages
|
||||||
echo. changes to make an overview over all changed/added/deprecated items
|
echo. changes to make an overview over all changed/added/deprecated items
|
||||||
echo. linkcheck to check all external links for integrity
|
echo. linkcheck to check all external links for integrity
|
||||||
echo. doctest to run all doctests embedded in the documentation if enabled
|
echo. doctest to run all doctests embedded in the documentation if enabled
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "clean" (
|
if "%1" == "clean" (
|
||||||
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
||||||
del /q /s %BUILDDIR%\*
|
del /q /s %BUILDDIR%\*
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "html" (
|
if "%1" == "html" (
|
||||||
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "dirhtml" (
|
if "%1" == "dirhtml" (
|
||||||
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "singlehtml" (
|
if "%1" == "singlehtml" (
|
||||||
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "pickle" (
|
if "%1" == "pickle" (
|
||||||
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished; now you can process the pickle files.
|
echo.Build finished; now you can process the pickle files.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "json" (
|
if "%1" == "json" (
|
||||||
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished; now you can process the JSON files.
|
echo.Build finished; now you can process the JSON files.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "htmlhelp" (
|
if "%1" == "htmlhelp" (
|
||||||
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished; now you can run HTML Help Workshop with the ^
|
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||||
.hhp project file in %BUILDDIR%/htmlhelp.
|
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "qthelp" (
|
if "%1" == "qthelp" (
|
||||||
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||||
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||||
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\PolyVox.qhcp
|
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\PolyVox.qhcp
|
||||||
echo.To view the help file:
|
echo.To view the help file:
|
||||||
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\PolyVox.ghc
|
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\PolyVox.ghc
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "devhelp" (
|
if "%1" == "devhelp" (
|
||||||
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished.
|
echo.Build finished.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "epub" (
|
if "%1" == "epub" (
|
||||||
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "latex" (
|
if "%1" == "latex" (
|
||||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "text" (
|
if "%1" == "text" (
|
||||||
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished. The text files are in %BUILDDIR%/text.
|
echo.Build finished. The text files are in %BUILDDIR%/text.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "man" (
|
if "%1" == "man" (
|
||||||
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
||||||
echo.
|
echo.
|
||||||
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "changes" (
|
if "%1" == "changes" (
|
||||||
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
||||||
echo.
|
echo.
|
||||||
echo.The overview file is in %BUILDDIR%/changes.
|
echo.The overview file is in %BUILDDIR%/changes.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "linkcheck" (
|
if "%1" == "linkcheck" (
|
||||||
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
||||||
echo.
|
echo.
|
||||||
echo.Link check complete; look for any errors in the above output ^
|
echo.Link check complete; look for any errors in the above output ^
|
||||||
or in %BUILDDIR%/linkcheck/output.txt.
|
or in %BUILDDIR%/linkcheck/output.txt.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "doctest" (
|
if "%1" == "doctest" (
|
||||||
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
||||||
echo.
|
echo.
|
||||||
echo.Testing of doctests in the sources finished, look at the ^
|
echo.Testing of doctests in the sources finished, look at the ^
|
||||||
results in %BUILDDIR%/doctest/output.txt.
|
results in %BUILDDIR%/doctest/output.txt.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
:end
|
:end
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
**********************
|
**********************
|
||||||
Principles of PolyVox
|
Principles of PolyVox
|
||||||
**********************
|
**********************
|
||||||
|
|
||||||
.. warning ::
|
.. warning ::
|
||||||
This section is being written and is just a skeleton for now
|
This section is yet to be fully written and is just a skeleton for now.
|
||||||
|
|
||||||
PolyVox provides a library for managing 3D arrays (volumes) of data (voxels). It gives you the tools to iterate through, randomly access, read and write volumes. It supports any type you'd like to represent each voxel whether it's just an ``int`` or a class which encapsulates both density and colour.
|
PolyVox provides a library for managing 3D arrays (volumes) of data (voxels). It gives you the tools to iterate through, randomly access, read and write volumes. The volumes are templatized on voxel type, so that each voxel can be as simple as just an number or as complex as a class with a range of properties.
|
||||||
|
|
||||||
Once you have a volume, PolyVox provides a number of tools for turning it into something that you can pass to your rendering engine. These are called `surface extractors`.
|
Once you have created a volume, PolyVox provides a number of tools for turning it into a mesh that you can pass to your rendering engine. These are called `surface extractors`. A 'Marching Cubes' surface extractor and a 'cubic' (Minecraft-style) surface extractor are included, and it is possible to write your own.
|
||||||
|
|
||||||
Each surface extractor needs to be told how to interperet your voxel type and that is done using...
|
PolyVox primarily handles this task of storing volume data and extracting surfaces from it. Most other aspects of you voxel application or game will need to be implemented by you (rendering, logic, physics, AI, networking, etc) though PolyVox does have a few utility classes for things like the A* algorithm on a 3D grid.
|
||||||
|
|
||||||
Link to a page describing how to write your own voxel type and link it to a surface extractor...
|
|
139
documentation/python-bindings.rst
Normal file
139
documentation/python-bindings.rst
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
***************
|
||||||
|
Python bindings
|
||||||
|
***************
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
PolyVox itself is a C++ library but in order to make it useful to as many people as possible, we also provide bindings to a number of other languages.
|
||||||
|
These bindings are all generated by `SWIG <http://swig.org>`_ and provide a bridge to a compiled PolyVox library (*DLL* or *.so*) via an interafce which is native to the language.
|
||||||
|
This allows you in a Python script to simpy call ``import PolyVoxCore`` and get access to the whole library's functionality.
|
||||||
|
|
||||||
|
The Python bindings are available for Python 3.
|
||||||
|
|
||||||
|
Comparison with C++
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
All the bindings available for PolyVox (so both the Python bindings and any future supported bindings such as for C♯) follow the PolyVox C++ API quite closely.
|
||||||
|
This means that many PolyVox code examples written in C++ are mostly applicable also to Python.
|
||||||
|
Classes and functions are named the same and take the same set of arguments.
|
||||||
|
The main place this falls down is with templated C++ classes.
|
||||||
|
Since C++ templates are essentially a code-generation system built into the C++ compiler there is no way for a user of the Python bindings to request, at run-time, a specific piece of code to be generated.
|
||||||
|
The way we work around this is by, as part of the bindings generation process, pre-compiling a number of different versions of each templated class.
|
||||||
|
For example, in C++ a 3D vector containing 32-bit integers would be declared as
|
||||||
|
|
||||||
|
.. sourcecode:: c++
|
||||||
|
|
||||||
|
PolyVox::Vector3D<int32_t> my_vec(0,1,4);
|
||||||
|
|
||||||
|
but in Python it would be accessed as
|
||||||
|
|
||||||
|
.. sourcecode:: python
|
||||||
|
|
||||||
|
my_vec = PolyVoxCore.Vector3Dint32_t(0,1,4)
|
||||||
|
|
||||||
|
As a rule, any time in C++ where you see a template instantiation with ``<>``, just remove the angle brackets and it will yield the Python class name.
|
||||||
|
|
||||||
|
The choice of which C++ templates to instantiate is made by the developers of PolyVox in order to try to cover the main use-cases that library users would have.
|
||||||
|
If, however, you want to add your own versions, this can be done by editing the SWIG interface files and recompiling PolyVox.
|
||||||
|
|
||||||
|
Buildings the bindings
|
||||||
|
======================
|
||||||
|
|
||||||
|
The bindings are built as part of the standard PolyVox build process. For details on this please follow the instructions at :doc:`install`.
|
||||||
|
The important things to note there are the requirements for building the bindings: *Python development libraries* and *SWIG*.
|
||||||
|
During the CMake phase of building, it should tell you whether or not the bindings will be built.
|
||||||
|
|
||||||
|
Compiling the whole PolyVox library should then give you two files inside the ``build/library/bindings`` directory:
|
||||||
|
|
||||||
|
``PolyVoxCore.py``
|
||||||
|
This is the main entry point to the library.
|
||||||
|
|
||||||
|
``_PolyVoxCore.so`` (or ``.dll`` on Windows)
|
||||||
|
This contains the compiled code of the PolyVox library.
|
||||||
|
|
||||||
|
This file has a link dependency the main ``libPolyVoxCore.so`` library as well as the Python shared library.
|
||||||
|
|
||||||
|
|
||||||
|
Using the bindings
|
||||||
|
==================
|
||||||
|
|
||||||
|
As discussed above, the Python API is very similar to the C++ one but none-the-less we'll go through an example to see how it works.
|
||||||
|
All the code in this section is taken from ``PythonExample.py`` found in the source distribution of PolyVox in the ``examples/Python`` folder.
|
||||||
|
|
||||||
|
Seting up the volume
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
The first this we do is import the ``PolyVoxCore`` module. We rename it as ``pv`` to make our life easier.
|
||||||
|
|
||||||
|
.. literalinclude:: ../examples/Python/PythonExample.py
|
||||||
|
:language: python
|
||||||
|
:lines: 29
|
||||||
|
|
||||||
|
We create a ``Region`` from two vectors defining the bounds of the area - a volume 64×64×64.
|
||||||
|
Remember that ``pv.Vector3Dint32_t`` refers to a 3D :polyvox:`PolyVox::Vector` templated on a 32-bit integer.
|
||||||
|
|
||||||
|
The second line creates a :polyvox:`SimpleVolume` of the same size as the :polyvox:`Region` where each voxel in the volume is defined an unsigned 8-bit integer.
|
||||||
|
|
||||||
|
.. literalinclude:: ../examples/Python/PythonExample.py
|
||||||
|
:language: python
|
||||||
|
:lines: 31-33
|
||||||
|
|
||||||
|
We're going to fill our volume with a sphere and so we start by finding out where the centre of the volume is and defining the radius of our desired shape.
|
||||||
|
|
||||||
|
.. literalinclude:: ../examples/Python/PythonExample.py
|
||||||
|
:language: python
|
||||||
|
:lines: 35-37
|
||||||
|
|
||||||
|
Then we actually loop over each of the dimensions of the volume such that inside the loop, ``x``, ``y`` and ``z`` refer to the current location.
|
||||||
|
|
||||||
|
.. literalinclude:: ../examples/Python/PythonExample.py
|
||||||
|
:language: python
|
||||||
|
:lines: 38-41
|
||||||
|
|
||||||
|
All we do inside the loop is set all the voxels inside the sphere to have a value of ``255`` and all those outside to have a value of ``0``.
|
||||||
|
|
||||||
|
.. literalinclude:: ../examples/Python/PythonExample.py
|
||||||
|
:language: python
|
||||||
|
:lines: 42-53
|
||||||
|
|
||||||
|
Getting the mesh data
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Extracting the surface mesh for the volume is a two-step process.
|
||||||
|
First we tell PolyVox to generate the appropriate mesh, then we have to convert the PolyVox mesh data to something that our rendering library can understand.
|
||||||
|
|
||||||
|
First we define the sort of mesh that we want. For this example we want a mesh with information on the position, material and normal of each vertex.
|
||||||
|
Once we have out mesh object ready to be filled, we pass it to our surface extractor of choice.
|
||||||
|
PolyVox comes with a number of different surface extractors but for our example here, we want a cubic mesh.
|
||||||
|
|
||||||
|
You should also note that the ungainly looking ``CubicSurfaceExtractorWithNormalsSimpleVolumeuint8`` refers to the C++ class ``CubicSurfaceExtractorWithNormals<SimpleVolume<uint8_t>>``.
|
||||||
|
The ``execute()`` call is when PolyVox actually goes off and generates the requested mesh based on the data contained in the volume.
|
||||||
|
|
||||||
|
.. literalinclude:: ../examples/Python/PythonExample.py
|
||||||
|
:language: python
|
||||||
|
:lines: 55-58
|
||||||
|
|
||||||
|
Up until this point, the Python code has been totally generic with respect to your choice of rendering engine.
|
||||||
|
For this example we will be using `PyOpenGL <http://pyopengl.sourceforge.net/>`_ as it provides a nice pythonic API for many OpenGL functions.
|
||||||
|
|
||||||
|
Regardless of which rendering engine you are using, you will need to be able to wrangle the PolyVox mesh output into something you can insert into your engine.
|
||||||
|
In our case, we want two lists:
|
||||||
|
|
||||||
|
1. All the vertices along with their normals
|
||||||
|
2. The vertex indices which describes how the vertices are put together to make triangles.
|
||||||
|
|
||||||
|
PyOpenGL undersands `NumPy <http://numpy.org>`_ arrays and so we are going to copy our vertex data into two of these.
|
||||||
|
:polyvox:`SurfaceMesh` provides two useful functions here, ``getIndices()`` and ``getVertices()``, the Python versions of which return Python tuples.
|
||||||
|
|
||||||
|
The indices we can pass directly to NumPy as long as we make sure we specify the correct type for the data inside.
|
||||||
|
For the vertices, we want to rearange the data so that OpenGL can read it more efficiently.
|
||||||
|
To this end we explicitly retrieve the vertex positions and normals for each vertex and place them
|
||||||
|
such that the vertex ``x``, ``y`` and ``z`` positions are placed contiguously in memory followed by the normal vector's ``x``, ``y`` and ``z`` values.
|
||||||
|
|
||||||
|
.. literalinclude:: ../examples/Python/PythonExample.py
|
||||||
|
:language: python
|
||||||
|
:lines: 62-69
|
||||||
|
|
||||||
|
From this point on in the example, PolyVox is no longer used directly and all the code is standard PyOpenGL.
|
||||||
|
I won't go through every line here but the source code in ``PythonExample.py`` is commented and should be sufficient to understand how things work.
|
@ -1,166 +1,194 @@
|
|||||||
**********************
|
**********************
|
||||||
Tutorial 1 - Basic use
|
Tutorial 1 - Basic use
|
||||||
**********************
|
**********************
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
============
|
============
|
||||||
This tutorial covers the basic use of the PolyVox API. After reading this tutorial you should have a good idea how to create a PolyVox volume and fill it with data, extract a triangle mesh representing the surface, and render the result. This tutorial assumes you are already familiar with the basic concepts behind PolyVox (see the :doc:`principles of polyvox <principles>` document if not), and are reasonably confident with 3D graphics and C++. It also assumes you have already got PolyVox installed on your system, if this is not the case then please consult :doc:`installation guide <install>`.
|
This tutorial covers the basic use of the PolyVox API. After reading this tutorial you should have a good idea how to create a PolyVox volume and fill it with data, extract a triangle mesh representing the surface, and render the result. This tutorial assumes you are already familiar with the basic concepts behind PolyVox (see the :doc:`principles of polyvox <principles>` document if not), and are reasonably confident with 3D graphics and C++. It also assumes you have already got PolyVox installed on your system, if this is not the case then please consult :doc:`installation guide <install>`.
|
||||||
|
|
||||||
The code samples and text in this tutorial correspond directly to the BasicExample which comes with PolyVox. This example uses the Qt toolkit for window and input handling, and for providing an OpenGL context to render into. In this tutorial we will omit code which performs these tasks and will instead focus on on the PolyVox code. You can consult the `Qt documentation <http://doc.qt.nokia.com/latest/>`_ if you want more information about these other aspects of the system.
|
The code samples and text in this tutorial correspond directly to the BasicExample which comes with PolyVox. This example uses the Qt toolkit for window and input handling, and for providing an OpenGL context to render into. In this tutorial we will omit code which performs these tasks and will instead focus on on the PolyVox code. You can consult the `Qt documentation <http://doc.qt.nokia.com/latest/>`_ if you want more information about these other aspects of the system.
|
||||||
|
|
||||||
Creating a volume
|
Creating a volume
|
||||||
=================
|
=================
|
||||||
To get started, we need to include the following headers:
|
To get started, we need to include the following headers:
|
||||||
|
|
||||||
.. code-block:: c++
|
.. sourcecode:: c++
|
||||||
|
|
||||||
#include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h"
|
#include "PolyVox/CubicSurfaceExtractor.h"
|
||||||
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.h"
|
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
#include "PolyVox/Mesh.h"
|
||||||
#include "PolyVoxCore/SimpleVolume.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
|
|
||||||
The most fundamental construct when working with PolyVox is that of the volume. This is represented by the :polyvox:`SimpleVolume` class which stores a 3D grid of voxels. Our basic example application creates a volume with the following line of code:
|
The most fundamental construct when working with PolyVox is that of the volume. This is represented by the :polyvox:`RawVolume` class which stores a 3D grid of voxels. Our basic example application creates a volume with the following line of code:
|
||||||
|
|
||||||
.. code-block:: c++
|
.. sourcecode:: c++
|
||||||
|
|
||||||
SimpleVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
|
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
||||||
|
|
||||||
As can be seen, the SimpleVolume class is templated upon the voxel type. This means it is straightforward to create a volume of integers, floats, or a custom voxel type (see the :polyvox:`SimpleVolume documentation <PolyVox::SimpleVolume>` for more details). In this particular case we have created a volume in which each voxel is of type `uint8_t` which is an unsigned 8-bit integer.
|
As can be seen, the RawVolume class is templated upon the voxel type. This means it is straightforward to create a volume of integers, floats, or a custom voxel type (see the :polyvox:`RawVolume documentation <PolyVox::RawVolume>` for more details). In this particular case we have created a volume in which each voxel is of type `uint8_t` which is an unsigned 8-bit integer.
|
||||||
|
|
||||||
Next, we set some of the voxels in the volume to be 'solid' in order to create a large sphere in the centre of the volume. We do this with the following function call:
|
Next, we set some of the voxels in the volume to be 'solid' in order to create a large sphere in the centre of the volume. We do this with the following function call:
|
||||||
|
|
||||||
.. code-block:: c++
|
.. sourcecode:: c++
|
||||||
|
|
||||||
createSphereInVolume(volData, 30);
|
createSphereInVolume(volData, 30);
|
||||||
|
|
||||||
Note that this function is part of the BasicExample (rather than being part of the PolyVox library) and is implemented as follows:
|
Note that this function is part of the BasicExample (rather than being part of the PolyVox library) and is implemented as follows:
|
||||||
|
|
||||||
.. code-block:: c++
|
.. sourcecode:: c++
|
||||||
|
|
||||||
void createSphereInVolume(SimpleVolume<uint8_t>& volData, float fRadius)
|
void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
|
||||||
{
|
{
|
||||||
//This vector hold the position of the center of the volume
|
//This vector hold the position of the center of the volume
|
||||||
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
||||||
|
|
||||||
//This three-level for loop iterates over every voxel in the volume
|
//This three-level for loop iterates over every voxel in the volume
|
||||||
for (int z = 0; z < volData.getDepth(); z++)
|
for (int z = 0; z < volData.getDepth(); z++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < volData.getHeight(); y++)
|
for (int y = 0; y < volData.getHeight(); y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < volData.getWidth(); x++)
|
for (int x = 0; x < volData.getWidth(); x++)
|
||||||
{
|
{
|
||||||
//Store our current position as a vector...
|
//Store our current position as a vector...
|
||||||
Vector3DFloat v3dCurrentPos(x,y,z);
|
Vector3DFloat v3dCurrentPos(x, y, z);
|
||||||
//And compute how far the current position is from the center of the volume
|
//And compute how far the current position is from the center of the volume
|
||||||
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
|
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
|
||||||
|
|
||||||
uint8_t uVoxelValue = 0;
|
uint8_t uVoxelValue = 0;
|
||||||
|
|
||||||
//If the current voxel is less than 'radius' units from the center then we make it solid.
|
//If the current voxel is less than 'radius' units from the center then we make it solid.
|
||||||
if(fDistToCenter <= fRadius)
|
if (fDistToCenter <= fRadius)
|
||||||
{
|
{
|
||||||
//Our new voxel value
|
//Our new voxel value
|
||||||
uVoxelValue = 255;
|
uVoxelValue = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Wrte the voxel value into the volume
|
//Wrte the voxel value into the volume
|
||||||
volData.setVoxelAt(x, y, z, uVoxelValue);
|
volData.setVoxel(x, y, z, uVoxelValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
This function takes as input the :polyvox:`SimpleVolume` in which we want to create the sphere, and also a radius specifying how large we want the sphere to be. In our case we have specified a radius of 30 voxels, which will fit nicely inside our :polyvox:`SimpleVolume` of dimensions 64x64x64.
|
This function takes as input the :polyvox:`RawVolume` in which we want to create the sphere, and also a radius specifying how large we want the sphere to be. In our case we have specified a radius of 30 voxels, which will fit nicely inside our :polyvox:`RawVolume` of dimensions 64x64x64.
|
||||||
|
|
||||||
Because this is a simple example function it always places the sphere at the centre of the volume. It computes this centre by halving the dimensions of the volume as given by the functions :polyvox:`SimpleVolume::getWidth`, :polyvox:`SimpleVolume::getHeight` and :polyvox:`SimpleVolume::getDepth`. The resulting position is stored using a :polyvox:`Vector3DFloat`. This is simply a typedef from our templatised :polyvox:`Vector` class, meaning that other sizes and storage types are available if you need them.
|
Because this is a simple example function it always places the sphere at the centre of the volume. It computes this centre by halving the dimensions of the volume as given by the functions :polyvox:`SimpleVolume::getWidth`, :polyvox:`SimpleVolume::getHeight` and :polyvox:`SimpleVolume::getDepth`. The resulting position is stored using a :polyvox:`Vector3DFloat`. This is simply a typedef from our templatised :polyvox:`Vector` class, meaning that other sizes and storage types are available if you need them.
|
||||||
|
|
||||||
Next, the function uses a three-level 'for' loop to iterate over each voxel in the volume. For each voxel it computes the distance from the voxel to the centre of the volume. If this distance is less than or equal to the specified radius then the voxel forms part of the sphere and is made solid. During surface extraction, the voxel will be considered empty if it has a value of zero, and otherwise it will be considered solid. In our case we simply set it to 255 which is the largest value a uint8_t can contain.
|
Next, the function uses a three-level 'for' loop to iterate over each voxel in the volume. For each voxel it computes the distance from the voxel to the centre of the volume. If this distance is less than or equal to the specified radius then the voxel forms part of the sphere and is made solid.
|
||||||
|
|
||||||
Extracting the surface
|
Extracting the surface
|
||||||
======================
|
======================
|
||||||
Now that we have built our volume we need to convert it into a triangle mesh for rendering. This process can be performed by the :polyvox:`CubicSurfaceExtractorWithNormals` class. An instance of the :polyvox:`CubicSurfaceExtractorWithNormals` is created as follows:
|
Now that we have built our volume we need to convert it into a triangle mesh for rendering. This process can be performed by the :polyvox:`extractCubicMesh` function:
|
||||||
|
|
||||||
.. code-block:: c++
|
.. sourcecode:: c++
|
||||||
|
|
||||||
SurfaceMesh<PositionMaterialNormal> mesh;
|
auto mesh = extractCubicMesh(&volData, volData.getEnclosingRegion());
|
||||||
CubicSurfaceExtractorWithNormals< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
|
||||||
|
The :polyvox:`extractCubicMesh` function takes a pointer to the volume data, and also it needs to be told which :polyvox:`Region` of the volume the extraction should be performed on (in more advanced applications this is useful for extracting only those parts of the volume which have been modified since the last extraction). For our purpose the :polyvox:`RawVolume` class provides a convenient :polyvox:`RawVolume::getEnclosingRegion` function which returns a :polyvox:`Region` representing the whole volume.
|
||||||
The :polyvox:`CubicSurfaceExtractorWithNormals` takes a pointer to the volume data, and also it needs to be told which :polyvox:`Region` of the volume the extraction should be performed on (in more advanced applications this is useful for extracting only those parts of the volume which have been modified since the last extraction). For our purpose the :polyvox:`SimpleVolume` class provides a convenient :polyvox:`SimpleVolume::getEnclosingRegion` function which returns a :polyvox:`Region` representing the whole volume. The constructor also takes a pointer to a :polyvox:`SurfaceMesh` object where it will store the result, so we need to create one of these before we can construct the :polyvox:`CubicSurfaceExtractorWithNormals`.
|
|
||||||
|
The resulting mesh has a complex templatized type and so we assign it to a variable declared with 'auto', This way the compiler will determine the correct type for us. PolyVox also makes use of some compression techniques to store the vertex data in a compact way. Therefore the vertices of the mesh need to be decompressed ('decoded') before they can be used. For now the easiest approach is to use the provided ``decode()`` function, though advanced users can actually do this decoding on the GPU (see 'DecodeOnGPUExample'):
|
||||||
The actual extraction happens in the :polyvox:`CubicSurfaceExtractorWithNormals::execute` function. This means you can set up a :polyvox:`CubicSurfaceExtractorWithNormals` with the required parameters and then actually execute it later. For this example we just call it straight away.
|
|
||||||
|
.. sourcecode:: c++
|
||||||
.. code-block:: c++
|
|
||||||
|
auto decodedMesh = decodeMesh(mesh);
|
||||||
surfaceExtractor.execute();
|
|
||||||
|
Our ``decodedMesh`` variable contains an index and vertex buffer representing the desired triangle mesh.
|
||||||
This fills in our :polyvox:`SurfaceMesh` object, which basically contains an index and vertex buffer representing the desired triangle mesh.
|
|
||||||
|
Note: If you like you can try swapping the :polyvox:`extractCubicMesh` for :polyvox:`extractMarchingCubesMesh`. We have already included the relevant header, and in the BasicExample you just need to change which line in commented out. The :polyvox:`MarchingCubesSurfaceExtractor` makes use of a smooth density field and will consider a voxel to be solid if it is above a threshold of half the voxel's maximum value (so in this case that's half of 255, which is 127).
|
||||||
Note: If you like you can try swapping the :polyvox:`CubicSurfaceExtractorWithNormals` for :polyvox:`MarchingCubesSurfaceExtractor`. We have already included the relevant header, and in the BasicExample you just need to change which line in commented out. The :polyvox:`MarchingCubesSurfaceExtractor` makes use of a smooth density field and will consider a voxel to be solid if it is above a threshold of half the voxel's maximum value (so in this case that's half of 255, which is 127).
|
|
||||||
|
Rendering the surface
|
||||||
Rendering the surface
|
=====================
|
||||||
=====================
|
Rendering the surface with OpenGL is handled by our ``PolyVoxExample`` which is an ``OpenGLWidget`` subclass. Again, this is not part of PolyVox, it is simply an example based on Qt and OpenGL which demonstrates how rendering can be performed. Within this class there are mainly two functions which are of interest - the PolyVoxExample::addMesh() function which constructs OpenGL buffers from our :polyvox:`Mesh` and the PolyVoxExample::renderOneFrame() function which is called each frame to perform the rendering.
|
||||||
Rendering the surface with OpenGL is handled by the OpenGLWidget class. Again, this is not part of PolyVox, it is simply an example based on Qt and OpenGL which demonstrates how rendering can be performed. Within this class there are mainly two functions which are of interest - the OpenGLWidget::setSurfaceMeshToRender() function which constructs OpenGL buffers from our :polyvox:`SurfaceMesh` and the OpenGLWidget::paintGL() function which is called each frame to perform the rendering.
|
|
||||||
|
The PolyVoxExample::addMesh() function is implemented as follows:
|
||||||
The OpenGLWidget::setSurfaceMeshToRender() function is implemented as follows:
|
|
||||||
|
.. sourcecode:: c++
|
||||||
.. code-block:: c++
|
|
||||||
|
template <typename MeshType>
|
||||||
void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PositionMaterialNormal>& surfaceMesh)
|
void addMesh(const MeshType& surfaceMesh, const PolyVox::Vector3DInt32& translation = PolyVox::Vector3DInt32(0, 0, 0), float scale = 1.0f)
|
||||||
{
|
{
|
||||||
//Convienient access to the vertices and indices
|
// This struct holds the OpenGL properties (buffer handles, etc) which will be used
|
||||||
const vector<uint32_t>& vecIndices = surfaceMesh.getIndices();
|
// to render our mesh. We copy the data from the PolyVox mesh into this structure.
|
||||||
const vector<PositionMaterialNormal>& vecVertices = surfaceMesh.getVertices();
|
OpenGLMeshData meshData;
|
||||||
|
|
||||||
//Build an OpenGL index buffer
|
// Create the VAO for the mesh
|
||||||
glGenBuffers(1, &indexBuffer);
|
glGenVertexArrays(1, &(meshData.vertexArrayObject));
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
|
glBindVertexArray(meshData.vertexArrayObject);
|
||||||
const GLvoid* pIndices = static_cast<const GLvoid*>(&(vecIndices[0]));
|
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, vecIndices.size() * sizeof(uint32_t), pIndices, GL_STATIC_DRAW);
|
// The GL_ARRAY_BUFFER will contain the list of vertex positions
|
||||||
|
glGenBuffers(1, &(meshData.vertexBuffer));
|
||||||
//Build an OpenGL vertex buffer
|
glBindBuffer(GL_ARRAY_BUFFER, meshData.vertexBuffer);
|
||||||
glGenBuffers(1, &vertexBuffer);
|
glBufferData(GL_ARRAY_BUFFER, surfaceMesh.getNoOfVertices() * sizeof(typename MeshType::VertexType), surfaceMesh.getRawVertexData(), GL_STATIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
|
||||||
const GLvoid* pVertices = static_cast<const GLvoid*>(&(vecVertices[0]));
|
// and GL_ELEMENT_ARRAY_BUFFER will contain the indices
|
||||||
glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(PositionMaterialNormal), pVertices, GL_STATIC_DRAW);
|
glGenBuffers(1, &(meshData.indexBuffer));
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, meshData.indexBuffer);
|
||||||
m_uBeginIndex = 0;
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, surfaceMesh.getNoOfIndices() * sizeof(typename MeshType::IndexType), surfaceMesh.getRawIndexData(), GL_STATIC_DRAW);
|
||||||
m_uEndIndex = vecIndices.size();
|
|
||||||
}
|
// Every surface extractor outputs valid positions for the vertices, so tell OpenGL how these are laid out
|
||||||
|
glEnableVertexAttribArray(0); // Attrib '0' is the vertex positions
|
||||||
We begin by obtaining direct access to the index and vertex buffer in the :polyvox:`SurfaceMesh` class in order to make the following code slightly cleaner. Both the :polyvox:`SurfaceMesh::getIndices` and :polyvox:`SurfaceMesh::getVertices` functions return an std::vector containing the relevant data.
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(typename MeshType::VertexType), (GLvoid*)(offsetof(typename MeshType::VertexType, position))); //take the first 3 floats from every sizeof(decltype(vecVertices)::value_type)
|
||||||
|
|
||||||
The OpenGL functions which are called to construct the index and vertex buffer are best explained by the OpenGL documentation. In both cases we are making an exact copy of the data stored in the :polyvox:`SurfaceMesh`.
|
// Some surface extractors also generate normals, so tell OpenGL how these are laid out. If a surface extractor
|
||||||
|
// does not generate normals then nonsense values are written into the buffer here and sghould be ignored by the
|
||||||
The begin and end indices are used in the OpenGLWidget::paintGL() to control what part of the index buffer is actually rendered. For this simple example we will render the whole buffer from '0' to 'vecIndices.size()'.
|
// shader. This is mostly just to simplify this example code - in a real application you will know whether your
|
||||||
|
// chosen surface extractor generates normals and can skip uploading them if not.
|
||||||
With the OpenGL index and vertex buffers set up, we can now look at the code which is called each frame to render them:
|
glEnableVertexAttribArray(1); // Attrib '1' is the vertex normals.
|
||||||
|
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(typename MeshType::VertexType), (GLvoid*)(offsetof(typename MeshType::VertexType, normal)));
|
||||||
.. code-block:: c++
|
|
||||||
|
// Finally a surface extractor will probably output additional data. This is highly application dependant. For this example code
|
||||||
void OpenGLWidget::paintGL()
|
// we're just uploading it as a set of bytes which we can read individually, but real code will want to do something specialised here.
|
||||||
{
|
glEnableVertexAttribArray(2); //We're talking about shader attribute '2'
|
||||||
//Clear the screen
|
GLint size = (std::min)(sizeof(typename MeshType::VertexType::DataType), size_t(4)); // Can't upload more that 4 components (vec4 is GLSL's biggest type)
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glVertexAttribIPointer(2, size, GL_UNSIGNED_BYTE, sizeof(typename MeshType::VertexType), (GLvoid*)(offsetof(typename MeshType::VertexType, data)));
|
||||||
|
|
||||||
//Set up the viewing transformation
|
// We're done uploading and can now unbind.
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glBindVertexArray(0);
|
||||||
glLoadIdentity();
|
|
||||||
glTranslatef(0.0f,0.0f,-100.0f); //Centre volume and move back
|
// A few additional properties can be copied across for use during rendering.
|
||||||
glRotatef(-m_xRotation, 0.0f, 1.0f, 0.0f);
|
meshData.noOfIndices = surfaceMesh.getNoOfIndices();
|
||||||
glRotatef(-m_yRotation, 1.0f, 0.0f, 0.0f);
|
meshData.translation = QVector3D(translation.getX(), translation.getY(), translation.getZ());
|
||||||
glTranslatef(-32.0f,-32.0f,-32.0f); //Centre volume and move back
|
meshData.scale = scale;
|
||||||
|
|
||||||
//Bind the index buffer
|
// Set 16 or 32-bit index buffer size.
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
|
meshData.indexType = sizeof(typename MeshType::IndexType) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
|
||||||
|
|
||||||
//Bind the vertex buffer
|
// Now add the mesh to the list of meshes to render.
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
addMeshData(meshData);
|
||||||
glVertexPointer(3, GL_FLOAT, sizeof(PositionMaterialNormal), 0);
|
}
|
||||||
glNormalPointer(GL_FLOAT, sizeof(PositionMaterialNormal), (GLvoid*)12);
|
|
||||||
|
With the OpenGL index and vertex buffers set up, we can now look at the code which is called each frame to render them:
|
||||||
glDrawRangeElements(GL_TRIANGLES, m_uBeginIndex, m_uEndIndex-1, m_uEndIndex - m_uBeginIndex, GL_UNSIGNED_INT, 0);
|
|
||||||
|
.. sourcecode:: c++
|
||||||
//Error checking code here...
|
|
||||||
}
|
void renderOneFrame() override
|
||||||
|
{
|
||||||
Again, the explanation of this code is best left to the OpenGL documentation. Note that is is called automatically by Qt each time the display needs to be updated.
|
// Our example framework only uses a single shader for the scene (for all meshes).
|
||||||
|
mShader->bind();
|
||||||
|
|
||||||
|
// These two matrices are constant for all meshes.
|
||||||
|
mShader->setUniformValue("viewMatrix", viewMatrix());
|
||||||
|
mShader->setUniformValue("projectionMatrix", projectionMatrix());
|
||||||
|
|
||||||
|
// Iterate over each mesh which the user added to our list, and render it.
|
||||||
|
for (OpenGLMeshData meshData : mMeshData)
|
||||||
|
{
|
||||||
|
//Set up the model matrrix based on provided translation and scale.
|
||||||
|
QMatrix4x4 modelMatrix;
|
||||||
|
modelMatrix.translate(meshData.translation);
|
||||||
|
modelMatrix.scale(meshData.scale);
|
||||||
|
mShader->setUniformValue("modelMatrix", modelMatrix);
|
||||||
|
|
||||||
|
// Bind the vertex array for the current mesh
|
||||||
|
glBindVertexArray(meshData.vertexArrayObject);
|
||||||
|
// Draw the mesh
|
||||||
|
glDrawElements(GL_TRIANGLES, meshData.noOfIndices, meshData.indexType, 0);
|
||||||
|
// Unbind the vertex array.
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We're done with the shader for this frame.
|
||||||
|
mShader->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
Again, the explanation of this code is best left to the OpenGL documentation.
|
@ -1,79 +1,77 @@
|
|||||||
# Copyright (c) 2010-2012 David Williams
|
################################################################################
|
||||||
#
|
# The MIT License (MIT)
|
||||||
# This software is provided 'as-is', without any express or implied
|
#
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
# arising from the use of this software.
|
#
|
||||||
#
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# including commercial applications, and to alter it and redistribute it
|
# in the Software without restriction, including without limitation the rights
|
||||||
# freely, subject to the following restrictions:
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
#
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
# furnished to do so, subject to the following conditions:
|
||||||
# claim that you wrote the original software. If you use this software
|
#
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# appreciated but is not required.
|
# copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# misrepresented as being the original software.
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# 3. This notice may not be removed or altered from any source
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# distribution.
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
# SOFTWARE.
|
||||||
|
################################################################################
|
||||||
PROJECT(BasicExample)
|
|
||||||
|
PROJECT(BasicExample)
|
||||||
#Projects source files
|
|
||||||
SET(SRC_FILES
|
#Projects source files
|
||||||
glew/glew.cpp
|
SET(SRC_FILES
|
||||||
|
main.cpp
|
||||||
main.cpp
|
../common/PolyVoxExample.cpp
|
||||||
OpenGLWidget.cpp
|
)
|
||||||
)
|
|
||||||
|
#Projects headers files
|
||||||
#Projects headers files
|
SET(INC_FILES
|
||||||
SET(INC_FILES
|
../common/OpenGLWidget.h
|
||||||
glew/glew.h
|
../common/OpenGLWidget.inl
|
||||||
glew/glxew.h
|
../common/PolyVoxExample.h
|
||||||
glew/wglew.h
|
)
|
||||||
|
|
||||||
OpenGLWidget.h
|
#"Sources" and "Headers" are the group names in Visual Studio.
|
||||||
)
|
#They may have other uses too...
|
||||||
|
SOURCE_GROUP("Sources" FILES ${SRC_FILES})
|
||||||
ADD_DEFINITIONS(-DGLEW_STATIC)
|
SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
||||||
|
|
||||||
#"Sources" and "Headers" are the group names in Visual Studio.
|
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
||||||
#They may have other uses too...
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ../common)
|
||||||
SOURCE_GROUP("Sources" FILES ${SRC_FILES})
|
|
||||||
SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
#This will include the shader files inside the compiled binary
|
||||||
|
QT5_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc)
|
||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
|
||||||
|
# Put the resources in a seperate folder in Visual Studio
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
SOURCE_GROUP("Resource Files" FILES ../common/example.qrc ${COMMON_RESOURCES_RCC})
|
||||||
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include)
|
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
#Build
|
||||||
|
ADD_EXECUTABLE(BasicExample ${SRC_FILES} ${COMMON_RESOURCES_RCC})
|
||||||
#Build
|
IF(MSVC)
|
||||||
ADD_EXECUTABLE(BasicExample ${SRC_FILES})
|
SET_TARGET_PROPERTIES(BasicExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") #All warnings
|
||||||
IF(MSVC)
|
ENDIF(MSVC)
|
||||||
SET_TARGET_PROPERTIES(BasicExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
|
TARGET_LINK_LIBRARIES(BasicExample Qt5::OpenGL)
|
||||||
ENDIF(MSVC)
|
SET_PROPERTY(TARGET BasicExample PROPERTY FOLDER "Examples")
|
||||||
TARGET_LINK_LIBRARIES(BasicExample ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore)
|
|
||||||
SET_PROPERTY(TARGET BasicExample PROPERTY FOLDER "Examples")
|
#Install - Only install the example in Windows
|
||||||
|
IF(WIN32)
|
||||||
#Install - Only install the example in Windows
|
INSTALL(TARGETS BasicExample
|
||||||
IF(WIN32)
|
RUNTIME DESTINATION Examples/OpenGL/bin
|
||||||
INSTALL(TARGETS BasicExample
|
LIBRARY DESTINATION Examples/OpenGL/lib
|
||||||
RUNTIME DESTINATION Examples/OpenGL/bin
|
ARCHIVE DESTINATION Examples/OpenGL/lib
|
||||||
LIBRARY DESTINATION Examples/OpenGL/lib
|
COMPONENT example
|
||||||
ARCHIVE DESTINATION Examples/OpenGL/lib
|
)
|
||||||
COMPONENT example
|
|
||||||
)
|
#.dlls should be installed in shared builds.
|
||||||
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
||||||
#.dlls should be installed in shared builds.
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
||||||
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
ENDIF(WIN32)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
|
||||||
ENDIF(WIN32)
|
|
||||||
|
@ -1,152 +0,0 @@
|
|||||||
#include "OpenGLWidget.h"
|
|
||||||
|
|
||||||
#include <QMouseEvent>
|
|
||||||
|
|
||||||
using namespace PolyVox;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
OpenGLWidget::OpenGLWidget(QWidget *parent)
|
|
||||||
:QGLWidget(parent)
|
|
||||||
,m_xRotation(0)
|
|
||||||
,m_yRotation(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PositionMaterialNormal>& surfaceMesh)
|
|
||||||
{
|
|
||||||
//Convienient access to the vertices and indices
|
|
||||||
const vector<uint32_t>& vecIndices = surfaceMesh.getIndices();
|
|
||||||
const vector<PositionMaterialNormal>& vecVertices = surfaceMesh.getVertices();
|
|
||||||
|
|
||||||
//Build an OpenGL index buffer
|
|
||||||
glGenBuffers(1, &indexBuffer);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
||||||
const GLvoid* pIndices = static_cast<const GLvoid*>(&(vecIndices[0]));
|
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, vecIndices.size() * sizeof(uint32_t), pIndices, GL_STATIC_DRAW);
|
|
||||||
|
|
||||||
//Build an OpenGL vertex buffer
|
|
||||||
glGenBuffers(1, &vertexBuffer);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
|
||||||
const GLvoid* pVertices = static_cast<const GLvoid*>(&(vecVertices[0]));
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(PositionMaterialNormal), pVertices, GL_STATIC_DRAW);
|
|
||||||
|
|
||||||
m_uBeginIndex = 0;
|
|
||||||
m_uEndIndex = vecIndices.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::initializeGL()
|
|
||||||
{
|
|
||||||
//We need GLEW to access recent OpenGL functionality
|
|
||||||
std::cout << "Initialising GLEW...";
|
|
||||||
GLenum result = glewInit();
|
|
||||||
if (result == GLEW_OK)
|
|
||||||
{
|
|
||||||
std::cout << "success" << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Problem: glewInit failed, something is seriously wrong. */
|
|
||||||
std::cout << "failed" << std::endl;
|
|
||||||
std::cout << "Initialising GLEW failed with the following error: " << glewGetErrorString(result) << std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Print out some information about the OpenGL implementation.
|
|
||||||
std::cout << "OpenGL Implementation Details:" << std::endl;
|
|
||||||
if(glGetString(GL_VENDOR))
|
|
||||||
std::cout << "\tGL_VENDOR: " << glGetString(GL_VENDOR) << std::endl;
|
|
||||||
if(glGetString(GL_RENDERER))
|
|
||||||
std::cout << "\tGL_RENDERER: " << glGetString(GL_RENDERER) << std::endl;
|
|
||||||
if(glGetString(GL_VERSION))
|
|
||||||
std::cout << "\tGL_VERSION: " << glGetString(GL_VERSION) << std::endl;
|
|
||||||
if(glGetString(GL_SHADING_LANGUAGE_VERSION))
|
|
||||||
std::cout << "\tGL_SHADING_LANGUAGE_VERSION: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
|
|
||||||
|
|
||||||
//Check our version of OpenGL is recent enough.
|
|
||||||
//We need at least 1.5 for vertex buffer objects,
|
|
||||||
if (!GLEW_VERSION_1_5)
|
|
||||||
{
|
|
||||||
std::cout << "Error: You need OpenGL version 1.5 to run this example." << std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set up the clear colour
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
|
||||||
glClearDepth(1.0f);
|
|
||||||
|
|
||||||
//Enable the depth buffer
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
|
|
||||||
//Anable smooth lighting
|
|
||||||
glEnable(GL_LIGHTING);
|
|
||||||
glEnable(GL_LIGHT0);
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
|
|
||||||
//We'll be rendering with index/vertex arrays
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::resizeGL(int w, int h)
|
|
||||||
{
|
|
||||||
//Setup the viewport
|
|
||||||
glViewport(0, 0, w, h);
|
|
||||||
|
|
||||||
//Set up the projection matrix
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
float frustumSize = 32.0f; //Half the volume size
|
|
||||||
float aspect = static_cast<float>(width()) / static_cast<float>(height());
|
|
||||||
glOrtho(frustumSize*aspect, -frustumSize*aspect, frustumSize, -frustumSize, 1.0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::paintGL()
|
|
||||||
{
|
|
||||||
//Clear the screen
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
//Set up the viewing transformation
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
glTranslatef(0.0f,0.0f,-100.0f); //Centre volume and move back
|
|
||||||
glRotatef(-m_xRotation, 0.0f, 1.0f, 0.0f);
|
|
||||||
glRotatef(-m_yRotation, 1.0f, 0.0f, 0.0f);
|
|
||||||
glTranslatef(-32.0f,-32.0f,-32.0f); //Centre volume and move back
|
|
||||||
|
|
||||||
//Bind the index buffer
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
||||||
|
|
||||||
//Bind the vertex buffer
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
|
||||||
glVertexPointer(3, GL_FLOAT, sizeof(PositionMaterialNormal), 0);
|
|
||||||
glNormalPointer(GL_FLOAT, sizeof(PositionMaterialNormal), (GLvoid*)12);
|
|
||||||
|
|
||||||
glDrawRangeElements(GL_TRIANGLES, m_uBeginIndex, m_uEndIndex-1, m_uEndIndex - m_uBeginIndex, GL_UNSIGNED_INT, 0);
|
|
||||||
|
|
||||||
GLenum errCode = glGetError();
|
|
||||||
if(errCode != GL_NO_ERROR)
|
|
||||||
{
|
|
||||||
//What has replaced getErrorString() in the latest OpenGL?
|
|
||||||
std::cout << "OpenGL Error: " << errCode << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::mousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
m_CurrentMousePos = event->pos();
|
|
||||||
m_LastFrameMousePos = m_CurrentMousePos;
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::mouseMoveEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
m_CurrentMousePos = event->pos();
|
|
||||||
QPoint diff = m_CurrentMousePos - m_LastFrameMousePos;
|
|
||||||
m_xRotation += diff.x();
|
|
||||||
m_yRotation += diff.y();
|
|
||||||
m_LastFrameMousePos = m_CurrentMousePos;
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __BasicExample_OpenGLWidget_H__
|
|
||||||
#define __BasicExample_OpenGLWidget_H__
|
|
||||||
|
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
|
||||||
|
|
||||||
#include "glew/glew.h"
|
|
||||||
|
|
||||||
#include <QGLWidget>
|
|
||||||
|
|
||||||
class OpenGLWidget : public QGLWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//Constructor
|
|
||||||
OpenGLWidget(QWidget *parent);
|
|
||||||
|
|
||||||
//Mouse handling
|
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
|
||||||
void mousePressEvent(QMouseEvent* event);
|
|
||||||
|
|
||||||
//Convert a SrfaceMesh to OpenGL index/vertex buffers
|
|
||||||
void setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>& surfaceMesh);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
//Qt OpenGL functions
|
|
||||||
void initializeGL();
|
|
||||||
void resizeGL(int w, int h);
|
|
||||||
void paintGL();
|
|
||||||
|
|
||||||
private:
|
|
||||||
//Index/vertex buffer data
|
|
||||||
GLuint m_uBeginIndex;
|
|
||||||
GLuint m_uEndIndex;
|
|
||||||
GLuint noOfIndices;
|
|
||||||
GLuint indexBuffer;
|
|
||||||
GLuint vertexBuffer;
|
|
||||||
|
|
||||||
//Mouse data
|
|
||||||
QPoint m_LastFrameMousePos;
|
|
||||||
QPoint m_CurrentMousePos;
|
|
||||||
int m_xRotation;
|
|
||||||
int m_yRotation;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //__BasicExample_OpenGLWidget_H__
|
|
@ -1,73 +0,0 @@
|
|||||||
The OpenGL Extension Wrangler Library
|
|
||||||
Copyright (C) 2002-2007, Milan Ikits <milan ikits[]ieee org>
|
|
||||||
Copyright (C) 2002-2007, Marcelo E. Magallon <mmagallo[]debian org>
|
|
||||||
Copyright (C) 2002, Lev Povalahev
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
* The name of the author may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
||||||
THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
Mesa 3-D graphics library
|
|
||||||
Version: 7.0
|
|
||||||
|
|
||||||
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
copy of this software and associated documentation files (the "Software"),
|
|
||||||
to deal in the Software without restriction, including without limitation
|
|
||||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included
|
|
||||||
in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
||||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2007 The Khronos Group Inc.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
copy of this software and/or associated documentation files (the
|
|
||||||
"Materials"), to deal in the Materials without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Materials, and to
|
|
||||||
permit persons to whom the Materials are furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included
|
|
||||||
in all copies or substantial portions of the Materials.
|
|
||||||
|
|
||||||
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,95 +1,109 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Copyright (c) 2005-2009 David Williams
|
The MIT License (MIT)
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
Copyright (c) 2015 David Williams and Matthew Williams
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
in the Software without restriction, including without limitation the rights
|
||||||
including commercial applications, and to alter it and redistribute it
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
freely, subject to the following restrictions:
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
The above copyright notice and this permission notice shall be included in all
|
||||||
in a product, an acknowledgment in the product documentation would be
|
copies or substantial portions of the Software.
|
||||||
appreciated but is not required.
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
misrepresented as being the original software.
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
3. This notice may not be removed or altered from any source
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
distribution.
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
*******************************************************************************/
|
SOFTWARE.
|
||||||
|
*******************************************************************************/
|
||||||
#include "OpenGLWidget.h"
|
|
||||||
|
#include "PolyVoxExample.h"
|
||||||
#include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h"
|
|
||||||
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.h"
|
#include "PolyVox/CubicSurfaceExtractor.h"
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
||||||
#include "PolyVoxCore/SimpleVolume.h"
|
#include "PolyVox/Mesh.h"
|
||||||
|
#include "PolyVox/RawVolume.h"
|
||||||
#include <QApplication>
|
|
||||||
|
#include <QApplication>
|
||||||
//Use the PolyVox namespace
|
|
||||||
using namespace PolyVox;
|
//Use the PolyVox namespace
|
||||||
|
using namespace PolyVox;
|
||||||
void createSphereInVolume(SimpleVolume<uint8_t>& volData, float fRadius)
|
|
||||||
{
|
void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
|
||||||
//This vector hold the position of the center of the volume
|
{
|
||||||
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
//This vector hold the position of the center of the volume
|
||||||
|
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
||||||
//This three-level for loop iterates over every voxel in the volume
|
|
||||||
for (int z = 0; z < volData.getDepth(); z++)
|
//This three-level for loop iterates over every voxel in the volume
|
||||||
{
|
for (int z = 0; z < volData.getDepth(); z++)
|
||||||
for (int y = 0; y < volData.getHeight(); y++)
|
{
|
||||||
{
|
for (int y = 0; y < volData.getHeight(); y++)
|
||||||
for (int x = 0; x < volData.getWidth(); x++)
|
{
|
||||||
{
|
for (int x = 0; x < volData.getWidth(); x++)
|
||||||
//Store our current position as a vector...
|
{
|
||||||
Vector3DFloat v3dCurrentPos(x,y,z);
|
//Store our current position as a vector...
|
||||||
//And compute how far the current position is from the center of the volume
|
Vector3DFloat v3dCurrentPos(x, y, z);
|
||||||
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
|
//And compute how far the current position is from the center of the volume
|
||||||
|
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
|
||||||
uint8_t uVoxelValue = 0;
|
|
||||||
|
uint8_t uVoxelValue = 0;
|
||||||
//If the current voxel is less than 'radius' units from the center then we make it solid.
|
|
||||||
if(fDistToCenter <= fRadius)
|
//If the current voxel is less than 'radius' units from the center then we make it solid.
|
||||||
{
|
if (fDistToCenter <= fRadius)
|
||||||
//Our new voxel value
|
{
|
||||||
uVoxelValue = 255;
|
//Our new voxel value
|
||||||
}
|
uVoxelValue = 255;
|
||||||
|
}
|
||||||
//Wrte the voxel value into the volume
|
|
||||||
volData.setVoxelAt(x, y, z, uVoxelValue);
|
//Wrte the voxel value into the volume
|
||||||
}
|
volData.setVoxel(x, y, z, uVoxelValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
class BasicExample : public PolyVoxExample
|
||||||
//Create and show the Qt OpenGL window
|
{
|
||||||
QApplication app(argc, argv);
|
public:
|
||||||
OpenGLWidget openGLWidget(0);
|
BasicExample(QWidget *parent)
|
||||||
openGLWidget.show();
|
:PolyVoxExample(parent)
|
||||||
|
{
|
||||||
//Create an empty volume and then place a sphere in it
|
}
|
||||||
SimpleVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
|
|
||||||
createSphereInVolume(volData, 30);
|
protected:
|
||||||
|
void initializeExample() override
|
||||||
//A mesh object to hold the result of surface extraction
|
{
|
||||||
SurfaceMesh<PositionMaterialNormal> mesh;
|
// Create an empty volume and then place a sphere in it
|
||||||
|
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
||||||
//Create a surface extractor. Comment out one of the following two lines to decide which type gets created.
|
createSphereInVolume(volData, 30);
|
||||||
CubicSurfaceExtractorWithNormals< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
|
||||||
//MarchingCubesSurfaceExtractor< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.
|
||||||
|
auto mesh = extractCubicMesh(&volData, volData.getEnclosingRegion());
|
||||||
//Execute the surface extractor.
|
//auto mesh = extractMarchingCubesMesh(&volData, volData.getEnclosingRegion());
|
||||||
surfaceExtractor.execute();
|
|
||||||
|
// The surface extractor outputs the mesh in an efficient compressed format which is not directly suitable for rendering. The easiest approach is to
|
||||||
//Pass the surface to the OpenGL window
|
// decode this on the CPU as shown below, though more advanced applications can upload the compressed mesh to the GPU and decompress in shader code.
|
||||||
openGLWidget.setSurfaceMeshToRender(mesh);
|
auto decodedMesh = decodeMesh(mesh);
|
||||||
|
|
||||||
//Run the message pump.
|
//Pass the surface to the OpenGL window
|
||||||
return app.exec();
|
addMesh(decodedMesh);
|
||||||
}
|
|
||||||
|
setCameraTransform(QVector3D(100.0f, 100.0f, 100.0f), -(PI / 4.0f), PI + (PI / 4.0f));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
//Create and show the Qt OpenGL window
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
BasicExample openGLWidget(0);
|
||||||
|
openGLWidget.show();
|
||||||
|
|
||||||
|
//Run the message pump.
|
||||||
|
return app.exec();
|
||||||
|
}
|
40
examples/CMakeLists.txt
Normal file
40
examples/CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
################################################################################
|
||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
find_package(Qt5OpenGL 5.2)
|
||||||
|
|
||||||
|
set_package_properties(Qt5OpenGL PROPERTIES DESCRIPTION "C++ framework" URL http://qt-project.org)
|
||||||
|
set_package_properties(Qt5OpenGL PROPERTIES TYPE RECOMMENDED PURPOSE "Building the examples")
|
||||||
|
|
||||||
|
if(Qt5OpenGL_FOUND)
|
||||||
|
SET(BUILD_EXAMPLES ON PARENT_SCOPE)
|
||||||
|
ADD_SUBDIRECTORY(Basic)
|
||||||
|
ADD_SUBDIRECTORY(Paging)
|
||||||
|
ADD_SUBDIRECTORY(OpenGL)
|
||||||
|
ADD_SUBDIRECTORY(SmoothLOD)
|
||||||
|
ADD_SUBDIRECTORY(DecodeOnGPU)
|
||||||
|
ADD_SUBDIRECTORY(Python)
|
||||||
|
else()
|
||||||
|
SET(BUILD_EXAMPLES OFF PARENT_SCOPE)
|
||||||
|
endif()
|
71
examples/DecodeOnGPU/CMakeLists.txt
Normal file
71
examples/DecodeOnGPU/CMakeLists.txt
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
################################################################################
|
||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
PROJECT(DecodeOnGPUExample)
|
||||||
|
|
||||||
|
#Projects source files
|
||||||
|
SET(SRC_FILES
|
||||||
|
main.cpp
|
||||||
|
../common/PolyVoxExample.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
#Projects headers files
|
||||||
|
SET(INC_FILES
|
||||||
|
../common/OpenGLWidget.h
|
||||||
|
../common/OpenGLWidget.inl
|
||||||
|
../common/PolyVoxExample.h
|
||||||
|
)
|
||||||
|
|
||||||
|
#"Sources" and "Headers" are the group names in Visual Studio.
|
||||||
|
#They may have other uses too...
|
||||||
|
SOURCE_GROUP("Sources" FILES ${SRC_FILES})
|
||||||
|
SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
||||||
|
|
||||||
|
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
||||||
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ../common)
|
||||||
|
|
||||||
|
#This will include the shader files inside the compiled binary
|
||||||
|
QT5_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc)
|
||||||
|
QT5_ADD_RESOURCES(DECODE_RESOURCES_RCC decode.qrc)
|
||||||
|
|
||||||
|
# Put the resources in a seperate folder in Visual Studio
|
||||||
|
SOURCE_GROUP("Resource Files" FILES ../common/example.qrc ${COMMON_RESOURCES_RCC} decode.qrc ${DECODE_RESOURCES_RCC})
|
||||||
|
|
||||||
|
#Build
|
||||||
|
ADD_EXECUTABLE(DecodeOnGPUExample ${SRC_FILES} ${COMMON_RESOURCES_RCC} ${DECODE_RESOURCES_RCC})
|
||||||
|
IF(MSVC)
|
||||||
|
SET_TARGET_PROPERTIES(DecodeOnGPUExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
|
||||||
|
ENDIF(MSVC)
|
||||||
|
TARGET_LINK_LIBRARIES(DecodeOnGPUExample Qt5::OpenGL)
|
||||||
|
SET_PROPERTY(TARGET DecodeOnGPUExample PROPERTY FOLDER "Examples")
|
||||||
|
|
||||||
|
#Install - Only install the example in Windows
|
||||||
|
IF(WIN32)
|
||||||
|
INSTALL(TARGETS DecodeOnGPUExample
|
||||||
|
RUNTIME DESTINATION Examples/OpenGL/bin
|
||||||
|
LIBRARY DESTINATION Examples/OpenGL/lib
|
||||||
|
ARCHIVE DESTINATION Examples/OpenGL/lib
|
||||||
|
COMPONENT example
|
||||||
|
)
|
||||||
|
ENDIF(WIN32)
|
19
examples/DecodeOnGPU/decode.frag
Normal file
19
examples/DecodeOnGPU/decode.frag
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#version 130
|
||||||
|
|
||||||
|
// Passed in from the vertex shader
|
||||||
|
in vec4 worldPosition;
|
||||||
|
in vec4 worldNormal;
|
||||||
|
|
||||||
|
// the color that gets written to the display
|
||||||
|
out vec4 outputColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// Again, for the purposes of these examples we cannot be sure that per-vertex normals are provided. A sensible fallback
|
||||||
|
// is to use this little trick to compute per-fragment flat-shaded normals from the world positions using derivative operations.
|
||||||
|
//vec3 normal = normalize(cross(dFdy(worldPosition.xyz), dFdx(worldPosition.xyz)));
|
||||||
|
|
||||||
|
// We are just using the normal as the output color, and making it lighter so it looks a bit nicer.
|
||||||
|
// Obviously a real shader would also do texuring, lighting, or whatever is required for the application.
|
||||||
|
outputColor = vec4(abs(worldNormal.xyz) * 0.5 + vec3(0.5, 0.5, 0.5), 1.0);
|
||||||
|
}
|
6
examples/DecodeOnGPU/decode.qrc
Normal file
6
examples/DecodeOnGPU/decode.qrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE RCC><RCC version="1.0">
|
||||||
|
<qresource>
|
||||||
|
<file>decode.vert</file>
|
||||||
|
<file>decode.frag</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
46
examples/DecodeOnGPU/decode.vert
Normal file
46
examples/DecodeOnGPU/decode.vert
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#version 140
|
||||||
|
|
||||||
|
in uvec4 position; // This will be the position of the vertex in model-space
|
||||||
|
in uint normal;
|
||||||
|
|
||||||
|
// The usual matrices are provided
|
||||||
|
uniform mat4 projectionMatrix;
|
||||||
|
uniform mat4 viewMatrix;
|
||||||
|
uniform mat4 modelMatrix;
|
||||||
|
|
||||||
|
// This will be used by the fragment shader to calculate flat-shaded normals. This is an unconventional approach
|
||||||
|
// but we use it in this example framework because not all surface extractor generate surface normals.
|
||||||
|
out vec4 worldPosition;
|
||||||
|
out vec4 worldNormal;
|
||||||
|
|
||||||
|
// Returns +/- 1
|
||||||
|
vec2 signNotZero(vec2 v)
|
||||||
|
{
|
||||||
|
return vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 decodedPosition = position;
|
||||||
|
decodedPosition.xyz = decodedPosition.xyz * (1.0 / 256.0);
|
||||||
|
|
||||||
|
//Get the encoded bytes of the normal
|
||||||
|
uint encodedX = (normal >> 8u) & 0xFFu;
|
||||||
|
uint encodedY = (normal) & 0xFFu;
|
||||||
|
|
||||||
|
// Map to range [-1.0, +1.0]
|
||||||
|
vec2 e = vec2(encodedX, encodedY);
|
||||||
|
e = e * vec2(1.0 / 127.5, 1.0 / 127.5);
|
||||||
|
e = e - vec2(1.0, 1.0);
|
||||||
|
|
||||||
|
// Now decode normal using listing 2 of http://jcgt.org/published/0003/02/01/
|
||||||
|
vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));
|
||||||
|
if (v.z < 0) v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);
|
||||||
|
worldNormal.xyz = normalize(v);
|
||||||
|
worldNormal.w = 1.0;
|
||||||
|
|
||||||
|
// Standard sequence of OpenGL transformations.
|
||||||
|
worldPosition = modelMatrix * decodedPosition;
|
||||||
|
vec4 cameraPosition = viewMatrix * worldPosition;
|
||||||
|
gl_Position = projectionMatrix * cameraPosition;
|
||||||
|
}
|
173
examples/DecodeOnGPU/main.cpp
Normal file
173
examples/DecodeOnGPU/main.cpp
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 David Williams and Matthew Williams
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "PolyVoxExample.h"
|
||||||
|
|
||||||
|
#include "PolyVox/CubicSurfaceExtractor.h"
|
||||||
|
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
||||||
|
#include "PolyVox/Mesh.h"
|
||||||
|
#include "PolyVox/RawVolume.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
//Use the PolyVox namespace
|
||||||
|
using namespace PolyVox;
|
||||||
|
|
||||||
|
void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
|
||||||
|
{
|
||||||
|
//This vector hold the position of the center of the volume
|
||||||
|
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
||||||
|
|
||||||
|
//This three-level for loop iterates over every voxel in the volume
|
||||||
|
for (int z = 0; z < volData.getDepth(); z++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < volData.getHeight(); y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < volData.getWidth(); x++)
|
||||||
|
{
|
||||||
|
//Store our current position as a vector...
|
||||||
|
Vector3DFloat v3dCurrentPos(x, y, z);
|
||||||
|
//And compute how far the current position is from the center of the volume
|
||||||
|
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
|
||||||
|
|
||||||
|
uint8_t uVoxelValue = 0;
|
||||||
|
|
||||||
|
//If the current voxel is less than 'radius' units from the center then we make it solid.
|
||||||
|
if (fDistToCenter <= fRadius)
|
||||||
|
{
|
||||||
|
//Our new voxel value
|
||||||
|
uVoxelValue = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wrte the voxel value into the volume
|
||||||
|
volData.setVoxel(x, y, z, uVoxelValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DecodeOnGPUExample : public PolyVoxExample
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DecodeOnGPUExample(QWidget *parent)
|
||||||
|
:PolyVoxExample(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initializeExample() override
|
||||||
|
{
|
||||||
|
QSharedPointer<QGLShaderProgram> shader(new QGLShaderProgram);
|
||||||
|
|
||||||
|
if (!shader->addShaderFromSourceFile(QGLShader::Vertex, ":/decode.vert"))
|
||||||
|
{
|
||||||
|
std::cerr << shader->log().toStdString() << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shader->addShaderFromSourceFile(QGLShader::Fragment, ":/decode.frag"))
|
||||||
|
{
|
||||||
|
std::cerr << shader->log().toStdString() << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
setShader(shader);
|
||||||
|
|
||||||
|
//Create an empty volume and then place a sphere in it
|
||||||
|
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
||||||
|
createSphereInVolume(volData, 30);
|
||||||
|
|
||||||
|
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.
|
||||||
|
auto mesh = extractMarchingCubesMesh(&volData, volData.getEnclosingRegion());
|
||||||
|
|
||||||
|
//Pass the surface to the OpenGL window
|
||||||
|
OpenGLMeshData meshData = buildOpenGLMeshData(mesh);
|
||||||
|
addMeshData(meshData);
|
||||||
|
|
||||||
|
setCameraTransform(QVector3D(100.0f, 100.0f, 100.0f), -(PI / 4.0f), PI + (PI / 4.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
OpenGLMeshData buildOpenGLMeshData(const PolyVox::Mesh< PolyVox::MarchingCubesVertex< uint8_t > >& surfaceMesh, const PolyVox::Vector3DInt32& translation = PolyVox::Vector3DInt32(0, 0, 0), float scale = 1.0f)
|
||||||
|
{
|
||||||
|
// This struct holds the OpenGL properties (buffer handles, etc) which will be used
|
||||||
|
// to render our mesh. We copy the data from the PolyVox mesh into this structure.
|
||||||
|
OpenGLMeshData meshData;
|
||||||
|
|
||||||
|
// Create the VAO for the mesh
|
||||||
|
glGenVertexArrays(1, &(meshData.vertexArrayObject));
|
||||||
|
glBindVertexArray(meshData.vertexArrayObject);
|
||||||
|
|
||||||
|
// The GL_ARRAY_BUFFER will contain the list of vertex positions
|
||||||
|
glGenBuffers(1, &(meshData.vertexBuffer));
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, meshData.vertexBuffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, surfaceMesh.getNoOfVertices() * sizeof(MarchingCubesVertex< uint8_t >), surfaceMesh.getRawVertexData(), GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
// and GL_ELEMENT_ARRAY_BUFFER will contain the indices
|
||||||
|
glGenBuffers(1, &(meshData.indexBuffer));
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, meshData.indexBuffer);
|
||||||
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, surfaceMesh.getNoOfIndices() * sizeof(uint32_t), surfaceMesh.getRawIndexData(), GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
// Every surface extractor outputs valid positions for the vertices, so tell OpenGL how these are laid out
|
||||||
|
glEnableVertexAttribArray(0); // Attrib '0' is the vertex positions
|
||||||
|
glVertexAttribIPointer(0, 3, GL_UNSIGNED_SHORT, sizeof(MarchingCubesVertex< uint8_t >), (GLvoid*)(offsetof(MarchingCubesVertex< uint8_t >, encodedPosition))); //take the first 3 floats from every sizeof(decltype(vecVertices)::value_type)
|
||||||
|
|
||||||
|
// Some surface extractors also generate normals, so tell OpenGL how these are laid out. If a surface extractor
|
||||||
|
// does not generate normals then nonsense values are written into the buffer here and sghould be ignored by the
|
||||||
|
// shader. This is mostly just to simplify this example code - in a real application you will know whether your
|
||||||
|
// chosen surface extractor generates normals and can skip uploading them if not.
|
||||||
|
glEnableVertexAttribArray(1); // Attrib '1' is the vertex normals.
|
||||||
|
glVertexAttribIPointer(1, 1, GL_UNSIGNED_SHORT, sizeof(MarchingCubesVertex< uint8_t >), (GLvoid*)(offsetof(MarchingCubesVertex< uint8_t >, encodedNormal)));
|
||||||
|
|
||||||
|
// Finally a surface extractor will probably output additional data. This is highly application dependant. For this example code
|
||||||
|
// we're just uploading it as a set of bytes which we can read individually, but real code will want to do something specialised here.
|
||||||
|
glEnableVertexAttribArray(2); //We're talking about shader attribute '2'
|
||||||
|
GLint size = (std::min)(sizeof(uint8_t), size_t(4)); // Can't upload more that 4 components (vec4 is GLSL's biggest type)
|
||||||
|
glVertexAttribIPointer(2, size, GL_UNSIGNED_BYTE, sizeof(MarchingCubesVertex< uint8_t >), (GLvoid*)(offsetof(MarchingCubesVertex< uint8_t >, data)));
|
||||||
|
|
||||||
|
// We're done uploading and can now unbind.
|
||||||
|
glBindVertexArray(0);
|
||||||
|
|
||||||
|
// A few additional properties can be copied across for use during rendering.
|
||||||
|
meshData.noOfIndices = surfaceMesh.getNoOfIndices();
|
||||||
|
meshData.translation = QVector3D(translation.getX(), translation.getY(), translation.getZ());
|
||||||
|
meshData.scale = scale;
|
||||||
|
|
||||||
|
// Set 16 or 32-bit index buffer size.
|
||||||
|
meshData.indexType = sizeof(PolyVox::Mesh< PolyVox::MarchingCubesVertex< uint8_t > >::IndexType) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
|
||||||
|
|
||||||
|
return meshData;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
//Create and show the Qt OpenGL window
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
DecodeOnGPUExample openGLWidget(0);
|
||||||
|
openGLWidget.show();
|
||||||
|
|
||||||
|
//Run the message pump.
|
||||||
|
return app.exec();
|
||||||
|
}
|
@ -1,85 +1,88 @@
|
|||||||
# Copyright (c) 2010-2012 David Williams
|
################################################################################
|
||||||
#
|
# The MIT License (MIT)
|
||||||
# This software is provided 'as-is', without any express or implied
|
#
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
# arising from the use of this software.
|
#
|
||||||
#
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# including commercial applications, and to alter it and redistribute it
|
# in the Software without restriction, including without limitation the rights
|
||||||
# freely, subject to the following restrictions:
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
#
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
# furnished to do so, subject to the following conditions:
|
||||||
# claim that you wrote the original software. If you use this software
|
#
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# appreciated but is not required.
|
# copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# misrepresented as being the original software.
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# 3. This notice may not be removed or altered from any source
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# distribution.
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
# SOFTWARE.
|
||||||
|
################################################################################
|
||||||
PROJECT(OpenGLExample)
|
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||||
#Projects source files
|
|
||||||
SET(SRC_FILES
|
PROJECT(OpenGLExample)
|
||||||
glew/glew.cpp
|
|
||||||
main.cpp
|
#Projects source files
|
||||||
OpenGLImmediateModeSupport.cpp
|
SET(SRC_FILES
|
||||||
OpenGLSupport.cpp
|
main.cpp
|
||||||
OpenGLVertexBufferObjectSupport.cpp
|
#OpenGLImmediateModeSupport.cpp
|
||||||
OpenGLWidget.cpp
|
#OpenGLSupport.cpp
|
||||||
Shapes.cpp
|
#OpenGLVertexBufferObjectSupport.cpp
|
||||||
)
|
../common/PolyVoxExample.cpp
|
||||||
|
Shapes.cpp
|
||||||
#Projects headers files
|
)
|
||||||
SET(INC_FILES
|
|
||||||
glew/glew.h
|
#Projects headers files
|
||||||
glew/glxew.h
|
SET(INC_FILES
|
||||||
glew/wglew.h
|
#OpenGLImmediateModeSupport.h
|
||||||
OpenGLImmediateModeSupport.h
|
#OpenGLSupport.h
|
||||||
OpenGLSupport.h
|
#OpenGLVertexBufferObjectSupport.h
|
||||||
OpenGLVertexBufferObjectSupport.h
|
../common/OpenGLWidget.h
|
||||||
OpenGLWidget.h
|
../common/OpenGLWidget.inl
|
||||||
Shapes.h
|
../common/PolyVoxExample.h
|
||||||
)
|
Shapes.h
|
||||||
|
)
|
||||||
ADD_DEFINITIONS(-DGLEW_STATIC)
|
|
||||||
|
#"Sources" and "Headers" are the group names in Visual Studio.
|
||||||
#"Sources" and "Headers" are the group names in Visual Studio.
|
#They may have other uses too...
|
||||||
#They may have other uses too...
|
SOURCE_GROUP("Sources" FILES ${SRC_FILES})
|
||||||
SOURCE_GROUP("Sources" FILES ${SRC_FILES})
|
SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
||||||
SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|
||||||
|
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ../common)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#This will include the shader files inside the compiled binary
|
||||||
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include)
|
QT5_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc)
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
QT5_ADD_RESOURCES(OPENGL_EXAMPLE_RESOURCES_RCC openglexample.qrc)
|
||||||
|
|
||||||
#Build
|
# Put the resources in a seperate folder in Visual Studio
|
||||||
ADD_EXECUTABLE(OpenGLExample ${SRC_FILES})
|
SOURCE_GROUP("Resource Files" FILES ../common/example.qrc ${COMMON_RESOURCES_RCC})
|
||||||
IF(MSVC)
|
|
||||||
SET_TARGET_PROPERTIES(OpenGLExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
|
#Build
|
||||||
ENDIF(MSVC)
|
ADD_EXECUTABLE(OpenGLExample ${SRC_FILES} ${COMMON_RESOURCES_RCC} ${OPENGL_EXAMPLE_RESOURCES_RCC})
|
||||||
TARGET_LINK_LIBRARIES(OpenGLExample ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore)
|
IF(MSVC)
|
||||||
SET_PROPERTY(TARGET OpenGLExample PROPERTY FOLDER "Examples")
|
SET_TARGET_PROPERTIES(OpenGLExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
|
||||||
|
ENDIF(MSVC)
|
||||||
#Install - Only install the example in Windows
|
TARGET_LINK_LIBRARIES(OpenGLExample Qt5::OpenGL)
|
||||||
IF(WIN32)
|
SET_PROPERTY(TARGET OpenGLExample PROPERTY FOLDER "Examples")
|
||||||
INSTALL(TARGETS OpenGLExample
|
|
||||||
RUNTIME DESTINATION Examples/OpenGL/bin
|
#Install - Only install the example in Windows
|
||||||
LIBRARY DESTINATION Examples/OpenGL/lib
|
IF(WIN32)
|
||||||
ARCHIVE DESTINATION Examples/OpenGL/lib
|
INSTALL(TARGETS OpenGLExample
|
||||||
COMPONENT example
|
RUNTIME DESTINATION Examples/OpenGL/bin
|
||||||
)
|
LIBRARY DESTINATION Examples/OpenGL/lib
|
||||||
|
ARCHIVE DESTINATION Examples/OpenGL/lib
|
||||||
#.dlls should be installed in shared builds.
|
COMPONENT example
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
|
||||||
|
#.dlls should be installed in shared builds.
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
||||||
ENDIF(WIN32)
|
|
||||||
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
||||||
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include "OpenGLImmediateModeSupport.h"
|
|
||||||
#include "OpenGLSupport.h"
|
|
||||||
|
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
|
||||||
|
|
||||||
using namespace PolyVox;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
void renderRegionImmediateMode(PolyVox::SurfaceMesh<PositionMaterialNormal>& mesh, unsigned int uLodLevel)
|
|
||||||
{
|
|
||||||
const vector<PositionMaterialNormal>& vecVertices = mesh.getVertices();
|
|
||||||
const vector<uint32_t>& vecIndices = mesh.getIndices();
|
|
||||||
|
|
||||||
int beginIndex = mesh.m_vecLodRecords[uLodLevel].beginIndex;
|
|
||||||
int endIndex = mesh.m_vecLodRecords[uLodLevel].endIndex;
|
|
||||||
|
|
||||||
glBegin(GL_TRIANGLES);
|
|
||||||
//for(vector<PolyVox::uint32_t>::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex)
|
|
||||||
for(int index = beginIndex; index < endIndex; ++index)
|
|
||||||
{
|
|
||||||
const PositionMaterialNormal& vertex = vecVertices[vecIndices[index]];
|
|
||||||
const Vector3DFloat& v3dVertexPos = vertex.getPosition();
|
|
||||||
//const Vector3DFloat v3dRegionOffset(uRegionX * g_uRegionSideLength, uRegionY * g_uRegionSideLength, uRegionZ * g_uRegionSideLength);
|
|
||||||
const Vector3DFloat v3dFinalVertexPos = v3dVertexPos + static_cast<Vector3DFloat>(mesh.m_Region.getLowerCorner());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t material = static_cast<uint8_t>(vertex.getMaterial() + 0.5);
|
|
||||||
|
|
||||||
OpenGLColour colour = convertMaterialIDToColour(material);
|
|
||||||
|
|
||||||
glColor3f(colour.red, colour.green, colour.blue);
|
|
||||||
glNormal3f(vertex.getNormal().getX(), vertex.getNormal().getY(), vertex.getNormal().getZ());
|
|
||||||
glVertex3f(v3dFinalVertexPos.getX(), v3dFinalVertexPos.getY(), v3dFinalVertexPos.getZ());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __OpenGLExample_OpenGLImmediateModeSupport_H__
|
|
||||||
#define __OpenGLExample_OpenGLImmediateModeSupport_H__
|
|
||||||
|
|
||||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
|
||||||
|
|
||||||
#include "glew/glew.h"
|
|
||||||
|
|
||||||
void renderRegionImmediateMode(PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>& mesh, unsigned int uLodLevel);
|
|
||||||
|
|
||||||
#endif //__OpenGLExample_OpenGLImmediateModeSupport_H__
|
|
@ -1,66 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include "OpenGLSupport.h"
|
|
||||||
|
|
||||||
using namespace PolyVox;
|
|
||||||
|
|
||||||
OpenGLColour convertMaterialIDToColour(uint8_t materialID)
|
|
||||||
{
|
|
||||||
OpenGLColour colour;
|
|
||||||
|
|
||||||
switch(materialID)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
colour.red = 1.0f;
|
|
||||||
colour.green = 0.0f;
|
|
||||||
colour.blue = 0.0f;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
colour.red = 0.0f;
|
|
||||||
colour.green = 1.0f;
|
|
||||||
colour.blue = 0.0f;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
colour.red = 0.0f;
|
|
||||||
colour.green = 0.0f;
|
|
||||||
colour.blue = 1.0f;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
colour.red = 1.0f;
|
|
||||||
colour.green = 1.0f;
|
|
||||||
colour.blue = 0.0f;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
colour.red = 1.0f;
|
|
||||||
colour.green = 0.0f;
|
|
||||||
colour.blue = 1.0f;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
colour.red = 1.0f;
|
|
||||||
colour.green = 1.0f;
|
|
||||||
colour.blue = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
return colour;
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __OpenGLExample_OpenGLSupport_H__
|
|
||||||
#define __OpenGLExample_OpenGLSupport_H__
|
|
||||||
|
|
||||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
|
||||||
|
|
||||||
#include "glew/glew.h"
|
|
||||||
|
|
||||||
struct OpenGLColour
|
|
||||||
{
|
|
||||||
GLfloat red;
|
|
||||||
GLfloat green;
|
|
||||||
GLfloat blue;
|
|
||||||
};
|
|
||||||
|
|
||||||
OpenGLColour convertMaterialIDToColour(uint8_t materialID);
|
|
||||||
|
|
||||||
#endif //__OpenGLExample_OpenGLSupport_H__
|
|
@ -1,124 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include "OpenGLSupport.h"
|
|
||||||
#include "OpenGLVertexBufferObjectSupport.h"
|
|
||||||
|
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
|
||||||
|
|
||||||
using namespace PolyVox;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const SurfaceMesh<PositionMaterialNormal>& mesh)
|
|
||||||
{
|
|
||||||
//Represents our filled in OpenGL vertex and index buffer objects.
|
|
||||||
OpenGLSurfaceMesh result;
|
|
||||||
|
|
||||||
//The source
|
|
||||||
result.sourceMesh = &mesh;
|
|
||||||
|
|
||||||
//Convienient access to the vertices and indices
|
|
||||||
const vector<PositionMaterialNormal>& vecVertices = mesh.getVertices();
|
|
||||||
const vector<uint32_t>& vecIndices = mesh.getIndices();
|
|
||||||
|
|
||||||
//If we have any indices...
|
|
||||||
if(!vecIndices.empty())
|
|
||||||
{
|
|
||||||
//Create an OpenGL index buffer
|
|
||||||
glGenBuffers(1, &result.indexBuffer);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.indexBuffer);
|
|
||||||
|
|
||||||
//Get a pointer to the first index
|
|
||||||
GLvoid* pIndices = (GLvoid*)(&(vecIndices[0]));
|
|
||||||
|
|
||||||
//Fill the OpenGL index buffer with our data.
|
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, vecIndices.size() * sizeof(uint32_t), pIndices, GL_STATIC_DRAW);
|
|
||||||
}
|
|
||||||
|
|
||||||
result.noOfIndices = vecIndices.size();
|
|
||||||
|
|
||||||
glGenBuffers(1, &result.vertexBuffer);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, result.vertexBuffer);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(GLfloat) * 9, 0, GL_STATIC_DRAW);
|
|
||||||
GLfloat* ptr = (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
|
|
||||||
|
|
||||||
for(vector<PositionMaterialNormal>::const_iterator iterVertex = vecVertices.begin(); iterVertex != vecVertices.end(); ++iterVertex)
|
|
||||||
{
|
|
||||||
const PositionMaterialNormal& vertex = *iterVertex;
|
|
||||||
const Vector3DFloat& v3dVertexPos = vertex.getPosition();
|
|
||||||
//const Vector3DFloat v3dRegionOffset(uRegionX * g_uRegionSideLength, uRegionY * g_uRegionSideLength, uRegionZ * g_uRegionSideLength);
|
|
||||||
const Vector3DFloat v3dFinalVertexPos = v3dVertexPos + static_cast<Vector3DFloat>(mesh.m_Region.getLowerCorner());
|
|
||||||
|
|
||||||
*ptr = v3dFinalVertexPos.getX();
|
|
||||||
ptr++;
|
|
||||||
*ptr = v3dFinalVertexPos.getY();
|
|
||||||
ptr++;
|
|
||||||
*ptr = v3dFinalVertexPos.getZ();
|
|
||||||
ptr++;
|
|
||||||
|
|
||||||
*ptr = vertex.getNormal().getX();
|
|
||||||
ptr++;
|
|
||||||
*ptr = vertex.getNormal().getY();
|
|
||||||
ptr++;
|
|
||||||
*ptr = vertex.getNormal().getZ();
|
|
||||||
ptr++;
|
|
||||||
|
|
||||||
uint8_t material = static_cast<uint8_t>(vertex.getMaterial() + 0.5);
|
|
||||||
|
|
||||||
OpenGLColour colour = convertMaterialIDToColour(material);
|
|
||||||
|
|
||||||
*ptr = colour.red;
|
|
||||||
ptr++;
|
|
||||||
*ptr = colour.green;
|
|
||||||
ptr++;
|
|
||||||
*ptr = colour.blue;
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void renderRegionVertexBufferObject(const OpenGLSurfaceMesh& openGLSurfaceMesh, unsigned int uLodLevel)
|
|
||||||
{
|
|
||||||
int beginIndex = openGLSurfaceMesh.sourceMesh->m_vecLodRecords[uLodLevel].beginIndex;
|
|
||||||
int endIndex = openGLSurfaceMesh.sourceMesh->m_vecLodRecords[uLodLevel].endIndex;
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, openGLSurfaceMesh.vertexBuffer);
|
|
||||||
glVertexPointer(3, GL_FLOAT, 36, 0);
|
|
||||||
glNormalPointer(GL_FLOAT, 36, (GLvoid*)12);
|
|
||||||
glColorPointer(3, GL_FLOAT, 36, (GLvoid*)24);
|
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, openGLSurfaceMesh.indexBuffer);
|
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
|
||||||
|
|
||||||
//glDrawElements(GL_TRIANGLES, openGLSurfaceMesh.noOfIndices, GL_UNSIGNED_INT, 0);
|
|
||||||
glDrawRangeElements(GL_TRIANGLES, beginIndex, endIndex-1, endIndex - beginIndex,/* openGLSurfaceMesh.noOfIndices,*/ GL_UNSIGNED_INT, 0);
|
|
||||||
|
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
|
||||||
glDisableClientState(GL_NORMAL_ARRAY);
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __OpenGLExample_OpenGLVertexBufferObjectSupport_H__
|
|
||||||
#define __OpenGLExample_OpenGLVertexBufferObjectSupport_H__
|
|
||||||
|
|
||||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
|
||||||
|
|
||||||
#include "glew/glew.h"
|
|
||||||
|
|
||||||
struct OpenGLSurfaceMesh
|
|
||||||
{
|
|
||||||
GLulong noOfIndices;
|
|
||||||
GLuint indexBuffer;
|
|
||||||
GLuint vertexBuffer;
|
|
||||||
const PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>* sourceMesh;
|
|
||||||
};
|
|
||||||
|
|
||||||
OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>& mesh);
|
|
||||||
void renderRegionVertexBufferObject(const OpenGLSurfaceMesh& openGLSurfaceMesh, unsigned int uLodLevel);
|
|
||||||
|
|
||||||
#endif //__OpenGLExample_OpenGLVertexBufferObjectSupport_H__
|
|
@ -1,246 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include "OpenGLWidget.h"
|
|
||||||
|
|
||||||
#include <QMouseEvent>
|
|
||||||
|
|
||||||
#include "PolyVoxCore/GradientEstimators.h"
|
|
||||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
|
||||||
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.h"
|
|
||||||
|
|
||||||
//Some namespaces we need
|
|
||||||
using namespace std;
|
|
||||||
using namespace PolyVox;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
OpenGLWidget::OpenGLWidget(QWidget *parent)
|
|
||||||
:QGLWidget(parent)
|
|
||||||
,m_volData(0)
|
|
||||||
{
|
|
||||||
m_xRotation = 0;
|
|
||||||
m_yRotation = 0;
|
|
||||||
m_uRegionSideLength = 32;
|
|
||||||
|
|
||||||
timer = new QTimer(this);
|
|
||||||
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
|
|
||||||
timer->start(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::setVolume(PolyVox::LargeVolume<MaterialDensityPair44>* volData)
|
|
||||||
{
|
|
||||||
//First we free anything from the previous volume (if there was one).
|
|
||||||
m_mapOpenGLSurfaceMeshes.clear();
|
|
||||||
m_mapSurfaceMeshes.clear();
|
|
||||||
m_volData = volData;
|
|
||||||
|
|
||||||
//If we have any volume data then generate the new surface patches.
|
|
||||||
if(m_volData != 0)
|
|
||||||
{
|
|
||||||
m_uVolumeWidthInRegions = volData->getWidth() / m_uRegionSideLength;
|
|
||||||
m_uVolumeHeightInRegions = volData->getHeight() / m_uRegionSideLength;
|
|
||||||
m_uVolumeDepthInRegions = volData->getDepth() / m_uRegionSideLength;
|
|
||||||
|
|
||||||
//Our volume is broken down into cuboid regions, and we create one mesh for each region.
|
|
||||||
//This three-level for loop iterates over each region.
|
|
||||||
for(uint16_t uRegionZ = 0; uRegionZ < m_uVolumeDepthInRegions; ++uRegionZ)
|
|
||||||
{
|
|
||||||
std::cout << "uRegionZ = " << uRegionZ << " of " << m_uVolumeDepthInRegions << std::endl;
|
|
||||||
for(uint16_t uRegionY = 0; uRegionY < m_uVolumeHeightInRegions; ++uRegionY)
|
|
||||||
{
|
|
||||||
for(uint16_t uRegionX = 0; uRegionX < m_uVolumeWidthInRegions; ++uRegionX)
|
|
||||||
{
|
|
||||||
//Compute the extents of the current region
|
|
||||||
//FIXME - This is a little complex? PolyVox could
|
|
||||||
//provide more functions for dealing with regions?
|
|
||||||
int32_t regionStartX = uRegionX * m_uRegionSideLength;
|
|
||||||
int32_t regionStartY = uRegionY * m_uRegionSideLength;
|
|
||||||
int32_t regionStartZ = uRegionZ * m_uRegionSideLength;
|
|
||||||
|
|
||||||
int32_t regionEndX = regionStartX + m_uRegionSideLength;
|
|
||||||
int32_t regionEndY = regionStartY + m_uRegionSideLength;
|
|
||||||
int32_t regionEndZ = regionStartZ + m_uRegionSideLength;
|
|
||||||
|
|
||||||
Vector3DInt32 regLowerCorner(regionStartX, regionStartY, regionStartZ);
|
|
||||||
Vector3DInt32 regUpperCorner(regionEndX, regionEndY, regionEndZ);
|
|
||||||
|
|
||||||
//Extract the surface for this region
|
|
||||||
//extractSurface(m_volData, 0, PolyVox::Region(regLowerCorner, regUpperCorner), meshCurrent);
|
|
||||||
|
|
||||||
polyvox_shared_ptr< SurfaceMesh<PositionMaterialNormal> > mesh(new SurfaceMesh<PositionMaterialNormal>);
|
|
||||||
MarchingCubesSurfaceExtractor< LargeVolume<MaterialDensityPair44> > surfaceExtractor(volData, PolyVox::Region(regLowerCorner, regUpperCorner), mesh.get());
|
|
||||||
surfaceExtractor.execute();
|
|
||||||
|
|
||||||
//decimatedMesh->generateAveragedFaceNormals(true);
|
|
||||||
|
|
||||||
//computeNormalsForVertices(m_volData, *(decimatedMesh.get()), SOBEL_SMOOTHED);
|
|
||||||
//*meshCurrent = getSmoothedSurface(*meshCurrent);
|
|
||||||
//mesh->smooth(0.3f);
|
|
||||||
//meshCurrent->generateAveragedFaceNormals(true);
|
|
||||||
|
|
||||||
if(mesh->m_vecTriangleIndices.size() > 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
|
|
||||||
if(m_bUseOpenGLVertexBufferObjects)
|
|
||||||
{
|
|
||||||
OpenGLSurfaceMesh openGLSurfaceMesh = BuildOpenGLSurfaceMesh(*(mesh.get()));
|
|
||||||
m_mapOpenGLSurfaceMeshes.insert(make_pair(v3dRegPos, openGLSurfaceMesh));
|
|
||||||
}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
m_mapSurfaceMeshes.insert(make_pair(v3dRegPos, mesh));
|
|
||||||
//}
|
|
||||||
//delete meshCurrent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Projection matrix is dependant on volume size, so we need to set it up again.
|
|
||||||
setupProjectionMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::initializeGL()
|
|
||||||
{
|
|
||||||
m_bUseOpenGLVertexBufferObjects = true;
|
|
||||||
if(m_bUseOpenGLVertexBufferObjects)
|
|
||||||
{
|
|
||||||
//We need GLEW to access recent OpenGL functionality
|
|
||||||
GLenum err = glewInit();
|
|
||||||
if (GLEW_OK != err)
|
|
||||||
{
|
|
||||||
/* Problem: glewInit failed, something is seriously wrong. */
|
|
||||||
cout << "GLEW Error: " << glewGetErrorString(err) << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
|
|
||||||
glClearDepth(1.0f); // Depth Buffer Setup
|
|
||||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
|
||||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
|
||||||
glEnable ( GL_COLOR_MATERIAL );
|
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
|
||||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
|
||||||
glEnable(GL_LIGHT0);
|
|
||||||
|
|
||||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
|
||||||
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::resizeGL(int w, int h)
|
|
||||||
{
|
|
||||||
//Setup the viewport based on the window size
|
|
||||||
glViewport(0, 0, w, h);
|
|
||||||
|
|
||||||
//Projection matrix is also dependant on the size of the current volume.
|
|
||||||
if(m_volData)
|
|
||||||
{
|
|
||||||
setupProjectionMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::paintGL()
|
|
||||||
{
|
|
||||||
if(m_volData)
|
|
||||||
{
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW); // Select The Model View Matrix
|
|
||||||
glLoadIdentity(); // Reset The Current Modelview Matrix
|
|
||||||
|
|
||||||
//Moves the camera back so we can see the volume
|
|
||||||
glTranslatef(0.0f, 0.0f, -m_volData->getDiagonalLength());
|
|
||||||
|
|
||||||
glRotatef(m_xRotation, 1.0f, 0.0f, 0.0f);
|
|
||||||
glRotatef(m_yRotation, 0.0f, 1.0f, 0.0f);
|
|
||||||
|
|
||||||
//Centre the volume on the origin
|
|
||||||
glTranslatef(-g_uVolumeSideLength/2,-g_uVolumeSideLength/2,-g_uVolumeSideLength/2);
|
|
||||||
|
|
||||||
for(uint16_t uRegionZ = 0; uRegionZ < m_uVolumeDepthInRegions; ++uRegionZ)
|
|
||||||
{
|
|
||||||
for(uint16_t uRegionY = 0; uRegionY < m_uVolumeHeightInRegions; ++uRegionY)
|
|
||||||
{
|
|
||||||
for(uint16_t uRegionX = 0; uRegionX < m_uVolumeWidthInRegions; ++uRegionX)
|
|
||||||
{
|
|
||||||
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
|
|
||||||
if(m_mapSurfaceMeshes.find(v3dRegPos) != m_mapSurfaceMeshes.end())
|
|
||||||
{
|
|
||||||
polyvox_shared_ptr< SurfaceMesh<PositionMaterialNormal> > meshCurrent = m_mapSurfaceMeshes[v3dRegPos];
|
|
||||||
unsigned int uLodLevel = 0; //meshCurrent->m_vecLodRecords.size() - 1;
|
|
||||||
if(m_bUseOpenGLVertexBufferObjects)
|
|
||||||
{
|
|
||||||
renderRegionVertexBufferObject(m_mapOpenGLSurfaceMeshes[v3dRegPos], uLodLevel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
renderRegionImmediateMode(*meshCurrent, uLodLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GLenum errCode;
|
|
||||||
const GLubyte *errString;
|
|
||||||
|
|
||||||
if ((errCode = glGetError()) != GL_NO_ERROR)
|
|
||||||
{
|
|
||||||
errString = gluErrorString(errCode);
|
|
||||||
cout << "OpenGL Error: " << errString << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::mousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
m_CurrentMousePos = event->pos();
|
|
||||||
m_LastFrameMousePos = m_CurrentMousePos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::mouseMoveEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
m_CurrentMousePos = event->pos();
|
|
||||||
QPoint diff = m_CurrentMousePos - m_LastFrameMousePos;
|
|
||||||
m_xRotation += diff.x();
|
|
||||||
m_yRotation += diff.y();
|
|
||||||
m_LastFrameMousePos = m_CurrentMousePos;;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::setupProjectionMatrix(void)
|
|
||||||
{
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
float frustumSize = m_volData->getDiagonalLength() / 2.0f;
|
|
||||||
float aspect = static_cast<float>(width()) / static_cast<float>(height());
|
|
||||||
|
|
||||||
glOrtho(frustumSize*aspect, -frustumSize*aspect, frustumSize, -frustumSize, 1.0, 5000);
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __PolyVox_OpenGLWidget_H__
|
|
||||||
#define __PolyVox_OpenGLWidget_H__
|
|
||||||
|
|
||||||
#include "glew/glew.h"
|
|
||||||
|
|
||||||
#include <QGLWidget>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include "PolyVoxCore/LargeVolume.h"
|
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
|
||||||
#include "PolyVoxCore/Impl/Utility.h"
|
|
||||||
|
|
||||||
#include "OpenGLImmediateModeSupport.h"
|
|
||||||
#include "OpenGLVertexBufferObjectSupport.h"
|
|
||||||
#include "Shapes.h"
|
|
||||||
|
|
||||||
const int32_t g_uVolumeSideLength = 128;
|
|
||||||
|
|
||||||
class OpenGLWidget : public QGLWidget
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
OpenGLWidget(QWidget *parent);
|
|
||||||
|
|
||||||
void setVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>* volData);
|
|
||||||
|
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
|
||||||
void mousePressEvent(QMouseEvent* event);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void initializeGL();
|
|
||||||
void resizeGL(int w, int h);
|
|
||||||
void paintGL();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setupProjectionMatrix(void);
|
|
||||||
QPoint m_LastFrameMousePos;
|
|
||||||
QPoint m_CurrentMousePos;
|
|
||||||
|
|
||||||
int m_xRotation;
|
|
||||||
int m_yRotation;
|
|
||||||
|
|
||||||
QTimer *timer;
|
|
||||||
|
|
||||||
bool m_bUseOpenGLVertexBufferObjects;
|
|
||||||
|
|
||||||
//Creates a volume 128x128x128
|
|
||||||
PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>* m_volData;
|
|
||||||
|
|
||||||
//Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region
|
|
||||||
std::map<PolyVox::Vector3DUint8, OpenGLSurfaceMesh> m_mapOpenGLSurfaceMeshes;
|
|
||||||
std::map<PolyVox::Vector3DUint8, polyvox_shared_ptr<PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> > > m_mapSurfaceMeshes;
|
|
||||||
|
|
||||||
unsigned int m_uRegionSideLength;
|
|
||||||
unsigned int m_uVolumeWidthInRegions;
|
|
||||||
unsigned int m_uVolumeHeightInRegions;
|
|
||||||
unsigned int m_uVolumeDepthInRegions;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //__PolyVox_OpenGLWidget_H__
|
|
@ -1,73 +1,74 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Copyright (c) 2005-2009 David Williams
|
The MIT License (MIT)
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
Copyright (c) 2015 David Williams and Matthew Williams
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
in the Software without restriction, including without limitation the rights
|
||||||
including commercial applications, and to alter it and redistribute it
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
freely, subject to the following restrictions:
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
The above copyright notice and this permission notice shall be included in all
|
||||||
in a product, an acknowledgment in the product documentation would be
|
copies or substantial portions of the Software.
|
||||||
appreciated but is not required.
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
misrepresented as being the original software.
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
3. This notice may not be removed or altered from any source
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
distribution.
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
*******************************************************************************/
|
SOFTWARE.
|
||||||
|
*******************************************************************************/
|
||||||
#include "Shapes.h"
|
|
||||||
|
#include "Shapes.h"
|
||||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
|
||||||
|
#include "PolyVox/MaterialDensityPair.h"
|
||||||
using namespace PolyVox;
|
|
||||||
|
using namespace PolyVox;
|
||||||
void createSphereInVolume(LargeVolume<MaterialDensityPair44>& volData, float fRadius, uint8_t uValue)
|
|
||||||
{
|
void createSphereInVolume(RawVolume<MaterialDensityPair88>& volData, float fRadius, uint8_t uValue)
|
||||||
//This vector hold the position of the center of the volume
|
{
|
||||||
Vector3DInt32 v3dVolCenter = (volData.getEnclosingRegion().getUpperCorner() - volData.getEnclosingRegion().getLowerCorner()) / static_cast<int32_t>(2);
|
//This vector hold the position of the center of the volume
|
||||||
|
Vector3DInt32 v3dVolCenter = (volData.getEnclosingRegion().getUpperCorner() - volData.getEnclosingRegion().getLowerCorner()) / static_cast<int32_t>(2);
|
||||||
//This three-level for loop iterates over every voxel in the volume
|
|
||||||
for (int z = 0; z < volData.getDepth(); z++)
|
//This three-level for loop iterates over every voxel in the volume
|
||||||
{
|
for (int z = 0; z < volData.getDepth(); z++)
|
||||||
for (int y = 0; y < volData.getHeight(); y++)
|
{
|
||||||
{
|
for (int y = 0; y < volData.getHeight(); y++)
|
||||||
for (int x = 0; x < volData.getWidth(); x++)
|
{
|
||||||
{
|
for (int x = 0; x < volData.getWidth(); x++)
|
||||||
//Store our current position as a vector...
|
{
|
||||||
Vector3DInt32 v3dCurrentPos(x,y,z);
|
//Store our current position as a vector...
|
||||||
//And compute how far the current position is from the center of the volume
|
Vector3DInt32 v3dCurrentPos(x, y, z);
|
||||||
double fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
|
//And compute how far the current position is from the center of the volume
|
||||||
|
double fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
|
||||||
//If the current voxel is less than 'radius' units from the center
|
|
||||||
//then we make it solid, otherwise we make it empty space.
|
//If the current voxel is less than 'radius' units from the center
|
||||||
if(fDistToCenter <= fRadius)
|
//then we make it solid, otherwise we make it empty space.
|
||||||
{
|
if (fDistToCenter <= fRadius)
|
||||||
volData.setVoxelAt(x,y,z, MaterialDensityPair44(uValue, uValue > 0 ? MaterialDensityPair44::getMaxDensity() : MaterialDensityPair44::getMinDensity()));
|
{
|
||||||
}
|
volData.setVoxel(x, y, z, MaterialDensityPair88(uValue, uValue > 0 ? MaterialDensityPair88::getMaxDensity() : MaterialDensityPair88::getMinDensity()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void createCubeInVolume(LargeVolume<MaterialDensityPair44>& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue)
|
|
||||||
{
|
void createCubeInVolume(RawVolume<MaterialDensityPair88>& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue)
|
||||||
uint8_t maxDen = MaterialDensityPair44::getMaxDensity();
|
{
|
||||||
uint8_t minDen = MaterialDensityPair44::getMinDensity();
|
uint8_t maxDen = static_cast<uint8_t>(MaterialDensityPair88::getMaxDensity());
|
||||||
//This three-level for loop iterates over every voxel between the specified corners
|
uint8_t minDen = static_cast<uint8_t>(MaterialDensityPair88::getMinDensity());
|
||||||
for (int z = lowerCorner.getZ(); z <= upperCorner.getZ(); z++)
|
//This three-level for loop iterates over every voxel between the specified corners
|
||||||
{
|
for (int z = lowerCorner.getZ(); z <= upperCorner.getZ(); z++)
|
||||||
for (int y = lowerCorner.getY(); y <= upperCorner.getY(); y++)
|
{
|
||||||
{
|
for (int y = lowerCorner.getY(); y <= upperCorner.getY(); y++)
|
||||||
for (int x = lowerCorner.getX() ; x <= upperCorner.getX(); x++)
|
{
|
||||||
{
|
for (int x = lowerCorner.getX(); x <= upperCorner.getX(); x++)
|
||||||
volData.setVoxelAt(x,y,z, MaterialDensityPair44(uValue, uValue > 0 ? maxDen : minDen));
|
{
|
||||||
}
|
volData.setVoxel(x, y, z, MaterialDensityPair88(uValue, uValue > 0 ? maxDen : minDen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,33 +1,34 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Copyright (c) 2005-2009 David Williams
|
The MIT License (MIT)
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
Copyright (c) 2015 David Williams and Matthew Williams
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
in the Software without restriction, including without limitation the rights
|
||||||
including commercial applications, and to alter it and redistribute it
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
freely, subject to the following restrictions:
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
The above copyright notice and this permission notice shall be included in all
|
||||||
in a product, an acknowledgment in the product documentation would be
|
copies or substantial portions of the Software.
|
||||||
appreciated but is not required.
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
misrepresented as being the original software.
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
3. This notice may not be removed or altered from any source
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
distribution.
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
*******************************************************************************/
|
SOFTWARE.
|
||||||
|
*******************************************************************************/
|
||||||
#ifndef __OpenGLExample_Shapes_H__
|
|
||||||
#define __OpenGLExample_Shapes_H__
|
#ifndef __OpenGLExample_Shapes_H__
|
||||||
|
#define __OpenGLExample_Shapes_H__
|
||||||
#include "PolyVoxCore/LargeVolume.h"
|
|
||||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
|
#include "PolyVox/MaterialDensityPair.h"
|
||||||
void createSphereInVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>& volData, float fRadius, uint8_t uValue);
|
|
||||||
void createCubeInVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>& volData, PolyVox::Vector3DInt32 lowerCorner, PolyVox::Vector3DInt32 upperCorner, uint8_t uValue);
|
void createSphereInVolume(PolyVox::RawVolume<PolyVox::MaterialDensityPair88>& volData, float fRadius, uint8_t uValue);
|
||||||
|
void createCubeInVolume(PolyVox::RawVolume<PolyVox::MaterialDensityPair88>& volData, PolyVox::Vector3DInt32 lowerCorner, PolyVox::Vector3DInt32 upperCorner, uint8_t uValue);
|
||||||
|
|
||||||
#endif //__OpenGLExample_Shapes_H__
|
#endif //__OpenGLExample_Shapes_H__
|
@ -1,73 +0,0 @@
|
|||||||
The OpenGL Extension Wrangler Library
|
|
||||||
Copyright (C) 2002-2007, Milan Ikits <milan ikits[]ieee org>
|
|
||||||
Copyright (C) 2002-2007, Marcelo E. Magallon <mmagallo[]debian org>
|
|
||||||
Copyright (C) 2002, Lev Povalahev
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
* The name of the author may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
||||||
THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
Mesa 3-D graphics library
|
|
||||||
Version: 7.0
|
|
||||||
|
|
||||||
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
copy of this software and associated documentation files (the "Software"),
|
|
||||||
to deal in the Software without restriction, including without limitation
|
|
||||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included
|
|
||||||
in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
||||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2007 The Khronos Group Inc.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
copy of this software and/or associated documentation files (the
|
|
||||||
"Materials"), to deal in the Materials without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Materials, and to
|
|
||||||
permit persons to whom the Materials are furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included
|
|
||||||
in all copies or substantial portions of the Materials.
|
|
||||||
|
|
||||||
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,128 +1,156 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Copyright (c) 2005-2009 David Williams
|
The MIT License (MIT)
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
Copyright (c) 2015 David Williams and Matthew Williams
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
in the Software without restriction, including without limitation the rights
|
||||||
including commercial applications, and to alter it and redistribute it
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
freely, subject to the following restrictions:
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
The above copyright notice and this permission notice shall be included in all
|
||||||
in a product, an acknowledgment in the product documentation would be
|
copies or substantial portions of the Software.
|
||||||
appreciated but is not required.
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
misrepresented as being the original software.
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
3. This notice may not be removed or altered from any source
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
distribution.
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
*******************************************************************************/
|
SOFTWARE.
|
||||||
|
*******************************************************************************/
|
||||||
#include "PolyVoxCore/Log.h"
|
|
||||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
#include "PolyVox/FilePager.h"
|
||||||
#include "PolyVoxCore/LargeVolume.h"
|
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
|
||||||
#include "PolyVoxCore/LowPassFilter.h"
|
#include "PolyVox/MaterialDensityPair.h"
|
||||||
#include "PolyVoxCore/RawVolume.h"
|
#include "PolyVox/LowPassFilter.h"
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
#include "PolyVox/RawVolume.h"
|
||||||
#include "PolyVoxCore/Impl/Utility.h"
|
#include "PolyVox/Mesh.h"
|
||||||
|
#include "PolyVox/Impl/Utility.h"
|
||||||
#include "OpenGLImmediateModeSupport.h"
|
|
||||||
#include "OpenGLVertexBufferObjectSupport.h"
|
#include "Shapes.h"
|
||||||
#include "Shapes.h"
|
|
||||||
|
#include "PolyVoxExample.h"
|
||||||
#include "OpenGLWidget.h"
|
|
||||||
|
#ifdef WIN32
|
||||||
#ifdef WIN32
|
#include <windows.h> // Standard Header For Most Programs
|
||||||
#include <windows.h> // Standard Header For Most Programs
|
#endif
|
||||||
#endif
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QApplication>
|
#include <QTime>
|
||||||
#include <QTime>
|
|
||||||
|
//Some namespaces we need
|
||||||
//Some namespaces we need
|
using namespace std;
|
||||||
using namespace std;
|
using namespace PolyVox;
|
||||||
using namespace PolyVox;
|
using namespace std;
|
||||||
using namespace std;
|
|
||||||
|
const int32_t g_uVolumeSideLength = 128;
|
||||||
void exampleLog(string message, int severity)
|
|
||||||
{
|
class OpenGLExample : public PolyVoxExample
|
||||||
//Identify how severe the mesage is
|
{
|
||||||
switch(severity)
|
public:
|
||||||
{
|
OpenGLExample(QWidget *parent)
|
||||||
case LS_DEBUG:
|
:PolyVoxExample(parent)
|
||||||
cout << "DEBUG: ";
|
{
|
||||||
break;
|
}
|
||||||
case LS_INFO:
|
|
||||||
cout << "INFO: ";
|
protected:
|
||||||
break;
|
void initializeExample() override
|
||||||
case LS_WARN:
|
{
|
||||||
cout << "WARN: ";
|
RawVolume<MaterialDensityPair88> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)));
|
||||||
break;
|
|
||||||
case LS_ERROR:
|
//Make our volume contain a sphere in the center.
|
||||||
cout << "ERROR: ";
|
int32_t minPos = 0;
|
||||||
break;
|
int32_t midPos = g_uVolumeSideLength / 2;
|
||||||
}
|
int32_t maxPos = g_uVolumeSideLength - 1;
|
||||||
|
|
||||||
//Print the message
|
cout << "Creating sphere 1" << std::endl;
|
||||||
cout << message << endl;
|
createSphereInVolume(volData, 60.0f, 5);
|
||||||
}
|
cout << "Creating sphere 2" << std::endl;
|
||||||
|
createSphereInVolume(volData, 50.0f, 4);
|
||||||
int main(int argc, char *argv[])
|
cout << "Creating sphere 3" << std::endl;
|
||||||
{
|
createSphereInVolume(volData, 40.0f, 3);
|
||||||
logHandler = &exampleLog;
|
cout << "Creating sphere 4" << std::endl;
|
||||||
LargeVolume<MaterialDensityPair44> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(g_uVolumeSideLength-1, g_uVolumeSideLength-1, g_uVolumeSideLength-1)));
|
createSphereInVolume(volData, 30.0f, 2);
|
||||||
|
cout << "Creating sphere 5" << std::endl;
|
||||||
//Make our volume contain a sphere in the center.
|
createSphereInVolume(volData, 20.0f, 1);
|
||||||
int32_t minPos = 0;
|
|
||||||
int32_t midPos = g_uVolumeSideLength / 2;
|
cout << "Creating cubes" << std::endl;
|
||||||
int32_t maxPos = g_uVolumeSideLength - 1;
|
createCubeInVolume(volData, Vector3DInt32(minPos, minPos, midPos + 1), Vector3DInt32(midPos - 1, midPos - 1, maxPos), 0);
|
||||||
|
createCubeInVolume(volData, Vector3DInt32(midPos + 1, midPos + 1, midPos + 1), Vector3DInt32(maxPos, maxPos, maxPos), 0);
|
||||||
cout << "Creating sphere 1" << std::endl;
|
createCubeInVolume(volData, Vector3DInt32(minPos, midPos + 1, minPos), Vector3DInt32(midPos - 1, maxPos, midPos - 1), 0);
|
||||||
createSphereInVolume(volData, 60.0f, 5);
|
createCubeInVolume(volData, Vector3DInt32(midPos + 1, minPos, minPos), Vector3DInt32(maxPos, midPos - 1, midPos - 1), 0);
|
||||||
cout << "Creating sphere 2" << std::endl;
|
|
||||||
createSphereInVolume(volData, 50.0f, 4);
|
createCubeInVolume(volData, Vector3DInt32(1, midPos - 10, midPos - 10), Vector3DInt32(maxPos - 1, midPos + 10, midPos + 10), MaterialDensityPair44::getMaxDensity());
|
||||||
cout << "Creating sphere 3" << std::endl;
|
createCubeInVolume(volData, Vector3DInt32(midPos - 10, 1, midPos - 10), Vector3DInt32(midPos + 10, maxPos - 1, midPos + 10), MaterialDensityPair44::getMaxDensity());
|
||||||
createSphereInVolume(volData, 40.0f, 3);
|
createCubeInVolume(volData, Vector3DInt32(midPos - 10, midPos - 10, 1), Vector3DInt32(midPos + 10, midPos + 10, maxPos - 1), MaterialDensityPair44::getMaxDensity());
|
||||||
cout << "Creating sphere 4" << std::endl;
|
|
||||||
createSphereInVolume(volData, 30.0f, 2);
|
QSharedPointer<QGLShaderProgram> shader(new QGLShaderProgram);
|
||||||
cout << "Creating sphere 5" << std::endl;
|
|
||||||
createSphereInVolume(volData, 20.0f, 1);
|
if (!shader->addShaderFromSourceFile(QGLShader::Vertex, ":/openglexample.vert"))
|
||||||
|
{
|
||||||
cout << "Creating cubes" << std::endl;
|
std::cerr << shader->log().toStdString() << std::endl;
|
||||||
createCubeInVolume(volData, Vector3DInt32(minPos, minPos, minPos), Vector3DInt32(midPos-1, midPos-1, midPos-1), 0);
|
exit(EXIT_FAILURE);
|
||||||
createCubeInVolume(volData, Vector3DInt32(midPos+1, midPos+1, minPos), Vector3DInt32(maxPos, maxPos, midPos-1), 0);
|
}
|
||||||
createCubeInVolume(volData, Vector3DInt32(midPos+1, minPos, midPos+1), Vector3DInt32(maxPos, midPos-1, maxPos), 0);
|
|
||||||
createCubeInVolume(volData, Vector3DInt32(minPos, midPos+1, midPos+1), Vector3DInt32(midPos-1, maxPos, maxPos), 0);
|
if (!shader->addShaderFromSourceFile(QGLShader::Fragment, ":/openglexample.frag"))
|
||||||
|
{
|
||||||
createCubeInVolume(volData, Vector3DInt32(1, midPos-10, midPos-10), Vector3DInt32(maxPos-1, midPos+10, midPos+10), MaterialDensityPair44::getMaxDensity());
|
std::cerr << shader->log().toStdString() << std::endl;
|
||||||
createCubeInVolume(volData, Vector3DInt32(midPos-10, 1, midPos-10), Vector3DInt32(midPos+10, maxPos-1, midPos+10), MaterialDensityPair44::getMaxDensity());
|
exit(EXIT_FAILURE);
|
||||||
createCubeInVolume(volData, Vector3DInt32(midPos-10, midPos-10 ,1), Vector3DInt32(midPos+10, midPos+10, maxPos-1), MaterialDensityPair44::getMaxDensity());
|
}
|
||||||
|
|
||||||
//I've removed this smoothing because it doesn't really make sense to apply a low pass filter to a volume with material values.
|
setShader(shader);
|
||||||
//I could implement the mathematical operators for MaterialDensityPair in such a way that they ignores the materials but this
|
|
||||||
//seems to be setting a bad example. Users can add this operators in their own classes if they want smoothing.
|
QTime time;
|
||||||
//RawVolume<MaterialDensityPair44> tempVolume(PolyVox::Region(0,0,0,128, 128, 128));
|
time.start();
|
||||||
//LowPassFilter< LargeVolume<MaterialDensityPair44>, RawVolume<MaterialDensityPair44> > pass1(&volData, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(126, 126, 126)), &tempVolume, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(126, 126, 126)), 3);
|
//openGLWidget.setVolume(&volData);
|
||||||
//pass1.executeSAT();
|
cout << endl << "Time taken = " << time.elapsed() / 1000.0f << "s" << endl << endl;
|
||||||
//LowPassFilter< RawVolume<MaterialDensityPair44>, LargeVolume<MaterialDensityPair44> > pass2(&tempVolume, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(126, 126, 126)), &volData, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(126, 126, 126)), 3);
|
|
||||||
//pass2.executeSAT();
|
const int32_t extractedRegionSize = 32;
|
||||||
|
int meshCounter = 0;
|
||||||
QApplication app(argc, argv);
|
|
||||||
|
for (int32_t z = 0; z < volData.getDepth(); z += extractedRegionSize)
|
||||||
OpenGLWidget openGLWidget(0);
|
{
|
||||||
|
for (int32_t y = 0; y < volData.getHeight(); y += extractedRegionSize)
|
||||||
|
{
|
||||||
openGLWidget.show();
|
for (int32_t x = 0; x < volData.getWidth(); x += extractedRegionSize)
|
||||||
|
{
|
||||||
QTime time;
|
// Specify the region to extract based on a starting position and the desired region sze.
|
||||||
time.start();
|
PolyVox::Region regToExtract(x, y, z, x + extractedRegionSize, y + extractedRegionSize, z + extractedRegionSize);
|
||||||
openGLWidget.setVolume(&volData);
|
|
||||||
cout << endl << "Time taken = " << time.elapsed() / 1000.0f << "s" << endl << endl;
|
// If you uncomment this line you will be able to see that the volume is rendered as multiple seperate meshes.
|
||||||
|
//regToExtract.shrink(1);
|
||||||
//return 0;
|
|
||||||
|
// Perform the extraction for this region of the volume
|
||||||
return app.exec();
|
auto mesh = extractMarchingCubesMesh(&volData, regToExtract);
|
||||||
}
|
|
||||||
|
// The returned mesh needs to be decoded to be appropriate for GPU rendering.
|
||||||
|
auto decodedMesh = decodeMesh(mesh);
|
||||||
|
|
||||||
|
// Pass the surface to the OpenGL window. Note that we are also passing an offset in this multi-mesh example. This is because
|
||||||
|
// the surface extractors return a mesh with 'local space' positions to reduce storage requirements and precision problems.
|
||||||
|
addMesh(decodedMesh, decodedMesh.getOffset());
|
||||||
|
|
||||||
|
meshCounter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "Rendering volume as " << meshCounter << " seperate meshes" << endl;
|
||||||
|
|
||||||
|
setCameraTransform(QVector3D(150.0f, 150.0f, 150.0f), -(PI / 4.0f), PI + (PI / 4.0f));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
//Create and show the Qt OpenGL window
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
OpenGLExample openGLWidget(0);
|
||||||
|
openGLWidget.show();
|
||||||
|
|
||||||
|
//Run the message pump.
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
45
examples/OpenGL/openglexample.frag
Normal file
45
examples/OpenGL/openglexample.frag
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#version 130
|
||||||
|
|
||||||
|
in vec4 worldPosition; //Passed in from the vertex shader
|
||||||
|
in vec3 normalFromVS;
|
||||||
|
flat in ivec2 materialFromVS;
|
||||||
|
|
||||||
|
out vec4 outputColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// The first byte of our voxel data is the material.
|
||||||
|
// We use this to decide how to color the fragment.
|
||||||
|
vec4 surfaceColor;
|
||||||
|
switch(materialFromVS.x)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
surfaceColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
surfaceColor = vec4(0.0, 1.0, 0.0, 1.0);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
surfaceColor = vec4(0.0, 0.0, 1.0, 1.0);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
surfaceColor = vec4(1.0, 1.0, 0.0, 1.0);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
surfaceColor = vec4(1.0, 0.0, 1.0, 1.0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
surfaceColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quick and dirty lighting, obviously a real implementation
|
||||||
|
// should pass light properties as shader parameters, etc.
|
||||||
|
vec3 lightDir = vec3(0.0, 0.0, 1.0);
|
||||||
|
float diffuse = clamp(dot(lightDir, normalFromVS), 0.0, 1.0);
|
||||||
|
diffuse *= 0.7; // Dim the diffuse a bit
|
||||||
|
float ambient = 0.3; // Add some ambient
|
||||||
|
float lightIntensity = diffuse + ambient; // Compute the final light intensity
|
||||||
|
|
||||||
|
outputColor = surfaceColor * lightIntensity; //Compute final rendered color
|
||||||
|
}
|
6
examples/OpenGL/openglexample.qrc
Normal file
6
examples/OpenGL/openglexample.qrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE RCC><RCC version="1.0">
|
||||||
|
<qresource>
|
||||||
|
<file>openglexample.vert</file>
|
||||||
|
<file>openglexample.frag</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
26
examples/OpenGL/openglexample.vert
Normal file
26
examples/OpenGL/openglexample.vert
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#version 140
|
||||||
|
|
||||||
|
in vec4 position; // This will be the position of the vertex in model-space
|
||||||
|
in vec4 normal; // The normal data may not have been set
|
||||||
|
in ivec2 material;
|
||||||
|
|
||||||
|
uniform mat4 projectionMatrix;
|
||||||
|
uniform mat4 viewMatrix;
|
||||||
|
uniform mat4 modelMatrix;
|
||||||
|
|
||||||
|
out vec4 worldPosition; //This is being passed to the fragment shader to calculate the normals
|
||||||
|
out vec3 normalFromVS;
|
||||||
|
flat out ivec2 materialFromVS;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// Compute the usual OpenGL transformation to clip space.
|
||||||
|
gl_Position = projectionMatrix * viewMatrix * modelMatrix * position;
|
||||||
|
|
||||||
|
// This example is demonstrating the marching cubes mesh, which does have per-vertex normals. We can
|
||||||
|
// just pass them through, though real code might want to deal with transforming normals appropriatly.
|
||||||
|
normalFromVS = normal.xyz;
|
||||||
|
|
||||||
|
// Nothing special here, we just pass the material through to the fragment shader.
|
||||||
|
materialFromVS = material;
|
||||||
|
}
|
@ -1,81 +1,79 @@
|
|||||||
# Copyright (c) 2010-2012 David Williams
|
################################################################################
|
||||||
#
|
# The MIT License (MIT)
|
||||||
# This software is provided 'as-is', without any express or implied
|
#
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
# Copyright (c) 2015 Matthew Williams and David Williams
|
||||||
# arising from the use of this software.
|
#
|
||||||
#
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# including commercial applications, and to alter it and redistribute it
|
# in the Software without restriction, including without limitation the rights
|
||||||
# freely, subject to the following restrictions:
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
#
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
# furnished to do so, subject to the following conditions:
|
||||||
# claim that you wrote the original software. If you use this software
|
#
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# appreciated but is not required.
|
# copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# misrepresented as being the original software.
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# 3. This notice may not be removed or altered from any source
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# distribution.
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
# SOFTWARE.
|
||||||
|
################################################################################
|
||||||
PROJECT(PagingExample)
|
|
||||||
|
PROJECT(PagingExample)
|
||||||
#Projects source files
|
|
||||||
SET(SRC_FILES
|
#Projects source files
|
||||||
glew/glew.cpp
|
SET(SRC_FILES
|
||||||
|
main.cpp
|
||||||
main.cpp
|
Perlin.cpp
|
||||||
OpenGLWidget.cpp
|
../common/PolyVoxExample.cpp
|
||||||
Perlin.cpp
|
)
|
||||||
)
|
|
||||||
|
#Projects headers files
|
||||||
#Projects headers files
|
SET(INC_FILES
|
||||||
SET(INC_FILES
|
../common/OpenGLWidget.h
|
||||||
glew/glew.h
|
../common/OpenGLWidget.inl
|
||||||
glew/glxew.h
|
Perlin.h
|
||||||
glew/wglew.h
|
../common/PolyVoxExample.h
|
||||||
|
)
|
||||||
OpenGLWidget.h
|
|
||||||
Perlin.h
|
#"Sources" and "Headers" are the group names in Visual Studio.
|
||||||
)
|
#They may have other uses too...
|
||||||
|
SOURCE_GROUP("Sources" FILES ${SRC_FILES})
|
||||||
ADD_DEFINITIONS(-DGLEW_STATIC)
|
SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
||||||
|
|
||||||
#"Sources" and "Headers" are the group names in Visual Studio.
|
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
||||||
#They may have other uses too...
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxHeaders_SOURCE_DIR} ../common)
|
||||||
SOURCE_GROUP("Sources" FILES ${SRC_FILES})
|
|
||||||
SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
#This will include the shader files inside the compiled binary
|
||||||
|
QT5_ADD_RESOURCES(COMMON_RESOURCES_RCC ../common/example.qrc)
|
||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
|
||||||
|
# Put the resources in a seperate folder in Visual Studio
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
SOURCE_GROUP("Resource Files" FILES ../common/example.qrc ${COMMON_RESOURCES_RCC})
|
||||||
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include)
|
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
#Build
|
||||||
|
ADD_EXECUTABLE(PagingExample ${SRC_FILES} ${COMMON_RESOURCES_RCC})
|
||||||
#Build
|
IF(MSVC)
|
||||||
ADD_EXECUTABLE(PagingExample ${SRC_FILES})
|
SET_TARGET_PROPERTIES(PagingExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
|
||||||
IF(MSVC)
|
ENDIF(MSVC)
|
||||||
SET_TARGET_PROPERTIES(PagingExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
|
TARGET_LINK_LIBRARIES(PagingExample Qt5::OpenGL)
|
||||||
ENDIF(MSVC)
|
SET_PROPERTY(TARGET PagingExample PROPERTY FOLDER "Examples")
|
||||||
TARGET_LINK_LIBRARIES(PagingExample ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore)
|
|
||||||
SET_PROPERTY(TARGET PagingExample PROPERTY FOLDER "Examples")
|
#Install - Only install the example in Windows
|
||||||
|
IF(WIN32)
|
||||||
#Install - Only install the example in Windows
|
INSTALL(TARGETS PagingExample
|
||||||
IF(WIN32)
|
RUNTIME DESTINATION Examples/OpenGL/bin
|
||||||
INSTALL(TARGETS PagingExample
|
LIBRARY DESTINATION Examples/OpenGL/lib
|
||||||
RUNTIME DESTINATION Examples/OpenGL/bin
|
ARCHIVE DESTINATION Examples/OpenGL/lib
|
||||||
LIBRARY DESTINATION Examples/OpenGL/lib
|
COMPONENT example
|
||||||
ARCHIVE DESTINATION Examples/OpenGL/lib
|
)
|
||||||
COMPONENT example
|
|
||||||
)
|
#.dlls should be installed in shared builds.
|
||||||
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
||||||
#.dlls should be installed in shared builds.
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../release/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Release)
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
||||||
|
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxCore.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
ENDIF(WIN32)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../debug/PolyVoxUtil.dll DESTINATION Examples/OpenGL/bin CONFIGURATIONS Debug)
|
|
||||||
ENDIF(WIN32)
|
|
||||||
|
@ -1,135 +0,0 @@
|
|||||||
#include "OpenGLWidget.h"
|
|
||||||
|
|
||||||
#include <QMouseEvent>
|
|
||||||
|
|
||||||
using namespace PolyVox;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
OpenGLWidget::OpenGLWidget(QWidget *parent)
|
|
||||||
:QGLWidget(parent)
|
|
||||||
,m_uBeginIndex(0)
|
|
||||||
,m_uEndIndex(0)
|
|
||||||
,noOfIndices(0)
|
|
||||||
,m_xRotation(0)
|
|
||||||
,m_yRotation(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PositionMaterialNormal>& surfaceMesh)
|
|
||||||
{
|
|
||||||
if((surfaceMesh.getNoOfIndices() == 0) || (surfaceMesh.getNoOfVertices() == 0))
|
|
||||||
{
|
|
||||||
//We don't have a valid mesh
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Convienient access to the vertices and indices
|
|
||||||
const vector<uint32_t>& vecIndices = surfaceMesh.getIndices();
|
|
||||||
const vector<PositionMaterialNormal>& vecVertices = surfaceMesh.getVertices();
|
|
||||||
|
|
||||||
//Build an OpenGL index buffer
|
|
||||||
glGenBuffers(1, &indexBuffer);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
||||||
const GLvoid* pIndices = static_cast<const GLvoid*>(&(vecIndices[0]));
|
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, vecIndices.size() * sizeof(uint32_t), pIndices, GL_STATIC_DRAW);
|
|
||||||
|
|
||||||
//Build an OpenGL vertex buffer
|
|
||||||
glGenBuffers(1, &vertexBuffer);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
|
||||||
const GLvoid* pVertices = static_cast<const GLvoid*>(&(vecVertices[0]));
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(PositionMaterialNormal), pVertices, GL_STATIC_DRAW);
|
|
||||||
|
|
||||||
m_uBeginIndex = 0;
|
|
||||||
m_uEndIndex = vecIndices.size();
|
|
||||||
noOfIndices = surfaceMesh.getNoOfIndices();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::initializeGL()
|
|
||||||
{
|
|
||||||
//We need GLEW to access recent OpenGL functionality
|
|
||||||
GLenum err = glewInit();
|
|
||||||
if (GLEW_OK != err)
|
|
||||||
{
|
|
||||||
/* Problem: glewInit failed, something is seriously wrong. */
|
|
||||||
std::cout << "GLEW Error: " << glewGetErrorString(err) << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set up the clear colour
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
|
||||||
glClearDepth(1.0f);
|
|
||||||
|
|
||||||
//Enable the depth buffer
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
|
|
||||||
//Anable smooth lighting
|
|
||||||
glEnable(GL_LIGHTING);
|
|
||||||
glEnable(GL_LIGHT0);
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
|
|
||||||
//We'll be rendering with index/vertex arrays
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::resizeGL(int w, int h)
|
|
||||||
{
|
|
||||||
//Setup the viewport
|
|
||||||
glViewport(0, 0, w, h);
|
|
||||||
|
|
||||||
//Set up the projection matrix
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
float frustumSize = 128.0f * 1.7f; //Half the volume diagonal
|
|
||||||
float aspect = static_cast<float>(width()) / static_cast<float>(height());
|
|
||||||
glOrtho(frustumSize*aspect, -frustumSize*aspect, frustumSize, -frustumSize, 10.0, 10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::paintGL()
|
|
||||||
{
|
|
||||||
if(noOfIndices == 0)
|
|
||||||
{
|
|
||||||
//Nothing to render
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clear the screen
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
//Set up the viewing transformation
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
glTranslatef(0.0f,0.0f,-5000.0f); //Centre volume and move back
|
|
||||||
glRotatef(m_xRotation, 1.0f, 0.0f, 0.0f);
|
|
||||||
glRotatef(m_yRotation, 0.0f, 1.0f, 0.0f);
|
|
||||||
glTranslatef(-128.0f,-128.0f,-128.0f); //Centre volume and move back
|
|
||||||
|
|
||||||
//Bind the index buffer
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
||||||
|
|
||||||
//Bind the vertex buffer
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
|
||||||
glVertexPointer(3, GL_FLOAT, sizeof(PositionMaterialNormal), 0);
|
|
||||||
glNormalPointer(GL_FLOAT, sizeof(PositionMaterialNormal), (GLvoid*)12);
|
|
||||||
|
|
||||||
glDrawRangeElements(GL_TRIANGLES, m_uBeginIndex, m_uEndIndex-1, m_uEndIndex - m_uBeginIndex, GL_UNSIGNED_INT, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::mousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
m_CurrentMousePos = event->pos();
|
|
||||||
m_LastFrameMousePos = m_CurrentMousePos;
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLWidget::mouseMoveEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
m_CurrentMousePos = event->pos();
|
|
||||||
QPoint diff = m_CurrentMousePos - m_LastFrameMousePos;
|
|
||||||
m_xRotation += diff.x();
|
|
||||||
m_yRotation += diff.y();
|
|
||||||
m_LastFrameMousePos = m_CurrentMousePos;
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
Copyright (c) 2005-2009 David Williams
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __BasicExample_OpenGLWidget_H__
|
|
||||||
#define __BasicExample_OpenGLWidget_H__
|
|
||||||
|
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
|
||||||
|
|
||||||
#include "glew/glew.h"
|
|
||||||
|
|
||||||
#include <QGLWidget>
|
|
||||||
|
|
||||||
class OpenGLWidget : public QGLWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//Constructor
|
|
||||||
OpenGLWidget(QWidget *parent);
|
|
||||||
|
|
||||||
//Mouse handling
|
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
|
||||||
void mousePressEvent(QMouseEvent* event);
|
|
||||||
|
|
||||||
//Convert a SrfaceMesh to OpenGL index/vertex buffers
|
|
||||||
void setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>& surfaceMesh);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
//Qt OpenGL functions
|
|
||||||
void initializeGL();
|
|
||||||
void resizeGL(int w, int h);
|
|
||||||
void paintGL();
|
|
||||||
|
|
||||||
private:
|
|
||||||
//Index/vertex buffer data
|
|
||||||
GLuint m_uBeginIndex;
|
|
||||||
GLuint m_uEndIndex;
|
|
||||||
GLuint noOfIndices;
|
|
||||||
GLuint indexBuffer;
|
|
||||||
GLuint vertexBuffer;
|
|
||||||
|
|
||||||
//Mouse data
|
|
||||||
QPoint m_LastFrameMousePos;
|
|
||||||
QPoint m_CurrentMousePos;
|
|
||||||
int m_xRotation;
|
|
||||||
int m_yRotation;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //__BasicExample_OpenGLWidget_H__
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user