Compare commits
1043 Commits
sceneform-
...
v1.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90fdb95429 | ||
|
|
d5c0d11404 | ||
|
|
b0d116632c | ||
|
|
a67d92c2ca | ||
|
|
21b208398b | ||
|
|
65b3e956df | ||
|
|
c8d0715b16 | ||
|
|
16d307e543 | ||
|
|
5ed07639af | ||
|
|
e2655e93bc | ||
|
|
3a20be1d1a | ||
|
|
8244f8e9cb | ||
|
|
c575fd7395 | ||
|
|
6a67cf0009 | ||
|
|
79292481b3 | ||
|
|
829f341de3 | ||
|
|
b509ef4dad | ||
|
|
422c8d9a64 | ||
|
|
d0b5c5cee8 | ||
|
|
9b9548306d | ||
|
|
b28e535540 | ||
|
|
1f7584ace2 | ||
|
|
21512e8228 | ||
|
|
a34903aa33 | ||
|
|
4eba402adb | ||
|
|
64c5f5aee7 | ||
|
|
1bda37776b | ||
|
|
1c5d7d6cc3 | ||
|
|
b81ff060ae | ||
|
|
0cebbfca23 | ||
|
|
b9c7814dfd | ||
|
|
ba9fd6719a | ||
|
|
f0ad12ce2e | ||
|
|
21acf53d3f | ||
|
|
2f5927d531 | ||
|
|
cf950a8d6f | ||
|
|
48b73ad998 | ||
|
|
8fc94f127b | ||
|
|
ce33f42e62 | ||
|
|
61032e55b5 | ||
|
|
6160d3f51e | ||
|
|
5d725f6de9 | ||
|
|
020e9e59ed | ||
|
|
bd777c1e56 | ||
|
|
087b12c802 | ||
|
|
42f2642d72 | ||
|
|
9c8d0ed5a1 | ||
|
|
9fd1705acf | ||
|
|
c981b52832 | ||
|
|
d074b6fd1a | ||
|
|
7da5a25e2f | ||
|
|
b96b8eb787 | ||
|
|
a25be5ee6e | ||
|
|
bf9d1f1967 | ||
|
|
561221fdc3 | ||
|
|
8548afa231 | ||
|
|
803e695d5c | ||
|
|
5c58776313 | ||
|
|
0db39ea08a | ||
|
|
d76fb5d7e5 | ||
|
|
f37ab8158c | ||
|
|
33db5acd13 | ||
|
|
e068204876 | ||
|
|
d849231caf | ||
|
|
996bd58fcb | ||
|
|
9b70dc5253 | ||
|
|
31af9ca80f | ||
|
|
08aa2ec4ca | ||
|
|
95be2e24ce | ||
|
|
7b200ec85e | ||
|
|
cf1b45c052 | ||
|
|
57e7280ac9 | ||
|
|
64d432cb34 | ||
|
|
fde23c89e2 | ||
|
|
0e3bc8a443 | ||
|
|
88bcd133f2 | ||
|
|
2072b67e04 | ||
|
|
2a2974580c | ||
|
|
65f72a48fb | ||
|
|
65674c7c51 | ||
|
|
8d1b630b24 | ||
|
|
1235a66f83 | ||
|
|
411e7f4511 | ||
|
|
cf095cbdd2 | ||
|
|
394db90ec9 | ||
|
|
72644f1416 | ||
|
|
ed2fc0e391 | ||
|
|
c9f4d983a0 | ||
|
|
694db54d9d | ||
|
|
15b663ba0b | ||
|
|
23ee5e276c | ||
|
|
7c24a1bbaa | ||
|
|
32eee2cdf1 | ||
|
|
7dbad8928f | ||
|
|
0e81207758 | ||
|
|
c67266833a | ||
|
|
d6b0b6ff52 | ||
|
|
9d0ad3586d | ||
|
|
7393d5d98c | ||
|
|
7a819a60ae | ||
|
|
c735659592 | ||
|
|
c36745db97 | ||
|
|
a5284af2b8 | ||
|
|
4989c3dc48 | ||
|
|
3925b0a8ec | ||
|
|
356610ba1d | ||
|
|
9eae72f99d | ||
|
|
1d12fc1aaa | ||
|
|
f9bd085757 | ||
|
|
1003926665 | ||
|
|
709180932e | ||
|
|
132326f8f2 | ||
|
|
92e86de630 | ||
|
|
3e8a145fce | ||
|
|
a5db6a84b6 | ||
|
|
f192b89ef9 | ||
|
|
637395b075 | ||
|
|
b03172f4a2 | ||
|
|
24225315fa | ||
|
|
2bc9256a7a | ||
|
|
264cf020b6 | ||
|
|
ceafc7835b | ||
|
|
db8d4ee076 | ||
|
|
26f7907b17 | ||
|
|
c35f1e0b29 | ||
|
|
e2ee00e36e | ||
|
|
d87f77c41a | ||
|
|
13fcce2d9a | ||
|
|
216761656f | ||
|
|
05e9d708ed | ||
|
|
cc321385cd | ||
|
|
038d39f294 | ||
|
|
3555a01541 | ||
|
|
5d52266eac | ||
|
|
5368756983 | ||
|
|
f74e136f46 | ||
|
|
040c1c686a | ||
|
|
e74c33ce04 | ||
|
|
ab24634637 | ||
|
|
8f3bdc20ba | ||
|
|
74aaaed4db | ||
|
|
9c64c20ceb | ||
|
|
b92c748fcc | ||
|
|
844dde4e6d | ||
|
|
c0de0ca36d | ||
|
|
ad3bc4a6f7 | ||
|
|
572b2cff57 | ||
|
|
fb9cf43768 | ||
|
|
f41db8bb91 | ||
|
|
89c8e7c51a | ||
|
|
0ad21cd47a | ||
|
|
7dbf81fe3d | ||
|
|
3072309574 | ||
|
|
573e9220a2 | ||
|
|
e22f02d228 | ||
|
|
b620b7efa1 | ||
|
|
d1593326cb | ||
|
|
6a8e6d45b5 | ||
|
|
11336964a1 | ||
|
|
71e98d54f5 | ||
|
|
417ba87fcb | ||
|
|
f71fea4ef5 | ||
|
|
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 |
57
.github/workflows/presubmit.yml
vendored
Normal file
57
.github/workflows/presubmit.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Presubmit
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build-desktop:
|
||||
name: build-desktop
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Run build script
|
||||
run: |
|
||||
WORKFLOW_OS=`echo \`uname\` | sed "s/Darwin/mac/" | tr [:upper:] [:lower:]`
|
||||
cd build/$WORKFLOW_OS && ./build.sh ${TARGET}
|
||||
env:
|
||||
TARGET: presubmit
|
||||
|
||||
build-android:
|
||||
name: build-android
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/android && ./build.sh ${TARGET}
|
||||
env:
|
||||
TARGET: presubmit
|
||||
|
||||
build-ios:
|
||||
name: build-iOS
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/ios && ./build.sh ${TARGET}
|
||||
env:
|
||||
TARGET: presubmit
|
||||
|
||||
build-web:
|
||||
name: build-web
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/web && ./build.sh ${TARGET}
|
||||
env:
|
||||
TARGET: presubmit
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -3,9 +3,13 @@
|
||||
imgui.ini
|
||||
cmake-*
|
||||
ImportExecutables-*.cmake
|
||||
out
|
||||
/out*
|
||||
dist
|
||||
dist-*
|
||||
toolchains
|
||||
filament/docs/html/**
|
||||
.vscode
|
||||
gltf_baker.ini
|
||||
*tmp*.png
|
||||
civetweb.txt
|
||||
/TAGS
|
||||
|
||||
204
CMakeLists.txt
204
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,6 +27,10 @@ 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
|
||||
@@ -42,19 +50,46 @@ if (WIN32)
|
||||
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} ${CRT_FLAGS_RELEASE} /Z7")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7")
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# 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} ${CRT_FLAGS_RELEASE} /Z7")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CRT_FLAGS_RELEASE} /Z7")
|
||||
|
||||
# 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} ${CRT_FLAGS_DEBUG} /Z7")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
|
||||
endif()
|
||||
|
||||
# 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} ${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 AND NOT IOS)
|
||||
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()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -75,13 +110,13 @@ 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)
|
||||
message(FATAL_ERROR "Detected C compiler Clang ${CMAKE_C_COMPILER_VERSION} < ${MIN_CLANG_VERSION}")
|
||||
endif()
|
||||
else()
|
||||
elseif (NOT MSVC)
|
||||
message(FATAL_ERROR "Detected C compiler ${CMAKE_C_COMPILER_ID} is unsupported")
|
||||
endif()
|
||||
|
||||
@@ -89,13 +124,31 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION)
|
||||
message(FATAL_ERROR "Detected CXX compiler Clang ${CMAKE_CXX_COMPILER_VERSION} < ${MIN_CLANG_VERSION}")
|
||||
endif()
|
||||
else()
|
||||
elseif (NOT MSVC)
|
||||
message(FATAL_ERROR "Detected CXX compiler ${CMAKE_CXX_COMPILER_ID} is unsupported")
|
||||
endif()
|
||||
|
||||
# Detect use of the clang-cl.exe frontend, which does not support all of clangs normal options
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
|
||||
set(CLANG_CL true)
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
|
||||
set(CLANG_CL true)
|
||||
endif()
|
||||
elseif (MSVC)
|
||||
set(MSVC_NATIVE 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()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -106,7 +159,12 @@ if (WIN32)
|
||||
set(CXX_STANDARD "/std:c++14")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} -fstrict-aliasing -Wno-unknown-pragmas -Wno-unused-function")
|
||||
if (MSVC_NATIVE)
|
||||
set(CXX_STANDARD "/std:c++latest")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} /W0 /Zc:__cplusplus")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} -fstrict-aliasing -Wno-unknown-pragmas -Wno-unused-function")
|
||||
endif()
|
||||
|
||||
if (USE_EXTERNAL_GLES3)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_EXTERNAL_GLES3")
|
||||
@@ -118,25 +176,16 @@ 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)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
|
||||
endif()
|
||||
|
||||
if (CLANG_CL)
|
||||
if (CLANG_CL OR MSVC)
|
||||
# Since the "secure" replacements that MSVC suggests are not portable, disable
|
||||
# the deprecation warnings. Also disable warnings about use of POSIX functions (i.e. "unlink").
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE")
|
||||
@@ -152,7 +201,7 @@ endif()
|
||||
# ==================================================================================================
|
||||
# Release compiler flags
|
||||
# ==================================================================================================
|
||||
if (NOT CLANG_CL)
|
||||
if (NOT CLANG_CL AND NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffunction-sections -fdata-sections")
|
||||
endif()
|
||||
|
||||
@@ -170,7 +219,7 @@ endif()
|
||||
# -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)
|
||||
if (NOT CLANG_CL AND NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${EXTRA_SANITIZE_OPTIONS}")
|
||||
@@ -216,8 +265,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)
|
||||
@@ -227,7 +275,8 @@ if (FILAMENT_SUPPORTS_VULKAN)
|
||||
endif()
|
||||
|
||||
# Build with Metal support on non-WebGL Apple platforms.
|
||||
if (APPLE AND NOT WEBGL)
|
||||
# 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)
|
||||
@@ -236,14 +285,43 @@ if (FILAMENT_SUPPORTS_METAL)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_METAL)
|
||||
endif()
|
||||
|
||||
# Building filamat increases build times and isn't required for non-desktop platforms, so turn it
|
||||
# off by default.
|
||||
if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
|
||||
# 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
|
||||
# ==================================================================================================
|
||||
@@ -258,18 +336,23 @@ endif()
|
||||
# ==================================================================================================
|
||||
# Functions
|
||||
# ==================================================================================================
|
||||
## The MSVC compiler has a limitation on literal string length which is reached when all the
|
||||
## licenses are concatenated together into a large string... so split them into multiple strings.
|
||||
function(list_licenses OUTPUT MODULES)
|
||||
file(WRITE ${OUTPUT} "R\"FILAMENT__(\n")
|
||||
set(STR_OPENER "R\"FILAMENT__(")
|
||||
set(STR_CLOSER ")FILAMENT__\"")
|
||||
set(CONTENT)
|
||||
set(_MODULES ${MODULES} ${ARGN})
|
||||
foreach(module ${_MODULES})
|
||||
set(license_path "../../third_party/${module}/LICENSE")
|
||||
get_filename_component(fullname "${license_path}" ABSOLUTE)
|
||||
file(APPEND ${OUTPUT} "License and copyrights for ${module}:\n\n")
|
||||
file(READ ${license_path} license)
|
||||
file(APPEND ${OUTPUT} ${license})
|
||||
file(APPEND ${OUTPUT} "\n\n")
|
||||
string(APPEND CONTENT "${STR_OPENER}License and copyrights for ${module}:\n${STR_CLOSER},\n")
|
||||
file(READ ${license_path} license_long)
|
||||
string(REPLACE "\n" "${STR_CLOSER},\n${STR_OPENER}" license ${license_long})
|
||||
string(APPEND CONTENT ${STR_OPENER}${license}\n${STR_CLOSER},)
|
||||
string(APPEND CONTENT "\n\n")
|
||||
endforeach()
|
||||
file(APPEND ${OUTPUT} ")FILAMENT__\"\n")
|
||||
configure_file(${FILAMENT}/build/licenses.inc.in ${OUTPUT})
|
||||
endfunction(list_licenses)
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -301,7 +384,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
|
||||
@@ -309,14 +394,16 @@ function(get_resgen_vars ARCHIVE_DIR ARCHIVE_NAME)
|
||||
${ARCHIVE_DIR}/${ARCHIVE_NAME}.apple.S
|
||||
${ARCHIVE_DIR}/${ARCHIVE_NAME}.h
|
||||
)
|
||||
set(ASM_ARCH_FLAG "-arch ${DIST_ARCH}")
|
||||
if (IOS)
|
||||
set(ASM_ARCH_FLAG "-arch ${DIST_ARCH}")
|
||||
endif()
|
||||
if (APPLE)
|
||||
set(ASM_SUFFIX ".apple")
|
||||
endif()
|
||||
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)
|
||||
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)
|
||||
@@ -337,7 +424,11 @@ add_subdirectory(${EXTERNAL}/libgtest/tnt)
|
||||
add_subdirectory(${LIBRARIES}/filabridge)
|
||||
add_subdirectory(${LIBRARIES}/filaflat)
|
||||
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)
|
||||
@@ -346,6 +437,10 @@ 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)
|
||||
add_subdirectory(${EXTERNAL}/getopt)
|
||||
|
||||
if (FILAMENT_BUILD_FILAMAT)
|
||||
# spirv-tools must come before filamat, as filamat relies on the presence of the
|
||||
@@ -353,7 +448,6 @@ if (FILAMENT_BUILD_FILAMAT)
|
||||
add_subdirectory(${EXTERNAL}/spirv-tools)
|
||||
add_subdirectory(${EXTERNAL}/glslang/tnt)
|
||||
add_subdirectory(${EXTERNAL}/spirv-cross/tnt)
|
||||
add_subdirectory(android/filamat-android)
|
||||
add_subdirectory(${LIBRARIES}/filamat)
|
||||
endif()
|
||||
|
||||
@@ -371,30 +465,33 @@ 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(${LIBRARIES}/bluegl)
|
||||
add_subdirectory(${LIBRARIES}/filagui)
|
||||
add_subdirectory(${LIBRARIES}/imageio)
|
||||
add_subdirectory(${LIBRARIES}/matdbg)
|
||||
|
||||
add_subdirectory(${FILAMENT}/java)
|
||||
add_subdirectory(${FILAMENT}/java/filamat)
|
||||
add_subdirectory(${FILAMENT}/java/filament)
|
||||
add_subdirectory(${FILAMENT}/samples)
|
||||
|
||||
add_subdirectory(${EXTERNAL}/astcenc/tnt)
|
||||
add_subdirectory(${EXTERNAL}/civetweb/tnt)
|
||||
add_subdirectory(${EXTERNAL}/etc2comp)
|
||||
add_subdirectory(${EXTERNAL}/getopt)
|
||||
add_subdirectory(${EXTERNAL}/imgui/tnt)
|
||||
add_subdirectory(${EXTERNAL}/libassimp/tnt)
|
||||
add_subdirectory(${EXTERNAL}/libpng/tnt)
|
||||
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)
|
||||
@@ -408,6 +505,11 @@ if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
|
||||
add_subdirectory(${TOOLS}/roughness-prefilter)
|
||||
add_subdirectory(${TOOLS}/skygen)
|
||||
add_subdirectory(${TOOLS}/specular-color)
|
||||
|
||||
if (DENOISE_LIBRARY)
|
||||
add_subdirectory(${EXTERNAL}/OpenImageDenoise/tnt)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# Generate exported executables for cross-compiled builds (Android, WebGL, and iOS)
|
||||
|
||||
@@ -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.
|
||||
|
||||
168
README.md
168
README.md
@@ -26,11 +26,11 @@ 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
|
||||
@@ -43,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
|
||||
@@ -62,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
|
||||
|
||||
@@ -74,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
|
||||
@@ -124,15 +136,21 @@ 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
|
||||
- `matdbg`: DebugServer for inspecting shaders at run-time (debug builds only)
|
||||
- `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
|
||||
@@ -154,7 +172,7 @@ and tools.
|
||||
|
||||
To build Filament, you must first install the following tools:
|
||||
|
||||
- CMake 3.4 (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)
|
||||
|
||||
@@ -165,11 +183,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.3
|
||||
- Android Studio 3.5
|
||||
- Android SDK
|
||||
- Android NDK
|
||||
- Android NDK "side-by-side" 20 or higher
|
||||
|
||||
### Environment variables
|
||||
|
||||
@@ -182,7 +205,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
|
||||
@@ -230,9 +253,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++-7-dev` (`libcxx-devel` on Fedora)
|
||||
- `libc++abi-7-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`
|
||||
|
||||
@@ -248,13 +272,6 @@ $ 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:
|
||||
|
||||
@@ -262,7 +279,7 @@ Your Linux distribution might default to `gcc` instead of `clang`, if that's the
|
||||
$ mkdir out/cmake-release
|
||||
$ cd out/cmake-release
|
||||
# Or use a specific version of clang, for instance /usr/bin/clang-7
|
||||
$ CC=/usr/bin/clang CXX=/usr/bin/clang++ CXXFLAGS=-stdlib=libc++ LDFLAGS=-lc++abi \
|
||||
$ CC=/usr/bin/clang CXX=/usr/bin/clang++ CXXFLAGS=-stdlib=libc++ \
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../release/filament ../..
|
||||
```
|
||||
|
||||
@@ -271,10 +288,10 @@ solution is to use `update-alternatives` to both change the default compiler, an
|
||||
specific version of clang:
|
||||
|
||||
```
|
||||
$ 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-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
|
||||
```
|
||||
|
||||
Finally, invoke `ninja`:
|
||||
@@ -333,10 +350,9 @@ Install the following components:
|
||||
|
||||
- [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)
|
||||
- [Visual Studio 2015 or 2017](https://www.visualstudio.com/downloads)
|
||||
- [Clang 6](http://releases.llvm.org/download.html)
|
||||
- [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)
|
||||
|
||||
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)
|
||||
@@ -381,7 +397,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
|
||||
@@ -414,7 +430,7 @@ following CMake command:
|
||||
You should then be able to build by invoking Ninja:
|
||||
|
||||
```
|
||||
ninja
|
||||
> ninja
|
||||
```
|
||||
|
||||
#### Development tips
|
||||
@@ -429,7 +445,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
|
||||
@@ -462,24 +478,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 21 \
|
||||
--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 21 \
|
||||
--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:
|
||||
|
||||
```
|
||||
@@ -507,24 +505,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 21 \
|
||||
--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 21 \
|
||||
--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:
|
||||
|
||||
```
|
||||
@@ -552,24 +532,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 21 \
|
||||
--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 21 \
|
||||
--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:
|
||||
|
||||
```
|
||||
@@ -597,24 +559,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 21 \
|
||||
--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 21 \
|
||||
--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:
|
||||
|
||||
```
|
||||
@@ -724,13 +668,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:
|
||||
@@ -773,8 +717,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
|
||||
@@ -790,7 +735,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
|
||||
@@ -798,7 +743,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();
|
||||
@@ -897,7 +842,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
|
||||
|
||||
87
RELEASE_NOTES.md
Normal file
87
RELEASE_NOTES.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# 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.
|
||||
|
||||
## v1.4.0
|
||||
|
||||
- API Breakage: Simplified public-facing Fence API.
|
||||
- Minimum API level on Android is now API 19 instead of API 21.
|
||||
- Filament can now be built with msvc 2019.
|
||||
- Added the ability to modify clip space coordinates in the vertex shader.
|
||||
- Added missing API documentation.
|
||||
- Improved existing API documentation.
|
||||
- Added `Camera::setExposure(float)` to directly control the camera's exposure.
|
||||
- Backface culling can now be toggled on material instances.
|
||||
- Face direction is now reversed when transforms have negative scale.
|
||||
- Dielectrics now behave properly under a white furnace (energy preserving and conserving).
|
||||
- Clear coat roughness now remains in the 0..1 (previously remapped to the 0..0.6 range).
|
||||
- gltfio: Fixed several limitations with ubershader mode.
|
||||
- gltfio: Fixed a transforms issue with non-uniform scale.
|
||||
- webgl: Fixed an issue with JPEG textures.
|
||||
- Windows: Fix link error in debug builds.
|
||||
- matdbg: Web server must now be enabled with an environment variable.
|
||||
- matdbg: Added support for editing GLSL and MSL code.
|
||||
|
||||
## v1.3.2
|
||||
|
||||
- Added optional web server for real-time inspection of shader code.
|
||||
- Added basic #include support in material files.
|
||||
- Fixed potential Metal memory leak.
|
||||
- Fixed intermittent memory overflow in wasm builds.
|
||||
- Fix bad normal mapping with skinning.
|
||||
- Java clients can now call getNativeObject().
|
||||
|
||||
## 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
|
||||
@@ -39,43 +39,6 @@ ninja matc resgen cmgen
|
||||
The build should succeed and a `ImportExecutables-Release.cmake` file should automatically be
|
||||
created at Filament's root directory.
|
||||
|
||||
## Toolchains
|
||||
|
||||
Generate a toolchain for each Android architecture you're interested in building for.
|
||||
|
||||
From Filament's root directory, run the NDK `make_standalone_toolchain.py` script for each
|
||||
architecture.
|
||||
|
||||
```
|
||||
python %ANDROID_HOME%\ndk-bundle\build\tools\make_standalone_toolchain.py ^
|
||||
--arch arm64 ^
|
||||
--api 21 ^
|
||||
--stl libc++ ^
|
||||
--force ^
|
||||
--install-dir "toolchains/Windows/aarch64-linux-android-4.9"
|
||||
|
||||
python %ANDROID_HOME%\ndk-bundle\build\tools\make_standalone_toolchain.py ^
|
||||
--arch arm ^
|
||||
--api 21 ^
|
||||
--stl libc++ ^
|
||||
--force ^
|
||||
--install-dir "toolchains/Windows/arm-linux-android-4.9"
|
||||
|
||||
python %ANDROID_HOME%\ndk-bundle\build\tools\make_standalone_toolchain.py ^
|
||||
--arch x86_64 ^
|
||||
--api 21 ^
|
||||
--stl libc++ ^
|
||||
--force ^
|
||||
--install-dir "toolchains/Windows/x86_64-linux-android-4.9"
|
||||
|
||||
python %ANDROID_HOME%\ndk-bundle\build\tools\make_standalone_toolchain.py ^
|
||||
--arch x86 ^
|
||||
--api 21 ^
|
||||
--stl libc++ ^
|
||||
--force ^
|
||||
--install-dir "toolchains/Windows/x86-linux-android-4.9"
|
||||
````
|
||||
|
||||
## Build
|
||||
|
||||
1. Create the build directories.
|
||||
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
};
|
||||
1
android/filamat-android/.gitignore
vendored
1
android/filamat-android/.gitignore
vendored
@@ -9,3 +9,4 @@
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
/.cxx
|
||||
@@ -1,95 +1,55 @@
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
project(filamat-java)
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
if (NOT ENABLE_JAVA)
|
||||
return()
|
||||
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
|
||||
|
||||
set(FILAMAT_FLAVOR "filamat")
|
||||
if(FILAMAT_LITE)
|
||||
set(FILAMAT_FLAVOR "filamat_lite")
|
||||
endif()
|
||||
|
||||
find_package(Java)
|
||||
if (NOT Java_FOUND)
|
||||
message(WARNING "JDK not found, skipping Java projects")
|
||||
return()
|
||||
endif()
|
||||
add_library(${FILAMAT_FLAVOR} STATIC IMPORTED)
|
||||
set_target_properties(${FILAMAT_FLAVOR} PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/lib${FILAMAT_FLAVOR}.a)
|
||||
|
||||
# Android already has the JNI headers in its system include path.
|
||||
if (NOT ANDROID)
|
||||
find_package(JNI)
|
||||
if (NOT JNI_FOUND)
|
||||
message(WARNING "JNI not found, skipping Java projects")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
add_library(utils STATIC IMPORTED)
|
||||
set_target_properties(utils PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libutils.a)
|
||||
|
||||
if (NOT DEFINED ENV{JAVA_HOME})
|
||||
message(WARNING "The JAVA_HOME environment variable must be set to compile Java projects")
|
||||
message(WARNING "Skipping Java projects")
|
||||
return()
|
||||
endif()
|
||||
add_library(filabridge STATIC IMPORTED)
|
||||
set_target_properties(filabridge PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilabridge.a)
|
||||
|
||||
# ==================================================================================================
|
||||
# JNI bindings
|
||||
# ==================================================================================================
|
||||
set(TARGET filamat-jni)
|
||||
add_library(smol-v STATIC IMPORTED)
|
||||
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
|
||||
|
||||
set(JNI_SOURCE_FILES
|
||||
src/main/cpp/MaterialBuilder.cpp)
|
||||
add_library(shaders STATIC IMPORTED)
|
||||
set_target_properties(shaders PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libshaders.a)
|
||||
|
||||
add_library(${TARGET} SHARED ${JNI_SOURCE_FILES})
|
||||
include_directories(${FILAMENT_DIR}/include)
|
||||
|
||||
target_include_directories(${TARGET} PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
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(EXPORTED_SYMBOLS)
|
||||
if (APPLE)
|
||||
set(EXPORTED_SYMBOLS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/libfilamat-jni.symbols")
|
||||
elseif (ANDROID)
|
||||
set(EXPORTED_SYMBOLS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libfilamat-jni.map")
|
||||
endif()
|
||||
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")
|
||||
|
||||
# This is necessary to avoid a CMake error due to setting RPATH on non-elf platforms.
|
||||
# Setting this also causes CMake to issue a warning on Mac:
|
||||
# "Policy CMP0068 is not set: RPATH settings on macOS do not affect install_name." which can be
|
||||
# safely ignored.
|
||||
set(CMAKE_SKIP_RPATH TRUE)
|
||||
|
||||
set_target_properties(${TARGET} PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
COMPILE_FLAGS "-fno-exceptions -fvisibility=hidden"
|
||||
LINK_FLAGS "${GC_SECTIONS} ${EXPORTED_SYMBOLS}")
|
||||
|
||||
target_compile_options(${TARGET} PRIVATE
|
||||
$<$<PLATFORM_ID:Linux>:-fPIC>
|
||||
add_library(filamat-jni SHARED
|
||||
src/main/cpp/MaterialBuilder.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${TARGET} filamat)
|
||||
target_link_libraries(filamat-jni
|
||||
${FILAMAT_FLAVOR}
|
||||
filabridge
|
||||
shaders
|
||||
utils
|
||||
log
|
||||
smol-v
|
||||
)
|
||||
|
||||
set(INSTALL_TYPE LIBRARY)
|
||||
if (WIN32 OR CYGWIN)
|
||||
set(INSTALL_TYPE RUNTIME)
|
||||
endif()
|
||||
install(TARGETS ${TARGET} ${INSTALL_TYPE} DESTINATION lib/${DIST_DIR})
|
||||
install(CODE "execute_process(COMMAND ${CMAKE_STRIP} -x ${CMAKE_INSTALL_PREFIX}/lib/${DIST_DIR}/lib${TARGET}${CMAKE_SHARED_LIBRARY_SUFFIX})")
|
||||
|
||||
# ==================================================================================================
|
||||
# Java APIs
|
||||
# ==================================================================================================
|
||||
|
||||
# Android builds its Java bindings for filamat through Gradle.
|
||||
if (ANDROID)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(TARGET filamat-java)
|
||||
|
||||
include(UseJava)
|
||||
|
||||
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.8" "-target" "1.8")
|
||||
|
||||
set(JAVA_SOURCE_FILES
|
||||
src/main/java/com/google/android/filament/filamat/MaterialBuilder.java
|
||||
src/main/java/com/google/android/filament/filamat/MaterialPackage.java)
|
||||
|
||||
add_jar(${TARGET}
|
||||
SOURCES ${JAVA_SOURCE_FILES}
|
||||
INCLUDE_JARS ../../java/lib/support-annotations.jar)
|
||||
|
||||
install_jar(${TARGET} lib)
|
||||
|
||||
@@ -13,7 +13,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ allprojects {
|
||||
}
|
||||
|
||||
group = "com.google.android.filament"
|
||||
version = "0.1"
|
||||
version = "1.3"
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
@@ -35,14 +35,27 @@ if (project.hasProperty("filament_dist_dir")) {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
compileSdkVersion 29
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-19")
|
||||
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 {
|
||||
@@ -52,17 +65,33 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jniLibs.srcDirs "${filament_path}/lib"
|
||||
flavorDimensions "functionality"
|
||||
productFlavors {
|
||||
full {
|
||||
dimension "functionality"
|
||||
}
|
||||
|
||||
lite {
|
||||
dimension "functionality"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DFILAMAT_LITE=ON")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that only the libfilamat-jni.so library is included in the AAR, in case any other
|
||||
// libraries happen to be present.
|
||||
packagingOptions {
|
||||
exclude '**/*.so'
|
||||
merge '**/libfilamat-jni.so'
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@@ -75,4 +104,3 @@ dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:support-annotations:28.0.0'
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
2
android/filamat-android/gradlew
vendored
2
android/filamat-android/gradlew
vendored
@@ -28,7 +28,7 @@ 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=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
2
android/filamat-android/gradlew.bat
vendored
2
android/filamat-android/gradlew.bat
vendored
@@ -14,7 +14,7 @@ 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=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -18,33 +18,40 @@
|
||||
|
||||
#include <filamat/MaterialBuilder.h>
|
||||
|
||||
#include <filament/EngineEnums.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 *env,
|
||||
jclass type) {
|
||||
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 *env,
|
||||
jclass type, jlong nativeBuilder) {
|
||||
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* env, jclass type,
|
||||
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 type,
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nGetPackageBytes(JNIEnv* env, jclass,
|
||||
jlong nativePackage) {
|
||||
auto package = (Package*) nativePackage;
|
||||
auto size = jsize(package->getSize());
|
||||
@@ -55,14 +62,14 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nGetPackageBytes(JNIEnv
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nGetPackageIsValid(JNIEnv* env,
|
||||
jclass type, jlong nativePackage) {
|
||||
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* env, jclass type,
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nDestroyPackage(JNIEnv*, jclass,
|
||||
jlong nativePackage) {
|
||||
Package* package = (Package*) nativePackage;
|
||||
delete package;
|
||||
@@ -70,29 +77,71 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nDestroyPackage(JNIEnv*
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderName(JNIEnv* env,
|
||||
jclass type, jlong nativeBuilder, jstring name_) {
|
||||
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* env,
|
||||
jclass type, jlong nativeBuilder, jint shading) {
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderShading(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jint shading) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->shading((Shading) shading);
|
||||
builder->shading((MaterialBuilder::Shading) shading);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderRequire(JNIEnv* env,
|
||||
jclass type, jlong nativeBuilder, jint attribute) {
|
||||
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 type, jlong nativeBuilder, jstring code_) {
|
||||
jclass, jlong nativeBuilder, jstring code_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* code = env->GetStringUTFChars(code_, nullptr);
|
||||
builder->material(code);
|
||||
@@ -100,22 +149,162 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMateria
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMaterialVertex(JNIEnv* env,
|
||||
jclass type, jlong nativeBuilder, jstring code_) {
|
||||
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_nMaterialBuilderColorWrite(JNIEnv* env,
|
||||
jclass type, jlong nativeBuilder, jboolean enable) {
|
||||
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_nMaterialBuilderPlatform(JNIEnv* env,
|
||||
jclass type, jlong nativeBuilder, jint platform) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,71 @@ public class MaterialBuilder {
|
||||
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)
|
||||
@@ -33,14 +98,52 @@ public class MaterialBuilder {
|
||||
UV0, // texture coordinates (float2)
|
||||
UV1, // texture coordinates (float2)
|
||||
BONE_INDICES, // indices of 4 bones (uvec4)
|
||||
BONE_WEIGHTS // weights of the 4 bones (normalized float4)
|
||||
BONE_WEIGHTS, // weights of the 4 bones (normalized float4)
|
||||
UNUSED, // reserved for future use
|
||||
CUSTOM0, // custom or MORPH_POSITION_0
|
||||
CUSTOM1, // custom or MORPH_POSITION_1
|
||||
CUSTOM2, // custom or MORPH_POSITION_2
|
||||
CUSTOM3, // custom or MORPH_POSITION_3
|
||||
CUSTOM4, // custom or MORPH_TANGENTS_0
|
||||
CUSTOM5, // custom or MORPH_TANGENTS_1
|
||||
CUSTOM6, // custom or MORPH_TANGENTS_2
|
||||
CUSTOM7 // custom or MORPH_TANGENTS_3
|
||||
}
|
||||
|
||||
public enum Shading {
|
||||
UNLIT, // no lighting applied, emissive possible
|
||||
LIT, // default, standard lighting
|
||||
SUBSURFACE, // subsurface lighting model
|
||||
CLOTH // cloth lighting model
|
||||
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 {
|
||||
@@ -49,6 +152,34 @@ public class MaterialBuilder {
|
||||
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);
|
||||
@@ -66,6 +197,38 @@ public class MaterialBuilder {
|
||||
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());
|
||||
@@ -84,18 +247,138 @@ public class MaterialBuilder {
|
||||
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);
|
||||
@@ -124,6 +407,9 @@ public class MaterialBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static native void nMaterialBuilderInit();
|
||||
private static native void nMaterialBuilderShutdown();
|
||||
|
||||
private static native long nCreateMaterialBuilder();
|
||||
private static native void nDestroyMaterialBuilder(long nativeBuilder);
|
||||
|
||||
@@ -134,9 +420,47 @@ public class MaterialBuilder {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
1
android/filament-android/.gitignore
vendored
1
android/filament-android/.gitignore
vendored
@@ -9,3 +9,4 @@
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
/.cxx
|
||||
Binary file not shown.
134
android/filament-android/.idea/codeStyles/Project.xml
generated
134
android/filament-android/.idea/codeStyles/Project.xml
generated
@@ -1,29 +1,113 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<Objective-C-extensions>
|
||||
<file>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||
</file>
|
||||
<class>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||
</class>
|
||||
<extensions>
|
||||
<pair source="cpp" header="h" fileNamingConvention="NONE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
</extensions>
|
||||
</Objective-C-extensions>
|
||||
<codeStyleSettings language="XML">
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
@@ -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,7 +39,7 @@ 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-stack-protector")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
|
||||
@@ -55,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
|
||||
@@ -65,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.3.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ allprojects {
|
||||
}
|
||||
|
||||
group = "com.google.android.filament"
|
||||
version = "0.1"
|
||||
version = "1.3"
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
@@ -35,13 +35,13 @@ if (project.hasProperty("filament_dist_dir")) {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
compileSdkVersion 29
|
||||
defaultConfig {
|
||||
// Our minSdkVersion is actually 21, we lie and say 14 here so apps don't have
|
||||
// Our minSdkVersion is actually 19, 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.
|
||||
// ensure they do not initialize Filament on API levels < 19.
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@@ -50,7 +50,7 @@ android {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-21")
|
||||
arguments.add("-DANDROID_PLATFORM=android-19")
|
||||
arguments.add("-DANDROID_STL=c++_static")
|
||||
arguments.add("-DFILAMENT_DIST_DIR=${filament_path}".toString())
|
||||
cppFlags.add("-std=c++14")
|
||||
@@ -77,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 @@
|
||||
#Mon Jan 14 11:04:36 PST 2019
|
||||
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.10.1-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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
@@ -147,9 +154,9 @@ Java_com_google_android_filament_Engine_nDestroyScene(JNIEnv*, jclass,
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Engine_nCreateFence(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jint fenceType) {
|
||||
jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) engine->createFence((Fence::Type) fenceType);
|
||||
return (jlong) engine->createFence();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -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,43 @@ 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);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetCullingMode(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jlong cullingMode) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setCullingMode((MaterialInstance::CullingMode) cullingMode);
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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,16 +23,16 @@
|
||||
#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) {
|
||||
@@ -107,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
|
||||
@@ -163,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,
|
||||
@@ -183,7 +177,7 @@ Java_com_google_android_filament_Texture_nSetImage(JNIEnv* env, jclass, jlong na
|
||||
(Texture::Type) type, (size_t) stride, (size_t) alignment);
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (remaining << nioBuffer.getShift())) {
|
||||
if (sizeInBytes > (size_t(remaining) << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
@@ -191,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,
|
||||
@@ -205,8 +199,7 @@ extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImageCompressed(JNIEnv *env, jclass,
|
||||
jlong nativeTexture, jlong nativeEngine, jint level, jint xoffset, jint yoffset,
|
||||
jint width, jint height, jobject storage, jint remaining,
|
||||
jint left, jint bottom, jint type, jint alignment,
|
||||
jint compressedSizeInBytes, jint compressedFormat,
|
||||
jint, jint, jint, jint, jint compressedSizeInBytes, jint compressedFormat,
|
||||
jobject handler, jobject runnable) {
|
||||
Texture *texture = (Texture *) nativeTexture;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
@@ -214,7 +207,7 @@ Java_com_google_android_filament_Texture_nSetImageCompressed(JNIEnv *env, jclass
|
||||
size_t sizeInBytes = (size_t) compressedSizeInBytes;
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (remaining << nioBuffer.getShift())) {
|
||||
if (sizeInBytes > (size_t(remaining) << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
@@ -223,7 +216,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,
|
||||
@@ -241,7 +234,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemap(JNIEnv *env, jclass,
|
||||
Texture *texture = (Texture *) nativeTexture;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
|
||||
jint *faceOffsetsInBytes = env->GetIntArrayElements(faceOffsetsInBytes_, NULL);
|
||||
jint *faceOffsetsInBytes = env->GetIntArrayElements(faceOffsetsInBytes_, nullptr);
|
||||
Texture::FaceOffsets faceOffsets;
|
||||
std::copy_n(faceOffsetsInBytes, 6, faceOffsets.offsets);
|
||||
env->ReleaseIntArrayElements(faceOffsetsInBytes_, faceOffsetsInBytes, JNI_ABORT);
|
||||
@@ -250,7 +243,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemap(JNIEnv *env, jclass,
|
||||
(Texture::Type) type, (size_t) stride, (size_t) alignment);
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (remaining << nioBuffer.getShift())) {
|
||||
if (sizeInBytes > (size_t(remaining) << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
@@ -258,8 +251,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);
|
||||
@@ -277,7 +270,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemapCompressed(JNIEnv *env,
|
||||
Texture *texture = (Texture *) nativeTexture;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
|
||||
jint *faceOffsetsInBytes = env->GetIntArrayElements(faceOffsetsInBytes_, NULL);
|
||||
jint *faceOffsetsInBytes = env->GetIntArrayElements(faceOffsetsInBytes_, nullptr);
|
||||
Texture::FaceOffsets faceOffsets;
|
||||
std::copy_n(faceOffsetsInBytes, 6, faceOffsets.offsets);
|
||||
env->ReleaseIntArrayElements(faceOffsetsInBytes_, faceOffsetsInBytes, JNI_ABORT);
|
||||
@@ -285,7 +278,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemapCompressed(JNIEnv *env,
|
||||
size_t sizeInBytes = 6 * (size_t) compressedSizeInBytes;
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (remaining << nioBuffer.getShift())) {
|
||||
if (sizeInBytes > (size_t(remaining) << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
@@ -294,7 +287,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);
|
||||
@@ -335,6 +328,49 @@ 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_, nullptr);
|
||||
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 > (size_t(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) left, (uint32_t) top, (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) {
|
||||
@@ -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);
|
||||
}
|
||||
@@ -191,3 +226,23 @@ Java_com_google_android_filament_View_nIsFrontFaceWindingInverted(JNIEnv*,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,10 @@ package com.google.android.filament;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.opengl.EGL14;
|
||||
import android.opengl.EGLContext;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
final class AndroidPlatform extends Platform {
|
||||
private static final String LOG_TAG = "Filament";
|
||||
@@ -59,6 +61,20 @@ final class AndroidPlatform extends Platform {
|
||||
|
||||
@Override
|
||||
long getSharedContextNativeHandle(Object sharedContext) {
|
||||
return ((EGLContext) sharedContext).getNativeHandle();
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return AndroidPlatform21.getSharedContextNativeHandle(sharedContext);
|
||||
} else {
|
||||
try {
|
||||
//noinspection JavaReflectionMemberAccess
|
||||
Method method = EGLContext.class.getDeclaredMethod("getHandle");
|
||||
Integer handle = (Integer) method.invoke(sharedContext);
|
||||
//noinspection ConstantConditions
|
||||
return handle.longValue();
|
||||
} catch (Exception e) {
|
||||
Log.d(LOG_TAG, "Could not access shared context's native handle", e);
|
||||
}
|
||||
// Should not happen
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.opengl.EGLContext;
|
||||
|
||||
final class AndroidPlatform21 {
|
||||
static long getSharedContextNativeHandle(Object sharedContext) {
|
||||
return ((EGLContext) sharedContext).getNativeHandle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.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;
|
||||
}
|
||||
}
|
||||
@@ -157,26 +157,30 @@ public class Camera {
|
||||
* @param projection type of projection to use
|
||||
*
|
||||
* @param left distance in world units from the camera to the left plane,
|
||||
* at the near plane. Precondition: left != right.
|
||||
* at the near plane. Precondition: <code>left</code> != <code>right</code>
|
||||
*
|
||||
* @param right distance in world units from the camera to the right plane,
|
||||
* at the near plane. Precondition: left != right.
|
||||
* at the near plane. Precondition: <code>left</code> != <code>right</code>
|
||||
*
|
||||
* @param bottom distance in world units from the camera to the bottom plane,
|
||||
* at the near plane. Precondition: bottom != top.
|
||||
* at the near plane. Precondition: <code>bottom</code> != <code>top</code>
|
||||
*
|
||||
* @param top distance in world units from the camera to the top plane,
|
||||
* at the near plane. Precondition: left != right.
|
||||
* at the near plane. Precondition: <code>bottom</code> != <code>top</code>
|
||||
*
|
||||
* @param near distance in world units from the camera to the near plane.
|
||||
* The near plane's position in view space is z = -near.
|
||||
* Precondition: near > 0 for {@link Projection#PERSPECTIVE} or
|
||||
* near != far for {@link Projection#ORTHO}.
|
||||
* The near plane's position in view space is z = -<code>near</code>.
|
||||
* Precondition:
|
||||
* <code>near</code> > 0 for {@link Projection#PERSPECTIVE} or
|
||||
* <code>near</code> != <code>far</code> for {@link Projection#ORTHO}.
|
||||
*
|
||||
* @param far distance in world units from the camera to the far plane.
|
||||
* The far plane's position in view space is z = -far.
|
||||
* Precondition: far > near for {@link Projection#PERSPECTIVE} or
|
||||
* far != near for {@link Projection#ORTHO}.
|
||||
* The far plane's position in view space is z = -<code>far</code>.
|
||||
* Precondition:
|
||||
* <code>far</code> > <code>near</code>
|
||||
* for {@link Projection#PERSPECTIVE} or
|
||||
* <code>far</code> != <code>near</code>
|
||||
* for {@link Projection#ORTHO}.
|
||||
*
|
||||
* <p>
|
||||
* These parameters are silently modified to meet the preconditions above.
|
||||
@@ -189,12 +193,32 @@ public class Camera {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the projection matrix from the field-of-view.
|
||||
*
|
||||
* @param fovInDegrees
|
||||
* @param aspect
|
||||
* @param near
|
||||
* @param far
|
||||
* @param direction
|
||||
* @param fovInDegrees field-of-view in degrees from the camera center axis.
|
||||
* 0 < <code>fovInDegrees</code> < 180
|
||||
*
|
||||
* @param aspect aspect ratio width/height. <code>aspect</code> > 0
|
||||
*
|
||||
* @param near distance in world units from the camera to the near plane.
|
||||
* The near plane's position in view space is z = -<code>near</code>.
|
||||
* Precondition:
|
||||
* <code>near</code> > 0 for {@link Projection#PERSPECTIVE} or
|
||||
* <code>near</code> != <code>far</code> for {@link Projection#ORTHO}.
|
||||
*
|
||||
* @param far distance in world units from the camera to the far plane.
|
||||
* The far plane's position in view space is z = -<code>far</code>.
|
||||
* Precondition:
|
||||
* <code>far</code> > <code>near</code>
|
||||
* for {@link Projection#PERSPECTIVE} or
|
||||
* <code>far</code> != <code>near</code>
|
||||
* for {@link Projection#ORTHO}.
|
||||
*
|
||||
* @param direction direction of the field-of-view parameter.
|
||||
* <p>
|
||||
* These parameters are silently modified to meet the preconditions above.
|
||||
*
|
||||
* @see Fov
|
||||
*/
|
||||
public void setProjection(double fovInDegrees, double aspect, double near, double far,
|
||||
@NonNull Fov direction) {
|
||||
@@ -202,47 +226,86 @@ public class Camera {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the projection matrix from the focal length
|
||||
*
|
||||
* @param focalLength lense's focal length in millimeters. <code>focalLength</code> > 0
|
||||
*
|
||||
* @param near distance in world units from the camera to the near plane.
|
||||
* The near plane's position in view space is z = -<code>near</code>.
|
||||
* Precondition:
|
||||
* <code>near</code> > 0 for {@link Projection#PERSPECTIVE} or
|
||||
* <code>near</code> != <code>far</code> for {@link Projection#ORTHO}.
|
||||
*
|
||||
* @param far distance in world units from the camera to the far plane.
|
||||
* The far plane's position in view space is z = -<code>far</code>.
|
||||
* Precondition:
|
||||
* <code>far</code> > <code>near</code>
|
||||
* for {@link Projection#PERSPECTIVE} or
|
||||
* <code>far</code> != <code>near</code>
|
||||
* for {@link Projection#ORTHO}.
|
||||
*
|
||||
* @param focalLength
|
||||
* @param near
|
||||
* @param far
|
||||
*/
|
||||
public void setLensProjection(double focalLength, double near, double far) {
|
||||
nSetLensProjection(getNativeObject(), focalLength, near, far);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the projection matrix.
|
||||
*
|
||||
* @param inMatrix
|
||||
* @param near
|
||||
* @param far
|
||||
* @param inMatrix custom projection matrix.
|
||||
*
|
||||
* @param near distance in world units from the camera to the near plane.
|
||||
* The near plane's position in view space is z = -<code>near</code>.
|
||||
* Precondition:
|
||||
* <code>near</code> > 0 for {@link Projection#PERSPECTIVE} or
|
||||
* <code>near</code> != <code>far</code> for {@link Projection#ORTHO}.
|
||||
*
|
||||
* @param far distance in world units from the camera to the far plane.
|
||||
* The far plane's position in view space is z = -<code>far</code>.
|
||||
* Precondition:
|
||||
* <code>far</code> > <code>near</code>
|
||||
* for {@link Projection#PERSPECTIVE} or
|
||||
* <code>far</code> != <code>near</code>
|
||||
* for {@link Projection#ORTHO}.
|
||||
*/
|
||||
public void setCustomProjection(@NonNull @Size(min = 16) double inMatrix[],
|
||||
public void setCustomProjection(@NonNull @Size(min = 16) double[] inMatrix,
|
||||
double near, double far) {
|
||||
assertMat4dIn(inMatrix);
|
||||
Asserts.assertMat4dIn(inMatrix);
|
||||
nSetCustomProjection(getNativeObject(), inMatrix, near, far);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's view matrix.
|
||||
* <p>
|
||||
* Helper method to set the camera's entity transform component.
|
||||
* Remember that the Camera "looks" towards its -z axis.
|
||||
* <p>
|
||||
* This has the same effect as calling:
|
||||
*
|
||||
* @param in
|
||||
* <pre>
|
||||
* engine.getTransformManager().setTransform(
|
||||
* engine.getTransformManager().getInstance(camera->getEntity()), viewMatrix);
|
||||
* </pre>
|
||||
*
|
||||
* @param viewMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
*/
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) float in[]) {
|
||||
assertMat4fIn(in);
|
||||
nSetModelMatrix(getNativeObject(), in);
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) float[] viewMatrix) {
|
||||
Asserts.assertMat4fIn(viewMatrix);
|
||||
nSetModelMatrix(getNativeObject(), viewMatrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's view matrix.
|
||||
*
|
||||
* @param eyeX
|
||||
* @param eyeY
|
||||
* @param eyeZ
|
||||
* @param centerX
|
||||
* @param centerY
|
||||
* @param centerZ
|
||||
* @param upX
|
||||
* @param upY
|
||||
* @param upZ
|
||||
* @param eyeX x-axis position of the camera in world space
|
||||
* @param eyeY y-axis position of the camera in world space
|
||||
* @param eyeZ z-axis position of the camera in world space
|
||||
* @param centerX x-axis position of the point in world space the camera is looking at
|
||||
* @param centerY y-axis position of the point in world space the camera is looking at
|
||||
* @param centerZ z-axis position of the point in world space the camera is looking at
|
||||
* @param upX x-axis coordinate of a unit vector denoting the camera's "up" direction
|
||||
* @param upY y-axis coordinate of a unit vector denoting the camera's "up" direction
|
||||
* @param upZ z-axis coordinate of a unit vector denoting the camera's "up" direction
|
||||
*/
|
||||
public void lookAt(double eyeX, double eyeY, double eyeZ,
|
||||
double centerX, double centerY, double centerZ, double upX, double upY, double upZ) {
|
||||
@@ -250,16 +313,14 @@ public class Camera {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Distance to the near plane.
|
||||
* @return Distance to the near plane
|
||||
*/
|
||||
public float getNear() {
|
||||
return nGetNear(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Distance to the far plane.
|
||||
* @return Distance to the far plane
|
||||
*/
|
||||
public float getCullingFar() {
|
||||
return nGetCullingFar(getNativeObject());
|
||||
@@ -267,13 +328,15 @@ public class Camera {
|
||||
|
||||
/**
|
||||
* Retrieves the camera's projection matrix.
|
||||
*
|
||||
* @param out A 16-float array where the projection matrix will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
*
|
||||
* @return A 16-float array containing the camera's projection as a column-major matrix.
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public double[] getProjectionMatrix(@Nullable @Size(min = 16) double out[]) {
|
||||
out = assertMat4d(out);
|
||||
public double[] getProjectionMatrix(@Nullable @Size(min = 16) double[] out) {
|
||||
out = Asserts.assertMat4d(out);
|
||||
nGetProjectionMatrix(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -281,13 +344,15 @@ public class Camera {
|
||||
/**
|
||||
* Retrieves the camera's model matrix. The model matrix encodes the camera position and
|
||||
* orientation, or pose.
|
||||
*
|
||||
* @param out A 16-float array where the model matrix will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
*
|
||||
* @return A 16-float array containing the camera's pose as a column-major matrix.
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public float[] getModelMatrix(@Nullable @Size(min = 16) float out[]) {
|
||||
out = assertMat4f(out);
|
||||
public float[] getModelMatrix(@Nullable @Size(min = 16) float[] out) {
|
||||
out = Asserts.assertMat4f(out);
|
||||
nGetModelMatrix(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -297,24 +362,27 @@ public class Camera {
|
||||
*
|
||||
* @param out A 16-float array where the model view will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
*
|
||||
* @return A 16-float array containing the camera's view as a column-major matrix.
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public float[] getViewMatrix(@Nullable @Size(min = 16) float out[]) {
|
||||
out = assertMat4f(out);
|
||||
public float[] getViewMatrix(@Nullable @Size(min = 16) float[] out) {
|
||||
out = Asserts.assertMat4f(out);
|
||||
nGetViewMatrix(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the camera position in world space.
|
||||
*
|
||||
* @param out A 3-float array where the position will be stored, or null in which case a new
|
||||
* array is allocated.
|
||||
*
|
||||
* @return A 3-float array containing the camera's position in world units.
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getPosition(@Nullable @Size(min = 3) float out[]) {
|
||||
out = assertFloat3(out);
|
||||
public float[] getPosition(@Nullable @Size(min = 3) float[] out) {
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetPosition(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -322,13 +390,15 @@ public class Camera {
|
||||
/**
|
||||
* Retrieves the camera left unit vector in world space, that is a unit vector that points to
|
||||
* the left of the camera.
|
||||
*
|
||||
* @param out A 3-float array where the left vector will be stored, or null in which case a new
|
||||
* array is allocated.
|
||||
*
|
||||
* @return A 3-float array containing the camera's left vector in world units.
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getLeftVector(@Nullable @Size(min = 3) float out[]) {
|
||||
out = assertFloat3(out);
|
||||
public float[] getLeftVector(@Nullable @Size(min = 3) float[] out) {
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetLeftVector(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -336,13 +406,15 @@ public class Camera {
|
||||
/**
|
||||
* Retrieves the camera up unit vector in world space, that is a unit vector that points up with
|
||||
* respect to the camera.
|
||||
*
|
||||
* @param out A 3-float array where the up vector will be stored, or null in which case a new
|
||||
* array is allocated.
|
||||
*
|
||||
* @return A 3-float array containing the camera's up vector in world units.
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getUpVector(@Nullable @Size(min = 3) float out[]) {
|
||||
out = assertFloat3(out);
|
||||
public float[] getUpVector(@Nullable @Size(min = 3) float[] out) {
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetUpVector(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
@@ -350,52 +422,91 @@ public class Camera {
|
||||
/**
|
||||
* Retrieves the camera forward unit vector in world space, that is a unit vector that points
|
||||
* in the direction the camera is looking at.
|
||||
*
|
||||
* @param out A 3-float array where the forward vector will be stored, or null in which case a
|
||||
* new array is allocated.
|
||||
*
|
||||
* @return A 3-float array containing the camera's forward vector in world units.
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] getForwardVector(@Nullable @Size(min = 3) float out[]) {
|
||||
out = assertFloat3(out);
|
||||
public float[] getForwardVector(@Nullable @Size(min = 3) float[] out) {
|
||||
out = Asserts.assertFloat3(out);
|
||||
nGetForwardVector(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this camera's exposure (default is f/16, 1/125s, 100 ISO)
|
||||
*
|
||||
* @param aperture
|
||||
* @param shutterSpeed
|
||||
* @param sensitivity
|
||||
* The exposure ultimately controls the scene's brightness, just like with a real camera.
|
||||
* The default values provide adequate exposure for a camera placed outdoors on a sunny day
|
||||
* with the sun at the zenith.
|
||||
*
|
||||
* With the default parameters, the scene must contain at least one Light of intensity
|
||||
* similar to the sun (e.g.: a 100,000 lux directional light) and/or an indirect light
|
||||
* of appropriate intensity (30,000).
|
||||
*
|
||||
* @param aperture Aperture in f-stops, clamped between 0.5 and 64.
|
||||
* A lower aperture value increases the exposure, leading to
|
||||
* a brighter scene. Realistic values are between 0.95 and 32.
|
||||
*
|
||||
* @param shutterSpeed Shutter speed in seconds, clamped between 1/25,000 and 60.
|
||||
* A lower shutter speed increases the exposure. Realistic values are
|
||||
* between 1/8000 and 30.
|
||||
*
|
||||
* @param sensitivity Sensitivity in ISO, clamped between 10 and 204,800.
|
||||
* A higher sensitivity increases the exposure. Realistic values are
|
||||
* between 50 and 25600.
|
||||
*
|
||||
* @see LightManager
|
||||
* @see Exposure
|
||||
* @see #setExposure(float)
|
||||
*/
|
||||
public void setExposure(float aperture, float shutterSpeed, float sensitivity) {
|
||||
nSetExposure(getNativeObject(), aperture, shutterSpeed, sensitivity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this camera's exposure directly. Calling this method will set the aperture
|
||||
* to 1.0, the shutter speed to 1.2 and the sensitivity will be computed to match
|
||||
* the requested exposure (for a desired exposure of 1.0, the sensitivity will be
|
||||
* set to 100 ISO).
|
||||
*
|
||||
* @return
|
||||
* This method is useful when trying to match the lighting of other engines or tools.
|
||||
* Many engines/tools use unit-less light intensities, which can be matched by setting
|
||||
* the exposure manually. This can be typically achieved by setting the exposure to
|
||||
* 1.0.
|
||||
*
|
||||
* @see Light
|
||||
* @see Exposure
|
||||
* @see #setExposure(float, float, float)
|
||||
*/
|
||||
public void setExposure(float exposure) {
|
||||
setExposure(1.0f, 1.2f, 100.0f * (1.0f / exposure));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Aperture in f-stops
|
||||
*/
|
||||
public float getAperture() {
|
||||
return nGetAperture(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @return Shutter speed in seconds
|
||||
*/
|
||||
public float getShutterSpeed() {
|
||||
return nGetShutterSpeed(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @return Sensitivity in ISO
|
||||
*/
|
||||
public float getSensitivity() {
|
||||
return nGetSensitivity(getNativeObject());
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Camera");
|
||||
}
|
||||
@@ -406,45 +517,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);
|
||||
|
||||
@@ -18,17 +18,118 @@ package com.google.android.filament;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
/**
|
||||
* Engine is filament's main entry-point.
|
||||
* <p>
|
||||
* An Engine instance main function is to keep track of all resources created by the user and
|
||||
* manage the rendering thread as well as the hardware renderer.
|
||||
* <p>
|
||||
* To use filament, an Engine instance must be created first:
|
||||
*
|
||||
* <pre>
|
||||
* import com.google.android.filament.*
|
||||
*
|
||||
* Engine engine = Engine.create();
|
||||
* </pre>
|
||||
* <p>
|
||||
* Engine essentially represents (or is associated to) a hardware context
|
||||
* (e.g. an OpenGL ES context).
|
||||
* <p>
|
||||
* Rendering typically happens in an operating system's window (which can be full screen), such
|
||||
* window is managed by a {@link Renderer}.
|
||||
* <p>
|
||||
* A typical filament render loop looks like this:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* import com.google.android.filament.*
|
||||
*
|
||||
* Engin engine = Engine.create();
|
||||
* SwapChain swapChain = engine.createSwapChain(nativeWindow);
|
||||
* Renderer renderer = engine.createRenderer();
|
||||
* Scene scene = engine.createScene();
|
||||
* View view = engine.createView();
|
||||
*
|
||||
* view.setScene(scene);
|
||||
*
|
||||
* do {
|
||||
* // typically we wait for VSYNC and user input events
|
||||
* if (renderer.beginFrame(swapChain)) {
|
||||
* renderer.render(view);
|
||||
* renderer.endFrame();
|
||||
* }
|
||||
* } while (!quit);
|
||||
*
|
||||
* engine.destroyView(view);
|
||||
* engine.destroyScene(scene);
|
||||
* engine.destroyRenderer(renderer);
|
||||
* engine.destroySwapChain(swapChain);
|
||||
* engine.destroy();
|
||||
* </pre>
|
||||
*
|
||||
* <h1><u>Resource Tracking</u></h1>
|
||||
* <p>
|
||||
* Each <code>Engine</code> instance keeps track of all objects created by the user, such as vertex
|
||||
* and index buffers, lights, cameras, etc...
|
||||
* The user is expected to free those resources, however, leaked resources are freed when the
|
||||
* engine instance is destroyed and a warning is emitted in the console.
|
||||
*
|
||||
* <h1><u>Thread safety</u></h1>
|
||||
* <p>
|
||||
* An <code>Engine</code> instance is not thread-safe. The implementation makes no attempt to
|
||||
* synchronize calls to an <code>Engine</code> instance methods.
|
||||
* If multi-threading is needed, synchronization must be external.
|
||||
*
|
||||
* <h1><u>Multi-threading</u></h1>
|
||||
* <p>
|
||||
* When created, the <code>Engine</code> instance starts a render thread as well as multiple worker
|
||||
* threads, these threads have an elevated priority appropriate for rendering, based on the
|
||||
* platform's best practices. The number of worker threads depends on the platform and is
|
||||
* automatically chosen for best performance.
|
||||
* <p>
|
||||
* On platforms with asymmetric cores (e.g. ARM's Big.Little), <code>Engine</code> makes some
|
||||
* educated guesses as to which cores to use for the render thread and worker threads. For example,
|
||||
* it'll try to keep an OpenGL ES thread on a Big core.
|
||||
*
|
||||
* <h1><u>Swap Chains</u></h1>
|
||||
* <p>
|
||||
* A swap chain represents an Operating System's <b>native</b> renderable surface.
|
||||
* Typically it's a window or a view. Because a {@link SwapChain} is initialized from a native
|
||||
* object, it is given to filament as an <code>Object</code>, which must be of the proper type for
|
||||
* each platform filament is running on.
|
||||
* <p>
|
||||
*
|
||||
* @see SwapChain
|
||||
* @see Renderer
|
||||
*/
|
||||
public class Engine {
|
||||
private long mNativeObject;
|
||||
@NonNull private final TransformManager mTransformManager;
|
||||
@NonNull private final LightManager mLightManager;
|
||||
@NonNull private final RenderableManager mRenderableManager;
|
||||
|
||||
/**
|
||||
* Denotes a backend
|
||||
*/
|
||||
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.
|
||||
/**
|
||||
* Automatically selects an appropriate driver for the platform.
|
||||
*/
|
||||
DEFAULT,
|
||||
/**
|
||||
* Selects the OpenGL ES driver.
|
||||
*/
|
||||
OPENGL,
|
||||
/**
|
||||
* Selects the experimental Vulkan driver.
|
||||
*/
|
||||
VULKAN,
|
||||
/**
|
||||
* Selects the no-op driver for testing purposes.
|
||||
*/
|
||||
NOOP,
|
||||
}
|
||||
|
||||
private Engine(long nativeEngine) {
|
||||
@@ -38,6 +139,19 @@ public class Engine {
|
||||
mRenderableManager = new RenderableManager(nGetRenderableManager(nativeEngine));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of Engine using the default {@link Backend}
|
||||
* <p>
|
||||
* This method is one of the few thread-safe methods.
|
||||
*
|
||||
* @return A newly created <code>Engine</code>, or <code>null</code> if the GPU driver couldn't
|
||||
* be initialized, for instance if it doesn't support the right version of OpenGL or
|
||||
* OpenGL ES.
|
||||
*
|
||||
* @exception IllegalStateException can be thrown if there isn't enough memory to
|
||||
* allocate the command buffer.
|
||||
*
|
||||
*/
|
||||
@NonNull
|
||||
public static Engine create() {
|
||||
long nativeEngine = nCreateEngine(0, 0);
|
||||
@@ -45,6 +159,21 @@ public class Engine {
|
||||
return new Engine(nativeEngine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of Engine using the specified {@link Backend}
|
||||
* <p>
|
||||
* This method is one of the few thread-safe methods.
|
||||
*
|
||||
* @param backend driver backend to use
|
||||
*
|
||||
* @return A newly created <code>Engine</code>, or <code>null</code> if the GPU driver couldn't
|
||||
* be initialized, for instance if it doesn't support the right version of OpenGL or
|
||||
* OpenGL ES.
|
||||
*
|
||||
* @exception IllegalStateException can be thrown if there isn't enough memory to
|
||||
* allocate the command buffer.
|
||||
*
|
||||
*/
|
||||
@NonNull
|
||||
public static Engine create(@NonNull Backend backend) {
|
||||
long nativeEngine = nCreateEngine(backend.ordinal(), 0);
|
||||
@@ -53,9 +182,21 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Valid shared context:
|
||||
* - Android: EGLContext
|
||||
* - Other: none
|
||||
* Creates an instance of Engine using the {@link Backend#OPENGL} and a shared OpenGL context.
|
||||
* <p>
|
||||
* This method is one of the few thread-safe methods.
|
||||
*
|
||||
* @param sharedContext A platform-dependant OpenGL context used as a shared context
|
||||
* when creating filament's internal context. On Android this parameter
|
||||
* <b>must be</b> an instance of {@link android.opengl.EGLContext}.
|
||||
*
|
||||
* @return A newly created <code>Engine</code>, or <code>null</code> if the GPU driver couldn't
|
||||
* be initialized, for instance if it doesn't support the right version of OpenGL or
|
||||
* OpenGL ES.
|
||||
*
|
||||
* @exception IllegalStateException can be thrown if there isn't enough memory to
|
||||
* allocate the command buffer.
|
||||
*
|
||||
*/
|
||||
@NonNull
|
||||
public static Engine create(@NonNull Object sharedContext) {
|
||||
@@ -68,37 +209,78 @@ public class Engine {
|
||||
throw new IllegalArgumentException("Invalid shared context " + sharedContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if this <code>Engine</code> is initialized properly.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return mNativeObject != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the <code>Engine</code> instance and all associated resources.
|
||||
* <p>
|
||||
* This method is one of the few thread-safe methods.
|
||||
* <p>
|
||||
* {@link Engine#destroy()} should be called last and after all other resources have been
|
||||
* destroyed, it ensures all filament resources are freed.
|
||||
* <p>
|
||||
* <code>Destroy</code> performs the following tasks:
|
||||
* <li>Destroy all internal software and hardware resources.</li>
|
||||
* <li>Free all user allocated resources that are not already destroyed and logs a warning.
|
||||
* <p>This indicates a "leak" in the user's code.</li>
|
||||
* <li>Terminate the rendering engine's thread.</li>
|
||||
*
|
||||
* <pre>
|
||||
* Engine engine = Engine.create();
|
||||
* engine.destroy();
|
||||
* </pre>
|
||||
*/
|
||||
public void destroy() {
|
||||
nDestroyEngine(getNativeObject());
|
||||
clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the backend used by this <code>Engine</code>
|
||||
*/
|
||||
@NonNull
|
||||
public Backend getBackend() {
|
||||
return Backend.values()[(int) nGetBackend(getNativeObject())];
|
||||
}
|
||||
|
||||
// SwapChain
|
||||
|
||||
/**
|
||||
* Valid surface types:
|
||||
* - Android: Surface
|
||||
* - Other: none
|
||||
* Creates an opaque {@link SwapChain} from the given OS native window handle.
|
||||
*
|
||||
* @param surface on Android, <b>must be</b> an instance of {@link android.view.Surface}
|
||||
*
|
||||
* @return a newly created {@link SwapChain} object
|
||||
*
|
||||
* @exception IllegalStateException can be thrown if the SwapChain couldn't be created
|
||||
*/
|
||||
@NonNull
|
||||
public SwapChain createSwapChain(@NonNull Object surface) {
|
||||
return createSwapChain(surface, SwapChain.CONFIG_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Valid surface types:
|
||||
* - Android: Surface
|
||||
* - Other: none
|
||||
* Creates a {@link SwapChain} from the given OS native window handle.
|
||||
*
|
||||
* Flags: see CONFIG flags in SwapChain.
|
||||
* @param surface on Android, <b>must be</b> an instance of {@link android.view.Surface}
|
||||
*
|
||||
* @param flags configuration flags, see {@link SwapChain}
|
||||
*
|
||||
* @return a newly created {@link SwapChain} object
|
||||
*
|
||||
* @exception IllegalStateException can be thrown if the SwapChain couldn't be created
|
||||
*
|
||||
* @see SwapChain#CONFIG_DEFAULT
|
||||
* @see SwapChain#CONFIG_TRANSPARENT
|
||||
* @see SwapChain#CONFIG_READABLE
|
||||
*
|
||||
*/
|
||||
@NonNull
|
||||
public SwapChain createSwapChain(@NonNull Object surface, long flags) {
|
||||
if (Platform.get().validateSurface(surface)) {
|
||||
long nativeSwapChain = nCreateSwapChain(getNativeObject(), surface, flags);
|
||||
@@ -108,6 +290,18 @@ public class Engine {
|
||||
throw new IllegalArgumentException("Invalid surface " + surface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link SwapChain} from a {@link NativeSurface}.
|
||||
*
|
||||
* @param surface a properly initialized {@link NativeSurface}
|
||||
*
|
||||
* @param flags configuration flags, see {@link SwapChain}
|
||||
*
|
||||
* @return a newly created {@link SwapChain} object
|
||||
*
|
||||
* @exception IllegalStateException can be thrown if the {@link SwapChain} couldn't be created
|
||||
*/
|
||||
@NonNull
|
||||
public SwapChain createSwapChainFromNativeSurface(@NonNull NativeSurface surface, long flags) {
|
||||
long nativeSwapChain =
|
||||
nCreateSwapChainFromRawPointer(getNativeObject(), surface.getNativeObject(), flags);
|
||||
@@ -115,6 +309,10 @@ public class Engine {
|
||||
return new SwapChain(nativeSwapChain, surface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link SwapChain} and frees all its associated resources.
|
||||
* @param swapChain the {@link SwapChain} to destroy
|
||||
*/
|
||||
public void destroySwapChain(@NonNull SwapChain swapChain) {
|
||||
nDestroySwapChain(getNativeObject(), swapChain.getNativeObject());
|
||||
swapChain.clearNativeObject();
|
||||
@@ -122,6 +320,11 @@ public class Engine {
|
||||
|
||||
// View
|
||||
|
||||
/**
|
||||
* Creates a {@link View}.
|
||||
* @return a newly created {@link View}
|
||||
* @exception IllegalStateException can be thrown if the {@link View} couldn't be created
|
||||
*/
|
||||
@NonNull
|
||||
public View createView() {
|
||||
long nativeView = nCreateView(getNativeObject());
|
||||
@@ -129,6 +332,10 @@ public class Engine {
|
||||
return new View(nativeView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link View} and frees all its associated resources.
|
||||
* @param view the {@link View} to destroy
|
||||
*/
|
||||
public void destroyView(@NonNull View view) {
|
||||
nDestroyView(getNativeObject(), view.getNativeObject());
|
||||
view.clearNativeObject();
|
||||
@@ -136,6 +343,11 @@ public class Engine {
|
||||
|
||||
// Renderer
|
||||
|
||||
/**
|
||||
* Creates a {@link Renderer}.
|
||||
* @return a newly created {@link Renderer}
|
||||
* @exception IllegalStateException can be thrown if the {@link Renderer} couldn't be created
|
||||
*/
|
||||
@NonNull
|
||||
public Renderer createRenderer() {
|
||||
long nativeRenderer = nCreateRenderer(getNativeObject());
|
||||
@@ -143,6 +355,10 @@ public class Engine {
|
||||
return new Renderer(this, nativeRenderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Renderer} and frees all its associated resources.
|
||||
* @param renderer the {@link Renderer} to destroy
|
||||
*/
|
||||
public void destroyRenderer(@NonNull Renderer renderer) {
|
||||
nDestroyRenderer(getNativeObject(), renderer.getNativeObject());
|
||||
renderer.clearNativeObject();
|
||||
@@ -150,6 +366,12 @@ public class Engine {
|
||||
|
||||
// Camera
|
||||
|
||||
/**
|
||||
* Creates a new <code>entity</code> and adds a {@link Camera} component to it.
|
||||
*
|
||||
* @return A newly created {@link Camera}
|
||||
* @exception IllegalStateException can be thrown if the {@link Camera} couldn't be created
|
||||
*/
|
||||
@NonNull
|
||||
public Camera createCamera() {
|
||||
long nativeCamera = nCreateCamera(getNativeObject());
|
||||
@@ -157,6 +379,13 @@ public class Engine {
|
||||
return new Camera(nativeCamera);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and adds a {@link Camera} component to a given <code>entity</code>.
|
||||
*
|
||||
* @param entity <code>entity</code> to add the camera component to
|
||||
* @return A newly created {@link Camera}
|
||||
* @exception IllegalStateException can be thrown if the {@link Camera} couldn't be created
|
||||
*/
|
||||
@NonNull
|
||||
public Camera createCamera(@Entity int entity) {
|
||||
long nativeCamera = nCreateCameraWithEntity(getNativeObject(), entity);
|
||||
@@ -164,6 +393,10 @@ public class Engine {
|
||||
return new Camera(nativeCamera);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Camera} component and frees all its associated resources.
|
||||
* @param camera the {@link Camera} to destroy
|
||||
*/
|
||||
public void destroyCamera(@NonNull Camera camera) {
|
||||
nDestroyCamera(getNativeObject(), camera.getNativeObject());
|
||||
camera.clearNativeObject();
|
||||
@@ -171,6 +404,11 @@ public class Engine {
|
||||
|
||||
// Scene
|
||||
|
||||
/**
|
||||
* Creates a {@link Scene}.
|
||||
* @return a newly created {@link Scene}
|
||||
* @exception IllegalStateException can be thrown if the {@link Scene} couldn't be created
|
||||
*/
|
||||
@NonNull
|
||||
public Scene createScene() {
|
||||
long nativeScene = nCreateScene(getNativeObject());
|
||||
@@ -178,6 +416,10 @@ public class Engine {
|
||||
return new Scene(nativeScene);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Scene} and frees all its associated resources.
|
||||
* @param scene the {@link Scene} to destroy
|
||||
*/
|
||||
public void destroyScene(@NonNull Scene scene) {
|
||||
nDestroyScene(getNativeObject(), scene.getNativeObject());
|
||||
scene.clearNativeObject();
|
||||
@@ -185,6 +427,10 @@ public class Engine {
|
||||
|
||||
// Stream
|
||||
|
||||
/**
|
||||
* Destroys a {@link Stream} and frees all its associated resources.
|
||||
* @param stream the {@link Stream} to destroy
|
||||
*/
|
||||
public void destroyStream(@NonNull Stream stream) {
|
||||
nDestroyStream(getNativeObject(), stream.getNativeObject());
|
||||
stream.clearNativeObject();
|
||||
@@ -192,13 +438,22 @@ public class Engine {
|
||||
|
||||
// Fence
|
||||
|
||||
/**
|
||||
* Creates a {@link Fence}.
|
||||
* @return a newly created {@link Fence}
|
||||
* @exception IllegalStateException can be thrown if the {@link Fence} couldn't be created
|
||||
*/
|
||||
@NonNull
|
||||
public Fence createFence(@NonNull Fence.Type type) {
|
||||
long nativeFence = nCreateFence(getNativeObject(), type.ordinal());
|
||||
public Fence createFence() {
|
||||
long nativeFence = nCreateFence(getNativeObject());
|
||||
if (nativeFence == 0) throw new IllegalStateException("Couldn't create Fence");
|
||||
return new Fence(nativeFence);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Fence} and frees all its associated resources.
|
||||
* @param fence the {@link Fence} to destroy
|
||||
*/
|
||||
public void destroyFence(@NonNull Fence fence) {
|
||||
nDestroyFence(getNativeObject(), fence.getNativeObject());
|
||||
fence.clearNativeObject();
|
||||
@@ -206,67 +461,134 @@ public class Engine {
|
||||
|
||||
// others...
|
||||
|
||||
/**
|
||||
* Destroys a {@link IndexBuffer} and frees all its associated resources.
|
||||
* @param indexBuffer the {@link IndexBuffer} to destroy
|
||||
*/
|
||||
public void destroyIndexBuffer(@NonNull IndexBuffer indexBuffer) {
|
||||
nDestroyIndexBuffer(getNativeObject(), indexBuffer.getNativeObject());
|
||||
indexBuffer.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link VertexBuffer} and frees all its associated resources.
|
||||
* @param vertexBuffer the {@link VertexBuffer} to destroy
|
||||
*/
|
||||
public void destroyVertexBuffer(@NonNull VertexBuffer vertexBuffer) {
|
||||
nDestroyVertexBuffer(getNativeObject(), vertexBuffer.getNativeObject());
|
||||
vertexBuffer.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link IndirectLight} and frees all its associated resources.
|
||||
* @param ibl the {@link IndirectLight} to destroy
|
||||
*/
|
||||
public void destroyIndirectLight(@NonNull IndirectLight ibl) {
|
||||
nDestroyIndirectLight(getNativeObject(), ibl.getNativeObject());
|
||||
ibl.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Material} and frees all its associated resources.
|
||||
* <p>
|
||||
* All {@link MaterialInstance} of the specified {@link Material} must be destroyed before
|
||||
* destroying it; if some {@link MaterialInstance} remain, this method fails silently.
|
||||
*
|
||||
* @param material the {@link Material} to destroy
|
||||
*/
|
||||
public void destroyMaterial(@NonNull Material material) {
|
||||
nDestroyMaterial(getNativeObject(), material.getNativeObject());
|
||||
material.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link MaterialInstance} and frees all its associated resources.
|
||||
* @param materialInstance the {@link MaterialInstance} to destroy
|
||||
*/
|
||||
public void destroyMaterialInstance(@NonNull MaterialInstance materialInstance) {
|
||||
nDestroyMaterialInstance(getNativeObject(), materialInstance.getNativeObject());
|
||||
materialInstance.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Skybox} and frees all its associated resources.
|
||||
* @param skybox the {@link Skybox} to destroy
|
||||
*/
|
||||
public void destroySkybox(@NonNull Skybox skybox) {
|
||||
nDestroySkybox(getNativeObject(), skybox.getNativeObject());
|
||||
skybox.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Texture} and frees all its associated resources.
|
||||
* @param texture the {@link Texture} to destroy
|
||||
*/
|
||||
public void destroyTexture(@NonNull Texture texture) {
|
||||
nDestroyTexture(getNativeObject(), texture.getNativeObject());
|
||||
texture.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link RenderTarget} and frees all its associated resources.
|
||||
* @param target the {@link RenderTarget} to destroy
|
||||
*/
|
||||
public void destroyRenderTarget(@NonNull RenderTarget target) {
|
||||
nDestroyRenderTarget(getNativeObject(), target.getNativeObject());
|
||||
target.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys an <code>entity</code> and all its components.
|
||||
* <p>
|
||||
* It is recommended to destroy components individually before destroying their
|
||||
* <code>entity</code>, this gives more control as to when the destruction really happens.
|
||||
* Otherwise, orphaned components are garbage collected, which can happen at a later time.
|
||||
* Even when component are garbage collected, the destruction of their <code>entity</code>
|
||||
* terminates their participation immediately.
|
||||
*
|
||||
* @param entity the <code>entity</code> to destroy
|
||||
*/
|
||||
public void destroyEntity(@Entity int entity) {
|
||||
nDestroyEntity(getNativeObject(), entity);
|
||||
}
|
||||
|
||||
// Managers
|
||||
|
||||
/**
|
||||
* @return the {@link TransformManager} used by this {@link Engine}
|
||||
*/
|
||||
@NonNull
|
||||
public TransformManager getTransformManager() {
|
||||
return mTransformManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link LightManager} used by this {@link Engine}
|
||||
*/
|
||||
@NonNull
|
||||
public LightManager getLightManager() {
|
||||
return mLightManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link RenderableManager} used by this {@link Engine}
|
||||
*/
|
||||
@NonNull
|
||||
public RenderableManager getRenderableManager() {
|
||||
return mRenderableManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicks the hardware thread (e.g.: the OpenGL, Vulkan or Metal thread) and blocks until
|
||||
* all commands to this point are executed. Note that this doesn't guarantee that the
|
||||
* hardware is actually finished.
|
||||
*/
|
||||
public void flushAndWait() {
|
||||
Fence.waitAndDestroy(createFence(Fence.Type.HARD), Fence.Mode.FLUSH);
|
||||
Fence.waitAndDestroy(createFence(), Fence.Mode.FLUSH);
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
@UsedByReflection("TextureHelper.java")
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Engine");
|
||||
}
|
||||
@@ -279,6 +601,7 @@ public class Engine {
|
||||
|
||||
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);
|
||||
@@ -291,7 +614,7 @@ public class Engine {
|
||||
private static native void nDestroyCamera(long nativeEngine, long nativeCamera);
|
||||
private static native long nCreateScene(long nativeEngine);
|
||||
private static native void nDestroyScene(long nativeEngine, long nativeScene);
|
||||
private static native long nCreateFence(long nativeEngine, int fenceType);
|
||||
private static native long nCreateFence(long nativeEngine);
|
||||
private static native void nDestroyFence(long nativeEngine, long nativeFence);
|
||||
private static native void nDestroyStream(long nativeEngine, long nativeStream);
|
||||
private static native void nDestroyIndexBuffer(long nativeEngine, long nativeIndexBuffer);
|
||||
@@ -301,6 +624,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);
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.google.android.filament;
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
public class EntityManager {
|
||||
private long mNativeObject = nGetEntityManager();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -26,11 +26,6 @@ public class Fence {
|
||||
|
||||
public static final long WAIT_FOR_EVER = -1;
|
||||
|
||||
public enum Type {
|
||||
SOFT,
|
||||
HARD
|
||||
}
|
||||
|
||||
public enum Mode {
|
||||
FLUSH,
|
||||
DONT_FLUSH
|
||||
@@ -70,7 +65,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;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,16 @@ 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;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ 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;
|
||||
import java.util.Collections;
|
||||
@@ -37,7 +39,8 @@ public class Material {
|
||||
UNLIT,
|
||||
LIT,
|
||||
SUBSURFACE,
|
||||
CLOTH
|
||||
CLOTH,
|
||||
SPECULAR_GLOSSINESS
|
||||
}
|
||||
|
||||
public enum Interpolation {
|
||||
@@ -68,6 +71,7 @@ public class Material {
|
||||
FRONT_AND_BACK
|
||||
}
|
||||
|
||||
@UsedByNative("Material.cpp")
|
||||
public static class Parameter {
|
||||
public enum Type {
|
||||
BOOL,
|
||||
@@ -100,8 +104,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 +125,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 +135,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 +156,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 +216,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 +339,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 +365,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,27 @@ 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 void setCullingMode(Material.CullingMode mode) {
|
||||
nSetCullingMode(getNativeObject(), mode.ordinal());
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed MaterialInstance");
|
||||
}
|
||||
@@ -210,5 +241,16 @@ 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);
|
||||
|
||||
private static native void nSetCullingMode(long nativeMaterialInstance, long mode);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ 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;
|
||||
import java.nio.CharBuffer;
|
||||
@@ -26,6 +28,7 @@ import java.nio.IntBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
@UsedByNative("NioUtils.cpp")
|
||||
final class NioUtils {
|
||||
|
||||
enum BufferType {
|
||||
@@ -41,18 +44,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,142 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
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.
|
||||
*/
|
||||
@@ -97,7 +104,7 @@ public class Renderer {
|
||||
nResetUserTime(getNativeObject());
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Renderer");
|
||||
}
|
||||
@@ -111,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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -19,10 +19,13 @@ package com.google.android.filament;
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SwapChain {
|
||||
return mSurface;
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed SwapChain");
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -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);
|
||||
|
||||
@@ -31,13 +31,22 @@ public class VertexBuffer {
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
BONE_WEIGHTS, // weights of the 4 bones (normalized float4)
|
||||
UNUSED, // reserved for future use
|
||||
CUSTOM0, // custom or MORPH_POSITION_0
|
||||
CUSTOM1, // custom or MORPH_POSITION_1
|
||||
CUSTOM2, // custom or MORPH_POSITION_2
|
||||
CUSTOM3, // custom or MORPH_POSITION_3
|
||||
CUSTOM4, // custom or MORPH_TANGENTS_0
|
||||
CUSTOM5, // custom or MORPH_TANGENTS_1
|
||||
CUSTOM6, // custom or MORPH_TANGENTS_2
|
||||
CUSTOM7 // custom or MORPH_TANGENTS_3
|
||||
}
|
||||
|
||||
public enum AttributeType {
|
||||
@@ -69,6 +78,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;
|
||||
@@ -172,7 +198,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");
|
||||
}
|
||||
@@ -197,4 +231,8 @@ public class VertexBuffer {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
import static com.google.android.filament.Colors.*;
|
||||
import static com.google.android.filament.Colors.LinearColor;
|
||||
|
||||
public class View {
|
||||
private long mNativeObject;
|
||||
@@ -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(),
|
||||
@@ -224,7 +276,29 @@ public class View {
|
||||
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");
|
||||
}
|
||||
@@ -235,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);
|
||||
@@ -253,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,
|
||||
@@ -268,4 +338,7 @@ public class View {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ 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;
|
||||
@@ -27,6 +26,7 @@ import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.TextureView;
|
||||
|
||||
import com.google.android.filament.SwapChain;
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ import com.google.android.filament.SwapChain;
|
||||
* mUiHelper = new UiHelper(UiHelper.ContextErrorPolicy.DONT_CHECK);
|
||||
*
|
||||
* // Attach the SurfaceView to the helper, you could do the same with a TextureView
|
||||
* mUiHelper.attachTo(surfaceView)
|
||||
* mUiHelper.attachTo(mSurfaceView);
|
||||
*
|
||||
* // Set a rendering callback that we will use to invoke Filament
|
||||
* mUiHelper.setRenderCallback(new UiHelper.RendererCallback() {
|
||||
@@ -95,15 +95,15 @@ import com.google.android.filament.SwapChain;
|
||||
* }
|
||||
*
|
||||
* public void onDestroy() {
|
||||
* super.onDestroy()
|
||||
* super.onDestroy();
|
||||
* // Always detach the surface before destroying the engine
|
||||
* mUiHelper.detach()
|
||||
* 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()
|
||||
* mEngine.destroy();
|
||||
* }
|
||||
*
|
||||
* // This is an example of a render function. You will most likely invoke this from
|
||||
@@ -113,8 +113,8 @@ import com.google.android.filament.SwapChain;
|
||||
* // 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()
|
||||
* mRenderer.render(mView);
|
||||
* mRenderer.endFrame();
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
@@ -381,6 +381,9 @@ public class UiHelper {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = "1.3"
|
||||
|
||||
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 29
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-19")
|
||||
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) ktx::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 = ktx::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 = ktx::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,165 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Consumes a blob of glTF 2.0 content (either JSON or GLB) and produces {@link FilamentAsset}
|
||||
* objects, which are bundles of Filament entities, material instances, textures, vertex buffers,
|
||||
* and index buffers.
|
||||
*
|
||||
* <p>AssetLoader does not fetch external buffer data or create textures on its own. Clients can use
|
||||
* the provided {@link ResourceLoader} class for this, which obtains the URI list from the asset.
|
||||
* This is demonstrated in the Kotlin snippet below.</p>
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* companion object {
|
||||
* init {
|
||||
* Filament.init()
|
||||
* AssetLoader.init()
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* override fun onCreate(savedInstanceState: Bundle?) {
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* assetLoader = AssetLoader(engine, MaterialProvider(engine), EntityManager.get())
|
||||
*
|
||||
* filamentAsset = assets.open("models/lucy.glb").use { input ->
|
||||
* val bytes = ByteArray(input.available())
|
||||
* input.read(bytes)
|
||||
* assetLoader.createAssetFromBinary(ByteBuffer.wrap(bytes))!!
|
||||
* }
|
||||
*
|
||||
* ResourceLoader(engine).loadResources(filamentAsset).destroy()
|
||||
* scene.addEntities(filamentAsset.entities)
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @see FilamentAsset
|
||||
* @see ResourceLoader
|
||||
*/
|
||||
public class AssetLoader {
|
||||
private long mNativeObject;
|
||||
|
||||
static Method sEngineGetNativeObject;
|
||||
static Method sEntityManagerGetNativeObject;
|
||||
static Constructor<Texture> sTextureConstructor;
|
||||
static Constructor<IndirectLight> sIndirectLightConstructor;
|
||||
static Constructor<Skybox> sSkyboxConstructor;
|
||||
|
||||
/**
|
||||
* Initializes the gltfio JNI layer. Must be called before using any gltfio functionality.
|
||||
*/
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <code>AssetLoader </code>that can be used to create and destroy instances of
|
||||
* {@link FilamentAsset}.
|
||||
*
|
||||
* @param engine the engine that the loader should pass to builder objects
|
||||
* @param generator specifies if materials should be generated or loaded from a pre-built set
|
||||
* @param entities the EntityManager that should be used to create entities
|
||||
*/
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees all memory consumed by the native <code>AssetLoader</code> and its material cache.
|
||||
*/
|
||||
public void destroy() {
|
||||
nDestroyAssetLoader(mNativeObject);
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link FilamentAsset} from the contents of a GLB file.
|
||||
*/
|
||||
@Nullable
|
||||
public FilamentAsset createAssetFromBinary(@NonNull Buffer buffer) {
|
||||
long nativeAsset = nCreateAssetFromBinary(mNativeObject, buffer, buffer.remaining());
|
||||
return new FilamentAsset(nativeAsset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows clients to enable diagnostic shading on newly-loaded assets.
|
||||
*/
|
||||
public void enableDiagnostics(boolean enable) {
|
||||
nEnableDiagnostics(mNativeObject, enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees all memory associated with the given {@link FilamentAsset}.
|
||||
*/
|
||||
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,100 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Owns a bundle of Filament objects that have been created by <code>AssetLoader</code>.
|
||||
*
|
||||
* <p>For usage instructions, see the documentation for {@link AssetLoader}.</p>
|
||||
*
|
||||
* <p>This class owns a hierarchy of entities that have been loaded from a glTF asset. Every entity has
|
||||
* a <code>TransformManager</code> component, and some entities also have
|
||||
* <code>NameComponentManager</code> and/or <code>RenderableManager</code> components.</p>
|
||||
*
|
||||
* <p>In addition to the aforementioned entities, an asset has strong ownership over a list of
|
||||
* <code>VertexBuffer</code>, <code>IndexBuffer</code>, <code>MaterialInstance</code>, and
|
||||
* <code>Texture</code>.</p>
|
||||
*
|
||||
* <p>Clients can use {@link ResourceLoader} to create textures, compute tangent quaternions, and
|
||||
* upload data into vertex buffers and index buffers.</p>
|
||||
*
|
||||
* <p>TODO: <code>Animator</code> is not yet exposed to Java / Kotlin clients.</p>
|
||||
*
|
||||
* @see ResourceLoader
|
||||
* @see AssetLoader
|
||||
*/
|
||||
public class FilamentAsset {
|
||||
private long mNativeObject;
|
||||
|
||||
FilamentAsset(long nativeObject) {
|
||||
mNativeObject = nativeObject;
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transform root for the asset, which has no matching glTF node.
|
||||
*/
|
||||
public @Entity int getRoot() {
|
||||
return nGetRoot(mNativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of entities, one for each glTF node.
|
||||
*
|
||||
* <p>All of these have a transform component. Some of the returned entities may also have a
|
||||
* renderable component.</p>
|
||||
*/
|
||||
public @Entity int[] getEntities() {
|
||||
int[] result = new int[nGetEntityCount(mNativeObject)];
|
||||
nGetEntities(mNativeObject, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bounding box computed from the supplied min / max values in glTF accessors.
|
||||
*/
|
||||
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]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <code>NameComponentManager<?code> label for the given entity, if it exists.
|
||||
*/
|
||||
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,101 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Utilities for consuming KTX files and producing Filament textures, IBLs, and sky boxes.
|
||||
*
|
||||
* <p>KTX is a simple container format that makes it easy to bundle miplevels and cubemap faces
|
||||
* into a single file.</p>
|
||||
*/
|
||||
public class KtxLoader {
|
||||
|
||||
public static class Options {
|
||||
public boolean srgb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes the content of a KTX file and produces a {@link Texture} object.
|
||||
*
|
||||
* @param engine Gets passed to the builder.
|
||||
* @param buffer The content of the KTX File.
|
||||
* @param options Loader options.
|
||||
* @return The resulting Filament texture, or null on failure.
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes the content of a KTX file and produces an {@link IndirectLight} object.
|
||||
*
|
||||
* @param engine Gets passed to the builder.
|
||||
* @param buffer The content of the KTX File.
|
||||
* @param options Loader options.
|
||||
* @return The resulting Filament texture, or null on failure.
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes the content of a KTX file and produces a {@link Skybox} object.
|
||||
*
|
||||
* @param engine Gets passed to the builder.
|
||||
* @param buffer The content of the KTX File.
|
||||
* @param options Loader options.
|
||||
* @return The resulting Filament texture, or null on failure.
|
||||
*/
|
||||
@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,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 com.google.android.filament.Engine;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Loads pre-generated ubershader materials that fulfill glTF requirements.
|
||||
*
|
||||
* <p>This class is used by {@link AssetLoader} to create Filament materials.
|
||||
* Client applications do not need to call methods on it.</p>
|
||||
*/
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an ubershader loader using the supplied {@link Engine}.
|
||||
*
|
||||
* @param engine the engine used to create materials
|
||||
*/
|
||||
public MaterialProvider(Engine engine) {
|
||||
try {
|
||||
long nativeEngine = (long) sEngineGetNativeObject.invoke(engine);
|
||||
mNativeObject = nCreateMaterialProvider(nativeEngine);
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the native material provider.
|
||||
* */
|
||||
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,110 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Uploads vertex buffers and textures to the GPU and computes tangents.
|
||||
*
|
||||
* <p>For a usage example, see the documentation for {@link AssetLoader}.</p>
|
||||
*
|
||||
* @see AssetLoader
|
||||
* @see FilamentAsset
|
||||
*/
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a resource loader tied to the given Filament engine.
|
||||
*
|
||||
* @param engine the engine that gets passed to all builder methods
|
||||
* @throws IllegalAccessException
|
||||
* @throws InvocationTargetException
|
||||
*/
|
||||
public ResourceLoader(@NonNull Engine engine) throws IllegalAccessException, InvocationTargetException {
|
||||
long nativeEngine = (long) sEngineGetNativeObject.invoke(engine);
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees all memory associated with the native resource loader.
|
||||
*/
|
||||
public void destroy() {
|
||||
nDestroyResourceLoader(mNativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Feeds the binary content of an external resource into the loader's URI cache.
|
||||
*
|
||||
* <p><code>ResourceLoader</code> does not know how to download external resources on its own
|
||||
* (for example, external resources might come from a filesystem, a database, or the internet)
|
||||
* so this method allows clients to download external resources and push them to the loader.</p>
|
||||
*
|
||||
* <p>When loading GLB files (as opposed to JSON-based glTF files), clients typically do not
|
||||
* need to call this method.</p>
|
||||
*
|
||||
* @param uri the string path that matches an image URI or buffer URI in the glTF
|
||||
* @param buffer the binary blob corresponding to the given URI
|
||||
* @return self (for daisy chaining)
|
||||
*/
|
||||
@NonNull
|
||||
public ResourceLoader addResourceData(@NonNull String uri, @NonNull Buffer buffer) {
|
||||
nAddResourceData(mNativeObject, uri, buffer, buffer.remaining());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through all external buffers and images and creates corresponding Filament objects
|
||||
* (vertex buffers, textures, etc), which become owned by the asset.
|
||||
*
|
||||
* <p>This is the main entry point for <code>ResourceLoader</code>, and only needs to be called
|
||||
* once.</p>
|
||||
*
|
||||
* @param asset the Filament asset that contains URI-based resources
|
||||
* @return self (for daisy chaining)
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
@@ -39,6 +39,19 @@ Demonstrates how to render into a `TextureView` instead of a `SurfaceView`:
|
||||
|
||||

|
||||
|
||||
### `material-builder`
|
||||
|
||||
Demonstrates how to programatically generate Filament materials, as opposed to compiling them on the
|
||||
host machine:
|
||||
|
||||

|
||||
|
||||
### `gltf-bloom`
|
||||
|
||||
Demonstrates how to load glTF models and render to an offscreen buffer:
|
||||
|
||||

|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you start, make sure to read [Filament's README](../../README.md). You need to be able to
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user