├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── arcore-android-sdk-1.23.0 ├── LICENSE └── samples │ └── augmented_image_java │ └── app │ ├── build.gradle │ └── src │ └── main │ └── java │ └── com │ └── google │ └── ar │ └── core │ └── examples │ └── java │ ├── augmentedimage │ ├── AugmentedImageActivity.java │ ├── PhysicsController.java │ └── rendering │ │ └── AugmentedImageRenderer.java │ └── common │ └── rendering │ └── ObjectRenderer.java └── third_party ├── GreenMaze_obj.zip └── licence info for GreenMaze_obj.zip.txt /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution; 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | ## Community Guidelines 26 | 27 | This project follows [Google's Open Source Community 28 | Guidelines](https://opensource.google.com/conduct/). 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Augmented Image codelab 2 | 3 | This repository contains code for Augmented Image codelab. 4 | Augmented Image Codelab is based on [ARCore Android SDK](https://github.com/google-ar/arcore-android-sdk)'s [**augmented_image_java**](https://github.com/google-ar/arcore-android-sdk/tree/master/samples/augmented_image_java) sample, which are not included here. Files in this repository are those we modified or added in this codelab. 5 | 6 | The extra GreenMaze asset used in this codelab is provided in third_party directory, with license and attribution info inside. 7 | 8 | This repository uses the Apache license, except for files in third_party directory. 9 | -------------------------------------------------------------------------------- /arcore-android-sdk-1.23.0/LICENSE: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | Section 1: ARCore SDK binary files 3 | 4 | The following files: 5 | tools/arcoreimg/linux/arcoreimg 6 | tools/arcoreimg/macos/arcoreimg 7 | tools/arcoreimg/windows/arcoreimg.exe 8 | 9 | as well as the files ending in ".apk" attached to [GitHub 10 | releases](https://github.com/google-ar/arcore-android-sdk/releases) 11 | 12 | are licensed as follows: 13 | 14 | Covered by the **Google APIs Terms of Service** at 15 | [https://developers.google.com/terms/](https://developers.google.com/terms/) 16 | 17 | =============================================================================== 18 | Section 2: ARCore SDK source files 19 | 20 | Except as indicated in sections 1 above and section 3 below, files in this SDK 21 | are licensed as follows: 22 | 23 | Copyright 2017 Google LLC 24 | 25 | Licensed under the Apache License, Version 2.0 (the "License"); 26 | you may not use this file except in compliance with the License. 27 | Unless required by applicable law or agreed to in writing, software 28 | distributed under the License is distributed on an "AS IS" BASIS, 29 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 30 | See the License for the specific language governing permissions and 31 | limitations under the License. 32 | Apache License 33 | Version 2.0, January 2004 34 | http://www.apache.org/licenses/ 35 | 36 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 37 | 38 | 1. Definitions. 39 | 40 | "License" shall mean the terms and conditions for use, reproduction, 41 | and distribution as defined by Sections 1 through 9 of this document. 42 | 43 | "Licensor" shall mean the copyright owner or entity authorized by 44 | the copyright owner that is granting the License. 45 | 46 | "Legal Entity" shall mean the union of the acting entity and all 47 | other entities that control, are controlled by, or are under common 48 | control with that entity. For the purposes of this definition, 49 | "control" means (i) the power, direct or indirect, to cause the 50 | direction or management of such entity, whether by contract or 51 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 52 | outstanding shares, or (iii) beneficial ownership of such entity. 53 | 54 | "You" (or "Your") shall mean an individual or Legal Entity 55 | exercising permissions granted by this License. 56 | 57 | "Source" form shall mean the preferred form for making modifications, 58 | including but not limited to software source code, documentation 59 | source, and configuration files. 60 | 61 | "Object" form shall mean any form resulting from mechanical 62 | transformation or translation of a Source form, including but 63 | not limited to compiled object code, generated documentation, 64 | and conversions to other media types. 65 | 66 | "Work" shall mean the work of authorship, whether in Source or 67 | Object form, made available under the License, as indicated by a 68 | copyright notice that is included in or attached to the work 69 | (an example is provided in the Appendix below). 70 | 71 | "Derivative Works" shall mean any work, whether in Source or Object 72 | form, that is based on (or derived from) the Work and for which the 73 | editorial revisions, annotations, elaborations, or other modifications 74 | represent, as a whole, an original work of authorship. For the purposes 75 | of this License, Derivative Works shall not include works that remain 76 | separable from, or merely link (or bind by name) to the interfaces of, 77 | the Work and Derivative Works thereof. 78 | 79 | "Contribution" shall mean any work of authorship, including 80 | the original version of the Work and any modifications or additions 81 | to that Work or Derivative Works thereof, that is intentionally 82 | submitted to Licensor for inclusion in the Work by the copyright owner 83 | or by an individual or Legal Entity authorized to submit on behalf of 84 | the copyright owner. For the purposes of this definition, "submitted" 85 | means any form of electronic, verbal, or written communication sent 86 | to the Licensor or its representatives, including but not limited to 87 | communication on electronic mailing lists, source code control systems, 88 | and issue tracking systems that are managed by, or on behalf of, the 89 | Licensor for the purpose of discussing and improving the Work, but 90 | excluding communication that is conspicuously marked or otherwise 91 | designated in writing by the copyright owner as "Not a Contribution." 92 | 93 | "Contributor" shall mean Licensor and any individual or Legal Entity 94 | on behalf of whom a Contribution has been received by Licensor and 95 | subsequently incorporated within the Work. 96 | 97 | 2. Grant of Copyright License. Subject to the terms and conditions of 98 | this License, each Contributor hereby grants to You a perpetual, 99 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 100 | copyright license to reproduce, prepare Derivative Works of, 101 | publicly display, publicly perform, sublicense, and distribute the 102 | Work and such Derivative Works in Source or Object form. 103 | 104 | 3. Grant of Patent License. Subject to the terms and conditions of 105 | this License, each Contributor hereby grants to You a perpetual, 106 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 107 | (except as stated in this section) patent license to make, have made, 108 | use, offer to sell, sell, import, and otherwise transfer the Work, 109 | where such license applies only to those patent claims licensable 110 | by such Contributor that are necessarily infringed by their 111 | Contribution(s) alone or by combination of their Contribution(s) 112 | with the Work to which such Contribution(s) was submitted. If You 113 | institute patent litigation against any entity (including a 114 | cross-claim or counterclaim in a lawsuit) alleging that the Work 115 | or a Contribution incorporated within the Work constitutes direct 116 | or contributory patent infringement, then any patent licenses 117 | granted to You under this License for that Work shall terminate 118 | as of the date such litigation is filed. 119 | 120 | 4. Redistribution. You may reproduce and distribute copies of the 121 | Work or Derivative Works thereof in any medium, with or without 122 | modifications, and in Source or Object form, provided that You 123 | meet the following conditions: 124 | 125 | (a) You must give any other recipients of the Work or 126 | Derivative Works a copy of this License; and 127 | 128 | (b) You must cause any modified files to carry prominent notices 129 | stating that You changed the files; and 130 | 131 | (c) You must retain, in the Source form of any Derivative Works 132 | that You distribute, all copyright, patent, trademark, and 133 | attribution notices from the Source form of the Work, 134 | excluding those notices that do not pertain to any part of 135 | the Derivative Works; and 136 | 137 | (d) If the Work includes a "NOTICE" text file as part of its 138 | distribution, then any Derivative Works that You distribute must 139 | include a readable copy of the attribution notices contained 140 | within such NOTICE file, excluding those notices that do not 141 | pertain to any part of the Derivative Works, in at least one 142 | of the following places: within a NOTICE text file distributed 143 | as part of the Derivative Works; within the Source form or 144 | documentation, if provided along with the Derivative Works; or, 145 | within a display generated by the Derivative Works, if and 146 | wherever such third-party notices normally appear. The contents 147 | of the NOTICE file are for informational purposes only and 148 | do not modify the License. You may add Your own attribution 149 | notices within Derivative Works that You distribute, alongside 150 | or as an addendum to the NOTICE text from the Work, provided 151 | that such additional attribution notices cannot be construed 152 | as modifying the License. 153 | 154 | You may add Your own copyright statement to Your modifications and 155 | may provide additional or different license terms and conditions 156 | for use, reproduction, or distribution of Your modifications, or 157 | for any such Derivative Works as a whole, provided Your use, 158 | reproduction, and distribution of the Work otherwise complies with 159 | the conditions stated in this License. 160 | 161 | 5. Submission of Contributions. Unless You explicitly state otherwise, 162 | any Contribution intentionally submitted for inclusion in the Work 163 | by You to the Licensor shall be under the terms and conditions of 164 | this License, without any additional terms or conditions. 165 | Notwithstanding the above, nothing herein shall supersede or modify 166 | the terms of any separate license agreement you may have executed 167 | with Licensor regarding such Contributions. 168 | 169 | 6. Trademarks. This License does not grant permission to use the trade 170 | names, trademarks, service marks, or product names of the Licensor, 171 | except as required for reasonable and customary use in describing the 172 | origin of the Work and reproducing the content of the NOTICE file. 173 | 174 | 7. Disclaimer of Warranty. Unless required by applicable law or 175 | agreed to in writing, Licensor provides the Work (and each 176 | Contributor provides its Contributions) on an "AS IS" BASIS, 177 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 178 | implied, including, without limitation, any warranties or conditions 179 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 180 | PARTICULAR PURPOSE. You are solely responsible for determining the 181 | appropriateness of using or redistributing the Work and assume any 182 | risks associated with Your exercise of permissions under this License. 183 | 184 | 8. Limitation of Liability. In no event and under no legal theory, 185 | whether in tort (including negligence), contract, or otherwise, 186 | unless required by applicable law (such as deliberate and grossly 187 | negligent acts) or agreed to in writing, shall any Contributor be 188 | liable to You for damages, including any direct, indirect, special, 189 | incidental, or consequential damages of any character arising as a 190 | result of this License or out of the use or inability to use the 191 | Work (including but not limited to damages for loss of goodwill, 192 | work stoppage, computer failure or malfunction, or any and all 193 | other commercial damages or losses), even if such Contributor 194 | has been advised of the possibility of such damages. 195 | 196 | 9. Accepting Warranty or Additional Liability. While redistributing 197 | the Work or Derivative Works thereof, You may choose to offer, 198 | and charge a fee for, acceptance of support, warranty, indemnity, 199 | or other liability obligations and/or rights consistent with this 200 | License. However, in accepting such obligations, You may act only 201 | on Your own behalf and on Your sole responsibility, not on behalf 202 | of any other Contributor, and only if You agree to indemnify, 203 | defend, and hold each Contributor harmless for any liability 204 | incurred by, or claims asserted against, such Contributor by reason 205 | of your accepting any such warranty or additional liability. 206 | 207 | END OF TERMS AND CONDITIONS 208 | 209 | APPENDIX: How to apply the Apache License to your work. 210 | 211 | To apply the Apache License to your work, attach the following 212 | boilerplate notice, with the fields enclosed by brackets "[]" 213 | replaced with your own identifying information. (Don't include 214 | the brackets!) The text should be enclosed in the appropriate 215 | comment syntax for the file format. We also recommend that a 216 | file or class name and description of purpose be included on the 217 | same "printed page" as the copyright notice for easier 218 | identification within third-party archives. 219 | 220 | Copyright [yyyy] [name of copyright owner] 221 | 222 | Licensed under the Apache License, Version 2.0 (the "License"); 223 | you may not use this file except in compliance with the License. 224 | You may obtain a copy of the License at 225 | 226 | http://www.apache.org/licenses/LICENSE-2.0 227 | 228 | Unless required by applicable law or agreed to in writing, software 229 | distributed under the License is distributed on an "AS IS" BASIS, 230 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 231 | See the License for the specific language governing permissions and 232 | limitations under the License. 233 | 234 | =============================================================================== 235 | Section 3: ARCore SDK dependencies 236 | 237 | ******************************************************************************* 238 | Abseil 239 | ******************************************************************************* 240 | 241 | Apache License 242 | Version 2.0, January 2004 243 | https://www.apache.org/licenses/ 244 | 245 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 246 | 247 | 1. Definitions. 248 | 249 | "License" shall mean the terms and conditions for use, reproduction, 250 | and distribution as defined by Sections 1 through 9 of this document. 251 | 252 | "Licensor" shall mean the copyright owner or entity authorized by 253 | the copyright owner that is granting the License. 254 | 255 | "Legal Entity" shall mean the union of the acting entity and all 256 | other entities that control, are controlled by, or are under common 257 | control with that entity. For the purposes of this definition, 258 | "control" means (i) the power, direct or indirect, to cause the 259 | direction or management of such entity, whether by contract or 260 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 261 | outstanding shares, or (iii) beneficial ownership of such entity. 262 | 263 | "You" (or "Your") shall mean an individual or Legal Entity 264 | exercising permissions granted by this License. 265 | 266 | "Source" form shall mean the preferred form for making modifications, 267 | including but not limited to software source code, documentation 268 | source, and configuration files. 269 | 270 | "Object" form shall mean any form resulting from mechanical 271 | transformation or translation of a Source form, including but 272 | not limited to compiled object code, generated documentation, 273 | and conversions to other media types. 274 | 275 | "Work" shall mean the work of authorship, whether in Source or 276 | Object form, made available under the License, as indicated by a 277 | copyright notice that is included in or attached to the work 278 | (an example is provided in the Appendix below). 279 | 280 | "Derivative Works" shall mean any work, whether in Source or Object 281 | form, that is based on (or derived from) the Work and for which the 282 | editorial revisions, annotations, elaborations, or other modifications 283 | represent, as a whole, an original work of authorship. For the purposes 284 | of this License, Derivative Works shall not include works that remain 285 | separable from, or merely link (or bind by name) to the interfaces of, 286 | the Work and Derivative Works thereof. 287 | 288 | "Contribution" shall mean any work of authorship, including 289 | the original version of the Work and any modifications or additions 290 | to that Work or Derivative Works thereof, that is intentionally 291 | submitted to Licensor for inclusion in the Work by the copyright owner 292 | or by an individual or Legal Entity authorized to submit on behalf of 293 | the copyright owner. For the purposes of this definition, "submitted" 294 | means any form of electronic, verbal, or written communication sent 295 | to the Licensor or its representatives, including but not limited to 296 | communication on electronic mailing lists, source code control systems, 297 | and issue tracking systems that are managed by, or on behalf of, the 298 | Licensor for the purpose of discussing and improving the Work, but 299 | excluding communication that is conspicuously marked or otherwise 300 | designated in writing by the copyright owner as "Not a Contribution." 301 | 302 | "Contributor" shall mean Licensor and any individual or Legal Entity 303 | on behalf of whom a Contribution has been received by Licensor and 304 | subsequently incorporated within the Work. 305 | 306 | 2. Grant of Copyright License. Subject to the terms and conditions of 307 | this License, each Contributor hereby grants to You a perpetual, 308 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 309 | copyright license to reproduce, prepare Derivative Works of, 310 | publicly display, publicly perform, sublicense, and distribute the 311 | Work and such Derivative Works in Source or Object form. 312 | 313 | 3. Grant of Patent License. Subject to the terms and conditions of 314 | this License, each Contributor hereby grants to You a perpetual, 315 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 316 | (except as stated in this section) patent license to make, have made, 317 | use, offer to sell, sell, import, and otherwise transfer the Work, 318 | where such license applies only to those patent claims licensable 319 | by such Contributor that are necessarily infringed by their 320 | Contribution(s) alone or by combination of their Contribution(s) 321 | with the Work to which such Contribution(s) was submitted. If You 322 | institute patent litigation against any entity (including a 323 | cross-claim or counterclaim in a lawsuit) alleging that the Work 324 | or a Contribution incorporated within the Work constitutes direct 325 | or contributory patent infringement, then any patent licenses 326 | granted to You under this License for that Work shall terminate 327 | as of the date such litigation is filed. 328 | 329 | 4. Redistribution. You may reproduce and distribute copies of the 330 | Work or Derivative Works thereof in any medium, with or without 331 | modifications, and in Source or Object form, provided that You 332 | meet the following conditions: 333 | 334 | (a) You must give any other recipients of the Work or 335 | Derivative Works a copy of this License; and 336 | 337 | (b) You must cause any modified files to carry prominent notices 338 | stating that You changed the files; and 339 | 340 | (c) You must retain, in the Source form of any Derivative Works 341 | that You distribute, all copyright, patent, trademark, and 342 | attribution notices from the Source form of the Work, 343 | excluding those notices that do not pertain to any part of 344 | the Derivative Works; and 345 | 346 | (d) If the Work includes a "NOTICE" text file as part of its 347 | distribution, then any Derivative Works that You distribute must 348 | include a readable copy of the attribution notices contained 349 | within such NOTICE file, excluding those notices that do not 350 | pertain to any part of the Derivative Works, in at least one 351 | of the following places: within a NOTICE text file distributed 352 | as part of the Derivative Works; within the Source form or 353 | documentation, if provided along with the Derivative Works; or, 354 | within a display generated by the Derivative Works, if and 355 | wherever such third-party notices normally appear. The contents 356 | of the NOTICE file are for informational purposes only and 357 | do not modify the License. You may add Your own attribution 358 | notices within Derivative Works that You distribute, alongside 359 | or as an addendum to the NOTICE text from the Work, provided 360 | that such additional attribution notices cannot be construed 361 | as modifying the License. 362 | 363 | You may add Your own copyright statement to Your modifications and 364 | may provide additional or different license terms and conditions 365 | for use, reproduction, or distribution of Your modifications, or 366 | for any such Derivative Works as a whole, provided Your use, 367 | reproduction, and distribution of the Work otherwise complies with 368 | the conditions stated in this License. 369 | 370 | 5. Submission of Contributions. Unless You explicitly state otherwise, 371 | any Contribution intentionally submitted for inclusion in the Work 372 | by You to the Licensor shall be under the terms and conditions of 373 | this License, without any additional terms or conditions. 374 | Notwithstanding the above, nothing herein shall supersede or modify 375 | the terms of any separate license agreement you may have executed 376 | with Licensor regarding such Contributions. 377 | 378 | 6. Trademarks. This License does not grant permission to use the trade 379 | names, trademarks, service marks, or product names of the Licensor, 380 | except as required for reasonable and customary use in describing the 381 | origin of the Work and reproducing the content of the NOTICE file. 382 | 383 | 7. Disclaimer of Warranty. Unless required by applicable law or 384 | agreed to in writing, Licensor provides the Work (and each 385 | Contributor provides its Contributions) on an "AS IS" BASIS, 386 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 387 | implied, including, without limitation, any warranties or conditions 388 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 389 | PARTICULAR PURPOSE. You are solely responsible for determining the 390 | appropriateness of using or redistributing the Work and assume any 391 | risks associated with Your exercise of permissions under this License. 392 | 393 | 8. Limitation of Liability. In no event and under no legal theory, 394 | whether in tort (including negligence), contract, or otherwise, 395 | unless required by applicable law (such as deliberate and grossly 396 | negligent acts) or agreed to in writing, shall any Contributor be 397 | liable to You for damages, including any direct, indirect, special, 398 | incidental, or consequential damages of any character arising as a 399 | result of this License or out of the use or inability to use the 400 | Work (including but not limited to damages for loss of goodwill, 401 | work stoppage, computer failure or malfunction, or any and all 402 | other commercial damages or losses), even if such Contributor 403 | has been advised of the possibility of such damages. 404 | 405 | 9. Accepting Warranty or Additional Liability. While redistributing 406 | the Work or Derivative Works thereof, You may choose to offer, 407 | and charge a fee for, acceptance of support, warranty, indemnity, 408 | or other liability obligations and/or rights consistent with this 409 | License. However, in accepting such obligations, You may act only 410 | on Your own behalf and on Your sole responsibility, not on behalf 411 | of any other Contributor, and only if You agree to indemnify, 412 | defend, and hold each Contributor harmless for any liability 413 | incurred by, or claims asserted against, such Contributor by reason 414 | of your accepting any such warranty or additional liability. 415 | 416 | END OF TERMS AND CONDITIONS 417 | 418 | APPENDIX: How to apply the Apache License to your work. 419 | 420 | To apply the Apache License to your work, attach the following 421 | boilerplate notice, with the fields enclosed by brackets "[]" 422 | replaced with your own identifying information. (Don't include 423 | the brackets!) The text should be enclosed in the appropriate 424 | comment syntax for the file format. We also recommend that a 425 | file or class name and description of purpose be included on the 426 | same "printed page" as the copyright notice for easier 427 | identification within third-party archives. 428 | 429 | Copyright [yyyy] [name of copyright owner] 430 | 431 | Licensed under the Apache License, Version 2.0 (the "License"); 432 | you may not use this file except in compliance with the License. 433 | You may obtain a copy of the License at 434 | 435 | https://www.apache.org/licenses/LICENSE-2.0 436 | 437 | Unless required by applicable law or agreed to in writing, software 438 | distributed under the License is distributed on an "AS IS" BASIS, 439 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 440 | See the License for the specific language governing permissions and 441 | limitations under the License. 442 | 443 | 444 | ******************************************************************************* 445 | AndroidX annotation library 446 | ******************************************************************************* 447 | 448 | Copyright (c) 2005-2011, The Android Open Source Project 449 | 450 | Licensed under the Apache License, Version 2.0 (the "License"); 451 | you may not use this file except in compliance with the License. 452 | 453 | Unless required by applicable law or agreed to in writing, software 454 | distributed under the License is distributed on an "AS IS" BASIS, 455 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 456 | See the License for the specific language governing permissions and 457 | limitations under the License. 458 | 459 | 460 | Apache License 461 | Version 2.0, January 2004 462 | http://www.apache.org/licenses/ 463 | 464 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 465 | 466 | 1. Definitions. 467 | 468 | "License" shall mean the terms and conditions for use, reproduction, 469 | and distribution as defined by Sections 1 through 9 of this document. 470 | 471 | "Licensor" shall mean the copyright owner or entity authorized by 472 | the copyright owner that is granting the License. 473 | 474 | "Legal Entity" shall mean the union of the acting entity and all 475 | other entities that control, are controlled by, or are under common 476 | control with that entity. For the purposes of this definition, 477 | "control" means (i) the power, direct or indirect, to cause the 478 | direction or management of such entity, whether by contract or 479 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 480 | outstanding shares, or (iii) beneficial ownership of such entity. 481 | 482 | "You" (or "Your") shall mean an individual or Legal Entity 483 | exercising permissions granted by this License. 484 | 485 | "Source" form shall mean the preferred form for making modifications, 486 | including but not limited to software source code, documentation 487 | source, and configuration files. 488 | 489 | "Object" form shall mean any form resulting from mechanical 490 | transformation or translation of a Source form, including but 491 | not limited to compiled object code, generated documentation, 492 | and conversions to other media types. 493 | 494 | "Work" shall mean the work of authorship, whether in Source or 495 | Object form, made available under the License, as indicated by a 496 | copyright notice that is included in or attached to the work 497 | (an example is provided in the Appendix below). 498 | 499 | "Derivative Works" shall mean any work, whether in Source or Object 500 | form, that is based on (or derived from) the Work and for which the 501 | editorial revisions, annotations, elaborations, or other modifications 502 | represent, as a whole, an original work of authorship. For the purposes 503 | of this License, Derivative Works shall not include works that remain 504 | separable from, or merely link (or bind by name) to the interfaces of, 505 | the Work and Derivative Works thereof. 506 | 507 | "Contribution" shall mean any work of authorship, including 508 | the original version of the Work and any modifications or additions 509 | to that Work or Derivative Works thereof, that is intentionally 510 | submitted to Licensor for inclusion in the Work by the copyright owner 511 | or by an individual or Legal Entity authorized to submit on behalf of 512 | the copyright owner. For the purposes of this definition, "submitted" 513 | means any form of electronic, verbal, or written communication sent 514 | to the Licensor or its representatives, including but not limited to 515 | communication on electronic mailing lists, source code control systems, 516 | and issue tracking systems that are managed by, or on behalf of, the 517 | Licensor for the purpose of discussing and improving the Work, but 518 | excluding communication that is conspicuously marked or otherwise 519 | designated in writing by the copyright owner as "Not a Contribution." 520 | 521 | "Contributor" shall mean Licensor and any individual or Legal Entity 522 | on behalf of whom a Contribution has been received by Licensor and 523 | subsequently incorporated within the Work. 524 | 525 | 2. Grant of Copyright License. Subject to the terms and conditions of 526 | this License, each Contributor hereby grants to You a perpetual, 527 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 528 | copyright license to reproduce, prepare Derivative Works of, 529 | publicly display, publicly perform, sublicense, and distribute the 530 | Work and such Derivative Works in Source or Object form. 531 | 532 | 3. Grant of Patent License. Subject to the terms and conditions of 533 | this License, each Contributor hereby grants to You a perpetual, 534 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 535 | (except as stated in this section) patent license to make, have made, 536 | use, offer to sell, sell, import, and otherwise transfer the Work, 537 | where such license applies only to those patent claims licensable 538 | by such Contributor that are necessarily infringed by their 539 | Contribution(s) alone or by combination of their Contribution(s) 540 | with the Work to which such Contribution(s) was submitted. If You 541 | institute patent litigation against any entity (including a 542 | cross-claim or counterclaim in a lawsuit) alleging that the Work 543 | or a Contribution incorporated within the Work constitutes direct 544 | or contributory patent infringement, then any patent licenses 545 | granted to You under this License for that Work shall terminate 546 | as of the date such litigation is filed. 547 | 548 | 4. Redistribution. You may reproduce and distribute copies of the 549 | Work or Derivative Works thereof in any medium, with or without 550 | modifications, and in Source or Object form, provided that You 551 | meet the following conditions: 552 | 553 | (a) You must give any other recipients of the Work or 554 | Derivative Works a copy of this License; and 555 | 556 | (b) You must cause any modified files to carry prominent notices 557 | stating that You changed the files; and 558 | 559 | (c) You must retain, in the Source form of any Derivative Works 560 | that You distribute, all copyright, patent, trademark, and 561 | attribution notices from the Source form of the Work, 562 | excluding those notices that do not pertain to any part of 563 | the Derivative Works; and 564 | 565 | (d) If the Work includes a "NOTICE" text file as part of its 566 | distribution, then any Derivative Works that You distribute must 567 | include a readable copy of the attribution notices contained 568 | within such NOTICE file, excluding those notices that do not 569 | pertain to any part of the Derivative Works, in at least one 570 | of the following places: within a NOTICE text file distributed 571 | as part of the Derivative Works; within the Source form or 572 | documentation, if provided along with the Derivative Works; or, 573 | within a display generated by the Derivative Works, if and 574 | wherever such third-party notices normally appear. The contents 575 | of the NOTICE file are for informational purposes only and 576 | do not modify the License. You may add Your own attribution 577 | notices within Derivative Works that You distribute, alongside 578 | or as an addendum to the NOTICE text from the Work, provided 579 | that such additional attribution notices cannot be construed 580 | as modifying the License. 581 | 582 | You may add Your own copyright statement to Your modifications and 583 | may provide additional or different license terms and conditions 584 | for use, reproduction, or distribution of Your modifications, or 585 | for any such Derivative Works as a whole, provided Your use, 586 | reproduction, and distribution of the Work otherwise complies with 587 | the conditions stated in this License. 588 | 589 | 5. Submission of Contributions. Unless You explicitly state otherwise, 590 | any Contribution intentionally submitted for inclusion in the Work 591 | by You to the Licensor shall be under the terms and conditions of 592 | this License, without any additional terms or conditions. 593 | Notwithstanding the above, nothing herein shall supersede or modify 594 | the terms of any separate license agreement you may have executed 595 | with Licensor regarding such Contributions. 596 | 597 | 6. Trademarks. This License does not grant permission to use the trade 598 | names, trademarks, service marks, or product names of the Licensor, 599 | except as required for reasonable and customary use in describing the 600 | origin of the Work and reproducing the content of the NOTICE file. 601 | 602 | 7. Disclaimer of Warranty. Unless required by applicable law or 603 | agreed to in writing, Licensor provides the Work (and each 604 | Contributor provides its Contributions) on an "AS IS" BASIS, 605 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 606 | implied, including, without limitation, any warranties or conditions 607 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 608 | PARTICULAR PURPOSE. You are solely responsible for determining the 609 | appropriateness of using or redistributing the Work and assume any 610 | risks associated with Your exercise of permissions under this License. 611 | 612 | 8. Limitation of Liability. In no event and under no legal theory, 613 | whether in tort (including negligence), contract, or otherwise, 614 | unless required by applicable law (such as deliberate and grossly 615 | negligent acts) or agreed to in writing, shall any Contributor be 616 | liable to You for damages, including any direct, indirect, special, 617 | incidental, or consequential damages of any character arising as a 618 | result of this License or out of the use or inability to use the 619 | Work (including but not limited to damages for loss of goodwill, 620 | work stoppage, computer failure or malfunction, or any and all 621 | other commercial damages or losses), even if such Contributor 622 | has been advised of the possibility of such damages. 623 | 624 | 9. Accepting Warranty or Additional Liability. While redistributing 625 | the Work or Derivative Works thereof, You may choose to offer, 626 | and charge a fee for, acceptance of support, warranty, indemnity, 627 | or other liability obligations and/or rights consistent with this 628 | License. However, in accepting such obligations, You may act only 629 | on Your own behalf and on Your sole responsibility, not on behalf 630 | of any other Contributor, and only if You agree to indemnify, 631 | defend, and hold each Contributor harmless for any liability 632 | incurred by, or claims asserted against, such Contributor by reason 633 | of your accepting any such warranty or additional liability. 634 | 635 | END OF TERMS AND CONDITIONS 636 | 637 | 638 | ******************************************************************************* 639 | JSR 305 640 | ******************************************************************************* 641 | Copyright (c) 2007-2009, JSR305 expert group 642 | All rights reserved. 643 | 644 | http://www.opensource.org/licenses/bsd-license.php 645 | 646 | Redistribution and use in source and binary forms, with or without 647 | modification, are permitted provided that the following conditions are met: 648 | 649 | * Redistributions of source code must retain the above copyright notice, 650 | this list of conditions and the following disclaimer. 651 | * Redistributions in binary form must reproduce the above copyright notice, 652 | this list of conditions and the following disclaimer in the documentation 653 | and/or other materials provided with the distribution. 654 | * Neither the name of the JSR305 expert group nor the names of its 655 | contributors may be used to endorse or promote products derived from 656 | this software without specific prior written permission. 657 | 658 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 659 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 660 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 661 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 662 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 663 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 664 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 665 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 666 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 667 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 668 | POSSIBILITY OF SUCH DAMAGE. 669 | 670 | ******************************************************************************* 671 | TCMalloc 672 | ******************************************************************************* 673 | 674 | Apache License 675 | Version 2.0, January 2004 676 | https://www.apache.org/licenses/ 677 | 678 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 679 | 680 | 1. Definitions. 681 | 682 | "License" shall mean the terms and conditions for use, reproduction, 683 | and distribution as defined by Sections 1 through 9 of this document. 684 | 685 | "Licensor" shall mean the copyright owner or entity authorized by 686 | the copyright owner that is granting the License. 687 | 688 | "Legal Entity" shall mean the union of the acting entity and all 689 | other entities that control, are controlled by, or are under common 690 | control with that entity. For the purposes of this definition, 691 | "control" means (i) the power, direct or indirect, to cause the 692 | direction or management of such entity, whether by contract or 693 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 694 | outstanding shares, or (iii) beneficial ownership of such entity. 695 | 696 | "You" (or "Your") shall mean an individual or Legal Entity 697 | exercising permissions granted by this License. 698 | 699 | "Source" form shall mean the preferred form for making modifications, 700 | including but not limited to software source code, documentation 701 | source, and configuration files. 702 | 703 | "Object" form shall mean any form resulting from mechanical 704 | transformation or translation of a Source form, including but 705 | not limited to compiled object code, generated documentation, 706 | and conversions to other media types. 707 | 708 | "Work" shall mean the work of authorship, whether in Source or 709 | Object form, made available under the License, as indicated by a 710 | copyright notice that is included in or attached to the work 711 | (an example is provided in the Appendix below). 712 | 713 | "Derivative Works" shall mean any work, whether in Source or Object 714 | form, that is based on (or derived from) the Work and for which the 715 | editorial revisions, annotations, elaborations, or other modifications 716 | represent, as a whole, an original work of authorship. For the purposes 717 | of this License, Derivative Works shall not include works that remain 718 | separable from, or merely link (or bind by name) to the interfaces of, 719 | the Work and Derivative Works thereof. 720 | 721 | "Contribution" shall mean any work of authorship, including 722 | the original version of the Work and any modifications or additions 723 | to that Work or Derivative Works thereof, that is intentionally 724 | submitted to Licensor for inclusion in the Work by the copyright owner 725 | or by an individual or Legal Entity authorized to submit on behalf of 726 | the copyright owner. For the purposes of this definition, "submitted" 727 | means any form of electronic, verbal, or written communication sent 728 | to the Licensor or its representatives, including but not limited to 729 | communication on electronic mailing lists, source code control systems, 730 | and issue tracking systems that are managed by, or on behalf of, the 731 | Licensor for the purpose of discussing and improving the Work, but 732 | excluding communication that is conspicuously marked or otherwise 733 | designated in writing by the copyright owner as "Not a Contribution." 734 | 735 | "Contributor" shall mean Licensor and any individual or Legal Entity 736 | on behalf of whom a Contribution has been received by Licensor and 737 | subsequently incorporated within the Work. 738 | 739 | 2. Grant of Copyright License. Subject to the terms and conditions of 740 | this License, each Contributor hereby grants to You a perpetual, 741 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 742 | copyright license to reproduce, prepare Derivative Works of, 743 | publicly display, publicly perform, sublicense, and distribute the 744 | Work and such Derivative Works in Source or Object form. 745 | 746 | 3. Grant of Patent License. Subject to the terms and conditions of 747 | this License, each Contributor hereby grants to You a perpetual, 748 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 749 | (except as stated in this section) patent license to make, have made, 750 | use, offer to sell, sell, import, and otherwise transfer the Work, 751 | where such license applies only to those patent claims licensable 752 | by such Contributor that are necessarily infringed by their 753 | Contribution(s) alone or by combination of their Contribution(s) 754 | with the Work to which such Contribution(s) was submitted. If You 755 | institute patent litigation against any entity (including a 756 | cross-claim or counterclaim in a lawsuit) alleging that the Work 757 | or a Contribution incorporated within the Work constitutes direct 758 | or contributory patent infringement, then any patent licenses 759 | granted to You under this License for that Work shall terminate 760 | as of the date such litigation is filed. 761 | 762 | 4. Redistribution. You may reproduce and distribute copies of the 763 | Work or Derivative Works thereof in any medium, with or without 764 | modifications, and in Source or Object form, provided that You 765 | meet the following conditions: 766 | 767 | (a) You must give any other recipients of the Work or 768 | Derivative Works a copy of this License; and 769 | 770 | (b) You must cause any modified files to carry prominent notices 771 | stating that You changed the files; and 772 | 773 | (c) You must retain, in the Source form of any Derivative Works 774 | that You distribute, all copyright, patent, trademark, and 775 | attribution notices from the Source form of the Work, 776 | excluding those notices that do not pertain to any part of 777 | the Derivative Works; and 778 | 779 | (d) If the Work includes a "NOTICE" text file as part of its 780 | distribution, then any Derivative Works that You distribute must 781 | include a readable copy of the attribution notices contained 782 | within such NOTICE file, excluding those notices that do not 783 | pertain to any part of the Derivative Works, in at least one 784 | of the following places: within a NOTICE text file distributed 785 | as part of the Derivative Works; within the Source form or 786 | documentation, if provided along with the Derivative Works; or, 787 | within a display generated by the Derivative Works, if and 788 | wherever such third-party notices normally appear. The contents 789 | of the NOTICE file are for informational purposes only and 790 | do not modify the License. You may add Your own attribution 791 | notices within Derivative Works that You distribute, alongside 792 | or as an addendum to the NOTICE text from the Work, provided 793 | that such additional attribution notices cannot be construed 794 | as modifying the License. 795 | 796 | You may add Your own copyright statement to Your modifications and 797 | may provide additional or different license terms and conditions 798 | for use, reproduction, or distribution of Your modifications, or 799 | for any such Derivative Works as a whole, provided Your use, 800 | reproduction, and distribution of the Work otherwise complies with 801 | the conditions stated in this License. 802 | 803 | 5. Submission of Contributions. Unless You explicitly state otherwise, 804 | any Contribution intentionally submitted for inclusion in the Work 805 | by You to the Licensor shall be under the terms and conditions of 806 | this License, without any additional terms or conditions. 807 | Notwithstanding the above, nothing herein shall supersede or modify 808 | the terms of any separate license agreement you may have executed 809 | with Licensor regarding such Contributions. 810 | 811 | 6. Trademarks. This License does not grant permission to use the trade 812 | names, trademarks, service marks, or product names of the Licensor, 813 | except as required for reasonable and customary use in describing the 814 | origin of the Work and reproducing the content of the NOTICE file. 815 | 816 | 7. Disclaimer of Warranty. Unless required by applicable law or 817 | agreed to in writing, Licensor provides the Work (and each 818 | Contributor provides its Contributions) on an "AS IS" BASIS, 819 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 820 | implied, including, without limitation, any warranties or conditions 821 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 822 | PARTICULAR PURPOSE. You are solely responsible for determining the 823 | appropriateness of using or redistributing the Work and assume any 824 | risks associated with Your exercise of permissions under this License. 825 | 826 | 8. Limitation of Liability. In no event and under no legal theory, 827 | whether in tort (including negligence), contract, or otherwise, 828 | unless required by applicable law (such as deliberate and grossly 829 | negligent acts) or agreed to in writing, shall any Contributor be 830 | liable to You for damages, including any direct, indirect, special, 831 | incidental, or consequential damages of any character arising as a 832 | result of this License or out of the use or inability to use the 833 | Work (including but not limited to damages for loss of goodwill, 834 | work stoppage, computer failure or malfunction, or any and all 835 | other commercial damages or losses), even if such Contributor 836 | has been advised of the possibility of such damages. 837 | 838 | 9. Accepting Warranty or Additional Liability. While redistributing 839 | the Work or Derivative Works thereof, You may choose to offer, 840 | and charge a fee for, acceptance of support, warranty, indemnity, 841 | or other liability obligations and/or rights consistent with this 842 | License. However, in accepting such obligations, You may act only 843 | on Your own behalf and on Your sole responsibility, not on behalf 844 | of any other Contributor, and only if You agree to indemnify, 845 | defend, and hold each Contributor harmless for any liability 846 | incurred by, or claims asserted against, such Contributor by reason 847 | of your accepting any such warranty or additional liability. 848 | 849 | END OF TERMS AND CONDITIONS 850 | 851 | APPENDIX: How to apply the Apache License to your work. 852 | 853 | To apply the Apache License to your work, attach the following 854 | boilerplate notice, with the fields enclosed by brackets "[]" 855 | replaced with your own identifying information. (Don't include 856 | the brackets!) The text should be enclosed in the appropriate 857 | comment syntax for the file format. We also recommend that a 858 | file or class name and description of purpose be included on the 859 | same "printed page" as the copyright notice for easier 860 | identification within third-party archives. 861 | 862 | Copyright [yyyy] [name of copyright owner] 863 | 864 | Licensed under the Apache License, Version 2.0 (the "License"); 865 | you may not use this file except in compliance with the License. 866 | You may obtain a copy of the License at 867 | 868 | https://www.apache.org/licenses/LICENSE-2.0 869 | 870 | Unless required by applicable law or agreed to in writing, software 871 | distributed under the License is distributed on an "AS IS" BASIS, 872 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 873 | See the License for the specific language governing permissions and 874 | limitations under the License. 875 | 876 | ******************************************************************************* 877 | tz database 878 | ******************************************************************************* 879 | Unless specified below, all files in the tz code and data (including 880 | this LICENSE file) are in the public domain. 881 | 882 | If the files date.c, newstrftime.3, and strftime.c are present, they 883 | contain material derived from BSD and use the BSD 3-clause license. 884 | 885 | Copyright 1985, 1987, 1988, 1989, 1991 886 | The Regents of the University of California. 887 | All rights reserved. 888 | 889 | Redistribution and use in source and binary forms, with or without 890 | modification, are permitted provided that the following conditions 891 | are met: 892 | 1. Redistributions of source code must retain the above copyright 893 | notice, this list of conditions and the following disclaimer. 894 | 2. Redistributions in binary form must reproduce the above copyright 895 | notice, this list of conditions and the following disclaimer in the 896 | documentation and/or other materials provided with the distribution. 897 | 3. Neither the name of the University nor the names of its contributors 898 | may be used to endorse or promote products derived from this software 899 | without specific prior written permission. 900 | 901 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND 902 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 903 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 904 | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 905 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 906 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 907 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 908 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 909 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 910 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 911 | SUCH DAMAGE. 912 | 913 | -------------------------------------------------------------------------------- /arcore-android-sdk-1.23.0/samples/augmented_image_java/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | defaultConfig { 6 | applicationId "com.google.ar.core.examples.java.augmentedimage" 7 | 8 | // "AR Optional" apps must declare minSdkVersion >= 14. 9 | // "AR Required" apps must declare minSdkVersion >= 24. 10 | minSdkVersion 24 11 | targetSdkVersion 29 12 | versionCode 1 13 | versionName '1.0' 14 | } 15 | compileOptions { 16 | sourceCompatibility JavaVersion.VERSION_1_8 17 | targetCompatibility JavaVersion.VERSION_1_8 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | // ARCore (Google Play Services for AR) library. 29 | implementation 'com.google.ar:core:1.23.0' 30 | 31 | // jbullet library 32 | implementation 'cz.advel.jbullet:jbullet:20101010-1' 33 | 34 | // Obj - a simple Wavefront OBJ file loader 35 | // https://github.com/javagl/Obj 36 | implementation 'de.javagl:obj:0.2.1' 37 | 38 | // Glide - An image loading and caching library for Android 39 | // https://github.com/bumptech/glide 40 | implementation 'com.github.bumptech.glide:glide:4.6.1' 41 | annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1' 42 | 43 | implementation 'androidx.appcompat:appcompat:1.1.0' 44 | implementation 'com.google.android.material:material:1.1.0' 45 | } 46 | -------------------------------------------------------------------------------- /arcore-android-sdk-1.23.0/samples/augmented_image_java/app/src/main/java/com/google/ar/core/examples/java/augmentedimage/AugmentedImageActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.ar.core.examples.java.augmentedimage; 18 | 19 | import android.graphics.Bitmap; 20 | import android.graphics.BitmapFactory; 21 | import android.net.Uri; 22 | import android.opengl.GLES20; 23 | import android.opengl.GLSurfaceView; 24 | import android.os.Bundle; 25 | import android.util.Log; 26 | import android.util.Pair; 27 | import android.view.View; 28 | import android.widget.ImageView; 29 | import android.widget.Toast; 30 | import androidx.appcompat.app.AppCompatActivity; 31 | import com.bumptech.glide.Glide; 32 | import com.bumptech.glide.RequestManager; 33 | import com.google.ar.core.Anchor; 34 | import com.google.ar.core.ArCoreApk; 35 | import com.google.ar.core.AugmentedImage; 36 | import com.google.ar.core.AugmentedImageDatabase; 37 | import com.google.ar.core.Camera; 38 | import com.google.ar.core.Config; 39 | import com.google.ar.core.Frame; 40 | import com.google.ar.core.Pose; 41 | import com.google.ar.core.Session; 42 | import com.google.ar.core.examples.java.augmentedimage.rendering.AugmentedImageRenderer; 43 | import com.google.ar.core.examples.java.common.helpers.CameraPermissionHelper; 44 | import com.google.ar.core.examples.java.common.helpers.DisplayRotationHelper; 45 | import com.google.ar.core.examples.java.common.helpers.FullScreenHelper; 46 | import com.google.ar.core.examples.java.common.helpers.SnackbarHelper; 47 | import com.google.ar.core.examples.java.common.helpers.TrackingStateHelper; 48 | import com.google.ar.core.examples.java.common.rendering.BackgroundRenderer; 49 | import com.google.ar.core.exceptions.CameraNotAvailableException; 50 | import com.google.ar.core.exceptions.UnavailableApkTooOldException; 51 | import com.google.ar.core.exceptions.UnavailableArcoreNotInstalledException; 52 | import com.google.ar.core.exceptions.UnavailableSdkTooOldException; 53 | import com.google.ar.core.exceptions.UnavailableUserDeclinedInstallationException; 54 | import java.io.IOException; 55 | import java.io.InputStream; 56 | import java.util.Collection; 57 | import java.util.HashMap; 58 | import java.util.Map; 59 | import javax.microedition.khronos.egl.EGLConfig; 60 | import javax.microedition.khronos.opengles.GL10; 61 | 62 | /** 63 | * This app extends the HelloAR Java app to include image tracking functionality. 64 | * 65 | *

In this example, we assume all images are static or moving slowly with a large occupation of 66 | * the screen. If the target is actively moving, we recommend to check 67 | * AugmentedImage.getTrackingMethod() and render only when the tracking method equals to 68 | * FULL_TRACKING. See details in Recognize and Augment 70 | * Images. 71 | */ 72 | public class AugmentedImageActivity extends AppCompatActivity implements GLSurfaceView.Renderer { 73 | private static final String TAG = AugmentedImageActivity.class.getSimpleName(); 74 | 75 | // Rendering. The Renderers are created here, and initialized when the GL surface is created. 76 | private GLSurfaceView surfaceView; 77 | private ImageView fitToScanView; 78 | private RequestManager glideRequestManager; 79 | 80 | private boolean installRequested; 81 | 82 | private Session session; 83 | private final SnackbarHelper messageSnackbarHelper = new SnackbarHelper(); 84 | private DisplayRotationHelper displayRotationHelper; 85 | private final TrackingStateHelper trackingStateHelper = new TrackingStateHelper(this); 86 | 87 | private final BackgroundRenderer backgroundRenderer = new BackgroundRenderer(); 88 | private final AugmentedImageRenderer augmentedImageRenderer = new AugmentedImageRenderer(); 89 | 90 | private boolean shouldConfigureSession = false; 91 | 92 | // Augmented image configuration and rendering. 93 | // Load a single image (true) or a pre-generated image database (false). 94 | private final boolean useSingleImage = false; 95 | // Augmented image and its associated center pose anchor, keyed by index of the augmented image in 96 | // the 97 | // database. 98 | private final Map> augmentedImageMap = new HashMap<>(); 99 | private PhysicsController physicsController; 100 | 101 | @Override 102 | protected void onCreate(Bundle savedInstanceState) { 103 | super.onCreate(savedInstanceState); 104 | setContentView(R.layout.activity_main); 105 | surfaceView = findViewById(R.id.surfaceview); 106 | displayRotationHelper = new DisplayRotationHelper(/*context=*/ this); 107 | 108 | // Set up renderer. 109 | surfaceView.setPreserveEGLContextOnPause(true); 110 | surfaceView.setEGLContextClientVersion(2); 111 | surfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); // Alpha used for plane blending. 112 | surfaceView.setRenderer(this); 113 | surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY); 114 | surfaceView.setWillNotDraw(false); 115 | 116 | fitToScanView = findViewById(R.id.image_view_fit_to_scan); 117 | glideRequestManager = Glide.with(this); 118 | glideRequestManager 119 | .load(Uri.parse("file:///android_asset/fit_to_scan.png")) 120 | .into(fitToScanView); 121 | 122 | installRequested = false; 123 | } 124 | 125 | @Override 126 | protected void onDestroy() { 127 | if (session != null) { 128 | // Explicitly close ARCore Session to release native resources. 129 | // Review the API reference for important considerations before calling close() in apps with 130 | // more complicated lifecycle requirements: 131 | // https://developers.google.com/ar/reference/java/arcore/reference/com/google/ar/core/Session#close() 132 | session.close(); 133 | session = null; 134 | } 135 | 136 | super.onDestroy(); 137 | } 138 | 139 | @Override 140 | protected void onResume() { 141 | super.onResume(); 142 | 143 | if (session == null) { 144 | Exception exception = null; 145 | String message = null; 146 | try { 147 | switch (ArCoreApk.getInstance().requestInstall(this, !installRequested)) { 148 | case INSTALL_REQUESTED: 149 | installRequested = true; 150 | return; 151 | case INSTALLED: 152 | break; 153 | } 154 | 155 | // ARCore requires camera permissions to operate. If we did not yet obtain runtime 156 | // permission on Android M and above, now is a good time to ask the user for it. 157 | if (!CameraPermissionHelper.hasCameraPermission(this)) { 158 | CameraPermissionHelper.requestCameraPermission(this); 159 | return; 160 | } 161 | 162 | session = new Session(/* context = */ this); 163 | } catch (UnavailableArcoreNotInstalledException 164 | | UnavailableUserDeclinedInstallationException e) { 165 | message = "Please install ARCore"; 166 | exception = e; 167 | } catch (UnavailableApkTooOldException e) { 168 | message = "Please update ARCore"; 169 | exception = e; 170 | } catch (UnavailableSdkTooOldException e) { 171 | message = "Please update this app"; 172 | exception = e; 173 | } catch (Exception e) { 174 | message = "This device does not support AR"; 175 | exception = e; 176 | } 177 | 178 | if (message != null) { 179 | messageSnackbarHelper.showError(this, message); 180 | Log.e(TAG, "Exception creating session", exception); 181 | return; 182 | } 183 | 184 | shouldConfigureSession = true; 185 | } 186 | 187 | if (shouldConfigureSession) { 188 | configureSession(); 189 | shouldConfigureSession = false; 190 | } 191 | 192 | // Note that order matters - see the note in onPause(), the reverse applies here. 193 | try { 194 | session.resume(); 195 | } catch (CameraNotAvailableException e) { 196 | messageSnackbarHelper.showError(this, "Camera not available. Try restarting the app."); 197 | session = null; 198 | return; 199 | } 200 | surfaceView.onResume(); 201 | displayRotationHelper.onResume(); 202 | 203 | fitToScanView.setVisibility(View.VISIBLE); 204 | } 205 | 206 | @Override 207 | public void onPause() { 208 | super.onPause(); 209 | if (session != null) { 210 | // Note that the order matters - GLSurfaceView is paused first so that it does not try 211 | // to query the session. If Session is paused before GLSurfaceView, GLSurfaceView may 212 | // still call session.update() and get a SessionPausedException. 213 | displayRotationHelper.onPause(); 214 | surfaceView.onPause(); 215 | session.pause(); 216 | } 217 | } 218 | 219 | @Override 220 | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) { 221 | super.onRequestPermissionsResult(requestCode, permissions, results); 222 | if (!CameraPermissionHelper.hasCameraPermission(this)) { 223 | Toast.makeText( 224 | this, "Camera permissions are needed to run this application", Toast.LENGTH_LONG) 225 | .show(); 226 | if (!CameraPermissionHelper.shouldShowRequestPermissionRationale(this)) { 227 | // Permission denied with checking "Do not ask again". 228 | CameraPermissionHelper.launchPermissionSettings(this); 229 | } 230 | finish(); 231 | } 232 | } 233 | 234 | @Override 235 | public void onWindowFocusChanged(boolean hasFocus) { 236 | super.onWindowFocusChanged(hasFocus); 237 | FullScreenHelper.setFullScreenOnWindowFocusChanged(this, hasFocus); 238 | } 239 | 240 | @Override 241 | public void onSurfaceCreated(GL10 gl, EGLConfig config) { 242 | GLES20.glClearColor(0.1f, 0.1f, 0.1f, 1.0f); 243 | 244 | // Prepare the rendering objects. This involves reading shaders, so may throw an IOException. 245 | try { 246 | // Create the texture and pass it to ARCore session to be filled during update(). 247 | backgroundRenderer.createOnGlThread(/*context=*/ this); 248 | augmentedImageRenderer.createOnGlThread(/*context=*/ this); 249 | } catch (IOException e) { 250 | Log.e(TAG, "Failed to read an asset file", e); 251 | } 252 | } 253 | 254 | @Override 255 | public void onSurfaceChanged(GL10 gl, int width, int height) { 256 | displayRotationHelper.onSurfaceChanged(width, height); 257 | GLES20.glViewport(0, 0, width, height); 258 | } 259 | 260 | @Override 261 | public void onDrawFrame(GL10 gl) { 262 | // Clear screen to notify driver it should not load any pixels from previous frame. 263 | GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); 264 | 265 | if (session == null) { 266 | return; 267 | } 268 | // Notify ARCore session that the view size changed so that the perspective matrix and 269 | // the video background can be properly adjusted. 270 | displayRotationHelper.updateSessionIfNeeded(session); 271 | 272 | try { 273 | session.setCameraTextureName(backgroundRenderer.getTextureId()); 274 | 275 | // Obtain the current frame from ARSession. When the configuration is set to 276 | // UpdateMode.BLOCKING (it is by default), this will throttle the rendering to the 277 | // camera framerate. 278 | Frame frame = session.update(); 279 | Camera camera = frame.getCamera(); 280 | 281 | // Keep the screen unlocked while tracking, but allow it to lock when tracking stops. 282 | trackingStateHelper.updateKeepScreenOnFlag(camera.getTrackingState()); 283 | 284 | // If frame is ready, render camera preview image to the GL surface. 285 | backgroundRenderer.draw(frame); 286 | 287 | // Get projection matrix. 288 | float[] projmtx = new float[16]; 289 | camera.getProjectionMatrix(projmtx, 0, 0.1f, 100.0f); 290 | 291 | // Get camera matrix and draw. 292 | float[] viewmtx = new float[16]; 293 | camera.getViewMatrix(viewmtx, 0); 294 | 295 | // Compute lighting from average intensity of the image. 296 | final float[] colorCorrectionRgba = new float[4]; 297 | frame.getLightEstimate().getColorCorrection(colorCorrectionRgba, 0); 298 | 299 | // Visualize augmented images. 300 | drawAugmentedImages(frame, projmtx, viewmtx, colorCorrectionRgba); 301 | } catch (Throwable t) { 302 | // Avoid crashing the application due to unhandled exceptions. 303 | Log.e(TAG, "Exception on the OpenGL thread", t); 304 | } 305 | } 306 | 307 | private void configureSession() { 308 | Config config = new Config(session); 309 | config.setFocusMode(Config.FocusMode.AUTO); 310 | if (!setupAugmentedImageDatabase(config)) { 311 | messageSnackbarHelper.showError(this, "Could not setup augmented image database"); 312 | } 313 | session.configure(config); 314 | } 315 | 316 | private void drawAugmentedImages( 317 | Frame frame, float[] projmtx, float[] viewmtx, float[] colorCorrectionRgba) { 318 | Collection updatedAugmentedImages = 319 | frame.getUpdatedTrackables(AugmentedImage.class); 320 | 321 | // Iterate to update augmentedImageMap, remove elements we cannot draw. 322 | for (AugmentedImage augmentedImage : updatedAugmentedImages) { 323 | switch (augmentedImage.getTrackingState()) { 324 | case PAUSED: 325 | // When an image is in PAUSED state, but the camera is not PAUSED, it has been detected, 326 | // but not yet tracked. 327 | String text = String.format("Detected Image %d", augmentedImage.getIndex()); 328 | messageSnackbarHelper.showMessage(this, text); 329 | break; 330 | 331 | case TRACKING: 332 | // Switch to UI Thread to update View 333 | this.runOnUiThread( 334 | new Runnable() { 335 | @Override 336 | public void run() { 337 | fitToScanView.setVisibility(View.GONE); 338 | } 339 | }); 340 | 341 | // Create a new anchor for newly found images 342 | if (!augmentedImageMap.containsKey(augmentedImage.getIndex())) { 343 | Anchor centerPoseAnchor = augmentedImage.createAnchor(augmentedImage.getCenterPose()); 344 | augmentedImageMap.put( 345 | augmentedImage.getIndex(), Pair.create(augmentedImage, centerPoseAnchor)); 346 | 347 | physicsController = new PhysicsController(this); 348 | } else { 349 | Pose ballPose = physicsController.getBallPose(); 350 | augmentedImageRenderer.updateAndyPose(ballPose); 351 | 352 | 353 | // Use real world gravity, (0, -10, 0), as gravity 354 | // Convert to Physics world coordinate(maze mesh has to be static) 355 | // Use it as a force to move the ball 356 | Pose worldGravityPose = Pose.makeTranslation(0, -10f, 0); 357 | Pose mazeGravityPose = augmentedImage.getCenterPose().inverse().compose(worldGravityPose); 358 | float mazeGravity[] = mazeGravityPose.getTranslation(); 359 | physicsController.applyGravityToBall(mazeGravity); 360 | 361 | physicsController.updatePhysics(); 362 | } 363 | break; 364 | 365 | case STOPPED: 366 | augmentedImageMap.remove(augmentedImage.getIndex()); 367 | break; 368 | 369 | default: 370 | break; 371 | } 372 | } 373 | 374 | // Draw all images in augmentedImageMap 375 | for (Pair pair : augmentedImageMap.values()) { 376 | AugmentedImage augmentedImage = pair.first; 377 | Anchor centerAnchor = augmentedImageMap.get(augmentedImage.getIndex()).second; 378 | switch (augmentedImage.getTrackingState()) { 379 | case TRACKING: 380 | augmentedImageRenderer.draw( 381 | viewmtx, projmtx, augmentedImage, centerAnchor, colorCorrectionRgba); 382 | break; 383 | default: 384 | break; 385 | } 386 | } 387 | } 388 | 389 | private boolean setupAugmentedImageDatabase(Config config) { 390 | AugmentedImageDatabase augmentedImageDatabase; 391 | 392 | // There are two ways to configure an AugmentedImageDatabase: 393 | // 1. Add Bitmap to DB directly 394 | // 2. Load a pre-built AugmentedImageDatabase 395 | // Option 2) has 396 | // * shorter setup time 397 | // * doesn't require images to be packaged in apk. 398 | if (useSingleImage) { 399 | Bitmap augmentedImageBitmap = loadAugmentedImageBitmap(); 400 | if (augmentedImageBitmap == null) { 401 | return false; 402 | } 403 | 404 | augmentedImageDatabase = new AugmentedImageDatabase(session); 405 | augmentedImageDatabase.addImage("image_name", augmentedImageBitmap); 406 | // If the physical size of the image is known, you can instead use: 407 | // augmentedImageDatabase.addImage("image_name", augmentedImageBitmap, widthInMeters); 408 | // This will improve the initial detection speed. ARCore will still actively estimate the 409 | // physical size of the image as it is viewed from multiple viewpoints. 410 | } else { 411 | // This is an alternative way to initialize an AugmentedImageDatabase instance, 412 | // load a pre-existing augmented image database. 413 | try (InputStream is = getAssets().open("sample_database.imgdb")) { 414 | augmentedImageDatabase = AugmentedImageDatabase.deserialize(session, is); 415 | } catch (IOException e) { 416 | Log.e(TAG, "IO exception loading augmented image database.", e); 417 | return false; 418 | } 419 | } 420 | 421 | config.setAugmentedImageDatabase(augmentedImageDatabase); 422 | return true; 423 | } 424 | 425 | private Bitmap loadAugmentedImageBitmap() { 426 | try (InputStream is = getAssets().open("default.jpg")) { 427 | return BitmapFactory.decodeStream(is); 428 | } catch (IOException e) { 429 | Log.e(TAG, "IO exception loading augmented image bitmap.", e); 430 | } 431 | return null; 432 | } 433 | } 434 | -------------------------------------------------------------------------------- /arcore-android-sdk-1.23.0/samples/augmented_image_java/app/src/main/java/com/google/ar/core/examples/java/augmentedimage/PhysicsController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google LLC All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.ar.core.examples.java.augmentedimage; 18 | 19 | import android.content.Context; 20 | import android.util.Log; 21 | 22 | import com.bulletphysics.collision.broadphase.DbvtBroadphase; 23 | import com.bulletphysics.collision.dispatch.CollisionDispatcher; 24 | import com.bulletphysics.collision.dispatch.CollisionObject; 25 | import com.bulletphysics.collision.dispatch.DefaultCollisionConfiguration; 26 | import com.bulletphysics.collision.shapes.BoxShape; 27 | import com.bulletphysics.collision.shapes.BvhTriangleMeshShape; 28 | import com.bulletphysics.collision.shapes.CollisionShape; 29 | import com.bulletphysics.collision.shapes.IndexedMesh; 30 | import com.bulletphysics.collision.shapes.ScaledBvhTriangleMeshShape; 31 | import com.bulletphysics.collision.shapes.SphereShape; 32 | import com.bulletphysics.collision.shapes.StaticPlaneShape; 33 | import com.bulletphysics.collision.shapes.TriangleIndexVertexArray; 34 | import com.bulletphysics.dynamics.DiscreteDynamicsWorld; 35 | import com.bulletphysics.dynamics.RigidBody; 36 | import com.bulletphysics.dynamics.RigidBodyConstructionInfo; 37 | import com.bulletphysics.dynamics.constraintsolver.SequentialImpulseConstraintSolver; 38 | import com.bulletphysics.linearmath.DefaultMotionState; 39 | import com.bulletphysics.linearmath.Transform; 40 | import com.bulletphysics.util.ObjectArrayList; 41 | import com.google.ar.core.Pose; 42 | 43 | import java.io.IOException; 44 | import java.io.InputStream; 45 | import java.nio.ByteBuffer; 46 | import java.nio.ByteOrder; 47 | import java.nio.FloatBuffer; 48 | import java.nio.IntBuffer; 49 | 50 | import javax.vecmath.Quat4f; 51 | import javax.vecmath.Vector3f; 52 | 53 | import de.javagl.obj.Obj; 54 | import de.javagl.obj.ObjData; 55 | import de.javagl.obj.ObjReader; 56 | import de.javagl.obj.ObjUtils; 57 | 58 | import static com.bulletphysics.collision.dispatch.CollisionObject.DISABLE_DEACTIVATION; 59 | 60 | 61 | public class PhysicsController { 62 | 63 | private static final String TAG = "PhysicsController"; 64 | 65 | private DiscreteDynamicsWorld dynamicsWorld; 66 | private SequentialImpulseConstraintSolver solver; 67 | private RigidBody ballRB; 68 | private long previous_time; 69 | private Context context; 70 | private final float MAZE_SCALE = 0.02f; 71 | private final float MAZE_SCALE_Y_EXTRA = 0.1f; 72 | 73 | public PhysicsController(Context activity) { 74 | context = activity; 75 | initialize(); 76 | } 77 | 78 | public void initialize() { 79 | // Initialize Bullet Physics Engine 80 | DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration(); 81 | CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration); 82 | DbvtBroadphase broadphase = new DbvtBroadphase(); 83 | solver = new SequentialImpulseConstraintSolver(); 84 | 85 | dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration); 86 | 87 | // Override default gravity, which would be (0, -10, 0) 88 | // Because I want to manually control the gravity based on maze's Pose 89 | dynamicsWorld.setGravity(new Vector3f(0f, 0f, 0f)); 90 | 91 | AddMazeRigidBody(); 92 | AddBallRigidBody(); 93 | 94 | previous_time = java.lang.System.currentTimeMillis(); 95 | } 96 | 97 | private void AddBallRigidBody() { 98 | // Read comments in AddMazeRigidBody to see why we choose 0.13 for Ball's radius 99 | CollisionShape ballShape = new SphereShape(0.13f); 100 | 101 | Transform ballTransform = new Transform(); 102 | ballTransform.setIdentity(); 103 | ballTransform.origin.set(0, 0.5f, 0); // Slightly raise the ball at the beginning 104 | 105 | DefaultMotionState ballMotionState = new DefaultMotionState(ballTransform); 106 | RigidBodyConstructionInfo ballRBInfo = new RigidBodyConstructionInfo( 107 | 0.2f, ballMotionState, ballShape, new Vector3f(0, 0, 0)); 108 | 109 | ballRB = new RigidBody(ballRBInfo); 110 | ballRB.setActivationState(DISABLE_DEACTIVATION); 111 | 112 | dynamicsWorld.addRigidBody(ballRB); 113 | } 114 | 115 | // 116 | // Load GreenMaze.obj and uses the vertices info inside as mesh for the maze 117 | // Because GreenMaze.obj doesn't have a bottom, so it won't catch the ball 118 | // We'll add a plane of infinite size at Y=0, as bottom. 119 | // 120 | private void AddMazeRigidBody() { 121 | IndexedMesh mazeMesh = loadMazeMesh(); 122 | if (mazeMesh == null) 123 | return; 124 | 125 | // 126 | // Maze rigid body has two parts 127 | // 1. The maze mesh, centered around origin 128 | // 2. A plane, at origin, as bottom of maze 129 | // 130 | // For the maze mesh, we'll use static mesh shape 131 | // This is the way to work with concave shape mesh in jBullet. 132 | // In jBullet, static mesh cannot move, so I'll only move the ball. 133 | // 134 | // Here're two special design in Physics calculation 135 | // 1) All things are in "maze" 's coordinate space. 136 | // - To do so, Maze is centered at origin. bottom at Y=0. 137 | // - When we add force to ball at runtime, we also convert gravity to Maze's space. 138 | // 2) All size are a good size for jBullet's simulation. 139 | // Which means take tips from here https://facultyfp.salisbury.edu/despickler/personal/Resources/GraphicsExampleCodeGLSL_SFML/InterfaceDoc/Bullet/Bullet_User_Manual.pdf 140 | // Particularly, avoid very small and very large shape => Keep triangles in [0.2, 10] size range. 141 | // In order to do so, we'll scale the maze to 0.02 scale on X, Y, Z, and then additional 0.1 on Y. 142 | // (Why Y is 0.002 instead of 0.02? Because we want to lower the height of maze) 143 | // 3) Reduce Maze wall height, to 1/10 it's original height (Slightly higher than radius of ball) 144 | // , so we can see ball when the ball reaches the bottom. 145 | // 146 | // Facts of the maze mesh: 147 | // - The maze's original size is (492, 120, 492) in (x, y, z) order. 148 | // - The maze's gap allows movement of a ball at about 13 diameter. 149 | // After scale, 150 | // - the maze's size in physics simulation is (9.84, 0.24, 9.84) 151 | // - which allows ball of 0.26 diameter (0.13 radius) 152 | // 153 | 154 | // Maze part 1, triangle mesh 155 | TriangleIndexVertexArray mazeMashVertexArray = new TriangleIndexVertexArray(); 156 | mazeMashVertexArray.addIndexedMesh(mazeMesh); 157 | 158 | BvhTriangleMeshShape mazeShape = new BvhTriangleMeshShape(mazeMashVertexArray, false); 159 | ScaledBvhTriangleMeshShape scaledMazeShape = new ScaledBvhTriangleMeshShape( 160 | mazeShape, new Vector3f(MAZE_SCALE, MAZE_SCALE * MAZE_SCALE_Y_EXTRA, MAZE_SCALE)); 161 | 162 | // For static concave mesh shape, Transform has to be identity 163 | Transform mazeTransform = new Transform(); 164 | mazeTransform.setIdentity(); 165 | 166 | DefaultMotionState mazeMotionState = new DefaultMotionState(mazeTransform); 167 | RigidBodyConstructionInfo mazeRBInfo = new RigidBodyConstructionInfo( 168 | 0, mazeMotionState, scaledMazeShape, new Vector3f(0, 0, 0)); 169 | mazeRBInfo.friction = 0.1f; 170 | RigidBody mazeRB = new RigidBody(mazeRBInfo); 171 | dynamicsWorld.addRigidBody(mazeRB); // add the body to the dynamics world 172 | 173 | 174 | // Maze part 2, plane as bottom 175 | CollisionShape fakeGroundShape = new StaticPlaneShape( 176 | new Vector3f(0, 1.0f, 0), 177 | 0); 178 | 179 | Transform fakeGroundTransform = new Transform(); 180 | fakeGroundTransform.setIdentity(); 181 | fakeGroundTransform.origin.set(0, 0, 0); 182 | 183 | DefaultMotionState fakeGroundMotionState = new DefaultMotionState(fakeGroundTransform); 184 | RigidBodyConstructionInfo fakeGroundRBInfo = new RigidBodyConstructionInfo( 185 | 0.0f, fakeGroundMotionState, fakeGroundShape, new Vector3f(0, 0, 0)); 186 | fakeGroundRBInfo.friction = 0.1f; 187 | RigidBody fakeGroundRB = new RigidBody(fakeGroundRBInfo); 188 | dynamicsWorld.addRigidBody(fakeGroundRB); 189 | } 190 | 191 | private IndexedMesh loadMazeMesh() { 192 | IndexedMesh indexedMesh = null; 193 | 194 | try { 195 | InputStream objInputStream = context.getAssets().open("GreenMaze.obj"); 196 | Obj obj = ObjReader.read(objInputStream); 197 | obj = ObjUtils.convertToRenderable(obj); 198 | 199 | IntBuffer wideIndices = ObjData.getFaceVertexIndices(obj, 3); 200 | FloatBuffer vertices = ObjData.getVertices(obj); 201 | 202 | // Usage reference: 203 | // https://github.com/LapisSea/OpenGL-Bullet-engine/blob/08848ea0e42c08cb43d5bb2fd3722cc1d1fa0b80/src/com/lapissea/opengl/util/UtilM.java 204 | indexedMesh = new IndexedMesh(); 205 | indexedMesh.numTriangles = wideIndices.limit() / 3; 206 | indexedMesh.triangleIndexBase = ByteBuffer.allocateDirect(wideIndices.limit()*4).order(ByteOrder.nativeOrder()); 207 | indexedMesh.triangleIndexBase.asIntBuffer().put(wideIndices); 208 | indexedMesh.triangleIndexStride = 3 * 4; 209 | indexedMesh.numVertices = vertices.limit(); 210 | indexedMesh.vertexBase = ByteBuffer.allocateDirect(vertices.limit()*4).order(ByteOrder.nativeOrder()); 211 | 212 | // 213 | // Get the mesh min, max and center, so we can recenter vertices 214 | // 215 | float minX = Float.MAX_VALUE; 216 | float minY = Float.MAX_VALUE; 217 | float minZ = Float.MAX_VALUE; 218 | float maxX = -Float.MAX_VALUE; 219 | float maxY = -Float.MAX_VALUE; 220 | float maxZ = -Float.MAX_VALUE; 221 | 222 | for (int i = 0; i < vertices.limit(); i = i + 3) { 223 | float x = vertices.get(i); 224 | float y = vertices.get(i+1); 225 | float z = vertices.get(i+2); 226 | minX = Float.min(x, minX); 227 | minY = Float.min(y, minY); 228 | minZ = Float.min(z, minZ); 229 | maxX = Float.max(x, maxX); 230 | maxY = Float.max(y, maxY); 231 | maxZ = Float.max(z, maxZ); 232 | } 233 | 234 | float centerX = (minX + maxX) / 2.0f; 235 | float centerZ = (minZ + maxZ) / 2.0f; 236 | 237 | // 238 | // Re-center vertices, put them into indexedMesh 239 | // 240 | FloatBuffer fbVertex = indexedMesh.vertexBase.asFloatBuffer(); 241 | for (int i = 0; i < vertices.limit(); i = i + 3) { 242 | float x = vertices.get(i); 243 | float y = vertices.get(i+1); 244 | float z = vertices.get(i+2); 245 | x = x - centerX; // x at [-1/2 * sizeX, 1/2 * sizeX] 246 | y = y - minY; // y at [0, sizeY] 247 | z = z - centerZ; // z at [-1/2 * sizeZ, 1/2 * sizeZ] 248 | 249 | fbVertex.put(x); 250 | fbVertex.put(y); 251 | fbVertex.put(z); 252 | } 253 | 254 | indexedMesh.vertexStride = 3 * 4; 255 | } catch (IOException e) { 256 | Log.e(TAG, "Failed to read an asset file GreenMaze.obj", e); 257 | } 258 | 259 | return indexedMesh; 260 | } 261 | 262 | 263 | public void updatePhysics() { 264 | long current_time = java.lang.System.currentTimeMillis(); 265 | 266 | // stepSimulation takes deltaTime in the unit of seconds 267 | dynamicsWorld.stepSimulation((current_time - previous_time) / 1000.0f); 268 | previous_time = current_time; 269 | 270 | //printDebugInfo(); 271 | } 272 | 273 | private void printDebugInfo() { 274 | // 275 | // Help print out debug info 276 | // 277 | int numObj = dynamicsWorld.getNumCollisionObjects(); 278 | ObjectArrayList objArray = dynamicsWorld.getCollisionObjectArray(); 279 | for (int j = 0; j < numObj; ++j) { 280 | CollisionObject collisionObj = objArray.get(j); 281 | RigidBody body = RigidBody.upcast(collisionObj); 282 | Transform worldTransform = new Transform(); 283 | int state = collisionObj.getActivationState(); 284 | if (body != null && body.getMotionState() != null) { 285 | body.getMotionState().getWorldTransform(worldTransform); 286 | } else { 287 | collisionObj.getWorldTransform(worldTransform); 288 | } 289 | 290 | Log.d(TAG, 291 | String.format("obj %d status [%d] World transform %f, %f, %f", 292 | j, state, 293 | worldTransform.origin.x, worldTransform.origin.y, worldTransform.origin.z)); 294 | } 295 | } 296 | 297 | // Get the pose on Ball, in Maze's coordinate space 298 | // - With centered the vertices in Maze, (0, 0, 0) is the center of the maze 299 | // - Though we scaled maze in physics simulation, the Pose returned here is not scaled. 300 | public Pose getBallPose() { 301 | Transform ballTransform = new Transform(); 302 | ballRB.getMotionState().getWorldTransform(ballTransform); 303 | 304 | Quat4f rot = new Quat4f(); 305 | ballTransform.getRotation(rot); 306 | 307 | // Use MAZE_SCALE to convert size from physical world size to Maze's original size 308 | // Because in display size, Sceneform is actually dealing with original size of Maze 309 | float translation[] = {ballTransform.origin.x / MAZE_SCALE, ballTransform.origin.y / MAZE_SCALE, ballTransform.origin.z/ MAZE_SCALE}; 310 | float rotation[] = {rot.x, rot.y, rot.z, rot.w}; 311 | 312 | Pose ballPose = new Pose(translation, rotation); 313 | return ballPose; 314 | } 315 | 316 | public void applyGravityToBall(float[] mazeGravity) { 317 | // Log.d(TAG, 318 | // String.format("Apply force to ball %f, %f, %f", 319 | // mazeGravity[0], mazeGravity [1], mazeGravity[2])); 320 | 321 | ballRB.applyCentralForce(new Vector3f(mazeGravity)); 322 | } 323 | } 324 | -------------------------------------------------------------------------------- /arcore-android-sdk-1.23.0/samples/augmented_image_java/app/src/main/java/com/google/ar/core/examples/java/augmentedimage/rendering/AugmentedImageRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.ar.core.examples.java.augmentedimage.rendering; 17 | 18 | import android.content.Context; 19 | import com.google.ar.core.Anchor; 20 | import com.google.ar.core.AugmentedImage; 21 | import com.google.ar.core.Pose; 22 | import com.google.ar.core.examples.java.common.rendering.ObjectRenderer; 23 | import com.google.ar.core.examples.java.common.rendering.ObjectRenderer.BlendMode; 24 | import java.io.IOException; 25 | 26 | /** Renders an augmented image. */ 27 | public class AugmentedImageRenderer { 28 | private static final String TAG = "AugmentedImageRenderer"; 29 | 30 | private static final float TINT_INTENSITY = 0.1f; 31 | private static final float TINT_ALPHA = 1.0f; 32 | private static final int[] TINT_COLORS_HEX = { 33 | 0x000000, 0xF44336, 0xE91E63, 0x9C27B0, 0x673AB7, 0x3F51B5, 0x2196F3, 0x03A9F4, 0x00BCD4, 34 | 0x009688, 0x4CAF50, 0x8BC34A, 0xCDDC39, 0xFFEB3B, 0xFFC107, 0xFF9800, 35 | }; 36 | 37 | private final ObjectRenderer imageFrameUpperLeft = new ObjectRenderer(); 38 | private final ObjectRenderer imageFrameUpperRight = new ObjectRenderer(); 39 | private final ObjectRenderer imageFrameLowerLeft = new ObjectRenderer(); 40 | private final ObjectRenderer imageFrameLowerRight = new ObjectRenderer(); 41 | 42 | private final ObjectRenderer mazeRenderer = new ObjectRenderer(); 43 | private final ObjectRenderer andyRenderer = new ObjectRenderer(); 44 | 45 | // Create a new pose for the Andy 46 | private Pose andyPose = Pose.IDENTITY; 47 | 48 | public AugmentedImageRenderer() {} 49 | 50 | public void createOnGlThread(Context context) throws IOException { 51 | 52 | mazeRenderer.createOnGlThread( 53 | context, "models/green-maze/GreenMaze.obj", "models/frame_base.png"); 54 | mazeRenderer.setMaterialProperties(0.0f, 3.5f, 1.0f, 6.0f); 55 | 56 | andyRenderer.createOnGlThread( 57 | context, "models/andy.obj", "models/andy.png"); 58 | andyRenderer.setMaterialProperties(0.0f, 3.5f, 1.0f, 6.0f); 59 | } 60 | 61 | public void draw( 62 | float[] viewMatrix, 63 | float[] projectionMatrix, 64 | AugmentedImage augmentedImage, 65 | Anchor centerAnchor, 66 | float[] colorCorrectionRgba) { 67 | float[] tintColor = 68 | convertHexToColor(TINT_COLORS_HEX[augmentedImage.getIndex() % TINT_COLORS_HEX.length]); 69 | 70 | final float mazeEdgeSize = 492.65f; // Magic number of maze size 71 | final float maxImageEdgeSize = Math.max(augmentedImage.getExtentX(), augmentedImage.getExtentZ()); // Get largest detected image edge size 72 | 73 | Pose anchorPose = centerAnchor.getPose(); 74 | 75 | float mazeScaleFactor = maxImageEdgeSize / mazeEdgeSize; // scale to set Maze to image size 76 | float[] modelMatrix = new float[16]; 77 | 78 | // OpenGL Matrix operation is in the order: Scale, rotation and Translation 79 | // So the manual adjustment is after scale 80 | // The 251.3f and 129.0f is magic number from the maze obj file 81 | // You mustWe need to do this adjustment because the maze OBJobj file 82 | // is not centered around origin. Normally when you 83 | // work with your own model, you don't have this problem. 84 | Pose mazeModelLocalOffset = Pose.makeTranslation( 85 | -251.3f * mazeScaleFactor, 86 | 0.0f, 87 | 129.0f * mazeScaleFactor); 88 | anchorPose.compose(mazeModelLocalOffset).toMatrix(modelMatrix, 0); 89 | mazeRenderer.updateModelMatrix(modelMatrix, mazeScaleFactor, mazeScaleFactor/10.0f, mazeScaleFactor); // This line relies on a change in ObjectRenderer.updateModelMatrix later in this codelab. 90 | mazeRenderer.draw(viewMatrix, projectionMatrix, colorCorrectionRgba, tintColor); 91 | 92 | // Adjust the Andy's rendering position 93 | // The Andy's pose is at the maze's vertex's coordinate 94 | Pose andyPoseInImageSpace = Pose.makeTranslation( 95 | andyPose.tx() * mazeScaleFactor, 96 | andyPose.ty() * mazeScaleFactor, 97 | andyPose.tz() * mazeScaleFactor); 98 | 99 | anchorPose.compose(andyPoseInImageSpace).toMatrix(modelMatrix, 0); 100 | andyRenderer.updateModelMatrix(modelMatrix, 0.05f); 101 | andyRenderer.draw(viewMatrix, projectionMatrix, colorCorrectionRgba, tintColor); 102 | 103 | } 104 | 105 | public void updateAndyPose(Pose pose) { 106 | andyPose = pose; 107 | } 108 | 109 | private static float[] convertHexToColor(int colorHex) { 110 | // colorHex is in 0xRRGGBB format 111 | float red = ((colorHex & 0xFF0000) >> 16) / 255.0f * TINT_INTENSITY; 112 | float green = ((colorHex & 0x00FF00) >> 8) / 255.0f * TINT_INTENSITY; 113 | float blue = (colorHex & 0x0000FF) / 255.0f * TINT_INTENSITY; 114 | return new float[] {red, green, blue, TINT_ALPHA}; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /arcore-android-sdk-1.23.0/samples/augmented_image_java/app/src/main/java/com/google/ar/core/examples/java/common/rendering/ObjectRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.ar.core.examples.java.common.rendering; 17 | 18 | import android.content.Context; 19 | import android.graphics.Bitmap; 20 | import android.graphics.BitmapFactory; 21 | import android.opengl.GLES20; 22 | import android.opengl.GLUtils; 23 | import android.opengl.Matrix; 24 | import de.javagl.obj.Obj; 25 | import de.javagl.obj.ObjData; 26 | import de.javagl.obj.ObjReader; 27 | import de.javagl.obj.ObjUtils; 28 | import java.io.IOException; 29 | import java.io.InputStream; 30 | import java.nio.ByteBuffer; 31 | import java.nio.ByteOrder; 32 | import java.nio.FloatBuffer; 33 | import java.nio.IntBuffer; 34 | import java.nio.ShortBuffer; 35 | import java.util.Map; 36 | import java.util.TreeMap; 37 | 38 | /** Renders an object loaded from an OBJ file in OpenGL. */ 39 | public class ObjectRenderer { 40 | private static final String TAG = ObjectRenderer.class.getSimpleName(); 41 | 42 | /** 43 | * Blend mode. 44 | * 45 | * @see #setBlendMode(BlendMode) 46 | */ 47 | public enum BlendMode { 48 | /** Multiplies the destination color by the source alpha, without z-buffer writing. */ 49 | Shadow, 50 | /** Normal alpha blending with z-buffer writing. */ 51 | AlphaBlending 52 | } 53 | 54 | // Shader names. 55 | private static final String VERTEX_SHADER_NAME = "shaders/ar_object.vert"; 56 | private static final String FRAGMENT_SHADER_NAME = "shaders/ar_object.frag"; 57 | 58 | private static final int COORDS_PER_VERTEX = 3; 59 | private static final float[] DEFAULT_COLOR = new float[] {0f, 0f, 0f, 0f}; 60 | 61 | // Note: the last component must be zero to avoid applying the translational part of the matrix. 62 | private static final float[] LIGHT_DIRECTION = new float[] {0.250f, 0.866f, 0.433f, 0.0f}; 63 | private final float[] viewLightDirection = new float[4]; 64 | 65 | // Object vertex buffer variables. 66 | private int vertexBufferId; 67 | private int verticesBaseAddress; 68 | private int texCoordsBaseAddress; 69 | private int normalsBaseAddress; 70 | private int indexBufferId; 71 | private int indexCount; 72 | 73 | private int program; 74 | private final int[] textures = new int[1]; 75 | 76 | // Shader location: model view projection matrix. 77 | private int modelViewUniform; 78 | private int modelViewProjectionUniform; 79 | 80 | // Shader location: object attributes. 81 | private int positionAttribute; 82 | private int normalAttribute; 83 | private int texCoordAttribute; 84 | 85 | // Shader location: texture sampler. 86 | private int textureUniform; 87 | 88 | // Shader location: environment properties. 89 | private int lightingParametersUniform; 90 | 91 | // Shader location: material properties. 92 | private int materialParametersUniform; 93 | 94 | // Shader location: color correction property. 95 | private int colorCorrectionParameterUniform; 96 | 97 | // Shader location: object color property (to change the primary color of the object). 98 | private int colorUniform; 99 | 100 | // Shader location: depth texture. 101 | private int depthTextureUniform; 102 | 103 | // Shader location: transform to depth uvs. 104 | private int depthUvTransformUniform; 105 | 106 | // Shader location: the aspect ratio of the depth texture. 107 | private int depthAspectRatioUniform; 108 | 109 | private BlendMode blendMode = null; 110 | 111 | // Temporary matrices allocated here to reduce number of allocations for each frame. 112 | private final float[] modelMatrix = new float[16]; 113 | private final float[] modelViewMatrix = new float[16]; 114 | private final float[] modelViewProjectionMatrix = new float[16]; 115 | 116 | // Set some default material properties to use for lighting. 117 | private float ambient = 0.3f; 118 | private float diffuse = 1.0f; 119 | private float specular = 1.0f; 120 | private float specularPower = 6.0f; 121 | 122 | // Depth-for-Occlusion parameters. 123 | private static final String USE_DEPTH_FOR_OCCLUSION_SHADER_FLAG = "USE_DEPTH_FOR_OCCLUSION"; 124 | private boolean useDepthForOcclusion = false; 125 | private float depthAspectRatio = 0.0f; 126 | private float[] uvTransform = null; 127 | private int depthTextureId; 128 | 129 | /** 130 | * Creates and initializes OpenGL resources needed for rendering the model. 131 | * 132 | * @param context Context for loading the shader and below-named model and texture assets. 133 | * @param objAssetName Name of the OBJ file containing the model geometry. 134 | * @param diffuseTextureAssetName Name of the PNG file containing the diffuse texture map. 135 | */ 136 | public void createOnGlThread(Context context, String objAssetName, String diffuseTextureAssetName) 137 | throws IOException { 138 | // Compiles and loads the shader based on the current configuration. 139 | compileAndLoadShaderProgram(context); 140 | 141 | // Read the texture. 142 | Bitmap textureBitmap = 143 | BitmapFactory.decodeStream(context.getAssets().open(diffuseTextureAssetName)); 144 | 145 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0); 146 | GLES20.glGenTextures(textures.length, textures, 0); 147 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); 148 | 149 | GLES20.glTexParameteri( 150 | GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_LINEAR); 151 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); 152 | GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0); 153 | GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D); 154 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); 155 | 156 | textureBitmap.recycle(); 157 | 158 | ShaderUtil.checkGLError(TAG, "Texture loading"); 159 | 160 | // Read the obj file. 161 | InputStream objInputStream = context.getAssets().open(objAssetName); 162 | Obj obj = ObjReader.read(objInputStream); 163 | 164 | // Prepare the Obj so that its structure is suitable for 165 | // rendering with OpenGL: 166 | // 1. Triangulate it 167 | // 2. Make sure that texture coordinates are not ambiguous 168 | // 3. Make sure that normals are not ambiguous 169 | // 4. Convert it to single-indexed data 170 | obj = ObjUtils.convertToRenderable(obj); 171 | 172 | // OpenGL does not use Java arrays. ByteBuffers are used instead to provide data in a format 173 | // that OpenGL understands. 174 | 175 | // Obtain the data from the OBJ, as direct buffers: 176 | IntBuffer wideIndices = ObjData.getFaceVertexIndices(obj, 3); 177 | FloatBuffer vertices = ObjData.getVertices(obj); 178 | FloatBuffer texCoords = ObjData.getTexCoords(obj, 2); 179 | FloatBuffer normals = ObjData.getNormals(obj); 180 | 181 | // Convert int indices to shorts for GL ES 2.0 compatibility 182 | ShortBuffer indices = 183 | ByteBuffer.allocateDirect(2 * wideIndices.limit()) 184 | .order(ByteOrder.nativeOrder()) 185 | .asShortBuffer(); 186 | while (wideIndices.hasRemaining()) { 187 | indices.put((short) wideIndices.get()); 188 | } 189 | indices.rewind(); 190 | 191 | int[] buffers = new int[2]; 192 | GLES20.glGenBuffers(2, buffers, 0); 193 | vertexBufferId = buffers[0]; 194 | indexBufferId = buffers[1]; 195 | 196 | // Load vertex buffer 197 | verticesBaseAddress = 0; 198 | texCoordsBaseAddress = verticesBaseAddress + 4 * vertices.limit(); 199 | normalsBaseAddress = texCoordsBaseAddress + 4 * texCoords.limit(); 200 | final int totalBytes = normalsBaseAddress + 4 * normals.limit(); 201 | 202 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vertexBufferId); 203 | GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, totalBytes, null, GLES20.GL_STATIC_DRAW); 204 | GLES20.glBufferSubData( 205 | GLES20.GL_ARRAY_BUFFER, verticesBaseAddress, 4 * vertices.limit(), vertices); 206 | GLES20.glBufferSubData( 207 | GLES20.GL_ARRAY_BUFFER, texCoordsBaseAddress, 4 * texCoords.limit(), texCoords); 208 | GLES20.glBufferSubData( 209 | GLES20.GL_ARRAY_BUFFER, normalsBaseAddress, 4 * normals.limit(), normals); 210 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); 211 | 212 | // Load index buffer 213 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, indexBufferId); 214 | indexCount = indices.limit(); 215 | GLES20.glBufferData( 216 | GLES20.GL_ELEMENT_ARRAY_BUFFER, 2 * indexCount, indices, GLES20.GL_STATIC_DRAW); 217 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); 218 | 219 | ShaderUtil.checkGLError(TAG, "OBJ buffer load"); 220 | 221 | Matrix.setIdentityM(modelMatrix, 0); 222 | } 223 | 224 | /** 225 | * Selects the blending mode for rendering. 226 | * 227 | * @param blendMode The blending mode. Null indicates no blending (opaque rendering). 228 | */ 229 | public void setBlendMode(BlendMode blendMode) { 230 | this.blendMode = blendMode; 231 | } 232 | 233 | /** 234 | * Specifies whether to use the depth texture to perform depth-based occlusion of virtual objects 235 | * from real-world geometry. 236 | * 237 | *

This function is a no-op if the value provided is the same as what is already set. If the 238 | * value changes, this function will recompile and reload the shader program to either 239 | * enable/disable depth-based occlusion. NOTE: recompilation of the shader is inefficient. This 240 | * code could be optimized to precompile both versions of the shader. 241 | * 242 | * @param context Context for loading the shader. 243 | * @param useDepthForOcclusion Specifies whether to use the depth texture to perform occlusion 244 | * during rendering of virtual objects. 245 | */ 246 | public void setUseDepthForOcclusion(Context context, boolean useDepthForOcclusion) 247 | throws IOException { 248 | if (this.useDepthForOcclusion == useDepthForOcclusion) { 249 | return; // No change, does nothing. 250 | } 251 | 252 | // Toggles the occlusion rendering mode and recompiles the shader. 253 | this.useDepthForOcclusion = useDepthForOcclusion; 254 | compileAndLoadShaderProgram(context); 255 | } 256 | 257 | private void compileAndLoadShaderProgram(Context context) throws IOException { 258 | // Compiles and loads the shader program based on the selected mode. 259 | Map defineValuesMap = new TreeMap<>(); 260 | defineValuesMap.put(USE_DEPTH_FOR_OCCLUSION_SHADER_FLAG, useDepthForOcclusion ? 1 : 0); 261 | 262 | final int vertexShader = 263 | ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME); 264 | final int fragmentShader = 265 | ShaderUtil.loadGLShader( 266 | TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME, defineValuesMap); 267 | 268 | program = GLES20.glCreateProgram(); 269 | GLES20.glAttachShader(program, vertexShader); 270 | GLES20.glAttachShader(program, fragmentShader); 271 | GLES20.glLinkProgram(program); 272 | GLES20.glUseProgram(program); 273 | 274 | ShaderUtil.checkGLError(TAG, "Program creation"); 275 | 276 | modelViewUniform = GLES20.glGetUniformLocation(program, "u_ModelView"); 277 | modelViewProjectionUniform = GLES20.glGetUniformLocation(program, "u_ModelViewProjection"); 278 | 279 | positionAttribute = GLES20.glGetAttribLocation(program, "a_Position"); 280 | normalAttribute = GLES20.glGetAttribLocation(program, "a_Normal"); 281 | texCoordAttribute = GLES20.glGetAttribLocation(program, "a_TexCoord"); 282 | 283 | textureUniform = GLES20.glGetUniformLocation(program, "u_Texture"); 284 | 285 | lightingParametersUniform = GLES20.glGetUniformLocation(program, "u_LightingParameters"); 286 | materialParametersUniform = GLES20.glGetUniformLocation(program, "u_MaterialParameters"); 287 | colorCorrectionParameterUniform = 288 | GLES20.glGetUniformLocation(program, "u_ColorCorrectionParameters"); 289 | colorUniform = GLES20.glGetUniformLocation(program, "u_ObjColor"); 290 | 291 | // Occlusion Uniforms. 292 | if (useDepthForOcclusion) { 293 | depthTextureUniform = GLES20.glGetUniformLocation(program, "u_DepthTexture"); 294 | depthUvTransformUniform = GLES20.glGetUniformLocation(program, "u_DepthUvTransform"); 295 | depthAspectRatioUniform = GLES20.glGetUniformLocation(program, "u_DepthAspectRatio"); 296 | } 297 | 298 | ShaderUtil.checkGLError(TAG, "Program parameters"); 299 | } 300 | 301 | /** 302 | * Updates the object model matrix and applies scaling. 303 | * 304 | * @param modelMatrix A 4x4 model-to-world transformation matrix, stored in column-major order. 305 | * @param scaleFactor A separate scaling factor to apply before the {@code modelMatrix}. 306 | * @see android.opengl.Matrix 307 | */ 308 | public void updateModelMatrix(float[] modelMatrix, float scaleFactor) { 309 | float[] scaleMatrix = new float[16]; 310 | Matrix.setIdentityM(scaleMatrix, 0); 311 | scaleMatrix[0] = scaleFactor; 312 | scaleMatrix[5] = scaleFactor; 313 | scaleMatrix[10] = scaleFactor; 314 | Matrix.multiplyMM(this.modelMatrix, 0, modelMatrix, 0, scaleMatrix, 0); 315 | } 316 | 317 | public void updateModelMatrix(float[] modelMatrix, float scaleFactorX, float scaleFactorY, float scaleFactorZ) { 318 | float[] scaleMatrix = new float[16]; 319 | Matrix.setIdentityM(scaleMatrix, 0); 320 | scaleMatrix[0] = scaleFactorX; 321 | scaleMatrix[5] = scaleFactorY; 322 | scaleMatrix[10] = scaleFactorZ; 323 | Matrix.multiplyMM(this.modelMatrix, 0, modelMatrix, 0, scaleMatrix, 0); 324 | } 325 | 326 | /** 327 | * Sets the surface characteristics of the rendered model. 328 | * 329 | * @param ambient Intensity of non-directional surface illumination. 330 | * @param diffuse Diffuse (matte) surface reflectivity. 331 | * @param specular Specular (shiny) surface reflectivity. 332 | * @param specularPower Surface shininess. Larger values result in a smaller, sharper specular 333 | * highlight. 334 | */ 335 | public void setMaterialProperties( 336 | float ambient, float diffuse, float specular, float specularPower) { 337 | this.ambient = ambient; 338 | this.diffuse = diffuse; 339 | this.specular = specular; 340 | this.specularPower = specularPower; 341 | } 342 | 343 | /** 344 | * Draws the model. 345 | * 346 | * @param cameraView A 4x4 view matrix, in column-major order. 347 | * @param cameraPerspective A 4x4 projection matrix, in column-major order. 348 | * @param colorCorrectionRgba Illumination intensity. Combined with diffuse and specular material 349 | * properties. 350 | * @see #setBlendMode(BlendMode) 351 | * @see #updateModelMatrix(float[], float) 352 | * @see #setMaterialProperties(float, float, float, float) 353 | * @see android.opengl.Matrix 354 | */ 355 | public void draw(float[] cameraView, float[] cameraPerspective, float[] colorCorrectionRgba) { 356 | draw(cameraView, cameraPerspective, colorCorrectionRgba, DEFAULT_COLOR); 357 | } 358 | 359 | public void draw( 360 | float[] cameraView, 361 | float[] cameraPerspective, 362 | float[] colorCorrectionRgba, 363 | float[] objColor) { 364 | 365 | ShaderUtil.checkGLError(TAG, "Before draw"); 366 | 367 | // Build the ModelView and ModelViewProjection matrices 368 | // for calculating object position and light. 369 | Matrix.multiplyMM(modelViewMatrix, 0, cameraView, 0, modelMatrix, 0); 370 | Matrix.multiplyMM(modelViewProjectionMatrix, 0, cameraPerspective, 0, modelViewMatrix, 0); 371 | 372 | GLES20.glUseProgram(program); 373 | 374 | // Set the lighting environment properties. 375 | Matrix.multiplyMV(viewLightDirection, 0, modelViewMatrix, 0, LIGHT_DIRECTION, 0); 376 | normalizeVec3(viewLightDirection); 377 | GLES20.glUniform4f( 378 | lightingParametersUniform, 379 | viewLightDirection[0], 380 | viewLightDirection[1], 381 | viewLightDirection[2], 382 | 1.f); 383 | GLES20.glUniform4fv(colorCorrectionParameterUniform, 1, colorCorrectionRgba, 0); 384 | 385 | // Set the object color property. 386 | GLES20.glUniform4fv(colorUniform, 1, objColor, 0); 387 | 388 | // Set the object material properties. 389 | GLES20.glUniform4f(materialParametersUniform, ambient, diffuse, specular, specularPower); 390 | 391 | // Attach the object texture. 392 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0); 393 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); 394 | GLES20.glUniform1i(textureUniform, 0); 395 | 396 | // Occlusion parameters. 397 | if (useDepthForOcclusion) { 398 | // Attach the depth texture. 399 | GLES20.glActiveTexture(GLES20.GL_TEXTURE1); 400 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, depthTextureId); 401 | GLES20.glUniform1i(depthTextureUniform, 1); 402 | 403 | // Set the depth texture uv transform. 404 | GLES20.glUniformMatrix3fv(depthUvTransformUniform, 1, false, uvTransform, 0); 405 | GLES20.glUniform1f(depthAspectRatioUniform, depthAspectRatio); 406 | } 407 | 408 | // Set the vertex attributes. 409 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vertexBufferId); 410 | 411 | GLES20.glVertexAttribPointer( 412 | positionAttribute, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, verticesBaseAddress); 413 | GLES20.glVertexAttribPointer(normalAttribute, 3, GLES20.GL_FLOAT, false, 0, normalsBaseAddress); 414 | GLES20.glVertexAttribPointer( 415 | texCoordAttribute, 2, GLES20.GL_FLOAT, false, 0, texCoordsBaseAddress); 416 | 417 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); 418 | 419 | // Set the ModelViewProjection matrix in the shader. 420 | GLES20.glUniformMatrix4fv(modelViewUniform, 1, false, modelViewMatrix, 0); 421 | GLES20.glUniformMatrix4fv(modelViewProjectionUniform, 1, false, modelViewProjectionMatrix, 0); 422 | 423 | // Enable vertex arrays 424 | GLES20.glEnableVertexAttribArray(positionAttribute); 425 | GLES20.glEnableVertexAttribArray(normalAttribute); 426 | GLES20.glEnableVertexAttribArray(texCoordAttribute); 427 | 428 | if (blendMode != null) { 429 | GLES20.glEnable(GLES20.GL_BLEND); 430 | switch (blendMode) { 431 | case Shadow: 432 | // Multiplicative blending function for Shadow. 433 | GLES20.glDepthMask(false); 434 | GLES20.glBlendFunc(GLES20.GL_ZERO, GLES20.GL_ONE_MINUS_SRC_ALPHA); 435 | break; 436 | case AlphaBlending: 437 | // Alpha blending function, with the depth mask enabled. 438 | GLES20.glDepthMask(true); 439 | 440 | // Textures are loaded with premultiplied alpha 441 | // (https://developer.android.com/reference/android/graphics/BitmapFactory.Options#inPremultiplied), 442 | // so we use the premultiplied alpha blend factors. 443 | GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA); 444 | break; 445 | } 446 | } 447 | 448 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, indexBufferId); 449 | GLES20.glDrawElements(GLES20.GL_TRIANGLES, indexCount, GLES20.GL_UNSIGNED_SHORT, 0); 450 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); 451 | 452 | if (blendMode != null) { 453 | GLES20.glDisable(GLES20.GL_BLEND); 454 | GLES20.glDepthMask(true); 455 | } 456 | 457 | // Disable vertex arrays 458 | GLES20.glDisableVertexAttribArray(positionAttribute); 459 | GLES20.glDisableVertexAttribArray(normalAttribute); 460 | GLES20.glDisableVertexAttribArray(texCoordAttribute); 461 | 462 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); 463 | 464 | ShaderUtil.checkGLError(TAG, "After draw"); 465 | } 466 | 467 | private static void normalizeVec3(float[] v) { 468 | float reciprocalLength = 1.0f / (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); 469 | v[0] *= reciprocalLength; 470 | v[1] *= reciprocalLength; 471 | v[2] *= reciprocalLength; 472 | } 473 | 474 | public void setUvTransformMatrix(float[] transform) { 475 | uvTransform = transform; 476 | } 477 | 478 | public void setDepthTexture(int textureId, int width, int height) { 479 | depthTextureId = textureId; 480 | depthAspectRatio = (float) width / (float) height; 481 | } 482 | } 483 | -------------------------------------------------------------------------------- /third_party/GreenMaze_obj.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google-ar/codelab-augmented-images-intro/87cb12d8812178013fa4abb96af360d14ef0b229/third_party/GreenMaze_obj.zip -------------------------------------------------------------------------------- /third_party/licence info for GreenMaze_obj.zip.txt: -------------------------------------------------------------------------------- 1 | GreenMaze_obj.zip is downloaded from https://poly.google.com/view/3vQIVKnZ2tF 2 | Author: Evol 3 | License CC-BY 3.0 4 | 5 | ============================================================================================ 6 | Complete text of CC-BY 3.0 license (https://creativecommons.org/licenses/by/3.0/legalcode.txt) 7 | 8 | Creative Commons Legal Code 9 | 10 | Attribution 3.0 Unported 11 | 12 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 13 | LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN 14 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 15 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 16 | REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR 17 | DAMAGES RESULTING FROM ITS USE. 18 | 19 | License 20 | 21 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE 22 | COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY 23 | COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS 24 | AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 25 | 26 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE 27 | TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY 28 | BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS 29 | CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND 30 | CONDITIONS. 31 | 32 | 1. Definitions 33 | 34 | a. "Adaptation" means a work based upon the Work, or upon the Work and 35 | other pre-existing works, such as a translation, adaptation, 36 | derivative work, arrangement of music or other alterations of a 37 | literary or artistic work, or phonogram or performance and includes 38 | cinematographic adaptations or any other form in which the Work may be 39 | recast, transformed, or adapted including in any form recognizably 40 | derived from the original, except that a work that constitutes a 41 | Collection will not be considered an Adaptation for the purpose of 42 | this License. For the avoidance of doubt, where the Work is a musical 43 | work, performance or phonogram, the synchronization of the Work in 44 | timed-relation with a moving image ("synching") will be considered an 45 | Adaptation for the purpose of this License. 46 | b. "Collection" means a collection of literary or artistic works, such as 47 | encyclopedias and anthologies, or performances, phonograms or 48 | broadcasts, or other works or subject matter other than works listed 49 | in Section 1(f) below, which, by reason of the selection and 50 | arrangement of their contents, constitute intellectual creations, in 51 | which the Work is included in its entirety in unmodified form along 52 | with one or more other contributions, each constituting separate and 53 | independent works in themselves, which together are assembled into a 54 | collective whole. A work that constitutes a Collection will not be 55 | considered an Adaptation (as defined above) for the purposes of this 56 | License. 57 | c. "Distribute" means to make available to the public the original and 58 | copies of the Work or Adaptation, as appropriate, through sale or 59 | other transfer of ownership. 60 | d. "Licensor" means the individual, individuals, entity or entities that 61 | offer(s) the Work under the terms of this License. 62 | e. "Original Author" means, in the case of a literary or artistic work, 63 | the individual, individuals, entity or entities who created the Work 64 | or if no individual or entity can be identified, the publisher; and in 65 | addition (i) in the case of a performance the actors, singers, 66 | musicians, dancers, and other persons who act, sing, deliver, declaim, 67 | play in, interpret or otherwise perform literary or artistic works or 68 | expressions of folklore; (ii) in the case of a phonogram the producer 69 | being the person or legal entity who first fixes the sounds of a 70 | performance or other sounds; and, (iii) in the case of broadcasts, the 71 | organization that transmits the broadcast. 72 | f. "Work" means the literary and/or artistic work offered under the terms 73 | of this License including without limitation any production in the 74 | literary, scientific and artistic domain, whatever may be the mode or 75 | form of its expression including digital form, such as a book, 76 | pamphlet and other writing; a lecture, address, sermon or other work 77 | of the same nature; a dramatic or dramatico-musical work; a 78 | choreographic work or entertainment in dumb show; a musical 79 | composition with or without words; a cinematographic work to which are 80 | assimilated works expressed by a process analogous to cinematography; 81 | a work of drawing, painting, architecture, sculpture, engraving or 82 | lithography; a photographic work to which are assimilated works 83 | expressed by a process analogous to photography; a work of applied 84 | art; an illustration, map, plan, sketch or three-dimensional work 85 | relative to geography, topography, architecture or science; a 86 | performance; a broadcast; a phonogram; a compilation of data to the 87 | extent it is protected as a copyrightable work; or a work performed by 88 | a variety or circus performer to the extent it is not otherwise 89 | considered a literary or artistic work. 90 | g. "You" means an individual or entity exercising rights under this 91 | License who has not previously violated the terms of this License with 92 | respect to the Work, or who has received express permission from the 93 | Licensor to exercise rights under this License despite a previous 94 | violation. 95 | h. "Publicly Perform" means to perform public recitations of the Work and 96 | to communicate to the public those public recitations, by any means or 97 | process, including by wire or wireless means or public digital 98 | performances; to make available to the public Works in such a way that 99 | members of the public may access these Works from a place and at a 100 | place individually chosen by them; to perform the Work to the public 101 | by any means or process and the communication to the public of the 102 | performances of the Work, including by public digital performance; to 103 | broadcast and rebroadcast the Work by any means including signs, 104 | sounds or images. 105 | i. "Reproduce" means to make copies of the Work by any means including 106 | without limitation by sound or visual recordings and the right of 107 | fixation and reproducing fixations of the Work, including storage of a 108 | protected performance or phonogram in digital form or other electronic 109 | medium. 110 | 111 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, 112 | limit, or restrict any uses free from copyright or rights arising from 113 | limitations or exceptions that are provided for in connection with the 114 | copyright protection under copyright law or other applicable laws. 115 | 116 | 3. License Grant. Subject to the terms and conditions of this License, 117 | Licensor hereby grants You a worldwide, royalty-free, non-exclusive, 118 | perpetual (for the duration of the applicable copyright) license to 119 | exercise the rights in the Work as stated below: 120 | 121 | a. to Reproduce the Work, to incorporate the Work into one or more 122 | Collections, and to Reproduce the Work as incorporated in the 123 | Collections; 124 | b. to create and Reproduce Adaptations provided that any such Adaptation, 125 | including any translation in any medium, takes reasonable steps to 126 | clearly label, demarcate or otherwise identify that changes were made 127 | to the original Work. For example, a translation could be marked "The 128 | original work was translated from English to Spanish," or a 129 | modification could indicate "The original work has been modified."; 130 | c. to Distribute and Publicly Perform the Work including as incorporated 131 | in Collections; and, 132 | d. to Distribute and Publicly Perform Adaptations. 133 | e. For the avoidance of doubt: 134 | 135 | i. Non-waivable Compulsory License Schemes. In those jurisdictions in 136 | which the right to collect royalties through any statutory or 137 | compulsory licensing scheme cannot be waived, the Licensor 138 | reserves the exclusive right to collect such royalties for any 139 | exercise by You of the rights granted under this License; 140 | ii. Waivable Compulsory License Schemes. In those jurisdictions in 141 | which the right to collect royalties through any statutory or 142 | compulsory licensing scheme can be waived, the Licensor waives the 143 | exclusive right to collect such royalties for any exercise by You 144 | of the rights granted under this License; and, 145 | iii. Voluntary License Schemes. The Licensor waives the right to 146 | collect royalties, whether individually or, in the event that the 147 | Licensor is a member of a collecting society that administers 148 | voluntary licensing schemes, via that society, from any exercise 149 | by You of the rights granted under this License. 150 | 151 | The above rights may be exercised in all media and formats whether now 152 | known or hereafter devised. The above rights include the right to make 153 | such modifications as are technically necessary to exercise the rights in 154 | other media and formats. Subject to Section 8(f), all rights not expressly 155 | granted by Licensor are hereby reserved. 156 | 157 | 4. Restrictions. The license granted in Section 3 above is expressly made 158 | subject to and limited by the following restrictions: 159 | 160 | a. You may Distribute or Publicly Perform the Work only under the terms 161 | of this License. You must include a copy of, or the Uniform Resource 162 | Identifier (URI) for, this License with every copy of the Work You 163 | Distribute or Publicly Perform. You may not offer or impose any terms 164 | on the Work that restrict the terms of this License or the ability of 165 | the recipient of the Work to exercise the rights granted to that 166 | recipient under the terms of the License. You may not sublicense the 167 | Work. You must keep intact all notices that refer to this License and 168 | to the disclaimer of warranties with every copy of the Work You 169 | Distribute or Publicly Perform. When You Distribute or Publicly 170 | Perform the Work, You may not impose any effective technological 171 | measures on the Work that restrict the ability of a recipient of the 172 | Work from You to exercise the rights granted to that recipient under 173 | the terms of the License. This Section 4(a) applies to the Work as 174 | incorporated in a Collection, but this does not require the Collection 175 | apart from the Work itself to be made subject to the terms of this 176 | License. If You create a Collection, upon notice from any Licensor You 177 | must, to the extent practicable, remove from the Collection any credit 178 | as required by Section 4(b), as requested. If You create an 179 | Adaptation, upon notice from any Licensor You must, to the extent 180 | practicable, remove from the Adaptation any credit as required by 181 | Section 4(b), as requested. 182 | b. If You Distribute, or Publicly Perform the Work or any Adaptations or 183 | Collections, You must, unless a request has been made pursuant to 184 | Section 4(a), keep intact all copyright notices for the Work and 185 | provide, reasonable to the medium or means You are utilizing: (i) the 186 | name of the Original Author (or pseudonym, if applicable) if supplied, 187 | and/or if the Original Author and/or Licensor designate another party 188 | or parties (e.g., a sponsor institute, publishing entity, journal) for 189 | attribution ("Attribution Parties") in Licensor's copyright notice, 190 | terms of service or by other reasonable means, the name of such party 191 | or parties; (ii) the title of the Work if supplied; (iii) to the 192 | extent reasonably practicable, the URI, if any, that Licensor 193 | specifies to be associated with the Work, unless such URI does not 194 | refer to the copyright notice or licensing information for the Work; 195 | and (iv) , consistent with Section 3(b), in the case of an Adaptation, 196 | a credit identifying the use of the Work in the Adaptation (e.g., 197 | "French translation of the Work by Original Author," or "Screenplay 198 | based on original Work by Original Author"). The credit required by 199 | this Section 4 (b) may be implemented in any reasonable manner; 200 | provided, however, that in the case of a Adaptation or Collection, at 201 | a minimum such credit will appear, if a credit for all contributing 202 | authors of the Adaptation or Collection appears, then as part of these 203 | credits and in a manner at least as prominent as the credits for the 204 | other contributing authors. For the avoidance of doubt, You may only 205 | use the credit required by this Section for the purpose of attribution 206 | in the manner set out above and, by exercising Your rights under this 207 | License, You may not implicitly or explicitly assert or imply any 208 | connection with, sponsorship or endorsement by the Original Author, 209 | Licensor and/or Attribution Parties, as appropriate, of You or Your 210 | use of the Work, without the separate, express prior written 211 | permission of the Original Author, Licensor and/or Attribution 212 | Parties. 213 | c. Except as otherwise agreed in writing by the Licensor or as may be 214 | otherwise permitted by applicable law, if You Reproduce, Distribute or 215 | Publicly Perform the Work either by itself or as part of any 216 | Adaptations or Collections, You must not distort, mutilate, modify or 217 | take other derogatory action in relation to the Work which would be 218 | prejudicial to the Original Author's honor or reputation. Licensor 219 | agrees that in those jurisdictions (e.g. Japan), in which any exercise 220 | of the right granted in Section 3(b) of this License (the right to 221 | make Adaptations) would be deemed to be a distortion, mutilation, 222 | modification or other derogatory action prejudicial to the Original 223 | Author's honor and reputation, the Licensor will waive or not assert, 224 | as appropriate, this Section, to the fullest extent permitted by the 225 | applicable national law, to enable You to reasonably exercise Your 226 | right under Section 3(b) of this License (right to make Adaptations) 227 | but not otherwise. 228 | 229 | 5. Representations, Warranties and Disclaimer 230 | 231 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR 232 | OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY 233 | KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, 234 | INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, 235 | FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF 236 | LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, 237 | WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION 238 | OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 239 | 240 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE 241 | LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR 242 | ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES 243 | ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS 244 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 245 | 246 | 7. Termination 247 | 248 | a. This License and the rights granted hereunder will terminate 249 | automatically upon any breach by You of the terms of this License. 250 | Individuals or entities who have received Adaptations or Collections 251 | from You under this License, however, will not have their licenses 252 | terminated provided such individuals or entities remain in full 253 | compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will 254 | survive any termination of this License. 255 | b. Subject to the above terms and conditions, the license granted here is 256 | perpetual (for the duration of the applicable copyright in the Work). 257 | Notwithstanding the above, Licensor reserves the right to release the 258 | Work under different license terms or to stop distributing the Work at 259 | any time; provided, however that any such election will not serve to 260 | withdraw this License (or any other license that has been, or is 261 | required to be, granted under the terms of this License), and this 262 | License will continue in full force and effect unless terminated as 263 | stated above. 264 | 265 | 8. Miscellaneous 266 | 267 | a. Each time You Distribute or Publicly Perform the Work or a Collection, 268 | the Licensor offers to the recipient a license to the Work on the same 269 | terms and conditions as the license granted to You under this License. 270 | b. Each time You Distribute or Publicly Perform an Adaptation, Licensor 271 | offers to the recipient a license to the original Work on the same 272 | terms and conditions as the license granted to You under this License. 273 | c. If any provision of this License is invalid or unenforceable under 274 | applicable law, it shall not affect the validity or enforceability of 275 | the remainder of the terms of this License, and without further action 276 | by the parties to this agreement, such provision shall be reformed to 277 | the minimum extent necessary to make such provision valid and 278 | enforceable. 279 | d. No term or provision of this License shall be deemed waived and no 280 | breach consented to unless such waiver or consent shall be in writing 281 | and signed by the party to be charged with such waiver or consent. 282 | e. This License constitutes the entire agreement between the parties with 283 | respect to the Work licensed here. There are no understandings, 284 | agreements or representations with respect to the Work not specified 285 | here. Licensor shall not be bound by any additional provisions that 286 | may appear in any communication from You. This License may not be 287 | modified without the mutual written agreement of the Licensor and You. 288 | f. The rights granted under, and the subject matter referenced, in this 289 | License were drafted utilizing the terminology of the Berne Convention 290 | for the Protection of Literary and Artistic Works (as amended on 291 | September 28, 1979), the Rome Convention of 1961, the WIPO Copyright 292 | Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 293 | and the Universal Copyright Convention (as revised on July 24, 1971). 294 | These rights and subject matter take effect in the relevant 295 | jurisdiction in which the License terms are sought to be enforced 296 | according to the corresponding provisions of the implementation of 297 | those treaty provisions in the applicable national law. If the 298 | standard suite of rights granted under applicable copyright law 299 | includes additional rights not granted under this License, such 300 | additional rights are deemed to be included in the License; this 301 | License is not intended to restrict the license of any rights under 302 | applicable law. 303 | 304 | 305 | Creative Commons Notice 306 | 307 | Creative Commons is not a party to this License, and makes no warranty 308 | whatsoever in connection with the Work. Creative Commons will not be 309 | liable to You or any party on any legal theory for any damages 310 | whatsoever, including without limitation any general, special, 311 | incidental or consequential damages arising in connection to this 312 | license. Notwithstanding the foregoing two (2) sentences, if Creative 313 | Commons has expressly identified itself as the Licensor hereunder, it 314 | shall have all rights and obligations of Licensor. 315 | 316 | Except for the limited purpose of indicating to the public that the 317 | Work is licensed under the CCPL, Creative Commons does not authorize 318 | the use by either party of the trademark "Creative Commons" or any 319 | related trademark or logo of Creative Commons without the prior 320 | written consent of Creative Commons. Any permitted use will be in 321 | compliance with Creative Commons' then-current trademark usage 322 | guidelines, as may be published on its website or otherwise made 323 | available upon request from time to time. For the avoidance of doubt, 324 | this trademark restriction does not form part of this License. 325 | 326 | Creative Commons may be contacted at https://creativecommons.org/. 327 | 328 | 329 | 330 | --------------------------------------------------------------------------------