Compare commits
804 Commits
v.5.0.0.rc
...
v5.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d2889f73f | ||
|
|
d3a79d0cc2 | ||
|
|
c07793149c | ||
|
|
3b2e0ebfc7 | ||
|
|
aa47a028c8 | ||
|
|
74ac8676e2 | ||
|
|
ab3c17419e | ||
|
|
720ac4846b | ||
|
|
87004aa70c | ||
|
|
94c488d7ea | ||
|
|
ef54a00fc4 | ||
|
|
06eb199704 | ||
|
|
aeecc17482 | ||
|
|
13586eb073 | ||
|
|
69087abc56 | ||
|
|
83df4f4104 | ||
|
|
d4101bbf06 | ||
|
|
18bbfdac1a | ||
|
|
4b9cc1a484 | ||
|
|
b6edcb35a8 | ||
|
|
dbf47f7769 | ||
|
|
e3d277faea | ||
|
|
9186e107f6 | ||
|
|
fed7fcf2fb | ||
|
|
06542c49df | ||
|
|
1abf6d50fe | ||
|
|
2194577429 | ||
|
|
a5859dd3f4 | ||
|
|
c0ec5140ee | ||
|
|
6d4854f12c | ||
|
|
116dcce0ba | ||
|
|
3b608307c8 | ||
|
|
8add762eac | ||
|
|
f5dcd5060f | ||
|
|
f7da7d8f67 | ||
|
|
2edcf82f5a | ||
|
|
7f3b33d1c2 | ||
|
|
8b95479bb0 | ||
|
|
7f7918957a | ||
|
|
2be0eba1ab | ||
|
|
ca0549558b | ||
|
|
79056da4be | ||
|
|
ab3528f726 | ||
|
|
818a5b633f | ||
|
|
446381e1ca | ||
|
|
cc7ba5288c | ||
|
|
ee1ed502e7 | ||
|
|
a1254f067e | ||
|
|
f985bcba83 | ||
|
|
a642b1d51a | ||
|
|
4d2adf5bea | ||
|
|
3bd63c006f | ||
|
|
a25a1f0772 | ||
|
|
783f92e148 | ||
|
|
3069e2272d | ||
|
|
f10bd72100 | ||
|
|
f9c6fed190 | ||
|
|
f67c18d41a | ||
|
|
55b735b6c3 | ||
|
|
3cbcfd3cd8 | ||
|
|
7ff7a5d64e | ||
|
|
0307327999 | ||
|
|
28d0300dbe | ||
|
|
d91eebf347 | ||
|
|
e1322f9178 | ||
|
|
b9cff2a019 | ||
|
|
52d0170470 | ||
|
|
1899aaef6e | ||
|
|
bfac0aae9c | ||
|
|
d672ae21d0 | ||
|
|
a16645f3f7 | ||
|
|
c19bd3d1d1 | ||
|
|
b4fdc009e2 | ||
|
|
66e5765387 | ||
|
|
a0fb50146a | ||
|
|
621a7a1abd | ||
|
|
db55ba4908 | ||
|
|
027ee6ee00 | ||
|
|
03514a9237 | ||
|
|
c519a91233 | ||
|
|
602b0cf0c2 | ||
|
|
ddc26e1c46 | ||
|
|
da97f1be79 | ||
|
|
1b86de9d14 | ||
|
|
3801b84ef9 | ||
|
|
ad2dd2dc18 | ||
|
|
a835afeb2b | ||
|
|
5d8482dae6 | ||
|
|
86886cb2e4 | ||
|
|
f8bcd7cb40 | ||
|
|
945af4397b | ||
|
|
336ae0e55a | ||
|
|
c1d4549d19 | ||
|
|
3546403284 | ||
|
|
570b3838c9 | ||
|
|
1503608aaa | ||
|
|
91706a1f6e | ||
|
|
1a8375f925 | ||
|
|
d177c722b1 | ||
|
|
eb8479a95e | ||
|
|
6661e7047a | ||
|
|
8fc625513e | ||
|
|
22bd047db5 | ||
|
|
9b897a8e8d | ||
|
|
af26c090db | ||
|
|
b271091c64 | ||
|
|
4029fe5e46 | ||
|
|
9adc4e87fa | ||
|
|
0324643cd5 | ||
|
|
873a358ce4 | ||
|
|
8ca9d2ed40 | ||
|
|
893a0177ff | ||
|
|
eb762e654e | ||
|
|
a16906686f | ||
|
|
50820e48b9 | ||
|
|
a8822a2b29 | ||
|
|
0685e415ad | ||
|
|
6c65b5b549 | ||
|
|
727cf0c49f | ||
|
|
4d9b350184 | ||
|
|
57e712c0a8 | ||
|
|
071504991a | ||
|
|
c4ce8cec96 | ||
|
|
e317fbfbb6 | ||
|
|
bbb1f6a1dc | ||
|
|
ceacad237f | ||
|
|
33e71ee8df | ||
|
|
75993ad653 | ||
|
|
53d795c1c9 | ||
|
|
ec1930478c | ||
|
|
c1d4ed7873 | ||
|
|
9196dab247 | ||
|
|
0f18ec9e2c | ||
|
|
4c12328e05 | ||
|
|
b34f9839f1 | ||
|
|
e8592024bd | ||
|
|
01d0f06d3a | ||
|
|
de51122639 | ||
|
|
2d0d2374c1 | ||
|
|
89079ead12 | ||
|
|
946d64282b | ||
|
|
340611785a | ||
|
|
cb2beba073 | ||
|
|
aec4726d21 | ||
|
|
b3788039df | ||
|
|
3ef0860f30 | ||
|
|
d7b3b344f6 | ||
|
|
e8ae086b35 | ||
|
|
75fed8340d | ||
|
|
a044852938 | ||
|
|
ba3e4ae892 | ||
|
|
2f53d42d45 | ||
|
|
cca81e877a | ||
|
|
b363fa3883 | ||
|
|
69fce64b9c | ||
|
|
44d7cb8177 | ||
|
|
02444be251 | ||
|
|
65ba0c4b46 | ||
|
|
ebb061d89c | ||
|
|
0d17315166 | ||
|
|
f009c216b6 | ||
|
|
eadbc89a1f | ||
|
|
438b070508 | ||
|
|
805fda3df8 | ||
|
|
b1f8f6ae3b | ||
|
|
ffb30fbc85 | ||
|
|
789e8abfe8 | ||
|
|
f1e0c460ed | ||
|
|
8e90bf8381 | ||
|
|
43865e6bc9 | ||
|
|
60f2535dcd | ||
|
|
7d8a25993b | ||
|
|
765c0e71f6 | ||
|
|
806bcf76b1 | ||
|
|
30eb3c56c3 | ||
|
|
575d7eb29c | ||
|
|
dbb498095d | ||
|
|
0dd1ae0196 | ||
|
|
9ad7ce1129 | ||
|
|
a9d902946d | ||
|
|
2405b3b5ba | ||
|
|
84c0d6b95a | ||
|
|
e20640c2c8 | ||
|
|
afb24d7a1c | ||
|
|
43cb76653b | ||
|
|
abdd853ca5 | ||
|
|
234b759cbc | ||
|
|
ad971468ef | ||
|
|
0729a6e20f | ||
|
|
7e12257ebc | ||
|
|
c50a4d8ade | ||
|
|
d56198774e | ||
|
|
5fe728345f | ||
|
|
48f1f012eb | ||
|
|
f119fedd55 | ||
|
|
594d90a18e | ||
|
|
646a466c70 | ||
|
|
b60fc4a44f | ||
|
|
ef98d357b4 | ||
|
|
d923c8ce48 | ||
|
|
9a78f2c6f1 | ||
|
|
95d4faef6d | ||
|
|
7016428895 | ||
|
|
db8606ba57 | ||
|
|
fb2b673387 | ||
|
|
ffc19790fb | ||
|
|
0d29203e24 | ||
|
|
63f63c7470 | ||
|
|
0f6e95f19d | ||
|
|
b8d4ae5a7c | ||
|
|
bdf6612ba0 | ||
|
|
4bc5e8c262 | ||
|
|
eb55a6a3cd | ||
|
|
fbb34b1de1 | ||
|
|
74685477e6 | ||
|
|
e5372fc385 | ||
|
|
23e1c0cbc9 | ||
|
|
b25b83fb46 | ||
|
|
7ee7946dc5 | ||
|
|
1cb23134b8 | ||
|
|
09a994f72c | ||
|
|
effd324a21 | ||
|
|
f69bf5f7ed | ||
|
|
0400e0bc7f | ||
|
|
5fa1f20327 | ||
|
|
581b368223 | ||
|
|
812397d681 | ||
|
|
84e9d9ddf8 | ||
|
|
25dcef2758 | ||
|
|
a9b4909a2f | ||
|
|
3309ea9a5c | ||
|
|
a2ee19e86d | ||
|
|
578fccf522 | ||
|
|
3d0775eebc | ||
|
|
172422460c | ||
|
|
02812f22af | ||
|
|
563ec1662c | ||
|
|
51923b5d3c | ||
|
|
4580c56504 | ||
|
|
4c1e8fe9c3 | ||
|
|
cc8e7dcc1b | ||
|
|
7d67eca52c | ||
|
|
f1f409d538 | ||
|
|
3c7a608956 | ||
|
|
181d3dd84f | ||
|
|
5b81899302 | ||
|
|
2d7505b244 | ||
|
|
1097f47ff5 | ||
|
|
74d2eb842b | ||
|
|
090e896ebf | ||
|
|
42f07c8bbc | ||
|
|
9f5b047f7c | ||
|
|
9330cca1cd | ||
|
|
83d2ec7f74 | ||
|
|
1e6eac9e65 | ||
|
|
1c3e934ae9 | ||
|
|
cfbe368d72 | ||
|
|
deee43f946 | ||
|
|
7b67b00a79 | ||
|
|
1d565b0aab | ||
|
|
d83af91095 | ||
|
|
762e039d15 | ||
|
|
69265273c2 | ||
|
|
7d74a3354d | ||
|
|
361609c60b | ||
|
|
7fc4cf1552 | ||
|
|
94328695d0 | ||
|
|
73914cd7e2 | ||
|
|
982914754e | ||
|
|
72e18ed4aa | ||
|
|
d8eaf0bc7f | ||
|
|
a6b06ad811 | ||
|
|
aaaa0a02a3 | ||
|
|
0f0454c3b7 | ||
|
|
f9f408690e | ||
|
|
2ddb00f4e0 | ||
|
|
029338940c | ||
|
|
0ed9158908 | ||
|
|
6e6765cae3 | ||
|
|
c597e21b67 | ||
|
|
9b2aac8c96 | ||
|
|
079e522eae | ||
|
|
8fc899035c | ||
|
|
5a7c226c30 | ||
|
|
57a56b7b1d | ||
|
|
337df20209 | ||
|
|
80047cd633 | ||
|
|
a879102309 | ||
|
|
9dce8e40ba | ||
|
|
7e8a3ec4cb | ||
|
|
e993cdc309 | ||
|
|
59a5343a1a | ||
|
|
9880db8d4d | ||
|
|
e05ece2eec | ||
|
|
9b78060a4a | ||
|
|
3016f3a725 | ||
|
|
5c6ea5d7ba | ||
|
|
9e04df810e | ||
|
|
dadf5c0020 | ||
|
|
d1b206a8ea | ||
|
|
c6620478ec | ||
|
|
17adc98eec | ||
|
|
e828dd1757 | ||
|
|
46a8164af4 | ||
|
|
78b283135e | ||
|
|
5895f04391 | ||
|
|
41ea607739 | ||
|
|
5b6fe80883 | ||
|
|
ff7ec7e454 | ||
|
|
4bd8ae8211 | ||
|
|
103048ff85 | ||
|
|
f804036cf3 | ||
|
|
b6616e7b79 | ||
|
|
e84f961f78 | ||
|
|
68520bff0c | ||
|
|
3416c04ad9 | ||
|
|
a8019cf8d8 | ||
|
|
2f6a005fb8 | ||
|
|
03b58e84c3 | ||
|
|
e1e9d92c01 | ||
|
|
e3683e49e4 | ||
|
|
5121a835b5 | ||
|
|
6299c58fae | ||
|
|
6e0810d3c1 | ||
|
|
cdf60d7423 | ||
|
|
c889699d58 | ||
|
|
9210ff37f2 | ||
|
|
c979b4060d | ||
|
|
4ff4938df4 | ||
|
|
2122dc231d | ||
|
|
0accbb58f1 | ||
|
|
fed764d2a8 | ||
|
|
c1670b6a97 | ||
|
|
f045170048 | ||
|
|
2bffdc7e08 | ||
|
|
36130f9b86 | ||
|
|
add4d6028b | ||
|
|
f2731a1b99 | ||
|
|
b344beb00b | ||
|
|
bcdb173e09 | ||
|
|
4a2df57241 | ||
|
|
07d3a7d5b0 | ||
|
|
678dd32da3 | ||
|
|
8f74508e40 | ||
|
|
e786483c64 | ||
|
|
53c0f91305 | ||
|
|
0c718a9c95 | ||
|
|
2a72c9b616 | ||
|
|
ddd1e770b9 | ||
|
|
8636d5607c | ||
|
|
d64e1bde13 | ||
|
|
2c7f607e7c | ||
|
|
259a9bd2af | ||
|
|
3b3a965d2b | ||
|
|
b1d8398243 | ||
|
|
8bf1b9ac5e | ||
|
|
82e7775d6d | ||
|
|
da33262bcc | ||
|
|
eb5e829436 | ||
|
|
2e782f43e5 | ||
|
|
b463ddd399 | ||
|
|
f03f099fa8 | ||
|
|
f703a798f4 | ||
|
|
d7773dcfba | ||
|
|
47661034ae | ||
|
|
6b5e0a9914 | ||
|
|
bc8f85eeae | ||
|
|
39dc9801e0 | ||
|
|
a01302dd4d | ||
|
|
ed6dbf9533 | ||
|
|
b87f4c03ba | ||
|
|
b688797766 | ||
|
|
01070b4de7 | ||
|
|
5a82e27885 | ||
|
|
ae7b1f1a77 | ||
|
|
6beed14e35 | ||
|
|
0ec5eb752c | ||
|
|
08eb6701c3 | ||
|
|
fa827f9075 | ||
|
|
1fc232effa | ||
|
|
96f16c7aea | ||
|
|
ab55fb27c3 | ||
|
|
500983074b | ||
|
|
ff662a6104 | ||
|
|
3fcf3bd81f | ||
|
|
01d144ce89 | ||
|
|
f5ece83f31 | ||
|
|
1ec01a870f | ||
|
|
6d07473550 | ||
|
|
05f5b54f75 | ||
|
|
07779a7ae1 | ||
|
|
af199c50aa | ||
|
|
b15311661c | ||
|
|
853afdf42b | ||
|
|
ed0cd2f775 | ||
|
|
d7e442f78a | ||
|
|
1952144445 | ||
|
|
0f66a917e5 | ||
|
|
8f43fb144a | ||
|
|
26bd54ae0b | ||
|
|
418c07a9bb | ||
|
|
bf252c4452 | ||
|
|
59f732e10d | ||
|
|
fb8ee5e301 | ||
|
|
6b3d6c3b8f | ||
|
|
3929ea0644 | ||
|
|
ced080f9f3 | ||
|
|
eb27fb753d | ||
|
|
2d3c3379e5 | ||
|
|
6c33374491 | ||
|
|
d00f4f4b3a | ||
|
|
5cda81e84b | ||
|
|
dab8041bcd | ||
|
|
a4587e8609 | ||
|
|
1db3e1e11f | ||
|
|
dd9511aaef | ||
|
|
34fa64faf9 | ||
|
|
b381467fc3 | ||
|
|
ba29b8f1da | ||
|
|
43375eafb7 | ||
|
|
8ec3aaed7d | ||
|
|
8d0567f727 | ||
|
|
c2097d9d0a | ||
|
|
05de460ced | ||
|
|
0021c93892 | ||
|
|
6ed753d80a | ||
|
|
fc06de82c6 | ||
|
|
963c6f1977 | ||
|
|
a4907e54b1 | ||
|
|
66f693a6a4 | ||
|
|
e914b9531b | ||
|
|
4dcb3c9235 | ||
|
|
fc065d8ab4 | ||
|
|
a6e3fc3fd9 | ||
|
|
cc10967913 | ||
|
|
d24b6e220b | ||
|
|
03c01004c5 | ||
|
|
d448b49ae1 | ||
|
|
1651f16239 | ||
|
|
f76d77955d | ||
|
|
2da3a38d60 | ||
|
|
7e20356a20 | ||
|
|
47c70a8811 | ||
|
|
6fc42cb898 | ||
|
|
a4bda3a205 | ||
|
|
2d985b92c9 | ||
|
|
83247e3fbd | ||
|
|
56d145e26a | ||
|
|
cbd5c5b284 | ||
|
|
4a46717a77 | ||
|
|
7dc38faeba | ||
|
|
5679dd435a | ||
|
|
ee7a2b6e31 | ||
|
|
57c46db042 | ||
|
|
589a306c85 | ||
|
|
6ed4f5d936 | ||
|
|
1855bf44f9 | ||
|
|
83237de02f | ||
|
|
e8a4d60b6f | ||
|
|
5dcb2cb8c0 | ||
|
|
cead840a75 | ||
|
|
4de162fa79 | ||
|
|
dcee3295cc | ||
|
|
fe4fd00a82 | ||
|
|
4d66b33253 | ||
|
|
35f9517510 | ||
|
|
04117e1378 | ||
|
|
f0f2a7fc09 | ||
|
|
0215d77abd | ||
|
|
48ed2d2d3c | ||
|
|
5bc6787d57 | ||
|
|
1370e0b26f | ||
|
|
cf4d656bbf | ||
|
|
a6b51ef911 | ||
|
|
eb6d9db505 | ||
|
|
85a7f46049 | ||
|
|
873762cf60 | ||
|
|
f114aa8d9b | ||
|
|
51527ba038 | ||
|
|
dff92d7733 | ||
|
|
3924a5c32a | ||
|
|
ca13160369 | ||
|
|
d048bccad1 | ||
|
|
5c3662dc6d | ||
|
|
4feefaf5f7 | ||
|
|
b03b3b9c03 | ||
|
|
fdcae81b61 | ||
|
|
e1ed975839 | ||
|
|
daef984ac6 | ||
|
|
f0a0de63e9 | ||
|
|
fc7575f5c5 | ||
|
|
5fa750fda0 | ||
|
|
1d05f1b222 | ||
|
|
9787ac724f | ||
|
|
52d4564b7e | ||
|
|
0e8444b83f | ||
|
|
a60b7696e3 | ||
|
|
0eec1c1d4a | ||
|
|
7ac831489c | ||
|
|
b10dc5747b | ||
|
|
b1975aaabc | ||
|
|
b8262c4c70 | ||
|
|
45c12cd5fb | ||
|
|
627cb93b0b | ||
|
|
b4eb974d9e | ||
|
|
ff4ab7ff2e | ||
|
|
2f4cb93764 | ||
|
|
9740c043c6 | ||
|
|
4b10c7e432 | ||
|
|
d29e245536 | ||
|
|
81f8ebf2d4 | ||
|
|
2ba3d956d1 | ||
|
|
7cd021e704 | ||
|
|
6fda615706 | ||
|
|
6c13ec8190 | ||
|
|
c84ac7a135 | ||
|
|
13bba4fb4c | ||
|
|
b957d44943 | ||
|
|
c58ed8da22 | ||
|
|
4e03a2c00d | ||
|
|
5bca43be74 | ||
|
|
77281b75b2 | ||
|
|
524d8c281e | ||
|
|
785ceaf58a | ||
|
|
f50a0f0648 | ||
|
|
add086b9e8 | ||
|
|
747a7c963b | ||
|
|
5bee5307e4 | ||
|
|
815730c92d | ||
|
|
adbdbf2be6 | ||
|
|
461e21f66d | ||
|
|
cb0c47764a | ||
|
|
c48adf2301 | ||
|
|
fd0e0d05e6 | ||
|
|
0898484d45 | ||
|
|
6aecfd0183 | ||
|
|
64ff361610 | ||
|
|
4f7de109a1 | ||
|
|
2582ae53ee | ||
|
|
741be6f9db | ||
|
|
f81b90a469 | ||
|
|
700954c115 | ||
|
|
a443544986 | ||
|
|
9903504c42 | ||
|
|
575ef4d927 | ||
|
|
6736f3d24b | ||
|
|
9430696048 | ||
|
|
56b82e9cd5 | ||
|
|
880e5ee32c | ||
|
|
e1a0861556 | ||
|
|
390452bd06 | ||
|
|
66a840d9e6 | ||
|
|
9501483367 | ||
|
|
22b01ca3e8 | ||
|
|
1517bfcb9f | ||
|
|
e917b288a1 | ||
|
|
4155f005be | ||
|
|
4a9cd08451 | ||
|
|
e611ccc933 | ||
|
|
02324123e5 | ||
|
|
e6b4a21be1 | ||
|
|
1203d4658c | ||
|
|
34084423ca | ||
|
|
e403aaa0cc | ||
|
|
eb1a2586c3 | ||
|
|
df2a279895 | ||
|
|
e1fce7819c | ||
|
|
9147fb8689 | ||
|
|
1324409c7b | ||
|
|
8c18c42afb | ||
|
|
69ece762d1 | ||
|
|
fcff12b219 | ||
|
|
9b9f7b2876 | ||
|
|
4a6b9d716a | ||
|
|
34ede5608b | ||
|
|
2f38545cc4 | ||
|
|
6d5f8cbe26 | ||
|
|
3e57510af5 | ||
|
|
8dacbf49f9 | ||
|
|
5498a50612 | ||
|
|
7c48552462 | ||
|
|
647d2f8d18 | ||
|
|
e108b6f1d2 | ||
|
|
37bf09ef0b | ||
|
|
d9cfc48a66 | ||
|
|
c93886e87b | ||
|
|
3ee85a8cc8 | ||
|
|
615a78e38f | ||
|
|
84e7f542fb | ||
|
|
6ff7635338 | ||
|
|
a2ca691072 | ||
|
|
84d5398d56 | ||
|
|
b96d53c05d | ||
|
|
800616e83a | ||
|
|
c821c6f301 | ||
|
|
718109c17e | ||
|
|
0b9c72fa94 | ||
|
|
ae9cb02427 | ||
|
|
9ab7f88cdf | ||
|
|
bcd17481e5 | ||
|
|
243b2618a9 | ||
|
|
bc4e411284 | ||
|
|
27665ce930 | ||
|
|
55cdf1d37c | ||
|
|
bd53e67110 | ||
|
|
3824f17223 | ||
|
|
0853623924 | ||
|
|
6d241cc2f0 | ||
|
|
4c3e34ba6c | ||
|
|
09905c2de3 | ||
|
|
58b1440fc8 | ||
|
|
42202c2204 | ||
|
|
e83671f494 | ||
|
|
0b42d55f73 | ||
|
|
48e5b948e3 | ||
|
|
5713be615c | ||
|
|
c34327b355 | ||
|
|
e8bcf162dd | ||
|
|
51be6236a7 | ||
|
|
7b6cb57e3b | ||
|
|
00f1fd6f7c | ||
|
|
b515f04ce6 | ||
|
|
692927a8a1 | ||
|
|
0b9da72ed8 | ||
|
|
9242a12bf5 | ||
|
|
836801d37e | ||
|
|
b6d3cbcb61 | ||
|
|
1ff10c1ade | ||
|
|
36bce5fa00 | ||
|
|
685a56266b | ||
|
|
9b9b2c8339 | ||
|
|
5bf096ab6d | ||
|
|
bbaa9f330d | ||
|
|
6ff563ec23 | ||
|
|
e2025c3dec | ||
|
|
c92ae50e4f | ||
|
|
2f6f716512 | ||
|
|
1b0c1139eb | ||
|
|
c1f3624f5b | ||
|
|
24a0aaeb77 | ||
|
|
567a645c4f | ||
|
|
6a373d55c7 | ||
|
|
f7384dec95 | ||
|
|
9aae110161 | ||
|
|
1f55bdd9a7 | ||
|
|
49459435df | ||
|
|
4507f7cf46 | ||
|
|
d72c8e9c22 | ||
|
|
dbd0f06d32 | ||
|
|
ef209c6eed | ||
|
|
e3a397a98d | ||
|
|
d66166675a | ||
|
|
99648b69c3 | ||
|
|
d3d98a7ec0 | ||
|
|
cbd8b032e7 | ||
|
|
98ed6a2e18 | ||
|
|
189bb2a233 | ||
|
|
2a3626577f | ||
|
|
6dec1346ed | ||
|
|
0973f504b5 | ||
|
|
79f62b0174 | ||
|
|
f7d226768c | ||
|
|
37357515fa | ||
|
|
ddfc140fc3 | ||
|
|
fac392d6cb | ||
|
|
015e960d0e | ||
|
|
b3177a2a9a | ||
|
|
03bd8905f5 | ||
|
|
c321fb6a44 | ||
|
|
d0ad03d653 | ||
|
|
225b6fa166 | ||
|
|
898e59d8ee | ||
|
|
20acce1c5e | ||
|
|
3abb494dd6 | ||
|
|
010afeb1d8 | ||
|
|
01d4b10f14 | ||
|
|
e63b9d4cd8 | ||
|
|
6d1514dd10 | ||
|
|
f10e759db6 | ||
|
|
42608c0260 | ||
|
|
287924a7d6 | ||
|
|
906a60a38d | ||
|
|
0251633ea2 | ||
|
|
4884cf2172 | ||
|
|
fa37018e08 | ||
|
|
0505dd7266 | ||
|
|
d2b45377e4 | ||
|
|
838d0c35b6 | ||
|
|
930af2da44 | ||
|
|
9d5a71e4af | ||
|
|
933fe5eb43 | ||
|
|
f15f37634d | ||
|
|
5a85ceaf18 | ||
|
|
3e19545dc7 | ||
|
|
e45d120f21 | ||
|
|
f001dfc840 | ||
|
|
5a53fbd65f | ||
|
|
efbb85721c | ||
|
|
1b9157440f | ||
|
|
1614b7bea4 | ||
|
|
ee79ac0f17 | ||
|
|
7930de9f37 | ||
|
|
e849b94f68 | ||
|
|
0292acd5a9 | ||
|
|
51844b206d | ||
|
|
44e89520eb | ||
|
|
4e714fce0e | ||
|
|
49033513ef | ||
|
|
1371cb59d9 | ||
|
|
ae6c1e5ad8 | ||
|
|
eb81619e56 | ||
|
|
3ea9216c6e | ||
|
|
89b3de9473 | ||
|
|
a79f832a54 | ||
|
|
d314afaebc | ||
|
|
faf12c6f5f | ||
|
|
d129259ae4 | ||
|
|
7721e430b4 | ||
|
|
d62724ab4f | ||
|
|
92ec834fec | ||
|
|
7b4c704e6b | ||
|
|
f0ffcd4025 | ||
|
|
f653c48c23 | ||
|
|
deceb4ebf4 | ||
|
|
4efa3736ba | ||
|
|
d718793163 | ||
|
|
769dd42b73 | ||
|
|
ab92f50fa8 | ||
|
|
ca08c4a209 | ||
|
|
bb11f90983 | ||
|
|
7e39ae0d52 | ||
|
|
a43ac5b3fd | ||
|
|
6c26268035 | ||
|
|
f8753482d3 | ||
|
|
0fc58c135b | ||
|
|
e3bd33f0c8 | ||
|
|
0abf6acf86 | ||
|
|
8d5551a422 | ||
|
|
cd9c256de5 | ||
|
|
82e08d2a92 | ||
|
|
22f4667932 | ||
|
|
e899067f44 | ||
|
|
718b5b266b | ||
|
|
525566b8b8 | ||
|
|
c1e2f19c08 | ||
|
|
a3fdb46f67 | ||
|
|
df6d257633 | ||
|
|
5ccd7d8c39 | ||
|
|
581d06a7b7 | ||
|
|
2f6aa2460a | ||
|
|
64bcf56101 | ||
|
|
f4ec02a34b | ||
|
|
a0c797a29e | ||
|
|
64a7a46406 | ||
|
|
e9b6a4895d | ||
|
|
ba6a7383b2 | ||
|
|
9a533d826a | ||
|
|
07bbb2c000 | ||
|
|
ef270225ac | ||
|
|
61ffe017e8 | ||
|
|
170549559e | ||
|
|
d9e81cbfd1 | ||
|
|
04025f09cf | ||
|
|
93e8a1054f | ||
|
|
27f3b35813 | ||
|
|
145c3d1589 | ||
|
|
0a731a0bff | ||
|
|
650fadebe9 | ||
|
|
0dc2e9197a | ||
|
|
90dbd8f350 | ||
|
|
152cddedd3 | ||
|
|
63afcf8267 | ||
|
|
ac80b116a9 | ||
|
|
f0ed1702b9 | ||
|
|
5fd9789fc3 | ||
|
|
4728c1bb68 | ||
|
|
27dc922d09 | ||
|
|
28c110af2e | ||
|
|
7bb1303773 | ||
|
|
2e262dbbc6 | ||
|
|
80dffb63e8 | ||
|
|
3a610d3d66 | ||
|
|
b15c93c726 | ||
|
|
c3c0f5028c | ||
|
|
762c09988c | ||
|
|
7d7574f189 | ||
|
|
c1c42023fa | ||
|
|
0810b2d51b | ||
|
|
6cc41d6be6 | ||
|
|
ce691d383f | ||
|
|
3aa5a61516 | ||
|
|
05ea039846 | ||
|
|
3c651be640 | ||
|
|
fe6b316695 | ||
|
|
555c54d917 | ||
|
|
cec163c025 | ||
|
|
ad7964be63 | ||
|
|
cf6dff0b93 | ||
|
|
b1da322deb | ||
|
|
54be5fdb7b | ||
|
|
27b331eb0c | ||
|
|
4f7bacd108 | ||
|
|
1c577f66f7 | ||
|
|
cb567d9f65 |
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
patreon: assimp
|
||||
ko_fi: kimkulling
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -7,6 +7,12 @@ build
|
||||
*.sln
|
||||
*.ncb
|
||||
*.vcproj
|
||||
*.vcxproj.user
|
||||
*.VC.db
|
||||
*.VC.db-shm
|
||||
*.VC.db-wal
|
||||
*.VC.opendb
|
||||
*.ipch
|
||||
|
||||
# Output
|
||||
bin/
|
||||
@@ -17,6 +23,7 @@ CMakeLists.txt.user
|
||||
|
||||
# Generated
|
||||
assimp.pc
|
||||
assimp.aps
|
||||
revision.h
|
||||
contrib/zlib/zconf.h
|
||||
contrib/zlib/zlib.pc
|
||||
@@ -31,6 +38,7 @@ cmake_uninstall.cmake
|
||||
*.dir/
|
||||
assimp-config.cmake
|
||||
assimp-config-version.cmake
|
||||
assimpTargets*.cmake
|
||||
|
||||
# MakeFile
|
||||
Makefile
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#
|
||||
function generate() {
|
||||
OPTIONS="-DASSIMP_WERROR=ON"
|
||||
|
||||
OPTIONS="$OPTIONS -DASSIMP_NO_EXPORT=NO"
|
||||
|
||||
if [ "$DISABLE_EXPORTERS" = "YES" ] ; then
|
||||
OPTIONS="$OPTIONS -DASSIMP_NO_EXPORT=YES"
|
||||
else
|
||||
|
||||
@@ -70,6 +70,6 @@ addons:
|
||||
project:
|
||||
name: "assimp/assimp"
|
||||
notification_email: kim.kulling@googlemail.com
|
||||
build_command_prepend: "cmake . -DASSIMP_ENABLE_BOOST_WORKAROUND=YES"
|
||||
build_command_prepend: "cmake ./"
|
||||
build_command: "make -j4"
|
||||
branch_pattern: coverity_scan
|
||||
|
||||
26
BUILDBINARIES_EXAMPLE.bat
Normal file
26
BUILDBINARIES_EXAMPLE.bat
Normal file
@@ -0,0 +1,26 @@
|
||||
:: This is an example file to generate binaries using Windows Operating System
|
||||
:: This script is configured to be executed from the source directory
|
||||
|
||||
:: Compiled binaries will be placed in BINARIES_DIR\code\CONFIG
|
||||
|
||||
:: NOTE
|
||||
:: The build process will generate a config.h file that is placed in BINARIES_DIR\include
|
||||
:: This file must be merged with SOURCE_DIR\include
|
||||
:: You should write yourself a script that copies the files where you want them.
|
||||
:: Also see: https://github.com/assimp/assimp/pull/2646
|
||||
|
||||
SET SOURCE_DIR=.
|
||||
|
||||
:: For generators see "cmake --help"
|
||||
SET GENERATOR=Visual Studio 15 2017
|
||||
|
||||
SET BINARIES_DIR="./BINARIES/Win32"
|
||||
cmake CMakeLists.txt -G "%GENERATOR%" -S %SOURCE_DIR% -B %BINARIES_DIR%
|
||||
cmake --build %BINARIES_DIR% --config release
|
||||
|
||||
SET BINARIES_DIR="./BINARIES/x64"
|
||||
cmake CMakeLists.txt -G "%GENERATOR% Win64" -S %SOURCE_DIR% -B %BINARIES_DIR%
|
||||
cmake --build %BINARIES_DIR% --config debug
|
||||
cmake --build %BINARIES_DIR% --config release
|
||||
|
||||
PAUSE
|
||||
43
Build.md
43
Build.md
@@ -1,32 +1,32 @@
|
||||
# Install CMake
|
||||
# Build Instructions
|
||||
## Install CMake
|
||||
Asset-Importer-Lib can be build for a lot of different platforms. We are using cmake to generate the build environment for these via cmake. So you have to make sure that you have a working cmake-installation on your system. You can download it at https://cmake.org/ or for linux install it via
|
||||
```
|
||||
```bash
|
||||
sudo apt-get install cmake
|
||||
```
|
||||
|
||||
# Get the source
|
||||
## Get the source
|
||||
Make sure you have a working git-installation. Open a command prompt and clone the Asset-Importer-Lib via:
|
||||
```
|
||||
```bash
|
||||
git clone https://github.com/assimp/assimp.git
|
||||
```
|
||||
|
||||
# Build instructions for Windows with Visual-Studio
|
||||
## Build instructions for Windows with Visual-Studio
|
||||
|
||||
First you have to install Visual-Studio on your windows-system. You can get the Community-Version for free here: https://visualstudio.microsoft.com/de/downloads/
|
||||
To generate the build environment for your IDE open a command prompt, navigate to your repo and type:
|
||||
```
|
||||
> cmake CMakeLists.txt
|
||||
```bash
|
||||
cmake CMakeLists.txt
|
||||
```
|
||||
This will generate the project files for the visual studio. All dependencies used to build Asset-IMporter-Lib shall be part of the repo. If you want to use you own zlib.installation this is possible as well. Check the options for it.
|
||||
|
||||
# Build instructions for Windows with UWP
|
||||
See https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app
|
||||
## Build instructions for Windows with UWP
|
||||
See <https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app>
|
||||
|
||||
|
||||
# Build instrcutions for Linux / Unix
|
||||
## Build instructions for Linux / Unix
|
||||
Open a terminal and got to your repository. You can generate the makefiles and build the library via:
|
||||
|
||||
```
|
||||
```bash
|
||||
cmake CMakeLists.txt
|
||||
make -j4
|
||||
```
|
||||
@@ -34,7 +34,23 @@ The option -j descripes the number of parallel processes for the build. In this
|
||||
|
||||
If you want to use a IDE for linux you can try QTCreator for instance.
|
||||
|
||||
# CMake build options
|
||||
## Build instructions for MinGW
|
||||
Older versions of MinGW's compiler (e.g. 5.1.0) do not support the -mbig_obj flag
|
||||
required to compile some of assimp's files, especially for debug builds.
|
||||
Version 7.3.0 of g++-mingw-w64 & gcc-mingw-w64 appears to work.
|
||||
|
||||
Please see [CMake Cross Compiling](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling) for general information on CMake Toolchains.
|
||||
|
||||
Some users have had success building assimp using MinGW on Linux using [polly](https://github.com/ruslo/polly/).
|
||||
|
||||
The following toolchain, which is not maintained by assimp, seems to work on Linux: [linux-mingw-w64-gnuxx11.cmake](https://github.com/ruslo/polly/blob/master/linux-mingw-w64-gnuxx11.cmake)
|
||||
|
||||
The following toolchain may or may not be helpful for building assimp using MinGW on Windows (untested):
|
||||
[mingw-cxx17.cmake](https://github.com/ruslo/polly/blob/master/mingw-cxx17.cmake)
|
||||
|
||||
Besides the toolchain, compilation should be the same as for Linux / Unix.
|
||||
|
||||
## CMake build options
|
||||
The cmake-build-environment provides options to configure the build. The following options can be used:
|
||||
- **BUILD_SHARED_LIBS ( default ON )**: Generation of shared libs ( dll for windows, so for Linux ). Set this to OFF to get a static lib.
|
||||
- **BUILD_FRAMEWORK ( default OFF, MacOnly)**: Build package as Mac OS X Framework bundle
|
||||
@@ -55,4 +71,3 @@ The cmake-build-environment provides options to configure the build. The followi
|
||||
- **INJECT_DEBUG_POSTFIX( default ON )**: Inject debug postfix in .a/.so lib names
|
||||
- **IGNORE_GIT_HASH ( default OFF )**: Don't call git to get the hash.
|
||||
- **ASSIMP_INSTALL_PDB ( default ON )**: Install MSVC debug files.
|
||||
|
||||
|
||||
282
CMakeLists.txt
282
CMakeLists.txt
@@ -1,7 +1,7 @@
|
||||
# Open Asset Import Library (assimp)
|
||||
# ----------------------------------------------------------------------
|
||||
# Copyright (c) 2006-2019, assimp team
|
||||
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this software in source and binary forms,
|
||||
@@ -34,9 +34,24 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#----------------------------------------------------------------------
|
||||
SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
|
||||
PROJECT( Assimp )
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )
|
||||
|
||||
# Toggles the use of the hunter package manager
|
||||
option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
|
||||
|
||||
include("cmake/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/ruslo/hunter/archive/v0.23.176.tar.gz"
|
||||
SHA1 "2e9ae973d028660b735ac4c6142725ca36a0048a"
|
||||
)
|
||||
|
||||
IF(HUNTER_ENABLED)
|
||||
add_definitions(-DASSIMP_USE_HUNTER)
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
PROJECT( Assimp VERSION 5.0.0 )
|
||||
|
||||
# All supported options ###############################################
|
||||
|
||||
@@ -106,7 +121,7 @@ OPTION ( BUILD_DOCS
|
||||
OFF
|
||||
)
|
||||
OPTION( INJECT_DEBUG_POSTFIX
|
||||
"Inject debug postfix in .a/.so lib names"
|
||||
"Inject debug postfix in .a/.so/.dll lib names"
|
||||
ON
|
||||
)
|
||||
|
||||
@@ -115,24 +130,27 @@ OPTION ( IGNORE_GIT_HASH
|
||||
OFF
|
||||
)
|
||||
|
||||
IF (IOS)
|
||||
IF (IOS AND NOT HUNTER_ENABLED)
|
||||
IF (NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
ENDIF (NOT CMAKE_BUILD_TYPE)
|
||||
ADD_DEFINITIONS(-DENABLE_BITCODE)
|
||||
ENDIF (IOS)
|
||||
ENDIF (IOS AND NOT HUNTER_ENABLED)
|
||||
|
||||
# Use subset of Windows.h
|
||||
if (WIN32)
|
||||
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
|
||||
endif()
|
||||
|
||||
|
||||
IF(MSVC)
|
||||
OPTION( ASSIMP_INSTALL_PDB
|
||||
"Install MSVC debug files."
|
||||
ON
|
||||
)
|
||||
IF(NOT (MSVC_VERSION LESS 1900))
|
||||
# Multibyte character set is deprecated since at least MSVC2015 (possibly earlier)
|
||||
ADD_DEFINITIONS( -DUNICODE -D_UNICODE )
|
||||
ENDIF()
|
||||
ENDIF(MSVC)
|
||||
|
||||
IF (BUILD_FRAMEWORK)
|
||||
@@ -148,17 +166,17 @@ ELSE()
|
||||
ENDIF(NOT BUILD_SHARED_LIBS)
|
||||
|
||||
# Define here the needed parameters
|
||||
SET (ASSIMP_VERSION_MAJOR 4)
|
||||
SET (ASSIMP_VERSION_MINOR 1)
|
||||
SET (ASSIMP_VERSION_PATCH 0)
|
||||
SET (ASSIMP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
SET (ASSIMP_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
SET (ASSIMP_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
SET (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH})
|
||||
SET (ASSIMP_SOVERSION 4)
|
||||
SET (PROJECT_VERSION "${ASSIMP_VERSION}")
|
||||
SET (ASSIMP_SOVERSION 5)
|
||||
|
||||
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
|
||||
|
||||
# Enable C++11 support globally
|
||||
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
||||
if(NOT HUNTER_ENABLED)
|
||||
# Enable C++11 support globally
|
||||
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
||||
endif()
|
||||
|
||||
IF(NOT IGNORE_GIT_HASH)
|
||||
# Get the current working branch
|
||||
@@ -200,6 +218,7 @@ CONFIGURE_FILE(
|
||||
|
||||
INCLUDE_DIRECTORIES( BEFORE
|
||||
./
|
||||
code/
|
||||
include
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
@@ -218,9 +237,13 @@ ENDIF( UNIX )
|
||||
|
||||
# Grouped compiler settings
|
||||
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
||||
IF(NOT HUNTER_ENABLED)
|
||||
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++0x ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
||||
ENDIF()
|
||||
# hide all not-exported symbols
|
||||
SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fPIC -fno-strict-aliasing -Wall -std=c++0x ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fPIC -fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
SET(LIBSTDC++_LIBRARIES -lstdc++)
|
||||
ELSEIF(MSVC)
|
||||
# enable multi-core compilation with MSVC
|
||||
@@ -230,26 +253,39 @@ ELSEIF(MSVC)
|
||||
IF(MSVC12)
|
||||
ADD_COMPILE_OPTIONS(/wd4351)
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Ob2 /DEBUG:FULL /Zi")
|
||||
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
||||
SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fPIC -fno-strict-aliasing -Wall -Wno-long-long -std=c++11 ${CMAKE_CXX_FLAGS}" )
|
||||
SET(CMAKE_C_FLAGS "-fPIC -fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
IF(NOT HUNTER_ENABLED)
|
||||
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
|
||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
ELSEIF( CMAKE_COMPILER_IS_MINGW )
|
||||
SET( CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -std=c++11 -Wa,-mbig-obj ${CMAKE_CXX_FLAGS}" )
|
||||
SET(CMAKE_C_FLAGS "-fPIC -fno-strict-aliasing ${CMAKE_C_FLAGS} ")
|
||||
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
|
||||
message(FATAL_ERROR "MinGW is too old to be supported. Please update MinGW and try again.")
|
||||
ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
|
||||
message(WARNING "MinGW is old, if you experience errors, update MinGW.")
|
||||
ENDIF()
|
||||
IF(NOT HUNTER_ENABLED)
|
||||
SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -O3 ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
ADD_DEFINITIONS( -U__STRICT_ANSI__ )
|
||||
ENDIF()
|
||||
|
||||
IF ( IOS )
|
||||
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -Og")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -Og")
|
||||
ELSE()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -O3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -O3")
|
||||
ENDIF()
|
||||
|
||||
ENDIF( IOS )
|
||||
IF ( IOS AND NOT HUNTER_ENABLED)
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -Og")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -Og")
|
||||
ELSE()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -O3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -O3")
|
||||
# Experimental for pdb generation
|
||||
ENDIF()
|
||||
ENDIF( IOS AND NOT HUNTER_ENABLED)
|
||||
|
||||
IF (ASSIMP_COVERALLS)
|
||||
MESSAGE(STATUS "Coveralls enabled")
|
||||
@@ -301,7 +337,9 @@ SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
|
||||
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
|
||||
"Path the tool executables are installed to." )
|
||||
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
|
||||
|
||||
IF (INJECT_DEBUG_POSTFIX AND (is_multi_config OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfix for lib, samples and tools")
|
||||
ELSE()
|
||||
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Debug Postfix for lib, samples and tools")
|
||||
@@ -314,20 +352,67 @@ IF (NOT TARGET uninstall)
|
||||
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
ENDIF()
|
||||
|
||||
# cmake configuration files
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-debug.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-release.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
|
||||
#we should generated these scripts after CMake VERSION 3.0.2 using export(EXPORT ...) and write_basic_package_version_file(...)
|
||||
INSTALL(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake"
|
||||
DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||
IF(HUNTER_ENABLED)
|
||||
set(CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
|
||||
set(INCLUDE_INSTALL_DIR "include")
|
||||
|
||||
set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
|
||||
# Configuration
|
||||
set(VERSION_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(PROJECT_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}Config.cmake")
|
||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||
set(NAMESPACE "${PROJECT_NAME}::")
|
||||
|
||||
# Include module with fuction 'write_basic_package_version_file'
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Note: PROJECT_VERSION is used as a VERSION
|
||||
write_basic_package_version_file("${VERSION_CONFIG}" COMPATIBILITY SameMajorVersion)
|
||||
|
||||
# Use variables:
|
||||
# * TARGETS_EXPORT_NAME
|
||||
# * PROJECT_NAME
|
||||
configure_package_config_file(
|
||||
"cmake/assimp-hunter-config.cmake.in"
|
||||
"${PROJECT_CONFIG}"
|
||||
INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${PROJECT_CONFIG}" "${VERSION_CONFIG}"
|
||||
DESTINATION "${CONFIG_INSTALL_DIR}"
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
NAMESPACE "${NAMESPACE}"
|
||||
DESTINATION "${CONFIG_INSTALL_DIR}"
|
||||
)
|
||||
ELSE(HUNTER_ENABLED)
|
||||
# cmake configuration files
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE)
|
||||
IF (is_multi_config)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-debug.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-release.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake" @ONLY IMMEDIATE)
|
||||
SET(PACKAGE_TARGETS_FILE "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake")
|
||||
ELSEIF (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-debug.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake" @ONLY IMMEDIATE)
|
||||
SET(PACKAGE_TARGETS_FILE "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-debug.cmake")
|
||||
ELSE()
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets-release.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake" @ONLY IMMEDIATE)
|
||||
SET(PACKAGE_TARGETS_FILE "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets-release.cmake")
|
||||
ENDIF()
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
|
||||
#we should generated these scripts after CMake VERSION 3.0.2 using export(EXPORT ...) and write_basic_package_version_file(...)
|
||||
INSTALL(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake"
|
||||
${PACKAGE_TARGETS_FILE}
|
||||
DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
FIND_PACKAGE( DirectX )
|
||||
|
||||
@@ -342,39 +427,57 @@ ENDIF( SYSTEM_IRRXML )
|
||||
|
||||
# Search for external dependencies, and build them from source if not found
|
||||
# Search for zlib
|
||||
IF ( NOT ASSIMP_BUILD_ZLIB )
|
||||
FIND_PACKAGE(ZLIB)
|
||||
ENDIF( NOT ASSIMP_BUILD_ZLIB )
|
||||
IF(HUNTER_ENABLED)
|
||||
hunter_add_package(ZLIB)
|
||||
find_package(ZLIB CONFIG REQUIRED)
|
||||
|
||||
IF( NOT ZLIB_FOUND )
|
||||
MESSAGE(STATUS "compiling zlib from sources")
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckTypeSize)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
# compile from sources
|
||||
ADD_SUBDIRECTORY(contrib/zlib)
|
||||
SET(ZLIB_FOUND 1)
|
||||
SET(ZLIB_LIBRARIES zlibstatic)
|
||||
SET(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zlib ${CMAKE_CURRENT_BINARY_DIR}/contrib/zlib)
|
||||
# need to ensure we don't link with system zlib or minizip as well.
|
||||
SET(ASSIMP_BUILD_MINIZIP 1)
|
||||
ELSE(NOT ZLIB_FOUND)
|
||||
ADD_DEFINITIONS(-DASSIMP_BUILD_NO_OWN_ZLIB)
|
||||
SET(ZLIB_LIBRARIES_LINKED -lz)
|
||||
ENDIF(NOT ZLIB_FOUND)
|
||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
||||
add_definitions(-DASSIMP_BUILD_NO_OWN_ZLIB)
|
||||
set(ZLIB_FOUND TRUE)
|
||||
set(ZLIB_LIBRARIES ZLIB::zlib)
|
||||
set(ASSIMP_BUILD_MINIZIP TRUE)
|
||||
ELSE(HUNTER_ENABLED)
|
||||
IF ( NOT ASSIMP_BUILD_ZLIB )
|
||||
FIND_PACKAGE(ZLIB)
|
||||
ENDIF( NOT ASSIMP_BUILD_ZLIB )
|
||||
|
||||
# Search for unzip
|
||||
IF ( NOT IOS )
|
||||
IF( NOT ZLIB_FOUND )
|
||||
MESSAGE(STATUS "compiling zlib from sources")
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckTypeSize)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
|
||||
# Explicitly turn off ASM686 and AMD64 cmake options.
|
||||
# The AMD64 option causes a build failure on MSVC and the ASM builds seem to have problems:
|
||||
# https://github.com/madler/zlib/issues/41#issuecomment-125848075
|
||||
# Also prevents these options from "polluting" the cmake options if assimp is being
|
||||
# included as a submodule.
|
||||
set( ASM686 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE )
|
||||
set( AMD64 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE )
|
||||
|
||||
# compile from sources
|
||||
ADD_SUBDIRECTORY(contrib/zlib)
|
||||
SET(ZLIB_FOUND 1)
|
||||
SET(ZLIB_LIBRARIES zlibstatic)
|
||||
SET(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zlib ${CMAKE_CURRENT_BINARY_DIR}/contrib/zlib)
|
||||
# need to ensure we don't link with system zlib or minizip as well.
|
||||
SET(ASSIMP_BUILD_MINIZIP 1)
|
||||
ELSE(NOT ZLIB_FOUND)
|
||||
ADD_DEFINITIONS(-DASSIMP_BUILD_NO_OWN_ZLIB)
|
||||
SET(ZLIB_LIBRARIES_LINKED -lz)
|
||||
ENDIF(NOT ZLIB_FOUND)
|
||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
||||
ENDIF(HUNTER_ENABLED)
|
||||
|
||||
IF( NOT IOS )
|
||||
IF( NOT ASSIMP_BUILD_MINIZIP )
|
||||
use_pkgconfig(UNZIP minizip)
|
||||
use_pkgconfig(UNZIP minizip)
|
||||
ENDIF( NOT ASSIMP_BUILD_MINIZIP )
|
||||
ELSE ( NOT IOS )
|
||||
IF(NOT BUILD_SHARED_LIBS)
|
||||
IF( NOT BUILD_SHARED_LIBS )
|
||||
IF( NOT ASSIMP_BUILD_MINIZIP )
|
||||
use_pkgconfig(UNZIP minizip)
|
||||
use_pkgconfig(UNZIP minizip)
|
||||
ENDIF( NOT ASSIMP_BUILD_MINIZIP )
|
||||
ENDIF (NOT BUILD_SHARED_LIBS)
|
||||
ENDIF ( NOT BUILD_SHARED_LIBS )
|
||||
ENDIF ( NOT IOS )
|
||||
|
||||
IF ( ASSIMP_NO_EXPORT )
|
||||
@@ -448,26 +551,27 @@ ELSE (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_C4D_IMPORTER )
|
||||
ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||
|
||||
ADD_SUBDIRECTORY(contrib)
|
||||
IF(NOT HUNTER_ENABLED)
|
||||
ADD_SUBDIRECTORY(contrib)
|
||||
ENDIF(NOT HUNTER_ENABLED)
|
||||
|
||||
ADD_SUBDIRECTORY( code/ )
|
||||
IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
|
||||
# The viewer for windows only
|
||||
IF ( WIN32 AND DirectX_D3DX9_LIBRARY )
|
||||
OPTION ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} )
|
||||
IF ( ASSIMP_BUILD_ASSIMP_VIEW )
|
||||
ADD_SUBDIRECTORY( tools/assimp_view/ )
|
||||
ENDIF ( ASSIMP_BUILD_ASSIMP_VIEW )
|
||||
ENDIF ( WIN32 AND DirectX_D3DX9_LIBRARY )
|
||||
|
||||
# Te command line tool
|
||||
ADD_SUBDIRECTORY( tools/assimp_cmd/ )
|
||||
IF (NOT IOS)
|
||||
ADD_SUBDIRECTORY( tools/assimp_qt_viewer/ )
|
||||
ENDIF (NOT IOS)
|
||||
ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS )
|
||||
|
||||
IF ( ASSIMP_BUILD_SAMPLES)
|
||||
IF ( WIN32 )
|
||||
ADD_SUBDIRECTORY( samples/SimpleTexturedOpenGL/ )
|
||||
ADD_SUBDIRECTORY( samples/SimpleTexturedDirectx11 )
|
||||
ENDIF ( WIN32 )
|
||||
ADD_SUBDIRECTORY( samples/SimpleOpenGL/ )
|
||||
ENDIF ( ASSIMP_BUILD_SAMPLES )
|
||||
@@ -533,18 +637,22 @@ if(WIN32)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
SET(BIN_DIR "${PROJECT_SOURCE_DIR}/bin64/")
|
||||
SET(LIB_DIR "${PROJECT_SOURCE_DIR}/lib64/")
|
||||
elseif()
|
||||
else()
|
||||
SET(BIN_DIR "${PROJECT_SOURCE_DIR}/bin32/")
|
||||
SET(LIB_DIR "${PROJECT_SOURCE_DIR}/lib32/")
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC12)
|
||||
SET(ASSIMP_MSVC_VERSION "vc120")
|
||||
ELSEIF(MSVC14)
|
||||
SET(ASSIMP_MSVC_VERSION "vc140")
|
||||
ELSEIF(MSVC15)
|
||||
SET(ASSIMP_MSVC_VERSION "vc141")
|
||||
ENDIF(MSVC12)
|
||||
IF(MSVC_TOOLSET_VERSION)
|
||||
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||
ELSE()
|
||||
IF(MSVC12)
|
||||
SET(ASSIMP_MSVC_VERSION "vc120")
|
||||
ELSEIF(MSVC14)
|
||||
SET(ASSIMP_MSVC_VERSION "vc140")
|
||||
ELSEIF(MSVC15)
|
||||
SET(ASSIMP_MSVC_VERSION "vc141")
|
||||
ENDIF(MSVC12)
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC12 OR MSVC14 OR MSVC15 )
|
||||
ADD_CUSTOM_TARGET(UpdateAssimpLibsDebugSymbolsAndDLLs COMMENT "Copying Assimp Libraries ..." VERBATIM)
|
||||
|
||||
11
INSTALL
11
INSTALL
@@ -35,13 +35,16 @@ http://www.cmake.org/.
|
||||
|
||||
For Unix:
|
||||
|
||||
1. cmake CMakeLists.txt -G 'Unix Makefiles'
|
||||
2. make
|
||||
1. mkdir build && cd build
|
||||
2. cmake .. -G 'Unix Makefiles'
|
||||
3. make -j4
|
||||
|
||||
For Windows:
|
||||
1. Open a command prompt
|
||||
2. cmake CMakeLists.txt
|
||||
2. Open your default IDE and build it
|
||||
2. mkdir build
|
||||
3. cd build
|
||||
4. cmake ..
|
||||
5. cmake --build .
|
||||
|
||||
For iOS:
|
||||
Just check the following project, which deploys a compiler toolchain for different iOS-versions: https://github.com/assimp/assimp/tree/master/port/iOS
|
||||
|
||||
14
Readme.md
14
Readme.md
@@ -17,6 +17,8 @@ A library to import and export various 3d-model-formats including scene-post-pro
|
||||
|
||||
APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS.
|
||||
|
||||
[Check the latest doc](https://assimp-docs.readthedocs.io/en/latest/).
|
||||
|
||||
Additionally, assimp features various __mesh post processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more.
|
||||
|
||||
This is the development repo containing the latest features and bugfixes. For productive use though, we recommend one of the stable releases available from [Github Assimp Releases](https://github.com/assimp/assimp/releases).
|
||||
@@ -99,7 +101,7 @@ __Importers__:
|
||||
|
||||
Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default):
|
||||
|
||||
- [C4D](https://en.wikipedia.org/wiki/Cinema_4D) (https://github.com/assimp/assimp/wiki/Cinema4D-&-Melange)
|
||||
- [C4D](https://en.wikipedia.org/wiki/Cinema_4D) (https://github.com/assimp/assimp/wiki/Cinema4D-&-Melange) IMporting geometry + node hierarchy are currently supported
|
||||
|
||||
__Exporters__:
|
||||
|
||||
@@ -123,17 +125,18 @@ Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file.
|
||||
### Ports ###
|
||||
* [Android](port/AndroidJNI/README.md)
|
||||
* [Python](port/PyAssimp/README.md)
|
||||
* [.NET](port/AssimpNET/Readme.md)
|
||||
* [.NET](https://github.com/kebby/assimp-net)
|
||||
* [Pascal](port/AssimpPascal/Readme.md)
|
||||
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
|
||||
* [Unity 3d Plugin](https://www.assetstore.unity3d.com/en/#!/content/91777)
|
||||
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (current [status](https://github.com/kotlin-graphics/assimp/wiki/Status))
|
||||
* [HAXE-Port](https://github.com/longde123/assimp-haxe) The Assimp-HAXE-port.
|
||||
|
||||
### Other tools ###
|
||||
[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.
|
||||
|
||||
#### Repository structure ####
|
||||
Open Asset Import Library is implemented in C++. The directory structure is:
|
||||
Open Asset Import Library is implemented in C++. The directory structure looks like:
|
||||
|
||||
/code Source code
|
||||
/contrib Third-party libraries
|
||||
@@ -146,6 +149,11 @@ Open Asset Import Library is implemented in C++. The directory structure is:
|
||||
/samples A small number of samples to illustrate possible
|
||||
use cases for Assimp
|
||||
|
||||
The source code is organized in the following way:
|
||||
|
||||
code/Common The base implementation for importers and the infrastructure
|
||||
code/PostProcessing The post-processing steps
|
||||
code/<FormatName> Implementation for import and export for the format
|
||||
|
||||
### Where to get help ###
|
||||
For more information, visit [our website](http://assimp.org/). Or check out the `./doc`- folder, which contains the official documentation in HTML format.
|
||||
|
||||
20
appveyor.yml
20
appveyor.yml
@@ -14,9 +14,9 @@ matrix:
|
||||
fast_finish: true
|
||||
|
||||
image:
|
||||
- Visual Studio 2013
|
||||
# - Visual Studio 2015
|
||||
# - Visual Studio 2017
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2017
|
||||
- MinGW
|
||||
|
||||
platform:
|
||||
- Win32
|
||||
@@ -27,11 +27,13 @@ configuration: Release
|
||||
install:
|
||||
- set PATH=C:\Ruby24-x64\bin;%PATH%
|
||||
- set CMAKE_DEFINES -DASSIMP_WERROR=ON
|
||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" set CMAKE_GENERATOR_NAME=Visual Studio 12 2013
|
||||
- if [%COMPILER%]==[MinGW] set PATH=C:\MinGW\bin;%PATH%
|
||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015
|
||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017
|
||||
- if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=%CMAKE_GENERATOR_NAME% Win64
|
||||
- cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%"
|
||||
- cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" .
|
||||
# Rename sh.exe as sh.exe in PATH interferes with MinGW
|
||||
- rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
|
||||
- set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 5"
|
||||
- ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/5/7/b/57b2947c-7221-4f33-b35e-2fc78cb10df4/vc_redist.x64.exe -OutFile .\packaging\windows-innosetup\vc_redist.x64.exe
|
||||
- ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/1/d/8/1d8137db-b5bb-4925-8c5d-927424a2e4de/vc_redist.x86.exe -OutFile .\packaging\windows-innosetup\vc_redist.x86.exe
|
||||
@@ -53,7 +55,13 @@ build:
|
||||
project: Assimp.sln
|
||||
|
||||
after_build:
|
||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" iscc packaging\windows-innosetup\script.iss
|
||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (
|
||||
if "%platform%"=="x64" (
|
||||
iscc packaging\windows-innosetup\script_x64.iss
|
||||
) else (
|
||||
iscc packaging\windows-innosetup\script_x86.iss
|
||||
)
|
||||
)
|
||||
- 7z a assimp.7z bin\%CONFIGURATION%\* lib\%CONFIGURATION%\*
|
||||
|
||||
test_script:
|
||||
|
||||
@@ -5,48 +5,79 @@
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
||||
|
||||
if(MSVC)
|
||||
if( MSVC70 OR MSVC71 )
|
||||
set(MSVC_PREFIX "vc70")
|
||||
elseif( MSVC80 )
|
||||
set(MSVC_PREFIX "vc80")
|
||||
elseif( MSVC90 )
|
||||
set(MSVC_PREFIX "vc90")
|
||||
elseif( MSVC10 )
|
||||
set(MSVC_PREFIX "vc100")
|
||||
elseif( MSVC11 )
|
||||
set(MSVC_PREFIX "vc110")
|
||||
elseif( MSVC12 )
|
||||
set(MSVC_PREFIX "vc120")
|
||||
elseif( MSVC14 )
|
||||
set(MSVC_PREFIX "vc140")
|
||||
if(MSVC_TOOLSET_VERSION)
|
||||
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||
else()
|
||||
set(MSVC_PREFIX "vc150")
|
||||
if( MSVC70 OR MSVC71 )
|
||||
set(MSVC_PREFIX "vc70")
|
||||
elseif( MSVC80 )
|
||||
set(MSVC_PREFIX "vc80")
|
||||
elseif( MSVC90 )
|
||||
set(MSVC_PREFIX "vc90")
|
||||
elseif( MSVC10 )
|
||||
set(MSVC_PREFIX "vc100")
|
||||
elseif( MSVC11 )
|
||||
set(MSVC_PREFIX "vc110")
|
||||
elseif( MSVC12 )
|
||||
set(MSVC_PREFIX "vc120")
|
||||
elseif( MSVC_VERSION LESS 1910)
|
||||
set(MSVC_PREFIX "vc140")
|
||||
elseif( MSVC_VERSION LESS 1920)
|
||||
set(MSVC_PREFIX "vc141")
|
||||
elseif( MSVC_VERSION LESS 1930)
|
||||
set(MSVC_PREFIX "vc142")
|
||||
else()
|
||||
set(MSVC_PREFIX "vc150")
|
||||
endif()
|
||||
endif()
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" )
|
||||
|
||||
set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||
set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_IMPORT_LIBRARY_SUFFIX@")
|
||||
if(ASSIMP_BUILD_SHARED_LIBS)
|
||||
set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||
set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_IMPORT_LIBRARY_SUFFIX@")
|
||||
|
||||
# Import target "assimp::assimp" for configuration "Debug"
|
||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}"
|
||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}")
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
|
||||
# Import target "assimp::assimp" for configuration "Debug"
|
||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}"
|
||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}")
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
|
||||
else()
|
||||
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||
|
||||
# Import target "assimp::assimp" for configuration "Debug"
|
||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}")
|
||||
endif()
|
||||
|
||||
else()
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" )
|
||||
set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@")
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_SONAME_DEBUG "${sharedLibraryName}"
|
||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the assimp libraries" )
|
||||
if(ASSIMP_BUILD_SHARED_LIBS)
|
||||
set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@")
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_SONAME_DEBUG "${sharedLibraryName}"
|
||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
|
||||
else()
|
||||
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -60,7 +91,11 @@ set( ASSIMP_CXX_FLAGS ) # dynamically linked library
|
||||
set( ASSIMP_LINK_FLAGS "" )
|
||||
set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@")
|
||||
set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@")
|
||||
set( ASSIMP_LIBRARIES ${sharedLibraryName})
|
||||
if(ASSIMP_BUILD_SHARED_LIBS)
|
||||
set( ASSIMP_LIBRARIES ${sharedLibraryName})
|
||||
else()
|
||||
set( ASSIMP_LIBRARIES ${staticLibraryName})
|
||||
endif()
|
||||
|
||||
# for compatibility with pkg-config
|
||||
set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}")
|
||||
@@ -75,4 +110,5 @@ MARK_AS_ADVANCED(
|
||||
ASSIMP_CFLAGS_OTHER
|
||||
ASSIMP_LDFLAGS_OTHER
|
||||
ASSIMP_LIBRARY_SUFFIX
|
||||
ASSIMP_BUILD_SHARED_LIBS
|
||||
)
|
||||
|
||||
@@ -5,59 +5,95 @@
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
||||
|
||||
if(MSVC)
|
||||
if( MSVC70 OR MSVC71 )
|
||||
set(MSVC_PREFIX "vc70")
|
||||
elseif( MSVC80 )
|
||||
set(MSVC_PREFIX "vc80")
|
||||
elseif( MSVC90 )
|
||||
set(MSVC_PREFIX "vc90")
|
||||
elseif( MSVC10 )
|
||||
set(MSVC_PREFIX "vc100")
|
||||
elseif( MSVC11 )
|
||||
set(MSVC_PREFIX "vc110")
|
||||
elseif( MSVC12 )
|
||||
set(MSVC_PREFIX "vc120")
|
||||
elseif( MSVC14 )
|
||||
set(MSVC_PREFIX "vc140")
|
||||
if(MSVC_TOOLSET_VERSION)
|
||||
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||
else()
|
||||
set(MSVC_PREFIX "vc150")
|
||||
if( MSVC70 OR MSVC71 )
|
||||
set(MSVC_PREFIX "vc70")
|
||||
elseif( MSVC80 )
|
||||
set(MSVC_PREFIX "vc80")
|
||||
elseif( MSVC90 )
|
||||
set(MSVC_PREFIX "vc90")
|
||||
elseif( MSVC10 )
|
||||
set(MSVC_PREFIX "vc100")
|
||||
elseif( MSVC11 )
|
||||
set(MSVC_PREFIX "vc110")
|
||||
elseif( MSVC12 )
|
||||
set(MSVC_PREFIX "vc120")
|
||||
elseif( MSVC_VERSION LESS 1910)
|
||||
set(MSVC_PREFIX "vc140")
|
||||
elseif( MSVC_VERSION LESS 1920)
|
||||
set(MSVC_PREFIX "vc141")
|
||||
elseif( MSVC_VERSION LESS 1930)
|
||||
set(MSVC_PREFIX "vc142")
|
||||
else()
|
||||
set(MSVC_PREFIX "vc150")
|
||||
endif()
|
||||
endif()
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" )
|
||||
|
||||
set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||
set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_IMPORT_LIBRARY_SUFFIX@")
|
||||
if(ASSIMP_BUILD_SHARED_LIBS)
|
||||
set(sharedLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||
set(importLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_IMPORT_LIBRARY_SUFFIX@")
|
||||
|
||||
# Import target "assimp::assimp" for configuration "Release"
|
||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
|
||||
# Import target "assimp::assimp" for configuration "Release"
|
||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}")
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}")
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" )
|
||||
else()
|
||||
set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||
|
||||
# Import target "assimp::assimp" for configuration "Release"
|
||||
set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}")
|
||||
endif()
|
||||
|
||||
else()
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the openrave libraries" )
|
||||
set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@")
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_SONAME_RELEASE "${sharedLibraryName}"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
|
||||
set(ASSIMP_LIBRARY_SUFFIX "@ASSIMP_LIBRARY_SUFFIX@" CACHE STRING "the suffix for the assimp libraries" )
|
||||
if(ASSIMP_BUILD_SHARED_LIBS)
|
||||
set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@")
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_SONAME_RELEASE "${sharedLibraryName}"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${sharedLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" )
|
||||
else()
|
||||
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}"
|
||||
)
|
||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
||||
|
||||
get_filename_component(ASSIMP_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" REALPATH)
|
||||
|
||||
set( ASSIMP_CXX_FLAGS ) # dynamically linked library
|
||||
set( ASSIMP_LINK_FLAGS "" )
|
||||
set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@")
|
||||
set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@")
|
||||
set( ASSIMP_LIBRARIES ${sharedLibraryName})
|
||||
if(ASSIMP_BUILD_SHARED_LIBS)
|
||||
set( ASSIMP_LIBRARIES ${sharedLibraryName})
|
||||
else()
|
||||
set( ASSIMP_LIBRARIES ${staticLibraryName})
|
||||
endif()
|
||||
|
||||
# for compatibility with pkg-config
|
||||
set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}")
|
||||
@@ -72,4 +108,5 @@ MARK_AS_ADVANCED(
|
||||
ASSIMP_CFLAGS_OTHER
|
||||
ASSIMP_LDFLAGS_OTHER
|
||||
ASSIMP_LIBRARY_SUFFIX
|
||||
ASSIMP_BUILD_SHARED_LIBS
|
||||
)
|
||||
|
||||
@@ -51,7 +51,11 @@ if(_IMPORT_PREFIX STREQUAL "/")
|
||||
endif()
|
||||
|
||||
# Create imported target assimp::assimp
|
||||
add_library(assimp::assimp SHARED IMPORTED)
|
||||
if(@BUILD_SHARED_LIBS@)
|
||||
add_library(assimp::assimp SHARED IMPORTED)
|
||||
else()
|
||||
add_library(assimp::assimp STATIC IMPORTED)
|
||||
endif()
|
||||
|
||||
set_target_properties(assimp::assimp PROPERTIES
|
||||
COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION"
|
||||
|
||||
540
cmake/HunterGate.cmake
Normal file
540
cmake/HunterGate.cmake
Normal file
@@ -0,0 +1,540 @@
|
||||
# Copyright (c) 2013-2018, Ruslan Baratov
|
||||
# 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.
|
||||
#
|
||||
# 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 HOLDER 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.
|
||||
|
||||
# This is a gate file to Hunter package manager.
|
||||
# Include this file using `include` command and add package you need, example:
|
||||
#
|
||||
# cmake_minimum_required(VERSION 3.2)
|
||||
#
|
||||
# include("cmake/HunterGate.cmake")
|
||||
# HunterGate(
|
||||
# URL "https://github.com/path/to/hunter/archive.tar.gz"
|
||||
# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d"
|
||||
# )
|
||||
#
|
||||
# project(MyProject)
|
||||
#
|
||||
# hunter_add_package(Foo)
|
||||
# hunter_add_package(Boo COMPONENTS Bar Baz)
|
||||
#
|
||||
# Projects:
|
||||
# * https://github.com/hunter-packages/gate/
|
||||
# * https://github.com/ruslo/hunter
|
||||
|
||||
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
|
||||
|
||||
if(HUNTER_ENABLED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.2")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"At least CMake version 3.2 required for Hunter dependency management."
|
||||
" Update CMake or set HUNTER_ENABLED to OFF."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(CMakeParseArguments) # cmake_parse_arguments
|
||||
|
||||
option(HUNTER_STATUS_PRINT "Print working status" ON)
|
||||
option(HUNTER_STATUS_DEBUG "Print a lot info" OFF)
|
||||
option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON)
|
||||
|
||||
set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki")
|
||||
|
||||
function(hunter_gate_status_print)
|
||||
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
|
||||
foreach(print_message ${ARGV})
|
||||
message(STATUS "[hunter] ${print_message}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_status_debug)
|
||||
if(HUNTER_STATUS_DEBUG)
|
||||
foreach(print_message ${ARGV})
|
||||
string(TIMESTAMP timestamp)
|
||||
message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_wiki wiki_page)
|
||||
message("------------------------------ WIKI -------------------------------")
|
||||
message(" ${HUNTER_WIKI}/${wiki_page}")
|
||||
message("-------------------------------------------------------------------")
|
||||
message("")
|
||||
message(FATAL_ERROR "")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_internal_error)
|
||||
message("")
|
||||
foreach(print_message ${ARGV})
|
||||
message("[hunter ** INTERNAL **] ${print_message}")
|
||||
endforeach()
|
||||
message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
|
||||
message("")
|
||||
hunter_gate_wiki("error.internal")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_fatal_error)
|
||||
cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}")
|
||||
string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki)
|
||||
if(have_no_wiki)
|
||||
hunter_gate_internal_error("Expected wiki")
|
||||
endif()
|
||||
message("")
|
||||
foreach(x ${hunter_UNPARSED_ARGUMENTS})
|
||||
message("[hunter ** FATAL ERROR **] ${x}")
|
||||
endforeach()
|
||||
message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
|
||||
message("")
|
||||
hunter_gate_wiki("${hunter_WIKI}")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_user_error)
|
||||
hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_self root version sha1 result)
|
||||
string(COMPARE EQUAL "${root}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("root is empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${version}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("version is empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${sha1}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("sha1 is empty")
|
||||
endif()
|
||||
|
||||
string(SUBSTRING "${sha1}" 0 7 archive_id)
|
||||
|
||||
if(EXISTS "${root}/cmake/Hunter")
|
||||
set(hunter_self "${root}")
|
||||
else()
|
||||
set(
|
||||
hunter_self
|
||||
"${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked"
|
||||
)
|
||||
endif()
|
||||
|
||||
set("${result}" "${hunter_self}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Set HUNTER_GATE_ROOT cmake variable to suitable value.
|
||||
function(hunter_gate_detect_root)
|
||||
# Check CMake variable
|
||||
string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty)
|
||||
if(not_empty)
|
||||
set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check environment variable
|
||||
string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty)
|
||||
if(not_empty)
|
||||
set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT detected by environment variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check HOME environment variable
|
||||
string(COMPARE NOTEQUAL "$ENV{HOME}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check SYSTEMDRIVE and USERPROFILE environment variable (windows only)
|
||||
if(WIN32)
|
||||
string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug(
|
||||
"HUNTER_ROOT set using SYSTEMDRIVE environment variable"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug(
|
||||
"HUNTER_ROOT set using USERPROFILE environment variable"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
hunter_gate_fatal_error(
|
||||
"Can't detect HUNTER_ROOT"
|
||||
WIKI "error.detect.hunter.root"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_download dir)
|
||||
string(
|
||||
COMPARE
|
||||
NOTEQUAL
|
||||
"$ENV{HUNTER_DISABLE_AUTOINSTALL}"
|
||||
""
|
||||
disable_autoinstall
|
||||
)
|
||||
if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL)
|
||||
hunter_gate_fatal_error(
|
||||
"Hunter not found in '${dir}'"
|
||||
"Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'"
|
||||
"Settings:"
|
||||
" HUNTER_ROOT: ${HUNTER_GATE_ROOT}"
|
||||
" HUNTER_SHA1: ${HUNTER_GATE_SHA1}"
|
||||
WIKI "error.run.install"
|
||||
)
|
||||
endif()
|
||||
string(COMPARE EQUAL "${dir}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("Empty 'dir' argument")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("HUNTER_GATE_SHA1 empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("HUNTER_GATE_URL empty")
|
||||
endif()
|
||||
|
||||
set(done_location "${dir}/DONE")
|
||||
set(sha1_location "${dir}/SHA1")
|
||||
|
||||
set(build_dir "${dir}/Build")
|
||||
set(cmakelists "${dir}/CMakeLists.txt")
|
||||
|
||||
hunter_gate_status_debug("Locking directory: ${dir}")
|
||||
file(LOCK "${dir}" DIRECTORY GUARD FUNCTION)
|
||||
hunter_gate_status_debug("Lock done")
|
||||
|
||||
if(EXISTS "${done_location}")
|
||||
# while waiting for lock other instance can do all the job
|
||||
hunter_gate_status_debug("File '${done_location}' found, skip install")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE "${build_dir}")
|
||||
file(REMOVE_RECURSE "${cmakelists}")
|
||||
|
||||
file(MAKE_DIRECTORY "${build_dir}") # check directory permissions
|
||||
|
||||
# Disabling languages speeds up a little bit, reduces noise in the output
|
||||
# and avoids path too long windows error
|
||||
file(
|
||||
WRITE
|
||||
"${cmakelists}"
|
||||
"cmake_minimum_required(VERSION 3.2)\n"
|
||||
"project(HunterDownload LANGUAGES NONE)\n"
|
||||
"include(ExternalProject)\n"
|
||||
"ExternalProject_Add(\n"
|
||||
" Hunter\n"
|
||||
" URL\n"
|
||||
" \"${HUNTER_GATE_URL}\"\n"
|
||||
" URL_HASH\n"
|
||||
" SHA1=${HUNTER_GATE_SHA1}\n"
|
||||
" DOWNLOAD_DIR\n"
|
||||
" \"${dir}\"\n"
|
||||
" TLS_VERIFY\n"
|
||||
" ${HUNTER_TLS_VERIFY}\n"
|
||||
" SOURCE_DIR\n"
|
||||
" \"${dir}/Unpacked\"\n"
|
||||
" CONFIGURE_COMMAND\n"
|
||||
" \"\"\n"
|
||||
" BUILD_COMMAND\n"
|
||||
" \"\"\n"
|
||||
" INSTALL_COMMAND\n"
|
||||
" \"\"\n"
|
||||
")\n"
|
||||
)
|
||||
|
||||
if(HUNTER_STATUS_DEBUG)
|
||||
set(logging_params "")
|
||||
else()
|
||||
set(logging_params OUTPUT_QUIET)
|
||||
endif()
|
||||
|
||||
hunter_gate_status_debug("Run generate")
|
||||
|
||||
# Need to add toolchain file too.
|
||||
# Otherwise on Visual Studio + MDD this will fail with error:
|
||||
# "Could not find an appropriate version of the Windows 10 SDK installed on this machine"
|
||||
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE)
|
||||
set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}")
|
||||
else()
|
||||
# 'toolchain_arg' can't be empty
|
||||
set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make)
|
||||
if(no_make)
|
||||
set(make_arg "")
|
||||
else()
|
||||
# Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM
|
||||
set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
"-H${dir}"
|
||||
"-B${build_dir}"
|
||||
"-G${CMAKE_GENERATOR}"
|
||||
"${toolchain_arg}"
|
||||
${make_arg}
|
||||
WORKING_DIRECTORY "${dir}"
|
||||
RESULT_VARIABLE download_result
|
||||
${logging_params}
|
||||
)
|
||||
|
||||
if(NOT download_result EQUAL 0)
|
||||
hunter_gate_internal_error(
|
||||
"Configure project failed."
|
||||
"To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}"
|
||||
"In directory ${dir}"
|
||||
)
|
||||
endif()
|
||||
|
||||
hunter_gate_status_print(
|
||||
"Initializing Hunter workspace (${HUNTER_GATE_SHA1})"
|
||||
" ${HUNTER_GATE_URL}"
|
||||
" -> ${dir}"
|
||||
)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" --build "${build_dir}"
|
||||
WORKING_DIRECTORY "${dir}"
|
||||
RESULT_VARIABLE download_result
|
||||
${logging_params}
|
||||
)
|
||||
|
||||
if(NOT download_result EQUAL 0)
|
||||
hunter_gate_internal_error("Build project failed")
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE "${build_dir}")
|
||||
file(REMOVE_RECURSE "${cmakelists}")
|
||||
|
||||
file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}")
|
||||
file(WRITE "${done_location}" "DONE")
|
||||
|
||||
hunter_gate_status_debug("Finished")
|
||||
endfunction()
|
||||
|
||||
# Must be a macro so master file 'cmake/Hunter' can
|
||||
# apply all variables easily just by 'include' command
|
||||
# (otherwise PARENT_SCOPE magic needed)
|
||||
macro(HunterGate)
|
||||
if(HUNTER_GATE_DONE)
|
||||
# variable HUNTER_GATE_DONE set explicitly for external project
|
||||
# (see `hunter_download`)
|
||||
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
|
||||
endif()
|
||||
|
||||
# First HunterGate command will init Hunter, others will be ignored
|
||||
get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET)
|
||||
|
||||
if(NOT HUNTER_ENABLED)
|
||||
# Empty function to avoid error "unknown function"
|
||||
function(hunter_add_package)
|
||||
endfunction()
|
||||
|
||||
set(
|
||||
_hunter_gate_disabled_mode_dir
|
||||
"${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode"
|
||||
)
|
||||
if(EXISTS "${_hunter_gate_disabled_mode_dir}")
|
||||
hunter_gate_status_debug(
|
||||
"Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}"
|
||||
)
|
||||
list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}")
|
||||
endif()
|
||||
elseif(_hunter_gate_done)
|
||||
hunter_gate_status_debug("Secondary HunterGate (use old settings)")
|
||||
hunter_gate_self(
|
||||
"${HUNTER_CACHED_ROOT}"
|
||||
"${HUNTER_VERSION}"
|
||||
"${HUNTER_SHA1}"
|
||||
_hunter_self
|
||||
)
|
||||
include("${_hunter_self}/cmake/Hunter")
|
||||
else()
|
||||
set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name)
|
||||
if(_have_project_name)
|
||||
hunter_gate_fatal_error(
|
||||
"Please set HunterGate *before* 'project' command. "
|
||||
"Detected project: ${PROJECT_NAME}"
|
||||
WIKI "error.huntergate.before.project"
|
||||
)
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(
|
||||
HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV}
|
||||
)
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1)
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url)
|
||||
string(
|
||||
COMPARE
|
||||
NOTEQUAL
|
||||
"${HUNTER_GATE_UNPARSED_ARGUMENTS}"
|
||||
""
|
||||
_have_unparsed
|
||||
)
|
||||
string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global)
|
||||
string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath)
|
||||
|
||||
if(_have_unparsed)
|
||||
hunter_gate_user_error(
|
||||
"HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}"
|
||||
)
|
||||
endif()
|
||||
if(_empty_sha1)
|
||||
hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory")
|
||||
endif()
|
||||
if(_empty_url)
|
||||
hunter_gate_user_error("URL suboption of HunterGate is mandatory")
|
||||
endif()
|
||||
if(_have_global)
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)")
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)")
|
||||
endif()
|
||||
endif()
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
if(_have_global)
|
||||
hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)")
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)")
|
||||
endif()
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
if(_have_global)
|
||||
hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)")
|
||||
endif()
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
hunter_gate_detect_root() # set HUNTER_GATE_ROOT
|
||||
|
||||
# Beautify path, fix probable problems with windows path slashes
|
||||
get_filename_component(
|
||||
HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE
|
||||
)
|
||||
hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}")
|
||||
if(NOT HUNTER_ALLOW_SPACES_IN_PATH)
|
||||
string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces)
|
||||
if(NOT _contain_spaces EQUAL -1)
|
||||
hunter_gate_fatal_error(
|
||||
"HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces."
|
||||
"Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error"
|
||||
"(Use at your own risk!)"
|
||||
WIKI "error.spaces.in.hunter.root"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(
|
||||
REGEX
|
||||
MATCH
|
||||
"[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*"
|
||||
HUNTER_GATE_VERSION
|
||||
"${HUNTER_GATE_URL}"
|
||||
)
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty)
|
||||
if(_is_empty)
|
||||
set(HUNTER_GATE_VERSION "unknown")
|
||||
endif()
|
||||
|
||||
hunter_gate_self(
|
||||
"${HUNTER_GATE_ROOT}"
|
||||
"${HUNTER_GATE_VERSION}"
|
||||
"${HUNTER_GATE_SHA1}"
|
||||
_hunter_self
|
||||
)
|
||||
|
||||
set(_master_location "${_hunter_self}/cmake/Hunter")
|
||||
if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter")
|
||||
# Hunter downloaded manually (e.g. by 'git clone')
|
||||
set(_unused "xxxxxxxxxx")
|
||||
set(HUNTER_GATE_SHA1 "${_unused}")
|
||||
set(HUNTER_GATE_VERSION "${_unused}")
|
||||
else()
|
||||
get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE)
|
||||
set(_done_location "${_archive_id_location}/DONE")
|
||||
set(_sha1_location "${_archive_id_location}/SHA1")
|
||||
|
||||
# Check Hunter already downloaded by HunterGate
|
||||
if(NOT EXISTS "${_done_location}")
|
||||
hunter_gate_download("${_archive_id_location}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${_done_location}")
|
||||
hunter_gate_internal_error("hunter_gate_download failed")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${_sha1_location}")
|
||||
hunter_gate_internal_error("${_sha1_location} not found")
|
||||
endif()
|
||||
file(READ "${_sha1_location}" _sha1_value)
|
||||
string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal)
|
||||
if(NOT _is_equal)
|
||||
hunter_gate_internal_error(
|
||||
"Short SHA1 collision:"
|
||||
" ${_sha1_value} (from ${_sha1_location})"
|
||||
" ${HUNTER_GATE_SHA1} (HunterGate)"
|
||||
)
|
||||
endif()
|
||||
if(NOT EXISTS "${_master_location}")
|
||||
hunter_gate_user_error(
|
||||
"Master file not found:"
|
||||
" ${_master_location}"
|
||||
"try to update Hunter/HunterGate"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
include("${_master_location}")
|
||||
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
|
||||
endif()
|
||||
endmacro()
|
||||
14
cmake/assimp-hunter-config.cmake.in
Normal file
14
cmake/assimp-hunter-config.cmake.in
Normal file
@@ -0,0 +1,14 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
find_package(RapidJSON CONFIG REQUIRED)
|
||||
find_package(ZLIB CONFIG REQUIRED)
|
||||
find_package(utf8 CONFIG REQUIRED)
|
||||
find_package(irrXML CONFIG REQUIRED)
|
||||
find_package(minizip CONFIG REQUIRED)
|
||||
find_package(openddlparser CONFIG REQUIRED)
|
||||
find_package(poly2tri CONFIG REQUIRED)
|
||||
find_package(polyclipping CONFIG REQUIRED)
|
||||
find_package(zip CONFIG REQUIRED)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
@@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// internal headers
|
||||
#include "3DSLoader.h"
|
||||
#include "TargetAnimation.h"
|
||||
#include "Common/TargetAnimation.h"
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/StringComparison.h>
|
||||
@@ -43,15 +43,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_3DS_EXPORTER
|
||||
|
||||
#include "3DSExporter.h"
|
||||
#include "3DSLoader.h"
|
||||
#include "3DSHelper.h"
|
||||
#include "3DS/3DSExporter.h"
|
||||
#include "3DS/3DSLoader.h"
|
||||
#include "3DS/3DSHelper.h"
|
||||
#include "PostProcessing/SplitLargeMeshes.h"
|
||||
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include "SplitLargeMeshes.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace Assimp;
|
||||
@@ -55,7 +55,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "3MFXmlTags.h"
|
||||
#include "D3MFOpcPackage.h"
|
||||
|
||||
#include <contrib/zip/src/zip.h>
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
# include <zip/zip.h>
|
||||
#else
|
||||
# include <contrib/zip/src/zip.h>
|
||||
#endif
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
@@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/ZipArchiveIOSystem.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -58,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <memory>
|
||||
|
||||
#include "D3MFOpcPackage.h"
|
||||
#include <unzip.h>
|
||||
#include <assimp/irrXMLWrapper.h>
|
||||
#include "3MFXmlTags.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
@@ -449,7 +449,7 @@ bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bo
|
||||
if ( nullptr == pIOHandler ) {
|
||||
return false;
|
||||
}
|
||||
if ( !D3MF::D3MFOpcPackage::isZipArchive( pIOHandler, filename ) ) {
|
||||
if ( !ZipArchiveIOSystem::isZipArchive( pIOHandler, filename ) ) {
|
||||
return false;
|
||||
}
|
||||
D3MF::D3MFOpcPackage opcPackage( pIOHandler, filename );
|
||||
207
code/3MF/D3MFOpcPackage.cpp
Normal file
207
code/3MF/D3MFOpcPackage.cpp
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software 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.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
|
||||
|
||||
#include "D3MFOpcPackage.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/ZipArchiveIOSystem.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include "3MFXmlTags.h"
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
namespace D3MF {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef std::shared_ptr<OpcPackageRelationship> OpcPackageRelationshipPtr;
|
||||
|
||||
class OpcPackageRelationshipReader {
|
||||
public:
|
||||
OpcPackageRelationshipReader(XmlReader* xmlReader) {
|
||||
while(xmlReader->read()) {
|
||||
if(xmlReader->getNodeType() == irr::io::EXN_ELEMENT &&
|
||||
xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_CONTAINER)
|
||||
{
|
||||
ParseRootNode(xmlReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParseRootNode(XmlReader* xmlReader)
|
||||
{
|
||||
ParseAttributes(xmlReader);
|
||||
|
||||
while(xmlReader->read())
|
||||
{
|
||||
if(xmlReader->getNodeType() == irr::io::EXN_ELEMENT &&
|
||||
xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_NODE)
|
||||
{
|
||||
ParseChildNode(xmlReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParseAttributes(XmlReader*) {
|
||||
// empty
|
||||
}
|
||||
|
||||
bool validateRels( OpcPackageRelationshipPtr &relPtr ) {
|
||||
if ( relPtr->id.empty() || relPtr->type.empty() || relPtr->target.empty() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParseChildNode(XmlReader* xmlReader) {
|
||||
OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship());
|
||||
|
||||
relPtr->id = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_ID.c_str());
|
||||
relPtr->type = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_TYPE.c_str());
|
||||
relPtr->target = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_TARGET.c_str());
|
||||
if ( validateRels( relPtr ) ) {
|
||||
m_relationShips.push_back( relPtr );
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<OpcPackageRelationshipPtr> m_relationShips;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile)
|
||||
: mRootStream(nullptr)
|
||||
, mZipArchive() {
|
||||
mZipArchive.reset( new ZipArchiveIOSystem( pIOHandler, rFile ) );
|
||||
if(!mZipArchive->isOpen()) {
|
||||
throw DeadlyImportError("Failed to open file " + rFile+ ".");
|
||||
}
|
||||
|
||||
std::vector<std::string> fileList;
|
||||
mZipArchive->getFileList(fileList);
|
||||
|
||||
for (auto& file: fileList) {
|
||||
if(file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE) {
|
||||
//PkgRelationshipReader pkgRelReader(file, archive);
|
||||
ai_assert(mZipArchive->Exists(file.c_str()));
|
||||
|
||||
IOStream *fileStream = mZipArchive->Open(file.c_str());
|
||||
|
||||
ai_assert(fileStream != nullptr);
|
||||
|
||||
std::string rootFile = ReadPackageRootRelationship(fileStream);
|
||||
if ( rootFile.size() > 0 && rootFile[ 0 ] == '/' ) {
|
||||
rootFile = rootFile.substr( 1 );
|
||||
if ( rootFile[ 0 ] == '/' ) {
|
||||
// deal with zip-bug
|
||||
rootFile = rootFile.substr( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
ASSIMP_LOG_DEBUG(rootFile);
|
||||
|
||||
mZipArchive->Close(fileStream);
|
||||
|
||||
mRootStream = mZipArchive->Open(rootFile.c_str());
|
||||
ai_assert( mRootStream != nullptr );
|
||||
if ( nullptr == mRootStream ) {
|
||||
throw DeadlyExportError( "Cannot open root-file in archive : " + rootFile );
|
||||
}
|
||||
|
||||
} else if( file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) {
|
||||
ASSIMP_LOG_WARN_F("Ignored file of unsupported type CONTENT_TYPES_ARCHIVES",file);
|
||||
} else {
|
||||
ASSIMP_LOG_WARN_F("Ignored file of unknown type: ",file);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
D3MFOpcPackage::~D3MFOpcPackage() {
|
||||
mZipArchive->Close(mRootStream);
|
||||
}
|
||||
|
||||
IOStream* D3MFOpcPackage::RootStream() const {
|
||||
return mRootStream;
|
||||
}
|
||||
|
||||
static const std::string ModelRef = "3D/3dmodel.model";
|
||||
|
||||
bool D3MFOpcPackage::validate() {
|
||||
if ( nullptr == mRootStream || nullptr == mZipArchive ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mZipArchive->Exists( ModelRef.c_str() );
|
||||
}
|
||||
|
||||
std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream* stream) {
|
||||
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(stream));
|
||||
std::unique_ptr<XmlReader> xml(irr::io::createIrrXMLReader(xmlStream.get()));
|
||||
|
||||
OpcPackageRelationshipReader reader(xml.get());
|
||||
|
||||
auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr& rel){
|
||||
return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE;
|
||||
});
|
||||
|
||||
if ( itr == reader.m_relationShips.end() ) {
|
||||
throw DeadlyImportError( "Cannot find " + XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE );
|
||||
}
|
||||
|
||||
return (*itr)->target;
|
||||
}
|
||||
|
||||
} // Namespace D3MF
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif //ASSIMP_BUILD_NO_3MF_IMPORTER
|
||||
@@ -49,6 +49,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/irrXMLWrapper.h>
|
||||
|
||||
namespace Assimp {
|
||||
class ZipArchiveIOSystem;
|
||||
|
||||
namespace D3MF {
|
||||
|
||||
using XmlReader = irr::io::IrrXMLReader ;
|
||||
@@ -60,22 +62,19 @@ struct OpcPackageRelationship {
|
||||
std::string target;
|
||||
};
|
||||
|
||||
class D3MFZipArchive;
|
||||
|
||||
class D3MFOpcPackage {
|
||||
public:
|
||||
D3MFOpcPackage( IOSystem* pIOHandler, const std::string& rFile );
|
||||
~D3MFOpcPackage();
|
||||
IOStream* RootStream() const;
|
||||
bool validate();
|
||||
static bool isZipArchive( IOSystem* pIOHandler, const std::string& rFile );
|
||||
|
||||
protected:
|
||||
std::string ReadPackageRootRelationship(IOStream* stream);
|
||||
|
||||
private:
|
||||
IOStream* mRootStream;
|
||||
std::unique_ptr<D3MFZipArchive> mZipArchive;
|
||||
std::unique_ptr<ZipArchiveIOSystem> mZipArchive;
|
||||
};
|
||||
|
||||
} // Namespace D3MF
|
||||
@@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/Subdivision.h>
|
||||
#include "Importer.h"
|
||||
#include "Common/Importer.h"
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/light.h>
|
||||
@@ -83,7 +83,7 @@ void AMFImporter::Clear()
|
||||
mMaterial_Converted.clear();
|
||||
mTexture_Converted.clear();
|
||||
// Delete all elements
|
||||
if(mNodeElement_List.size())
|
||||
if(!mNodeElement_List.empty())
|
||||
{
|
||||
for(CAMFImporter_NodeElement* ne: mNodeElement_List) { delete ne; }
|
||||
|
||||
@@ -66,7 +66,7 @@ aiColor4D AMFImporter::SPP_Material::GetColor(const float /*pX*/, const float /*
|
||||
aiColor4D tcol;
|
||||
|
||||
// Check if stored data are supported.
|
||||
if(Composition.size() != 0)
|
||||
if(!Composition.empty())
|
||||
{
|
||||
throw DeadlyImportError("IME. GetColor for composition");
|
||||
}
|
||||
@@ -321,7 +321,7 @@ void AMFImporter::PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace
|
||||
};
|
||||
|
||||
pOutputList_Separated.clear();
|
||||
if(pInputList.size() == 0) return;
|
||||
if(pInputList.empty()) return;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -334,19 +334,19 @@ void AMFImporter::PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace
|
||||
{
|
||||
auto it_old = it;
|
||||
|
||||
it++;
|
||||
++it;
|
||||
face_list_cur.push_back(*it_old);
|
||||
pInputList.erase(it_old);
|
||||
}
|
||||
else
|
||||
{
|
||||
it++;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
if(face_list_cur.size() > 0) pOutputList_Separated.push_back(face_list_cur);
|
||||
if(!face_list_cur.empty()) pOutputList_Separated.push_back(face_list_cur);
|
||||
|
||||
} while(pInputList.size() > 0);
|
||||
} while(!pInputList.empty());
|
||||
}
|
||||
|
||||
void AMFImporter::Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& metadataList, aiNode& sceneNode) const
|
||||
@@ -712,7 +712,7 @@ std::list<unsigned int> mesh_idx;
|
||||
}// for(const CAMFImporter_NodeElement* ne_child: pNodeElement.Child)
|
||||
|
||||
// if meshes was created then assign new indices with current aiNode
|
||||
if(mesh_idx.size() > 0)
|
||||
if(!mesh_idx.empty())
|
||||
{
|
||||
std::list<unsigned int>::const_iterator mit = mesh_idx.begin();
|
||||
|
||||
@@ -787,7 +787,7 @@ std::list<aiNode*> ch_node;
|
||||
}// for(const CAMFImporter_NodeElement* ne: pConstellation.Child)
|
||||
|
||||
// copy found aiNode's as children
|
||||
if(ch_node.size() == 0) throw DeadlyImportError("<constellation> must have at least one <instance>.");
|
||||
if(ch_node.empty()) throw DeadlyImportError("<constellation> must have at least one <instance>.");
|
||||
|
||||
size_t ch_idx = 0;
|
||||
|
||||
@@ -883,13 +883,13 @@ nl_clean_loop:
|
||||
if(node_list.size() > 1)
|
||||
{
|
||||
// walk through all nodes
|
||||
for(std::list<aiNode*>::iterator nl_it = node_list.begin(); nl_it != node_list.end(); nl_it++)
|
||||
for(std::list<aiNode*>::iterator nl_it = node_list.begin(); nl_it != node_list.end(); ++nl_it)
|
||||
{
|
||||
// and try to find them in another top nodes.
|
||||
std::list<aiNode*>::const_iterator next_it = nl_it;
|
||||
|
||||
next_it++;
|
||||
for(; next_it != node_list.end(); next_it++)
|
||||
++next_it;
|
||||
for(; next_it != node_list.end(); ++next_it)
|
||||
{
|
||||
if((*next_it)->FindNode((*nl_it)->mName) != nullptr)
|
||||
{
|
||||
@@ -907,7 +907,7 @@ nl_clean_loop:
|
||||
//
|
||||
//
|
||||
// Nodes
|
||||
if(node_list.size() > 0)
|
||||
if(!node_list.empty())
|
||||
{
|
||||
std::list<aiNode*>::const_iterator nl_it = node_list.begin();
|
||||
|
||||
@@ -924,7 +924,7 @@ nl_clean_loop:
|
||||
|
||||
//
|
||||
// Meshes
|
||||
if(mesh_list.size() > 0)
|
||||
if(!mesh_list.empty())
|
||||
{
|
||||
std::list<aiMesh*>::const_iterator ml_it = mesh_list.begin();
|
||||
|
||||
@@ -53,7 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "ASELoader.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/SkeletonMeshBuilder.h>
|
||||
#include "TargetAnimation.h"
|
||||
#include "Common/TargetAnimation.h"
|
||||
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
@@ -88,23 +89,25 @@ ASEImporter::ASEImporter()
|
||||
, mBuffer()
|
||||
, pcScene()
|
||||
, configRecomputeNormals()
|
||||
, noSkeletonMesh()
|
||||
{}
|
||||
, noSkeletonMesh() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
ASEImporter::~ASEImporter()
|
||||
{}
|
||||
ASEImporter::~ASEImporter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const
|
||||
{
|
||||
bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const {
|
||||
// check file extension
|
||||
const std::string extension = GetExtension(pFile);
|
||||
|
||||
if( extension == "ase" || extension == "ask")
|
||||
if (extension == "ase" || extension == "ask") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((!extension.length() || cs) && pIOHandler) {
|
||||
const char* tokens[] = {"*3dsmax_asciiexport"};
|
||||
@@ -115,15 +118,13 @@ bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Loader meta information
|
||||
const aiImporterDesc* ASEImporter::GetInfo () const
|
||||
{
|
||||
const aiImporterDesc* ASEImporter::GetInfo () const {
|
||||
return &desc;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Setup configuration options
|
||||
void ASEImporter::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
void ASEImporter::SetupProperties(const Importer* pImp) {
|
||||
configRecomputeNormals = (pImp->GetPropertyInteger(
|
||||
AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS,1) ? true : false);
|
||||
|
||||
@@ -133,12 +134,11 @@ void ASEImporter::SetupProperties(const Importer* pImp)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void ASEImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
aiScene* pScene, IOSystem* pIOHandler) {
|
||||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
|
||||
|
||||
// Check whether we can read from the file
|
||||
if( file.get() == NULL) {
|
||||
if( file.get() == nullptr) {
|
||||
throw DeadlyImportError( "Failed to open ASE file " + pFile + ".");
|
||||
}
|
||||
|
||||
@@ -1299,7 +1299,7 @@ void ASEImporter::BuildMaterialIndices()
|
||||
}
|
||||
}
|
||||
|
||||
// Dekete our temporary array
|
||||
// Delete our temporary array
|
||||
delete[] pcIntMaterials;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -45,20 +45,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* @brief Implementation of the ASE parser class
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_ASE_IMPORTER
|
||||
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||
|
||||
// internal headers
|
||||
#include "TextureTransform.h"
|
||||
#include "PostProcessing/TextureTransform.h"
|
||||
#include "ASELoader.h"
|
||||
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::ASE;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Begin an ASE parsing function
|
||||
|
||||
@@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/qnan.h>
|
||||
|
||||
// ASE is quite similar to 3ds. We can reuse some structures
|
||||
#include "3DSLoader.h"
|
||||
#include "3DS/3DSLoader.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace ASE {
|
||||
@@ -188,10 +188,11 @@ struct Animation {
|
||||
} mRotationType, mScalingType, mPositionType;
|
||||
|
||||
Animation() AI_NO_EXCEPT
|
||||
: mRotationType (TRACK)
|
||||
, mScalingType (TRACK)
|
||||
, mPositionType (TRACK)
|
||||
{}
|
||||
: mRotationType (TRACK)
|
||||
, mScalingType (TRACK)
|
||||
, mPositionType (TRACK) {
|
||||
// empty
|
||||
}
|
||||
|
||||
//! List of track rotation keyframes
|
||||
std::vector< aiQuatKey > akeyRotations;
|
||||
@@ -243,7 +244,6 @@ struct BaseNode {
|
||||
mTargetPosition.x = qnan;
|
||||
}
|
||||
|
||||
|
||||
//! Name of the mesh
|
||||
std::string mName;
|
||||
|
||||
@@ -46,12 +46,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||
|
||||
#include "assbin_chunks.h"
|
||||
#include "Common/assbin_chunks.h"
|
||||
#include "PostProcessing/ProcessHelper.h"
|
||||
|
||||
#include <assimp/version.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include "ProcessHelper.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||
@@ -50,8 +50,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER
|
||||
|
||||
// internal headers
|
||||
#include "AssbinLoader.h"
|
||||
#include "assbin_chunks.h"
|
||||
#include "Assbin/AssbinLoader.h"
|
||||
#include "Common/assbin_chunks.h"
|
||||
#include <assimp/MemoryIOWrapper.h>
|
||||
#include <assimp/mesh.h>
|
||||
#include <assimp/anim.h>
|
||||
@@ -68,7 +68,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
using namespace Assimp;
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
".assbin Importer",
|
||||
"Assimp Binary Importer",
|
||||
"Gargaj / Conspiracy",
|
||||
"",
|
||||
"",
|
||||
@@ -708,7 +708,7 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||
|
||||
unsigned char * uncompressedData = new unsigned char[ uncompressedSize ];
|
||||
|
||||
int res = uncompress( uncompressedData, &uncompressedSize, compressedData, len );
|
||||
int res = uncompress( uncompressedData, &uncompressedSize, compressedData, (uLong) len );
|
||||
if(res != Z_OK)
|
||||
{
|
||||
delete [] uncompressedData;
|
||||
109
code/Assjson/cencode.c
Normal file
109
code/Assjson/cencode.c
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
cencoder.c - c source to a base64 encoding algorithm implementation
|
||||
|
||||
This is part of the libb64 project, and has been placed in the public domain.
|
||||
For details, see http://sourceforge.net/projects/libb64
|
||||
*/
|
||||
|
||||
#include "cencode.h" // changed from <B64/cencode.h>
|
||||
|
||||
const int CHARS_PER_LINE = 72;
|
||||
|
||||
void base64_init_encodestate(base64_encodestate* state_in)
|
||||
{
|
||||
state_in->step = step_A;
|
||||
state_in->result = 0;
|
||||
state_in->stepcount = 0;
|
||||
}
|
||||
|
||||
char base64_encode_value(char value_in)
|
||||
{
|
||||
static const char* encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
if (value_in > 63) return '=';
|
||||
return encoding[(int)value_in];
|
||||
}
|
||||
|
||||
int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in)
|
||||
{
|
||||
const char* plainchar = plaintext_in;
|
||||
const char* const plaintextend = plaintext_in + length_in;
|
||||
char* codechar = code_out;
|
||||
char result;
|
||||
char fragment;
|
||||
|
||||
result = state_in->result;
|
||||
|
||||
switch (state_in->step)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
case step_A:
|
||||
if (plainchar == plaintextend)
|
||||
{
|
||||
state_in->result = result;
|
||||
state_in->step = step_A;
|
||||
return codechar - code_out;
|
||||
}
|
||||
fragment = *plainchar++;
|
||||
result = (fragment & 0x0fc) >> 2;
|
||||
*codechar++ = base64_encode_value(result);
|
||||
result = (fragment & 0x003) << 4;
|
||||
case step_B:
|
||||
if (plainchar == plaintextend)
|
||||
{
|
||||
state_in->result = result;
|
||||
state_in->step = step_B;
|
||||
return codechar - code_out;
|
||||
}
|
||||
fragment = *plainchar++;
|
||||
result |= (fragment & 0x0f0) >> 4;
|
||||
*codechar++ = base64_encode_value(result);
|
||||
result = (fragment & 0x00f) << 2;
|
||||
case step_C:
|
||||
if (plainchar == plaintextend)
|
||||
{
|
||||
state_in->result = result;
|
||||
state_in->step = step_C;
|
||||
return codechar - code_out;
|
||||
}
|
||||
fragment = *plainchar++;
|
||||
result |= (fragment & 0x0c0) >> 6;
|
||||
*codechar++ = base64_encode_value(result);
|
||||
result = (fragment & 0x03f) >> 0;
|
||||
*codechar++ = base64_encode_value(result);
|
||||
|
||||
++(state_in->stepcount);
|
||||
if (state_in->stepcount == CHARS_PER_LINE/4)
|
||||
{
|
||||
*codechar++ = '\n';
|
||||
state_in->stepcount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* control should not reach here */
|
||||
return codechar - code_out;
|
||||
}
|
||||
|
||||
int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
||||
{
|
||||
char* codechar = code_out;
|
||||
|
||||
switch (state_in->step)
|
||||
{
|
||||
case step_B:
|
||||
*codechar++ = base64_encode_value(state_in->result);
|
||||
*codechar++ = '=';
|
||||
*codechar++ = '=';
|
||||
break;
|
||||
case step_C:
|
||||
*codechar++ = base64_encode_value(state_in->result);
|
||||
*codechar++ = '=';
|
||||
break;
|
||||
case step_A:
|
||||
break;
|
||||
}
|
||||
*codechar++ = '\n';
|
||||
|
||||
return codechar - code_out;
|
||||
}
|
||||
|
||||
31
code/Assjson/cencode.h
Normal file
31
code/Assjson/cencode.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
cencode.h - c header for a base64 encoding algorithm
|
||||
|
||||
This is part of the libb64 project, and has been placed in the public domain.
|
||||
For details, see http://sourceforge.net/projects/libb64
|
||||
*/
|
||||
|
||||
#ifndef BASE64_CENCODE_H
|
||||
#define BASE64_CENCODE_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
step_A, step_B, step_C
|
||||
} base64_encodestep;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
base64_encodestep step;
|
||||
char result;
|
||||
int stepcount;
|
||||
} base64_encodestate;
|
||||
|
||||
void base64_init_encodestate(base64_encodestate* state_in);
|
||||
|
||||
char base64_encode_value(char value_in);
|
||||
|
||||
int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in);
|
||||
|
||||
int base64_encode_blockend(char* code_out, base64_encodestate* state_in);
|
||||
|
||||
#endif /* BASE64_CENCODE_H */
|
||||
809
code/Assjson/json_exporter.cpp
Normal file
809
code/Assjson/json_exporter.cpp
Normal file
@@ -0,0 +1,809 @@
|
||||
/*
|
||||
Assimp2Json
|
||||
Copyright (c) 2011, Alexander C. Gessler
|
||||
|
||||
Licensed under a 3-clause BSD license. See the LICENSE file for more information.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSJSON_EXPORTER
|
||||
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
|
||||
#define CURRENT_FORMAT_VERSION 100
|
||||
|
||||
// grab scoped_ptr from assimp to avoid a dependency on boost.
|
||||
//#include <assimp/../../code/BoostWorkaround/boost/scoped_ptr.hpp>
|
||||
|
||||
#include "mesh_splitter.h"
|
||||
|
||||
extern "C" {
|
||||
#include "cencode.h"
|
||||
}
|
||||
namespace Assimp {
|
||||
|
||||
void ExportAssimp2Json(const char*, Assimp::IOSystem*, const aiScene*, const Assimp::ExportProperties*);
|
||||
|
||||
// small utility class to simplify serializing the aiScene to Json
|
||||
class JSONWriter {
|
||||
public:
|
||||
enum {
|
||||
Flag_DoNotIndent = 0x1,
|
||||
Flag_WriteSpecialFloats = 0x2,
|
||||
};
|
||||
|
||||
JSONWriter(Assimp::IOStream& out, unsigned int flags = 0u)
|
||||
: out(out)
|
||||
, first()
|
||||
, flags(flags) {
|
||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||
buff.imbue(std::locale("C"));
|
||||
}
|
||||
|
||||
~JSONWriter() {
|
||||
Flush();
|
||||
}
|
||||
|
||||
void Flush() {
|
||||
const std::string s = buff.str();
|
||||
out.Write(s.c_str(), s.length(), 1);
|
||||
buff.clear();
|
||||
}
|
||||
|
||||
void PushIndent() {
|
||||
indent += '\t';
|
||||
}
|
||||
|
||||
void PopIndent() {
|
||||
indent.erase(indent.end() - 1);
|
||||
}
|
||||
|
||||
void Key(const std::string& name) {
|
||||
AddIndentation();
|
||||
Delimit();
|
||||
buff << '\"' + name + "\": ";
|
||||
}
|
||||
|
||||
template<typename Literal>
|
||||
void Element(const Literal& name) {
|
||||
AddIndentation();
|
||||
Delimit();
|
||||
|
||||
LiteralToString(buff, name) << '\n';
|
||||
}
|
||||
|
||||
template<typename Literal>
|
||||
void SimpleValue(const Literal& s) {
|
||||
LiteralToString(buff, s) << '\n';
|
||||
}
|
||||
|
||||
void SimpleValue(const void* buffer, size_t len) {
|
||||
base64_encodestate s;
|
||||
base64_init_encodestate(&s);
|
||||
|
||||
char* const out = new char[std::max(len * 2, static_cast<size_t>(16u))];
|
||||
const int n = base64_encode_block(reinterpret_cast<const char*>(buffer), static_cast<int>(len), out, &s);
|
||||
out[n + base64_encode_blockend(out + n, &s)] = '\0';
|
||||
|
||||
// base64 encoding may add newlines, but JSON strings may not contain 'real' newlines
|
||||
// (only escaped ones). Remove any newlines in out.
|
||||
for (char* cur = out; *cur; ++cur) {
|
||||
if (*cur == '\n') {
|
||||
*cur = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
buff << '\"' << out << "\"\n";
|
||||
delete[] out;
|
||||
}
|
||||
|
||||
void StartObj(bool is_element = false) {
|
||||
// if this appears as a plain array element, we need to insert a delimiter and we should also indent it
|
||||
if (is_element) {
|
||||
AddIndentation();
|
||||
if (!first) {
|
||||
buff << ',';
|
||||
}
|
||||
}
|
||||
first = true;
|
||||
buff << "{\n";
|
||||
PushIndent();
|
||||
}
|
||||
|
||||
void EndObj() {
|
||||
PopIndent();
|
||||
AddIndentation();
|
||||
first = false;
|
||||
buff << "}\n";
|
||||
}
|
||||
|
||||
void StartArray(bool is_element = false) {
|
||||
// if this appears as a plain array element, we need to insert a delimiter and we should also indent it
|
||||
if (is_element) {
|
||||
AddIndentation();
|
||||
if (!first) {
|
||||
buff << ',';
|
||||
}
|
||||
}
|
||||
first = true;
|
||||
buff << "[\n";
|
||||
PushIndent();
|
||||
}
|
||||
|
||||
void EndArray() {
|
||||
PopIndent();
|
||||
AddIndentation();
|
||||
buff << "]\n";
|
||||
first = false;
|
||||
}
|
||||
|
||||
void AddIndentation() {
|
||||
if (!(flags & Flag_DoNotIndent)) {
|
||||
buff << indent;
|
||||
}
|
||||
}
|
||||
|
||||
void Delimit() {
|
||||
if (!first) {
|
||||
buff << ',';
|
||||
}
|
||||
else {
|
||||
buff << ' ';
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename Literal>
|
||||
std::stringstream& LiteralToString(std::stringstream& stream, const Literal& s) {
|
||||
stream << s;
|
||||
return stream;
|
||||
}
|
||||
|
||||
std::stringstream& LiteralToString(std::stringstream& stream, const aiString& s) {
|
||||
std::string t;
|
||||
|
||||
// escape backslashes and single quotes, both would render the JSON invalid if left as is
|
||||
t.reserve(s.length);
|
||||
for (size_t i = 0; i < s.length; ++i) {
|
||||
|
||||
if (s.data[i] == '\\' || s.data[i] == '\'' || s.data[i] == '\"') {
|
||||
t.push_back('\\');
|
||||
}
|
||||
|
||||
t.push_back(s.data[i]);
|
||||
}
|
||||
stream << "\"";
|
||||
stream << t;
|
||||
stream << "\"";
|
||||
return stream;
|
||||
}
|
||||
|
||||
std::stringstream& LiteralToString(std::stringstream& stream, float f) {
|
||||
if (!std::numeric_limits<float>::is_iec559) {
|
||||
// on a non IEEE-754 platform, we make no assumptions about the representation or existence
|
||||
// of special floating-point numbers.
|
||||
stream << f;
|
||||
return stream;
|
||||
}
|
||||
|
||||
// JSON does not support writing Inf/Nan
|
||||
// [RFC 4672: "Numeric values that cannot be represented as sequences of digits
|
||||
// (such as Infinity and NaN) are not permitted."]
|
||||
// Nevertheless, many parsers will accept the special keywords Infinity, -Infinity and NaN
|
||||
if (std::numeric_limits<float>::infinity() == fabs(f)) {
|
||||
if (flags & Flag_WriteSpecialFloats) {
|
||||
stream << (f < 0 ? "\"-" : "\"") + std::string("Infinity\"");
|
||||
return stream;
|
||||
}
|
||||
// we should print this warning, but we can't - this is called from within a generic assimp exporter, we cannot use cerr
|
||||
// std::cerr << "warning: cannot represent infinite number literal, substituting 0 instead (use -i flag to enforce Infinity/NaN)" << std::endl;
|
||||
stream << "0.0";
|
||||
return stream;
|
||||
}
|
||||
// f!=f is the most reliable test for NaNs that I know of
|
||||
else if (f != f) {
|
||||
if (flags & Flag_WriteSpecialFloats) {
|
||||
stream << "\"NaN\"";
|
||||
return stream;
|
||||
}
|
||||
// we should print this warning, but we can't - this is called from within a generic assimp exporter, we cannot use cerr
|
||||
// std::cerr << "warning: cannot represent infinite number literal, substituting 0 instead (use -i flag to enforce Infinity/NaN)" << std::endl;
|
||||
stream << "0.0";
|
||||
return stream;
|
||||
}
|
||||
|
||||
stream << f;
|
||||
return stream;
|
||||
}
|
||||
|
||||
private:
|
||||
Assimp::IOStream& out;
|
||||
std::string indent, newline;
|
||||
std::stringstream buff;
|
||||
bool first;
|
||||
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
void Write(JSONWriter& out, const aiVector3D& ai, bool is_elem = true) {
|
||||
out.StartArray(is_elem);
|
||||
out.Element(ai.x);
|
||||
out.Element(ai.y);
|
||||
out.Element(ai.z);
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiQuaternion& ai, bool is_elem = true) {
|
||||
out.StartArray(is_elem);
|
||||
out.Element(ai.w);
|
||||
out.Element(ai.x);
|
||||
out.Element(ai.y);
|
||||
out.Element(ai.z);
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiColor3D& ai, bool is_elem = true) {
|
||||
out.StartArray(is_elem);
|
||||
out.Element(ai.r);
|
||||
out.Element(ai.g);
|
||||
out.Element(ai.b);
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiMatrix4x4& ai, bool is_elem = true) {
|
||||
out.StartArray(is_elem);
|
||||
for (unsigned int x = 0; x < 4; ++x) {
|
||||
for (unsigned int y = 0; y < 4; ++y) {
|
||||
out.Element(ai[x][y]);
|
||||
}
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiBone& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("name");
|
||||
out.SimpleValue(ai.mName);
|
||||
|
||||
out.Key("offsetmatrix");
|
||||
Write(out, ai.mOffsetMatrix, false);
|
||||
|
||||
out.Key("weights");
|
||||
out.StartArray();
|
||||
for (unsigned int i = 0; i < ai.mNumWeights; ++i) {
|
||||
out.StartArray(true);
|
||||
out.Element(ai.mWeights[i].mVertexId);
|
||||
out.Element(ai.mWeights[i].mWeight);
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndArray();
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiFace& ai, bool is_elem = true) {
|
||||
out.StartArray(is_elem);
|
||||
for (unsigned int i = 0; i < ai.mNumIndices; ++i) {
|
||||
out.Element(ai.mIndices[i]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiMesh& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("name");
|
||||
out.SimpleValue(ai.mName);
|
||||
|
||||
out.Key("materialindex");
|
||||
out.SimpleValue(ai.mMaterialIndex);
|
||||
|
||||
out.Key("primitivetypes");
|
||||
out.SimpleValue(ai.mPrimitiveTypes);
|
||||
|
||||
out.Key("vertices");
|
||||
out.StartArray();
|
||||
for (unsigned int i = 0; i < ai.mNumVertices; ++i) {
|
||||
out.Element(ai.mVertices[i].x);
|
||||
out.Element(ai.mVertices[i].y);
|
||||
out.Element(ai.mVertices[i].z);
|
||||
}
|
||||
out.EndArray();
|
||||
|
||||
if (ai.HasNormals()) {
|
||||
out.Key("normals");
|
||||
out.StartArray();
|
||||
for (unsigned int i = 0; i < ai.mNumVertices; ++i) {
|
||||
out.Element(ai.mNormals[i].x);
|
||||
out.Element(ai.mNormals[i].y);
|
||||
out.Element(ai.mNormals[i].z);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.HasTangentsAndBitangents()) {
|
||||
out.Key("tangents");
|
||||
out.StartArray();
|
||||
for (unsigned int i = 0; i < ai.mNumVertices; ++i) {
|
||||
out.Element(ai.mTangents[i].x);
|
||||
out.Element(ai.mTangents[i].y);
|
||||
out.Element(ai.mTangents[i].z);
|
||||
}
|
||||
out.EndArray();
|
||||
|
||||
out.Key("bitangents");
|
||||
out.StartArray();
|
||||
for (unsigned int i = 0; i < ai.mNumVertices; ++i) {
|
||||
out.Element(ai.mBitangents[i].x);
|
||||
out.Element(ai.mBitangents[i].y);
|
||||
out.Element(ai.mBitangents[i].z);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.GetNumUVChannels()) {
|
||||
out.Key("numuvcomponents");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.GetNumUVChannels(); ++n) {
|
||||
out.Element(ai.mNumUVComponents[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
|
||||
out.Key("texturecoords");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.GetNumUVChannels(); ++n) {
|
||||
const unsigned int numc = ai.mNumUVComponents[n] ? ai.mNumUVComponents[n] : 2;
|
||||
|
||||
out.StartArray(true);
|
||||
for (unsigned int i = 0; i < ai.mNumVertices; ++i) {
|
||||
for (unsigned int c = 0; c < numc; ++c) {
|
||||
out.Element(ai.mTextureCoords[n][i][c]);
|
||||
}
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.GetNumColorChannels()) {
|
||||
out.Key("colors");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.GetNumColorChannels(); ++n) {
|
||||
out.StartArray(true);
|
||||
for (unsigned int i = 0; i < ai.mNumVertices; ++i) {
|
||||
out.Element(ai.mColors[n][i].r);
|
||||
out.Element(ai.mColors[n][i].g);
|
||||
out.Element(ai.mColors[n][i].b);
|
||||
out.Element(ai.mColors[n][i].a);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.mNumBones) {
|
||||
out.Key("bones");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumBones; ++n) {
|
||||
Write(out, *ai.mBones[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
out.Key("faces");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumFaces; ++n) {
|
||||
Write(out, ai.mFaces[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiNode& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("name");
|
||||
out.SimpleValue(ai.mName);
|
||||
|
||||
out.Key("transformation");
|
||||
Write(out, ai.mTransformation, false);
|
||||
|
||||
if (ai.mNumMeshes) {
|
||||
out.Key("meshes");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumMeshes; ++n) {
|
||||
out.Element(ai.mMeshes[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.mNumChildren) {
|
||||
out.Key("children");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumChildren; ++n) {
|
||||
Write(out, *ai.mChildren[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiMaterial& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("properties");
|
||||
out.StartArray();
|
||||
for (unsigned int i = 0; i < ai.mNumProperties; ++i) {
|
||||
const aiMaterialProperty* const prop = ai.mProperties[i];
|
||||
out.StartObj(true);
|
||||
out.Key("key");
|
||||
out.SimpleValue(prop->mKey);
|
||||
out.Key("semantic");
|
||||
out.SimpleValue(prop->mSemantic);
|
||||
out.Key("index");
|
||||
out.SimpleValue(prop->mIndex);
|
||||
|
||||
out.Key("type");
|
||||
out.SimpleValue(prop->mType);
|
||||
|
||||
out.Key("value");
|
||||
switch (prop->mType) {
|
||||
case aiPTI_Float:
|
||||
if (prop->mDataLength / sizeof(float) > 1) {
|
||||
out.StartArray();
|
||||
for (unsigned int i = 0; i < prop->mDataLength / sizeof(float); ++i) {
|
||||
out.Element(reinterpret_cast<float*>(prop->mData)[i]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
else {
|
||||
out.SimpleValue(*reinterpret_cast<float*>(prop->mData));
|
||||
}
|
||||
break;
|
||||
|
||||
case aiPTI_Integer:
|
||||
if (prop->mDataLength / sizeof(int) > 1) {
|
||||
out.StartArray();
|
||||
for (unsigned int i = 0; i < prop->mDataLength / sizeof(int); ++i) {
|
||||
out.Element(reinterpret_cast<int*>(prop->mData)[i]);
|
||||
}
|
||||
out.EndArray();
|
||||
} else {
|
||||
out.SimpleValue(*reinterpret_cast<int*>(prop->mData));
|
||||
}
|
||||
break;
|
||||
|
||||
case aiPTI_String:
|
||||
{
|
||||
aiString s;
|
||||
aiGetMaterialString(&ai, prop->mKey.data, prop->mSemantic, prop->mIndex, &s);
|
||||
out.SimpleValue(s);
|
||||
}
|
||||
break;
|
||||
case aiPTI_Buffer:
|
||||
{
|
||||
// binary data is written as series of hex-encoded octets
|
||||
out.SimpleValue(prop->mData, prop->mDataLength);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
out.EndArray();
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiTexture& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("width");
|
||||
out.SimpleValue(ai.mWidth);
|
||||
|
||||
out.Key("height");
|
||||
out.SimpleValue(ai.mHeight);
|
||||
|
||||
out.Key("formathint");
|
||||
out.SimpleValue(aiString(ai.achFormatHint));
|
||||
|
||||
out.Key("data");
|
||||
if (!ai.mHeight) {
|
||||
out.SimpleValue(ai.pcData, ai.mWidth);
|
||||
}
|
||||
else {
|
||||
out.StartArray();
|
||||
for (unsigned int y = 0; y < ai.mHeight; ++y) {
|
||||
out.StartArray(true);
|
||||
for (unsigned int x = 0; x < ai.mWidth; ++x) {
|
||||
const aiTexel& tx = ai.pcData[y*ai.mWidth + x];
|
||||
out.StartArray(true);
|
||||
out.Element(static_cast<unsigned int>(tx.r));
|
||||
out.Element(static_cast<unsigned int>(tx.g));
|
||||
out.Element(static_cast<unsigned int>(tx.b));
|
||||
out.Element(static_cast<unsigned int>(tx.a));
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiLight& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("name");
|
||||
out.SimpleValue(ai.mName);
|
||||
|
||||
out.Key("type");
|
||||
out.SimpleValue(ai.mType);
|
||||
|
||||
if (ai.mType == aiLightSource_SPOT || ai.mType == aiLightSource_UNDEFINED) {
|
||||
out.Key("angleinnercone");
|
||||
out.SimpleValue(ai.mAngleInnerCone);
|
||||
|
||||
out.Key("angleoutercone");
|
||||
out.SimpleValue(ai.mAngleOuterCone);
|
||||
}
|
||||
|
||||
out.Key("attenuationconstant");
|
||||
out.SimpleValue(ai.mAttenuationConstant);
|
||||
|
||||
out.Key("attenuationlinear");
|
||||
out.SimpleValue(ai.mAttenuationLinear);
|
||||
|
||||
out.Key("attenuationquadratic");
|
||||
out.SimpleValue(ai.mAttenuationQuadratic);
|
||||
|
||||
out.Key("diffusecolor");
|
||||
Write(out, ai.mColorDiffuse, false);
|
||||
|
||||
out.Key("specularcolor");
|
||||
Write(out, ai.mColorSpecular, false);
|
||||
|
||||
out.Key("ambientcolor");
|
||||
Write(out, ai.mColorAmbient, false);
|
||||
|
||||
if (ai.mType != aiLightSource_POINT) {
|
||||
out.Key("direction");
|
||||
Write(out, ai.mDirection, false);
|
||||
|
||||
}
|
||||
|
||||
if (ai.mType != aiLightSource_DIRECTIONAL) {
|
||||
out.Key("position");
|
||||
Write(out, ai.mPosition, false);
|
||||
}
|
||||
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiNodeAnim& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("name");
|
||||
out.SimpleValue(ai.mNodeName);
|
||||
|
||||
out.Key("prestate");
|
||||
out.SimpleValue(ai.mPreState);
|
||||
|
||||
out.Key("poststate");
|
||||
out.SimpleValue(ai.mPostState);
|
||||
|
||||
if (ai.mNumPositionKeys) {
|
||||
out.Key("positionkeys");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumPositionKeys; ++n) {
|
||||
const aiVectorKey& pos = ai.mPositionKeys[n];
|
||||
out.StartArray(true);
|
||||
out.Element(pos.mTime);
|
||||
Write(out, pos.mValue);
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.mNumRotationKeys) {
|
||||
out.Key("rotationkeys");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumRotationKeys; ++n) {
|
||||
const aiQuatKey& rot = ai.mRotationKeys[n];
|
||||
out.StartArray(true);
|
||||
out.Element(rot.mTime);
|
||||
Write(out, rot.mValue);
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.mNumScalingKeys) {
|
||||
out.Key("scalingkeys");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumScalingKeys; ++n) {
|
||||
const aiVectorKey& scl = ai.mScalingKeys[n];
|
||||
out.StartArray(true);
|
||||
out.Element(scl.mTime);
|
||||
Write(out, scl.mValue);
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiAnimation& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("name");
|
||||
out.SimpleValue(ai.mName);
|
||||
|
||||
out.Key("tickspersecond");
|
||||
out.SimpleValue(ai.mTicksPerSecond);
|
||||
|
||||
out.Key("duration");
|
||||
out.SimpleValue(ai.mDuration);
|
||||
|
||||
out.Key("channels");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumChannels; ++n) {
|
||||
Write(out, *ai.mChannels[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiCamera& ai, bool is_elem = true) {
|
||||
out.StartObj(is_elem);
|
||||
|
||||
out.Key("name");
|
||||
out.SimpleValue(ai.mName);
|
||||
|
||||
out.Key("aspect");
|
||||
out.SimpleValue(ai.mAspect);
|
||||
|
||||
out.Key("clipplanefar");
|
||||
out.SimpleValue(ai.mClipPlaneFar);
|
||||
|
||||
out.Key("clipplanenear");
|
||||
out.SimpleValue(ai.mClipPlaneNear);
|
||||
|
||||
out.Key("horizontalfov");
|
||||
out.SimpleValue(ai.mHorizontalFOV);
|
||||
|
||||
out.Key("up");
|
||||
Write(out, ai.mUp, false);
|
||||
|
||||
out.Key("lookat");
|
||||
Write(out, ai.mLookAt, false);
|
||||
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void WriteFormatInfo(JSONWriter& out) {
|
||||
out.StartObj();
|
||||
out.Key("format");
|
||||
out.SimpleValue("\"assimp2json\"");
|
||||
out.Key("version");
|
||||
out.SimpleValue(CURRENT_FORMAT_VERSION);
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
void Write(JSONWriter& out, const aiScene& ai) {
|
||||
out.StartObj();
|
||||
|
||||
out.Key("__metadata__");
|
||||
WriteFormatInfo(out);
|
||||
|
||||
out.Key("rootnode");
|
||||
Write(out, *ai.mRootNode, false);
|
||||
|
||||
out.Key("flags");
|
||||
out.SimpleValue(ai.mFlags);
|
||||
|
||||
if (ai.HasMeshes()) {
|
||||
out.Key("meshes");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumMeshes; ++n) {
|
||||
Write(out, *ai.mMeshes[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.HasMaterials()) {
|
||||
out.Key("materials");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumMaterials; ++n) {
|
||||
Write(out, *ai.mMaterials[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.HasAnimations()) {
|
||||
out.Key("animations");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumAnimations; ++n) {
|
||||
Write(out, *ai.mAnimations[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.HasLights()) {
|
||||
out.Key("lights");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumLights; ++n) {
|
||||
Write(out, *ai.mLights[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.HasCameras()) {
|
||||
out.Key("cameras");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumCameras; ++n) {
|
||||
Write(out, *ai.mCameras[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
|
||||
if (ai.HasTextures()) {
|
||||
out.Key("textures");
|
||||
out.StartArray();
|
||||
for (unsigned int n = 0; n < ai.mNumTextures; ++n) {
|
||||
Write(out, *ai.mTextures[n]);
|
||||
}
|
||||
out.EndArray();
|
||||
}
|
||||
out.EndObj();
|
||||
}
|
||||
|
||||
|
||||
void ExportAssimp2Json(const char* file, Assimp::IOSystem* io, const aiScene* scene, const Assimp::ExportProperties*) {
|
||||
std::unique_ptr<Assimp::IOStream> str(io->Open(file, "wt"));
|
||||
if (!str) {
|
||||
//throw Assimp::DeadlyExportError("could not open output file");
|
||||
}
|
||||
|
||||
// get a copy of the scene so we can modify it
|
||||
aiScene* scenecopy_tmp;
|
||||
aiCopyScene(scene, &scenecopy_tmp);
|
||||
|
||||
try {
|
||||
// split meshes so they fit into a 16 bit index buffer
|
||||
MeshSplitter splitter;
|
||||
splitter.SetLimit(1 << 16);
|
||||
splitter.Execute(scenecopy_tmp);
|
||||
|
||||
// XXX Flag_WriteSpecialFloats is turned on by default, right now we don't have a configuration interface for exporters
|
||||
JSONWriter s(*str, JSONWriter::Flag_WriteSpecialFloats);
|
||||
Write(s, *scenecopy_tmp);
|
||||
|
||||
}
|
||||
catch (...) {
|
||||
aiFreeScene(scenecopy_tmp);
|
||||
throw;
|
||||
}
|
||||
aiFreeScene(scenecopy_tmp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_ASSJSON_EXPORTER
|
||||
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||
320
code/Assjson/mesh_splitter.cpp
Normal file
320
code/Assjson/mesh_splitter.cpp
Normal file
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
Assimp2Json
|
||||
Copyright (c) 2011, Alexander C. Gessler
|
||||
|
||||
Licensed under a 3-clause BSD license. See the LICENSE file for more information.
|
||||
|
||||
*/
|
||||
|
||||
#include "mesh_splitter.h"
|
||||
|
||||
#include <assimp/scene.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Note: this is largely based on assimp's SplitLargeMeshes_Vertex process.
|
||||
// it is refactored and the coding style is slightly improved, though.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
void MeshSplitter::Execute( aiScene* pScene) {
|
||||
std::vector<std::pair<aiMesh*, unsigned int> > source_mesh_map;
|
||||
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++) {
|
||||
SplitMesh(a, pScene->mMeshes[a],source_mesh_map);
|
||||
}
|
||||
|
||||
const unsigned int size = static_cast<unsigned int>(source_mesh_map.size());
|
||||
if (size != pScene->mNumMeshes) {
|
||||
// it seems something has been split. rebuild the mesh list
|
||||
delete[] pScene->mMeshes;
|
||||
pScene->mNumMeshes = size;
|
||||
pScene->mMeshes = new aiMesh*[size]();
|
||||
|
||||
for (unsigned int i = 0; i < size;++i) {
|
||||
pScene->mMeshes[i] = source_mesh_map[i].first;
|
||||
}
|
||||
|
||||
// now we need to update all nodes
|
||||
UpdateNode(pScene->mRootNode,source_mesh_map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void MeshSplitter::UpdateNode(aiNode* pcNode, const std::vector<std::pair<aiMesh*, unsigned int> >& source_mesh_map) {
|
||||
// TODO: should better use std::(multi)set for source_mesh_map.
|
||||
|
||||
// for every index in out list build a new entry
|
||||
std::vector<unsigned int> aiEntries;
|
||||
aiEntries.reserve(pcNode->mNumMeshes + 1);
|
||||
for (unsigned int i = 0; i < pcNode->mNumMeshes;++i) {
|
||||
for (unsigned int a = 0, end = static_cast<unsigned int>(source_mesh_map.size()); a < end;++a) {
|
||||
if (source_mesh_map[a].second == pcNode->mMeshes[i]) {
|
||||
aiEntries.push_back(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now build the new list
|
||||
delete pcNode->mMeshes;
|
||||
pcNode->mNumMeshes = static_cast<unsigned int>(aiEntries.size());
|
||||
pcNode->mMeshes = new unsigned int[pcNode->mNumMeshes];
|
||||
|
||||
for (unsigned int b = 0; b < pcNode->mNumMeshes;++b) {
|
||||
pcNode->mMeshes[b] = aiEntries[b];
|
||||
}
|
||||
|
||||
// recursively update children
|
||||
for (unsigned int i = 0, end = pcNode->mNumChildren; i < end;++i) {
|
||||
UpdateNode ( pcNode->mChildren[i], source_mesh_map );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#define WAS_NOT_COPIED 0xffffffff
|
||||
|
||||
typedef std::pair <unsigned int,float> PerVertexWeight;
|
||||
typedef std::vector <PerVertexWeight> VertexWeightTable;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
VertexWeightTable* ComputeVertexBoneWeightTable(const aiMesh* pMesh) {
|
||||
if (!pMesh || !pMesh->mNumVertices || !pMesh->mNumBones) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
VertexWeightTable* const avPerVertexWeights = new VertexWeightTable[pMesh->mNumVertices];
|
||||
for (unsigned int i = 0; i < pMesh->mNumBones;++i) {
|
||||
|
||||
aiBone* bone = pMesh->mBones[i];
|
||||
for (unsigned int a = 0; a < bone->mNumWeights;++a) {
|
||||
const aiVertexWeight& weight = bone->mWeights[a];
|
||||
avPerVertexWeights[weight.mVertexId].push_back( std::make_pair(i,weight.mWeight) );
|
||||
}
|
||||
}
|
||||
return avPerVertexWeights;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void MeshSplitter :: SplitMesh(unsigned int a, aiMesh* in_mesh, std::vector<std::pair<aiMesh*, unsigned int> >& source_mesh_map) {
|
||||
// TODO: should better use std::(multi)set for source_mesh_map.
|
||||
|
||||
if (in_mesh->mNumVertices <= LIMIT) {
|
||||
source_mesh_map.push_back(std::make_pair(in_mesh,a));
|
||||
return;
|
||||
}
|
||||
|
||||
// build a per-vertex weight list if necessary
|
||||
VertexWeightTable* avPerVertexWeights = ComputeVertexBoneWeightTable(in_mesh);
|
||||
|
||||
// we need to split this mesh into sub meshes. Estimate submesh size
|
||||
const unsigned int sub_meshes = (in_mesh->mNumVertices / LIMIT) + 1;
|
||||
|
||||
// create a std::vector<unsigned int> to remember which vertices have already
|
||||
// been copied and to which position (i.e. output index)
|
||||
std::vector<unsigned int> was_copied_to;
|
||||
was_copied_to.resize(in_mesh->mNumVertices,WAS_NOT_COPIED);
|
||||
|
||||
// Try to find a good estimate for the number of output faces
|
||||
// per mesh. Add 12.5% as buffer
|
||||
unsigned int size_estimated = in_mesh->mNumFaces / sub_meshes;
|
||||
size_estimated += size_estimated / 8;
|
||||
|
||||
// now generate all submeshes
|
||||
unsigned int base = 0;
|
||||
while (true) {
|
||||
const unsigned int out_vertex_index = LIMIT;
|
||||
|
||||
aiMesh* out_mesh = new aiMesh();
|
||||
out_mesh->mNumVertices = 0;
|
||||
out_mesh->mMaterialIndex = in_mesh->mMaterialIndex;
|
||||
|
||||
// the name carries the adjacency information between the meshes
|
||||
out_mesh->mName = in_mesh->mName;
|
||||
|
||||
typedef std::vector<aiVertexWeight> BoneWeightList;
|
||||
if (in_mesh->HasBones()) {
|
||||
out_mesh->mBones = new aiBone*[in_mesh->mNumBones]();
|
||||
}
|
||||
|
||||
// clear the temporary helper array
|
||||
if (base) {
|
||||
std::fill(was_copied_to.begin(), was_copied_to.end(), WAS_NOT_COPIED);
|
||||
}
|
||||
|
||||
std::vector<aiFace> vFaces;
|
||||
|
||||
// reserve enough storage for most cases
|
||||
if (in_mesh->HasPositions()) {
|
||||
out_mesh->mVertices = new aiVector3D[out_vertex_index];
|
||||
}
|
||||
|
||||
if (in_mesh->HasNormals()) {
|
||||
out_mesh->mNormals = new aiVector3D[out_vertex_index];
|
||||
}
|
||||
|
||||
if (in_mesh->HasTangentsAndBitangents()) {
|
||||
out_mesh->mTangents = new aiVector3D[out_vertex_index];
|
||||
out_mesh->mBitangents = new aiVector3D[out_vertex_index];
|
||||
}
|
||||
|
||||
for (unsigned int c = 0; in_mesh->HasVertexColors(c);++c) {
|
||||
out_mesh->mColors[c] = new aiColor4D[out_vertex_index];
|
||||
}
|
||||
|
||||
for (unsigned int c = 0; in_mesh->HasTextureCoords(c);++c) {
|
||||
out_mesh->mNumUVComponents[c] = in_mesh->mNumUVComponents[c];
|
||||
out_mesh->mTextureCoords[c] = new aiVector3D[out_vertex_index];
|
||||
}
|
||||
vFaces.reserve(size_estimated);
|
||||
|
||||
// (we will also need to copy the array of indices)
|
||||
while (base < in_mesh->mNumFaces) {
|
||||
const unsigned int iNumIndices = in_mesh->mFaces[base].mNumIndices;
|
||||
|
||||
// doesn't catch degenerates but is quite fast
|
||||
unsigned int iNeed = 0;
|
||||
for (unsigned int v = 0; v < iNumIndices;++v) {
|
||||
unsigned int index = in_mesh->mFaces[base].mIndices[v];
|
||||
|
||||
// check whether we do already have this vertex
|
||||
if (WAS_NOT_COPIED == was_copied_to[index]) {
|
||||
iNeed++;
|
||||
}
|
||||
}
|
||||
if (out_mesh->mNumVertices + iNeed > out_vertex_index) {
|
||||
// don't use this face
|
||||
break;
|
||||
}
|
||||
|
||||
vFaces.push_back(aiFace());
|
||||
aiFace& rFace = vFaces.back();
|
||||
|
||||
// setup face type and number of indices
|
||||
rFace.mNumIndices = iNumIndices;
|
||||
rFace.mIndices = new unsigned int[iNumIndices];
|
||||
|
||||
// need to update the output primitive types
|
||||
switch (rFace.mNumIndices)
|
||||
{
|
||||
case 1:
|
||||
out_mesh->mPrimitiveTypes |= aiPrimitiveType_POINT;
|
||||
break;
|
||||
case 2:
|
||||
out_mesh->mPrimitiveTypes |= aiPrimitiveType_LINE;
|
||||
break;
|
||||
case 3:
|
||||
out_mesh->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE;
|
||||
break;
|
||||
default:
|
||||
out_mesh->mPrimitiveTypes |= aiPrimitiveType_POLYGON;
|
||||
}
|
||||
|
||||
// and copy the contents of the old array, offset them by current base
|
||||
for (unsigned int v = 0; v < iNumIndices;++v) {
|
||||
const unsigned int index = in_mesh->mFaces[base].mIndices[v];
|
||||
|
||||
// check whether we do already have this vertex
|
||||
if (WAS_NOT_COPIED != was_copied_to[index]) {
|
||||
rFace.mIndices[v] = was_copied_to[index];
|
||||
continue;
|
||||
}
|
||||
|
||||
// copy positions
|
||||
out_mesh->mVertices[out_mesh->mNumVertices] = (in_mesh->mVertices[index]);
|
||||
|
||||
// copy normals
|
||||
if (in_mesh->HasNormals()) {
|
||||
out_mesh->mNormals[out_mesh->mNumVertices] = (in_mesh->mNormals[index]);
|
||||
}
|
||||
|
||||
// copy tangents/bi-tangents
|
||||
if (in_mesh->HasTangentsAndBitangents()) {
|
||||
out_mesh->mTangents[out_mesh->mNumVertices] = (in_mesh->mTangents[index]);
|
||||
out_mesh->mBitangents[out_mesh->mNumVertices] = (in_mesh->mBitangents[index]);
|
||||
}
|
||||
|
||||
// texture coordinates
|
||||
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) {
|
||||
if (in_mesh->HasTextureCoords( c)) {
|
||||
out_mesh->mTextureCoords[c][out_mesh->mNumVertices] = in_mesh->mTextureCoords[c][index];
|
||||
}
|
||||
}
|
||||
// vertex colors
|
||||
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS;++c) {
|
||||
if (in_mesh->HasVertexColors( c)) {
|
||||
out_mesh->mColors[c][out_mesh->mNumVertices] = in_mesh->mColors[c][index];
|
||||
}
|
||||
}
|
||||
// check whether we have bone weights assigned to this vertex
|
||||
rFace.mIndices[v] = out_mesh->mNumVertices;
|
||||
if (avPerVertexWeights) {
|
||||
VertexWeightTable& table = avPerVertexWeights[ out_mesh->mNumVertices ];
|
||||
for (VertexWeightTable::const_iterator iter = table.begin(), end = table.end(); iter != end;++iter) {
|
||||
// allocate the bone weight array if necessary and store it in the mBones field (HACK!)
|
||||
BoneWeightList* weight_list = reinterpret_cast<BoneWeightList*>(out_mesh->mBones[(*iter).first]);
|
||||
if (!weight_list) {
|
||||
weight_list = new BoneWeightList();
|
||||
out_mesh->mBones[(*iter).first] = reinterpret_cast<aiBone*>(weight_list);
|
||||
}
|
||||
weight_list->push_back(aiVertexWeight(out_mesh->mNumVertices,(*iter).second));
|
||||
}
|
||||
}
|
||||
|
||||
was_copied_to[index] = out_mesh->mNumVertices;
|
||||
out_mesh->mNumVertices++;
|
||||
}
|
||||
base++;
|
||||
if(out_mesh->mNumVertices == out_vertex_index) {
|
||||
// break here. The face is only added if it was complete
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// check which bones we'll need to create for this submesh
|
||||
if (in_mesh->HasBones()) {
|
||||
aiBone** ppCurrent = out_mesh->mBones;
|
||||
for (unsigned int k = 0; k < in_mesh->mNumBones;++k) {
|
||||
// check whether the bone exists
|
||||
BoneWeightList* const weight_list = reinterpret_cast<BoneWeightList*>(out_mesh->mBones[k]);
|
||||
|
||||
if (weight_list) {
|
||||
const aiBone* const bone_in = in_mesh->mBones[k];
|
||||
aiBone* const bone_out = new aiBone();
|
||||
*ppCurrent++ = bone_out;
|
||||
bone_out->mName = aiString(bone_in->mName);
|
||||
bone_out->mOffsetMatrix =bone_in->mOffsetMatrix;
|
||||
bone_out->mNumWeights = (unsigned int)weight_list->size();
|
||||
bone_out->mWeights = new aiVertexWeight[bone_out->mNumWeights];
|
||||
|
||||
// copy the vertex weights
|
||||
::memcpy(bone_out->mWeights, &(*weight_list)[0],bone_out->mNumWeights * sizeof(aiVertexWeight));
|
||||
|
||||
delete weight_list;
|
||||
out_mesh->mNumBones++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copy the face list to the mesh
|
||||
out_mesh->mFaces = new aiFace[vFaces.size()];
|
||||
out_mesh->mNumFaces = (unsigned int)vFaces.size();
|
||||
|
||||
for (unsigned int p = 0; p < out_mesh->mNumFaces;++p) {
|
||||
out_mesh->mFaces[p] = vFaces[p];
|
||||
}
|
||||
|
||||
// add the newly created mesh to the list
|
||||
source_mesh_map.push_back(std::make_pair(out_mesh,a));
|
||||
|
||||
if (base == in_mesh->mNumFaces) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// delete the per-vertex weight list again
|
||||
delete[] avPerVertexWeights;
|
||||
|
||||
// now delete the old mesh data
|
||||
delete in_mesh;
|
||||
}
|
||||
61
code/Assjson/mesh_splitter.h
Normal file
61
code/Assjson/mesh_splitter.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Assimp2Json
|
||||
Copyright (c) 2011, Alexander C. Gessler
|
||||
|
||||
Licensed under a 3-clause BSD license. See the LICENSE file for more information.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_MESH_SPLITTER
|
||||
#define INCLUDED_MESH_SPLITTER
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Note: this is largely based on assimp's SplitLargeMeshes_Vertex process.
|
||||
// it is refactored and the coding style is slightly improved, though.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct aiScene;
|
||||
struct aiMesh;
|
||||
struct aiNode;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Splits meshes of unique vertices into meshes with no more vertices than
|
||||
* a given, configurable threshold value.
|
||||
*/
|
||||
class MeshSplitter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void SetLimit(unsigned int l) {
|
||||
LIMIT = l;
|
||||
}
|
||||
|
||||
unsigned int GetLimit() const {
|
||||
return LIMIT;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Executes the post processing step on the given imported data.
|
||||
* At the moment a process is not supposed to fail.
|
||||
* @param pScene The imported data to work at.
|
||||
*/
|
||||
void Execute( aiScene* pScene);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void UpdateNode(aiNode* pcNode, const std::vector<std::pair<aiMesh*, unsigned int> >& source_mesh_map);
|
||||
void SplitMesh (unsigned int index, aiMesh* mesh, std::vector<std::pair<aiMesh*, unsigned int> >& source_mesh_map);
|
||||
|
||||
public:
|
||||
|
||||
unsigned int LIMIT;
|
||||
};
|
||||
|
||||
#endif // INCLUDED_MESH_SPLITTER
|
||||
|
||||
@@ -46,13 +46,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "PostProcessing/ProcessHelper.h"
|
||||
|
||||
#include <assimp/version.h>
|
||||
#include "ProcessHelper.h"
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||
# include <zlib.h>
|
||||
#else
|
||||
@@ -555,8 +557,6 @@ void WriteDump(const aiScene* scene, IOStream* io, bool shortened) {
|
||||
mesh->mNormals[n].z);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
ioprintf(io,"\t\t</Normals>\n");
|
||||
}
|
||||
|
||||
@@ -49,17 +49,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef ASSIMP_BUILD_NO_B3D_IMPORTER
|
||||
|
||||
// internal headers
|
||||
#include "B3DImporter.h"
|
||||
#include "TextureTransform.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include "B3D/B3DImporter.h"
|
||||
#include "PostProcessing/TextureTransform.h"
|
||||
#include "PostProcessing/ConvertToLHProcess.h"
|
||||
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <memory>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/anim.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace std;
|
||||
|
||||
@@ -416,7 +416,7 @@ template <> struct Structure :: _defaultInitializer<ErrorPolicy_Fail> {
|
||||
void operator ()(T& /*out*/,const char* = "") {
|
||||
// obviously, it is crucial that _DefaultInitializer is used
|
||||
// only from within a catch clause.
|
||||
throw;
|
||||
throw DeadlyImportError("Constructing BlenderDNA Structure encountered an error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1225,6 +1225,16 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c
|
||||
case Lamp::Type_Local:
|
||||
out->mType = aiLightSource_POINT;
|
||||
break;
|
||||
case Lamp::Type_Spot:
|
||||
out->mType = aiLightSource_SPOT;
|
||||
|
||||
// blender orients directional lights as facing toward -z
|
||||
out->mDirection = aiVector3D(0.f, 0.f, -1.f);
|
||||
out->mUp = aiVector3D(0.f, 1.f, 0.f);
|
||||
|
||||
out->mAngleInnerCone = lamp->spotsize * (1.0f - lamp->spotblend);
|
||||
out->mAngleOuterCone = lamp->spotsize;
|
||||
break;
|
||||
case Lamp::Type_Sun:
|
||||
out->mType = aiLightSource_DIRECTIONAL;
|
||||
|
||||
@@ -1255,6 +1265,23 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c
|
||||
out->mColorAmbient = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
|
||||
out->mColorSpecular = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
|
||||
out->mColorDiffuse = aiColor3D(lamp->r, lamp->g, lamp->b) * lamp->energy;
|
||||
|
||||
// If default values are supplied, compute the coefficients from light's max distance
|
||||
// Read this: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/
|
||||
//
|
||||
if (lamp->constant_coefficient == 1.0f && lamp->linear_coefficient == 0.0f && lamp->quadratic_coefficient == 0.0f && lamp->dist > 0.0f)
|
||||
{
|
||||
out->mAttenuationConstant = 1.0f;
|
||||
out->mAttenuationLinear = 2.0f / lamp->dist;
|
||||
out->mAttenuationQuadratic = 1.0f / (lamp->dist * lamp->dist);
|
||||
}
|
||||
else
|
||||
{
|
||||
out->mAttenuationConstant = lamp->constant_coefficient;
|
||||
out->mAttenuationLinear = lamp->linear_coefficient;
|
||||
out->mAttenuationQuadratic = lamp->quadratic_coefficient;
|
||||
}
|
||||
|
||||
return out.release();
|
||||
}
|
||||
|
||||
@@ -211,9 +211,12 @@ template <> void Structure :: Convert<Lamp> (
|
||||
ReadField<ErrorPolicy_Warn>(dest.b,"b",db);
|
||||
ReadField<ErrorPolicy_Warn>(dest.k,"k",db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.energy,"energy",db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.dist,"dist",db);
|
||||
ReadField<ErrorPolicy_Warn>(dest.dist,"dist",db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.spotsize,"spotsize",db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.spotblend,"spotblend",db);
|
||||
ReadField<ErrorPolicy_Warn>(dest.constant_coefficient, "coeff_const", db);
|
||||
ReadField<ErrorPolicy_Warn>(dest.linear_coefficient, "coeff_lin", db);
|
||||
ReadField<ErrorPolicy_Warn>(dest.quadratic_coefficient, "coeff_quad", db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.att1,"att1",db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.att2,"att2",db);
|
||||
ReadField<ErrorPolicy_Igno>(temp,"falloff_type",db);
|
||||
@@ -538,6 +538,10 @@ struct Lamp : ElemBase {
|
||||
float energy, dist, spotsize, spotblend;
|
||||
//float haint;
|
||||
|
||||
float constant_coefficient;
|
||||
float linear_coefficient;
|
||||
float quadratic_coefficient;
|
||||
|
||||
float att1, att2;
|
||||
//struct CurveMapping *curfalloff;
|
||||
FalloffType falloff_type;
|
||||
@@ -144,7 +144,11 @@ namespace Assimp
|
||||
|
||||
#if ASSIMP_BLEND_WITH_POLY_2_TRI
|
||||
|
||||
#include "../contrib/poly2tri/poly2tri/poly2tri.h"
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
# include <poly2tri/poly2tri.h>
|
||||
#else
|
||||
# include "../contrib/poly2tri/poly2tri/poly2tri.h"
|
||||
#endif
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2012, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -68,8 +68,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
using namespace melange;
|
||||
|
||||
// overload this function and fill in your own unique data
|
||||
void GetWriterInfo(int &id, String &appname)
|
||||
{
|
||||
void GetWriterInfo(int &id, String &appname) {
|
||||
id = 2424226;
|
||||
appname = "Open Asset Import Library";
|
||||
}
|
||||
@@ -78,7 +77,10 @@ using namespace Assimp;
|
||||
using namespace Assimp::Formatter;
|
||||
|
||||
namespace Assimp {
|
||||
template<> const std::string LogFunctions<C4DImporter>::log_prefix = "C4D: ";
|
||||
template<> const char* LogFunctions<C4DImporter>::Prefix() {
|
||||
static auto prefix = "C4D: ";
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
@@ -97,47 +99,44 @@ static const aiImporterDesc desc = {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
C4DImporter::C4DImporter()
|
||||
{}
|
||||
: BaseImporter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
C4DImporter::~C4DImporter()
|
||||
{}
|
||||
C4DImporter::~C4DImporter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool C4DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
||||
{
|
||||
bool C4DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||
const std::string& extension = GetExtension(pFile);
|
||||
if (extension == "c4d") {
|
||||
return true;
|
||||
}
|
||||
|
||||
else if ((!extension.length() || checkSig) && pIOHandler) {
|
||||
} else if ((!extension.length() || checkSig) && pIOHandler) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const aiImporterDesc* C4DImporter::GetInfo () const
|
||||
{
|
||||
const aiImporterDesc* C4DImporter::GetInfo () const {
|
||||
return &desc;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void C4DImporter::SetupProperties(const Importer* /*pImp*/)
|
||||
{
|
||||
void C4DImporter::SetupProperties(const Importer* /*pImp*/) {
|
||||
// nothing to be done for the moment
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void C4DImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
void C4DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
|
||||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||
|
||||
if( file.get() == NULL) {
|
||||
if( file.get() == nullptr ) {
|
||||
ThrowException("failed to open file " + pFile);
|
||||
}
|
||||
|
||||
@@ -151,7 +150,7 @@ void C4DImporter::InternReadFile( const std::string& pFile,
|
||||
|
||||
// open document first
|
||||
BaseDocument* doc = LoadDocument(f, SCENEFILTER_OBJECTS | SCENEFILTER_MATERIALS);
|
||||
if(doc == NULL) {
|
||||
if(doc == nullptr ) {
|
||||
ThrowException("failed to read document " + pFile);
|
||||
}
|
||||
|
||||
@@ -160,11 +159,10 @@ void C4DImporter::InternReadFile( const std::string& pFile,
|
||||
// first convert all materials
|
||||
ReadMaterials(doc->GetFirstMaterial());
|
||||
|
||||
// process C4D scenegraph recursively
|
||||
// process C4D scene-graph recursively
|
||||
try {
|
||||
RecurseHierarchy(doc->GetFirstObject(), pScene->mRootNode);
|
||||
}
|
||||
catch(...) {
|
||||
} catch(...) {
|
||||
for(aiMesh* mesh : meshes) {
|
||||
delete mesh;
|
||||
}
|
||||
@@ -201,8 +199,7 @@ void C4DImporter::InternReadFile( const std::string& pFile,
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader)
|
||||
{
|
||||
bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
||||
// based on Melange sample code (C4DImportExport.cpp)
|
||||
while(shader) {
|
||||
if(shader->GetType() == Xlayer) {
|
||||
@@ -220,15 +217,12 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader)
|
||||
// Ignore the actual layer blending - models for real-time rendering should not
|
||||
// use them in a non-trivial way. Just try to find textures that we can apply
|
||||
// to the model.
|
||||
while (lsl)
|
||||
{
|
||||
if (lsl->GetType() == TypeFolder)
|
||||
{
|
||||
while (lsl) {
|
||||
if (lsl->GetType() == TypeFolder) {
|
||||
BlendFolder* const folder = dynamic_cast<BlendFolder*>(lsl);
|
||||
LayerShaderLayer *subLsl = dynamic_cast<LayerShaderLayer*>(folder->m_Children.GetObject(0));
|
||||
|
||||
while (subLsl)
|
||||
{
|
||||
while (subLsl) {
|
||||
if (subLsl->GetType() == TypeShader) {
|
||||
BlendShader* const shader = dynamic_cast<BlendShader*>(subLsl);
|
||||
if(ReadShader(out, static_cast<BaseShader*>(shader->m_pLink->GetLink()))) {
|
||||
@@ -238,8 +232,7 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader)
|
||||
|
||||
subLsl = subLsl->GetNext();
|
||||
}
|
||||
}
|
||||
else if (lsl->GetType() == TypeShader) {
|
||||
} else if (lsl->GetType() == TypeShader) {
|
||||
BlendShader* const shader = dynamic_cast<BlendShader*>(lsl);
|
||||
if(ReadShader(out, static_cast<BaseShader*>(shader->m_pLink->GetLink()))) {
|
||||
return true;
|
||||
@@ -248,33 +241,27 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader)
|
||||
|
||||
lsl = lsl->GetNext();
|
||||
}
|
||||
}
|
||||
else if ( shader->GetType() == Xbitmap )
|
||||
{
|
||||
} else if ( shader->GetType() == Xbitmap ) {
|
||||
aiString path;
|
||||
shader->GetFileName().GetString().GetCString(path.data, MAXLEN-1);
|
||||
path.length = ::strlen(path.data);
|
||||
out->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
LogWarn("ignoring shader type: " + std::string(GetObjectTypeName(shader->GetType())));
|
||||
}
|
||||
shader = shader->GetNext();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void C4DImporter::ReadMaterials(melange::BaseMaterial* mat)
|
||||
{
|
||||
void C4DImporter::ReadMaterials(melange::BaseMaterial* mat) {
|
||||
// based on Melange sample code
|
||||
while (mat)
|
||||
{
|
||||
while (mat) {
|
||||
const String& name = mat->GetName();
|
||||
if (mat->GetType() == Mmaterial)
|
||||
{
|
||||
if (mat->GetType() == Mmaterial) {
|
||||
aiMaterial* out = new aiMaterial();
|
||||
material_mapping[mat] = static_cast<unsigned int>(materials.size());
|
||||
materials.push_back(out);
|
||||
@@ -286,8 +273,7 @@ void C4DImporter::ReadMaterials(melange::BaseMaterial* mat)
|
||||
|
||||
Material& m = dynamic_cast<Material&>(*mat);
|
||||
|
||||
if (m.GetChannelState(CHANNEL_COLOR))
|
||||
{
|
||||
if (m.GetChannelState(CHANNEL_COLOR)) {
|
||||
GeData data;
|
||||
mat->GetParameter(MATERIAL_COLOR_COLOR, data);
|
||||
Vector color = data.GetVector();
|
||||
@@ -307,9 +293,7 @@ void C4DImporter::ReadMaterials(melange::BaseMaterial* mat)
|
||||
if(shader) {
|
||||
ReadShader(out, shader);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
LogWarn("ignoring plugin material: " + std::string(GetObjectTypeName(mat->GetType())));
|
||||
}
|
||||
mat = mat->GetNext();
|
||||
@@ -317,14 +301,12 @@ void C4DImporter::ReadMaterials(melange::BaseMaterial* mat)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent)
|
||||
{
|
||||
ai_assert(parent != NULL);
|
||||
void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent) {
|
||||
ai_assert(parent != nullptr );
|
||||
std::vector<aiNode*> nodes;
|
||||
|
||||
// based on Melange sample code
|
||||
while (object)
|
||||
{
|
||||
while (object) {
|
||||
const String& name = object->GetName();
|
||||
const LONG type = object->GetType();
|
||||
const Matrix& ml = object->GetMl();
|
||||
@@ -356,26 +338,20 @@ void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent)
|
||||
nodes.push_back(nd);
|
||||
|
||||
GeData data;
|
||||
if (type == Ocamera)
|
||||
{
|
||||
if (type == Ocamera) {
|
||||
object->GetParameter(CAMERAOBJECT_FOV, data);
|
||||
// TODO: read camera
|
||||
}
|
||||
else if (type == Olight)
|
||||
{
|
||||
} else if (type == Olight) {
|
||||
// TODO: read light
|
||||
}
|
||||
else if (type == Opolygon)
|
||||
{
|
||||
} else if (type == Opolygon) {
|
||||
aiMesh* const mesh = ReadMesh(object);
|
||||
if(mesh != NULL) {
|
||||
if(mesh != nullptr) {
|
||||
nd->mNumMeshes = 1;
|
||||
nd->mMeshes = new unsigned int[1];
|
||||
nd->mMeshes[0] = static_cast<unsigned int>(meshes.size());
|
||||
meshes.push_back(mesh);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
LogWarn("ignoring object: " + std::string(GetObjectTypeName(type)));
|
||||
}
|
||||
|
||||
@@ -389,28 +365,27 @@ void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent)
|
||||
std::copy(nodes.begin(), nodes.end(), parent->mChildren);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
aiMesh* C4DImporter::ReadMesh(BaseObject* object)
|
||||
{
|
||||
ai_assert(object != NULL && object->GetType() == Opolygon);
|
||||
aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
|
||||
ai_assert(object != nullptr);
|
||||
ai_assert( object->GetType() == Opolygon );
|
||||
|
||||
// based on Melange sample code
|
||||
PolygonObject* const polyObject = dynamic_cast<PolygonObject*>(object);
|
||||
ai_assert(polyObject != NULL);
|
||||
ai_assert(polyObject != nullptr);
|
||||
|
||||
const LONG pointCount = polyObject->GetPointCount();
|
||||
const LONG polyCount = polyObject->GetPolygonCount();
|
||||
if(!polyObject || !pointCount) {
|
||||
LogWarn("ignoring mesh with zero vertices or faces");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Vector* points = polyObject->GetPointR();
|
||||
ai_assert(points != NULL);
|
||||
ai_assert(points != nullptr);
|
||||
|
||||
const CPolygon* polys = polyObject->GetPolygonR();
|
||||
ai_assert(polys != NULL);
|
||||
ai_assert(polys != nullptr);
|
||||
|
||||
std::unique_ptr<aiMesh> mesh(new aiMesh());
|
||||
mesh->mNumFaces = static_cast<unsigned int>(polyCount);
|
||||
@@ -443,14 +418,14 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object)
|
||||
|
||||
// check if there are normals, tangents or UVW coordinates
|
||||
BaseTag* tag = object->GetTag(Tnormal);
|
||||
NormalTag* normals_src = NULL;
|
||||
NormalTag* normals_src = nullptr;
|
||||
if(tag) {
|
||||
normals_src = dynamic_cast<NormalTag*>(tag);
|
||||
normals = mesh->mNormals = new aiVector3D[mesh->mNumVertices]();
|
||||
}
|
||||
|
||||
tag = object->GetTag(Ttangent);
|
||||
TangentTag* tangents_src = NULL;
|
||||
TangentTag* tangents_src = nullptr;
|
||||
if(tag) {
|
||||
tangents_src = dynamic_cast<TangentTag*>(tag);
|
||||
tangents = mesh->mTangents = new aiVector3D[mesh->mNumVertices]();
|
||||
@@ -458,15 +433,14 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object)
|
||||
}
|
||||
|
||||
tag = object->GetTag(Tuvw);
|
||||
UVWTag* uvs_src = NULL;
|
||||
UVWTag* uvs_src = nullptr;
|
||||
if(tag) {
|
||||
uvs_src = dynamic_cast<UVWTag*>(tag);
|
||||
uvs = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices]();
|
||||
}
|
||||
|
||||
// copy vertices and extra channels over and populate faces
|
||||
for (LONG i = 0; i < polyCount; ++i, ++face)
|
||||
{
|
||||
for (LONG i = 0; i < polyCount; ++i, ++face) {
|
||||
ai_assert(polys[i].a < pointCount && polys[i].a >= 0);
|
||||
const Vector& pointA = points[polys[i].a];
|
||||
verts->x = pointA.x;
|
||||
@@ -489,8 +463,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object)
|
||||
++verts;
|
||||
|
||||
// TODO: do we also need to handle lines or points with similar checks?
|
||||
if (polys[i].c != polys[i].d)
|
||||
{
|
||||
if (polys[i].c != polys[i].d) {
|
||||
ai_assert(polys[i].d < pointCount && polys[i].d >= 0);
|
||||
|
||||
face->mNumIndices = 4;
|
||||
@@ -500,8 +473,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object)
|
||||
verts->y = pointD.y;
|
||||
verts->z = pointD.z;
|
||||
++verts;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
face->mNumIndices = 3;
|
||||
}
|
||||
face->mIndices = new unsigned int[face->mNumIndices];
|
||||
@@ -513,8 +485,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object)
|
||||
if (normals_src) {
|
||||
if(i >= normals_src->GetDataCount()) {
|
||||
LogError("unexpected number of normals, ignoring");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ConstNormalHandle normal_handle = normals_src->GetDataAddressR();
|
||||
NormalStruct nor;
|
||||
NormalTag::Get(normal_handle, i, nor);
|
||||
@@ -616,26 +587,25 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object)
|
||||
}
|
||||
|
||||
mesh->mMaterialIndex = ResolveMaterial(polyObject);
|
||||
|
||||
return mesh.release();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
unsigned int C4DImporter::ResolveMaterial(PolygonObject* obj)
|
||||
{
|
||||
ai_assert(obj != NULL);
|
||||
unsigned int C4DImporter::ResolveMaterial(PolygonObject* obj) {
|
||||
ai_assert(obj != nullptr);
|
||||
|
||||
const unsigned int mat_count = static_cast<unsigned int>(materials.size());
|
||||
|
||||
BaseTag* tag = obj->GetTag(Ttexture);
|
||||
if(tag == NULL) {
|
||||
if(tag == nullptr) {
|
||||
return mat_count;
|
||||
}
|
||||
|
||||
TextureTag& ttag = dynamic_cast<TextureTag&>(*tag);
|
||||
|
||||
BaseMaterial* const mat = ttag.GetMaterial();
|
||||
ai_assert(mat != NULL);
|
||||
ai_assert(mat != nullptr);
|
||||
|
||||
const MaterialMap::const_iterator it = material_mapping.find(mat);
|
||||
if(it == material_mapping.end()) {
|
||||
@@ -643,6 +613,7 @@ unsigned int C4DImporter::ResolveMaterial(PolygonObject* obj)
|
||||
}
|
||||
|
||||
ai_assert((*it).second < mat_count);
|
||||
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2012, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -48,6 +48,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/LogAux.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
// Forward declarations
|
||||
struct aiNode;
|
||||
struct aiMesh;
|
||||
struct aiMaterial;
|
||||
@@ -61,8 +63,7 @@ namespace melange {
|
||||
class BaseShader;
|
||||
}
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
namespace Assimp {
|
||||
// TinyFormatter.h
|
||||
namespace Formatter {
|
||||
template <typename T,typename TR, typename A> class basic_formatter;
|
||||
@@ -75,17 +76,10 @@ namespace Assimp {
|
||||
*
|
||||
* Note that Melange is not free software. */
|
||||
// -------------------------------------------------------------------------------------------
|
||||
class C4DImporter : public BaseImporter, public LogFunctions<C4DImporter>
|
||||
{
|
||||
class C4DImporter : public BaseImporter, public LogFunctions<C4DImporter> {
|
||||
public:
|
||||
|
||||
C4DImporter();
|
||||
~C4DImporter();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// --------------------
|
||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
||||
bool checkSig) const;
|
||||
|
||||
@@ -119,5 +113,5 @@ private:
|
||||
}; // !class C4DImporter
|
||||
|
||||
} // end of namespace Assimp
|
||||
#endif // INCLUDED_AI_CINEMA_4D_LOADER_H
|
||||
|
||||
#endif // INCLUDED_AI_CINEMA_4D_LOADER_H
|
||||
@@ -49,7 +49,7 @@ Assimp C export interface. See Exporter.cpp for some notes.
|
||||
|
||||
#include "CInterfaceIOWrapper.h"
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include "ScenePrivate.h"
|
||||
#include "Common/ScenePrivate.h"
|
||||
#include <assimp/Exporter.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
1220
code/CMakeLists.txt
1220
code/CMakeLists.txt
File diff suppressed because it is too large
Load Diff
@@ -45,20 +45,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_COB_IMPORTER
|
||||
#include "COBLoader.h"
|
||||
#include "COBScene.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include "COB/COBLoader.h"
|
||||
#include "COB/COBScene.h"
|
||||
#include "PostProcessing/ConvertToLHProcess.h"
|
||||
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/LineSplitter.h>
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include <memory>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/importerdesc.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::COB;
|
||||
using namespace Assimp::Formatter;
|
||||
@@ -144,7 +146,7 @@ void COBImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||
// check header
|
||||
char head[32];
|
||||
stream->CopyAndAdvance(head,32);
|
||||
if (strncmp(head,"Caligari ",9)) {
|
||||
if (strncmp(head,"Caligari ",9) != 0) {
|
||||
ThrowException("Could not found magic id: `Caligari`");
|
||||
}
|
||||
|
||||
@@ -656,14 +658,14 @@ void COBImporter::ReadLght_Ascii(Scene& out, LineSplitter& splitter, const Chunk
|
||||
ReadFloat3Tuple_Ascii(msh.color ,&rgb);
|
||||
|
||||
SkipSpaces(&rgb);
|
||||
if (strncmp(rgb,"cone angle",10)) {
|
||||
if (strncmp(rgb,"cone angle",10) != 0) {
|
||||
ASSIMP_LOG_WARN_F( "Expected `cone angle` entity in `color` line in `Lght` chunk ", nfo.id );
|
||||
}
|
||||
SkipSpaces(rgb+10,&rgb);
|
||||
msh.angle = fast_atof(&rgb);
|
||||
|
||||
SkipSpaces(&rgb);
|
||||
if (strncmp(rgb,"inner angle",11)) {
|
||||
if (strncmp(rgb,"inner angle",11) != 0) {
|
||||
ASSIMP_LOG_WARN_F( "Expected `inner angle` entity in `color` line in `Lght` chunk ", nfo.id);
|
||||
}
|
||||
SkipSpaces(rgb+11,&rgb);
|
||||
@@ -896,6 +898,7 @@ public:
|
||||
: nfo(nfo)
|
||||
, reader(reader)
|
||||
, cur(reader.GetCurrentPos()) {
|
||||
// empty
|
||||
}
|
||||
|
||||
~chunk_guard() {
|
||||
@@ -903,7 +906,7 @@ public:
|
||||
if(nfo.size != static_cast<unsigned int>(-1)) {
|
||||
try {
|
||||
reader.IncPtr( static_cast< int >( nfo.size ) - reader.GetCurrentPos() + cur );
|
||||
} catch ( DeadlyImportError e ) {
|
||||
} catch (const DeadlyImportError& ) {
|
||||
// out of limit so correct the value
|
||||
reader.IncPtr( reader.GetReadLimit() );
|
||||
}
|
||||
@@ -911,15 +914,17 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const COB::ChunkInfo& nfo;
|
||||
StreamReaderLE& reader;
|
||||
long cur;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void COBImporter::ReadBinaryFile(Scene& out, StreamReaderLE* reader)
|
||||
{
|
||||
void COBImporter::ReadBinaryFile(Scene& out, StreamReaderLE* reader) {
|
||||
if (nullptr == reader) {
|
||||
return;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
std::string type;
|
||||
type += reader -> GetI1()
|
||||
@@ -1214,7 +1219,7 @@ void COBImporter::ReadGrou_Binary(COB::Scene& out, StreamReaderLE& reader, const
|
||||
|
||||
const chunk_guard cn(nfo,reader);
|
||||
|
||||
out.nodes.push_back(std::shared_ptr<Group>(new Group()));
|
||||
out.nodes.push_back(std::make_shared<Group>());
|
||||
Group& msh = (Group&)(*out.nodes.back().get());
|
||||
msh = nfo;
|
||||
|
||||
@@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "ColladaExporter.h"
|
||||
#include <assimp/Bitmap.h>
|
||||
#include <assimp/MathFunctions.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
@@ -64,13 +65,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
namespace Assimp {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp
|
||||
void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/)
|
||||
{
|
||||
void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) {
|
||||
std::string path = DefaultIOSystem::absolutePath(std::string(pFile));
|
||||
std::string file = DefaultIOSystem::completeBaseName(std::string(pFile));
|
||||
|
||||
@@ -93,15 +92,15 @@ void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* p
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor for a specific scene to export
|
||||
ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file)
|
||||
{
|
||||
ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file)
|
||||
: mIOSystem(pIOSystem)
|
||||
, mPath(path)
|
||||
, mFile(file) {
|
||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||
mOutput.imbue( std::locale("C") );
|
||||
mOutput.precision(16);
|
||||
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||
|
||||
mScene = pScene;
|
||||
mSceneOwned = false;
|
||||
@@ -115,17 +114,15 @@ ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, co
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor
|
||||
ColladaExporter::~ColladaExporter()
|
||||
{
|
||||
if(mSceneOwned) {
|
||||
ColladaExporter::~ColladaExporter() {
|
||||
if ( mSceneOwned ) {
|
||||
delete mScene;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Starts writing the contents
|
||||
void ColladaExporter::WriteFile()
|
||||
{
|
||||
void ColladaExporter::WriteFile() {
|
||||
// write the DTD
|
||||
mOutput << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>" << endstr;
|
||||
// COLLADA element start
|
||||
@@ -158,9 +155,8 @@ void ColladaExporter::WriteFile()
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Writes the asset header
|
||||
void ColladaExporter::WriteHeader()
|
||||
{
|
||||
static const ai_real epsilon = ai_real( 0.00001 );
|
||||
void ColladaExporter::WriteHeader() {
|
||||
static const ai_real epsilon = Math::getEpsilon<ai_real>();
|
||||
static const aiQuaternion x_rot(aiMatrix3x3(
|
||||
0, -1, 0,
|
||||
1, 0, 0,
|
||||
@@ -238,25 +234,64 @@ void ColladaExporter::WriteHeader()
|
||||
mOutput << startstr << "<contributor>" << endstr;
|
||||
PushTag();
|
||||
|
||||
aiMetadata* meta = mScene->mRootNode->mMetaData;
|
||||
// If no Scene metadata, use root node metadata
|
||||
aiMetadata* meta = mScene->mMetaData;
|
||||
if (nullptr == meta) {
|
||||
meta = mScene->mRootNode->mMetaData;
|
||||
}
|
||||
|
||||
aiString value;
|
||||
if (!meta || !meta->Get("Author", value))
|
||||
if (!meta || !meta->Get("Author", value)) {
|
||||
mOutput << startstr << "<author>" << "Assimp" << "</author>" << endstr;
|
||||
else
|
||||
} else {
|
||||
mOutput << startstr << "<author>" << XMLEscape(value.C_Str()) << "</author>" << endstr;
|
||||
}
|
||||
|
||||
if (!meta || !meta->Get("AuthoringTool", value))
|
||||
if (nullptr == meta || !meta->Get("AuthoringTool", value)) {
|
||||
mOutput << startstr << "<authoring_tool>" << "Assimp Exporter" << "</authoring_tool>" << endstr;
|
||||
else
|
||||
} else {
|
||||
mOutput << startstr << "<authoring_tool>" << XMLEscape(value.C_Str()) << "</authoring_tool>" << endstr;
|
||||
}
|
||||
|
||||
//mOutput << startstr << "<author>" << mScene->author.C_Str() << "</author>" << endstr;
|
||||
//mOutput << startstr << "<authoring_tool>" << mScene->authoringTool.C_Str() << "</authoring_tool>" << endstr;
|
||||
if (meta) {
|
||||
if (meta->Get("Comments", value)) {
|
||||
mOutput << startstr << "<comments>" << XMLEscape(value.C_Str()) << "</comments>" << endstr;
|
||||
}
|
||||
if (meta->Get("Copyright", value)) {
|
||||
mOutput << startstr << "<copyright>" << XMLEscape(value.C_Str()) << "</copyright>" << endstr;
|
||||
}
|
||||
if (meta->Get("SourceData", value)) {
|
||||
mOutput << startstr << "<source_data>" << XMLEscape(value.C_Str()) << "</source_data>" << endstr;
|
||||
}
|
||||
}
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</contributor>" << endstr;
|
||||
mOutput << startstr << "<created>" << date_str << "</created>" << endstr;
|
||||
|
||||
if (nullptr == meta || !meta->Get("Created", value)) {
|
||||
mOutput << startstr << "<created>" << date_str << "</created>" << endstr;
|
||||
} else {
|
||||
mOutput << startstr << "<created>" << XMLEscape(value.C_Str()) << "</created>" << endstr;
|
||||
}
|
||||
|
||||
// Modified date is always the date saved
|
||||
mOutput << startstr << "<modified>" << date_str << "</modified>" << endstr;
|
||||
|
||||
if (meta) {
|
||||
if (meta->Get("Keywords", value)) {
|
||||
mOutput << startstr << "<keywords>" << XMLEscape(value.C_Str()) << "</keywords>" << endstr;
|
||||
}
|
||||
if (meta->Get("Revision", value)) {
|
||||
mOutput << startstr << "<revision>" << XMLEscape(value.C_Str()) << "</revision>" << endstr;
|
||||
}
|
||||
if (meta->Get("Subject", value)) {
|
||||
mOutput << startstr << "<subject>" << XMLEscape(value.C_Str()) << "</subject>" << endstr;
|
||||
}
|
||||
if (meta->Get("Title", value)) {
|
||||
mOutput << startstr << "<title>" << XMLEscape(value.C_Str()) << "</title>" << endstr;
|
||||
}
|
||||
}
|
||||
|
||||
mOutput << startstr << "<unit name=\"meter\" meter=\"" << scale << "\" />" << endstr;
|
||||
mOutput << startstr << "<up_axis>" << up_axis << "</up_axis>" << endstr;
|
||||
PopTag();
|
||||
@@ -269,18 +304,21 @@ void ColladaExporter::WriteTextures() {
|
||||
static const unsigned int buffer_size = 1024;
|
||||
char str[buffer_size];
|
||||
|
||||
if(mScene->HasTextures()) {
|
||||
if (mScene->HasTextures()) {
|
||||
for(unsigned int i = 0; i < mScene->mNumTextures; i++) {
|
||||
// It would be great to be able to create a directory in portable standard C++, but it's not the case,
|
||||
// so we just write the textures in the current directory.
|
||||
|
||||
aiTexture* texture = mScene->mTextures[i];
|
||||
if ( nullptr == texture ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSIMP_itoa10(str, buffer_size, i + 1);
|
||||
|
||||
std::string name = mFile + "_texture_" + (i < 1000 ? "0" : "") + (i < 100 ? "0" : "") + (i < 10 ? "0" : "") + str + "." + ((const char*) texture->achFormatHint);
|
||||
|
||||
std::unique_ptr<IOStream> outfile(mIOSystem->Open(mPath + name, "wb"));
|
||||
std::unique_ptr<IOStream> outfile(mIOSystem->Open(mPath + mIOSystem->getOsSeparator() + name, "wb"));
|
||||
if(outfile == NULL) {
|
||||
throw DeadlyExportError("could not open output texture file: " + mPath + name);
|
||||
}
|
||||
@@ -428,6 +466,7 @@ void ColladaExporter::WritePointLight(const aiLight *const light){
|
||||
mOutput << startstr << "</point>" << endstr;
|
||||
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteDirectionalLight(const aiLight *const light){
|
||||
const aiColor3D &color= light->mColorDiffuse;
|
||||
mOutput << startstr << "<directional>" << endstr;
|
||||
@@ -440,6 +479,7 @@ void ColladaExporter::WriteDirectionalLight(const aiLight *const light){
|
||||
mOutput << startstr << "</directional>" << endstr;
|
||||
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteSpotLight(const aiLight *const light){
|
||||
|
||||
const aiColor3D &color= light->mColorDiffuse;
|
||||
@@ -496,18 +536,16 @@ void ColladaExporter::WriteAmbienttLight(const aiLight *const light){
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads a single surface entry from the given material keys
|
||||
void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat, aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex)
|
||||
{
|
||||
if( pSrcMat->GetTextureCount( pTexture) > 0 )
|
||||
{
|
||||
void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat,
|
||||
aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex) {
|
||||
if( pSrcMat->GetTextureCount( pTexture) > 0 ) {
|
||||
aiString texfile;
|
||||
unsigned int uvChannel = 0;
|
||||
pSrcMat->GetTexture( pTexture, 0, &texfile, NULL, &uvChannel);
|
||||
|
||||
std::string index_str(texfile.C_Str());
|
||||
|
||||
if(index_str.size() != 0 && index_str[0] == '*')
|
||||
{
|
||||
if(index_str.size() != 0 && index_str[0] == '*') {
|
||||
unsigned int index;
|
||||
|
||||
index_str = index_str.substr(1, std::string::npos);
|
||||
@@ -525,15 +563,13 @@ void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial*
|
||||
} else {
|
||||
throw DeadlyExportError("could not find embedded texture at index " + index_str);
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
poSurface.texture = texfile.C_Str();
|
||||
}
|
||||
|
||||
poSurface.channel = uvChannel;
|
||||
poSurface.exist = true;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
if( pKey )
|
||||
poSurface.exist = pSrcMat->Get( pKey, static_cast<unsigned int>(pType), static_cast<unsigned int>(pIndex), poSurface.color) == aiReturn_SUCCESS;
|
||||
}
|
||||
@@ -541,15 +577,13 @@ void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial*
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reimplementation of isalnum(,C locale), because AppVeyor does not see standard version.
|
||||
static bool isalnum_C(char c)
|
||||
{
|
||||
static bool isalnum_C(char c) {
|
||||
return ( nullptr != strchr("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",c) );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Writes an image entry for the given surface
|
||||
void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::string& pNameAdd)
|
||||
{
|
||||
void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::string& pNameAdd) {
|
||||
if( !pSurface.texture.empty() )
|
||||
{
|
||||
mOutput << startstr << "<image id=\"" << XMLEscape(pNameAdd) << "\">" << endstr;
|
||||
@@ -803,8 +837,9 @@ void ColladaExporter::WriteControllerLibrary()
|
||||
mOutput << startstr << "<library_controllers>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for( size_t a = 0; a < mScene->mNumMeshes; ++a)
|
||||
for( size_t a = 0; a < mScene->mNumMeshes; ++a) {
|
||||
WriteController( a);
|
||||
}
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_controllers>" << endstr;
|
||||
@@ -150,7 +150,6 @@ public:
|
||||
/// Stringstream to write all output into
|
||||
std::stringstream mOutput;
|
||||
|
||||
protected:
|
||||
/// The IOSystem for output
|
||||
IOSystem* mIOSystem;
|
||||
|
||||
@@ -204,7 +203,7 @@ protected:
|
||||
|
||||
std::map<unsigned int, std::string> textures;
|
||||
|
||||
protected:
|
||||
public:
|
||||
/// Dammit C++ - y u no compile two-pass? No I have to add all methods below the struct definitions
|
||||
/// Reads a single surface entry from the given material keys
|
||||
void ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat, aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex);
|
||||
@@ -580,15 +580,11 @@ struct Image
|
||||
{
|
||||
std::string mFileName;
|
||||
|
||||
/** If image file name is zero, embedded image data
|
||||
*/
|
||||
/** Embedded image data */
|
||||
std::vector<uint8_t> mImageData;
|
||||
|
||||
/** If image file name is zero, file format of
|
||||
* embedded image data.
|
||||
*/
|
||||
/** File format hint ofembedded image data */
|
||||
std::string mEmbeddedFormat;
|
||||
|
||||
};
|
||||
|
||||
/** An animation channel. */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -94,20 +94,20 @@ public:
|
||||
public:
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
* See BaseImporter::CanRead() for details. */
|
||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
|
||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
|
||||
|
||||
protected:
|
||||
/** Return importer meta information.
|
||||
* See #BaseImporter::GetInfo for the details
|
||||
*/
|
||||
const aiImporterDesc* GetInfo () const;
|
||||
const aiImporterDesc* GetInfo () const override;
|
||||
|
||||
void SetupProperties(const Importer* pImp);
|
||||
void SetupProperties(const Importer* pImp) override;
|
||||
|
||||
/** Imports the given file into the given scene structure.
|
||||
* See BaseImporter::InternReadFile() for details
|
||||
*/
|
||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
|
||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
|
||||
|
||||
/** Recursively constructs a scene node for the given parser node and returns it. */
|
||||
aiNode* BuildHierarchy( const ColladaParser& pParser, const Collada::Node* pNode);
|
||||
@@ -120,7 +120,7 @@ protected:
|
||||
void BuildMeshesForNode( const ColladaParser& pParser, const Collada::Node* pNode,
|
||||
aiNode* pTarget);
|
||||
|
||||
aiMesh *findMesh(std::string meshid);
|
||||
aiMesh *findMesh(const std::string& meshid);
|
||||
|
||||
/** Creates a mesh for the given ColladaMesh face subset and returns the newly created mesh */
|
||||
aiMesh* CreateMesh( const ColladaParser& pParser, const Collada::Mesh* pSrcMesh, const Collada::SubMesh& pSubMesh,
|
||||
File diff suppressed because it is too large
Load Diff
@@ -54,6 +54,7 @@
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
class ZipArchiveIOSystem;
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
/** Parser helper class for the Collada loader.
|
||||
@@ -66,12 +67,18 @@ namespace Assimp
|
||||
friend class ColladaLoader;
|
||||
|
||||
protected:
|
||||
/** Map for generic metadata as aiString */
|
||||
typedef std::map<std::string, aiString> StringMetaData;
|
||||
|
||||
/** Constructor from XML file */
|
||||
ColladaParser( IOSystem* pIOHandler, const std::string& pFile);
|
||||
|
||||
/** Destructor */
|
||||
~ColladaParser();
|
||||
|
||||
/** Attempts to read the ZAE manifest and returns the DAE to open */
|
||||
static std::string ReadZaeManifest(ZipArchiveIOSystem &zip_archive);
|
||||
|
||||
/** Reads the contents of the file */
|
||||
void ReadContents();
|
||||
|
||||
@@ -81,6 +88,15 @@ namespace Assimp
|
||||
/** Reads asset information such as coordinate system information and legal blah */
|
||||
void ReadAssetInfo();
|
||||
|
||||
/** Reads contributor information such as author and legal blah */
|
||||
void ReadContributorInfo();
|
||||
|
||||
/** Reads generic metadata into provided map */
|
||||
void ReadMetaDataItem(StringMetaData &metadata);
|
||||
|
||||
/** Convert underscore_seperated to CamelCase "authoring_tool" becomes "AuthoringTool" */
|
||||
static void ToCamelCase(std::string &text);
|
||||
|
||||
/** Reads the animation library */
|
||||
void ReadAnimationLibrary();
|
||||
|
||||
@@ -223,6 +239,9 @@ namespace Assimp
|
||||
// Processes bind_vertex_input and bind elements
|
||||
void ReadMaterialVertexInputBinding( Collada::SemanticMappingTable& tbl);
|
||||
|
||||
/** Reads embedded textures from a ZAE archive*/
|
||||
void ReadEmbeddedTextures(ZipArchiveIOSystem &zip_archive);
|
||||
|
||||
protected:
|
||||
/** Aborts the file reading with an exception */
|
||||
AI_WONT_RETURN void ThrowException( const std::string& pError) const AI_WONT_RETURN_SUFFIX;
|
||||
@@ -343,6 +362,9 @@ namespace Assimp
|
||||
/** Which is the up vector */
|
||||
enum { UP_X, UP_Y, UP_Z } mUpDirection;
|
||||
|
||||
/** Asset metadata (global for scene) */
|
||||
StringMetaData mAssetMetaData;
|
||||
|
||||
/** Collada file format version */
|
||||
Collada::FormatVersion mFormat;
|
||||
};
|
||||
@@ -54,7 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/BaseImporter.h>
|
||||
|
||||
#include "CInterfaceIOWrapper.h"
|
||||
#include "CApi/CInterfaceIOWrapper.h"
|
||||
#include "Importer.h"
|
||||
#include "ScenePrivate.h"
|
||||
|
||||
@@ -76,9 +76,25 @@ BaseImporter::~BaseImporter() {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
void BaseImporter::UpdateImporterScale( Importer* pImp )
|
||||
{
|
||||
ai_assert(pImp != nullptr);
|
||||
ai_assert(importerScale != 0.0);
|
||||
ai_assert(fileScale != 0.0);
|
||||
|
||||
double activeScale = importerScale * fileScale;
|
||||
|
||||
// Set active scaling
|
||||
pImp->SetPropertyFloat( AI_CONFIG_APP_SCALE_KEY, static_cast<float>( activeScale) );
|
||||
|
||||
ASSIMP_LOG_DEBUG_F("UpdateImporterScale scale set: %f", activeScale );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file and returns the imported data.
|
||||
aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) {
|
||||
aiScene* BaseImporter::ReadFile(Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) {
|
||||
|
||||
|
||||
m_progress = pImp->GetProgressHandler();
|
||||
if (nullptr == m_progress) {
|
||||
return nullptr;
|
||||
@@ -100,6 +116,11 @@ aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile,
|
||||
{
|
||||
InternReadFile( pFile, sc.get(), &filter);
|
||||
|
||||
// Calculate import scale hook - required because pImp not available anywhere else
|
||||
// passes scale into ScaleProcess
|
||||
UpdateImporterScale(pImp);
|
||||
|
||||
|
||||
} catch( const std::exception& err ) {
|
||||
// extract error description
|
||||
m_ErrorText = err.what();
|
||||
@@ -112,7 +133,7 @@ aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile,
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BaseImporter::SetupProperties(const Importer* /*pImp*/)
|
||||
void BaseImporter::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
// the default implementation does nothing
|
||||
}
|
||||
@@ -320,7 +341,11 @@ std::string BaseImporter::GetExtension( const std::string& file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "../contrib/utf8cpp/source/utf8.h"
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
# include <utf8/utf8.h>
|
||||
#else
|
||||
# include "../contrib/utf8cpp/source/utf8.h"
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert to UTF8 data
|
||||
@@ -584,6 +609,8 @@ aiScene* BatchLoader::GetImport( unsigned int which )
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BatchLoader::LoadAll()
|
||||
{
|
||||
@@ -89,7 +89,7 @@ void BaseProcess::ExecuteOnScene( Importer* pImp)
|
||||
|
||||
// and kill the partially imported data
|
||||
delete pImp->Pimpl()->mScene;
|
||||
pImp->Pimpl()->mScene = NULL;
|
||||
pImp->Pimpl()->mScene = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,6 @@ namespace Assimp {
|
||||
aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh)
|
||||
{
|
||||
aiAnimMesh *animesh = new aiAnimMesh;
|
||||
animesh->mVertices = NULL;
|
||||
animesh->mNormals = NULL;
|
||||
animesh->mTangents = NULL;
|
||||
animesh->mBitangents = NULL;
|
||||
animesh->mNumVertices = mesh->mNumVertices;
|
||||
if (mesh->mVertices) {
|
||||
animesh->mVertices = new aiVector3D[animesh->mNumVertices];
|
||||
@@ -61,83 +61,66 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// maximum path length
|
||||
// XXX http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
|
||||
#ifdef PATH_MAX
|
||||
# define PATHLIMIT PATH_MAX
|
||||
#else
|
||||
# define PATHLIMIT 4096
|
||||
#ifdef _WIN32
|
||||
static std::wstring Utf8ToWide(const char* in)
|
||||
{
|
||||
int size = MultiByteToWideChar(CP_UTF8, 0, in, -1, nullptr, 0);
|
||||
// size includes terminating null; std::wstring adds null automatically
|
||||
std::wstring out(static_cast<size_t>(size) - 1, L'\0');
|
||||
MultiByteToWideChar(CP_UTF8, 0, in, -1, &out[0], size);
|
||||
return out;
|
||||
}
|
||||
|
||||
static std::string WideToUtf8(const wchar_t* in)
|
||||
{
|
||||
int size = WideCharToMultiByte(CP_UTF8, 0, in, -1, nullptr, 0, nullptr, nullptr);
|
||||
// size includes terminating null; std::string adds null automatically
|
||||
std::string out(static_cast<size_t>(size) - 1, '\0');
|
||||
WideCharToMultiByte(CP_UTF8, 0, in, -1, &out[0], size, nullptr, nullptr);
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for the existence of a file at the given path.
|
||||
bool DefaultIOSystem::Exists( const char* pFile) const
|
||||
bool DefaultIOSystem::Exists(const char* pFile) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
wchar_t fileName16[PATHLIMIT];
|
||||
|
||||
#ifndef WindowsStore
|
||||
bool isUnicode = IsTextUnicode(pFile, static_cast<int>(strlen(pFile)), NULL) != 0;
|
||||
if (isUnicode) {
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, pFile, -1, fileName16, PATHLIMIT);
|
||||
struct __stat64 filestat;
|
||||
if (0 != _wstat64(fileName16, &filestat)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
FILE* file = ::fopen(pFile, "rb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
::fclose(file);
|
||||
#ifndef WindowsStore
|
||||
struct __stat64 filestat;
|
||||
if (_wstat64(Utf8ToWide(pFile).c_str(), &filestat) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
FILE* file = ::fopen( pFile, "rb");
|
||||
if( !file)
|
||||
FILE* file = ::fopen(pFile, "rb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
::fclose( file);
|
||||
::fclose(file);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Open a new file with a given path.
|
||||
IOStream* DefaultIOSystem::Open( const char* strFile, const char* strMode)
|
||||
IOStream* DefaultIOSystem::Open(const char* strFile, const char* strMode)
|
||||
{
|
||||
ai_assert(NULL != strFile);
|
||||
ai_assert(NULL != strMode);
|
||||
ai_assert(strFile != nullptr);
|
||||
ai_assert(strMode != nullptr);
|
||||
FILE* file;
|
||||
#ifdef _WIN32
|
||||
wchar_t fileName16[PATHLIMIT];
|
||||
#ifndef WindowsStore
|
||||
bool isUnicode = IsTextUnicode(strFile, static_cast<int>(strlen(strFile)), NULL) != 0;
|
||||
if (isUnicode) {
|
||||
MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, strFile, -1, fileName16, PATHLIMIT);
|
||||
std::string mode8(strMode);
|
||||
file = ::_wfopen(fileName16, std::wstring(mode8.begin(), mode8.end()).c_str());
|
||||
} else {
|
||||
#endif
|
||||
file = ::fopen(strFile, strMode);
|
||||
#ifndef WindowsStore
|
||||
}
|
||||
#endif
|
||||
file = ::_wfopen(Utf8ToWide(strFile).c_str(), Utf8ToWide(strMode).c_str());
|
||||
#else
|
||||
file = ::fopen(strFile, strMode);
|
||||
#endif
|
||||
if (nullptr == file)
|
||||
if (!file)
|
||||
return nullptr;
|
||||
|
||||
return new DefaultIOStream(file, (std::string) strFile);
|
||||
return new DefaultIOStream(file, strFile);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Closes the given file and releases all resources associated with it.
|
||||
void DefaultIOSystem::Close( IOStream* pFile)
|
||||
void DefaultIOSystem::Close(IOStream* pFile)
|
||||
{
|
||||
delete pFile;
|
||||
}
|
||||
@@ -155,78 +138,56 @@ char DefaultIOSystem::getOsSeparator() const
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// IOSystem default implementation (ComparePaths isn't a pure virtual function)
|
||||
bool IOSystem::ComparePaths (const char* one, const char* second) const
|
||||
bool IOSystem::ComparePaths(const char* one, const char* second) const
|
||||
{
|
||||
return !ASSIMP_stricmp(one,second);
|
||||
return !ASSIMP_stricmp(one, second);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert a relative path into an absolute path
|
||||
inline static void MakeAbsolutePath (const char* in, char* _out)
|
||||
inline static std::string MakeAbsolutePath(const char* in)
|
||||
{
|
||||
ai_assert(in && _out);
|
||||
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
||||
#ifndef WindowsStore
|
||||
bool isUnicode = IsTextUnicode(in, static_cast<int>(strlen(in)), NULL) != 0;
|
||||
if (isUnicode) {
|
||||
wchar_t out16[PATHLIMIT];
|
||||
wchar_t in16[PATHLIMIT];
|
||||
MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, in, -1, out16, PATHLIMIT);
|
||||
wchar_t* ret = ::_wfullpath(out16, in16, PATHLIMIT);
|
||||
if (ret) {
|
||||
WideCharToMultiByte(CP_UTF8, MB_PRECOMPOSED, out16, -1, _out, PATHLIMIT, nullptr, nullptr);
|
||||
}
|
||||
if (!ret) {
|
||||
// preserve the input path, maybe someone else is able to fix
|
||||
// the path before it is accessed (e.g. our file system filter)
|
||||
ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in));
|
||||
strcpy(_out, in);
|
||||
}
|
||||
|
||||
} else {
|
||||
#endif
|
||||
char* ret = :: _fullpath(_out, in, PATHLIMIT);
|
||||
if (!ret) {
|
||||
// preserve the input path, maybe someone else is able to fix
|
||||
// the path before it is accessed (e.g. our file system filter)
|
||||
ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in));
|
||||
strcpy(_out, in);
|
||||
}
|
||||
#ifndef WindowsStore
|
||||
ai_assert(in);
|
||||
std::string out;
|
||||
#ifdef _WIN32
|
||||
wchar_t* ret = ::_wfullpath(nullptr, Utf8ToWide(in).c_str(), 0);
|
||||
if (ret) {
|
||||
out = WideToUtf8(ret);
|
||||
free(ret);
|
||||
}
|
||||
#else
|
||||
char* ret = realpath(in, nullptr);
|
||||
if (ret) {
|
||||
out = ret;
|
||||
free(ret);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// use realpath
|
||||
char* ret = realpath(in, _out);
|
||||
if(!ret) {
|
||||
if (!ret) {
|
||||
// preserve the input path, maybe someone else is able to fix
|
||||
// the path before it is accessed (e.g. our file system filter)
|
||||
ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in));
|
||||
strcpy(_out,in);
|
||||
out = in;
|
||||
}
|
||||
#endif
|
||||
return out;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// DefaultIOSystem's more specialized implementation
|
||||
bool DefaultIOSystem::ComparePaths (const char* one, const char* second) const
|
||||
bool DefaultIOSystem::ComparePaths(const char* one, const char* second) const
|
||||
{
|
||||
// chances are quite good both paths are formatted identically,
|
||||
// so we can hopefully return here already
|
||||
if( !ASSIMP_stricmp(one,second) )
|
||||
if (!ASSIMP_stricmp(one, second))
|
||||
return true;
|
||||
|
||||
char temp1[PATHLIMIT];
|
||||
char temp2[PATHLIMIT];
|
||||
std::string temp1 = MakeAbsolutePath(one);
|
||||
std::string temp2 = MakeAbsolutePath(second);
|
||||
|
||||
MakeAbsolutePath (one, temp1);
|
||||
MakeAbsolutePath (second, temp2);
|
||||
|
||||
return !ASSIMP_stricmp(temp1,temp2);
|
||||
return !ASSIMP_stricmp(temp1, temp2);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
std::string DefaultIOSystem::fileName( const std::string &path )
|
||||
std::string DefaultIOSystem::fileName(const std::string& path)
|
||||
{
|
||||
std::string ret = path;
|
||||
std::size_t last = ret.find_last_of("\\/");
|
||||
@@ -235,16 +196,16 @@ std::string DefaultIOSystem::fileName( const std::string &path )
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
std::string DefaultIOSystem::completeBaseName( const std::string &path )
|
||||
std::string DefaultIOSystem::completeBaseName(const std::string& path)
|
||||
{
|
||||
std::string ret = fileName(path);
|
||||
std::size_t pos = ret.find_last_of('.');
|
||||
if(pos != ret.npos) ret = ret.substr(0, pos);
|
||||
if (pos != std::string::npos) ret = ret.substr(0, pos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
std::string DefaultIOSystem::absolutePath( const std::string &path )
|
||||
std::string DefaultIOSystem::absolutePath(const std::string& path)
|
||||
{
|
||||
std::string ret = path;
|
||||
std::size_t last = ret.find_last_of("\\/");
|
||||
@@ -253,5 +214,3 @@ std::string DefaultIOSystem::absolutePath( const std::string &path )
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
#undef PATHLIMIT
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user