Compare commits
1030 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc062305b9 | ||
|
|
bc94269e73 | ||
|
|
876534330a | ||
|
|
2af8ef81b3 | ||
|
|
8da553db58 | ||
|
|
83e9857b30 | ||
|
|
088ed2d472 | ||
|
|
c826b03411 | ||
|
|
f1257994d1 | ||
|
|
efb9e005b2 | ||
|
|
6f30ff31c8 | ||
|
|
d0f38c2d5d | ||
|
|
d4943cc70b | ||
|
|
9a47ea1ef0 | ||
|
|
ac33331fd6 | ||
|
|
a65998bbc1 | ||
|
|
5120c18977 | ||
|
|
21347eaa88 | ||
|
|
a191cc8171 | ||
|
|
ad3d823fa3 | ||
|
|
8d7c00b0d9 | ||
|
|
99d9ea73ac | ||
|
|
c4b0edbfe3 | ||
|
|
6d74d31ecd | ||
|
|
bd22bed2fb | ||
|
|
f8aa17c245 | ||
|
|
6ba20f29d4 | ||
|
|
95ef8d85db | ||
|
|
eca381a5be | ||
|
|
ea47f0bd87 | ||
|
|
b849008ce5 | ||
|
|
5389ac963f | ||
|
|
0fd16d760a | ||
|
|
6754e80c75 | ||
|
|
fb95d8e7a4 | ||
|
|
40efd5fd23 | ||
|
|
d440775775 | ||
|
|
e1d9f26dbd | ||
|
|
ee048d259f | ||
|
|
d7e5f2c26b | ||
|
|
c11a61aa15 | ||
|
|
b859b57797 | ||
|
|
76cca21c65 | ||
|
|
a09c3b154a | ||
|
|
2460f9e721 | ||
|
|
d30429e891 | ||
|
|
c23c3d48b2 | ||
|
|
046809cee0 | ||
|
|
c9750dd633 | ||
|
|
18a0bd70fb | ||
|
|
38955a91e5 | ||
|
|
eac2ad7e05 | ||
|
|
5df53f733e | ||
|
|
50abcf6bfa | ||
|
|
4d41b83448 | ||
|
|
d2324d253c | ||
|
|
cf9e87a892 | ||
|
|
829db244f2 | ||
|
|
772af1e897 | ||
|
|
52a8f50539 | ||
|
|
9f1cadf77a | ||
|
|
308935d706 | ||
|
|
67f75f0ecf | ||
|
|
f728776714 | ||
|
|
10259f80f4 | ||
|
|
c65239aec2 | ||
|
|
0bd9515b3d | ||
|
|
442315aaa8 | ||
|
|
614a7d6de8 | ||
|
|
d28189c173 | ||
|
|
dc75c10014 | ||
|
|
91ff1d87eb | ||
|
|
6b415273ba | ||
|
|
4ce2a03f64 | ||
|
|
f67a71d849 | ||
|
|
55d8d93be9 | ||
|
|
5d57dee18d | ||
|
|
1d1a0c16ba | ||
|
|
71e2434717 | ||
|
|
f876e6165f | ||
|
|
54e224e9fa | ||
|
|
8e76259bac | ||
|
|
13224d9c6e | ||
|
|
34ef2a871f | ||
|
|
6f143b1b54 | ||
|
|
46e85804b1 | ||
|
|
0fe8035309 | ||
|
|
b3feafe320 | ||
|
|
ec623e7c1b | ||
|
|
a38f2754ce | ||
|
|
932d2746f3 | ||
|
|
e176dea383 | ||
|
|
8f15964ee6 | ||
|
|
53a12c3f01 | ||
|
|
2c953b9f08 | ||
|
|
b1cdd5452f | ||
|
|
cb66324095 | ||
|
|
b16dc443ff | ||
|
|
8798d367c5 | ||
|
|
c9921cac3d | ||
|
|
485711f7c6 | ||
|
|
81df9dd705 | ||
|
|
0faa391470 | ||
|
|
cd59d6cd23 | ||
|
|
d46ba48293 | ||
|
|
7d84f97dc1 | ||
|
|
3263c46355 | ||
|
|
44c7d3ac34 | ||
|
|
7dad09dbc4 | ||
|
|
401bc4b486 | ||
|
|
2b1f9290a4 | ||
|
|
90c17ccbad | ||
|
|
f8f947addb | ||
|
|
85449a08fb | ||
|
|
115ce0cb42 | ||
|
|
edc2b49196 | ||
|
|
a47b5c21cf | ||
|
|
ada148b819 | ||
|
|
5d5d9af4df | ||
|
|
064441732e | ||
|
|
7b80b31365 | ||
|
|
b439ddc5f4 | ||
|
|
5b9351354a | ||
|
|
9bcf10cf44 | ||
|
|
ff72598b7d | ||
|
|
79aeaf3250 | ||
|
|
261dafa924 | ||
|
|
90792e7032 | ||
|
|
6e375b1bba | ||
|
|
4d7ab6547c | ||
|
|
58b7084c8b | ||
|
|
d313fe13fb | ||
|
|
4d41c9bde3 | ||
|
|
6c4157767f | ||
|
|
5cceda4155 | ||
|
|
8f45f4ec35 | ||
|
|
f3e5b46bf9 | ||
|
|
497c544f33 | ||
|
|
2e4a825fec | ||
|
|
244c83a77c | ||
|
|
41e5bb4f78 | ||
|
|
2265eca82d | ||
|
|
82c7e4d988 | ||
|
|
793198f96a | ||
|
|
f139589423 | ||
|
|
f929b6cee7 | ||
|
|
4d6f8c281a | ||
|
|
943af435aa | ||
|
|
f028af3186 | ||
|
|
b15abe9e5e | ||
|
|
5281f2a511 | ||
|
|
c2c546d671 | ||
|
|
6fc10c1dda | ||
|
|
80f3afaac6 | ||
|
|
725c978545 | ||
|
|
a9091570b7 | ||
|
|
4e8dac2680 | ||
|
|
da81e857a0 | ||
|
|
111b3320c0 | ||
|
|
665703dbd8 | ||
|
|
8170ca7cd1 | ||
|
|
2df639133b | ||
|
|
fc1d39334f | ||
|
|
af16e43830 | ||
|
|
801c5b57a5 | ||
|
|
19d7a3d21f | ||
|
|
6af77db79d | ||
|
|
efb2f9a1d8 | ||
|
|
3b3f52f48c | ||
|
|
ba5b9c733d | ||
|
|
e009dbbf96 | ||
|
|
073a6c7696 | ||
|
|
b30f6e5332 | ||
|
|
384651e21a | ||
|
|
22dcdc770f | ||
|
|
fd4d6c0d44 | ||
|
|
ca5b52b2ce | ||
|
|
cc4e9db81b | ||
|
|
2bfea16459 | ||
|
|
927662ea4d | ||
|
|
5b2dc1d3de | ||
|
|
097feb0372 | ||
|
|
9cd2971b65 | ||
|
|
fb16516480 | ||
|
|
76027cab85 | ||
|
|
64c95c615a | ||
|
|
31745f6025 | ||
|
|
2a8f04c791 | ||
|
|
3fdecfdefa | ||
|
|
26cbef7452 | ||
|
|
571a9b1ff3 | ||
|
|
b84117eb92 | ||
|
|
6af0c72d0d | ||
|
|
12fde30f31 | ||
|
|
56c2d6338e | ||
|
|
10c8ff352d | ||
|
|
53ea1a00ec | ||
|
|
62a458099a | ||
|
|
826d52bca2 | ||
|
|
299a600377 | ||
|
|
a4ebf23baa | ||
|
|
d23a703ca5 | ||
|
|
2beb9c5588 | ||
|
|
a7fc4d8fbb | ||
|
|
a5dc89b071 | ||
|
|
2bfec9f4af | ||
|
|
1aa7fac8c2 | ||
|
|
c01107fd52 | ||
|
|
5b27361ef0 | ||
|
|
494ddc10e4 | ||
|
|
6151f78d28 | ||
|
|
46c67632c7 | ||
|
|
3f7cf2f971 | ||
|
|
84cc8ff9c8 | ||
|
|
921c2bcd61 | ||
|
|
6ea8ed07ed | ||
|
|
a5addd2257 | ||
|
|
8b1d4ee06a | ||
|
|
3e23d9742b | ||
|
|
847d7dd71a | ||
|
|
10dc3a24e8 | ||
|
|
c6c1cfef3c | ||
|
|
cc8a2f736b | ||
|
|
7fcd3e1a4f | ||
|
|
481fe5a087 | ||
|
|
2d690ac585 | ||
|
|
a118299cfb | ||
|
|
bc01475920 | ||
|
|
56e9d8eda5 | ||
|
|
902e7021fd | ||
|
|
1773c42398 | ||
|
|
ae88536f0c | ||
|
|
b4d6583901 | ||
|
|
b31e420064 | ||
|
|
e4e439e2bf | ||
|
|
a79a83d6da | ||
|
|
50d4dc6499 | ||
|
|
cbc662085e | ||
|
|
02a5541fed | ||
|
|
14248621fe | ||
|
|
8c299d7b0b | ||
|
|
57d6bdff1b | ||
|
|
957ec9be60 | ||
|
|
76147a7231 | ||
|
|
eff3d1a09b | ||
|
|
5f6d7a279c | ||
|
|
9bce361b3e | ||
|
|
925e414e7b | ||
|
|
aeec6f2df5 | ||
|
|
9358650bd4 | ||
|
|
54d44a76a7 | ||
|
|
cc22183f20 | ||
|
|
2ded1c955f | ||
|
|
d955e733bf | ||
|
|
99a501f0c3 | ||
|
|
cdb2b47e0f | ||
|
|
366e20cbe8 | ||
|
|
d5179bd9ed | ||
|
|
12506784da | ||
|
|
4fee4d8da2 | ||
|
|
b1242163f7 | ||
|
|
8cd44fb2e8 | ||
|
|
33a8c9da7e | ||
|
|
37facf7f7b | ||
|
|
1d20973363 | ||
|
|
0cb08cd114 | ||
|
|
c97ba45eed | ||
|
|
74fcc456dc | ||
|
|
b17d606ed2 | ||
|
|
3e97ac5268 | ||
|
|
a7ab0d98fa | ||
|
|
94b4f92bc5 | ||
|
|
77d058cf76 | ||
|
|
52f815e240 | ||
|
|
83b329c123 | ||
|
|
909806b8ce | ||
|
|
d67d5cc267 | ||
|
|
0b95f61549 | ||
|
|
6620edebb3 | ||
|
|
4e4f7fd4ac | ||
|
|
f3769d8e86 | ||
|
|
5caf9b9575 | ||
|
|
6d927f61aa | ||
|
|
65a20df7c1 | ||
|
|
8ba0849bcf | ||
|
|
55abd67e81 | ||
|
|
8cb38344ae | ||
|
|
d90d30d10b | ||
|
|
709c5884ea | ||
|
|
5795bef02a | ||
|
|
1f72b3ac24 | ||
|
|
0949e0a6f3 | ||
|
|
1139209551 | ||
|
|
9c4fecb5c6 | ||
|
|
8142ffdfb7 | ||
|
|
961ad36443 | ||
|
|
11309a8cf2 | ||
|
|
7fadc438ec | ||
|
|
7388aeff55 | ||
|
|
c886d5bcfd | ||
|
|
58187f5c2c | ||
|
|
6129930fb0 | ||
|
|
505bb391c6 | ||
|
|
3483eed412 | ||
|
|
aee938b51e | ||
|
|
ba95e522c4 | ||
|
|
4c4303eacf | ||
|
|
6a7b1e8cb0 | ||
|
|
62cab7710c | ||
|
|
96d34349ec | ||
|
|
e4c6dcf3bc | ||
|
|
0f23633809 | ||
|
|
53adfedc83 | ||
|
|
2f736bee19 | ||
|
|
ae37ace15b | ||
|
|
1aed2379b9 | ||
|
|
f93046308c | ||
|
|
1d514e6bf6 | ||
|
|
62e51649fa | ||
|
|
edb1beac3d | ||
|
|
f441e4ec4e | ||
|
|
70d569029b | ||
|
|
018d6461f5 | ||
|
|
413ce37681 | ||
|
|
9d31b7c008 | ||
|
|
fb004a1990 | ||
|
|
0262a38c7e | ||
|
|
d3f784d4f9 | ||
|
|
475cd80faf | ||
|
|
37ff2d903f | ||
|
|
a900851abc | ||
|
|
3ae91957be | ||
|
|
be11944f99 | ||
|
|
f3a70d82cd | ||
|
|
61423f6900 | ||
|
|
29d2f51fca | ||
|
|
bfaa2bdd4e | ||
|
|
ce4a3edf7b | ||
|
|
6c153b046f | ||
|
|
7a732eb9c4 | ||
|
|
fdfb8862eb | ||
|
|
8df3253955 | ||
|
|
78ec315b69 | ||
|
|
13fc64470a | ||
|
|
97b5d43bd5 | ||
|
|
c2fcb39336 | ||
|
|
4e718f592c | ||
|
|
d780e8b2a0 | ||
|
|
e1b773958f | ||
|
|
326a67acdb | ||
|
|
2c36d0aaae | ||
|
|
1b45f253eb | ||
|
|
7a2b5125ed | ||
|
|
da39dbcb57 | ||
|
|
fab70e878a | ||
|
|
0d2fe62d68 | ||
|
|
bafa62cdec | ||
|
|
fd318826c5 | ||
|
|
5403a19076 | ||
|
|
89c4647c3c | ||
|
|
9befaeb3ae | ||
|
|
122eb8c82e | ||
|
|
81b3f1b244 | ||
|
|
cc89b6ad1e | ||
|
|
0f7aa70f2d | ||
|
|
b7304084d9 | ||
|
|
a99d3b613f | ||
|
|
e896ed9d87 | ||
|
|
975395ce98 | ||
|
|
761b407159 | ||
|
|
5bdbf63ff6 | ||
|
|
d3753ca463 | ||
|
|
ca20ae3851 | ||
|
|
ea6d8dd212 | ||
|
|
92dfeb63dc | ||
|
|
68d6b5718e | ||
|
|
8f1d4ffa4d | ||
|
|
3b2d75e129 | ||
|
|
2d2be0a214 | ||
|
|
1716f9e7cd | ||
|
|
da0d94caf2 | ||
|
|
1b41ef78cd | ||
|
|
83c523256d | ||
|
|
507aeb1e34 | ||
|
|
43115e1f3b | ||
|
|
0a5c068cb6 | ||
|
|
af559a1344 | ||
|
|
0f69dbb0cf | ||
|
|
d7778e29b0 | ||
|
|
9388aab32e | ||
|
|
6d3cbb8d32 | ||
|
|
dd0e0840b8 | ||
|
|
5a5b6720b0 | ||
|
|
a4a26ef528 | ||
|
|
9fe60a6368 | ||
|
|
e2c3dfd341 | ||
|
|
2687bf99d6 | ||
|
|
3d39f64c0d | ||
|
|
60bc860e76 | ||
|
|
2377287890 | ||
|
|
cabdc255f5 | ||
|
|
ac11e2b79a | ||
|
|
8f0fcc4efd | ||
|
|
399f7c24ac | ||
|
|
fdefa16cae | ||
|
|
95b4cdf819 | ||
|
|
517bfc54c5 | ||
|
|
e840e72755 | ||
|
|
992e27c4e0 | ||
|
|
cfb6a1c917 | ||
|
|
0347fb0441 | ||
|
|
24a77023bd | ||
|
|
07be9d1721 | ||
|
|
88f6f4827c | ||
|
|
9a72831a33 | ||
|
|
59f929c7d3 | ||
|
|
f0aab6e46a | ||
|
|
8d7d10ae81 | ||
|
|
c112b3ce40 | ||
|
|
affc947ce0 | ||
|
|
cbfb364c41 | ||
|
|
c84c60112e | ||
|
|
a9ef45dc9a | ||
|
|
bdd3e343ba | ||
|
|
cd364b029c | ||
|
|
3e1ed97187 | ||
|
|
daddc25de8 | ||
|
|
4237ff42c9 | ||
|
|
3291fb6a1b | ||
|
|
f5b47dc95e | ||
|
|
4f6d15d849 | ||
|
|
c35c1b6426 | ||
|
|
80f6f18e54 | ||
|
|
ac8f55099d | ||
|
|
3987da830c | ||
|
|
cbae6120e1 | ||
|
|
011daa952e | ||
|
|
cb98b75400 | ||
|
|
9a87b05570 | ||
|
|
725ea06400 | ||
|
|
facaa3326b | ||
|
|
062ec48ee6 | ||
|
|
6e0dc1dd2c | ||
|
|
64afe136f6 | ||
|
|
e7749c59ce | ||
|
|
841f76f510 | ||
|
|
2e391b01fe | ||
|
|
57fffab7b6 | ||
|
|
45636e5afe | ||
|
|
843372ace3 | ||
|
|
511a11a573 | ||
|
|
13ae670568 | ||
|
|
97850c62c7 | ||
|
|
5b4ec6fd7d | ||
|
|
e4107201a3 | ||
|
|
b9879cf23b | ||
|
|
2bc0e49bc7 | ||
|
|
f6767b59f5 | ||
|
|
5228aba5dd | ||
|
|
9a69a755bc | ||
|
|
c688874064 | ||
|
|
9e6d5f7727 | ||
|
|
59f1fb8956 | ||
|
|
224faeacb6 | ||
|
|
f0465e442f | ||
|
|
849bc91506 | ||
|
|
f15667838b | ||
|
|
9ae2fe84f4 | ||
|
|
0398aa4c67 | ||
|
|
409f95b50a | ||
|
|
510451a35e | ||
|
|
a781fb6f2b | ||
|
|
a429f361b8 | ||
|
|
be5d06d3c8 | ||
|
|
ce6baeb714 | ||
|
|
85122d3fa9 | ||
|
|
5255871f1a | ||
|
|
bd145cf18b | ||
|
|
04859da116 | ||
|
|
1b41a73eb0 | ||
|
|
9081a0b657 | ||
|
|
d87714e4ef | ||
|
|
45fae716de | ||
|
|
8d9ebb7a68 | ||
|
|
15a8828a6c | ||
|
|
ad79bb8532 | ||
|
|
7923964f50 | ||
|
|
7cf121b5c2 | ||
|
|
4da4c07b52 | ||
|
|
524b33aa52 | ||
|
|
657473ae2e | ||
|
|
dba5b05db6 | ||
|
|
b033334cbe | ||
|
|
3f11af49a0 | ||
|
|
3ad41cd20c | ||
|
|
1a7d517d4f | ||
|
|
061bcfc63c | ||
|
|
22be5f17b4 | ||
|
|
e63282c9a2 | ||
|
|
7795de4ac2 | ||
|
|
0cdfbc9524 | ||
|
|
65718ceb81 | ||
|
|
1c81fcb535 | ||
|
|
a9089aef8a | ||
|
|
2f7898e146 | ||
|
|
beb2f74bdc | ||
|
|
44754a9368 | ||
|
|
4671b7c090 | ||
|
|
0bdde49b47 | ||
|
|
ac8d0c78a1 | ||
|
|
88098f99b9 | ||
|
|
4e175421e0 | ||
|
|
8518c52a65 | ||
|
|
af7c3784d6 | ||
|
|
33600aa72c | ||
|
|
c2b54c900a | ||
|
|
4349de5614 | ||
|
|
87e066ae91 | ||
|
|
072c5ffd78 | ||
|
|
ad62b1e4ed | ||
|
|
16374cb11e | ||
|
|
f6480921c0 | ||
|
|
9b0fa727f4 | ||
|
|
7b05d4fdeb | ||
|
|
90c5af3b0e | ||
|
|
1ddfe4b9a9 | ||
|
|
c6e2086e67 | ||
|
|
fe2c5f6a9e | ||
|
|
0a0c2497d5 | ||
|
|
6663f6584b | ||
|
|
23cdb56dcd | ||
|
|
1a313ed299 | ||
|
|
77237fd3fa | ||
|
|
724e9abf96 | ||
|
|
3629a8154c | ||
|
|
37cb9247fd | ||
|
|
9df268b2e1 | ||
|
|
45fdece973 | ||
|
|
bd20d005ce | ||
|
|
dcc17b9b7e | ||
|
|
1634a8a2db | ||
|
|
ff1053523c | ||
|
|
e423611e39 | ||
|
|
5ddbcdf418 | ||
|
|
138c7e091e | ||
|
|
bc381ac1b7 | ||
|
|
147dfec5e5 | ||
|
|
098f8f539d | ||
|
|
230f0e1b2b | ||
|
|
10251821c6 | ||
|
|
ba0bc9e481 | ||
|
|
ccc9606ffc | ||
|
|
ab52a759b8 | ||
|
|
396801b3d0 | ||
|
|
ca7f942b7b | ||
|
|
7b87662db0 | ||
|
|
6374c9ab59 | ||
|
|
6bec21d611 | ||
|
|
c667fd3087 | ||
|
|
9f99904a1f | ||
|
|
84c08d3abc | ||
|
|
b020311c8c | ||
|
|
9a72773c29 | ||
|
|
ab12d1d1bb | ||
|
|
1fc8e8dbeb | ||
|
|
feb7d968b6 | ||
|
|
5366105ed2 | ||
|
|
c92700ce28 | ||
|
|
aa90f7edd6 | ||
|
|
7a106be627 | ||
|
|
01e8154bc8 | ||
|
|
0076de25fa | ||
|
|
5090fe6395 | ||
|
|
abdfc44aa8 | ||
|
|
2eb2f910b1 | ||
|
|
46877abd8c | ||
|
|
e37701c097 | ||
|
|
09cae083b2 | ||
|
|
0b8acb451d | ||
|
|
b26684deed | ||
|
|
639d05374b | ||
|
|
3f0bd4596e | ||
|
|
c0c6b4bea0 | ||
|
|
4bec201717 | ||
|
|
8ec3b62715 | ||
|
|
3ca691cb40 | ||
|
|
570dd8a869 | ||
|
|
9c69b377b7 | ||
|
|
8b7c2159d3 | ||
|
|
25eef9dddb | ||
|
|
25c5bbd624 | ||
|
|
1f183def46 | ||
|
|
a1bce26765 | ||
|
|
395e68a73e | ||
|
|
99e1e37964 | ||
|
|
aad584e521 | ||
|
|
2b5f6cafa6 | ||
|
|
7d31d1a384 | ||
|
|
004ffce334 | ||
|
|
43175adcae | ||
|
|
ab3626570a | ||
|
|
a2fec34c4b | ||
|
|
daba56ee85 | ||
|
|
b66a1184e9 | ||
|
|
0632d7ac3f | ||
|
|
a6aa3934b1 | ||
|
|
e458c94e7f | ||
|
|
b684bdc83d | ||
|
|
3265e0d68e | ||
|
|
48723fb10f | ||
|
|
0ce6c8d8d0 | ||
|
|
2052116a35 | ||
|
|
c6aebd61f6 | ||
|
|
02ed4c6c4d | ||
|
|
e07a634c06 | ||
|
|
9daf7aab64 | ||
|
|
b94c032489 | ||
|
|
4a5323fa53 | ||
|
|
2e22a26ca5 | ||
|
|
861a0bbb8f | ||
|
|
fe35a98c91 | ||
|
|
3b528263e5 | ||
|
|
54fe2a6f2e | ||
|
|
289b889a1a | ||
|
|
67743db2b7 | ||
|
|
ea7e9556c0 | ||
|
|
d25dd6234c | ||
|
|
38e08131bc | ||
|
|
5383174df4 | ||
|
|
8a6881544f | ||
|
|
08457e1f16 | ||
|
|
b4270909c4 | ||
|
|
1c37eb37b6 | ||
|
|
2f34f9f857 | ||
|
|
ee28f0adac | ||
|
|
df9791faaf | ||
|
|
6b39569c14 | ||
|
|
82be8e1553 | ||
|
|
06850cf934 | ||
|
|
e3e7073f74 | ||
|
|
fbcdcc24af | ||
|
|
cc3177ce34 | ||
|
|
c97e812056 | ||
|
|
7bc6b3c818 | ||
|
|
583bfa54d9 | ||
|
|
a8a37a537a | ||
|
|
13d3ade5bb | ||
|
|
54d292bc8a | ||
|
|
43ac656a38 | ||
|
|
f8fc2dd808 | ||
|
|
529c44e548 | ||
|
|
637390ea85 | ||
|
|
69db5134a6 | ||
|
|
0102489748 | ||
|
|
3b827da834 | ||
|
|
ce50ea17c0 | ||
|
|
ca79e9d420 | ||
|
|
fb4e498bc1 | ||
|
|
b44717ae54 | ||
|
|
6e4491c852 | ||
|
|
07bb62490b | ||
|
|
b8f72590bb | ||
|
|
39c63146e0 | ||
|
|
960d1321e6 | ||
|
|
8ffba072b2 | ||
|
|
031ff260f7 | ||
|
|
c78db48b81 | ||
|
|
11eaad7992 | ||
|
|
eda6ea64c8 | ||
|
|
79dec2f8b5 | ||
|
|
41397e1b82 | ||
|
|
31a70d2352 | ||
|
|
98ce5e2f5a | ||
|
|
9d8c000bcc | ||
|
|
d238d7f6f2 | ||
|
|
73af2620f9 | ||
|
|
160297db9c | ||
|
|
8628c43fbf | ||
|
|
af9b3a99e0 | ||
|
|
7a2924738c | ||
|
|
06964a787a | ||
|
|
2e8c01d8aa | ||
|
|
b2738a2c8c | ||
|
|
0e4ca0bc7b | ||
|
|
64f2a580da | ||
|
|
f1f9fde3a4 | ||
|
|
c98ac44827 | ||
|
|
3c2a6d5f8c | ||
|
|
d5178f862a | ||
|
|
4de71f7239 | ||
|
|
302d296949 | ||
|
|
1836377753 | ||
|
|
462251bde6 | ||
|
|
a1eedb95a0 | ||
|
|
b14759a0a4 | ||
|
|
f02fe33070 | ||
|
|
1ccf2d6a08 | ||
|
|
d2afc27703 | ||
|
|
801d24b6e7 | ||
|
|
91738d0513 | ||
|
|
2a72e8aee8 | ||
|
|
b0d640832a | ||
|
|
50d8a8a2d8 | ||
|
|
23fe2cba98 | ||
|
|
906097625e | ||
|
|
8d979a7cb8 | ||
|
|
5ef0247569 | ||
|
|
46e3326b81 | ||
|
|
413f6a97b1 | ||
|
|
1597b6f572 | ||
|
|
dc57eb4b7b | ||
|
|
7d81d9bb51 | ||
|
|
4abe017bc5 | ||
|
|
0f6f53d501 | ||
|
|
084fd95489 | ||
|
|
ff53515295 | ||
|
|
bba42ea81f | ||
|
|
66f6031e2c | ||
|
|
f2ba48f4a7 | ||
|
|
955ab2d2f3 | ||
|
|
561726b938 | ||
|
|
7b3475f1da | ||
|
|
923db48614 | ||
|
|
9558f0d6ca | ||
|
|
3297c9bc78 | ||
|
|
6c75c6436e | ||
|
|
28ebc64fd9 | ||
|
|
3c027b9ea0 | ||
|
|
8861b55d3d | ||
|
|
bb72e796bf | ||
|
|
c5fc7a01e8 | ||
|
|
ee1377fcad | ||
|
|
1aa4eff190 | ||
|
|
16d878186c | ||
|
|
bf93468c3f | ||
|
|
71762cf55e | ||
|
|
a6a4055a0a | ||
|
|
8d484dd762 | ||
|
|
6e7c705c92 | ||
|
|
38facc9038 | ||
|
|
c7848efd86 | ||
|
|
13cd77bc9a | ||
|
|
fa9ba2c592 | ||
|
|
4f22eb44e6 | ||
|
|
4b587a1f6d | ||
|
|
583645a943 | ||
|
|
42875b7809 | ||
|
|
54283291d1 | ||
|
|
9263eda90e | ||
|
|
16cef02441 | ||
|
|
d07222fc3c | ||
|
|
0dd8414844 | ||
|
|
7a5ca724fc | ||
|
|
c8a6a4dd62 | ||
|
|
4d90b9d0f0 | ||
|
|
ebe7b2e182 | ||
|
|
08af0f06bc | ||
|
|
cdbfbcc1e4 | ||
|
|
ced19bde17 | ||
|
|
523e1b957f | ||
|
|
2ec6916f63 | ||
|
|
9d78f1a54e | ||
|
|
1ec8fc16a4 | ||
|
|
705c1969b2 | ||
|
|
ace38eff24 | ||
|
|
6d1e0ed6f4 | ||
|
|
c65e561c59 | ||
|
|
552b1c551f | ||
|
|
b1ba798312 | ||
|
|
e40935dae8 | ||
|
|
38a6d047c9 | ||
|
|
b3284edb36 | ||
|
|
2378e64153 | ||
|
|
186920e8d0 | ||
|
|
d8ca867691 | ||
|
|
5e27fdea68 | ||
|
|
c0e63b24c1 | ||
|
|
8a6de4cff1 | ||
|
|
e56ff75e1b | ||
|
|
147dafb4c1 | ||
|
|
5f6f026648 | ||
|
|
fdee8e2e5c | ||
|
|
e9430dd07f | ||
|
|
538243295c | ||
|
|
fa3f34ea4b | ||
|
|
3faef1f9cb | ||
|
|
d0bab0fa8a | ||
|
|
4738e93b83 | ||
|
|
803c922ac1 | ||
|
|
cc637870b6 | ||
|
|
5c57a18b35 | ||
|
|
d538e71959 | ||
|
|
c1c84f6400 | ||
|
|
84eb9547f5 | ||
|
|
9b5060bb1d | ||
|
|
d22e2f2834 | ||
|
|
52ebfb1665 | ||
|
|
07eda48196 | ||
|
|
b2f19a1879 | ||
|
|
39b9d30d1a | ||
|
|
45beccc68b | ||
|
|
45e7580dc6 | ||
|
|
6f9df5bfab | ||
|
|
91ce2f412b | ||
|
|
e60744a6e4 | ||
|
|
de4abe3295 | ||
|
|
b6ccdc0529 | ||
|
|
28c8f6818e | ||
|
|
8f42e1a812 | ||
|
|
803229bcdc | ||
|
|
c64dae95fa | ||
|
|
630b14d273 | ||
|
|
08a71bf2f0 | ||
|
|
2e917fc8d0 | ||
|
|
26ce90483a | ||
|
|
5b7ad2511e | ||
|
|
42acac02c0 | ||
|
|
d0247f7867 | ||
|
|
529f65d63c | ||
|
|
3b373e5d05 | ||
|
|
6fbecef857 | ||
|
|
e98b413eb5 | ||
|
|
147e4d2189 | ||
|
|
26468d9532 | ||
|
|
6bcceefb04 | ||
|
|
8a850ff908 | ||
|
|
7099682204 | ||
|
|
c5090ead8e | ||
|
|
2e1acaee71 | ||
|
|
a0f8602d02 | ||
|
|
e9c37a356e | ||
|
|
7915bee0df | ||
|
|
ab18e07995 | ||
|
|
f821718171 | ||
|
|
a1f46652d6 | ||
|
|
ac679e0da4 | ||
|
|
be18155996 | ||
|
|
691daeb45d | ||
|
|
40fe6628d0 | ||
|
|
d2f8fa5a36 | ||
|
|
32287aea7f | ||
|
|
8253006899 | ||
|
|
e5eb29dc92 | ||
|
|
a2caea7e88 | ||
|
|
5ee359cf40 | ||
|
|
6089be6de6 | ||
|
|
72a987057e | ||
|
|
4b0f1e8247 | ||
|
|
60d17fff2e | ||
|
|
846f21ce51 | ||
|
|
4327612159 | ||
|
|
714b431cf9 | ||
|
|
83d9ba91e5 | ||
|
|
7381475321 | ||
|
|
d127a718ab | ||
|
|
a827f4528a | ||
|
|
9fd69ec7a9 | ||
|
|
16088760c8 | ||
|
|
8298520f0a | ||
|
|
0595e8f7a6 | ||
|
|
2972060cd0 | ||
|
|
69de626ead | ||
|
|
694d5a397e | ||
|
|
92098d2610 | ||
|
|
0b71691a61 | ||
|
|
6556345941 | ||
|
|
d1aecf864f | ||
|
|
01c2d31484 | ||
|
|
18bff7ef5e | ||
|
|
41a1250598 | ||
|
|
2800f58aa1 | ||
|
|
7ba46ef5f1 | ||
|
|
21f0aa5fb4 | ||
|
|
8bdae79536 | ||
|
|
0bdb6b8a8a | ||
|
|
447f44539f | ||
|
|
0a9be8f9b2 | ||
|
|
d0df2e1336 | ||
|
|
f690d5e69c | ||
|
|
4ffd790fd6 | ||
|
|
c29fcc7668 | ||
|
|
ae6ab66af4 | ||
|
|
7be3994c96 | ||
|
|
836b641bff | ||
|
|
44bfac85e9 | ||
|
|
a141abd212 | ||
|
|
12aba0f1b7 | ||
|
|
40666bdd23 | ||
|
|
66d71be300 | ||
|
|
614a832be0 | ||
|
|
92de93bfb8 | ||
|
|
c1b7f2ac27 | ||
|
|
6110809d23 | ||
|
|
81a52411ed | ||
|
|
6956154d62 | ||
|
|
9940a68165 | ||
|
|
c3d957671d | ||
|
|
fbb7e1f2ef | ||
|
|
6e90d73e24 | ||
|
|
07c1dbb5f4 | ||
|
|
4e0749f0ae | ||
|
|
f5bd28b7df | ||
|
|
ad4c4148f4 | ||
|
|
a35762bdf2 | ||
|
|
1ca2b1b642 | ||
|
|
373e519292 | ||
|
|
acea32aae8 | ||
|
|
150fd321bc | ||
|
|
1bbe203a15 | ||
|
|
37201e742f | ||
|
|
ba8adc2d49 | ||
|
|
d3efbd810e | ||
|
|
91c946cfbd | ||
|
|
98d39b7e7e | ||
|
|
e7169cb889 | ||
|
|
8f70f8f879 | ||
|
|
8c6ac11c2d | ||
|
|
d9bebaa8e7 | ||
|
|
5baa699c7c | ||
|
|
8c8cfb6528 | ||
|
|
f1c6acafff | ||
|
|
03161226f2 | ||
|
|
4d0859b266 | ||
|
|
896c85c324 | ||
|
|
49f1464016 | ||
|
|
c8b3544a36 | ||
|
|
321845d04a | ||
|
|
a31928600e | ||
|
|
f3752a42c8 | ||
|
|
2f35f26148 | ||
|
|
d47e6f9456 | ||
|
|
6bb385f354 | ||
|
|
dd7af66516 | ||
|
|
04f3268961 | ||
|
|
a3c939894c | ||
|
|
b460d2f547 | ||
|
|
9ea81bc2fd | ||
|
|
cebc83e8fa | ||
|
|
b3cd6a7f59 | ||
|
|
c8f5190099 | ||
|
|
28ab087f79 | ||
|
|
e66aeb0c94 | ||
|
|
749817b64b | ||
|
|
1b18724b6b | ||
|
|
ff5a2a7a99 | ||
|
|
125f79e5e0 | ||
|
|
fac084dfdf | ||
|
|
f8ebc047e0 | ||
|
|
00f6fa24f7 | ||
|
|
0394aeb23b | ||
|
|
c4989da047 | ||
|
|
60363e518d | ||
|
|
2a74397101 | ||
|
|
0cccbda9b9 | ||
|
|
0c1fdc88ec | ||
|
|
8228deb209 | ||
|
|
8029ad5cc3 | ||
|
|
045274bbdb | ||
|
|
206512add0 | ||
|
|
f876171239 | ||
|
|
f96501215b | ||
|
|
0158e7e858 | ||
|
|
c6444fb502 | ||
|
|
60d304a83b | ||
|
|
422bf8631b | ||
|
|
013d735242 | ||
|
|
3be10d816a | ||
|
|
9ce88e6e23 | ||
|
|
83c40e6664 | ||
|
|
28f2806beb | ||
|
|
d37e21f4ea | ||
|
|
d113af8afb | ||
|
|
f676d3d3ea | ||
|
|
cd2786a2ef | ||
|
|
5ea35ab87e | ||
|
|
c21d11e20f | ||
|
|
8fe11a067d | ||
|
|
67ffa91843 | ||
|
|
55fbb300ca | ||
|
|
4901f6f72a | ||
|
|
cfb9c03226 | ||
|
|
d6de2bf426 | ||
|
|
b5eb00bdb1 | ||
|
|
ede9f7fdbb | ||
|
|
eaf790aaa7 | ||
|
|
02b0eb3ae2 | ||
|
|
e38870ebf5 | ||
|
|
8ae1b06bce | ||
|
|
380e3fa690 | ||
|
|
2d6b43827e | ||
|
|
d135108763 | ||
|
|
73e1bfb134 | ||
|
|
b81349b227 | ||
|
|
71df133053 | ||
|
|
42fd0f5dad | ||
|
|
ff74255e6e | ||
|
|
2529a34c36 | ||
|
|
b291e11b90 | ||
|
|
85a649b239 | ||
|
|
b96867e03a | ||
|
|
23e2e2a9bd | ||
|
|
e624dff037 | ||
|
|
025f4a54f5 | ||
|
|
b375d029d2 | ||
|
|
40298f3cc0 | ||
|
|
a38c40cf11 | ||
|
|
3c8b7e537c | ||
|
|
ab3dddeb78 | ||
|
|
cd00c4bbe8 | ||
|
|
1dfc7fd5ae | ||
|
|
f9cc118bdb | ||
|
|
418aebb2a0 | ||
|
|
96c0e999ae | ||
|
|
8dda07bf2c | ||
|
|
76b15e895a | ||
|
|
e3d0630704 | ||
|
|
e41dd027ab | ||
|
|
3c89f901af | ||
|
|
6ae21d3825 | ||
|
|
866c694977 | ||
|
|
c11d6e549a | ||
|
|
4789e81ebc | ||
|
|
a042cc7b8b | ||
|
|
4d9788ffb9 | ||
|
|
5bbdc673f2 | ||
|
|
4be93cbdd6 | ||
|
|
556baee70c | ||
|
|
2633edf2c4 | ||
|
|
1feb07ba8b | ||
|
|
083a60938e |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,3 +9,5 @@ dist-*
|
||||
toolchains
|
||||
filament/docs/html/**
|
||||
.vscode
|
||||
gltf_baker.ini
|
||||
*tmp*.png
|
||||
|
||||
209
CMakeLists.txt
209
CMakeLists.txt
@@ -1,7 +1,7 @@
|
||||
# ==================================================================================================
|
||||
# CMake
|
||||
# ==================================================================================================
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# ==================================================================================================
|
||||
# Project declaration
|
||||
@@ -16,6 +16,10 @@ option(ENABLE_JAVA "Compile Java projects, requires a JDK and the JAVA_HOME env
|
||||
|
||||
option(USE_EXTERNAL_GLES3 "Experimental: Compile Filament against OpenGL ES 3" OFF)
|
||||
|
||||
option(GENERATE_JS_DOCS "Build WebGL documentation and tutorials" OFF)
|
||||
|
||||
option(ENABLE_LTO "Enable link-time optimizations if supported by the compiler" OFF)
|
||||
|
||||
# ==================================================================================================
|
||||
# OS specific
|
||||
# ==================================================================================================
|
||||
@@ -23,26 +27,66 @@ if (UNIX AND NOT APPLE AND NOT ANDROID AND NOT WEBGL)
|
||||
set(LINUX TRUE)
|
||||
endif()
|
||||
|
||||
if (ANDROID OR WEBGL OR IOS)
|
||||
set(IS_MOBILE_TARGET TRUE)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
# Link statically against c/c++ lib to avoid missing redistriburable such as
|
||||
# "VCRUNTIME140.dll not found. Try reinstalling the app.", but give users
|
||||
# a choice to opt for the shared runtime if they want.
|
||||
option(USE_STATIC_CRT "Link against the static runtime libraries." ON)
|
||||
|
||||
# On Windows we need to instruct cmake to generate the .def in order to get the .lib required
|
||||
# when linking against dlls. CL.EXE will not generate .lib without .def file (or without pragma
|
||||
# __declspec(dllexport) in front of each functions).
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
||||
if (${USE_STATIC_CRT})
|
||||
set(CRT_FLAGS_RELEASE "/MT")
|
||||
set(CRT_FLAGS_DEBUG "/MTd")
|
||||
else()
|
||||
set(CRT_FLAGS_RELEASE "/MD")
|
||||
set(CRT_FLAGS_DEBUG "/MDd")
|
||||
endif()
|
||||
|
||||
# TODO: Figure out why pdb generation messes with incremental compilaton.
|
||||
# IN RELEASE_WITH_DEBUG_INFO, generate debug info in .obj, no in pdb.
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Z7")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Z7")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7")
|
||||
|
||||
# In RELEASE, link statically against c/c++ lib to avoid missing redistriburable such as
|
||||
# "VCRUNTIME140.dll not found. Try reinstalling the app.". Also generate PDBs.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /Zi")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT /Zi")
|
||||
# In RELEASE, also generate PDBs.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CRT_FLAGS_RELEASE} /Zi")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CRT_FLAGS_RELEASE} /Zi")
|
||||
|
||||
# In DEBUG, avoid generating a PDB file which seems to mess with incremental compilation.
|
||||
# Instead generate debug info directly inside obj files.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Check if embree is available.
|
||||
# This is an optional dependency and can be installed with homebrew, apt-get, etc.
|
||||
# ==================================================================================================
|
||||
|
||||
find_package(embree 3.0 QUIET PATHS /usr/lib64/cmake)
|
||||
if (embree_FOUND AND NOT ANDROID)
|
||||
message("Found embree in ${embree_DIR}")
|
||||
set(MKLDNN_THREADING "TBB")
|
||||
include(third_party/OpenImageDenoise/cmake/resource.cmake)
|
||||
include(third_party/OpenImageDenoise/mkl-dnn/cmake/Threading.cmake)
|
||||
include(third_party/OpenImageDenoise/mkl-dnn/cmake/TBB.cmake)
|
||||
find_package(TBB QUIET)
|
||||
if (TBB_FOUND AND "${TBB_VERSION_MAJOR}" VERSION_EQUAL 2019)
|
||||
message("Found TBB ${TBB_VERSION}")
|
||||
add_definitions(-DFILAMENT_HAS_EMBREE)
|
||||
set(DENOISE_LIBRARY OpenImageDenoise)
|
||||
else()
|
||||
message("TBB 2019 not found.")
|
||||
endif()
|
||||
else()
|
||||
message("Embree not found, pipeline features are disabled.")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -63,7 +107,7 @@ set(TOOLS ${CMAKE_CURRENT_SOURCE_DIR}/tools)
|
||||
# ==================================================================================================
|
||||
# Compiler check
|
||||
# ==================================================================================================
|
||||
set(MIN_CLANG_VERSION "5.0")
|
||||
set(MIN_CLANG_VERSION "6.0")
|
||||
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION)
|
||||
@@ -86,6 +130,20 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" S
|
||||
set(CLANG_CL true)
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Link time optimizations (LTO)
|
||||
# ==================================================================================================
|
||||
if (ENABLE_LTO)
|
||||
include(CheckIPOSupported)
|
||||
|
||||
check_ipo_supported(RESULT IPO_SUPPORT)
|
||||
|
||||
if (IPO_SUPPORT)
|
||||
message(STATUS "LTO support is enabled")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# General compiler flags
|
||||
# ==================================================================================================
|
||||
@@ -106,18 +164,9 @@ endif()
|
||||
|
||||
if (LINUX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
if (FILAMENT_REQUIRES_CXXABI)
|
||||
# Required in CI environment with custom libc++ and libc++abi
|
||||
link_libraries("-lc++abi")
|
||||
endif()
|
||||
# To distribute our binaries, we must remove the dependency on libc++ and libgcc.
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
link_libraries("-static-libgcc -static-libstdc++")
|
||||
endif()
|
||||
else()
|
||||
if (FILAMENT_REQUIRES_CXXABI)
|
||||
message("The option FILAMENT_REQUIRES_CXXABI is unsupported on this platform")
|
||||
endif()
|
||||
link_libraries("-static-libgcc -static-libstdc++")
|
||||
link_libraries(libc++.a)
|
||||
link_libraries(libc++abi.a)
|
||||
endif()
|
||||
|
||||
if (CYGWIN)
|
||||
@@ -147,7 +196,7 @@ endif()
|
||||
# On Android RELEASE builds, we disable exceptions and RTTI to save some space (about 75 KiB
|
||||
# saved by -fno-exception and 10 KiB saved by -fno-rtti).
|
||||
if (ANDROID OR WEBGL)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-rtti")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -157,6 +206,10 @@ endif()
|
||||
# -fsanitize=undefined causes extremely long link times
|
||||
# -fsanitize=address causes a crash with assimp, which we can't explain for now
|
||||
#set(EXTRA_SANITIZE_OPTIONS "-fsanitize=undefined -fsanitize=address")
|
||||
# clang-cl.exe on Windows does not support -fstack-protector.
|
||||
if (NOT CLANG_CL)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${EXTRA_SANITIZE_OPTIONS}")
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -200,8 +253,7 @@ endif()
|
||||
# By default, build with Vulkan support on desktop platforms, although clients must request to use
|
||||
# it at run time. On Android, the build does not include Vulkan support unless CMake is invoked
|
||||
# with -DFILAMENT_SUPPORTS_VULKAN=ON.
|
||||
# Vulkan is not supported on Windows.
|
||||
if (ANDROID OR WIN32 OR WEBGL)
|
||||
if (ANDROID OR WIN32 OR WEBGL OR IOS)
|
||||
option(FILAMENT_SUPPORTS_VULKAN "Include the Vulkan backend" OFF)
|
||||
else()
|
||||
option(FILAMENT_SUPPORTS_VULKAN "Include the Vulkan backend" ON)
|
||||
@@ -210,6 +262,54 @@ if (FILAMENT_SUPPORTS_VULKAN)
|
||||
add_definitions(-DFILAMENT_DRIVER_SUPPORTS_VULKAN)
|
||||
endif()
|
||||
|
||||
# Build with Metal support on non-WebGL Apple platforms.
|
||||
# Apple's simulator does not support Metal.
|
||||
if (APPLE AND (NOT IOS OR IOS_ARCH STREQUAL "arm64") AND NOT WEBGL)
|
||||
option(FILAMENT_SUPPORTS_METAL "Include the Metal backend" ON)
|
||||
else()
|
||||
option(FILAMENT_SUPPORTS_METAL "Include the Metal backend" OFF)
|
||||
endif()
|
||||
if (FILAMENT_SUPPORTS_METAL)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_METAL)
|
||||
endif()
|
||||
|
||||
# Building filamat increases build times and isn't required for web, so turn it off by default.
|
||||
if (NOT WEBGL)
|
||||
option(FILAMENT_BUILD_FILAMAT "Build filamat and JNI buildings" ON)
|
||||
else()
|
||||
option(FILAMENT_BUILD_FILAMAT "Build filamat and JNI buildings" OFF)
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Material compilation flags
|
||||
# ==================================================================================================
|
||||
|
||||
# Target system.
|
||||
if (IS_MOBILE_TARGET)
|
||||
set(MATC_TARGET mobile)
|
||||
else()
|
||||
set(MATC_TARGET desktop)
|
||||
endif()
|
||||
|
||||
set(MATC_API_FLAGS )
|
||||
|
||||
# TODO: Add a flag to build Filament without support for OpenGL.
|
||||
set(MATC_API_FLAGS ${MATC_API_FLAGS} -a opengl)
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
set(MATC_API_FLAGS ${MATC_API_FLAGS} -a vulkan)
|
||||
endif()
|
||||
if (FILAMENT_SUPPORTS_METAL)
|
||||
set(MATC_API_FLAGS ${MATC_API_FLAGS} -a metal)
|
||||
endif()
|
||||
|
||||
# Only optimize materials in Release mode (so error message lines match the source code)
|
||||
if (NOT CMAKE_BUILD_TYPE MATCHES Release)
|
||||
set(MATC_OPT_FLAGS -g)
|
||||
endif()
|
||||
|
||||
set(MATC_BASE_FLAGS ${MATC_API_FLAGS} -p ${MATC_TARGET} ${MATC_OPT_FLAGS})
|
||||
|
||||
# ==================================================================================================
|
||||
# Distribution
|
||||
# ==================================================================================================
|
||||
@@ -267,7 +367,9 @@ endif()
|
||||
# ==================================================================================================
|
||||
|
||||
# Sets the following variables: RESGEN_HEADER, RESGEN_SOURCE, RESGEN_FLAGS, RESGEN_SOURCE_FLAGS,
|
||||
# and RESGEN_OUTPUTS
|
||||
# and RESGEN_OUTPUTS. Please pass in an ARCHIVE_NAME that is unique to your project, otherwise the
|
||||
# incbin directive will happily consume a blob from the wrong project without warnings or errors.
|
||||
# Also be sure to include the ASM language in the CMake "project" directive for your project.
|
||||
function(get_resgen_vars ARCHIVE_DIR ARCHIVE_NAME)
|
||||
set(OUTPUTS
|
||||
${ARCHIVE_DIR}/${ARCHIVE_NAME}.bin
|
||||
@@ -275,19 +377,20 @@ function(get_resgen_vars ARCHIVE_DIR ARCHIVE_NAME)
|
||||
${ARCHIVE_DIR}/${ARCHIVE_NAME}.apple.S
|
||||
${ARCHIVE_DIR}/${ARCHIVE_NAME}.h
|
||||
)
|
||||
if (NOT WIN32)
|
||||
if (IOS)
|
||||
set(ASM_ARCH_FLAG "-arch ${DIST_ARCH}")
|
||||
endif()
|
||||
if (APPLE)
|
||||
set(ASM_SUFFIX ".apple")
|
||||
endif()
|
||||
if (WEBGL)
|
||||
set(RESGEN_HEADER "${ARCHIVE_DIR}/${ARCHIVE_NAME}.h" PARENT_SCOPE)
|
||||
set(RESGEN_HEADER "${ARCHIVE_DIR}/${ARCHIVE_NAME}.h" PARENT_SCOPE)
|
||||
# Visual Studio makes it difficult to use assembly without using MASM. MASM doesn't support
|
||||
# the equivalent of .incbin, so on Windows we'll just tell resgen to output a C file.
|
||||
if (WEBGL OR WIN32 OR ANDROID_ON_WINDOWS)
|
||||
set(RESGEN_OUTPUTS "${OUTPUTS};${ARCHIVE_DIR}/${ARCHIVE_NAME}.c" PARENT_SCOPE)
|
||||
set(RESGEN_FLAGS -cx ${ARCHIVE_DIR} -p ${ARCHIVE_NAME} PARENT_SCOPE)
|
||||
set(RESGEN_SOURCE "${ARCHIVE_DIR}/${ARCHIVE_NAME}.c" PARENT_SCOPE)
|
||||
else()
|
||||
set(RESGEN_HEADER "${ARCHIVE_DIR}/${ARCHIVE_NAME}.h" PARENT_SCOPE)
|
||||
set(RESGEN_OUTPUTS "${OUTPUTS}" PARENT_SCOPE)
|
||||
set(RESGEN_FLAGS -x ${ARCHIVE_DIR} -p ${ARCHIVE_NAME} PARENT_SCOPE)
|
||||
set(RESGEN_SOURCE "${ARCHIVE_DIR}/${ARCHIVE_NAME}${ASM_SUFFIX}.S" PARENT_SCOPE)
|
||||
@@ -298,27 +401,38 @@ endfunction()
|
||||
# ==================================================================================================
|
||||
# Sub-projects
|
||||
# ==================================================================================================
|
||||
# spirv-tools must come before filamat, as filamat relies on the presence of the
|
||||
# spirv-tools_SOURCE_DIR variable.
|
||||
add_subdirectory(${EXTERNAL}/spirv-tools)
|
||||
add_subdirectory(${EXTERNAL}/glslang/tnt)
|
||||
add_subdirectory(${EXTERNAL}/spirv-cross/tnt)
|
||||
|
||||
# Common to all platforms
|
||||
add_subdirectory(${EXTERNAL}/libgtest/tnt)
|
||||
add_subdirectory(${LIBRARIES}/filabridge)
|
||||
add_subdirectory(${LIBRARIES}/filaflat)
|
||||
add_subdirectory(${LIBRARIES}/filamat)
|
||||
add_subdirectory(${LIBRARIES}/filameshio)
|
||||
add_subdirectory(${LIBRARIES}/geometry)
|
||||
add_subdirectory(${LIBRARIES}/gltfio)
|
||||
add_subdirectory(${LIBRARIES}/ibl)
|
||||
add_subdirectory(${LIBRARIES}/image)
|
||||
add_subdirectory(${LIBRARIES}/rays)
|
||||
add_subdirectory(${LIBRARIES}/math)
|
||||
add_subdirectory(${LIBRARIES}/utils)
|
||||
add_subdirectory(${FILAMENT}/filament)
|
||||
add_subdirectory(${FILAMENT}/shaders)
|
||||
add_subdirectory(${EXTERNAL}/civetweb/tnt)
|
||||
add_subdirectory(${EXTERNAL}/robin-map/tnt)
|
||||
add_subdirectory(${EXTERNAL}/smol-v/tnt)
|
||||
add_subdirectory(${EXTERNAL}/benchmark/tnt)
|
||||
add_subdirectory(${EXTERNAL}/meshoptimizer)
|
||||
add_subdirectory(${EXTERNAL}/cgltf/tnt)
|
||||
add_subdirectory(${EXTERNAL}/xatlas/tnt)
|
||||
add_subdirectory(${EXTERNAL}/stb/tnt)
|
||||
|
||||
if (FILAMENT_BUILD_FILAMAT)
|
||||
# spirv-tools must come before filamat, as filamat relies on the presence of the
|
||||
# spirv-tools_SOURCE_DIR variable.
|
||||
add_subdirectory(${EXTERNAL}/spirv-tools)
|
||||
add_subdirectory(${EXTERNAL}/glslang/tnt)
|
||||
add_subdirectory(${EXTERNAL}/spirv-cross/tnt)
|
||||
add_subdirectory(${LIBRARIES}/filamat)
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
add_subdirectory(${LIBRARIES}/bluevk)
|
||||
@@ -334,20 +448,24 @@ set (FILAMENT_SAMPLES_BINARY_DIR ${PROJECT_BINARY_DIR}/samples)
|
||||
if (WEBGL)
|
||||
add_subdirectory(web/filament-js)
|
||||
add_subdirectory(web/samples)
|
||||
add_subdirectory(web/docs)
|
||||
|
||||
if (GENERATE_JS_DOCS)
|
||||
add_subdirectory(web/docs)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${EXTERNAL}/imgui/tnt)
|
||||
add_subdirectory(${EXTERNAL}/stb/tnt)
|
||||
endif()
|
||||
|
||||
if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
|
||||
add_subdirectory(${FILAMENT}/samples)
|
||||
|
||||
add_subdirectory(${LIBRARIES}/bluegl)
|
||||
add_subdirectory(${LIBRARIES}/filagui)
|
||||
add_subdirectory(${LIBRARIES}/imageio)
|
||||
add_subdirectory(${LIBRARIES}/matdbg)
|
||||
|
||||
add_subdirectory(${FILAMENT}/java/filamat)
|
||||
add_subdirectory(${FILAMENT}/java/filament)
|
||||
add_subdirectory(${FILAMENT}/samples)
|
||||
|
||||
add_subdirectory(${FILAMENT}/java)
|
||||
add_subdirectory(${EXTERNAL}/astcenc/tnt)
|
||||
add_subdirectory(${EXTERNAL}/etc2comp)
|
||||
add_subdirectory(${EXTERNAL}/getopt)
|
||||
@@ -357,11 +475,10 @@ if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
|
||||
add_subdirectory(${EXTERNAL}/libsdl2/tnt)
|
||||
add_subdirectory(${EXTERNAL}/libz/tnt)
|
||||
add_subdirectory(${EXTERNAL}/skylight/tnt)
|
||||
add_subdirectory(${EXTERNAL}/stb/tnt)
|
||||
add_subdirectory(${EXTERNAL}/tinyexr/tnt)
|
||||
|
||||
add_subdirectory(${TOOLS}/cmgen)
|
||||
add_subdirectory(${TOOLS}/filamesh)
|
||||
add_subdirectory(${TOOLS}/glslminifier)
|
||||
add_subdirectory(${TOOLS}/matc)
|
||||
add_subdirectory(${TOOLS}/matinfo)
|
||||
add_subdirectory(${TOOLS}/mipgen)
|
||||
@@ -372,7 +489,11 @@ if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
|
||||
add_subdirectory(${TOOLS}/specular-color)
|
||||
endif()
|
||||
|
||||
if (DENOISE_LIBRARY)
|
||||
add_subdirectory(${EXTERNAL}/OpenImageDenoise/tnt)
|
||||
endif()
|
||||
|
||||
# Generate exported executables for cross-compiled builds (Android, WebGL, and iOS)
|
||||
if (NOT CMAKE_CROSSCOMPILING)
|
||||
export(TARGETS matc cmgen filamesh mipgen resgen FILE ${IMPORT_EXECUTABLES})
|
||||
export(TARGETS matc cmgen filamesh mipgen resgen glslminifier FILE ${IMPORT_EXECUTABLES})
|
||||
endif()
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
private:
|
||||
int mAttributeName;
|
||||
static int sGlobalAttribute;
|
||||
staric constexpr int FOO_COUNT = 10;
|
||||
static constexpr int FOO_COUNT = 10;
|
||||
enum {
|
||||
ONE, TWO, THREE
|
||||
};
|
||||
@@ -171,7 +171,7 @@ private:
|
||||
|
||||
### Misc
|
||||
|
||||
- Use `auto` only when the type appears on the same line or with iterators
|
||||
- Use `auto` only when the type appears on the same line or with iterators and lambdas.
|
||||
```
|
||||
auto foo = new Foo();
|
||||
for (auto& i : collection) { }
|
||||
|
||||
@@ -20,7 +20,7 @@ again.
|
||||
Contributor License Agreement (see details above).
|
||||
1. Fork the desired repo, develop and test your code changes.
|
||||
1. Ensure that your code adheres to the existing style in the sample to which
|
||||
you are contributing. Refer to [CodeStyle.md](/CodeStyle.md) for the recommended coding
|
||||
you are contributing. Refer to [CodeStyle.md](/CODE_STYLE.md) for the recommended coding
|
||||
standards for this project.
|
||||
1. Ensure that your code has an appropriate set of unit tests which all pass.
|
||||
1. Submit a pull request.
|
||||
|
||||
206
README.md
206
README.md
@@ -18,16 +18,19 @@ Android devices and as the renderer inside the Android Studio plugin.
|
||||
|
||||
[Download Filament releases](https://github.com/google/filament/releases) to access stable builds.
|
||||
|
||||
Make sure you always use tools from the same release as the runtime library. This is particularly
|
||||
important for `matc` (material compiler).
|
||||
|
||||
If you prefer to live on the edge, you can download a continuous build by clicking one of the build
|
||||
badges above.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Filament](https://google.github.io/filament/Filament.md.html), an in-depth explanation of
|
||||
- [Filament](https://google.github.io/filament/Filament.html), an in-depth explanation of
|
||||
real-time physically based rendering, the graphics capabilities and implementation of Filament.
|
||||
This document explains the math and reasoning behind most of our decisions. This document is a
|
||||
good introduction to PBR for graphics programmers.
|
||||
- [Materials](https://google.github.io/filament/Materials.md.html), the full reference
|
||||
- [Materials](https://google.github.io/filament/Materials.html), the full reference
|
||||
documentation for our material system. This document explains our different material models, how
|
||||
to use the material compiler `matc` and how to write custom materials.
|
||||
- [Material Properties](https://google.github.io/filament/Material%20Properties.pdf), a reference
|
||||
@@ -40,13 +43,23 @@ Here are a few sample materials rendered with Filament:
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Applications
|
||||
|
||||
Here are a few screenshots of applications that use Filament in production:
|
||||
|
||||
### Google Maps AR Navigation
|
||||
|
||||

|
||||
|
||||
### Google Search 3D/AR Viewer on Android
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
### APIs
|
||||
@@ -59,6 +72,7 @@ Here are a few sample materials rendered with Filament:
|
||||
|
||||
- OpenGL 4.1+ for Linux, macOS and Windows
|
||||
- OpenGL ES 3.0+ for Android and iOS
|
||||
- Metal for macOS and iOS
|
||||
- Vulkan 1.0 for Android, Linux, macOS and iOS (with MoltenVk), and Windows
|
||||
- WebGL 2.0 for all platforms
|
||||
|
||||
@@ -71,23 +85,24 @@ Here are a few sample materials rendered with Filament:
|
||||
- Metallic workflow
|
||||
- Clear coat
|
||||
- Anisotropic lighting
|
||||
- Approximated translucent (subsurface) materials (direct and indirect lighting)
|
||||
- Approximated translucent (subsurface) materials
|
||||
- Cloth shading
|
||||
- Normal mapping & ambient occlusion mapping
|
||||
- Image-based lighting
|
||||
- Physically-based camera (shutter speed, sensitivity and aperture)
|
||||
- Physical light units
|
||||
- Point light, spot light and directional light
|
||||
- SSAO
|
||||
- ACES-like tone-mapping
|
||||
- Temporal dithering
|
||||
- FXAA or MSAA
|
||||
- Dynamic resolution (on Android)
|
||||
- FXAA, MSAA and specular anti-aliasing
|
||||
- Dynamic resolution (on Android and iOS)
|
||||
|
||||
### Future
|
||||
|
||||
Many other features have been either prototyped or planned:
|
||||
|
||||
- IES light profiles
|
||||
- IES light profiles/cookies
|
||||
- Area lights
|
||||
- Fog
|
||||
- Color grading
|
||||
@@ -102,6 +117,7 @@ and tools.
|
||||
|
||||
- `android`: Android libraries and projects
|
||||
- `build`: Custom Gradle tasks for Android builds
|
||||
- `filamat-android`: Filament material generation library (AAR) for Android
|
||||
- `filament-android`: Filament library (AAR) for Android
|
||||
- `samples`: Android-specific Filament samples
|
||||
- `art`: Source for various artworks (logos, PDF manuals, etc.)
|
||||
@@ -120,19 +136,25 @@ and tools.
|
||||
- `filaflat`: Serialization/deserialization library used for materials
|
||||
- `filagui`: Helper library for [Dear ImGui](https://github.com/ocornut/imgui)
|
||||
- `filamat`: Material generation library
|
||||
- `filameshio`: Tiny mesh parsing library (see also `tools/filamesh`)
|
||||
- `filameshio`: Tiny filamesh parsing library (see also `tools/filamesh`)
|
||||
- `geometry`: Mesh-related utilities
|
||||
- `gltfio`: Loader and optional pipeline for glTF 2.0
|
||||
- `ibl`: IBL generation tools
|
||||
- `image`: Image filtering and simple transforms
|
||||
- `imageio`: Image file reading / writing, only intended for internal use
|
||||
- `math`: Math library
|
||||
- `rays`: Simple path tracer used for baking ambient occlusion, etc.
|
||||
- `utils`: Utility library (threads, memory, data structures, etc.)
|
||||
- `samples`: Sample desktop applications
|
||||
- `shaders`: Shaders used by `filamat` and `matc`
|
||||
- `third_party`: External libraries and assets
|
||||
- `environments`: Environment maps under CC0 license that can be used with `cmgen`
|
||||
- `models`: Models under permissive licenses
|
||||
- `textures`: Textures under CC0 license
|
||||
- `tools`: Host tools
|
||||
- `cmgen`: Image-based lighting asset generator
|
||||
- `filamesh`: Mesh converter
|
||||
- `glslminifier`: Minifies GLSL source code
|
||||
- `matc`: Material compiler
|
||||
- `matinfo` Displays information about materials compiled with `matc`
|
||||
- `mipgen` Generates a series of miplevels from a source image
|
||||
@@ -149,8 +171,8 @@ and tools.
|
||||
|
||||
To build Filament, you must first install the following tools:
|
||||
|
||||
- CMake 3.4 (or more recent)
|
||||
- clang 5.0 (or more recent)
|
||||
- CMake 3.10 (or more recent)
|
||||
- clang 7.0 (or more recent)
|
||||
- [ninja 1.8](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages) (or more recent)
|
||||
|
||||
To build the Java based components of the project you can optionally install (recommended):
|
||||
@@ -160,11 +182,16 @@ To build the Java based components of the project you can optionally install (re
|
||||
Additional dependencies may be required for your operating system. Please refer to the appropriate
|
||||
section below.
|
||||
|
||||
Building the `rays` library (used for light baking) is optional and requires the following packages:
|
||||
|
||||
- embree 3.0+
|
||||
- libtbb-dev
|
||||
|
||||
To build Filament for Android you must also install the following:
|
||||
|
||||
- Android Studio 3.1
|
||||
- Android Studio 3.5
|
||||
- Android SDK
|
||||
- Android NDK
|
||||
- Android NDK 19 or higher
|
||||
|
||||
### Environment variables
|
||||
|
||||
@@ -177,7 +204,7 @@ When building for WebGL, you'll also need to set `EMSDK`. See [WebAssembly](#web
|
||||
|
||||
### IDE
|
||||
|
||||
We recommend using CLion to develop for Filament. Simply open the root directory's CMakeList.txt
|
||||
We recommend using CLion to develop for Filament. Simply open the root directory's CMakeLists.txt
|
||||
in CLion to obtain a usable project.
|
||||
|
||||
### Easy build
|
||||
@@ -225,9 +252,10 @@ If you use CMake directly instead of the build script, pass `-DENABLE_JAVA=OFF`
|
||||
|
||||
Make sure you've installed the following dependencies:
|
||||
|
||||
- `clang-7` or higher
|
||||
- `libglu1-mesa-dev`
|
||||
- `libc++-dev` (`libcxx-devel` on Fedora)
|
||||
- `libc++abi-dev`
|
||||
- `libc++-7-dev` (`libcxx-devel` and `libcxx-static` on Fedora) or higher
|
||||
- `libc++abi-7-dev` (`libcxxabi-static` on Fedora) or higher
|
||||
- `ninja-build`
|
||||
- `libxi-dev`
|
||||
|
||||
@@ -243,21 +271,14 @@ $ cd out/cmake-release
|
||||
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../release/filament ../..
|
||||
```
|
||||
|
||||
If you experience link errors you must ensure that you are using `libc++abi` by passing this
|
||||
extra parameter to `cmake`:
|
||||
|
||||
```
|
||||
-DFILAMENT_REQUIRES_CXXABI=true
|
||||
```
|
||||
|
||||
Your Linux distribution might default to `gcc` instead of `clang`, if that's the case invoke
|
||||
`cmake` with the following command:
|
||||
|
||||
```
|
||||
$ mkdir out/cmake-release
|
||||
$ cd out/cmake-release
|
||||
# Or use a specific version of clang, for instance /usr/bin/clang-5.0
|
||||
$ CC=/usr/bin/clang CXX=/usr/bin/clang++ \
|
||||
# Or use a specific version of clang, for instance /usr/bin/clang-7
|
||||
$ CC=/usr/bin/clang CXX=/usr/bin/clang++ CXXFLAGS=-stdlib=libc++ \
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../release/filament ../..
|
||||
```
|
||||
|
||||
@@ -266,10 +287,10 @@ solution is to use `update-alternatives` to both change the default compiler, an
|
||||
specific version of clang:
|
||||
|
||||
```
|
||||
$ update-alternatives --install /usr/bin/clang clang /usr/bin/clang-7 100
|
||||
$ update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-7 100
|
||||
$ update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
|
||||
$ update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
|
||||
$ update-alternatives --install /usr/bin/clang clang /usr/bin/clang-5.0 100
|
||||
$ update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-5.0 100
|
||||
```
|
||||
|
||||
Finally, invoke `ninja`:
|
||||
@@ -327,14 +348,20 @@ Google employees require additional steps which can be found here [go/filawin](h
|
||||
Install the following components:
|
||||
|
||||
- [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)
|
||||
- [Visual Studio 2015](https://www.visualstudio.com/downloads)
|
||||
- [Clang 6](http://releases.llvm.org/download.html)
|
||||
- [Visual Studio 2015 or 2017](https://www.visualstudio.com/downloads)
|
||||
- [Clang 7](http://releases.llvm.org/download.html)
|
||||
- [Python 3.7](https://www.python.org/ftp/python/3.7.0/python-3.7.0.exe)
|
||||
- [Git 2.16.1 or later](https://github.com/git-for-windows/git/releases/download/v2.16.1.windows.4/PortableGit-2.16.1.4-64-bit.7z.exe)
|
||||
- [Cmake 3.11 or later](https://cmake.org/files/v3.11/cmake-3.11.0-rc1-win64-x64.msi)
|
||||
- [Cmake 3.13 or later](https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4-win64-x64.msi)
|
||||
|
||||
Open an VS2015 x64 Native Tools terminal (click the start button, type "x64 native tools" and
|
||||
select: "VS2015 x64 Native Tools Command Prompt").
|
||||
If you're using Visual Studio 2017, you'll also need to install the [LLVM Compiler
|
||||
Toolchain](https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain)
|
||||
extension.
|
||||
|
||||
Open an appropriate Native Tools terminal for the version of Visual Studio you are using:
|
||||
- VS 2015: VS2015 x64 Native Tools Command Prompt
|
||||
- VS 2017: x64 Native Tools Command Prompt for VS 2017
|
||||
|
||||
You can find these by clicking the start button and typing "x64 native tools".
|
||||
|
||||
Create a working directory:
|
||||
```
|
||||
@@ -344,11 +371,20 @@ Create a working directory:
|
||||
|
||||
Create the msBuild project:
|
||||
```
|
||||
# Visual Studio 2015:
|
||||
> cmake -T"LLVM-vs2014" -G "Visual Studio 14 2015 Win64" ../..
|
||||
|
||||
# Visual Studio 2017
|
||||
> cmake ..\.. -T"LLVM" -G "Visual Studio 15 2017 Win64" ^
|
||||
-DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
|
||||
-DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
|
||||
-DCMAKE_LINKER:PATH="C:\Program Files\LLVM\bin\lld-link.exe"
|
||||
```
|
||||
|
||||
Check out the output and make sure Clang for Windows frontend was found. You should see a line
|
||||
showing the following output.
|
||||
showing the following output. Note that for Visual Studio 2017 this line may list Microsoft's
|
||||
compiler, but the build will still in fact use Clang and you can proceed.
|
||||
|
||||
```
|
||||
Clang:C:/Program Files/LLVM/msbuild-bin/cl.exe
|
||||
```
|
||||
@@ -360,7 +396,7 @@ You are now ready to build:
|
||||
|
||||
Run it:
|
||||
```
|
||||
> samples\Release\lightbulb.exe ..\..\assets\models\monkey\monkey.obj
|
||||
> samples\Release\material_sandbox.exe ..\..\assets\models\monkey\monkey.obj
|
||||
```
|
||||
|
||||
#### Tips
|
||||
@@ -379,11 +415,11 @@ Alternatively, you can use [Ninja](https://ninja-build.org/) to build for Window
|
||||
installation is still necessary.
|
||||
|
||||
First, install the dependencies listed under [Windows](#Windows) as well as Ninja. Then open up a
|
||||
VS2015 x64 Native Tools terminal as before. Create a build directory inside Filament and run the
|
||||
Native Tools terminal as before. Create a build directory inside Filament and run the
|
||||
following CMake command:
|
||||
|
||||
```
|
||||
cmake .. -G Ninja ^
|
||||
> cmake .. -G Ninja ^
|
||||
-DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
|
||||
-DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
|
||||
-DCMAKE_LINKER:PATH="C:\Program Files\LLVM\bin\lld-link.exe" ^
|
||||
@@ -393,7 +429,7 @@ cmake .. -G Ninja ^
|
||||
You should then be able to build by invoking Ninja:
|
||||
|
||||
```
|
||||
ninja
|
||||
> ninja
|
||||
```
|
||||
|
||||
#### Development tips
|
||||
@@ -408,7 +444,7 @@ ninja
|
||||
To confirm Filament was properly built, run the following command from the build directory:
|
||||
|
||||
```
|
||||
./samples/material_sandbox --ibl=../../samples/envs/pillars ../../assets/models/sphere/sphere.obj
|
||||
> samples\material_sandbox.exe --ibl=..\..\samples\envs\pillars ..\..\assets\models\sphere\sphere.obj
|
||||
```
|
||||
|
||||
### Android
|
||||
@@ -426,6 +462,8 @@ Filament can be built for the following architectures:
|
||||
Note that the main target is the ARM 64-bit target. Our implementation is optimized first and
|
||||
foremost for `arm64-v8a`.
|
||||
|
||||
To build Android on Windows machines, see [android/Windows.md](android/Windows.md).
|
||||
|
||||
#### Easy Android build
|
||||
|
||||
The easiest way to build Filament for Android is to use `build.sh` and the
|
||||
@@ -439,24 +477,6 @@ Run `build.sh -h` for more information.
|
||||
|
||||
#### ARM 64-bit target (arm64-v8a)
|
||||
|
||||
##### Linux toolchain
|
||||
|
||||
```
|
||||
$ $SDK/ndk-bundle/build/tools/make_standalone_toolchain.py --arch arm64 --api 24 \
|
||||
--stl libc++ --force \
|
||||
--install-dir toolchains/Linux/aarch64-linux-android-4.9
|
||||
```
|
||||
|
||||
##### Darwin toolchain
|
||||
|
||||
```
|
||||
$ $SDK/ndk-bundle/build/tools/make_standalone_toolchain.py --arch arm64 --api 24 \
|
||||
--stl libc++ --force \
|
||||
--install-dir toolchains/Darwin/aarch64-linux-android-4.9
|
||||
```
|
||||
|
||||
##### Compiling
|
||||
|
||||
Then invoke CMake in a build directory of your choice, inside of filament's directory:
|
||||
|
||||
```
|
||||
@@ -484,24 +504,6 @@ binaries should be found in `out/android-release/filament/lib/arm64-v8a`.
|
||||
|
||||
#### ARM 32-bit target (armeabi-v7a)
|
||||
|
||||
##### Linux toolchain
|
||||
|
||||
```
|
||||
$ $SDK/ndk-bundle/build/tools/make_standalone_toolchain.py --arch arm --api 24 \
|
||||
--stl libc++ --force \
|
||||
--install-dir toolchains/Linux/arm-linux-androideabi-4.9
|
||||
```
|
||||
|
||||
##### Darwin toolchain
|
||||
|
||||
```
|
||||
$ $SDK/ndk-bundle/build/tools/make_standalone_toolchain.py --arch arm --api 24 \
|
||||
--stl libc++ --force \
|
||||
--install-dir toolchains/Darwin/arm-linux-androideabi-4.9
|
||||
```
|
||||
|
||||
##### Compiling
|
||||
|
||||
Then invoke CMake in a build directory of your choice, inside of filament's directory:
|
||||
|
||||
```
|
||||
@@ -529,24 +531,6 @@ binaries should be found in `out/android-release/filament/lib/armeabi-v7a`.
|
||||
|
||||
#### Intel 64-bit target (x86_64)
|
||||
|
||||
##### Linux toolchain
|
||||
|
||||
```
|
||||
$ $SDK/ndk-bundle/build/tools/make_standalone_toolchain.py --arch x86_64 --api 24 \
|
||||
--stl libc++ --force \
|
||||
--install-dir toolchains/Linux/x86_64-linux-android-4.9
|
||||
```
|
||||
|
||||
##### Darwin toolchain
|
||||
|
||||
```
|
||||
$ $SDK/ndk-bundle/build/tools/make_standalone_toolchain.py --arch x86_64 --api 24 \
|
||||
--stl libc++ --force \
|
||||
--install-dir toolchains/Darwin/x86_64-linux-android-4.9
|
||||
```
|
||||
|
||||
##### Compiling
|
||||
|
||||
Then invoke CMake in a build directory of your choice, sibling of filament's directory:
|
||||
|
||||
```
|
||||
@@ -574,24 +558,6 @@ binaries should be found in `out/android-release/filament/lib/x86_64`.
|
||||
|
||||
#### Intel 32-bit target (x86)
|
||||
|
||||
##### Linux toolchain
|
||||
|
||||
```
|
||||
$ $SDK/ndk-bundle/build/tools/make_standalone_toolchain.py --arch x86 --api 24 \
|
||||
--stl libc++ --force \
|
||||
--install-dir toolchains/Linux/i686-linux-android-4.9
|
||||
```
|
||||
|
||||
##### Darwin toolchain
|
||||
|
||||
```
|
||||
$ $SDK/ndk-bundle/build/tools/make_standalone_toolchain.py --arch x86 --api 24 \
|
||||
--stl libc++ --force \
|
||||
--install-dir toolchains/Darwin/i686-linux-android-4.9
|
||||
```
|
||||
|
||||
##### Compiling
|
||||
|
||||
Then invoke CMake in a build directory of your choice, sibling of filament's directory:
|
||||
|
||||
```
|
||||
@@ -701,13 +667,13 @@ same version that our continuous builds use.
|
||||
|
||||
```
|
||||
cd <your chosen parent folder for the emscripten SDK>
|
||||
curl -L https://github.com/juj/emsdk/archive/0d8576c.zip > emsdk.zip
|
||||
curl -L https://github.com/emscripten-core/emsdk/archive/a77638d.zip > emsdk.zip
|
||||
unzip emsdk.zip
|
||||
mv emsdk-* emsdk
|
||||
cd emsdk
|
||||
./emsdk update
|
||||
./emsdk install sdk-1.38.11-64bit
|
||||
./emsdk activate sdk-1.38.11-64bit
|
||||
./emsdk install sdk-1.38.28-64bit
|
||||
./emsdk activate sdk-1.38.28-64bit
|
||||
```
|
||||
|
||||
After this you can invoke the [easy build](#easy-build) script as follows:
|
||||
@@ -750,8 +716,9 @@ filamesh ./assets/models/monkey/monkey.obj monkey.filamesh
|
||||
```
|
||||
|
||||
Most samples accept an IBL that must be generated using the `cmgen` tool (`./tools/filamesh/cmgen`
|
||||
in your build directory). These sample apps expect a path to a directory containing the RGBM files
|
||||
for the IBL. To generate an IBL simply use this command:
|
||||
in your build directory). These sample apps expect a path to a directory containing the '.rgb32f'
|
||||
files for the IBL (which are PNGs containing `R11F_G11F_B10F` data). To generate an IBL simply use
|
||||
this command:
|
||||
|
||||
```
|
||||
cmgen -x ./ibls/ my_ibl.exr
|
||||
@@ -767,7 +734,7 @@ pre-filtered environment map (one file per cubemap face and per mip level), the
|
||||
texture for the skybox and a text file containing the spherical harmonics for indirect diffuse
|
||||
lighting.
|
||||
|
||||
If you prefer a blurred background, run `cmgen` with this flag: `--extract-blur=0.5`. The numerical
|
||||
If you prefer a blurred background, run `cmgen` with this flag: `--extract-blur=0.1`. The numerical
|
||||
value is the desired roughness between 0 and 1.
|
||||
|
||||
## Rendering with Filament
|
||||
@@ -775,7 +742,7 @@ value is the desired roughness between 0 and 1.
|
||||
### Native Linux, macOS and Windows
|
||||
|
||||
You must create an `Engine`, a `Renderer` and a `SwapChain`. The `SwapChain` is created from a
|
||||
native window pointer (an `NSView` on macOS or a `HDC` on Windows for instance):
|
||||
native window pointer (an `NSView` on macOS or a `HWND` on Windows for instance):
|
||||
|
||||
```c++
|
||||
Engine* engine = Engine::create();
|
||||
@@ -874,7 +841,8 @@ MoltenVK.
|
||||
|
||||
## Generating C++ documentation
|
||||
|
||||
To generate the documentation you must first install `doxygen`, then run the following commands:
|
||||
To generate the documentation you must first install `doxygen` and `graphviz`, then run the
|
||||
following commands:
|
||||
|
||||
```
|
||||
$ cd filament/filament
|
||||
|
||||
61
RELEASE_NOTES.md
Normal file
61
RELEASE_NOTES.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Filament Release Notes log
|
||||
|
||||
This file contains one line summaries of commits that are worthy of mentioning in release notes.
|
||||
A new header is inserted each time a *tag* is created.
|
||||
|
||||
- Added a live material debugger with a web-based interface.
|
||||
- Added basic #include support in material files.
|
||||
|
||||
## v1.3.1
|
||||
|
||||
- Unified Filament Sceneform and npm releases.
|
||||
- Improved cmgen SH with HDR images.
|
||||
- IndirectLight can now be queried for dominant direction and color.
|
||||
- Added support for vertex morphing.
|
||||
- Introduced custom attributes, accessible from the vertex shader.
|
||||
- Added Java / Kotlin bindings for KtxLoader.
|
||||
- Added JavaScript / Typescript bindings for the new `RenderTarget` class.
|
||||
- Added base path to glTF loadResources method for JavaScript.
|
||||
- Added support for iOS `CVPixelBuffer` external images with the OpenGL backend.
|
||||
|
||||
## sceneform-1.9pr4
|
||||
|
||||
- Added `gltf_bloom` Android sample to show gltfio and the `RenderTarget` API.
|
||||
- Added `getMaterialInstanceAt` to the Java version of RenderableManager.
|
||||
- Fix JNI bindings for setting values in parameter arrays.
|
||||
- Added JNI bindings for the gltfio library.
|
||||
- Fix support for parameter arrays in `.mat` files.
|
||||
- Added support for `RGB_11_11_10`
|
||||
- Removed support for `RGBM` (**warning:** source compatibility breakage)
|
||||
- IBL cubemap can now be of any size
|
||||
- `Texture::generatePrefilterMipmap` can be used for runtime generation of a reflection cubemap
|
||||
|
||||
## sceneform-1.9pr3
|
||||
|
||||
- Added `Scene.addEntities()` to the Java / Kotlin bindings.
|
||||
- Improved robustness in the tangents utility for meshes that have tangents *and* normals.
|
||||
- Introduced `RenderTarget` API that allows View to reference an offscreen render target.
|
||||
- Added `lucy_bloom` sample to demonstrate the new `RenderTarget` API.
|
||||
- Added Screen Space Ambient Occlusion support (SAO)
|
||||
- New blending modes: `multiply` and `screen`
|
||||
- Fixed an issue when sorting blended objects with different blending modes
|
||||
- The material property `curvatureToRoughness` has been replaced with `specularAntiAliasing`.
|
||||
This new specular anti-aliasing solution offers more control via two new properties:
|
||||
`specularAntiAliasingVariance` and `specularAntiAliasingThreshold`. They can also be set on
|
||||
material instances if needed
|
||||
- Added specular ambient occlusion to compute a new AO term applied to specular reflections
|
||||
(see `specularAmbientOcclusion` property in materials)
|
||||
- Added multi-bounce ambient occlusion to brighten AO and preserve local color
|
||||
(see `multiBounceAmbientOcclusion` property in materials)
|
||||
- Micro-shadowing is now applied to material ambient occlusion
|
||||
- Use a smaller 64x64 DFG LUT on mobile to reduce binary size
|
||||
- Added a distance field generator to libimage.
|
||||
- JavaScript MaterialInstance now supports vec4 colors.
|
||||
- Further reduced `filamat` binary size by removing reliance on stdlib.
|
||||
- Added a new, smaller, version of the `filamat` library, `filamat_lite`. Material optimization and
|
||||
compiling for non-OpenGL backends have been removed in favor of a smaller binary size.
|
||||
- Implemented hard fences for the Metal backend, enablying dynamic resolution support.
|
||||
- Improved `SurfaceOrientation` robustness when using UVs to generate tangents.
|
||||
- Created a `RELEASE_NOTES.md` file, to be updated with significant PRs.
|
||||
|
||||
## sceneform-1.9pr2
|
||||
123
android/Windows.md
Normal file
123
android/Windows.md
Normal file
@@ -0,0 +1,123 @@
|
||||
# Building Filament for Android on Windows
|
||||
|
||||
## Prerequisites
|
||||
|
||||
In addition to the requirements for [building Filament on Windows](../README.md#windows), you'll
|
||||
need the Android SDK and NDK. See [Getting Started with the
|
||||
NDK](https://developer.android.com/ndk/guides/) for detailed installation instructions.
|
||||
|
||||
Ensure the `%ANDROID_HOME%` environment variable is set to your Android SDK installation location.
|
||||
|
||||
All of the following commands should be executed in a Visual Studio x64 Native Tools Command Prompt.
|
||||
|
||||
## Desktop Tools
|
||||
|
||||
First, a few Filament tools need to be compiled for desktop.
|
||||
|
||||
1. From Filament's root directory, create a desktop build directory and run CMake.
|
||||
|
||||
```
|
||||
mkdir out\cmake-release
|
||||
cd out\cmake-release
|
||||
cmake ^
|
||||
-G Ninja ^
|
||||
-DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
|
||||
-DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
|
||||
-DCMAKE_LINKER:PATH="C:\Program Files\LLVM\bin\lld-link.exe" ^
|
||||
-DCMAKE_INSTALL_PREFIX=..\release\filament ^
|
||||
-DENABLE_JAVA=NO ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
..\..
|
||||
```
|
||||
|
||||
2. Build the required desktop host tools.
|
||||
|
||||
```
|
||||
ninja matc resgen cmgen
|
||||
```
|
||||
|
||||
The build should succeed and a `ImportExecutables-Release.cmake` file should automatically be
|
||||
created at Filament's root directory.
|
||||
|
||||
## Build
|
||||
|
||||
1. Create the build directories.
|
||||
|
||||
```
|
||||
mkdir out\cmake-android-release-aarch64
|
||||
mkdir out\cmake-android-release-arm7
|
||||
mkdir out\cmake-android-release-x86_64
|
||||
mkdir out\cmake-android-release-x86
|
||||
```
|
||||
|
||||
2. Run CMake for each architecture.
|
||||
|
||||
```
|
||||
cd out\cmake-android-release-aarch64
|
||||
cmake ^
|
||||
-G Ninja ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DCMAKE_INSTALL_PREFIX=..\android-release\filament ^
|
||||
-DCMAKE_TOOLCHAIN_FILE=..\..\build\toolchain-aarch64-linux-android.cmake ^
|
||||
..\..
|
||||
|
||||
cd out\cmake-android-release-arm7
|
||||
cmake ^
|
||||
-G Ninja ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DCMAKE_INSTALL_PREFIX=..\android-release\filament ^
|
||||
-DCMAKE_TOOLCHAIN_FILE=..\..\build\toolchain-arm7-linux-android.cmake ^
|
||||
..\..
|
||||
|
||||
cd out\cmake-android-release-x86_64
|
||||
cmake ^
|
||||
-G Ninja ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DCMAKE_INSTALL_PREFIX=..\android-release\filament ^
|
||||
-DCMAKE_TOOLCHAIN_FILE=..\..\build\toolchain-x86_64-linux-android.cmake ^
|
||||
..\..
|
||||
|
||||
cd out\cmake-android-release-x86
|
||||
cmake ^
|
||||
-G Ninja ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DCMAKE_INSTALL_PREFIX=..\android-release\filament ^
|
||||
-DCMAKE_TOOLCHAIN_FILE=..\..\build\toolchain-x86-linux-android.cmake ^
|
||||
..\..
|
||||
```
|
||||
|
||||
3. Build.
|
||||
|
||||
Inside of each build directory, run:
|
||||
|
||||
```
|
||||
ninja install
|
||||
```
|
||||
|
||||
## Generate AAR
|
||||
|
||||
The Gradle project used to generate the AAR is located at `<filament>\android\filament-android`.
|
||||
|
||||
```
|
||||
cd android\filament-android
|
||||
gradlew -Pfilament_dist_dir=..\..\out\android-release\filament assembleRelease
|
||||
copy build\outputs\aar\filament-android-release.aar ..\..\out\
|
||||
```
|
||||
|
||||
If you're only interested in building for a single ABI, you'll need to add an `abiFilters` override
|
||||
inside the `build.gradle` file underneath `defaultConfig`:
|
||||
|
||||
```
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
```
|
||||
|
||||
See
|
||||
[NdkOptions](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.NdkOptions.html#com.android.build.gradle.internal.dsl.NdkOptions:abiFilters)
|
||||
for more information.
|
||||
|
||||
`filament-android-release.aar` should now be present at `<filament>\out\filament-android-release.aar`.
|
||||
|
||||
See [Using Filament's AAR](../README.md#using-filaments-aar) for usage instructions.
|
||||
|
||||
@@ -33,6 +33,7 @@ List<File> getBinaries(String name, File toolsPath) {
|
||||
ext.matcFullPath = getBinaries('matc', filamentToolsPath)
|
||||
ext.cmgenFullPath = getBinaries('cmgen', filamentToolsPath)
|
||||
ext.filameshFullPath = getBinaries('filamesh', filamentToolsPath)
|
||||
ext.resgenFullPath = getBinaries('resgen', filamentToolsPath)
|
||||
|
||||
class LogOutputStream extends ByteArrayOutputStream {
|
||||
private final Logger logger;
|
||||
@@ -83,6 +84,7 @@ class MaterialCompiler extends DefaultTask {
|
||||
}
|
||||
|
||||
inputs.outOfDate { InputFileDetails outOfDate ->
|
||||
if (outOfDate.file.directory) return
|
||||
def file = outOfDate.file
|
||||
|
||||
def out = new LogOutputStream(logger, LogLevel.LIFECYCLE)
|
||||
@@ -96,7 +98,7 @@ class MaterialCompiler extends DefaultTask {
|
||||
standardOutput out
|
||||
errorOutput err
|
||||
executable "${matcPath}"
|
||||
args('-O', '-p', 'mobile', '-o', getOutputFile(file), file)
|
||||
args('-a', 'all', '-p', 'mobile', '-o', getOutputFile(file), file)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +116,7 @@ class MaterialCompiler extends DefaultTask {
|
||||
// This task handles incremental builds
|
||||
class IblGenerator extends DefaultTask {
|
||||
File cmgenPath
|
||||
String cmgenArgs = null;
|
||||
|
||||
@SuppressWarnings("GroovyUnusedDeclaration")
|
||||
@InputFile
|
||||
@@ -153,9 +156,13 @@ class IblGenerator extends DefaultTask {
|
||||
|
||||
project.exec {
|
||||
standardOutput out
|
||||
if (!cmgenArgs) {
|
||||
cmgenArgs = '--format=rgb32f --extract-blur=0.08 --extract=' + outputDir.absolutePath
|
||||
}
|
||||
cmgenArgs = cmgenArgs + " " + file
|
||||
errorOutput err
|
||||
executable "${cmgenPath}"
|
||||
args('--format=rgbm', '--extract-blur=0.08', "--extract=${outputDir.absolutePath}", file)
|
||||
args(cmgenArgs.split())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "CallbackUtils.h"
|
||||
#include "NioUtils.h"
|
||||
#include "common/CallbackUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
#include <filament/Engine.h>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "NioUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -26,7 +26,8 @@ struct {
|
||||
jmethodID getBufferType;
|
||||
} gNioUtils;
|
||||
|
||||
AutoBuffer::AutoBuffer(JNIEnv *env, jobject buffer, jint size) noexcept : mEnv(env) {
|
||||
AutoBuffer::AutoBuffer(JNIEnv *env, jobject buffer, jint size, bool commit) noexcept : mEnv(env),
|
||||
mDoCommit(commit) {
|
||||
mBuffer = env->NewGlobalRef(buffer);
|
||||
|
||||
mType = (BufferType) env->CallStaticIntMethod(
|
||||
@@ -108,27 +109,28 @@ AutoBuffer::AutoBuffer(AutoBuffer &&rhs) noexcept {
|
||||
AutoBuffer::~AutoBuffer() noexcept {
|
||||
JNIEnv *env = mEnv;
|
||||
if (mBaseArray) {
|
||||
jint mode = mDoCommit ? 0 : JNI_ABORT;
|
||||
switch (mType) {
|
||||
case BufferType::BYTE:
|
||||
env->ReleaseByteArrayElements((jbyteArray)mBaseArray, (jbyte *) mData, JNI_ABORT);
|
||||
env->ReleaseByteArrayElements((jbyteArray)mBaseArray, (jbyte *) mData, mode);
|
||||
break;
|
||||
case BufferType::CHAR:
|
||||
env->ReleaseCharArrayElements((jcharArray)mBaseArray, (jchar *) mData, JNI_ABORT);
|
||||
env->ReleaseCharArrayElements((jcharArray)mBaseArray, (jchar *) mData, mode);
|
||||
break;
|
||||
case BufferType::SHORT:
|
||||
env->ReleaseShortArrayElements((jshortArray)mBaseArray, (jshort *) mData, JNI_ABORT);
|
||||
env->ReleaseShortArrayElements((jshortArray)mBaseArray, (jshort *) mData, mode);
|
||||
break;
|
||||
case BufferType::INT:
|
||||
env->ReleaseIntArrayElements((jintArray)mBaseArray, (jint *) mData, JNI_ABORT);
|
||||
env->ReleaseIntArrayElements((jintArray)mBaseArray, (jint *) mData, mode);
|
||||
break;
|
||||
case BufferType::LONG:
|
||||
env->ReleaseLongArrayElements((jlongArray)mBaseArray, (jlong *) mData, JNI_ABORT);
|
||||
env->ReleaseLongArrayElements((jlongArray)mBaseArray, (jlong *) mData, mode);
|
||||
break;
|
||||
case BufferType::FLOAT:
|
||||
env->ReleaseFloatArrayElements((jfloatArray)mBaseArray, (jfloat *) mData, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements((jfloatArray)mBaseArray, (jfloat *) mData, mode);
|
||||
break;
|
||||
case BufferType::DOUBLE:
|
||||
env->ReleaseDoubleArrayElements((jdoubleArray)mBaseArray, (jdouble *) mData, JNI_ABORT);
|
||||
env->ReleaseDoubleArrayElements((jdoubleArray)mBaseArray, (jdouble *) mData, mode);
|
||||
break;
|
||||
}
|
||||
env->DeleteGlobalRef(mBaseArray);
|
||||
@@ -32,7 +32,9 @@ public:
|
||||
DOUBLE
|
||||
};
|
||||
|
||||
AutoBuffer(JNIEnv* env, jobject buffer, jint size) noexcept;
|
||||
// Clients should pass "true" for the commit argument if they intend to mutate the buffer
|
||||
// contents from native code.
|
||||
AutoBuffer(JNIEnv* env, jobject buffer, jint size, bool commit = false) noexcept;
|
||||
AutoBuffer(AutoBuffer&& rhs) noexcept;
|
||||
~AutoBuffer() noexcept;
|
||||
|
||||
@@ -62,4 +64,5 @@ private:
|
||||
void* mData = nullptr;
|
||||
jobject mBuffer = nullptr;
|
||||
jarray mBaseArray = nullptr;
|
||||
bool mDoCommit = false;
|
||||
};
|
||||
12
android/filamat-android/.gitignore
vendored
Normal file
12
android/filamat-android/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
/.idea/caches
|
||||
/.idea/gradle.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
/.cxx
|
||||
55
android/filamat-android/CMakeLists.txt
Normal file
55
android/filamat-android/CMakeLists.txt
Normal file
@@ -0,0 +1,55 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
|
||||
|
||||
set(FILAMAT_FLAVOR "filamat")
|
||||
if(FILAMAT_LITE)
|
||||
set(FILAMAT_FLAVOR "filamat_lite")
|
||||
endif()
|
||||
|
||||
add_library(${FILAMAT_FLAVOR} STATIC IMPORTED)
|
||||
set_target_properties(${FILAMAT_FLAVOR} PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/lib${FILAMAT_FLAVOR}.a)
|
||||
|
||||
add_library(utils STATIC IMPORTED)
|
||||
set_target_properties(utils PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libutils.a)
|
||||
|
||||
add_library(filabridge STATIC IMPORTED)
|
||||
set_target_properties(filabridge PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilabridge.a)
|
||||
|
||||
add_library(smol-v STATIC IMPORTED)
|
||||
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
|
||||
|
||||
add_library(shaders STATIC IMPORTED)
|
||||
set_target_properties(shaders PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libshaders.a)
|
||||
|
||||
include_directories(${FILAMENT_DIR}/include)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-stack-protector")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -ffp-contract=fast")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility-inlines-hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffunction-sections -fdata-sections")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS" ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS" ${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${CMAKE_SOURCE_DIR}/libfilamat-jni.map")
|
||||
|
||||
add_library(filamat-jni SHARED
|
||||
src/main/cpp/MaterialBuilder.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(filamat-jni
|
||||
${FILAMAT_FLAVOR}
|
||||
filabridge
|
||||
shaders
|
||||
utils
|
||||
log
|
||||
smol-v
|
||||
)
|
||||
|
||||
106
android/filamat-android/build.gradle
Normal file
106
android/filamat-android/build.gradle
Normal file
@@ -0,0 +1,106 @@
|
||||
// This script accepts the following parameters:
|
||||
//
|
||||
// filament_dist_dir
|
||||
// Path to the Filament distribution/install directory for Android
|
||||
// (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc.
|
||||
//
|
||||
// Example:
|
||||
// ./gradlew -Pfilament_dist_dir=../../dist-android-release assembleRelease
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
group = "com.google.android.filament"
|
||||
version = "0.1"
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
def filament_path = file("../../out/android-release/filament").absolutePath
|
||||
if (project.hasProperty("filament_dist_dir")) {
|
||||
filament_path = file("$filament_dist_dir").absolutePath
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-21")
|
||||
arguments.add("-DANDROID_STL=c++_static")
|
||||
arguments.add("-DFILAMENT_DIST_DIR=${filament_path}".toString())
|
||||
cppFlags.add("-std=c++14")
|
||||
if (project.hasProperty('extra_cmake_args')) {
|
||||
arguments.add(extra_cmake_args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions "functionality"
|
||||
productFlavors {
|
||||
full {
|
||||
dimension "functionality"
|
||||
}
|
||||
|
||||
lite {
|
||||
dimension "functionality"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DFILAMAT_LITE=ON")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:support-annotations:28.0.0'
|
||||
}
|
||||
BIN
android/filamat-android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
android/filamat-android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
android/filamat-android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
android/filamat-android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
172
android/filamat-android/gradlew
vendored
Executable file
172
android/filamat-android/gradlew
vendored
Executable file
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
84
android/filamat-android/gradlew.bat
vendored
Normal file
84
android/filamat-android/gradlew.bat
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
4
android/filamat-android/libfilamat-jni.map
Normal file
4
android/filamat-android/libfilamat-jni.map
Normal file
@@ -0,0 +1,4 @@
|
||||
LIBFILAMAT {
|
||||
global: Java_com_google_android_filament_*; JNI*;
|
||||
local: *;
|
||||
};
|
||||
1
android/filamat-android/libfilamat-jni.symbols
Normal file
1
android/filamat-android/libfilamat-jni.symbols
Normal file
@@ -0,0 +1 @@
|
||||
_Java_com_google_android_filament_*
|
||||
10
android/filamat-android/settings.gradle
Normal file
10
android/filamat-android/settings.gradle
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* The settings file is used to specify which projects to include in your build.
|
||||
*
|
||||
* Detailed information about configuring a multi-project build in Gradle can be found
|
||||
* in the user guide at https://docs.gradle.org/4.6/userguide/multi_project_builds.html
|
||||
*/
|
||||
|
||||
rootProject.name = 'filamat-android'
|
||||
2
android/filamat-android/src/main/AndroidManifest.xml
Normal file
2
android/filamat-android/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.filament.filamat" />
|
||||
310
android/filamat-android/src/main/cpp/MaterialBuilder.cpp
Normal file
310
android/filamat-android/src/main/cpp/MaterialBuilder.cpp
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filamat/MaterialBuilder.h>
|
||||
|
||||
using namespace filament;
|
||||
using namespace filamat;
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderInit(JNIEnv*, jclass) {
|
||||
MaterialBuilder::init();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderShutdown(JNIEnv*, jclass) {
|
||||
MaterialBuilder::shutdown();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nCreateMaterialBuilder(JNIEnv*, jclass) {
|
||||
return (jlong) new MaterialBuilder();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nDestroyMaterialBuilder(JNIEnv*, jclass,
|
||||
jlong nativeBuilder) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
delete builder;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nBuilderBuild(JNIEnv*, jclass,
|
||||
jlong nativeBuilder) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
return (jlong) new Package(builder->build());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jbyteArray JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nGetPackageBytes(JNIEnv* env, jclass,
|
||||
jlong nativePackage) {
|
||||
auto package = (Package*) nativePackage;
|
||||
auto size = jsize(package->getSize());
|
||||
jbyteArray ret = env->NewByteArray(size);
|
||||
auto data = (jbyte*) package->getData();
|
||||
env->SetByteArrayRegion(ret, 0, size, data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nGetPackageIsValid(JNIEnv*, jclass,
|
||||
jlong nativePackage) {
|
||||
auto* package = (Package*) nativePackage;
|
||||
return jboolean(package->isValid());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nDestroyPackage(JNIEnv*, jclass,
|
||||
jlong nativePackage) {
|
||||
Package* package = (Package*) nativePackage;
|
||||
delete package;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderName(JNIEnv* env,
|
||||
jclass, jlong nativeBuilder, jstring name_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->name(name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderShading(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint shading) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->shading((MaterialBuilder::Shading) shading);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderInterpolation(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint interpolation) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->interpolation((MaterialBuilder::Interpolation) interpolation);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderUniformParameter(
|
||||
JNIEnv* env, jclass, jlong nativeBuilder, jint uniformType, jstring name_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->parameter((MaterialBuilder::UniformType) uniformType, name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderUniformParameterArray(
|
||||
JNIEnv* env, jclass, jlong nativeBuilder, jint uniformType, jint size, jstring name_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->parameter((MaterialBuilder::UniformType) uniformType, (size_t) size, name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSamplerParameter(
|
||||
JNIEnv* env, jclass, jlong nativeBuilder, jint samplerType, jint format,
|
||||
jint precision, jstring name_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->parameter((MaterialBuilder::SamplerType) samplerType,
|
||||
(MaterialBuilder::SamplerFormat) format, (MaterialBuilder::SamplerPrecision) precision,
|
||||
name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderVariable(
|
||||
JNIEnv* env, jclass, jlong nativeBuilder, jint variable, jstring name_) {
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->variable((MaterialBuilder::Variable) variable, name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderRequire(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint attribute) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->require((VertexAttribute) attribute);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMaterial(JNIEnv* env,
|
||||
jclass, jlong nativeBuilder, jstring code_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* code = env->GetStringUTFChars(code_, nullptr);
|
||||
builder->material(code);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMaterialVertex(JNIEnv* env,
|
||||
jclass, jlong nativeBuilder, jstring code_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* code = env->GetStringUTFChars(code_, nullptr);
|
||||
builder->materialVertex(code);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderBlending(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint mode) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->blending((MaterialBuilder::BlendingMode) mode);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderPostLightingBlending(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jint mode) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->postLightingBlending((MaterialBuilder::BlendingMode) mode);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderVertexDomain(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint vertexDomain) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->vertexDomain((MaterialBuilder::VertexDomain) vertexDomain);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderCulling(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint mode) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->culling((MaterialBuilder::CullingMode) mode);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderColorWrite(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jboolean enable) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->colorWrite(enable);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderDepthWrite(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jboolean depthWrite) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->depthWrite(depthWrite);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderDepthCulling(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jboolean depthCulling) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->depthCulling(depthCulling);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderDoubleSided(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jboolean doubleSided) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->doubleSided(doubleSided);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMaskThreshold(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jfloat maskThreshold) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->maskThreshold(maskThreshold);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderShadowMultiplier(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jboolean shadowMultiplier) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->shadowMultiplier(shadowMultiplier);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSpecularAntiAliasing(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jboolean specularAntiAliasing) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->specularAntiAliasing(specularAntiAliasing);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSpecularAntiAliasingVariance(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jfloat variance) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->specularAntiAliasingVariance(variance);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSpecularAntiAliasingThreshold(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jfloat threshold) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->specularAntiAliasingThreshold(threshold);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderClearCoatIorChange(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jboolean clearCoatIorChange) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->clearCoatIorChange(clearCoatIorChange);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderFlipUV(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jboolean flipUV) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->flipUV(flipUV);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMultiBounceAmbientOcclusion(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jboolean multiBounceAO) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->multiBounceAmbientOcclusion(multiBounceAO);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSpecularAmbientOcclusion(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jboolean specularAO) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->specularAmbientOcclusion(specularAO);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderTransparencyMode(
|
||||
JNIEnv* env, jclass, jlong nativeBuilder, jint mode) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->transparencyMode((MaterialBuilder::TransparencyMode) mode);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderPlatform(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint platform) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->platform((MaterialBuilder::Platform) platform);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderTargetApi(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint targetApi) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->targetApi((MaterialBuilder::TargetApi) targetApi);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderOptimization(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint optimization) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->optimization((MaterialBuilder::Optimization) optimization);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderVariantFilter(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jbyte variantFilter) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->variantFilter((uint8_t) variantFilter);
|
||||
}
|
||||
@@ -0,0 +1,465 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.filamat;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class MaterialBuilder {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
// Keep to finalize native resources
|
||||
private final BuilderFinalizer mFinalizer;
|
||||
private final long mNativeObject;
|
||||
|
||||
static {
|
||||
System.loadLibrary("filamat-jni");
|
||||
}
|
||||
|
||||
public enum Shading {
|
||||
UNLIT, // no lighting applied, emissive possible
|
||||
LIT, // default, standard lighting
|
||||
SUBSURFACE, // subsurface lighting model
|
||||
CLOTH, // cloth lighting model
|
||||
SPECULAR_GLOSSINESS // legacy lighting model
|
||||
}
|
||||
|
||||
public enum Interpolation {
|
||||
SMOOTH, // default, smooth interpolation
|
||||
FLAT // flat interpolation
|
||||
}
|
||||
|
||||
public enum UniformType {
|
||||
BOOL,
|
||||
BOOL2,
|
||||
BOOL3,
|
||||
BOOL4,
|
||||
FLOAT,
|
||||
FLOAT2,
|
||||
FLOAT3,
|
||||
FLOAT4,
|
||||
INT,
|
||||
INT2,
|
||||
INT3,
|
||||
INT4,
|
||||
UINT,
|
||||
UINT2,
|
||||
UINT3,
|
||||
UINT4,
|
||||
MAT3,
|
||||
MAT4
|
||||
}
|
||||
|
||||
public enum SamplerType {
|
||||
SAMPLER_2D, // 2D texture
|
||||
SAMPLER_CUBEMAP, // Cube map texture
|
||||
SAMPLER_EXTERNAL, // External texture
|
||||
}
|
||||
|
||||
public enum SamplerFormat {
|
||||
INT,
|
||||
UINT,
|
||||
FLOAT,
|
||||
SHADOW
|
||||
}
|
||||
|
||||
public enum SamplerPrecision {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
DEFAULT
|
||||
}
|
||||
|
||||
public enum Variable {
|
||||
CUSTOM0,
|
||||
CUSTOM1,
|
||||
CUSTOM2,
|
||||
CUSTOM3
|
||||
}
|
||||
|
||||
public enum VertexAttribute {
|
||||
POSITION, // XYZ position (float3)
|
||||
TANGENTS, // tangent, bitangent and normal, encoded as a quaternion (4 floats or half floats)
|
||||
COLOR, // vertex color (float4)
|
||||
UV0, // texture coordinates (float2)
|
||||
UV1, // texture coordinates (float2)
|
||||
BONE_INDICES, // indices of 4 bones (uvec4)
|
||||
BONE_WEIGHTS, // weights of the 4 bones (normalized float4)
|
||||
CUSTOM0,
|
||||
CUSTOM1,
|
||||
CUSTOM2,
|
||||
CUSTOM3,
|
||||
CUSTOM4,
|
||||
CUSTOM5,
|
||||
CUSTOM6,
|
||||
CUSTOM7
|
||||
}
|
||||
|
||||
public enum BlendingMode {
|
||||
OPAQUE, // material is opaque
|
||||
TRANSPARENT, // material is transparent and color is alpha-pre-multiplied,
|
||||
// affects diffuse lighting only
|
||||
ADD, // material is additive (e.g.: hologram)
|
||||
MASKED, // material is masked (i.e. alpha tested)
|
||||
FADE, // material is transparent and color is alpha-pre-multiplied,
|
||||
// affects specular lighting
|
||||
MULTIPLY, // material darkens what's behind it
|
||||
SCREN // material brightens what's behind it
|
||||
}
|
||||
|
||||
public enum VertexDomain {
|
||||
OBJECT, // vertices are in object space, default
|
||||
WORLD, // vertices are in world space
|
||||
VIEW, // vertices are in view space
|
||||
DEVICE // vertices are in normalized device space
|
||||
}
|
||||
|
||||
public enum CullingMode {
|
||||
NONE,
|
||||
FRONT,
|
||||
BACK,
|
||||
FRONT_AND_BACK
|
||||
}
|
||||
|
||||
public enum TransparencyMode {
|
||||
DEFAULT, // the transparent object is drawn honoring the raster state
|
||||
TWO_PASSES_ONE_SIDE, // the transparent object is first drawn in the depth buffer,
|
||||
// then in the color buffer, honoring the culling mode, but
|
||||
// ignoring the depth test function
|
||||
TWO_PASSES_TWO_SIDES // the transparent object is drawn twice in the color buffer,
|
||||
// first with back faces only, then with front faces; the culling
|
||||
// mode is ignored. Can be combined with two-sided lighting
|
||||
}
|
||||
|
||||
public enum Platform {
|
||||
DESKTOP,
|
||||
MOBILE,
|
||||
ALL
|
||||
}
|
||||
|
||||
public enum TargetApi {
|
||||
OPENGL (0x1),
|
||||
VULKAN (0x2),
|
||||
METAL (0x4),
|
||||
ALL (0x7);
|
||||
|
||||
final int number;
|
||||
|
||||
private TargetApi(int number) {
|
||||
this.number = number;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Optimization {
|
||||
NONE,
|
||||
PREPROCESSOR,
|
||||
SIZE,
|
||||
PERFORMANCE
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
nMaterialBuilderInit();
|
||||
}
|
||||
|
||||
public static void shutdown() {
|
||||
nMaterialBuilderShutdown();
|
||||
}
|
||||
|
||||
public MaterialBuilder() {
|
||||
mNativeObject = nCreateMaterialBuilder();
|
||||
mFinalizer = new BuilderFinalizer(mNativeObject);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder name(@NonNull String name) {
|
||||
nMaterialBuilderName(mNativeObject, name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder shading(@NonNull Shading shading) {
|
||||
nMaterialBuilderShading(mNativeObject, shading.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder interpolation(@NonNull Interpolation interpolation) {
|
||||
nMaterialBuilderInterpolation(mNativeObject, interpolation.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder uniformParameter(@NonNull UniformType type, String name) {
|
||||
nMaterialBuilderUniformParameter(mNativeObject, type.ordinal(), name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder uniformParameterArray(@NonNull UniformType type, int size, String name) {
|
||||
nMaterialBuilderUniformParameterArray(mNativeObject, type.ordinal(), size, name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder samplerParameter(@NonNull SamplerType type, SamplerFormat format,
|
||||
SamplerPrecision precision, String name) {
|
||||
nMaterialBuilderSamplerParameter(
|
||||
mNativeObject, type.ordinal(), format.ordinal(), precision.ordinal(), name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder variable(@NonNull Variable variable, String name) {
|
||||
nMaterialBuilderVariable(mNativeObject, variable.ordinal(), name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder require(@NonNull VertexAttribute attribute) {
|
||||
nMaterialBuilderRequire(mNativeObject, attribute.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder material(@NonNull String code) {
|
||||
nMaterialBuilderMaterial(mNativeObject, code);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder materialVertex(@NonNull String code) {
|
||||
nMaterialBuilderMaterialVertex(mNativeObject, code);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder blending(@NonNull BlendingMode mode) {
|
||||
nMaterialBuilderBlending(mNativeObject, mode.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder postLightingBlending(@NonNull BlendingMode mode) {
|
||||
nMaterialBuilderPostLightingBlending(mNativeObject, mode.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder vertexDomain(@NonNull VertexDomain vertexDomain) {
|
||||
nMaterialBuilderVertexDomain(mNativeObject, vertexDomain.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder culling(@NonNull CullingMode mode) {
|
||||
nMaterialBuilderCulling(mNativeObject, mode.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder colorWrite(boolean enable) {
|
||||
nMaterialBuilderColorWrite(mNativeObject, enable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder depthWrite(boolean enable) {
|
||||
nMaterialBuilderDepthWrite(mNativeObject, enable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder depthCulling(boolean enable) {
|
||||
nMaterialBuilderDepthCulling(mNativeObject, enable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder doubleSided(boolean doubleSided) {
|
||||
nMaterialBuilderDoubleSided(mNativeObject, doubleSided);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder maskThreshold(float threshold) {
|
||||
nMaterialBuilderMaskThreshold(mNativeObject, threshold);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder shadowMultiplier(boolean shadowMultiplier) {
|
||||
nMaterialBuilderShadowMultiplier(mNativeObject, shadowMultiplier);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder specularAntiAliasing(boolean specularAntiAliasing) {
|
||||
nMaterialBuilderSpecularAntiAliasing(mNativeObject, specularAntiAliasing);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder specularAntiAliasingVariance(float variance) {
|
||||
nMaterialBuilderSpecularAntiAliasingVariance(mNativeObject, variance);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder specularAntiAliasingThreshold(float threshold) {
|
||||
nMaterialBuilderSpecularAntiAliasingThreshold(mNativeObject, threshold);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder clearCoatIorChange(boolean clearCoatIorChange) {
|
||||
nMaterialBuilderClearCoatIorChange(mNativeObject, clearCoatIorChange);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder flipUV(boolean flipUV) {
|
||||
nMaterialBuilderFlipUV(mNativeObject, flipUV);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder multiBounceAmbientOcclusion(boolean multiBounceAO) {
|
||||
nMaterialBuilderMultiBounceAmbientOcclusion(mNativeObject, multiBounceAO);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder specularAmbientOcclusion(boolean specularAO) {
|
||||
nMaterialBuilderSpecularAmbientOcclusion(mNativeObject, specularAO);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder transparencyMode(@NonNull TransparencyMode mode) {
|
||||
nMaterialBuilderTransparencyMode(mNativeObject, mode.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder platform(@NonNull Platform platform) {
|
||||
nMaterialBuilderPlatform(mNativeObject, platform.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder targetApi(@NonNull TargetApi api) {
|
||||
nMaterialBuilderTargetApi(mNativeObject, api.number);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder optimization(@NonNull Optimization optimization) {
|
||||
nMaterialBuilderOptimization(mNativeObject, optimization.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder variantFilter(byte variantFilter) {
|
||||
nMaterialBuilderVariantFilter(mNativeObject, variantFilter);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialPackage build() {
|
||||
long nativePackage = nBuilderBuild(mNativeObject);
|
||||
byte[] data = nGetPackageBytes(nativePackage);
|
||||
MaterialPackage result =
|
||||
new MaterialPackage(ByteBuffer.wrap(data), nGetPackageIsValid(nativePackage));
|
||||
nDestroyPackage(nativePackage);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class BuilderFinalizer {
|
||||
private final long mNativeObject;
|
||||
|
||||
BuilderFinalizer(long nativeObject) {
|
||||
mNativeObject = nativeObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalize() {
|
||||
try {
|
||||
super.finalize();
|
||||
} catch (Throwable t) { // Ignore
|
||||
} finally {
|
||||
nDestroyMaterialBuilder(mNativeObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static native void nMaterialBuilderInit();
|
||||
private static native void nMaterialBuilderShutdown();
|
||||
|
||||
private static native long nCreateMaterialBuilder();
|
||||
private static native void nDestroyMaterialBuilder(long nativeBuilder);
|
||||
|
||||
private static native long nBuilderBuild(long nativeBuilder);
|
||||
private static native byte[] nGetPackageBytes(long nativePackage);
|
||||
private static native boolean nGetPackageIsValid(long nativePackage);
|
||||
private static native void nDestroyPackage(long nativePackage);
|
||||
|
||||
private static native void nMaterialBuilderName(long nativeBuilder, String name);
|
||||
private static native void nMaterialBuilderShading(long nativeBuilder, int shading);
|
||||
private static native void nMaterialBuilderInterpolation(long nativeBuilder, int interpolation);
|
||||
private static native void nMaterialBuilderUniformParameter(long nativeBuilder, int type,
|
||||
String name);
|
||||
private static native void nMaterialBuilderUniformParameterArray(long nativeBuilder, int type,
|
||||
int size, String name);
|
||||
private static native void nMaterialBuilderSamplerParameter(long nativeBuilder, int type,
|
||||
int format, int precision, String name);
|
||||
private static native void nMaterialBuilderVariable(long nativeBuilder, int variable,
|
||||
String name);
|
||||
private static native void nMaterialBuilderRequire(long nativeBuilder, int attribute);
|
||||
private static native void nMaterialBuilderMaterial(long nativeBuilder, String code);
|
||||
private static native void nMaterialBuilderMaterialVertex(long nativeBuilder, String code);
|
||||
private static native void nMaterialBuilderBlending(long nativeBuilder, int mode);
|
||||
private static native void nMaterialBuilderPostLightingBlending(long nativeBuilder, int mode);
|
||||
private static native void nMaterialBuilderVertexDomain(long nativeBuilder, int vertexDomain);
|
||||
private static native void nMaterialBuilderCulling(long nativeBuilder, int mode);
|
||||
private static native void nMaterialBuilderColorWrite(long nativeBuilder, boolean enable);
|
||||
private static native void nMaterialBuilderDepthWrite(long nativeBuilder, boolean enable);
|
||||
private static native void nMaterialBuilderDepthCulling(long nativeBuilder, boolean enable);
|
||||
private static native void nMaterialBuilderDoubleSided(long nativeBuilder, boolean doubleSided);
|
||||
private static native void nMaterialBuilderMaskThreshold(long nativeBuilder, float mode);
|
||||
|
||||
private static native void nMaterialBuilderShadowMultiplier(long mNativeObject,
|
||||
boolean shadowMultiplier);
|
||||
private static native void nMaterialBuilderSpecularAntiAliasing(long mNativeObject,
|
||||
boolean specularAntiAliasing);
|
||||
private static native void nMaterialBuilderSpecularAntiAliasingVariance(long mNativeObject,
|
||||
float variance);
|
||||
private static native void nMaterialBuilderSpecularAntiAliasingThreshold(long mNativeObject,
|
||||
float threshold);
|
||||
private static native void nMaterialBuilderClearCoatIorChange(long mNativeObject,
|
||||
boolean clearCoatIorChange);
|
||||
private static native void nMaterialBuilderFlipUV(long nativeBuilder, boolean flipUV);
|
||||
private static native void nMaterialBuilderMultiBounceAmbientOcclusion(long nativeBuilder,
|
||||
boolean multiBounceAO);
|
||||
private static native void nMaterialBuilderSpecularAmbientOcclusion(long nativeBuilder,
|
||||
boolean specularAO);
|
||||
private static native void nMaterialBuilderTransparencyMode(long nativeBuilder, int mode);
|
||||
private static native void nMaterialBuilderPlatform(long nativeBuilder, int platform);
|
||||
private static native void nMaterialBuilderTargetApi(long nativeBuilder, int api);
|
||||
private static native void nMaterialBuilderOptimization(long nativeBuilder, int optimization);
|
||||
private static native void nMaterialBuilderVariantFilter(long nativeBuilder,
|
||||
byte variantFilter);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.filamat;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class MaterialPackage {
|
||||
|
||||
private final ByteBuffer mBuffer;
|
||||
private final boolean mIsValid;
|
||||
|
||||
MaterialPackage(@NonNull ByteBuffer buffer, boolean isValid) {
|
||||
mBuffer = buffer;
|
||||
mIsValid = isValid;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ByteBuffer getBuffer() {
|
||||
return mBuffer;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return mIsValid;
|
||||
}
|
||||
}
|
||||
|
||||
1
android/filament-android/.gitignore
vendored
1
android/filament-android/.gitignore
vendored
@@ -9,3 +9,4 @@
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
/.cxx
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Google Configuration Checker Style" />
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
|
||||
|
||||
@@ -6,14 +6,26 @@ add_library(filament STATIC IMPORTED)
|
||||
set_target_properties(filament PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilament.a)
|
||||
|
||||
add_library(backend STATIC IMPORTED)
|
||||
set_target_properties(backend PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbackend.a)
|
||||
|
||||
add_library(utils STATIC IMPORTED)
|
||||
set_target_properties(utils PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libutils.a)
|
||||
|
||||
add_library(ibl STATIC IMPORTED)
|
||||
set_target_properties(ibl PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libibl.a)
|
||||
|
||||
add_library(filaflat STATIC IMPORTED)
|
||||
set_target_properties(filaflat PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilaflat.a)
|
||||
|
||||
add_library(geometry STATIC IMPORTED)
|
||||
set_target_properties(geometry PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgeometry.a)
|
||||
|
||||
add_library(filabridge STATIC IMPORTED)
|
||||
set_target_properties(filabridge PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilabridge.a)
|
||||
@@ -27,13 +39,14 @@ set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
|
||||
|
||||
|
||||
include_directories(${FILAMENT_DIR}/include)
|
||||
include_directories(.. ${FILAMENT_DIR}/include)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-rtti")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-stack-protector")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -ffp-contract=fast")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility-inlines-hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffunction-sections -fdata-sections")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS" ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS" ${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
|
||||
@@ -54,6 +67,7 @@ add_library(filament-jni SHARED
|
||||
src/main/cpp/MathUtils.cpp
|
||||
src/main/cpp/RenderableManager.cpp
|
||||
src/main/cpp/Renderer.cpp
|
||||
src/main/cpp/RenderTarget.cpp
|
||||
src/main/cpp/Scene.cpp
|
||||
src/main/cpp/SkyBox.cpp
|
||||
src/main/cpp/Stream.cpp
|
||||
@@ -64,15 +78,19 @@ add_library(filament-jni SHARED
|
||||
# Android specific
|
||||
src/main/cpp/nativewindow/Android.cpp
|
||||
# Private utils
|
||||
src/main/cpp/CallbackUtils.cpp
|
||||
src/main/cpp/Filament.cpp
|
||||
src/main/cpp/NioUtils.cpp
|
||||
# Common utils
|
||||
../common/CallbackUtils.cpp
|
||||
../common/NioUtils.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(filament-jni
|
||||
filament
|
||||
backend
|
||||
filaflat
|
||||
filabridge
|
||||
geometry
|
||||
ibl
|
||||
utils
|
||||
log
|
||||
GLESv3
|
||||
|
||||
@@ -13,7 +13,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ if (project.hasProperty("filament_dist_dir")) {
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
// Our minSdkVersion is actually 21, we lie and say 14 here so apps don't have
|
||||
// to increase their minSdkVersion unnecessarily. It is however up to them to
|
||||
// ensure they do not initialize Filament on API levels < 21.
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
@@ -47,7 +50,7 @@ android {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-24")
|
||||
arguments.add("-DANDROID_PLATFORM=android-21")
|
||||
arguments.add("-DANDROID_STL=c++_static")
|
||||
arguments.add("-DFILAMENT_DIST_DIR=${filament_path}".toString())
|
||||
cppFlags.add("-std=c++14")
|
||||
@@ -74,6 +77,12 @@ android {
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
// To enable validation layers with the Vulkan backend, uncomment the following lines
|
||||
// to copy the appropriate files from the NDK to the device. Also be sure to use a debug
|
||||
// configuration for the native build.
|
||||
// jniLibs {
|
||||
// srcDirs = ["${android.ndkDirectory}/sources/third_party/vulkan/src/build-android/jniLibs"]
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,5 @@
|
||||
#Tue Aug 28 15:45:13 PDT 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||
|
||||
100
android/filament-android/gradlew
vendored
100
android/filament-android/gradlew
vendored
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
@@ -6,42 +6,6 @@
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
@@ -60,6 +24,46 @@ cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -85,7 +89,7 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
@@ -150,11 +154,19 @@ if $cygwin ; then
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
14
android/filament-android/gradlew.bat
vendored
14
android/filament-android/gradlew.bat
vendored
@@ -8,14 +8,14 @@
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -46,10 +46,9 @@ echo location of your Java installation.
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
@@ -60,11 +59,6 @@ set _SKIP=2
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
25
android/filament-android/proguard-rules.pro
vendored
25
android/filament-android/proguard-rules.pro
vendored
@@ -5,17 +5,18 @@
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
# JNI is an entry point that's hard to keep track of, so there's
|
||||
# an annotation to mark fields and methods used by native code.
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
# Keep the annotations that proguard needs to process.
|
||||
-keep class com.google.android.filament.proguard.UsedBy*
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
# Just because native code accesses members of a class, does not mean that the
|
||||
# class itself needs to be annotated - only annotate classes that are
|
||||
# referenced themselves in native code.
|
||||
-keep @com.google.android.filament.proguard.UsedBy* class * {
|
||||
<init>();
|
||||
}
|
||||
-keepclassmembers class * {
|
||||
@com.google.android.filament.proguard.UsedBy* *;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ Java_com_google_android_filament_Camera_nSetCustomProjection(JNIEnv *env, jclass
|
||||
jlong nativeCamera, jdoubleArray inMatrix_, jdouble near, jdouble far) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jdouble *inMatrix = env->GetDoubleArrayElements(inMatrix_, NULL);
|
||||
camera->setCustomProjection(*reinterpret_cast<const math::mat4 *>(inMatrix), near, far);
|
||||
camera->setCustomProjection(*reinterpret_cast<const filament::math::mat4 *>(inMatrix), near, far);
|
||||
env->ReleaseDoubleArrayElements(inMatrix_, inMatrix, JNI_ABORT);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ Java_com_google_android_filament_Camera_nSetModelMatrix(JNIEnv *env, jclass,
|
||||
jlong nativeCamera, jfloatArray in_) {
|
||||
Camera* camera = (Camera *) nativeCamera;
|
||||
jfloat *in = env->GetFloatArrayElements(in_, NULL);
|
||||
camera->setModelMatrix(*reinterpret_cast<const math::mat4f*>(in));
|
||||
camera->setModelMatrix(*reinterpret_cast<const filament::math::mat4f*>(in));
|
||||
env->ReleaseFloatArrayElements(in_, in, JNI_ABORT);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ Java_com_google_android_filament_Camera_nGetProjectionMatrix(JNIEnv *env, jclass
|
||||
jlong nativeCamera, jdoubleArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jdouble *out = env->GetDoubleArrayElements(out_, NULL);
|
||||
const math::mat4& m = camera->getProjectionMatrix();
|
||||
const filament::math::mat4& m = camera->getProjectionMatrix();
|
||||
std::copy_n(&m[0][0], 16, out);
|
||||
env->ReleaseDoubleArrayElements(out_, out, 0);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ Java_com_google_android_filament_Camera_nGetModelMatrix(JNIEnv *env, jclass,
|
||||
jlong nativeCamera, jfloatArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
const math::mat4f& m = camera->getModelMatrix();
|
||||
const filament::math::mat4f& m = camera->getModelMatrix();
|
||||
std::copy_n(&m[0][0], 16, out);
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ Java_com_google_android_filament_Camera_nGetViewMatrix(JNIEnv *env, jclass, jlon
|
||||
jfloatArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
const math::mat4f& m = camera->getViewMatrix();
|
||||
const filament::math::mat4f& m = camera->getViewMatrix();
|
||||
std::copy_n(&m[0][0], 16, out);
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ Java_com_google_android_filament_Camera_nGetPosition(JNIEnv *env, jclass, jlong
|
||||
jfloatArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
reinterpret_cast<math::float3&>(*out) = camera->getPosition();
|
||||
reinterpret_cast<filament::math::float3&>(*out) = camera->getPosition();
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ Java_com_google_android_filament_Camera_nGetLeftVector(JNIEnv *env, jclass, jlon
|
||||
jfloatArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
reinterpret_cast<math::float3&>(*out) = camera->getLeftVector();
|
||||
reinterpret_cast<filament::math::float3&>(*out) = camera->getLeftVector();
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ Java_com_google_android_filament_Camera_nGetUpVector(JNIEnv *env, jclass, jlong
|
||||
jfloatArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
reinterpret_cast<math::float3&>(*out) = camera->getUpVector();
|
||||
reinterpret_cast<filament::math::float3&>(*out) = camera->getUpVector();
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ Java_com_google_android_filament_Camera_nGetForwardVector(JNIEnv *env, jclass,
|
||||
jlong nativeCamera, jfloatArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
reinterpret_cast<math::float3&>(*out) = camera->getForwardVector();
|
||||
reinterpret_cast<filament::math::float3&>(*out) = camera->getForwardVector();
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ using namespace filament;
|
||||
using namespace utils;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Engine_nCreateEngine(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_Engine_nCreateEngine(JNIEnv*, jclass, jlong backend,
|
||||
jlong sharedContext) {
|
||||
return (jlong) Engine::create(Engine::Backend::OPENGL, nullptr, (void*) sharedContext);
|
||||
return (jlong) Engine::create((Engine::Backend) backend, nullptr, (void*) sharedContext);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -44,6 +44,13 @@ extern "C" {
|
||||
extern void *getNativeWindow(JNIEnv *env, jclass, jobject surface);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Engine_nGetBackend(JNIEnv* env,
|
||||
jclass klass, jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) engine->getBackend();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Engine_nCreateSwapChain(JNIEnv* env,
|
||||
jclass klass, jlong nativeEngine, jobject surface, jlong flags) {
|
||||
@@ -229,6 +236,14 @@ Java_com_google_android_filament_Engine_nDestroyTexture(JNIEnv*, jclass,
|
||||
engine->destroy(texture);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyRenderTarget(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeTarget) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
RenderTarget* target = (RenderTarget*) nativeTarget;
|
||||
engine->destroy(target);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyEntity(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jint entity_) {
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
#include <filament/IndexBuffer.h>
|
||||
|
||||
#include "CallbackUtils.h"
|
||||
#include "NioUtils.h"
|
||||
#include "common/CallbackUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace driver;
|
||||
using namespace backend;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_IndexBuffer_nCreateBuilder(JNIEnv *env, jclass type) {
|
||||
@@ -91,8 +91,7 @@ Java_com_google_android_filament_IndexBuffer_nSetBuffer(JNIEnv *env, jclass type
|
||||
|
||||
BufferDescriptor desc(data, sizeInBytes, &JniBufferCallback::invoke, callback);
|
||||
|
||||
indexBuffer->setBuffer(*engine, std::move(desc),
|
||||
(uint32_t) destOffsetInBytes, (uint32_t) sizeInBytes);
|
||||
indexBuffer->setBuffer(*engine, std::move(desc), (uint32_t) destOffsetInBytes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/IndirectLight.h>
|
||||
#include <filament/Texture.h>
|
||||
#include <common/NioUtils.h>
|
||||
#include <common/CallbackUtils.h>
|
||||
|
||||
using namespace filament;
|
||||
|
||||
@@ -53,7 +56,16 @@ Java_com_google_android_filament_IndirectLight_nIrradiance(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jint bands, jfloatArray sh_) {
|
||||
IndirectLight::Builder* builder = (IndirectLight::Builder*) nativeBuilder;
|
||||
jfloat* sh = env->GetFloatArrayElements(sh_, NULL);
|
||||
builder->irradiance((uint8_t) bands, (const math::float3*) sh);
|
||||
builder->irradiance((uint8_t) bands, (const filament::math::float3*) sh);
|
||||
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nRadiance(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jint bands, jfloatArray sh_) {
|
||||
IndirectLight::Builder* builder = (IndirectLight::Builder*) nativeBuilder;
|
||||
jfloat* sh = env->GetFloatArrayElements(sh_, NULL);
|
||||
builder->radiance((uint8_t) bands, (const filament::math::float3*) sh);
|
||||
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
|
||||
}
|
||||
|
||||
@@ -77,11 +89,9 @@ Java_com_google_android_filament_IndirectLight_nRotation(JNIEnv *, jclass, jlong
|
||||
jfloat v0, jfloat v1, jfloat v2, jfloat v3, jfloat v4, jfloat v5, jfloat v6, jfloat v7,
|
||||
jfloat v8) {
|
||||
IndirectLight::Builder *builder = (IndirectLight::Builder *) nativeBuilder;
|
||||
builder->rotation(math::mat3f{v0, v1, v2, v3, v4, v5, v6, v7, v8});
|
||||
builder->rotation(filament::math::mat3f{v0, v1, v2, v3, v4, v5, v6, v7, v8});
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nSetIntensity(JNIEnv*, jclass,
|
||||
jlong nativeIndirectLight, jfloat intensity) {
|
||||
@@ -97,9 +107,38 @@ Java_com_google_android_filament_IndirectLight_nGetIntensity(JNIEnv*, jclass,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nSetRotation(JNIEnv *env, jclass type,
|
||||
jlong nativeIndirectLight, jfloat v0, jfloat v1, jfloat v2, jfloat v3, jfloat v4, jfloat v5,
|
||||
jfloat v6, jfloat v7, jfloat v8) {
|
||||
Java_com_google_android_filament_IndirectLight_nSetRotation(JNIEnv*, jclass,
|
||||
jlong nativeIndirectLight, jfloat v0, jfloat v1, jfloat v2,
|
||||
jfloat v3, jfloat v4, jfloat v5, jfloat v6, jfloat v7, jfloat v8) {
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
indirectLight->setRotation(math::mat3f{v0, v1, v2, v3, v4, v5, v6, v7, v8});
|
||||
indirectLight->setRotation(filament::math::mat3f{v0, v1, v2, v3, v4, v5, v6, v7, v8});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nGetRotation(JNIEnv* env, jclass,
|
||||
jlong nativeIndirectLight, jfloatArray outRotation_) {
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
jfloat *outRotation = env->GetFloatArrayElements(outRotation_, NULL);
|
||||
*reinterpret_cast<filament::math::mat3f*>(outRotation) = indirectLight->getRotation();
|
||||
env->ReleaseFloatArrayElements(outRotation_, outRotation, 0);
|
||||
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nGetDirectionEstimate(JNIEnv* env, jclass,
|
||||
jlong nativeIndirectLight, jfloatArray outDirection_) {
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
jfloat *outDirection = env->GetFloatArrayElements(outDirection_, NULL);
|
||||
*reinterpret_cast<filament::math::float3*>(outDirection) = indirectLight->getDirectionEstimate();
|
||||
env->ReleaseFloatArrayElements(outDirection_, outDirection, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nGetColorEstimate(JNIEnv* env, jclass,
|
||||
jlong nativeIndirectLight, jfloatArray outColor_, float x, float y, float z) {
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
jfloat *outColor = env->GetFloatArrayElements(outColor_, NULL);
|
||||
*reinterpret_cast<filament::math::float4*>(outColor) =
|
||||
indirectLight->getColorEstimate(math::float3{x, y, z});
|
||||
env->ReleaseFloatArrayElements(outColor_, outColor, 0);
|
||||
}
|
||||
|
||||
@@ -22,133 +22,139 @@ using namespace filament;
|
||||
using namespace utils;
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_LightManager_nHasComponent(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nHasComponent(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint entity) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return (jboolean) lm->hasComponent((Entity &) entity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetInstance(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetInstance(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint entity) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getInstance((Entity &) entity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nDestroy(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nDestroy(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint entity) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->destroy((Entity &) entity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_LightManager_nCreateBuilder(JNIEnv *env, jclass type,
|
||||
jint lightType) {
|
||||
Java_com_google_android_filament_LightManager_nCreateBuilder(JNIEnv*, jclass, jint lightType) {
|
||||
return (jlong) new LightManager::Builder((LightManager::Type) lightType);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nDestroyBuilder(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nDestroyBuilder(JNIEnv*, jclass,
|
||||
jlong nativeBuilder) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
delete builder;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderCastShadows(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderCastShadows(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jboolean enable) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->castShadows(enable);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderShadowOptions(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jint mapSize, jfloat constantBias, jfloat normalBias, jfloat shadowFar) {
|
||||
Java_com_google_android_filament_LightManager_nBuilderShadowOptions(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jint mapSize, jfloat constantBias, jfloat normalBias, jfloat shadowFar,
|
||||
jfloat shadowNearHint, jfloat shadowFarHint, jboolean stable) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->shadowOptions(
|
||||
LightManager::ShadowOptions{(uint32_t) mapSize, constantBias, normalBias, shadowFar});
|
||||
LightManager::ShadowOptions{.mapSize = (uint32_t)mapSize,
|
||||
.constantBias = constantBias,
|
||||
.normalBias = normalBias,
|
||||
.shadowFar = shadowFar,
|
||||
.shadowNearHint = shadowNearHint,
|
||||
.shadowFarHint = shadowFarHint,
|
||||
.stable = (bool)stable});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderCastLight(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderCastLight(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jboolean enabled) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->castLight(enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderPosition(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderPosition(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat x, jfloat y, jfloat z) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->position({x, y, z});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderDirection(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderDirection(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat x, jfloat y, jfloat z) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->direction({x, y, z});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderColor(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderColor(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat linearR, jfloat linearG, jfloat linearB) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->color({linearR, linearG, linearB});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderIntensity__JF(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderIntensity__JF(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat intensity) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->intensity(intensity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderIntensity__JFF(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderIntensity__JFF(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat watts, jfloat efficiency) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->intensity(watts, efficiency);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderFalloff(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderFalloff(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat radius) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->falloff(radius);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderSpotLightCone(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderSpotLightCone(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat inner, jfloat outer) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->spotLightCone(inner, outer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderAngularRadius(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderAngularRadius(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat angularRadius) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->sunAngularRadius(angularRadius);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderHaloSize(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderHaloSize(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat haloSize) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->sunHaloSize(haloSize);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderHaloFalloff(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderHaloFalloff(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat haloFalloff) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->sunHaloFalloff(haloFalloff);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderBuild(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nBuilderBuild(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jlong nativeEngine, jint entity) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
@@ -163,133 +169,147 @@ Java_com_google_android_filament_LightManager_nGetType(JNIEnv* env,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetPosition(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetPosition(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat x, jfloat y, jfloat z) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setPosition((LightManager::Instance) i, {x, y, z});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetPosition(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetPosition(JNIEnv* env, jclass,
|
||||
jlong nativeLightManager, jint i, jfloatArray out_) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
*reinterpret_cast<math::float3 *>(out) = lm->getPosition((LightManager::Instance) i);
|
||||
jfloat *out = env->GetFloatArrayElements(out_, nullptr);
|
||||
*reinterpret_cast<filament::math::float3 *>(out) = lm->getPosition((LightManager::Instance) i);
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetDirection(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetDirection(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat x, jfloat y, jfloat z) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setDirection((LightManager::Instance) i, {x, y, z});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetDirection(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetDirection(JNIEnv *env, jclass,
|
||||
jlong nativeLightManager, jint i, jfloatArray out_) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
*reinterpret_cast<math::float3 *>(out) = lm->getDirection((LightManager::Instance) i);
|
||||
jfloat *out = env->GetFloatArrayElements(out_, nullptr);
|
||||
*reinterpret_cast<filament::math::float3 *>(out) = lm->getDirection((LightManager::Instance) i);
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetColor(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetColor(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat linearR, jfloat linearG, jfloat linearB) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setColor((LightManager::Instance) i, {linearR, linearG, linearB});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetColor(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetColor(JNIEnv *env, jclass,
|
||||
jlong nativeLightManager, jint i, jfloatArray out_) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
jfloat *out = env->GetFloatArrayElements(out_, NULL);
|
||||
*reinterpret_cast<math::float3 *>(out) = lm->getColor((LightManager::Instance) i);
|
||||
jfloat *out = env->GetFloatArrayElements(out_, nullptr);
|
||||
*reinterpret_cast<filament::math::float3 *>(out) = lm->getColor((LightManager::Instance) i);
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetIntensity__JIF(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetIntensity__JIF(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat intensity) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setIntensity((LightManager::Instance) i, intensity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetIntensity__JIFF(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetIntensity__JIFF(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat watts, jfloat efficiency) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setIntensity((LightManager::Instance) i, watts, efficiency);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetIntensity(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetIntensity(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getIntensity((LightManager::Instance) i);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetFalloff(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetFalloff(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat falloff) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setFalloff((LightManager::Instance) i, falloff);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetFalloff(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetFalloff(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getFalloff((LightManager::Instance) i);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetSpotLightCone(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetSpotLightCone(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat inner, jfloat outer) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setSpotLightCone((LightManager::Instance) i, inner, outer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetSunAngularRadius(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetSunAngularRadius(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat angularRadius) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setSunAngularRadius((LightManager::Instance) i, angularRadius);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetSunAngularRadius(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetSunAngularRadius(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getSunAngularRadius((LightManager::Instance) i);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetSunHaloSize(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetSunHaloSize(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat haloSize) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setSunHaloSize((LightManager::Instance) i, haloSize);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetHaloSize(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetHaloSize(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getSunHaloSize((LightManager::Instance) i);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetSunHaloFalloff(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nSetSunHaloFalloff(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat haloFalloff) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setSunHaloFalloff((LightManager::Instance) i, haloFalloff);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetHaloFalloff(JNIEnv *env, jclass type,
|
||||
Java_com_google_android_filament_LightManager_nGetHaloFalloff(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getSunHaloFalloff((LightManager::Instance) i);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetShadowCaster(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat shadowCaster) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setShadowCaster((LightManager::Instance) i, shadowCaster);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_LightManager_nIsShadowCaster(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->isShadowCaster((LightManager::Instance) i);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <filament/Material.h>
|
||||
|
||||
#include "NioUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
|
||||
@@ -140,6 +140,22 @@ Java_com_google_android_filament_Material_nGetMaskThreshold(JNIEnv*, jclass,
|
||||
return material->getMaskThreshold();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_Material_nGetSpecularAntiAliasingVariance(JNIEnv*, jclass,
|
||||
jlong nativeMaterial) {
|
||||
Material* material = (Material*) nativeMaterial;
|
||||
return material->getSpecularAntiAliasingVariance();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_Material_nGetSpecularAntiAliasingThreshold(JNIEnv*, jclass,
|
||||
jlong nativeMaterial) {
|
||||
Material* material = (Material*) nativeMaterial;
|
||||
return material->getSpecularAntiAliasingThreshold();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Material_nGetParameterCount(JNIEnv*, jclass,
|
||||
|
||||
@@ -27,6 +27,30 @@
|
||||
#include <math/vec4.h>
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::math;
|
||||
|
||||
enum BooleanElement {
|
||||
BOOL,
|
||||
BOOL2,
|
||||
BOOL3,
|
||||
BOOL4
|
||||
};
|
||||
|
||||
enum IntElement {
|
||||
INT,
|
||||
INT2,
|
||||
INT3,
|
||||
INT4
|
||||
};
|
||||
|
||||
enum FloatElement {
|
||||
FLOAT,
|
||||
FLOAT2,
|
||||
FLOAT3,
|
||||
FLOAT4,
|
||||
MAT3,
|
||||
MAT4
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
static void setParameter(JNIEnv* env, jlong nativeMaterialInstance, jstring name_, T v) {
|
||||
@@ -47,14 +71,14 @@ extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterBool2(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_, jboolean x, jboolean y) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::bool2{x, y});
|
||||
setParameter(env, nativeMaterialInstance, name_, bool2{x, y});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterBool3(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_, jboolean x, jboolean y, jboolean z) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::bool3{x, y, z});
|
||||
setParameter(env, nativeMaterialInstance, name_, bool3{x, y, z});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -62,7 +86,7 @@ JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterBool4(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_,
|
||||
jboolean x, jboolean y, jboolean z, jboolean w) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::bool4{x, y, z, w});
|
||||
setParameter(env, nativeMaterialInstance, name_, bool4{x, y, z, w});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -76,14 +100,14 @@ extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterInt2(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_, jint x, jint y) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::int2{x, y});
|
||||
setParameter(env, nativeMaterialInstance, name_, int2{x, y});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterInt3(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_, jint x, jint y, jint z) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::int3{x, y, z});
|
||||
setParameter(env, nativeMaterialInstance, name_, int3{x, y, z});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -91,7 +115,7 @@ JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterInt4(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_,
|
||||
jint x, jint y, jint z, jint w) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::int4{x, y, z, w});
|
||||
setParameter(env, nativeMaterialInstance, name_, int4{x, y, z, w});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -105,14 +129,14 @@ extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterFloat2(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_, jfloat x, jfloat y) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::float2{x, y});
|
||||
setParameter(env, nativeMaterialInstance, name_, float2{x, y});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterFloat3(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_, jfloat x, jfloat y, jfloat z) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::float3{x, y, z});
|
||||
setParameter(env, nativeMaterialInstance, name_, float3{x, y, z});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -120,7 +144,7 @@ JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterFloat4(JNIEnv *env, jclass,
|
||||
jlong nativeMaterialInstance, jstring name_,
|
||||
jfloat x, jfloat y, jfloat z, jfloat w) {
|
||||
setParameter(env, nativeMaterialInstance, name_, math::float4{x, y, z, w});
|
||||
setParameter(env, nativeMaterialInstance, name_, float4{x, y, z, w});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -131,9 +155,26 @@ Java_com_google_android_filament_MaterialInstance_nSetBooleanParameterArray(JNIE
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
|
||||
const char* name = env->GetStringUTFChars(name_, 0);
|
||||
size_t size = (size_t) element + 1;
|
||||
jboolean* v = env->GetBooleanArrayElements(v_, NULL);
|
||||
instance->setParameter(name, (bool*) (v + offset * size), (size_t) (count * size));
|
||||
|
||||
// NOTE: In C++, bool has an implementation-defined size. Here we assume
|
||||
// it has the same size as jboolean, which is 1 byte.
|
||||
|
||||
switch ((BooleanElement) element) {
|
||||
case BOOL:
|
||||
instance->setParameter(name, ((const bool*) v) + offset, count);
|
||||
break;
|
||||
case BOOL2:
|
||||
instance->setParameter(name, ((const bool2*) v) + offset, count);
|
||||
break;
|
||||
case BOOL3:
|
||||
instance->setParameter(name, ((const bool3*) v) + offset, count);
|
||||
break;
|
||||
case BOOL4:
|
||||
instance->setParameter(name, ((const bool4*) v) + offset, count);
|
||||
break;
|
||||
}
|
||||
|
||||
env->ReleaseBooleanArrayElements(v_, v, 0);
|
||||
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
@@ -147,10 +188,23 @@ Java_com_google_android_filament_MaterialInstance_nSetIntParameterArray(JNIEnv *
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
|
||||
const char* name = env->GetStringUTFChars(name_, 0);
|
||||
size_t size = (size_t) element + 1;
|
||||
jint* v = env->GetIntArrayElements(v_, NULL);
|
||||
instance->setParameter(name, reinterpret_cast<int32_t*>(v + offset * size),
|
||||
(size_t) (count * size));
|
||||
|
||||
switch ((IntElement) element) {
|
||||
case INT:
|
||||
instance->setParameter(name, ((const int32_t*) v) + offset, count);
|
||||
break;
|
||||
case INT2:
|
||||
instance->setParameter(name, ((const int2*) v) + offset, count);
|
||||
break;
|
||||
case INT3:
|
||||
instance->setParameter(name, ((const int3*) v) + offset, count);
|
||||
break;
|
||||
case INT4:
|
||||
instance->setParameter(name, ((const int4*) v) + offset, count);
|
||||
break;
|
||||
}
|
||||
|
||||
env->ReleaseIntArrayElements(v_, v, 0);
|
||||
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
@@ -164,16 +218,29 @@ Java_com_google_android_filament_MaterialInstance_nSetFloatParameterArray(JNIEnv
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
|
||||
const char* name = env->GetStringUTFChars(name_, 0);
|
||||
size_t size = (size_t) element + 1;
|
||||
if (size == 5) {
|
||||
// mat3
|
||||
size = 9;
|
||||
} else if (size == 6) {
|
||||
// mat4
|
||||
size = 16;
|
||||
}
|
||||
jfloat* v = env->GetFloatArrayElements(v_, NULL);
|
||||
instance->setParameter(name, v + offset * size, (size_t) (count * size));
|
||||
|
||||
switch ((FloatElement) element) {
|
||||
case FLOAT:
|
||||
instance->setParameter(name, ((const float*) v) + offset, count);
|
||||
break;
|
||||
case FLOAT2:
|
||||
instance->setParameter(name, ((const float2*) v) + offset, count);
|
||||
break;
|
||||
case FLOAT3:
|
||||
instance->setParameter(name, ((const float3*) v) + offset, count);
|
||||
break;
|
||||
case FLOAT4:
|
||||
instance->setParameter(name, ((const float4*) v) + offset, count);
|
||||
break;
|
||||
case MAT3:
|
||||
instance->setParameter(name, ((const mat3f*) v) + offset, count);
|
||||
break;
|
||||
case MAT4:
|
||||
instance->setParameter(name, ((const mat4f*) v) + offset, count);
|
||||
break;
|
||||
}
|
||||
|
||||
env->ReleaseFloatArrayElements(v_, v, 0);
|
||||
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
@@ -217,3 +284,35 @@ Java_com_google_android_filament_MaterialInstance_nSetPolygonOffset(JNIEnv*,
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setPolygonOffset(scale, constant);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetMaskThreshold(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jfloat threshold) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setMaskThreshold(threshold);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetSpecularAntiAliasingVariance(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jfloat variance) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setSpecularAntiAliasingVariance(variance);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetSpecularAntiAliasingThreshold(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jfloat threshold) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setSpecularAntiAliasingThreshold(threshold);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetDoubleSided(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jboolean doubleSided) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setDoubleSided(doubleSided);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <math/mat3.h>
|
||||
#include <math/quat.h>
|
||||
|
||||
using namespace math;
|
||||
using namespace filament::math;
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MathUtils_nPackTangentFrame(JNIEnv *env, jclass,
|
||||
|
||||
83
android/filament-android/src/main/cpp/RenderTarget.cpp
Normal file
83
android/filament-android/src/main/cpp/RenderTarget.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <functional>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <filament/RenderTarget.h>
|
||||
|
||||
using namespace filament;
|
||||
using namespace backend;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nCreateBuilder(JNIEnv *env, jclass type) {
|
||||
return (jlong) new RenderTarget::Builder();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nDestroyBuilder(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
delete builder;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderTexture(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong attachment, jlong nativeTexture) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
Texture* texture = (Texture*) nativeTexture;
|
||||
builder->texture(RenderTarget::AttachmentPoint(attachment), texture);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderMipLevel(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong attachment, jint level) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
builder->mipLevel(RenderTarget::AttachmentPoint(attachment), level);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderFace(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong attachment, jint face) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
RenderTarget::CubemapFace cubeface = (RenderTarget::CubemapFace) face;
|
||||
builder->face(RenderTarget::AttachmentPoint(attachment), cubeface);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderLayer(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong attachment, jint layer) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
builder->layer(RenderTarget::AttachmentPoint(attachment), layer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderBuild(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong nativeEngine) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
return (jlong) builder->build(*engine);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nGetMipLevel(JNIEnv *env, jclass type,
|
||||
jlong nativeTarget, jlong attachment) {
|
||||
RenderTarget* target = (RenderTarget*) nativeTarget;
|
||||
return (jint) target->getMipLevel(RenderTarget::AttachmentPoint(attachment));
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/RenderableManager.h>
|
||||
#include "NioUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace utils;
|
||||
@@ -182,6 +182,12 @@ Java_com_google_android_filament_RenderableManager_nBuilderSkinningBones(JNIEnv*
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderMorphing(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jboolean enabled) {
|
||||
RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder;
|
||||
builder->morphing(enabled);
|
||||
}
|
||||
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
@@ -197,7 +203,7 @@ Java_com_google_android_filament_RenderableManager_nSetBonesAsMatrices(JNIEnv* e
|
||||
return -1;
|
||||
}
|
||||
rm->setBones((RenderableManager::Instance)i,
|
||||
static_cast<math::mat4f const *>(data), (size_t)boneCount, (size_t)offset);
|
||||
static_cast<filament::math::mat4f const *>(data), (size_t)boneCount, (size_t)offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -218,6 +224,16 @@ Java_com_google_android_filament_RenderableManager_nSetBonesAsQuaternions(JNIEnv
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetMorphWeights(JNIEnv* env, jclass,
|
||||
jlong nativeRenderableManager, jint instance, jfloatArray weights) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
jfloat* vec = env->GetFloatArrayElements(weights, NULL);
|
||||
math::float4 floatvec(vec[0], vec[1], vec[2], vec[3]);
|
||||
env->ReleaseFloatArrayElements(weights, vec, JNI_ABORT);
|
||||
rm->setMorphWeights((RenderableManager::Instance)instance, floatvec);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetAxisAlignedBoundingBox(JNIEnv*,
|
||||
jclass, jlong nativeRenderableManager, jint i, jfloat cx, jfloat cy, jfloat cz,
|
||||
@@ -277,8 +293,8 @@ Java_com_google_android_filament_RenderableManager_nGetAxisAlignedBoundingBox(JN
|
||||
jfloat *center = env->GetFloatArrayElements(center_, NULL);
|
||||
jfloat *halfExtent = env->GetFloatArrayElements(halfExtent_, NULL);
|
||||
Box const &aabb = rm->getAxisAlignedBoundingBox((RenderableManager::Instance) i);
|
||||
*reinterpret_cast<math::float3 *>(center) = aabb.center;
|
||||
*reinterpret_cast<math::float3 *>(halfExtent) = aabb.halfExtent;
|
||||
*reinterpret_cast<filament::math::float3 *>(center) = aabb.center;
|
||||
*reinterpret_cast<filament::math::float3 *>(halfExtent) = aabb.halfExtent;
|
||||
env->ReleaseFloatArrayElements(center_, center, 0);
|
||||
env->ReleaseFloatArrayElements(halfExtent_, halfExtent, 0);
|
||||
}
|
||||
@@ -299,6 +315,21 @@ Java_com_google_android_filament_RenderableManager_nSetMaterialInstanceAt(JNIEnv
|
||||
materialInstance);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT long JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nGetMaterialInstanceAt(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jint primitiveIndex) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
return (long) rm->getMaterialInstanceAt((RenderableManager::Instance) i, (size_t) primitiveIndex);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT long JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nGetMaterialAt(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jint primitiveIndex) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
MaterialInstance *mi = rm->getMaterialInstanceAt((RenderableManager::Instance) i, (size_t) primitiveIndex);
|
||||
return (long) mi->getMaterial();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetGeometryAt__JIIIJJII(JNIEnv*,
|
||||
jclass, jlong nativeRenderableManager, jint i, jint primitiveIndex, jint primitiveType,
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
#include <filament/Engine.h>
|
||||
#include <filament/Renderer.h>
|
||||
#include <filament/Viewport.h>
|
||||
#include <filament/driver/PixelBufferDescriptor.h>
|
||||
#include <backend/PixelBufferDescriptor.h>
|
||||
|
||||
#include "CallbackUtils.h"
|
||||
#include "NioUtils.h"
|
||||
#include "common/CallbackUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace driver;
|
||||
using namespace backend;
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Renderer_nBeginFrame(JNIEnv *, jclass, jlong nativeRenderer,
|
||||
@@ -51,16 +51,16 @@ Java_com_google_android_filament_Renderer_nRender(JNIEnv *, jclass, jlong native
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Renderer_nMirrorFrame(JNIEnv *, jclass, jlong nativeRenderer,
|
||||
Java_com_google_android_filament_Renderer_nCopyFrame(JNIEnv *, jclass, jlong nativeRenderer,
|
||||
jlong nativeDstSwapChain,
|
||||
jint dstLeft, jint dstBottom, jint dstWidth, jint dstHeight,
|
||||
jint srcLeft, jint srcBottom, jint srcWidth, jint srcHeight,
|
||||
jint flags) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
SwapChain *dstSwapChain = (SwapChain *) nativeDstSwapChain;
|
||||
const Viewport dstViewport {dstLeft, dstBottom, (uint32_t) dstWidth, (uint32_t) dstHeight};
|
||||
const Viewport srcViewport {srcLeft, srcBottom, (uint32_t) srcWidth, (uint32_t) srcHeight};
|
||||
renderer->mirrorFrame(dstSwapChain, dstViewport, srcViewport, (uint32_t) flags);
|
||||
const filament::Viewport dstViewport {dstLeft, dstBottom, (uint32_t) dstWidth, (uint32_t) dstHeight};
|
||||
const filament::Viewport srcViewport {srcLeft, srcBottom, (uint32_t) srcWidth, (uint32_t) srcHeight};
|
||||
renderer->copyFrame(dstSwapChain, dstViewport, srcViewport, (uint32_t) flags);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
@@ -87,8 +87,8 @@ Java_com_google_android_filament_Renderer_nReadPixels(JNIEnv *env, jclass,
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
PixelBufferDescriptor desc(buffer, sizeInBytes, (driver::PixelDataFormat) format,
|
||||
(driver::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) top,
|
||||
PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
|
||||
(backend::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) top,
|
||||
(uint32_t) stride, &JniBufferCallback::invoke, callback);
|
||||
|
||||
renderer->readPixels(uint32_t(xoffset), uint32_t(yoffset), uint32_t(width), uint32_t(height),
|
||||
@@ -96,3 +96,15 @@ Java_com_google_android_filament_Renderer_nReadPixels(JNIEnv *env, jclass,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
Java_com_google_android_filament_Renderer_nGetUserTime(JNIEnv*, jclass, jlong nativeRenderer) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
return renderer->getUserTime();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Renderer_nResetUserTime(JNIEnv*, jclass, jlong nativeRenderer) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
renderer->resetUserTime();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,15 @@ Java_com_google_android_filament_Scene_nAddEntity(JNIEnv *env, jclass type, jlon
|
||||
scene->addEntity((Entity&) entity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Scene_nAddEntities(JNIEnv *env, jclass type, jlong nativeScene,
|
||||
jintArray entities) {
|
||||
Scene* scene = (Scene*) nativeScene;
|
||||
Entity* nativeEntities = (Entity*) env->GetIntArrayElements(entities, nullptr);
|
||||
scene->addEntities(nativeEntities, env->GetArrayLength(entities));
|
||||
env->ReleaseIntArrayElements(entities, (jint*) nativeEntities, JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Scene_nRemove(JNIEnv *env, jclass type, jlong nativeScene,
|
||||
jint entity) {
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/Stream.h>
|
||||
#include <filament/driver/PixelBufferDescriptor.h>
|
||||
#include <backend/PixelBufferDescriptor.h>
|
||||
|
||||
#include "NioUtils.h"
|
||||
#include "CallbackUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
#include "common/CallbackUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace driver;
|
||||
using namespace backend;
|
||||
|
||||
class StreamBuilder {
|
||||
public:
|
||||
@@ -145,8 +145,8 @@ Java_com_google_android_filament_Stream_nReadPixels(JNIEnv *env, jclass,
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
PixelBufferDescriptor desc(buffer, sizeInBytes, (driver::PixelDataFormat) format,
|
||||
(driver::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) top,
|
||||
PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
|
||||
(backend::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) top,
|
||||
(uint32_t) stride, &JniBufferCallback::invoke, callback);
|
||||
|
||||
stream->readPixels(uint32_t(xoffset), uint32_t(yoffset), uint32_t(width), uint32_t(height),
|
||||
|
||||
@@ -23,21 +23,23 @@
|
||||
#include <android/bitmap.h>
|
||||
#endif
|
||||
|
||||
#include <filament/driver/BufferDescriptor.h>
|
||||
#include <backend/BufferDescriptor.h>
|
||||
#include <filament/Engine.h>
|
||||
#include <filament/Stream.h>
|
||||
#include <filament/Texture.h>
|
||||
|
||||
#include "CallbackUtils.h"
|
||||
#include "NioUtils.h"
|
||||
#include "common/CallbackUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace driver;
|
||||
using namespace backend;
|
||||
|
||||
static size_t getTextureDataSize(const Texture *texture, size_t level,
|
||||
Texture::Format format, Texture::Type type, size_t stride, size_t alignment) {
|
||||
// Zero stride implies tight row-to-row packing.
|
||||
stride = stride == 0 ? texture->getWidth(level) : std::max(size_t(1), stride >> level);
|
||||
return Texture::computeTextureDataSize(format, type,
|
||||
std::max(size_t(1), stride >> level), texture->getHeight(level), alignment);
|
||||
stride, texture->getHeight(level), alignment);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
@@ -105,10 +107,10 @@ Java_com_google_android_filament_Texture_nBuilderFormat(JNIEnv*, jclass,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Texture_nBuilderRgbm(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jboolean enable) {
|
||||
Java_com_google_android_filament_Texture_nBuilderUsage(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jint flags) {
|
||||
Texture::Builder *builder = (Texture::Builder *) nativeBuilder;
|
||||
builder->rgbm(enable);
|
||||
builder->usage((Texture::Usage) flags);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
@@ -161,12 +163,6 @@ Java_com_google_android_filament_Texture_nGetInternalFormat(JNIEnv*, jclass,
|
||||
return (jint) texture->getFormat();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Texture_nGetRgbm(JNIEnv*, jclass, jlong nativeTexture) {
|
||||
Texture *texture = (Texture *) nativeTexture;
|
||||
return static_cast<jboolean>(texture->isRgbm());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImage(JNIEnv* env, jclass, jlong nativeTexture,
|
||||
jlong nativeEngine, jint level, jint xoffset, jint yoffset, jint width, jint height,
|
||||
@@ -189,8 +185,8 @@ Java_com_google_android_filament_Texture_nSetImage(JNIEnv* env, jclass, jlong na
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes, (driver::PixelDataFormat) format,
|
||||
(driver::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) bottom,
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
|
||||
(backend::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) bottom,
|
||||
(uint32_t) stride, &JniBufferCallback::invoke, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level, (uint32_t) xoffset, (uint32_t) yoffset,
|
||||
@@ -221,7 +217,7 @@ Java_com_google_android_filament_Texture_nSetImageCompressed(JNIEnv *env, jclass
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes,
|
||||
(driver::CompressedPixelDataType) compressedFormat, (uint32_t) compressedSizeInBytes,
|
||||
(backend::CompressedPixelDataType) compressedFormat, (uint32_t) compressedSizeInBytes,
|
||||
&JniBufferCallback::invoke, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level, (uint32_t) xoffset, (uint32_t) yoffset,
|
||||
@@ -256,8 +252,8 @@ Java_com_google_android_filament_Texture_nSetImageCubemap(JNIEnv *env, jclass,
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes, (driver::PixelDataFormat) format,
|
||||
(driver::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) bottom,
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
|
||||
(backend::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) bottom,
|
||||
(uint32_t) stride, &JniBufferCallback::invoke, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level, std::move(desc), faceOffsets);
|
||||
@@ -292,7 +288,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemapCompressed(JNIEnv *env,
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes,
|
||||
(driver::CompressedPixelDataType) compressedFormat, (uint32_t) compressedSizeInBytes,
|
||||
(backend::CompressedPixelDataType) compressedFormat, (uint32_t) compressedSizeInBytes,
|
||||
&JniBufferCallback::invoke, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level, std::move(desc), faceOffsets);
|
||||
@@ -333,6 +329,48 @@ Java_com_google_android_filament_Texture_nIsStreamValidForTexture(JNIEnv*, jclas
|
||||
return (jboolean) (texture->getTarget() == SamplerType::SAMPLER_EXTERNAL);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nGeneratePrefilterMipmap(JNIEnv *env, jclass,
|
||||
jlong nativeTexture, jlong nativeEngine, jint width, jint height,
|
||||
jobject storage, jint remaining, jint left,
|
||||
jint top, jint type, jint alignment, jint stride, jint format,
|
||||
jintArray faceOffsetsInBytes_, jobject handler, jobject runnable, jint sampleCount,
|
||||
jboolean mirror) {
|
||||
|
||||
Texture *texture = (Texture *) nativeTexture;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
|
||||
jint *faceOffsetsInBytes = env->GetIntArrayElements(faceOffsetsInBytes_, NULL);
|
||||
Texture::FaceOffsets faceOffsets;
|
||||
std::copy_n(faceOffsetsInBytes, 6, faceOffsets.offsets);
|
||||
env->ReleaseIntArrayElements(faceOffsetsInBytes_, faceOffsetsInBytes, JNI_ABORT);
|
||||
|
||||
stride = stride ? stride : width;
|
||||
size_t sizeInBytes = 6 *
|
||||
Texture::computeTextureDataSize((Texture::Format) format, (Texture::Type) type,
|
||||
(size_t) stride, (size_t) height, (size_t) alignment);
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (remaining << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
|
||||
(backend::PixelDataType) type, (uint8_t) alignment, (uint32_t)0, (uint32_t)0,
|
||||
(uint32_t) stride, &JniBufferCallback::invoke, callback);
|
||||
|
||||
Texture::PrefilterOptions options;
|
||||
options.sampleCount = sampleCount;
|
||||
options.mirror = mirror;
|
||||
texture->generatePrefilterMipmap(*engine, std::move(desc), faceOffsets, &options);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ANDROID SPECIFIC BITS
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -59,7 +59,7 @@ Java_com_google_android_filament_TransformManager_nCreateArray(JNIEnv* env,
|
||||
if (localTransform_) {
|
||||
jfloat *localTransform = env->GetFloatArrayElements(localTransform_, NULL);
|
||||
tm->create(entity, (TransformManager::Instance) parent,
|
||||
*reinterpret_cast<const math::mat4f *>(localTransform));
|
||||
*reinterpret_cast<const filament::math::mat4f *>(localTransform));
|
||||
env->ReleaseFloatArrayElements(localTransform_, localTransform, JNI_ABORT);
|
||||
} else {
|
||||
tm->create(entity, (TransformManager::Instance) parent);
|
||||
@@ -90,7 +90,7 @@ Java_com_google_android_filament_TransformManager_nSetTransform(JNIEnv* env,
|
||||
TransformManager* tm = (TransformManager*) nativeTransformManager;
|
||||
jfloat *localTransform = env->GetFloatArrayElements(localTransform_, NULL);
|
||||
tm->setTransform((TransformManager::Instance) i,
|
||||
*reinterpret_cast<const math::mat4f *>(localTransform));
|
||||
*reinterpret_cast<const filament::math::mat4f *>(localTransform));
|
||||
env->ReleaseFloatArrayElements(localTransform_, localTransform, JNI_ABORT);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ Java_com_google_android_filament_TransformManager_nGetTransform(JNIEnv* env,
|
||||
jfloatArray outLocalTransform_) {
|
||||
TransformManager* tm = (TransformManager*) nativeTransformManager;
|
||||
jfloat *outLocalTransform = env->GetFloatArrayElements(outLocalTransform_, NULL);
|
||||
*reinterpret_cast<math::mat4f *>(outLocalTransform) = tm->getTransform(
|
||||
*reinterpret_cast<filament::math::mat4f *>(outLocalTransform) = tm->getTransform(
|
||||
(TransformManager::Instance) i);
|
||||
env->ReleaseFloatArrayElements(outLocalTransform_, outLocalTransform, 0);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ Java_com_google_android_filament_TransformManager_nGetWorldTransform(JNIEnv* env
|
||||
jfloatArray outWorldTransform_) {
|
||||
TransformManager* tm = (TransformManager*) nativeTransformManager;
|
||||
jfloat *outWorldTransform = env->GetFloatArrayElements(outWorldTransform_, NULL);
|
||||
*reinterpret_cast<math::mat4f *>(outWorldTransform) = tm->getWorldTransform(
|
||||
*reinterpret_cast<filament::math::mat4f *>(outWorldTransform) = tm->getWorldTransform(
|
||||
(TransformManager::Instance) i);
|
||||
env->ReleaseFloatArrayElements(outWorldTransform_, outWorldTransform, 0);
|
||||
}
|
||||
|
||||
@@ -21,11 +21,15 @@
|
||||
|
||||
#include <filament/VertexBuffer.h>
|
||||
|
||||
#include "CallbackUtils.h"
|
||||
#include "NioUtils.h"
|
||||
#include <math/vec3.h>
|
||||
#include <math/vec4.h>
|
||||
|
||||
#include "common/CallbackUtils.h"
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace driver;
|
||||
using namespace filament::math;
|
||||
using namespace backend;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_VertexBuffer_nCreateBuilder(JNIEnv *env, jclass type) {
|
||||
@@ -65,9 +69,9 @@ Java_com_google_android_filament_VertexBuffer_nBuilderAttribute(JNIEnv *env, jcl
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_VertexBuffer_nBuilderNormalized(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jint attribute) {
|
||||
jlong nativeBuilder, jint attribute, jboolean normalized) {
|
||||
VertexBuffer::Builder* builder = (VertexBuffer::Builder *) nativeBuilder;
|
||||
builder->normalized((VertexAttribute) attribute);
|
||||
builder->normalized((VertexAttribute) attribute, normalized);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
@@ -106,7 +110,47 @@ Java_com_google_android_filament_VertexBuffer_nSetBufferAt(JNIEnv *env, jclass t
|
||||
BufferDescriptor desc(data, sizeInBytes, &JniBufferCallback::invoke, callback);
|
||||
|
||||
vertexBuffer->setBufferAt(*engine, (uint8_t) bufferIndex, std::move(desc),
|
||||
(uint32_t) destOffsetInBytes, (uint32_t) sizeInBytes);
|
||||
(uint32_t) destOffsetInBytes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_VertexBuffer_nPopulateTangentQuaternions(JNIEnv *env,
|
||||
jclass type, jint quatType, jint quatCount, jobject outBuffer, jint outRemaining,
|
||||
jint outStride, jobject normals, jint normalsRemaining, jint normalsStride,
|
||||
jobject tangents, jint tangentsRemaining, jint tangentsStride) {
|
||||
|
||||
AutoBuffer outNioBuffer(env, outBuffer, outRemaining, true);
|
||||
void* outData = outNioBuffer.getData();
|
||||
|
||||
AutoBuffer normalsNioBuffer(env, normals, normalsRemaining);
|
||||
auto normalsData = (const float3*) normalsNioBuffer.getData();
|
||||
|
||||
if (tangents) {
|
||||
AutoBuffer tangentsNioBuffer(env, tangents, tangentsRemaining);
|
||||
auto tangentsData = (const float4*) tangentsNioBuffer.getData();
|
||||
VertexBuffer::populateTangentQuaternions({
|
||||
.quatType = (VertexBuffer::QuatType) quatType,
|
||||
.quatCount = (size_t) quatCount,
|
||||
.outBuffer = outData,
|
||||
.outStride = (size_t) outStride,
|
||||
.normals = normalsData,
|
||||
.normalsStride = (size_t) normalsStride,
|
||||
.tangents = tangentsData,
|
||||
.tangentsStride = (size_t) tangentsStride
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
VertexBuffer::populateTangentQuaternions({
|
||||
.quatType = (VertexBuffer::QuatType) quatType,
|
||||
.quatCount = (size_t) quatCount,
|
||||
.outBuffer = outData,
|
||||
.outStride = (size_t) outStride,
|
||||
.normals = normalsData,
|
||||
.normalsStride = (size_t) normalsStride,
|
||||
.tangents = nullptr,
|
||||
.tangentsStride = 0
|
||||
});
|
||||
}
|
||||
|
||||
@@ -94,6 +94,13 @@ Java_com_google_android_filament_View_nSetShadowsEnabled(JNIEnv*, jclass,
|
||||
view->setShadowsEnabled(enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetRenderTarget(JNIEnv*, jclass,
|
||||
jlong nativeView, jlong nativeTarget) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setRenderTarget((RenderTarget*) nativeTarget);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetSampleCount(JNIEnv*, jclass,
|
||||
jlong nativeView, jint count) {
|
||||
@@ -122,6 +129,34 @@ Java_com_google_android_filament_View_nGetAntiAliasing(JNIEnv*, jclass,
|
||||
return (jint) view->getAntiAliasing();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetToneMapping(JNIEnv*, jclass,
|
||||
jlong nativeView, jint type) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setToneMapping(View::ToneMapping(type));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetToneMapping(JNIEnv*, jclass,
|
||||
jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return (jint) view->getToneMapping();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetDithering(JNIEnv*, jclass,
|
||||
jlong nativeView, jint dithering) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setDithering((View::Dithering) dithering);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetDithering(JNIEnv*, jclass,
|
||||
jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return (jint)view->getDithering();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetDynamicResolutionOptions(JNIEnv*,
|
||||
jclass, jlong nativeView, jboolean enabled, jboolean homogeneousScaling,
|
||||
@@ -134,8 +169,8 @@ Java_com_google_android_filament_View_nSetDynamicResolutionOptions(JNIEnv*,
|
||||
options.targetFrameTimeMilli = targetFrameTimeMilli;
|
||||
options.headRoomRatio = headRoomRatio;
|
||||
options.scaleRate = scaleRate;
|
||||
options.minScale = math::float2{minScale};
|
||||
options.maxScale = math::float2{maxScale};
|
||||
options.minScale = filament::math::float2{minScale};
|
||||
options.maxScale = filament::math::float2{maxScale};
|
||||
options.history = (uint8_t) history;
|
||||
view->setDynamicResolutionOptions(options);
|
||||
}
|
||||
@@ -177,3 +212,37 @@ Java_com_google_android_filament_View_nIsPostProcessingEnabled(JNIEnv*,
|
||||
View* view = (View*) nativeView;
|
||||
return static_cast<jboolean>(view->isPostProcessingEnabled());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetFrontFaceWindingInverted(JNIEnv*,
|
||||
jclass, jlong nativeView, jboolean inverted) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setFrontFaceWindingInverted(inverted);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_View_nIsFrontFaceWindingInverted(JNIEnv*,
|
||||
jclass, jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return static_cast<jboolean>(view->isFrontFaceWindingInverted());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetAmbientOcclusion(JNIEnv*, jclass, jlong nativeView, jint ordinal) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setAmbientOcclusion((View::AmbientOcclusion)ordinal);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetAmbientOcclusion(JNIEnv*, jclass, jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return (jint)view->getAmbientOcclusion();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetAmbientOcclusionOptions(JNIEnv*, jclass,
|
||||
jlong nativeView, jfloat radius, jfloat bias, jfloat power, jfloat resolution) {
|
||||
View* view = (View*) nativeView;
|
||||
View::AmbientOcclusionOptions options = { .radius = radius, .bias = bias, .power = power, .resolution = resolution};
|
||||
view->setAmbientOcclusionOptions(options);
|
||||
}
|
||||
|
||||
@@ -27,46 +27,20 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
void chooseAndSetPixelFormat(HDC dc) {
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
1,
|
||||
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
|
||||
PFD_TYPE_RGBA,
|
||||
32, // Colordepth of the framebuffer.
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
24, // Number of bits for the depthbuffer
|
||||
0, // Number of bits for the stencilbuffer
|
||||
0, // Number of aux buffers in the framebuffer.
|
||||
PFD_MAIN_PLANE,
|
||||
0,
|
||||
0, 0, 0
|
||||
};
|
||||
int pixelFormat = ChoosePixelFormat(dc, &pfd);
|
||||
SetPixelFormat(dc, pixelFormat, &pfd);
|
||||
}
|
||||
|
||||
void* getNativeWindow(JNIEnv* env, jclass, jobject surface) {
|
||||
void* win = nullptr;
|
||||
JAWT_DrawingSurface* ds = nullptr;
|
||||
JAWT_DrawingSurfaceInfo* dsi = nullptr;
|
||||
|
||||
if (!acquireDrawingSurface(env, surface, &ds, &dsi)) {
|
||||
return win;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JAWT_Win32DrawingSurfaceInfo* dsi_win32 = (JAWT_Win32DrawingSurfaceInfo*) dsi->platformInfo;
|
||||
HDC dc = dsi_win32->hdc;
|
||||
chooseAndSetPixelFormat(dsi_win32->hdc);
|
||||
HWND hWnd = dsi_win32->hwnd;
|
||||
|
||||
win = (void*) dsi_win32->hdc;
|
||||
releaseDrawingSurface(ds, dsi);
|
||||
|
||||
return win;
|
||||
return (void*) hWnd;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,16 +56,11 @@ jlong createNativeSurface(jint width, jint height) {
|
||||
HWND window = CreateWindowA("STATIC", "dummy", 0, 0, 0, width, height, NULL, NULL, NULL, NULL);
|
||||
SetWindowLong(window, GWL_STYLE, 0); //remove all window styles
|
||||
|
||||
HDC dc = GetDC(window);
|
||||
chooseAndSetPixelFormat(dc);
|
||||
|
||||
return (jlong) dc;
|
||||
return (jlong) window;
|
||||
}
|
||||
|
||||
void destroyNativeSurface(jlong surface) {
|
||||
HDC dc = (HDC) surface;
|
||||
HWND window = WindowFromDC(dc);
|
||||
ReleaseDC(window, dc);
|
||||
HWND window = (HWND) surface;
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament;
|
||||
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
final class Asserts {
|
||||
private Asserts() {
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 9)
|
||||
static float[] assertMat3f(@Nullable float[] out) {
|
||||
if (out == null) out = new float[9];
|
||||
else if (out.length < 9) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 9");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static void assertMat3fIn(@NonNull @Size(min = 9) float[] in) {
|
||||
if (in.length < 9) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 9");
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 16)
|
||||
static double[] assertMat4d(@Nullable double[] out) {
|
||||
if (out == null) out = new double[16];
|
||||
else if (out.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static void assertMat4dIn(@NonNull @Size(min = 16) double[] in) {
|
||||
if (in.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 16)
|
||||
static float[] assertMat4f(@Nullable float[] out) {
|
||||
if (out == null) out = new float[16];
|
||||
else if (out.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static void assertMat4fIn(@NonNull @Size(min = 16) float[] in) {
|
||||
if (in.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 3)
|
||||
static float[] assertFloat3(@Nullable float[] out) {
|
||||
if (out == null) out = new float[3];
|
||||
else if (out.length < 3) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 3");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 4)
|
||||
static float[] assertFloat4(@Nullable float[] out) {
|
||||
if (out == null) out = new float[4];
|
||||
else if (out.length < 4) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 4");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public class Camera {
|
||||
*/
|
||||
public void setCustomProjection(@NonNull @Size(min = 16) double inMatrix[],
|
||||
double near, double far) {
|
||||
assertMat4dIn(inMatrix);
|
||||
Asserts.assertMat4dIn(inMatrix);
|
||||
nSetCustomProjection(getNativeObject(), inMatrix, near, far);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public class Camera {
|
||||
* @param in
|
||||
*/
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) float in[]) {
|
||||
assertMat4fIn(in);
|
||||
Asserts.assertMat4fIn(in);
|
||||
nSetModelMatrix(getNativeObject(), in);
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public class Camera {
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public double[] getProjectionMatrix(@Nullable @Size(min = 16) double out[]) {
|
||||
out = assertMat4d(out);
|
||||
out = Asserts.assertMat4d(out);
|
||||
nGetProjectionMatrix(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -287,7 +287,7 @@ public class Camera {
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public float[] getModelMatrix(@Nullable @Size(min = 16) float out[]) {
|
||||
out = assertMat4f(out);
|
||||
out = Asserts.assertMat4f(out);
|
||||
nGetModelMatrix(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ public class Camera {
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public float[] getViewMatrix(@Nullable @Size(min = 16) float out[]) {
|
||||
out = assertMat4f(out);
|
||||
out = Asserts.assertMat4f(out);
|
||||
nGetViewMatrix(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -314,7 +314,7 @@ public class Camera {
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getPosition(@Nullable @Size(min = 3) float out[]) {
|
||||
out = assertFloat3(out);
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetPosition(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ public class Camera {
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getLeftVector(@Nullable @Size(min = 3) float out[]) {
|
||||
out = assertFloat3(out);
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetLeftVector(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class Camera {
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getUpVector(@Nullable @Size(min = 3) float out[]) {
|
||||
out = assertFloat3(out);
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetUpVector(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -356,7 +356,7 @@ public class Camera {
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getForwardVector(@Nullable @Size(min = 3) float out[]) {
|
||||
out = assertFloat3(out);
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetForwardVector(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ public class Camera {
|
||||
return nGetSensitivity(getNativeObject());
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Camera");
|
||||
}
|
||||
@@ -406,45 +406,6 @@ public class Camera {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 16)
|
||||
private static double[] assertMat4d(@Nullable double[] out) {
|
||||
if (out == null) out = new double[16];
|
||||
else if (out.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 16)
|
||||
private static float[] assertMat4f(@Nullable float[] out) {
|
||||
if (out == null) out = new float[16];
|
||||
else if (out.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static void assertMat4dIn(@NonNull @Size(min = 16) double[] in) {
|
||||
if (in.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertMat4fIn(@NonNull @Size(min = 16) float[] in) {
|
||||
if (in.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 3)
|
||||
private static float[] assertFloat3(@Nullable float[] out) {
|
||||
if (out == null) out = new float[3];
|
||||
else if (out.length < 3) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 3");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static native void nSetProjection(long nativeCamera, int projection, double left, double right, double bottom, double top, double near, double far);
|
||||
private static native void nSetProjectionFov(long nativeCamera, double fovInDegrees, double aspect, double near, double far, int fov);
|
||||
private static native void nSetLensProjection(long nativeCamera, double focalLength, double near, double far);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.google.android.filament;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public class Engine {
|
||||
@@ -24,6 +26,13 @@ public class Engine {
|
||||
@NonNull private final LightManager mLightManager;
|
||||
@NonNull private final RenderableManager mRenderableManager;
|
||||
|
||||
public enum Backend {
|
||||
DEFAULT, // Automatically selects an appropriate driver for the platform.
|
||||
OPENGL, // Selects the OpenGL ES driver.
|
||||
VULKAN, // Selects the experimental Vulkan driver.
|
||||
NOOP, // Selects the no-op driver for testing purposes.
|
||||
}
|
||||
|
||||
private Engine(long nativeEngine) {
|
||||
mNativeObject = nativeEngine;
|
||||
mTransformManager = new TransformManager(nGetTransformManager(nativeEngine));
|
||||
@@ -33,7 +42,14 @@ public class Engine {
|
||||
|
||||
@NonNull
|
||||
public static Engine create() {
|
||||
long nativeEngine = nCreateEngine(0);
|
||||
long nativeEngine = nCreateEngine(0, 0);
|
||||
if (nativeEngine == 0) throw new IllegalStateException("Couldn't create Engine");
|
||||
return new Engine(nativeEngine);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Engine create(@NonNull Backend backend) {
|
||||
long nativeEngine = nCreateEngine(backend.ordinal(), 0);
|
||||
if (nativeEngine == 0) throw new IllegalStateException("Couldn't create Engine");
|
||||
return new Engine(nativeEngine);
|
||||
}
|
||||
@@ -46,7 +62,7 @@ public class Engine {
|
||||
@NonNull
|
||||
public static Engine create(@NonNull Object sharedContext) {
|
||||
if (Platform.get().validateSharedContext(sharedContext)) {
|
||||
long nativeEngine = nCreateEngine(
|
||||
long nativeEngine = nCreateEngine(0,
|
||||
Platform.get().getSharedContextNativeHandle(sharedContext));
|
||||
if (nativeEngine == 0) throw new IllegalStateException("Couldn't create Engine");
|
||||
return new Engine(nativeEngine);
|
||||
@@ -63,6 +79,10 @@ public class Engine {
|
||||
clearNativeObject();
|
||||
}
|
||||
|
||||
public Backend getBackend() {
|
||||
return Backend.values()[(int) nGetBackend(getNativeObject())];
|
||||
}
|
||||
|
||||
// SwapChain
|
||||
|
||||
/**
|
||||
@@ -71,13 +91,19 @@ public class Engine {
|
||||
* - Other: none
|
||||
*/
|
||||
public SwapChain createSwapChain(@NonNull Object surface) {
|
||||
return createSwapChain(surface, 0);
|
||||
return createSwapChain(surface, SwapChain.CONFIG_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Valid surface types:
|
||||
* - Android: Surface
|
||||
* - Other: none
|
||||
*
|
||||
* Flags: see CONFIG flags in SwapChain.
|
||||
*
|
||||
* @see SwapChain#CONFIG_DEFAULT
|
||||
* @see SwapChain#CONFIG_TRANSPARENT
|
||||
* @see SwapChain#CONFIG_READABLE
|
||||
*/
|
||||
public SwapChain createSwapChain(@NonNull Object surface, long flags) {
|
||||
if (Platform.get().validateSurface(surface)) {
|
||||
@@ -221,6 +247,11 @@ public class Engine {
|
||||
texture.clearNativeObject();
|
||||
}
|
||||
|
||||
public void destroyRenderTarget(@NonNull RenderTarget target) {
|
||||
nDestroyRenderTarget(getNativeObject(), target.getNativeObject());
|
||||
target.clearNativeObject();
|
||||
}
|
||||
|
||||
public void destroyEntity(@Entity int entity) {
|
||||
nDestroyEntity(getNativeObject(), entity);
|
||||
}
|
||||
@@ -246,7 +277,8 @@ public class Engine {
|
||||
Fence.waitAndDestroy(createFence(Fence.Type.HARD), Fence.Mode.FLUSH);
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
@UsedByReflection("TextureHelper.java")
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Engine");
|
||||
}
|
||||
@@ -257,8 +289,9 @@ public class Engine {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native long nCreateEngine(long sharedContext);
|
||||
private static native long nCreateEngine(long backend, long sharedContext);
|
||||
private static native void nDestroyEngine(long nativeEngine);
|
||||
private static native long nGetBackend(long nativeEngine);
|
||||
private static native long nCreateSwapChain(long nativeEngine, Object nativeWindow, long flags);
|
||||
private static native long nCreateSwapChainFromRawPointer(long nativeEngine, long pointer, long flags);
|
||||
private static native void nDestroySwapChain(long nativeEngine, long nativeSwapChain);
|
||||
@@ -281,6 +314,7 @@ public class Engine {
|
||||
private static native void nDestroyMaterialInstance(long nativeEngine, long nativeMaterialInstance);
|
||||
private static native void nDestroySkybox(long nativeEngine, long nativeSkybox);
|
||||
private static native void nDestroyTexture(long nativeEngine, long nativeTexture);
|
||||
private static native void nDestroyRenderTarget(long nativeEngine, long nativeTarget);
|
||||
private static native void nDestroyEntity(long nativeEngine, int entity);
|
||||
private static native long nGetTransformManager(long nativeEngine);
|
||||
private static native long nGetLightManager(long nativeEngine);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.google.android.filament;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
@@ -66,6 +68,11 @@ public class EntityManager {
|
||||
return nIsAlive(mNativeObject, entity);
|
||||
}
|
||||
|
||||
@UsedByReflection("AssetLoader.java")
|
||||
public long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
private static native long nGetEntityManager();
|
||||
private static native void nCreateArray(long nativeEntityManager, int n, int[] entities);
|
||||
private static native int nCreate(long nativeEntityManager);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Fence {
|
||||
}
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Fence");
|
||||
}
|
||||
|
||||
@@ -30,13 +30,6 @@ public class IndexBuffer {
|
||||
mNativeObject = nativeIndexBuffer;
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed IndexBuffer");
|
||||
}
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
// Keep to finalize native resources
|
||||
@@ -121,6 +114,13 @@ public class IndexBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed IndexBuffer");
|
||||
}
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
void clearNativeObject() {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
@@ -16,14 +16,18 @@
|
||||
|
||||
package com.google.android.filament;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
public class IndirectLight {
|
||||
long mNativeObject;
|
||||
|
||||
private IndirectLight(long indirectLight) {
|
||||
@UsedByReflection("KtxLoader.java")
|
||||
IndirectLight(long indirectLight) {
|
||||
mNativeObject = indirectLight;
|
||||
}
|
||||
|
||||
@@ -61,6 +65,24 @@ public class IndirectLight {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder radiance(@IntRange(from=1, to=3) int bands, @NonNull float[] sh) {
|
||||
switch (bands) {
|
||||
case 1: if (sh.length < 3)
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
"1 band SH, array must be at least 1 x float3"); else break;
|
||||
case 2: if (sh.length < 4 * 3)
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
"2 bands SH, array must be at least 4 x float3"); else break;
|
||||
case 3: if (sh.length < 9 * 3)
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
"3 bands SH, array must be at least 9 x float3"); else break;
|
||||
default: throw new IllegalArgumentException("bands must be 1, 2 or 3");
|
||||
}
|
||||
nRadiance(mNativeBuilder, bands, sh);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder irradiance(@NonNull Texture cubemap) {
|
||||
nIrradianceAsTexture(mNativeBuilder, cubemap.getNativeObject());
|
||||
@@ -74,7 +96,7 @@ public class IndirectLight {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder rotation(@NonNull @Size(min = 9) float rotation[]) {
|
||||
public Builder rotation(@NonNull @Size(min = 9) float[] rotation) {
|
||||
nRotation(mNativeBuilder,
|
||||
rotation[0], rotation[1], rotation[2],
|
||||
rotation[3], rotation[4], rotation[5],
|
||||
@@ -114,14 +136,36 @@ public class IndirectLight {
|
||||
return nGetIntensity(getNativeObject());
|
||||
}
|
||||
|
||||
public void setRotation(@NonNull @Size(min = 9) float rotation[]) {
|
||||
public void setRotation(@NonNull @Size(min = 9) float[] rotation) {
|
||||
Asserts.assertMat3fIn(rotation);
|
||||
nSetRotation(getNativeObject(),
|
||||
rotation[0], rotation[1], rotation[2],
|
||||
rotation[3], rotation[4], rotation[5],
|
||||
rotation[6], rotation[7], rotation[8]);
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
@NonNull @Size(min = 9)
|
||||
public float[] getRotation(@Nullable @Size(min = 9) float[] rotation) {
|
||||
rotation = Asserts.assertMat3f(rotation);
|
||||
nGetRotation(getNativeObject(), rotation);
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getDirectionEstimate(@Nullable @Size(min = 3) float[] direction) {
|
||||
direction = Asserts.assertFloat3(direction);
|
||||
nGetDirectionEstimate(getNativeObject(), direction);
|
||||
return direction;
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 4)
|
||||
public float[] getColorEstimate(@Nullable @Size(min = 4) float[] colorIntensity, float x, float y, float z) {
|
||||
colorIntensity = Asserts.assertFloat4(colorIntensity);
|
||||
nGetColorEstimate(getNativeObject(), colorIntensity, x, y, z);
|
||||
return colorIntensity;
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed IndirectLight");
|
||||
}
|
||||
@@ -138,6 +182,7 @@ public class IndirectLight {
|
||||
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);
|
||||
private static native void nBuilderReflections(long nativeBuilder, long nativeTexture);
|
||||
private static native void nIrradiance(long nativeBuilder, int bands, float[] sh);
|
||||
private static native void nRadiance(long nativeBuilder, int bands, float[] sh);
|
||||
private static native void nIrradianceAsTexture(long nativeBuilder, long nativeTexture);
|
||||
private static native void nIntensity(long nativeBuilder, float envIntensity);
|
||||
private static native void nRotation(long nativeBuilder, float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float v8) ;
|
||||
@@ -145,5 +190,7 @@ public class IndirectLight {
|
||||
private static native void nSetIntensity(long nativeIndirectLight, float intensity);
|
||||
private static native float nGetIntensity(long nativeIndirectLight);
|
||||
private static native void nSetRotation(long nativeIndirectLight, float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float v8);
|
||||
|
||||
private static native void nGetRotation(long nativeIndirectLight, float[] outRotation);
|
||||
private static native void nGetDirectionEstimate(long nativeIndirectLight, float[] outDirection);
|
||||
private static native void nGetColorEstimate(long nativeIndirectLight, float[] outColor, float x, float y, float z);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@ public class LightManager {
|
||||
public float constantBias = 0.05f;
|
||||
public float normalBias = 0.4f;
|
||||
public float shadowFar = 0.0f;
|
||||
public float shadowNearHint = 1.0f;
|
||||
public float shadowFarHint = 100.0f;
|
||||
public boolean stable = true;
|
||||
}
|
||||
|
||||
public static final float EFFICIENCY_INCANDESCENT = 0.0220f;
|
||||
@@ -79,7 +82,8 @@ public class LightManager {
|
||||
@NonNull
|
||||
public Builder shadowOptions(@NonNull ShadowOptions options) {
|
||||
nBuilderShadowOptions(mNativeBuilder,
|
||||
options.mapSize, options.constantBias, options.normalBias, options.shadowFar);
|
||||
options.mapSize, options.constantBias, options.normalBias, options.shadowFar,
|
||||
options.shadowNearHint, options.shadowFarHint, options.stable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -183,7 +187,7 @@ public class LightManager {
|
||||
|
||||
@NonNull
|
||||
public float[] getPosition(@EntityInstance int i, @Nullable @Size(min = 3) float[] out) {
|
||||
out = assertFloat3(out);
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetPosition(mNativeObject, i, out);
|
||||
return out;
|
||||
}
|
||||
@@ -194,7 +198,7 @@ public class LightManager {
|
||||
|
||||
@NonNull
|
||||
public float[] getDirection(@EntityInstance int i, @Nullable @Size(min = 3) float[] out) {
|
||||
out = assertFloat3(out);
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetDirection(mNativeObject, i, out);
|
||||
return out;
|
||||
}
|
||||
@@ -205,7 +209,7 @@ public class LightManager {
|
||||
|
||||
@NonNull
|
||||
public float[] getColor(@EntityInstance int i, @Nullable @Size(min = 3) float[] out) {
|
||||
out = assertFloat3(out);
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetColor(mNativeObject, i, out);
|
||||
return out;
|
||||
}
|
||||
@@ -258,13 +262,16 @@ public class LightManager {
|
||||
return nGetSunHaloFalloff(mNativeObject, i);
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 3)
|
||||
private static float[] assertFloat3(@Nullable float[] out) {
|
||||
if (out == null) out = new float[3];
|
||||
else if (out.length < 3) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 3");
|
||||
}
|
||||
return out;
|
||||
public void setShadowCaster(@EntityInstance int i, boolean shadowCaster) {
|
||||
nSetShadowCaster(mNativeObject, i, shadowCaster);
|
||||
}
|
||||
|
||||
public boolean isShadowCaster(@EntityInstance int i) {
|
||||
return nIsShadowCaster(mNativeObject, i);
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
private static native boolean nHasComponent(long nativeLightManager, int entity);
|
||||
@@ -275,7 +282,7 @@ public class LightManager {
|
||||
private static native void nDestroyBuilder(long nativeBuilder);
|
||||
private static native boolean nBuilderBuild(long nativeBuilder, long nativeEngine, int entity);
|
||||
private static native void nBuilderCastShadows(long nativeBuilder, boolean enable);
|
||||
private static native void nBuilderShadowOptions(long nativeBuilder, int mapSize, float constantBias, float normalBias, float shadowFar);
|
||||
private static native void nBuilderShadowOptions(long nativeBuilder, int mapSize, float constantBias, float normalBias, float shadowFar, float shadowNearHint, float shadowFarhint, boolean stable);
|
||||
private static native void nBuilderCastLight(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderPosition(long nativeBuilder, float x, float y, float z);
|
||||
private static native void nBuilderDirection(long nativeBuilder, float x, float y, float z);
|
||||
@@ -288,7 +295,6 @@ public class LightManager {
|
||||
private static native void nBuilderHaloSize(long nativeBuilder, float haloSize);
|
||||
private static native void nBuilderHaloFalloff(long nativeBuilder, float haloFalloff);
|
||||
|
||||
|
||||
private static native int nGetType(long nativeLightManager, int i);
|
||||
private static native void nSetPosition(long nativeLightManager, int i, float x, float y, float z);
|
||||
private static native void nGetPosition(long nativeLightManager, int i, float[] out);
|
||||
@@ -308,4 +314,6 @@ public class LightManager {
|
||||
private static native float nGetSunHaloSize(long nativeLightManager, int i);
|
||||
private static native void nSetSunHaloFalloff(long nativeLightManager, int i, float haloFalloff);
|
||||
private static native float nGetSunHaloFalloff(long nativeLightManager, int i);
|
||||
private static native void nSetShadowCaster(long nativeLightManager, int i, boolean shadowCaster);
|
||||
private static native boolean nIsShadowCaster(long nativeLightManager, int i);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.google.android.filament;
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Size;
|
||||
import com.google.android.filament.proguard.UsedByNative;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.util.ArrayList;
|
||||
@@ -37,7 +38,8 @@ public class Material {
|
||||
UNLIT,
|
||||
LIT,
|
||||
SUBSURFACE,
|
||||
CLOTH
|
||||
CLOTH,
|
||||
SPECULAR_GLOSSINESS
|
||||
}
|
||||
|
||||
public enum Interpolation {
|
||||
@@ -68,6 +70,7 @@ public class Material {
|
||||
FRONT_AND_BACK
|
||||
}
|
||||
|
||||
@UsedByNative("Material.cpp")
|
||||
public static class Parameter {
|
||||
public enum Type {
|
||||
BOOL,
|
||||
@@ -100,8 +103,8 @@ public class Material {
|
||||
DEFAULT
|
||||
}
|
||||
|
||||
// Used by native code
|
||||
@SuppressWarnings("unused")
|
||||
@UsedByNative("Material.cpp")
|
||||
private static final int SAMPLER_OFFSET = Type.MAT4.ordinal() + 1;
|
||||
|
||||
@NonNull
|
||||
@@ -121,8 +124,8 @@ public class Material {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
// Used by native code
|
||||
@SuppressWarnings("unused")
|
||||
@UsedByNative("Material.cpp")
|
||||
private static void add(@NonNull List<Parameter> parameters, @NonNull String name,
|
||||
@IntRange(from = 0) int type, @IntRange(from = 0) int precision,
|
||||
@IntRange(from = 1) int count) {
|
||||
@@ -131,8 +134,9 @@ public class Material {
|
||||
}
|
||||
}
|
||||
|
||||
private Material(long nativeMaterial, long nativeDefaultInstance) {
|
||||
Material(long nativeMaterial) {
|
||||
mNativeObject = nativeMaterial;
|
||||
long nativeDefaultInstance = nGetDefaultInstance(nativeMaterial);
|
||||
mDefaultInstance = new MaterialInstance(this, nativeDefaultInstance);
|
||||
}
|
||||
|
||||
@@ -151,8 +155,7 @@ public class Material {
|
||||
public Material build(@NonNull Engine engine) {
|
||||
long nativeMaterial = nBuilderBuild(engine.getNativeObject(), mBuffer, mSize);
|
||||
if (nativeMaterial == 0) throw new IllegalStateException("Couldn't create Material");
|
||||
long nativeDefaultInstance = nGetDefaultInstance(nativeMaterial);
|
||||
return new Material(nativeMaterial, nativeDefaultInstance);
|
||||
return new Material(nativeMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +215,14 @@ public class Material {
|
||||
return nGetMaskThreshold(getNativeObject());
|
||||
}
|
||||
|
||||
public float getSpecularAntiAliasingVariance() {
|
||||
return nGetSpecularAntiAliasingVariance(getNativeObject());
|
||||
}
|
||||
|
||||
public float getSpecularAntiAliasingThreshold() {
|
||||
return nGetSpecularAntiAliasingThreshold(getNativeObject());
|
||||
}
|
||||
|
||||
public Set<VertexBuffer.VertexAttribute> getRequiredAttributes() {
|
||||
if (mRequiredAttributes == null) {
|
||||
int bitSet = nGetRequiredAttributes(getNativeObject());
|
||||
@@ -327,7 +338,7 @@ public class Material {
|
||||
mDefaultInstance.setParameter(name, texture, sampler);
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Material");
|
||||
}
|
||||
@@ -353,6 +364,8 @@ public class Material {
|
||||
private static native boolean nIsDepthCullingEnabled(long nativeMaterial);
|
||||
private static native boolean nIsDoubleSided(long nativeMaterial);
|
||||
private static native float nGetMaskThreshold(long nativeMaterial);
|
||||
private static native float nGetSpecularAntiAliasingVariance(long nativeMaterial);
|
||||
private static native float nGetSpecularAntiAliasingThreshold(long nativeMaterial);
|
||||
|
||||
private static native int nGetParameterCount(long nativeMaterial);
|
||||
private static native void nGetParameters(long nativeMaterial,
|
||||
|
||||
@@ -21,8 +21,9 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
public class MaterialInstance {
|
||||
private final Material mMaterial;
|
||||
private Material mMaterial;
|
||||
private long mNativeObject;
|
||||
private long mNativeMaterial;
|
||||
|
||||
public enum BooleanElement {
|
||||
BOOL,
|
||||
@@ -52,8 +53,16 @@ public class MaterialInstance {
|
||||
mNativeObject = nativeMaterialInstance;
|
||||
}
|
||||
|
||||
MaterialInstance(long nativeMaterial, long nativeMaterialInstance) {
|
||||
mNativeMaterial = nativeMaterial;
|
||||
mNativeObject = nativeMaterialInstance;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Material getMaterial() {
|
||||
if (mMaterial == null) {
|
||||
mMaterial = new Material(mNativeMaterial);
|
||||
}
|
||||
return mMaterial;
|
||||
}
|
||||
|
||||
@@ -130,12 +139,14 @@ public class MaterialInstance {
|
||||
|
||||
public void setParameter(@NonNull String name, @NonNull Colors.RgbType type,
|
||||
float r, float g, float b) {
|
||||
setParameter(name, FloatElement.FLOAT3, Colors.toLinear(type, r, g, b), 0, 1);
|
||||
float[] color = Colors.toLinear(type, r, g, b);
|
||||
nSetParameterFloat3(getNativeObject(), name, color[0], color[1], color[2]);
|
||||
}
|
||||
|
||||
public void setParameter(@NonNull String name, @NonNull Colors.RgbaType type,
|
||||
float r, float g, float b, float a) {
|
||||
setParameter(name, FloatElement.FLOAT4, Colors.toLinear(type, r, g, b, a), 0, 1);
|
||||
float[] color = Colors.toLinear(type, r, g, b, a);
|
||||
nSetParameterFloat4(getNativeObject(), name, color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
||||
public void setScissor(@IntRange(from = 0) int left, @IntRange(from = 0) int bottom,
|
||||
@@ -151,7 +162,23 @@ public class MaterialInstance {
|
||||
nSetPolygonOffset(getNativeObject(), scale, constant);
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public void setMaskThreshold(float threshold) {
|
||||
nSetMaskThreshold(getNativeObject(), threshold);
|
||||
}
|
||||
|
||||
public void setSpecularAntiAliasingVariance(float variance) {
|
||||
nSetSpecularAntiAliasingVariance(getNativeObject(), variance);
|
||||
}
|
||||
|
||||
public void setSpecularAntiAliasingThreshold(float threshold) {
|
||||
nSetSpecularAntiAliasingThreshold(getNativeObject(), threshold);
|
||||
}
|
||||
|
||||
public void setDoubleSided(boolean doubleSided) {
|
||||
nSetDoubleSided(getNativeObject(), doubleSided);
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed MaterialInstance");
|
||||
}
|
||||
@@ -210,5 +237,14 @@ public class MaterialInstance {
|
||||
private static native void nUnsetScissor(long nativeMaterialInstance);
|
||||
|
||||
private static native void nSetPolygonOffset(long nativeMaterialInstance,
|
||||
float scale, float constant);
|
||||
float scale, float constant);
|
||||
|
||||
private static native void nSetMaskThreshold(long nativeMaterialInstance, float threshold);
|
||||
|
||||
private static native void nSetSpecularAntiAliasingVariance(long nativeMaterialInstance,
|
||||
float variance);
|
||||
private static native void nSetSpecularAntiAliasingThreshold(long nativeMaterialInstance,
|
||||
float threshold);
|
||||
|
||||
private static native void nSetDoubleSided(long nativeMaterialInstance, boolean doubleSided);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.google.android.filament;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import com.google.android.filament.proguard.UsedByNative;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -26,6 +27,7 @@ import java.nio.IntBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
@UsedByNative("NioUtils.cpp")
|
||||
final class NioUtils {
|
||||
|
||||
enum BufferType {
|
||||
@@ -41,18 +43,22 @@ final class NioUtils {
|
||||
private NioUtils() {
|
||||
}
|
||||
|
||||
@UsedByNative("NioUtils.cpp")
|
||||
static long getBasePointer(@NonNull Buffer b, long address, int sizeShift) {
|
||||
return address != 0 ? address + (b.position() << sizeShift) : 0;
|
||||
}
|
||||
|
||||
@UsedByNative("NioUtils.cpp")
|
||||
static Object getBaseArray(@NonNull Buffer b) {
|
||||
return b.hasArray() ? b.array() : null;
|
||||
}
|
||||
|
||||
@UsedByNative("NioUtils.cpp")
|
||||
static int getBaseArrayOffset(@NonNull Buffer b, int sizeShift) {
|
||||
return b.hasArray() ? ((b.arrayOffset() + b.position()) << sizeShift) : 0;
|
||||
}
|
||||
|
||||
@UsedByNative("NioUtils.cpp")
|
||||
static int getBufferType(@NonNull Buffer b) {
|
||||
if (b instanceof ByteBuffer) {
|
||||
return BufferType.BYTE.ordinal();
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament;
|
||||
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.BufferOverflowException;
|
||||
|
||||
public class RenderTarget {
|
||||
private long mNativeObject;
|
||||
private final Texture[] mTextures = new Texture[2];
|
||||
|
||||
private RenderTarget(long nativeRenderTarget, Builder builder) {
|
||||
mNativeObject = nativeRenderTarget;
|
||||
mTextures[0] = builder.mTextures[0];
|
||||
mTextures[1] = builder.mTextures[1];
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed RenderTarget");
|
||||
}
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
public enum AttachmentPoint {
|
||||
COLOR,
|
||||
DEPTH,
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
private final BuilderFinalizer mFinalizer;
|
||||
private final long mNativeBuilder;
|
||||
private final Texture[] mTextures = new Texture[2];
|
||||
|
||||
public Builder() {
|
||||
mNativeBuilder = nCreateBuilder();
|
||||
mFinalizer = new BuilderFinalizer(mNativeBuilder);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder texture(@NonNull AttachmentPoint attachment, @Nullable Texture texture) {
|
||||
mTextures[attachment.ordinal()] = texture;
|
||||
nBuilderTexture(mNativeBuilder, attachment.ordinal(), texture != null ? texture.getNativeObject() : 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder mipLevel(@NonNull AttachmentPoint attachment, @IntRange(from = 0) int level) {
|
||||
nBuilderMipLevel(mNativeBuilder, attachment.ordinal(), level);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder face(@NonNull AttachmentPoint attachment, Texture.CubemapFace face) {
|
||||
nBuilderFace(mNativeBuilder, attachment.ordinal(), face.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder layer(@NonNull AttachmentPoint attachment, @IntRange(from = 0) int layer) {
|
||||
nBuilderLayer(mNativeBuilder, attachment.ordinal(), layer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public RenderTarget build(@NonNull Engine engine) {
|
||||
long nativeRenderTarget = nBuilderBuild(mNativeBuilder, engine.getNativeObject());
|
||||
if (nativeRenderTarget == 0)
|
||||
throw new IllegalStateException("Couldn't create RenderTarget");
|
||||
return new RenderTarget(nativeRenderTarget, this);
|
||||
}
|
||||
|
||||
private static class BuilderFinalizer {
|
||||
private final long mNativeObject;
|
||||
|
||||
BuilderFinalizer(long nativeObject) {
|
||||
mNativeObject = nativeObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalize() {
|
||||
try {
|
||||
super.finalize();
|
||||
} catch (Throwable t) { // Ignore
|
||||
} finally {
|
||||
nDestroyBuilder(mNativeObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Texture getTexture(@NonNull AttachmentPoint attachment) {
|
||||
return mTextures[attachment.ordinal()];
|
||||
}
|
||||
|
||||
@IntRange(from = 0)
|
||||
public int getMipLevel(@NonNull AttachmentPoint attachment) {
|
||||
return nGetMipLevel(getNativeObject(), attachment.ordinal());
|
||||
}
|
||||
|
||||
public Texture.CubemapFace getFace(AttachmentPoint attachment) {
|
||||
return Texture.CubemapFace.values()[nGetFace(getNativeObject(), attachment.ordinal())];
|
||||
}
|
||||
|
||||
@IntRange(from = 0)
|
||||
public int getLayer(@NonNull AttachmentPoint attachment) {
|
||||
return nGetLayer(getNativeObject(), attachment.ordinal());
|
||||
}
|
||||
|
||||
void clearNativeObject() {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native long nCreateBuilder();
|
||||
private static native long nDestroyBuilder(long nativeBuilder);
|
||||
private static native long nBuilderTexture(long nativeBuilder, int attachment, long nativeTexture);
|
||||
private static native long nBuilderMipLevel(long nativeBuilder, int attachment, int level);
|
||||
private static native long nBuilderFace(long nativeBuilder, int attachment, int face);
|
||||
private static native long nBuilderLayer(long nativeBuilder, int attachment, int layer);
|
||||
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);
|
||||
|
||||
private static native int nGetMipLevel(long nativeRenderTarget, int attachment);
|
||||
private static native int nGetFace(long nativeRenderTarget, int attachment);
|
||||
private static native int nGetLayer(long nativeRenderTarget, int attachment);
|
||||
}
|
||||
@@ -169,6 +169,12 @@ public class RenderableManager {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder morphing(boolean enabled) {
|
||||
nBuilderMorphing(mNativeBuilder, enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void build(@NonNull Engine engine, @Entity int entity) {
|
||||
if (!nBuilderBuild(mNativeBuilder, engine.getNativeObject(), entity)) {
|
||||
throw new IllegalStateException(
|
||||
@@ -225,6 +231,10 @@ public class RenderableManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void setMorphWeights(@EntityInstance int i, float[] weights) {
|
||||
nSetMorphWeights(mNativeObject, i, weights);
|
||||
}
|
||||
|
||||
public void setAxisAlignedBoundingBox(@EntityInstance int i, @NonNull Box aabb) {
|
||||
nSetAxisAlignedBoundingBox(mNativeObject, i,
|
||||
aabb.getCenter()[0], aabb.getCenter()[1], aabb.getCenter()[2],
|
||||
@@ -282,6 +292,14 @@ public class RenderableManager {
|
||||
nSetMaterialInstanceAt(mNativeObject, i, primitiveIndex, materialInstance.getNativeObject());
|
||||
}
|
||||
|
||||
// creates a MaterialInstance Java wrapper object for a particular material instance
|
||||
public @NonNull MaterialInstance getMaterialInstanceAt(@EntityInstance int i,
|
||||
@IntRange(from = 0) int primitiveIndex) {
|
||||
long nativeMatInstance = nGetMaterialInstanceAt(mNativeObject, i, primitiveIndex);
|
||||
long nativeMaterial = nGetMaterialAt(mNativeObject, i, primitiveIndex);
|
||||
return new MaterialInstance(nativeMaterial, nativeMatInstance);
|
||||
}
|
||||
|
||||
// set/change the geometry (vertex/index buffers) of a given primitive
|
||||
public void setGeometryAt(@EntityInstance int i, @IntRange(from = 0) int primitiveIndex,
|
||||
@NonNull PrimitiveType type, @NonNull VertexBuffer vertices,
|
||||
@@ -322,6 +340,10 @@ public class RenderableManager {
|
||||
return requiredAttributes;
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
private static native boolean nHasComponent(long nativeRenderableManager, int entity);
|
||||
private static native int nGetInstance(long nativeRenderableManager, int entity);
|
||||
private static native void nDestroy(long nativeRenderableManager, int entity);
|
||||
@@ -343,9 +365,11 @@ public class RenderableManager {
|
||||
private static native void nBuilderReceiveShadows(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderSkinning(long nativeBuilder, int boneCount);
|
||||
private static native int nBuilderSkinningBones(long nativeBuilder, int boneCount, Buffer bones, int remaining);
|
||||
private static native void nBuilderMorphing(long nativeBuilder, boolean enabled);
|
||||
|
||||
private static native int nSetBonesAsMatrices(long nativeObject, int i, Buffer matrices, int remaining, int boneCount, int offset);
|
||||
private static native int nSetBonesAsQuaternions(long nativeObject, int i, Buffer quaternions, int remaining, int boneCount, int offset);
|
||||
private static native void nSetMorphWeights(long nativeObject, int instance, float[] weights);
|
||||
private static native void nSetAxisAlignedBoundingBox(long nativeRenderableManager, int i, float cx, float cy, float cz, float ex, float ey, float ez);
|
||||
private static native void nSetLayerMask(long nativeRenderableManager, int i, int select, int value);
|
||||
private static native void nSetPriority(long nativeRenderableManager, int i, int priority);
|
||||
@@ -356,6 +380,8 @@ public class RenderableManager {
|
||||
private static native void nGetAxisAlignedBoundingBox(long nativeRenderableManager, int i, float[] center, float[] halfExtent);
|
||||
private static native int nGetPrimitiveCount(long nativeRenderableManager, int i);
|
||||
private static native void nSetMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex, long nativeMaterialInstance);
|
||||
private static native long nGetMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex);
|
||||
private static native long nGetMaterialAt(long nativeRenderableManager, int i, int primitiveIndex);
|
||||
private static native void nSetGeometryAt(long nativeRenderableManager, int i, int primitiveIndex, int primitiveType, long nativeVertexBuffer, long nativeIndexBuffer, int offset, int count);
|
||||
private static native void nSetGeometryAt(long nativeRenderableManager, int i, int primitiveIndex, int primitiveType, int offset, int count);
|
||||
private static native void nSetBlendOrderAt(long nativeRenderableManager, int i, int primitiveIndex, int blendOrder);
|
||||
|
||||
@@ -56,15 +56,22 @@ public class Renderer {
|
||||
/**
|
||||
* This method MUST be called before endFrame.
|
||||
*/
|
||||
public void mirrorFrame(
|
||||
public void copyFrame(
|
||||
@NonNull SwapChain dstSwapChain, @NonNull Viewport dstViewport,
|
||||
@NonNull Viewport srcViewport, int flags) {
|
||||
nMirrorFrame(getNativeObject(), dstSwapChain.getNativeObject(),
|
||||
nCopyFrame(getNativeObject(), dstSwapChain.getNativeObject(),
|
||||
dstViewport.left, dstViewport.bottom, dstViewport.width, dstViewport.height,
|
||||
srcViewport.left, srcViewport.bottom, srcViewport.width, srcViewport.height,
|
||||
flags);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void mirrorFrame(
|
||||
@NonNull SwapChain dstSwapChain, @NonNull Viewport dstViewport,
|
||||
@NonNull Viewport srcViewport, int flags) {
|
||||
copyFrame(dstSwapChain, dstViewport, srcViewport, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method MUST be called before endFrame.
|
||||
*/
|
||||
@@ -89,7 +96,15 @@ public class Renderer {
|
||||
}
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
double getUserTime() {
|
||||
return nGetUserTime(getNativeObject());
|
||||
}
|
||||
|
||||
void resetUserTime() {
|
||||
nResetUserTime(getNativeObject());
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Renderer");
|
||||
}
|
||||
@@ -103,7 +118,7 @@ public class Renderer {
|
||||
private static native boolean nBeginFrame(long nativeRenderer, long nativeSwapChain);
|
||||
private static native void nEndFrame(long nativeRenderer);
|
||||
private static native void nRender(long nativeRenderer, long nativeView);
|
||||
private static native void nMirrorFrame(long nativeRenderer, long nativeDstSwapChain,
|
||||
private static native void nCopyFrame(long nativeRenderer, long nativeDstSwapChain,
|
||||
int dstLeft, int dstBottom, int dstWidth, int dstHeight,
|
||||
int srcLeft, int srcBottom, int srcWidth, int srcHeight,
|
||||
int flags);
|
||||
@@ -112,4 +127,6 @@ public class Renderer {
|
||||
Buffer storage, int remaining,
|
||||
int left, int top, int type, int alignment, int stride, int format,
|
||||
Object handler, Runnable callback);
|
||||
private static native double nGetUserTime(long nativeRenderer);
|
||||
private static native void nResetUserTime(long nativeRenderer);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,10 @@ public class Scene {
|
||||
nAddEntity(getNativeObject(), entity);
|
||||
}
|
||||
|
||||
public void addEntities(@Entity int[] entities) {
|
||||
nAddEntities(getNativeObject(), entities);
|
||||
}
|
||||
|
||||
public void removeEntity(@Entity int entity) {
|
||||
nRemove(getNativeObject(), entity);
|
||||
}
|
||||
@@ -71,7 +75,7 @@ public class Scene {
|
||||
return nGetLightCount(getNativeObject());
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Scene");
|
||||
}
|
||||
@@ -85,6 +89,7 @@ public class Scene {
|
||||
private static native void nSetSkybox(long nativeScene, long nativeSkybox);
|
||||
private static native void nSetIndirectLight(long nativeScene, long nativeIndirectLight);
|
||||
private static native void nAddEntity(long nativeScene, int entity);
|
||||
private static native void nAddEntities(long nativeScene, int[] entities);
|
||||
private static native void nRemove(long nativeScene, int entity);
|
||||
private static native int nGetRenderableCount(long nativeScene);
|
||||
private static native int nGetLightCount(long nativeScene);
|
||||
|
||||
@@ -16,13 +16,16 @@
|
||||
|
||||
package com.google.android.filament;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public class Skybox {
|
||||
private long mNativeObject;
|
||||
|
||||
private Skybox(long nativeSkybox) {
|
||||
@UsedByReflection("KtxLoader.java")
|
||||
Skybox(long nativeSkybox) {
|
||||
mNativeObject = nativeSkybox;
|
||||
}
|
||||
|
||||
@@ -80,7 +83,7 @@ public class Skybox {
|
||||
return nGetLayerMask(getNativeObject());
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Skybox");
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class Stream {
|
||||
return nGetTimestamp(getNativeObject());
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Stream");
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class SwapChain {
|
||||
private final Object mSurface;
|
||||
private long mNativeObject;
|
||||
|
||||
public static final long CONFIG_DEFAULT = 0x0;
|
||||
public static final long CONFIG_TRANSPARENT = 0x1;
|
||||
public static final long CONFIG_READABLE = 0x2;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class SwapChain {
|
||||
return mSurface;
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed SwapChain");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.google.android.filament;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -30,6 +32,7 @@ import static com.google.android.filament.Texture.Type.COMPRESSED;
|
||||
public class Texture {
|
||||
private long mNativeObject;
|
||||
|
||||
@UsedByReflection("KtxLoader.java")
|
||||
Texture(long nativeTexture) {
|
||||
mNativeObject = nativeTexture;
|
||||
}
|
||||
@@ -60,7 +63,7 @@ public class Texture {
|
||||
RG16F, RG16UI, RG16I,
|
||||
R11F_G11F_B10F,
|
||||
RGBA8, SRGB8_A8, RGBA8_SNORM,
|
||||
UNUSED, // The RGBM InternalFormat has been replaced with a flag (Texture.Builder.rgbm)
|
||||
UNUSED, // used to be rgbm
|
||||
RGB10_A2, RGBA8UI, RGBA8I,
|
||||
DEPTH32F, DEPTH24_STENCIL8, DEPTH32F_STENCIL8,
|
||||
|
||||
@@ -118,7 +121,7 @@ public class Texture {
|
||||
RGB_INTEGER,
|
||||
RGBA,
|
||||
RGBA_INTEGER,
|
||||
RGBM,
|
||||
UNUSED,
|
||||
DEPTH_COMPONENT,
|
||||
DEPTH_STENCIL,
|
||||
STENCIL_INDEX,
|
||||
@@ -134,7 +137,8 @@ public class Texture {
|
||||
INT,
|
||||
HALF,
|
||||
FLOAT,
|
||||
COMPRESSED
|
||||
COMPRESSED,
|
||||
UINT_10F_11F_11F_REV
|
||||
}
|
||||
|
||||
public static class PixelBufferDescriptor {
|
||||
@@ -252,7 +256,6 @@ public class Texture {
|
||||
break;
|
||||
case RGBA:
|
||||
case RGBA_INTEGER:
|
||||
case RGBM:
|
||||
n = 4;
|
||||
break;
|
||||
}
|
||||
@@ -273,6 +276,10 @@ public class Texture {
|
||||
case FLOAT:
|
||||
bpp *= 4;
|
||||
break;
|
||||
case UINT_10F_11F_11F_REV:
|
||||
// Special case, format must be RGB and uses 4 bytes
|
||||
bpp = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
int bpr = bpp * stride;
|
||||
@@ -281,6 +288,11 @@ public class Texture {
|
||||
}
|
||||
}
|
||||
|
||||
public static class PrefilterOptions {
|
||||
public int sampleCount = 8;
|
||||
public boolean mirror = true;
|
||||
}
|
||||
|
||||
public static boolean isTextureFormatSupported(@NonNull Engine engine,
|
||||
@NonNull InternalFormat format) {
|
||||
return nIsTextureFormatSupported(engine.getNativeObject(), format.ordinal());
|
||||
@@ -333,9 +345,14 @@ public class Texture {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the usage flags, which is necessary when attaching to {@link RenderTarget}.
|
||||
*
|
||||
* The flags argument much be a combination of {@link Usage} flags.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder rgbm(boolean enabled) {
|
||||
nBuilderRgbm(mNativeBuilder, enabled);
|
||||
public Builder usage(int flags) {
|
||||
nBuilderUsage(mNativeBuilder, flags);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -365,6 +382,15 @@ public class Texture {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Usage {
|
||||
public static final int COLOR_ATTACHMENT = 0x1;
|
||||
public static final int DEPTH_ATTACHMENT = 0x2;
|
||||
public static final int STENCIL_ATTACHMENT = 0x4;
|
||||
public static final int UPLOADABLE = 0x8;
|
||||
public static final int SAMPLEABLE = 0x10;
|
||||
public static final int DEFAULT = UPLOADABLE | SAMPLEABLE;
|
||||
}
|
||||
|
||||
public static final int BASE_LEVEL = 0;
|
||||
|
||||
public int getWidth(@IntRange(from = 0) int level) {
|
||||
@@ -470,7 +496,35 @@ public class Texture {
|
||||
nGenerateMipmaps(getNativeObject(), engine.getNativeObject());
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public void generatePrefilterMipmap(@NonNull Engine engine,
|
||||
@NonNull PixelBufferDescriptor buffer, @NonNull @Size(min = 6) int[] faceOffsetsInBytes,
|
||||
PrefilterOptions options) {
|
||||
|
||||
int width = getWidth(0);
|
||||
int height= getHeight(0);
|
||||
int sampleCount = 8;
|
||||
boolean mirror = true;
|
||||
if (options != null) {
|
||||
sampleCount = options.sampleCount;
|
||||
mirror = options.mirror;
|
||||
}
|
||||
|
||||
int result = nGeneratePrefilterMipmap(getNativeObject(), engine.getNativeObject(),
|
||||
width, height,
|
||||
buffer.storage, buffer.storage.remaining(),
|
||||
buffer.left, buffer.top, buffer.type.ordinal(), buffer.alignment,
|
||||
buffer.stride, buffer.format.ordinal(), faceOffsetsInBytes,
|
||||
buffer.handler, buffer.callback,
|
||||
sampleCount, mirror);
|
||||
|
||||
if (result < 0) {
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@UsedByReflection("TextureHelper.java")
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Texture");
|
||||
}
|
||||
@@ -492,7 +546,7 @@ public class Texture {
|
||||
private static native void nBuilderLevels(long nativeBuilder, int levels);
|
||||
private static native void nBuilderSampler(long nativeBuilder, int sampler);
|
||||
private static native void nBuilderFormat(long nativeBuilder, int format);
|
||||
private static native void nBuilderRgbm(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderUsage(long nativeBuilder, int flags);
|
||||
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);
|
||||
|
||||
private static native int nGetWidth(long nativeTexture, int level);
|
||||
@@ -533,4 +587,9 @@ public class Texture {
|
||||
private static native void nGenerateMipmaps(long nativeTexture, long nativeEngine);
|
||||
|
||||
private static native boolean nIsStreamValidForTexture(long nativeTexture, long nativeStream);
|
||||
|
||||
private static native int nGeneratePrefilterMipmap(long nativeIndirectLight, long nativeEngine,
|
||||
int width, int height, Buffer storage, int remaining, int left, int top,
|
||||
int type, int alignment, int stride, int format, int[] faceOffsetsInBytes,
|
||||
Object handler, Runnable callback, int sampleCount, boolean mirror);
|
||||
}
|
||||
|
||||
@@ -57,9 +57,7 @@ public class TransformManager {
|
||||
|
||||
public void setTransform(@EntityInstance int i,
|
||||
@NonNull @Size(min = 16) float[] localTransform) {
|
||||
if (localTransform.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
Asserts.assertMat4fIn(localTransform);
|
||||
nSetTransform(mNativeObject, i, localTransform);
|
||||
}
|
||||
|
||||
@@ -67,7 +65,7 @@ public class TransformManager {
|
||||
@Size(min = 16)
|
||||
public float[] getTransform(@EntityInstance int i,
|
||||
@Nullable @Size(min = 16) float[] outLocalTransform) {
|
||||
outLocalTransform = assertMat4f(outLocalTransform);
|
||||
outLocalTransform = Asserts.assertMat4f(outLocalTransform);
|
||||
nGetTransform(mNativeObject, i, outLocalTransform);
|
||||
return outLocalTransform;
|
||||
}
|
||||
@@ -76,7 +74,7 @@ public class TransformManager {
|
||||
@Size(min = 16)
|
||||
public float[] getWorldTransform(@EntityInstance int i,
|
||||
@Nullable @Size(min = 16) float[] outWorldTransform) {
|
||||
outWorldTransform = assertMat4f(outWorldTransform);
|
||||
outWorldTransform = Asserts.assertMat4f(outWorldTransform);
|
||||
nGetWorldTransform(mNativeObject, i, outWorldTransform);
|
||||
return outWorldTransform;
|
||||
}
|
||||
@@ -89,13 +87,8 @@ public class TransformManager {
|
||||
nCommitLocalTransformTransaction(mNativeObject);
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 16)
|
||||
private static float[] assertMat4f(@Nullable float[] out) {
|
||||
if (out == null) out = new float[16];
|
||||
else if (out.length < 16) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 16");
|
||||
}
|
||||
return out;
|
||||
public long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
private static native boolean nHasComponent(long nativeTransformManager, int entity);
|
||||
|
||||
@@ -69,6 +69,23 @@ public class VertexBuffer {
|
||||
HALF4,
|
||||
}
|
||||
|
||||
public enum QuatType {
|
||||
HALF4, // 2 bytes per component as half-floats (8 bytes per quat)
|
||||
SHORT4, // 2 bytes per component as normalized integers (8 bytes per quat)
|
||||
FLOAT4, // 4 bytes per component as floats (16 bytes per quat)
|
||||
}
|
||||
|
||||
public static class QuatTangentContext {
|
||||
public QuatType quatType; // desired quaternion type (required)
|
||||
public int quatCount; // number of quaternions (required)
|
||||
public Buffer outBuffer; // pre-allocated output buffer (required)
|
||||
public int outStride; // desired stride in bytes (optional)
|
||||
public Buffer normals; // source normals (required)
|
||||
public int normalsStride; // normals stride in bytes (optional)
|
||||
public Buffer tangents; // source tangents (optional)
|
||||
public int tangentsStride; // tangents stride in bytes (optional)
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // Keep to finalize native resources
|
||||
private final BuilderFinalizer mFinalizer;
|
||||
@@ -108,7 +125,13 @@ public class VertexBuffer {
|
||||
|
||||
@NonNull
|
||||
public Builder normalized(@NonNull VertexAttribute attribute) {
|
||||
nBuilderNormalized(mNativeBuilder, attribute.ordinal());
|
||||
nBuilderNormalized(mNativeBuilder, attribute.ordinal(), true);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder normalized(@NonNull VertexAttribute attribute, boolean enabled) {
|
||||
nBuilderNormalized(mNativeBuilder, attribute.ordinal(), enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -166,7 +189,15 @@ public class VertexBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public static void populateTangentQuaternions(@NonNull QuatTangentContext context) {
|
||||
nPopulateTangentQuaternions(context.quatType.ordinal(), context.quatCount,
|
||||
context.outBuffer, context.outBuffer.remaining(), context.outStride,
|
||||
context.normals, context.normals.remaining(), context.normalsStride,
|
||||
context.tangents, context.tangents != null ? context.tangents.remaining() : 0,
|
||||
context.tangentsStride);
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed VertexBuffer");
|
||||
}
|
||||
@@ -183,11 +214,16 @@ public class VertexBuffer {
|
||||
private static native void nBuilderBufferCount(long nativeBuilder, int bufferCount);
|
||||
private static native void nBuilderAttribute(long nativeBuilder, int attribute,
|
||||
int bufferIndex, int attributeType, int byteOffset, int byteStride);
|
||||
private static native void nBuilderNormalized(long nativeBuilder, int attribute);
|
||||
private static native void nBuilderNormalized(long nativeBuilder, int attribute,
|
||||
boolean normalized);
|
||||
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);
|
||||
|
||||
private static native int nGetVertexCount(long nativeVertexBuffer);
|
||||
private static native int nSetBufferAt(long nativeVertexBuffer, long nativeEngine,
|
||||
int bufferIndex, Buffer buffer, int remaining, int destOffsetInBytes, int count,
|
||||
Object handler, Runnable callback);
|
||||
|
||||
private static native void nPopulateTangentQuaternions(int quatType, int quatCount,
|
||||
Buffer outBuffer, int outRemaining, int outStride, Buffer normals, int normalsRemaining,
|
||||
int normalsStride, Buffer tangents, int tangentsRemaining, int tangentsStride);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ public class View {
|
||||
private DynamicResolutionOptions mDynamicResolution;
|
||||
private RenderQuality mRenderQuality;
|
||||
private DepthPrepass mDepthPrepass = DepthPrepass.DEFAULT;
|
||||
private AmbientOcclusionOptions mAmbientOcclusionOptions;
|
||||
private RenderTarget mRenderTarget;
|
||||
|
||||
public static class DynamicResolutionOptions {
|
||||
public boolean enabled = false;
|
||||
@@ -44,6 +46,13 @@ public class View {
|
||||
public int history = 9;
|
||||
}
|
||||
|
||||
public static class AmbientOcclusionOptions {
|
||||
public float radius = 0.3f;
|
||||
public float bias = 0.005f;
|
||||
public float power = 0.0f;
|
||||
public float resolution = 0.5f;
|
||||
}
|
||||
|
||||
public enum QualityLevel {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
@@ -55,11 +64,26 @@ public class View {
|
||||
public QualityLevel hdrColorBuffer = QualityLevel.HIGH;
|
||||
}
|
||||
|
||||
public enum AmbientOcclusion {
|
||||
NONE,
|
||||
SSAO
|
||||
}
|
||||
|
||||
public enum AntiAliasing {
|
||||
NONE,
|
||||
FXAA
|
||||
}
|
||||
|
||||
public enum ToneMapping {
|
||||
LINEAR,
|
||||
ACES
|
||||
}
|
||||
|
||||
public enum Dithering {
|
||||
NONE,
|
||||
TEMPORAL
|
||||
}
|
||||
|
||||
public enum DepthPrepass {
|
||||
DEFAULT(-1),
|
||||
DISABLED(0),
|
||||
@@ -124,7 +148,7 @@ public class View {
|
||||
|
||||
@NonNull @Size(min = 4)
|
||||
public float[] getClearColor(@NonNull @Size(min = 4) float[] out) {
|
||||
out = assertFloat4(out);
|
||||
out = Asserts.assertFloat4(out);
|
||||
nGetClearColor(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -143,6 +167,16 @@ public class View {
|
||||
nSetShadowsEnabled(getNativeObject(), enabled);
|
||||
}
|
||||
|
||||
public void setRenderTarget(@Nullable RenderTarget target) {
|
||||
mRenderTarget = target;
|
||||
nSetRenderTarget(getNativeObject(), target != null ? target.getNativeObject() : 0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RenderTarget getRenderTarget() {
|
||||
return mRenderTarget;
|
||||
}
|
||||
|
||||
public void setSampleCount(int count) {
|
||||
nSetSampleCount(getNativeObject(), count);
|
||||
}
|
||||
@@ -160,6 +194,24 @@ public class View {
|
||||
return AntiAliasing.values()[nGetAntiAliasing(getNativeObject())];
|
||||
}
|
||||
|
||||
public void setToneMapping(@NonNull ToneMapping type) {
|
||||
nSetToneMapping(getNativeObject(), type.ordinal());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ToneMapping getToneMapping() {
|
||||
return ToneMapping.values()[nGetToneMapping(getNativeObject())];
|
||||
}
|
||||
|
||||
public void setDithering(@NonNull Dithering dithering) {
|
||||
nSetDithering(getNativeObject(), dithering.ordinal());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Dithering getDithering() {
|
||||
return Dithering.values()[nGetDithering(getNativeObject())];
|
||||
}
|
||||
|
||||
public void setDynamicResolutionOptions(@NonNull DynamicResolutionOptions options) {
|
||||
mDynamicResolution = options;
|
||||
nSetDynamicResolutionOptions(getNativeObject(),
|
||||
@@ -212,11 +264,41 @@ public class View {
|
||||
nSetPostProcessingEnabled(getNativeObject(), enabled);
|
||||
}
|
||||
|
||||
public boolean isFrontFaceWindingInverted() {
|
||||
return nIsFrontFaceWindingInverted(getNativeObject());
|
||||
}
|
||||
|
||||
public void setFrontFaceWindingInverted(boolean inverted) {
|
||||
nSetFrontFaceWindingInverted(getNativeObject(), inverted);
|
||||
}
|
||||
|
||||
public void setDynamicLightingOptions(float zLightNear, float zLightFar) {
|
||||
nSetDynamicLightingOptions(getNativeObject(), zLightNear, zLightFar);
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public void setAmbientOcclusion(@NonNull AmbientOcclusion ao) {
|
||||
nSetAmbientOcclusion(getNativeObject(), ao.ordinal());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AmbientOcclusion getAmbientOcclusion() {
|
||||
return AmbientOcclusion.values()[nGetAmbientOcclusion(getNativeObject())];
|
||||
}
|
||||
|
||||
public void setAmbientOcclusionOptions(@NonNull AmbientOcclusionOptions options) {
|
||||
mAmbientOcclusionOptions = options;
|
||||
nSetAmbientOcclusionOptions(getNativeObject(), options.radius, options.bias, options.power, options.resolution);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public AmbientOcclusionOptions getAmbientOcclusionOptions() {
|
||||
if (mAmbientOcclusionOptions == null) {
|
||||
mAmbientOcclusionOptions = new AmbientOcclusionOptions();
|
||||
}
|
||||
return mAmbientOcclusionOptions;
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed View");
|
||||
}
|
||||
@@ -227,15 +309,6 @@ public class View {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 4)
|
||||
private static float[] assertFloat4(@Nullable float[] out) {
|
||||
if (out == null) out = new float[4];
|
||||
else if (out.length < 4) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 4");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static native void nSetName(long nativeView, String name);
|
||||
private static native void nSetScene(long nativeView, long nativeScene);
|
||||
private static native void nSetCamera(long nativeView, long nativeCamera);
|
||||
@@ -245,10 +318,15 @@ public class View {
|
||||
private static native void nSetClearTargets(long nativeView, boolean color, boolean depth, boolean stencil);
|
||||
private static native void nSetVisibleLayers(long nativeView, int select, int value);
|
||||
private static native void nSetShadowsEnabled(long nativeView, boolean enabled);
|
||||
private static native void nSetRenderTarget(long nativeView, long nativeRenderTarget);
|
||||
private static native void nSetSampleCount(long nativeView, int count);
|
||||
private static native int nGetSampleCount(long nativeView);
|
||||
private static native void nSetAntiAliasing(long nativeView, int type);
|
||||
private static native int nGetAntiAliasing(long nativeView);
|
||||
private static native void nSetToneMapping(long nativeView, int type);
|
||||
private static native int nGetToneMapping(long nativeView);
|
||||
private static native void nSetDithering(long nativeView, int dithering);
|
||||
private static native int nGetDithering(long nativeView);
|
||||
private static native void nSetDynamicResolutionOptions(long nativeView,
|
||||
boolean enabled, boolean homogeneousScaling,
|
||||
float targetFrameTimeMilli, float headRoomRatio, float scaleRate,
|
||||
@@ -258,4 +336,9 @@ public class View {
|
||||
private static native void nSetDepthPrepass(long nativeView, int value);
|
||||
private static native void nSetPostProcessingEnabled(long nativeView, boolean enabled);
|
||||
private static native boolean nIsPostProcessingEnabled(long nativeView);
|
||||
private static native void nSetFrontFaceWindingInverted(long nativeView, boolean inverted);
|
||||
private static native boolean nIsFrontFaceWindingInverted(long nativeView);
|
||||
private static native void nSetAmbientOcclusion(long nativeView, int ordinal);
|
||||
private static native int nGetAmbientOcclusion(long nativeView);
|
||||
private static native void nSetAmbientOcclusionOptions(long nativeView, float radius, float bias, float power, float resolution);
|
||||
}
|
||||
|
||||
@@ -16,15 +16,111 @@
|
||||
|
||||
package com.google.android.filament.android;
|
||||
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.SurfaceTexture;
|
||||
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.TextureView;
|
||||
import com.google.android.filament.SwapChain;
|
||||
|
||||
/**
|
||||
* UiHelper is a simple class that can manage either a SurfaceView or a TextureView so it can
|
||||
* be used to render into with Filament.
|
||||
*
|
||||
* Here is a simple example with a SurfaceView. The code would be exactly the same with a
|
||||
* TextureView:
|
||||
*
|
||||
* <pre>
|
||||
* public class FilamentActivity extends Activity {
|
||||
* private UiHelper mUiHelper;
|
||||
* private SurfaceView mSurfaceView;
|
||||
*
|
||||
* // Filament specific APIs
|
||||
* private Engine mEngine;
|
||||
* private Renderer mRenderer;
|
||||
* private View mView; // com.google.android.filament.View, not android.view.View
|
||||
* private SwapChain mSwapChain;
|
||||
*
|
||||
* public void onCreate(Bundle savedInstanceState) {
|
||||
* super.onCreate(savedInstanceState);
|
||||
*
|
||||
* // Create a SurfaceView and add it to the activity
|
||||
* mSurfaceView = new SurfaceView(this);
|
||||
* setContentView(mSurfaceView);
|
||||
*
|
||||
* // Create the Filament UI helper
|
||||
* mUiHelper = new UiHelper(UiHelper.ContextErrorPolicy.DONT_CHECK);
|
||||
*
|
||||
* // Attach the SurfaceView to the helper, you could do the same with a TextureView
|
||||
* mUiHelper.attachTo(mSurfaceView);
|
||||
*
|
||||
* // Set a rendering callback that we will use to invoke Filament
|
||||
* mUiHelper.setRenderCallback(new UiHelper.RendererCallback() {
|
||||
* public void onNativeWindowChanged(Surface surface) {
|
||||
* if (mSwapChain != null) mEngine.destroySwapChain(mSwapChain);
|
||||
* mSwapChain = mEngine.createSwapChain(surface, mUiHelper.getSwapChainFlags());
|
||||
* }
|
||||
*
|
||||
* // The native surface went away, we must stop rendering.
|
||||
* public void onDetachedFromSurface() {
|
||||
* if (mSwapChain != null) {
|
||||
* mEngine.destroySwapChain(mSwapChain);
|
||||
*
|
||||
* // Required to ensure we don't return before Filament is done executing the
|
||||
* // destroySwapChain command, otherwise Android might destroy the Surface
|
||||
* // too early
|
||||
* mEngine.flushAndWait();
|
||||
*
|
||||
* mSwapChain = null;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // The native surface has changed size. This is always called at least once
|
||||
* // after the surface is created (after onNativeWindowChanged() is invoked).
|
||||
* public void onResized(int width, int height) {
|
||||
* // Compute camera projection and set the viewport on the view
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* mEngine = Engine.create();
|
||||
* mRenderer = mEngine.createRenderer();
|
||||
* mView = mEngine.createView();
|
||||
* // Create scene, camera, etc.
|
||||
* }
|
||||
*
|
||||
* public void onDestroy() {
|
||||
* super.onDestroy();
|
||||
* // Always detach the surface before destroying the engine
|
||||
* mUiHelper.detach();
|
||||
*
|
||||
* // This ensures that all the commands we've sent to Filament have
|
||||
* // been processed before we attempt to destroy anything
|
||||
* Fence.waitAndDestroy(mEngine.createFence(Fence.Type.SOFT), Fence.Mode.FLUSH);
|
||||
*
|
||||
* mEngine.destroy();
|
||||
* }
|
||||
*
|
||||
* // This is an example of a render function. You will most likely invoke this from
|
||||
* // a Choreographer callback to trigger rendering at vsync.
|
||||
* public void render() {
|
||||
* if (mUiHelper.isReadyToRender) {
|
||||
* // If beginFrame() returns false you should skip the frame
|
||||
* // This means you are sending frames too quickly to the GPU
|
||||
* if (mRenderer.beginFrame(swapChain)) {
|
||||
* mRenderer.render(mView);
|
||||
* mRenderer.endFrame();
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public class UiHelper {
|
||||
private static final String LOG_TAG = "UiHelper";
|
||||
private static final boolean LOGGING = false;
|
||||
@@ -36,27 +132,46 @@ public class UiHelper {
|
||||
private RendererCallback mRenderCallback;
|
||||
private boolean mHasSwapChain;
|
||||
|
||||
private RenderSurface mRenderSurface;
|
||||
|
||||
private boolean mOpaque = true;
|
||||
|
||||
/**
|
||||
* Enum used to decide whether UiHelper should perform extra error checking.
|
||||
*
|
||||
* @see UiHelper#UiHelper(ContextErrorPolicy)
|
||||
*/
|
||||
public enum ContextErrorPolicy {
|
||||
CHECK, DONT_CHECK
|
||||
/** Check for extra errors. */
|
||||
CHECK,
|
||||
/** Do not check for extra errors. */
|
||||
DONT_CHECK
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to know when the native surface is created, destroyed or resized.
|
||||
*
|
||||
* @see #setRenderCallback(RendererCallback)
|
||||
*/
|
||||
public interface RendererCallback {
|
||||
|
||||
// called when the underlying native window has changed
|
||||
// NOTE: this could be called from UiHelper's constructor.
|
||||
/**
|
||||
* Called when the underlying native window has changed.
|
||||
*/
|
||||
void onNativeWindowChanged(Surface surface);
|
||||
|
||||
// called when the surface is going away. after this call isReadyToRender() returns false.
|
||||
// you MUST have stopped drawing when returning.
|
||||
// This is called from detach() or if the surface disappears on its own.
|
||||
/**
|
||||
* Called when the surface is going away. After this call <code>isReadyToRender()</code>
|
||||
* returns false. You MUST have stopped drawing when returning.
|
||||
* This is called from detach() or if the surface disappears on its own.
|
||||
*/
|
||||
void onDetachedFromSurface();
|
||||
|
||||
// called when the underlying native window has been resized
|
||||
/**
|
||||
* Called when the underlying native window has been resized.
|
||||
*/
|
||||
void onResized(int width, int height);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
private interface RenderSurface {
|
||||
void resize(int width, int height);
|
||||
void detach();
|
||||
@@ -108,34 +223,46 @@ public class UiHelper {
|
||||
mSurface = surface;
|
||||
}
|
||||
}
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
private RenderSurface mRenderSurface;
|
||||
|
||||
/**
|
||||
* Creates a UiHelper which will help manage the EGL context
|
||||
* and EGL surfaces. UiHelper handles SurfaceView and TextureView.
|
||||
*
|
||||
* When this call returns, OpenGL ES is ready to use.
|
||||
* Creates a UiHelper which will help manage the native surface provided by a
|
||||
* SurfaceView or a TextureView.
|
||||
*/
|
||||
public UiHelper() {
|
||||
this(ContextErrorPolicy.CHECK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a UiHelper which will help manage the native surface provided by a
|
||||
* SurfaceView or a TextureView.
|
||||
*
|
||||
* @param policy The error checking policy to use.
|
||||
*/
|
||||
public UiHelper(ContextErrorPolicy policy) {
|
||||
// TODO: do something with policy
|
||||
}
|
||||
|
||||
public void setRenderCallback(RendererCallback renderCallback) {
|
||||
/**
|
||||
* Sets the renderer callback that will be notified when the native surface is
|
||||
* created, destroyed or resized.
|
||||
*
|
||||
* @param renderCallback The callback to register.
|
||||
*/
|
||||
public void setRenderCallback(@Nullable RendererCallback renderCallback) {
|
||||
mRenderCallback = renderCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current render callback associated with this UiHelper.
|
||||
*/
|
||||
@Nullable
|
||||
public RendererCallback getRenderCallback() {
|
||||
return mRenderCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free resources associated to the native window specified in attachTo().
|
||||
* Free resources associated to the native window specified in {@link #attachTo(SurfaceView)}
|
||||
* or {@link #attachTo(TextureView)}.
|
||||
*/
|
||||
public void detach() {
|
||||
destroySwapChain();
|
||||
@@ -143,13 +270,6 @@ public class UiHelper {
|
||||
mRenderSurface = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
// TODO: check that detach() has been called
|
||||
// TODO: call Surface.release() if not already done
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether we are ready to render into the attached surface.
|
||||
*
|
||||
@@ -163,7 +283,7 @@ public class UiHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the underlying buffers
|
||||
* Set the size of the render target buffers of the native surface.
|
||||
*/
|
||||
public void setDesiredSize(int width, int height) {
|
||||
mDesiredWidth = width;
|
||||
@@ -173,51 +293,97 @@ public class UiHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested width for the native surface.
|
||||
*/
|
||||
public int getDesiredWidth() {
|
||||
return mDesiredWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested height for the native surface.
|
||||
*/
|
||||
public int getDesiredHeight() {
|
||||
return mDesiredHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the render target is opaque.
|
||||
*/
|
||||
public boolean isOpaque() {
|
||||
return mOpaque;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls whether the render target (SurfaceView or TextureView) is opaque or not.
|
||||
* The render target is considered opaque by default.
|
||||
*
|
||||
* Must be called before calling {@link #attachTo(SurfaceView)}
|
||||
* or {@link #attachTo(TextureView)}.
|
||||
*
|
||||
* @param opaque Indicates whether the render target should be opaque. True by default.
|
||||
*/
|
||||
public void setOpaque(boolean opaque) {
|
||||
mOpaque = opaque;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flags to pass to
|
||||
* {@link com.google.android.filament.Engine#createSwapChain(Object, long)} to honor all
|
||||
* the options set on this UiHelper.
|
||||
*/
|
||||
public long getSwapChainFlags() {
|
||||
return isOpaque() ? SwapChain.CONFIG_DEFAULT : SwapChain.CONFIG_TRANSPARENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate UiHelper with a SurfaceView.
|
||||
*
|
||||
* As soon as SurfaceView is ready (i.e. has a Surface), we'll create the
|
||||
* EGL resources needed, and call user callbacks if needed.
|
||||
*/
|
||||
public void attachTo(SurfaceView view) {
|
||||
final SurfaceHolder.Callback callback = new SurfaceHolder.Callback() {
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "surfaceCreated()");
|
||||
createSwapChain(holder.getSurface());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
// Note: this is always called at least once after surfaceCreated()
|
||||
if (LOGGING) Log.d(LOG_TAG, "surfaceChanged(" + width + ", " + height + ")");
|
||||
mRenderCallback.onResized(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "surfaceDestroyed()");
|
||||
destroySwapChain();
|
||||
}
|
||||
};
|
||||
|
||||
public void attachTo(@NonNull SurfaceView view) {
|
||||
if (attach(view)) {
|
||||
if (!isOpaque()) {
|
||||
view.setZOrderOnTop(true);
|
||||
view.getHolder().setFormat(PixelFormat.TRANSLUCENT);
|
||||
}
|
||||
|
||||
mRenderSurface = new SurfaceViewHandler(view);
|
||||
|
||||
final SurfaceHolder.Callback callback = new SurfaceHolder.Callback() {
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "surfaceCreated()");
|
||||
createSwapChain(holder.getSurface());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(
|
||||
SurfaceHolder holder, int format, int width, int height) {
|
||||
// Note: this is always called at least once after surfaceCreated()
|
||||
if (LOGGING) Log.d(LOG_TAG, "surfaceChanged(" + width + ", " + height + ")");
|
||||
mRenderCallback.onResized(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "surfaceDestroyed()");
|
||||
destroySwapChain();
|
||||
}
|
||||
};
|
||||
|
||||
SurfaceHolder holder = view.getHolder();
|
||||
holder.addCallback(callback);
|
||||
holder.setFixedSize(mDesiredWidth, mDesiredHeight);
|
||||
|
||||
// in case the SurfaceView's surface already existed
|
||||
final Surface surface = holder.getSurface();
|
||||
if (surface != null && surface.isValid()) {
|
||||
callback.surfaceCreated(holder);
|
||||
int format = isOpaque() ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT;
|
||||
callback.surfaceChanged(holder, format,
|
||||
holder.getSurfaceFrame().width(), holder.getSurfaceFrame().height());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,49 +394,64 @@ public class UiHelper {
|
||||
* As soon as TextureView is ready (i.e. has a buffer), we'll create the
|
||||
* EGL resources needed, and call user callbacks if needed.
|
||||
*/
|
||||
public void attachTo(TextureView view) {
|
||||
final TextureView.SurfaceTextureListener listener = new TextureView.SurfaceTextureListener() {
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureAvailable()");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
|
||||
surfaceTexture.setDefaultBufferSize(mDesiredWidth, mDesiredHeight);
|
||||
}
|
||||
Surface surface = new Surface(surfaceTexture);
|
||||
TextureViewHandler textureViewHandler = (TextureViewHandler)mRenderSurface;
|
||||
textureViewHandler.setSurface(surface);
|
||||
createSwapChain(surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureSizeChanged()");
|
||||
mRenderCallback.onResized(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureDestroyed()");
|
||||
destroySwapChain();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureUpdated(SurfaceTexture surface) { }
|
||||
};
|
||||
|
||||
public void attachTo(@NonNull TextureView view) {
|
||||
if (attach(view)) {
|
||||
view.setOpaque(isOpaque());
|
||||
|
||||
mRenderSurface = new TextureViewHandler(view);
|
||||
|
||||
TextureView.SurfaceTextureListener listener = new TextureView.SurfaceTextureListener() {
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(
|
||||
SurfaceTexture surfaceTexture, int width, int height) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureAvailable()");
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
|
||||
if (mDesiredWidth > 0 && mDesiredHeight > 0) {
|
||||
surfaceTexture.setDefaultBufferSize(mDesiredWidth, mDesiredHeight);
|
||||
}
|
||||
}
|
||||
|
||||
Surface surface = new Surface(surfaceTexture);
|
||||
TextureViewHandler textureViewHandler = (TextureViewHandler) mRenderSurface;
|
||||
textureViewHandler.setSurface(surface);
|
||||
|
||||
createSwapChain(surface);
|
||||
|
||||
// Call this the first time because onSurfaceTextureSizeChanged()
|
||||
// isn't called at initialization time
|
||||
mRenderCallback.onResized(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureSizeChanged(
|
||||
SurfaceTexture surfaceTexture, int width, int height) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureSizeChanged()");
|
||||
mRenderCallback.onResized(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureDestroyed()");
|
||||
destroySwapChain();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureUpdated(SurfaceTexture surface) { }
|
||||
};
|
||||
|
||||
view.setSurfaceTextureListener(listener);
|
||||
|
||||
// in case the View's SurfaceTexture already existed
|
||||
if (view.isAvailable()) {
|
||||
final SurfaceTexture surfaceTexture = view.getSurfaceTexture();
|
||||
SurfaceTexture surfaceTexture = view.getSurfaceTexture();
|
||||
listener.onSurfaceTextureAvailable(surfaceTexture, mDesiredWidth, mDesiredHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean attach(Object nativeWindow) {
|
||||
private boolean attach(@NonNull Object nativeWindow) {
|
||||
if (mNativeWindow != null) {
|
||||
// we are already attached to a native window
|
||||
if (mNativeWindow == nativeWindow) {
|
||||
@@ -283,8 +464,8 @@ public class UiHelper {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createSwapChain(Surface sur) {
|
||||
mRenderCallback.onNativeWindowChanged(sur);
|
||||
private void createSwapChain(@NonNull Surface surface) {
|
||||
mRenderCallback.onNativeWindowChanged(surface);
|
||||
mHasSwapChain = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.proguard;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation used for marking methods and fields that are called from native
|
||||
* code. Useful for keeping components that would otherwise be removed by
|
||||
* Proguard. Use the value parameter to mention a file that calls this method.
|
||||
*
|
||||
* Note that adding this annotation to a method is not enough to guarantee that
|
||||
* it is kept - either its class must be referenced elsewhere in the program, or
|
||||
* the class must be annotated with this as well.
|
||||
*
|
||||
* Usage example:<br />
|
||||
* {@code
|
||||
* @UsedByNative("NativeCrashHandler.cpp")
|
||||
public static void reportCrash(int signal, int code, int address) {
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
@Target({
|
||||
ElementType.METHOD,
|
||||
ElementType.FIELD,
|
||||
ElementType.TYPE,
|
||||
ElementType.CONSTRUCTOR})
|
||||
public @interface UsedByNative {
|
||||
String value();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.proguard;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation used for marking methods and fields that are called by reflection. Useful for keeping
|
||||
* components that would otherwise be removed by Proguard. Use the value parameter to mention a file
|
||||
* that calls this method.
|
||||
*
|
||||
* Note that adding this annotation to a method is not enough to guarantee that
|
||||
* it is kept - either its class must be referenced elsewhere in the program, or
|
||||
* the class must be annotated with this as well.
|
||||
*
|
||||
* Usage example:<br />
|
||||
* {@code
|
||||
* @UsedByReflection("PeopleListItemView.java")
|
||||
public PeopleListItemViewV11(Context context) {
|
||||
super(context);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
@Target({
|
||||
ElementType.METHOD,
|
||||
ElementType.FIELD,
|
||||
ElementType.TYPE,
|
||||
ElementType.CONSTRUCTOR})
|
||||
public @interface UsedByReflection {
|
||||
String value();
|
||||
}
|
||||
12
android/gltfio-android/.gitignore
vendored
Normal file
12
android/gltfio-android/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
/.idea/caches
|
||||
/.idea/gradle.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
/.cxx
|
||||
102
android/gltfio-android/CMakeLists.txt
Normal file
102
android/gltfio-android/CMakeLists.txt
Normal file
@@ -0,0 +1,102 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
|
||||
|
||||
add_library(filament SHARED IMPORTED)
|
||||
set_target_properties(filament PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilament.a)
|
||||
|
||||
add_library(backend SHARED IMPORTED)
|
||||
set_target_properties(backend PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbackend.a)
|
||||
|
||||
add_library(utils SHARED IMPORTED)
|
||||
set_target_properties(utils PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libutils.a)
|
||||
|
||||
add_library(filaflat SHARED IMPORTED)
|
||||
set_target_properties(filaflat PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilaflat.a)
|
||||
|
||||
add_library(image STATIC IMPORTED)
|
||||
set_target_properties(image PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libimage.a)
|
||||
|
||||
add_library(ibl STATIC IMPORTED)
|
||||
set_target_properties(ibl PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libibl.a)
|
||||
|
||||
add_library(geometry SHARED IMPORTED)
|
||||
set_target_properties(geometry PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgeometry.a)
|
||||
|
||||
add_library(filabridge SHARED IMPORTED)
|
||||
set_target_properties(filabridge PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilabridge.a)
|
||||
|
||||
add_library(gltfio SHARED IMPORTED)
|
||||
set_target_properties(gltfio PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_core.a)
|
||||
|
||||
add_library(gltfio_resources SHARED IMPORTED)
|
||||
set_target_properties(gltfio_resources PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_resources.a)
|
||||
|
||||
add_library(bluevk SHARED IMPORTED)
|
||||
set_target_properties(bluevk PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbluevk.a)
|
||||
|
||||
add_library(smol-v SHARED IMPORTED)
|
||||
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
|
||||
|
||||
include_directories(${FILAMENT_DIR}/include
|
||||
..
|
||||
../../libs/utils/include)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-stack-protector")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -ffp-contract=fast")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility-inlines-hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffunction-sections -fdata-sections")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS " ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS " ${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${CMAKE_SOURCE_DIR}/libgltfio-jni.map")
|
||||
|
||||
add_library(gltfio-jni SHARED
|
||||
src/main/cpp/AssetLoader.cpp
|
||||
src/main/cpp/FilamentAsset.cpp
|
||||
src/main/cpp/KtxLoader.cpp
|
||||
src/main/cpp/MaterialProvider.cpp
|
||||
src/main/cpp/ResourceLoader.cpp
|
||||
../common/CallbackUtils.cpp
|
||||
../common/NioUtils.cpp
|
||||
)
|
||||
|
||||
set_target_properties(gltfio-jni PROPERTIES LINK_DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.symbols)
|
||||
|
||||
# The ordering in the following list is important because CMake does not have dependency information.
|
||||
target_link_libraries(gltfio-jni
|
||||
android
|
||||
gltfio
|
||||
gltfio_resources
|
||||
filament
|
||||
filabridge
|
||||
backend
|
||||
filaflat
|
||||
geometry
|
||||
image
|
||||
ibl
|
||||
utils
|
||||
GLESv3
|
||||
EGL
|
||||
m
|
||||
log
|
||||
)
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
target_link_libraries(gltfio-jni bluevk smol-v)
|
||||
endif()
|
||||
90
android/gltfio-android/build.gradle
Normal file
90
android/gltfio-android/build.gradle
Normal file
@@ -0,0 +1,90 @@
|
||||
// This script accepts the following parameters:
|
||||
//
|
||||
// filament_dist_dir
|
||||
// Path to the Filament distribution/install directory for Android
|
||||
// (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc.
|
||||
//
|
||||
// Example:
|
||||
// ./gradlew -Pfilament_dist_dir=../../dist-android-release assembleRelease
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
group = "com.google.android.filament"
|
||||
version = "0.1"
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
def filament_path = file("../../out/android-release/filament").absolutePath
|
||||
if (project.hasProperty("filament_dist_dir")) {
|
||||
filament_path = file("$filament_dist_dir").absolutePath
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-21")
|
||||
arguments.add("-DANDROID_STL=c++_static")
|
||||
arguments.add("-DFILAMENT_DIST_DIR=${filament_path}".toString())
|
||||
cppFlags.add("-std=c++14")
|
||||
if (project.hasProperty('extra_cmake_args')) {
|
||||
arguments.add(extra_cmake_args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:support-annotations:28.0.0'
|
||||
implementation 'com.google.android.filament:filament-android'
|
||||
}
|
||||
BIN
android/gltfio-android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
android/gltfio-android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
android/gltfio-android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
android/gltfio-android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
172
android/gltfio-android/gradlew
vendored
Executable file
172
android/gltfio-android/gradlew
vendored
Executable file
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
84
android/gltfio-android/gradlew.bat
vendored
Normal file
84
android/gltfio-android/gradlew.bat
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
4
android/gltfio-android/libgltfio-jni.map
Normal file
4
android/gltfio-android/libgltfio-jni.map
Normal file
@@ -0,0 +1,4 @@
|
||||
LIBGLTFIO {
|
||||
global: Java_com_google_android_filament_*; JNI*;
|
||||
local: *;
|
||||
};
|
||||
1
android/gltfio-android/libgltfio-jni.symbols
Normal file
1
android/gltfio-android/libgltfio-jni.symbols
Normal file
@@ -0,0 +1 @@
|
||||
_Java_com_google_android_filament_*
|
||||
12
android/gltfio-android/settings.gradle
Normal file
12
android/gltfio-android/settings.gradle
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* The settings file is used to specify which projects to include in your build.
|
||||
*
|
||||
* Detailed information about configuring a multi-project build in Gradle can be found
|
||||
* in the user guide at https://docs.gradle.org/4.6/userguide/multi_project_builds.html
|
||||
*/
|
||||
|
||||
includeBuild '../filament-android'
|
||||
|
||||
rootProject.name = 'gltfio-android'
|
||||
18
android/gltfio-android/src/main/AndroidManifest.xml
Normal file
18
android/gltfio-android/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<!--
|
||||
Copyright (C) 2019 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.filament.gltfio" />
|
||||
85
android/gltfio-android/src/main/cpp/AssetLoader.cpp
Normal file
85
android/gltfio-android/src/main/cpp/AssetLoader.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/Engine.h>
|
||||
|
||||
#include <utils/EntityManager.h>
|
||||
|
||||
#include <gltfio/AssetLoader.h>
|
||||
#include <gltfio/MaterialProvider.h>
|
||||
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
extern void registerCallbackUtils(JNIEnv*);
|
||||
extern void registerNioUtils(JNIEnv*);
|
||||
|
||||
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
registerCallbackUtils(env);
|
||||
registerNioUtils(env);
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nCreateAssetLoader(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeProvider, jlong nativeEntities) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
MaterialProvider* materials = (MaterialProvider*) nativeProvider;
|
||||
EntityManager* entities = (EntityManager*) nativeEntities;
|
||||
return (jlong) AssetLoader::create({engine, materials, nullptr, entities});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nDestroyAssetLoader(JNIEnv*, jclass,
|
||||
jlong nativeLoader) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
AssetLoader::destroy(&loader);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nCreateAssetFromBinary(JNIEnv* env, jclass,
|
||||
jlong nativeLoader, jobject javaBuffer, jint remaining) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
return (jlong) loader->createAssetFromBinary((const uint8_t *) buffer.getData(),
|
||||
buffer.getSize());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nEnableDiagnostics(JNIEnv*, jclass,
|
||||
jlong nativeLoader, jboolean enable) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
loader->enableDiagnostics(enable);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nDestroyAsset(JNIEnv*, jclass,
|
||||
jlong nativeLoader, jlong nativeAsset) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
loader->destroyAsset(asset);
|
||||
}
|
||||
73
android/gltfio-android/src/main/cpp/FilamentAsset.cpp
Normal file
73
android/gltfio-android/src/main/cpp/FilamentAsset.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <gltfio/FilamentAsset.h>
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::math;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetRoot(JNIEnv*, jclass, jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return asset->getRoot().getId();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetEntityCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return asset->getEntityCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetEntities(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(asset->getEntities(), asset->getEntityCount(), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetBoundingBox(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jfloatArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
float* values = (float*) env->GetFloatArrayElements(result, nullptr);
|
||||
const filament::Aabb box = asset->getBoundingBox();
|
||||
const float3 center = box.center();
|
||||
const float3 extent = box.extent();
|
||||
values[0] = center.x;
|
||||
values[1] = center.y;
|
||||
values[2] = center.z;
|
||||
values[3] = extent.x;
|
||||
values[4] = extent.y;
|
||||
values[5] = extent.z;
|
||||
env->ReleaseFloatArrayElements(result, (jfloat*) values, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetName(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint entityId) {
|
||||
uint32_t id = entityId;
|
||||
Entity* entity = (Entity*) &id;
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const char* val = asset->getName(*entity);
|
||||
return val ? env->NewStringUTF(val) : nullptr;
|
||||
}
|
||||
77
android/gltfio-android/src/main/cpp/KtxLoader.cpp
Normal file
77
android/gltfio-android/src/main/cpp/KtxLoader.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/Engine.h>
|
||||
#include <filament/IndirectLight.h>
|
||||
#include <filament/Skybox.h>
|
||||
|
||||
#include <image/KtxUtility.h>
|
||||
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::math;
|
||||
using namespace image;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_KtxLoader_nCreateTexture(JNIEnv* env, jclass,
|
||||
jlong nativeEngine, jobject javaBuffer, jint remaining, jboolean srgb) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
KtxBundle* bundle = new KtxBundle((const uint8_t*) buffer.getData(), buffer.getSize());
|
||||
return (jlong) KtxUtility::createTexture(engine, *bundle, srgb, [](void* userdata) {
|
||||
KtxBundle* bundle = (KtxBundle*) userdata;
|
||||
delete bundle;
|
||||
}, bundle);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_KtxLoader_nCreateIndirectLight(JNIEnv* env, jclass,
|
||||
jlong nativeEngine, jobject javaBuffer, jint remaining, jboolean srgb) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
KtxBundle* bundle = new KtxBundle((const uint8_t*) buffer.getData(), buffer.getSize());
|
||||
Texture* cubemap = KtxUtility::createTexture(engine, *bundle, srgb, [](void* userdata) {
|
||||
KtxBundle* bundle = (KtxBundle*) userdata;
|
||||
delete bundle;
|
||||
}, bundle);
|
||||
|
||||
float3 harmonics[9];
|
||||
bundle->getSphericalHarmonics(harmonics);
|
||||
|
||||
IndirectLight* indirectLight = IndirectLight::Builder()
|
||||
.reflections(cubemap)
|
||||
.irradiance(3, harmonics)
|
||||
.intensity(30000)
|
||||
.build(*engine);
|
||||
|
||||
return (jlong) indirectLight;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_KtxLoader_nCreateSkybox(JNIEnv* env, jclass,
|
||||
jlong nativeEngine, jobject javaBuffer, jint remaining, jboolean srgb) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
KtxBundle* bundle = new KtxBundle((const uint8_t*) buffer.getData(), buffer.getSize());
|
||||
Texture* cubemap = KtxUtility::createTexture(engine, *bundle, srgb, [](void* userdata) {
|
||||
KtxBundle* bundle = (KtxBundle*) userdata;
|
||||
delete bundle;
|
||||
}, bundle);
|
||||
return (jlong) Skybox::Builder().environment(cubemap).showSun(true).build(*engine);
|
||||
}
|
||||
36
android/gltfio-android/src/main/cpp/MaterialProvider.cpp
Normal file
36
android/gltfio-android/src/main/cpp/MaterialProvider.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <gltfio/MaterialProvider.h>
|
||||
|
||||
using namespace filament;
|
||||
using namespace gltfio;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_MaterialProvider_nCreateMaterialProvider(JNIEnv*, jclass,
|
||||
jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) createUbershaderLoader(engine);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_MaterialProvider_nDestroyMaterialProvider(JNIEnv*, jclass,
|
||||
jlong nativeProvider) {
|
||||
auto provider = (MaterialProvider*) nativeProvider;
|
||||
delete provider;
|
||||
}
|
||||
67
android/gltfio-android/src/main/cpp/ResourceLoader.cpp
Normal file
67
android/gltfio-android/src/main/cpp/ResourceLoader.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/Engine.h>
|
||||
|
||||
#include <gltfio/ResourceLoader.h>
|
||||
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
using namespace filament;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
static void destroy(void* data, size_t size, void *userData) {
|
||||
AutoBuffer* buffer = (AutoBuffer*) userData;
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nCreateResourceLoader(JNIEnv*, jclass,
|
||||
jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) new ResourceLoader({ engine, utils::Path(), true, true });
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nDestroyResourceLoader(JNIEnv*, jclass,
|
||||
jlong nativeLoader) {
|
||||
ResourceLoader* loader = (ResourceLoader*) nativeLoader;
|
||||
delete loader;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nAddResourceData(JNIEnv* env, jclass,
|
||||
jlong nativeLoader, jstring url, jobject javaBuffer, jint remaining) {
|
||||
ResourceLoader* loader = (ResourceLoader*) nativeLoader;
|
||||
AutoBuffer* buffer = new AutoBuffer(env, javaBuffer, remaining);
|
||||
const char* curl = env->GetStringUTFChars(url, nullptr);
|
||||
loader->addResourceData(curl,
|
||||
ResourceLoader::BufferDescriptor(buffer->getData(), buffer->getSize(), &destroy,
|
||||
buffer));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nLoadResources(JNIEnv*, jclass,
|
||||
jlong nativeLoader, jlong nativeAsset) {
|
||||
ResourceLoader* loader = (ResourceLoader*) nativeLoader;
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
loader->loadResources(asset);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.gltfio;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.google.android.filament.Engine;
|
||||
import com.google.android.filament.EntityManager;
|
||||
import com.google.android.filament.IndirectLight;
|
||||
import com.google.android.filament.Skybox;
|
||||
import com.google.android.filament.Texture;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.Buffer;
|
||||
|
||||
public class AssetLoader {
|
||||
private long mNativeObject;
|
||||
|
||||
static Method sEngineGetNativeObject;
|
||||
static Method sEntityManagerGetNativeObject;
|
||||
static Constructor<Texture> sTextureConstructor;
|
||||
static Constructor<IndirectLight> sIndirectLightConstructor;
|
||||
static Constructor<Skybox> sSkyboxConstructor;
|
||||
|
||||
public static void init() {
|
||||
System.loadLibrary("gltfio-jni");
|
||||
try {
|
||||
sEngineGetNativeObject = Engine.class.getDeclaredMethod("getNativeObject");
|
||||
sEngineGetNativeObject.setAccessible(true);
|
||||
|
||||
sEntityManagerGetNativeObject = EntityManager.class.getDeclaredMethod("getNativeObject");
|
||||
sEntityManagerGetNativeObject.setAccessible(true);
|
||||
|
||||
sTextureConstructor = Texture.class.getDeclaredConstructor(long.class);
|
||||
sTextureConstructor.setAccessible(true);
|
||||
|
||||
sIndirectLightConstructor = IndirectLight.class.getDeclaredConstructor(long.class);
|
||||
sIndirectLightConstructor.setAccessible(true);
|
||||
|
||||
sSkyboxConstructor = Skybox.class.getDeclaredConstructor(long.class);
|
||||
sSkyboxConstructor.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
// Cannot happen
|
||||
}
|
||||
}
|
||||
|
||||
public AssetLoader(@NonNull Engine engine, @NonNull MaterialProvider generator,
|
||||
@NonNull EntityManager entities) {
|
||||
try {
|
||||
long nativeEngine = (long) sEngineGetNativeObject.invoke(engine);
|
||||
long nativeMaterials = generator.getNativeObject();
|
||||
long nativeEntities = (long) sEntityManagerGetNativeObject.invoke(entities);
|
||||
mNativeObject = nCreateAssetLoader(nativeEngine, nativeMaterials, nativeEntities);
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Unable to parse glTF asset.");
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
nDestroyAssetLoader(mNativeObject);
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FilamentAsset createAssetFromBinary(@NonNull Buffer buffer) {
|
||||
long nativeAsset = nCreateAssetFromBinary(mNativeObject, buffer, buffer.remaining());
|
||||
return new FilamentAsset(nativeAsset);
|
||||
}
|
||||
|
||||
public void enableDiagnostics(boolean enable) {
|
||||
nEnableDiagnostics(mNativeObject, enable);
|
||||
}
|
||||
|
||||
public void destroyAsset(@Nullable FilamentAsset asset) {
|
||||
nDestroyAsset(mNativeObject, asset.getNativeObject());
|
||||
asset.clearNativeObject();
|
||||
}
|
||||
|
||||
private static native long nCreateAssetLoader(long nativeEngine, long nativeGenerator, long nativeEntities);
|
||||
private static native void nDestroyAssetLoader(long nativeLoader);
|
||||
private static native long nCreateAssetFromBinary(long nativeLoader, Buffer buffer, int remaining);
|
||||
private static native void nEnableDiagnostics(long nativeLoader, boolean enable);
|
||||
private static native void nDestroyAsset(long nativeLoader, long nativeAsset);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.gltfio;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.google.android.filament.Box;
|
||||
import com.google.android.filament.Entity;
|
||||
|
||||
public class FilamentAsset {
|
||||
private long mNativeObject;
|
||||
|
||||
FilamentAsset(long nativeObject) {
|
||||
mNativeObject = nativeObject;
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
public @Entity int getRoot() {
|
||||
return nGetRoot(mNativeObject);
|
||||
}
|
||||
|
||||
public @Entity int[] getEntities() {
|
||||
int[] result = new int[nGetEntityCount(mNativeObject)];
|
||||
nGetEntities(mNativeObject, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public @NonNull Box getBoundingBox() {
|
||||
float[] box = new float[6];
|
||||
nGetBoundingBox(mNativeObject, box);
|
||||
return new Box(box[0], box[1], box[2], box[3], box[4], box[5]);
|
||||
}
|
||||
|
||||
public String getName(@Entity int entity) {
|
||||
return nGetName(getNativeObject(), entity);
|
||||
}
|
||||
|
||||
void clearNativeObject() {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native int nGetRoot(long nativeAsset);
|
||||
private static native int nGetEntityCount(long nativeAsset);
|
||||
private static native void nGetEntities(long nativeAsset, int[] result);
|
||||
private static native void nGetBoundingBox(long nativeAsset, float[] box);
|
||||
private static native String nGetName(long nativeAsset, int entity);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.gltfio;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.google.android.filament.Engine;
|
||||
import com.google.android.filament.IndirectLight;
|
||||
import com.google.android.filament.Skybox;
|
||||
import com.google.android.filament.Texture;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
public class KtxLoader {
|
||||
|
||||
public static class Options {
|
||||
public boolean srgb;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Texture createTexture(@NonNull Engine engine, @NonNull Buffer buffer, @NonNull Options options) {
|
||||
try {
|
||||
long nativeEngine = (long) AssetLoader.sEngineGetNativeObject.invoke(engine);
|
||||
long nativeTexture = nCreateTexture(nativeEngine, buffer, buffer.remaining(), options.srgb);
|
||||
return AssetLoader.sTextureConstructor.newInstance(nativeTexture);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IndirectLight createIndirectLight(@NonNull Engine engine, @NonNull Buffer buffer, @NonNull Options options) {
|
||||
try {
|
||||
long nativeEngine = (long) AssetLoader.sEngineGetNativeObject.invoke(engine);
|
||||
long nativeIndirectLight = nCreateIndirectLight(nativeEngine, buffer, buffer.remaining(), options.srgb);
|
||||
return AssetLoader.sIndirectLightConstructor.newInstance(nativeIndirectLight);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Skybox createSkybox(@NonNull Engine engine, @NonNull Buffer buffer, @NonNull Options options) {
|
||||
try {
|
||||
long nativeEngine = (long) AssetLoader.sEngineGetNativeObject.invoke(engine);
|
||||
long nativeSkybox = nCreateSkybox(nativeEngine, buffer, buffer.remaining(), options.srgb);
|
||||
return AssetLoader.sSkyboxConstructor.newInstance(nativeSkybox);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static native long nCreateTexture(long nativeEngine, Buffer buffer, int remaining, boolean srgb);
|
||||
private static native long nCreateIndirectLight(long nativeEngine, Buffer buffer, int remaining, boolean srgb);
|
||||
private static native long nCreateSkybox(long nativeEngine, Buffer buffer, int remaining, boolean srgb);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.gltfio;
|
||||
|
||||
import com.google.android.filament.Engine;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class MaterialProvider {
|
||||
private long mNativeObject;
|
||||
|
||||
private static Method sEngineGetNativeObject;
|
||||
|
||||
static {
|
||||
try {
|
||||
sEngineGetNativeObject = Engine.class.getDeclaredMethod("getNativeObject");
|
||||
sEngineGetNativeObject.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
// Cannot happen
|
||||
}
|
||||
}
|
||||
|
||||
public MaterialProvider(Engine engine) {
|
||||
try {
|
||||
long nativeEngine = (long) sEngineGetNativeObject.invoke(engine);
|
||||
mNativeObject = nCreateMaterialProvider(nativeEngine);
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
nDestroyMaterialProvider(mNativeObject);
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
private static native long nCreateMaterialProvider(long nativeEngine);
|
||||
private static native void nDestroyMaterialProvider(long nativeProvider);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.gltfio;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.filament.Engine;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.Buffer;
|
||||
|
||||
public class ResourceLoader {
|
||||
private final long mNativeObject;
|
||||
|
||||
private static Method sEngineGetNativeObject;
|
||||
|
||||
static {
|
||||
try {
|
||||
sEngineGetNativeObject = Engine.class.getDeclaredMethod("getNativeObject");
|
||||
sEngineGetNativeObject.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
// Cannot happen
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLoader(@NonNull Engine engine) throws IllegalAccessException, InvocationTargetException {
|
||||
long nativeEngine = (long) sEngineGetNativeObject.invoke(engine);
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
nDestroyResourceLoader(mNativeObject);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ResourceLoader addResourceData(@NonNull String url, @NonNull Buffer buffer) {
|
||||
nAddResourceData(mNativeObject, url, buffer, buffer.remaining());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ResourceLoader loadResources(@NonNull FilamentAsset asset) {
|
||||
nLoadResources(mNativeObject, asset.getNativeObject());
|
||||
return this;
|
||||
}
|
||||
|
||||
private static native long nCreateResourceLoader(long nativeEngine);
|
||||
private static native void nDestroyResourceLoader(long nativeLoader);
|
||||
private static native void nAddResourceData(long nativeLoader, String url, Buffer buffer,
|
||||
int remaining);
|
||||
private static native void nLoadResources(long nativeLoader, long nativeAsset);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user