diff --git a/LICENSE b/LICENSE index f288702..5385cfe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,21 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +MIT License + +Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 24af9b1..b2fbfc4 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ For more advanced installation and for installing SMPL body models, please refer ## Features * Native Python interface, easy to use and hack. -* Load [SMPL[-H/-X]](https://smpl.is.tue.mpg.de/) / [MANO](https://mano.is.tue.mpg.de/) / [FLAME](https://flame.is.tue.mpg.de/) / [STAR](https://github.com/ahmedosman/STAR) sequences and display them in an interactive viewer. +* Load [SMPL[-H/-X]](https://smpl.is.tue.mpg.de/) / [MANO](https://mano.is.tue.mpg.de/) / [FLAME](https://flame.is.tue.mpg.de/) / [STAR](https://github.com/ahmedosman/STAR) / [SUPR](https://github.com/ahmedosman/SUPR) sequences and display them in an interactive viewer. * Headless mode for server rendering of videos/images. * Remote mode for non-blocking integration of visualization code. * Render 3D data on top of images via weak-perspective or OpenCV camera models. diff --git a/aitviewer/aitvconfig.yaml b/aitviewer/aitvconfig.yaml index 5ca1658..283f25d 100644 --- a/aitviewer/aitvconfig.yaml +++ b/aitviewer/aitvconfig.yaml @@ -36,6 +36,9 @@ backface_culling: True background_color: [1.0, 1.0, 1.0, 1.0] window_type: "pyqt5" +# Viewer defaults to Y up, set to true for Z up. +z_up: False + # Server for remote connections. server_enabled: False server_port: 8417 diff --git a/aitviewer/configuration.py b/aitviewer/configuration.py index cd38026..b68668a 100644 --- a/aitviewer/configuration.py +++ b/aitviewer/configuration.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import torch diff --git a/aitviewer/headless.py b/aitviewer/headless.py index 8ae9e2b..22069fb 100644 --- a/aitviewer/headless.py +++ b/aitviewer/headless.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os from typing import Dict, Tuple diff --git a/aitviewer/models/smpl.py b/aitviewer/models/smpl.py index f8baa54..711423c 100644 --- a/aitviewer/models/smpl.py +++ b/aitviewer/models/smpl.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import collections from abc import ABC diff --git a/aitviewer/models/star.py b/aitviewer/models/star.py index 96aa4de..5b0ae66 100644 --- a/aitviewer/models/star.py +++ b/aitviewer/models/star.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import collections import os diff --git a/aitviewer/models/supr.py b/aitviewer/models/supr.py index 37a9665..f1bf61e 100644 --- a/aitviewer/models/supr.py +++ b/aitviewer/models/supr.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import collections import os diff --git a/aitviewer/remote/message.py b/aitviewer/remote/message.py index 255fe5e..c567d2d 100644 --- a/aitviewer/remote/message.py +++ b/aitviewer/remote/message.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import enum diff --git a/aitviewer/remote/node.py b/aitviewer/remote/node.py index 41815fc..56e41ba 100644 --- a/aitviewer/remote/node.py +++ b/aitviewer/remote/node.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from .message import Message from .viewer import RemoteViewer diff --git a/aitviewer/remote/renderables/arrows.py b/aitviewer/remote/renderables/arrows.py index 7c673ad..71f4c24 100644 --- a/aitviewer/remote/renderables/arrows.py +++ b/aitviewer/remote/renderables/arrows.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from ..message import Message from ..node import RemoteNode diff --git a/aitviewer/remote/renderables/lines.py b/aitviewer/remote/renderables/lines.py index 0850d12..bbbacc4 100644 --- a/aitviewer/remote/renderables/lines.py +++ b/aitviewer/remote/renderables/lines.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from ..message import Message from ..node import RemoteNode diff --git a/aitviewer/remote/renderables/meshes.py b/aitviewer/remote/renderables/meshes.py index d30a551..a2d1dda 100644 --- a/aitviewer/remote/renderables/meshes.py +++ b/aitviewer/remote/renderables/meshes.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from ..message import Message from ..node import RemoteNode diff --git a/aitviewer/remote/renderables/rigid_bodies.py b/aitviewer/remote/renderables/rigid_bodies.py index d5b26cc..18819ae 100644 --- a/aitviewer/remote/renderables/rigid_bodies.py +++ b/aitviewer/remote/renderables/rigid_bodies.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from ..message import Message from ..node import RemoteNode diff --git a/aitviewer/remote/renderables/smpl.py b/aitviewer/remote/renderables/smpl.py index a8f9c30..1d182ac 100644 --- a/aitviewer/remote/renderables/smpl.py +++ b/aitviewer/remote/renderables/smpl.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from ..message import Message from ..node import RemoteNode diff --git a/aitviewer/remote/renderables/spheres.py b/aitviewer/remote/renderables/spheres.py index 07a3853..e11340d 100644 --- a/aitviewer/remote/renderables/spheres.py +++ b/aitviewer/remote/renderables/spheres.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from ..message import Message from ..node import RemoteNode diff --git a/aitviewer/remote/viewer.py b/aitviewer/remote/viewer.py index ba19aca..12be88b 100644 --- a/aitviewer/remote/viewer.py +++ b/aitviewer/remote/viewer.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import asyncio import pickle import queue diff --git a/aitviewer/renderables/arrows.py b/aitviewer/renderables/arrows.py index 50cd2f6..509fa88 100644 --- a/aitviewer/renderables/arrows.py +++ b/aitviewer/renderables/arrows.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.renderables.lines import Lines diff --git a/aitviewer/renderables/billboard.py b/aitviewer/renderables/billboard.py index 29da0c9..9d9a0ed 100644 --- a/aitviewer/renderables/billboard.py +++ b/aitviewer/renderables/billboard.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import pickle from typing import List, Union diff --git a/aitviewer/renderables/bounding_boxes.py b/aitviewer/renderables/bounding_boxes.py index 9503892..5de78b4 100644 --- a/aitviewer/renderables/bounding_boxes.py +++ b/aitviewer/renderables/bounding_boxes.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.renderables.lines import Lines diff --git a/aitviewer/renderables/coordinate_system.py b/aitviewer/renderables/coordinate_system.py index e5ecec3..8d1b19c 100644 --- a/aitviewer/renderables/coordinate_system.py +++ b/aitviewer/renderables/coordinate_system.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.renderables.rigid_bodies import RigidBodies diff --git a/aitviewer/renderables/lines.py b/aitviewer/renderables/lines.py index 21a4ad4..be14441 100644 --- a/aitviewer/renderables/lines.py +++ b/aitviewer/renderables/lines.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import moderngl import numpy as np import trimesh @@ -33,6 +18,7 @@ compute_vertex_and_face_normals, set_lights_in_program, set_material_properties, + usd, ) from aitviewer.utils.decorators import hooked from aitviewer.utils.so3 import aa2rot_numpy as aa2rot @@ -447,6 +433,47 @@ def remove_frames(self, frames): self.lines = np.delete(self.lines, frames, axis=0) self.redraw() + def export_usd(self, stage, usd_path: str, directory: str = None, verbose=False): + name = f"{self.name}_{self.uid:03}".replace(" ", "_") + usd_path = f"{usd_path}/{name}" + + if self.mode == "lines": + v0s = self.lines[:, ::2] + v1s = self.lines[:, 1::2] + else: + v0s = self.lines[:, :-1] + v1s = self.lines[:, 1:] + + print(self.lines.shape) + print(v0s.shape) + + # Data is in the form of (F, N_LINES, 3), convert it to (F*N_LINES, 3) + v0s = np.reshape(v0s, (-1, 3)) + v1s = np.reshape(v1s, (-1, 3)) + + self.r_tip = self.r_base if self.r_tip is None else self.r_tip + + # If r_tip is below a certain threshold, we create a proper cone, i.e. with just a single vertex at the top. + if self.r_tip < 10e-6: + data = _create_cone_from_to(v0s, v1s, radius=self.r_base) + else: + data = _create_cylinder_from_to(v0s, v1s, radius1=self.r_base, radius2=self.r_tip) + + L = self.n_lines + V = data["vertices"].shape[1] + + vertices = data["vertices"].reshape((self.n_frames, -1, 3)) + faces = data["faces"] + + fs = faces[np.newaxis].repeat(L, 0).reshape((L, -1)) + offsets = (np.arange(L) * V).reshape((L, 1)) + faces = (fs + offsets).reshape((-1, 3)) + + mesh = usd.add_mesh(stage, usd_path, self.name, vertices, faces, self.get_local_transform()) + usd.add_color(stage, mesh, usd_path, self.color[:3]) + + self._export_usd_recursively(stage, usd_path, directory, verbose) + class Lines2D(Node): """Render 2D lines.""" diff --git a/aitviewer/renderables/meshes.py b/aitviewer/renderables/meshes.py index 591a823..4e3161c 100644 --- a/aitviewer/renderables/meshes.py +++ b/aitviewer/renderables/meshes.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import pickle import re @@ -24,6 +9,7 @@ import tqdm import trimesh import trimesh.geometry +import trimesh.visual from moderngl_window.opengl.vao import VAO from PIL import Image from pxr import Gf, Sdf, UsdGeom @@ -128,7 +114,7 @@ def _maybe_unsqueeze(x): self.face_colors = _maybe_unsqueeze(face_colors) # Texture handling. - self.has_texture = uv_coords is not None + self.has_texture = (uv_coords is not None) and (path_to_texture is not None) self.uv_coords = uv_coords self.texture_path = path_to_texture @@ -206,6 +192,35 @@ def check_array(a, dim): transforms[:, :, 3, 3] = 1.0 return cls(*args, **kwargs, instance_transforms=transforms) + @classmethod + def from_file(cls, file, **kwargs): + """ + Loads a mesh from a file that can be loaded by trimesh (e.g. ".obj", ".ply", ...) + See trimesh.available_formats() for a complete list. + """ + mesh = trimesh.load(file) + + uvs = None + vertex_colors = None + face_colors = None + if isinstance(mesh.visual, trimesh.visual.ColorVisuals): + if mesh.visual.kind == "vertex_colors": + vertex_colors = mesh.visual.vertex_colors + elif mesh.visual.kind == "face_colors": + face_colors = mesh.visual.vertex_colors + elif isinstance(mesh.visual, trimesh.visual.TextureVisuals): + uvs = mesh.visual.uv + + return Meshes( + mesh.vertices, + mesh.faces, + vertex_normals=mesh.vertex_normals, + face_colors=face_colors, + vertex_colors=vertex_colors, + uv_coords=uvs, + **kwargs, + ) + @property def vertices(self): return self._vertices @@ -731,19 +746,7 @@ def export_usd(self, stage, usd_path: str, directory: str = None, verbose=False) name = f"{self.name}_{self.uid:03}".replace(" ", "_") usd_path = f"{usd_path}/{name}" - # Transform. - xform = UsdGeom.Xform.Define(stage, usd_path) - a_xform = xform.AddTransformOp() - a_xform.Set(Gf.Matrix4d(self.get_local_transform().astype(np.float64).T)) - - # Geometry. - mesh = UsdGeom.Mesh.Define(stage, usd_path + "/" + self.name.replace(" ", "_")) - a_vertices = mesh.CreatePointsAttr() - for i in range(self.n_frames): - a_vertices.Set(time=i + 1, value=self.vertices[i]) - mesh.CreateFaceVertexCountsAttr(np.full(self.faces.shape[0], 3)) - mesh.CreateFaceVertexIndicesAttr(self.faces) - + mesh = usd.add_mesh(stage, usd_path, self.name, self.vertices, self.faces, self.get_local_transform()) if self.has_texture and not self.use_pickle_texture: # UVs. a_uv = UsdGeom.PrimvarsAPI(mesh).CreatePrimvar( @@ -756,6 +759,30 @@ def export_usd(self, stage, usd_path: str, directory: str = None, verbose=False) else: texture_path = usd.copy_texture(self.texture_path, name, directory) usd.add_texture(stage, mesh, usd_path, texture_path) + else: + # NOTE: Per vertex and per face colors using usd displayColor are not currently + # loaded by Blender. This code path can be enabled once support is there. + if False: + a_colors = mesh.GetDisplayColorAttr() + if self._face_colors is not None: + # Per face colors. + if self._face_colors.shape[0] == 1: + a_colors.Set(self._face_colors[0, :, :3].astype(np.float32)) + else: + for i in range(self.n_frames): + a_colors.Set(time=i + 1, value=self._face_colors[i, :, :3].astype(np.float32)) + elif self._vertex_colors is not None: + # Per vertex colors. + if self._vertex_colors.shape[0] == 1: + a_colors.Set(self._vertex_colors[0, :, :3].astype(np.float32)) + else: + for i in range(self.n_frames): + a_colors.Set(time=i + 1, value=self._vertex_colors[i, :, :3].astype(np.float32)) + else: + # Uniform color. + a_colors.Set(np.array(self.color, np.float32)[:3]) + else: + usd.add_color(stage, mesh, usd_path, self.color[:3]) self._export_usd_recursively(stage, usd_path, directory, verbose) diff --git a/aitviewer/renderables/multi_view_system.py b/aitviewer/renderables/multi_view_system.py index 85b3a2c..684b05d 100644 --- a/aitviewer/renderables/multi_view_system.py +++ b/aitviewer/renderables/multi_view_system.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import re from collections import OrderedDict diff --git a/aitviewer/renderables/plane.py b/aitviewer/renderables/plane.py index da2d525..2be3c81 100644 --- a/aitviewer/renderables/plane.py +++ b/aitviewer/renderables/plane.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import moderngl import numpy as np from pxr import Gf, UsdGeom @@ -187,8 +172,8 @@ def __init__( v1 = np.array([1, 0, 0], dtype=np.float32) v2 = np.array([0, 0, 1], dtype=np.float32) elif plane == "xy": - v1 = np.array([1, 0, 0], dtype=np.float32) - v2 = np.array([0, 1, 0], dtype=np.float32) + v1 = np.array([0, 1, 0], dtype=np.float32) + v2 = np.array([1, 0, 0], dtype=np.float32) else: # plane == "yz" v1 = np.array([0, 1, 0], dtype=np.float32) diff --git a/aitviewer/renderables/point_clouds.py b/aitviewer/renderables/point_clouds.py index e8298b9..dac1e3f 100644 --- a/aitviewer/renderables/point_clouds.py +++ b/aitviewer/renderables/point_clouds.py @@ -1,23 +1,9 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import moderngl import numpy as np from moderngl_window.opengl.vao import VAO +from aitviewer.configuration import CONFIG as C from aitviewer.scene.node import Node from aitviewer.shaders import ( get_fragmap_program, @@ -69,7 +55,7 @@ def __init__( self.vao = VAO("points", mode=moderngl.POINTS) - if z_up: + if z_up and not C.z_up: self.rotation = np.matmul(np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]), self.rotation) @property diff --git a/aitviewer/renderables/rigid_bodies.py b/aitviewer/renderables/rigid_bodies.py index 338a715..d204b55 100644 --- a/aitviewer/renderables/rigid_bodies.py +++ b/aitviewer/renderables/rigid_bodies.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.renderables.arrows import Arrows diff --git a/aitviewer/renderables/sdf.py b/aitviewer/renderables/sdf.py index d170402..54e69da 100644 --- a/aitviewer/renderables/sdf.py +++ b/aitviewer/renderables/sdf.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from skimage import measure diff --git a/aitviewer/renderables/skeletons.py b/aitviewer/renderables/skeletons.py index e2c1174..cc33d1e 100644 --- a/aitviewer/renderables/skeletons.py +++ b/aitviewer/renderables/skeletons.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.renderables.lines import Lines diff --git a/aitviewer/renderables/smpl.py b/aitviewer/renderables/smpl.py index d2bb9a2..4020ff0 100644 --- a/aitviewer/renderables/smpl.py +++ b/aitviewer/renderables/smpl.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import pickle as pkl from typing import IO, Union @@ -181,7 +166,7 @@ def __init__( else: global_oris = np.tile(np.eye(3), self.joints.shape[:-1])[np.newaxis] - if self._z_up: + if self._z_up and not C.z_up: self.rotation = np.matmul(np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]), self.rotation) self.rbs = RigidBodies(self.joints, global_oris, length=0.1, gui_affine=False, name="Joint Angles") diff --git a/aitviewer/renderables/spheres.py b/aitviewer/renderables/spheres.py index ceb44ac..5c09392 100644 --- a/aitviewer/renderables/spheres.py +++ b/aitviewer/renderables/spheres.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import moderngl import numpy as np from moderngl_window.opengl.vao import VAO @@ -26,6 +11,7 @@ get_outline_program, get_sphere_instanced_program, ) +from aitviewer.utils import usd from aitviewer.utils.decorators import hooked from aitviewer.utils.utils import set_lights_in_program, set_material_properties @@ -55,7 +41,7 @@ def _create_sphere(radius=1.0, rings=16, sectors=32): v += 1 n += 1 - faces = np.zeros([rings * sectors * 2, 3], dtype=np.int32) + faces = np.zeros([(rings - 1) * (sectors - 1) * 2, 3], dtype=np.int32) i = 0 for r in range(rings - 1): for s in range(sectors - 1): @@ -279,6 +265,28 @@ def remove_frames(self, frames): self.sphere_positions = np.delete(self.sphere_positions, frames, axis=0) self.redraw() + def export_usd(self, stage, usd_path: str, directory: str = None, verbose=False): + name = f"{self.name}_{self.uid:03}".replace(" ", "_") + usd_path = f"{usd_path}/{name}" + + V = self.vertices.shape[0] + N = self.sphere_positions.shape[0] + M = self.n_spheres + + vertices = np.empty((N, V * M, 3), np.float32) + for i in range(N): + vs = self.vertices[np.newaxis].repeat(M, 0) + vertices[i] = (vs * self.radius + self.sphere_positions[i].reshape(M, 1, 3)).reshape((-1, 3)) + + fs = self.faces[np.newaxis].repeat(M, 0).reshape((M, -1)) + offsets = (np.arange(M) * V).reshape((M, 1)) + faces = (fs + offsets).reshape((-1, 3)) + + mesh = usd.add_mesh(stage, usd_path, self.name, vertices, faces, self.get_local_transform()) + usd.add_color(stage, mesh, usd_path, self.color[:3]) + + self._export_usd_recursively(stage, usd_path, directory, verbose) + class SpheresTrail(Spheres): """A sequence of spheres that leaves a trail, i.e. the past spheres keep being rendered.""" diff --git a/aitviewer/renderables/star.py b/aitviewer/renderables/star.py index 260c94f..9675c5a 100644 --- a/aitviewer/renderables/star.py +++ b/aitviewer/renderables/star.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np import torch diff --git a/aitviewer/renderables/supr.py b/aitviewer/renderables/supr.py index a961deb..b3e0a6d 100644 --- a/aitviewer/renderables/supr.py +++ b/aitviewer/renderables/supr.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.configuration import CONFIG as C diff --git a/aitviewer/renderables/volume.py b/aitviewer/renderables/volume.py index 109695b..11fecc6 100644 --- a/aitviewer/renderables/volume.py +++ b/aitviewer/renderables/volume.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import moderngl import numpy as np import trimesh diff --git a/aitviewer/renderer.py b/aitviewer/renderer.py index e124d2b..60015d9 100644 --- a/aitviewer/renderer.py +++ b/aitviewer/renderer.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import struct from typing import Dict, List, Tuple diff --git a/aitviewer/scene/camera.py b/aitviewer/scene/camera.py index 38a3cce..09de21d 100644 --- a/aitviewer/scene/camera.py +++ b/aitviewer/scene/camera.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os from abc import ABC, abstractmethod @@ -727,6 +712,7 @@ def __init__( cols, rows, fov=45, + world_up=None, near=None, far=None, viewer=None, @@ -738,7 +724,11 @@ def __init__( positions.shape[0] == 1 or targets.shape[0] == 1 or positions.shape[0] == targets.shape[0] ), f"position and target array shape mismatch: {positions.shape} and {targets.shape}" - self._world_up = np.array([0.0, 1.0, 0.0]) + if world_up: + self._world_up = world_up + else: + self._world_up = np.array([0.0, 0.0, 1.0]) if C.z_up else np.array([0.0, 1.0, 0.0]) + self._targets = targets super(PinholeCamera, self).__init__(position=position, n_frames=targets.shape[0], viewer=viewer, **kwargs) @@ -877,9 +867,9 @@ def __init__(self, fov=45, orthographic=None, znear=None, zfar=None): self.ortho_size = 1.0 if orthographic is None else orthographic # Default camera settings. - self._position = np.array([0.0, 0.0, 2.5]) + self._position = np.array([0.0, 2.5, 0.0]) if C.z_up else np.array([0.0, 0.0, 2.5]) self._target = np.array([0.0, 0.0, 0.0]) - self._up = np.array([0.0, 1.0, 0.0]) + self._up = np.array([0.0, 0.0, 1.0]) if C.z_up else np.array([0.0, 1.0, 0.0]) self.ZOOM_FACTOR = 4 self.ROT_FACTOR = 0.0025 @@ -919,7 +909,7 @@ def control_mode(self, mode): if mode not in self._control_modes: raise ValueError(f"Invalid camera mode: {mode}") if mode == "first_person" or mode == "turntable": - self.up = (0, 1, 0) + self.up = (0, 0, 1) if C.z_up else (0, 1, 0) self._control_mode = mode def copy(self): @@ -1067,8 +1057,8 @@ def rotate_azimuth(self, angle): if np.abs(angle) < 1e-8: return cam_pose = np.linalg.inv(self.view_matrix) - y_axis = cam_pose[:3, 1] - rot = rotation_matrix(angle, y_axis, self.target) + up_axis = cam_pose[:3, 1] + rot = rotation_matrix(angle, up_axis, self.target) self.position = _transform_vector(rot, self.position) def _rotation_from_mouse_delta(self, mouse_dx: int, mouse_dy: int): diff --git a/aitviewer/scene/camera_utils.py b/aitviewer/scene/camera_utils.py index 7c40c7a..f1bc051 100644 --- a/aitviewer/scene/camera_utils.py +++ b/aitviewer/scene/camera_utils.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np diff --git a/aitviewer/scene/light.py b/aitviewer/scene/light.py index 428d8d0..d030a9f 100644 --- a/aitviewer/scene/light.py +++ b/aitviewer/scene/light.py @@ -1,27 +1,12 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from functools import lru_cache import numpy as np +from pxr import Gf, UsdGeom, UsdLux from aitviewer.renderables.lines import Lines from aitviewer.renderables.rigid_bodies import RigidBodies from aitviewer.scene.camera_utils import look_at, orthographic_projection -from aitviewer.scene.material import Material from aitviewer.scene.node import Node from aitviewer.utils.utils import ( direction_from_spherical_coordinates, @@ -73,6 +58,7 @@ def __init__( self.mesh.spheres.material.diffuse = 0.0 self.mesh.spheres.material.ambient = 1.0 self.mesh.spheres.color = (*tuple(light_color), 1.0) + self.mesh.export_usd_enabled = False self.add(self.mesh, show_in_hierarchy=False, enabled=False) @classmethod @@ -185,6 +171,7 @@ def _update_debug_lines(self): if self._debug_lines is None: self._debug_lines = Lines(lines, r_base=0.05, mode="lines", cast_shadow=False, is_selectable=False) + self._debug_lines.export_usd_enabled = False self.add(self._debug_lines, show_in_hierarchy=False) else: self._debug_lines.lines = lines @@ -296,3 +283,20 @@ def gui(self, imgui): else: if self._debug_lines: self._debug_lines.enabled = False + + def export_usd(self, stage, usd_path: str, directory: str = None, verbose=False): + name = f"{self.name}_{self.uid:03}".replace(" ", "_") + usd_path = f"{usd_path}/{name}" + + # Transform. + xform = UsdGeom.Xform.Define(stage, usd_path) + a_xform = xform.AddTransformOp() + a_xform.Set(Gf.Matrix4d(self.get_local_transform().astype(np.float64).T)) + + # Light. + light = UsdLux.DistantLight.Define(stage, usd_path + "/" + name.replace(" ", "_")) + lightAPI = light.LightAPI() + lightAPI.GetInput("color").Set(self.light_color[:3]) + lightAPI.GetInput("intensity").Set(self.strength) + + self._export_usd_recursively(stage, usd_path, directory, verbose) diff --git a/aitviewer/scene/material.py b/aitviewer/scene/material.py index fadeb96..689cfc7 100644 --- a/aitviewer/scene/material.py +++ b/aitviewer/scene/material.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos class Material(object): diff --git a/aitviewer/scene/node.py b/aitviewer/scene/node.py index bfbda4e..101b251 100644 --- a/aitviewer/scene/node.py +++ b/aitviewer/scene/node.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from functools import lru_cache from typing import List @@ -727,7 +712,7 @@ def _export_usd_recursively(self, stage, usd_path, directory, verbose): if verbose: print(usd_path) for n in self.nodes: - if n.export_usd_enabled and n.show_in_hierarchy: + if n.export_usd_enabled: n.export_usd(stage, usd_path, directory, verbose) def export_usd(self, stage, usd_path: str, directory: str = None, verbose=False): diff --git a/aitviewer/scene/scene.py b/aitviewer/scene/scene.py index 4547d8d..855c09f 100644 --- a/aitviewer/scene/scene.py +++ b/aitviewer/scene/scene.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import moderngl import numpy as np @@ -57,7 +42,7 @@ def __init__(self, **kwargs): Light.facing_origin( light_color=(1.0, 1.0, 1.0), name="Back Light", - position=(0.0, 10.0, -15.0), + position=(0.0, -15.0, 10.0) if C.z_up else (0.0, 10.0, -15.0), shadow_enabled=False, ) ) @@ -65,7 +50,7 @@ def __init__(self, **kwargs): Light.facing_origin( light_color=(1.0, 1.0, 1.0), name="Front Light", - position=(0.0, 10.0, 15.0), + position=(0.0, 15.0, 10.0) if C.z_up else (0.0, 10.0, 15.0), ) ) self.add(*self.lights) @@ -76,7 +61,9 @@ def __init__(self, **kwargs): self.origin = CoordinateSystem(name="Origin", length=0.1, gui_affine=False, gui_material=False) self.add(self.origin) - self.floor = ChessboardPlane(100.0, 200, (0.9, 0.9, 0.9, 1.0), (0.82, 0.82, 0.82, 1.0), name="Floor") + self.floor = ChessboardPlane( + 100.0, 200, (0.9, 0.9, 0.9, 1.0), (0.82, 0.82, 0.82, 1.0), "xy" if C.z_up else "xz", name="Floor" + ) self.floor.material.diffuse = 0.1 self.add(self.floor) @@ -95,6 +82,7 @@ def __init__(self, **kwargs): color=(0.2, 0.2, 0.2, 1), mode="lines", ) + self.camera_target.export_usd_enabled = False self.add(self.camera_target, show_in_hierarchy=False, enabled=False) # Camera trackball. @@ -125,6 +113,7 @@ def __init__(self, **kwargs): trackball_colors, mode="lines", ) + self.trackball.export_usd_enabled = False self.add(self.trackball, show_in_hierarchy=False, enabled=False) self.custom_font = None @@ -248,8 +237,9 @@ def bounds_without_floor(self): def auto_set_floor(self): """Finds the minimum lower bound in the y coordinate from all the children bounds and uses that as the floor""" if self.floor is not None and len(self.nodes) > 0: - self.floor.position[1] = self.current_bounds[1, 0] - self.floor.update_transform() + axis = 2 if C.z_up else 1 + self.floor.position[axis] = self.current_bounds[axis, 0] + self.floor.update_transform(parent_transform=self.model_matrix) def auto_set_camera_target(self): """Sets the camera target to the average of the center of all objects in the scene""" diff --git a/aitviewer/server.py b/aitviewer/server.py index 6fa11b1..6d25f7a 100644 --- a/aitviewer/server.py +++ b/aitviewer/server.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import asyncio import pickle import queue diff --git a/aitviewer/shaders.py b/aitviewer/shaders.py index e8f54c3..74ce440 100644 --- a/aitviewer/shaders.py +++ b/aitviewer/shaders.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import functools import os diff --git a/aitviewer/shaders/chessboard.glsl b/aitviewer/shaders/chessboard.glsl index 2678451..7cccc52 100644 --- a/aitviewer/shaders/chessboard.glsl +++ b/aitviewer/shaders/chessboard.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #include directional_lights.glsl #if defined VERTEX_SHADER diff --git a/aitviewer/shaders/clipping.glsl b/aitviewer/shaders/clipping.glsl index 8e70afa..7d59e9c 100644 --- a/aitviewer/shaders/clipping.glsl +++ b/aitviewer/shaders/clipping.glsl @@ -1,3 +1,5 @@ +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + uniform ivec3 clip_control = ivec3(0, 0, 0); uniform vec3 clip_value; diff --git a/aitviewer/shaders/cylinder.glsl b/aitviewer/shaders/cylinder.glsl index f26a5ad..f9f071f 100644 --- a/aitviewer/shaders/cylinder.glsl +++ b/aitviewer/shaders/cylinder.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined VERTEX_SHADER in vec3 in_position; diff --git a/aitviewer/shaders/directional_lights.glsl b/aitviewer/shaders/directional_lights.glsl index 962a4ba..a9b4952 100644 --- a/aitviewer/shaders/directional_lights.glsl +++ b/aitviewer/shaders/directional_lights.glsl @@ -1,3 +1,5 @@ +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + struct DirLight { vec3 direction; vec3 color; diff --git a/aitviewer/shaders/fragment_picking/frag_map.fs.glsl b/aitviewer/shaders/fragment_picking/frag_map.fs.glsl index e54f1ff..665ad35 100644 --- a/aitviewer/shaders/fragment_picking/frag_map.fs.glsl +++ b/aitviewer/shaders/fragment_picking/frag_map.fs.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined FRAGMENT_SHADER layout(location=0) out vec4 out_position; diff --git a/aitviewer/shaders/fragment_picking/frag_pick.glsl b/aitviewer/shaders/fragment_picking/frag_pick.glsl index fa4ed52..df6efca 100644 --- a/aitviewer/shaders/fragment_picking/frag_pick.glsl +++ b/aitviewer/shaders/fragment_picking/frag_pick.glsl @@ -1,4 +1,7 @@ #version 400 + +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + // // Picks a point from the depth buffer and returns the position in camera space, along with the object and triangle id // Adapted from https://github.com/moderngl/moderngl-window/blob/master/examples/resources/programs/fragment_picking/picker.glsl diff --git a/aitviewer/shaders/lines_instanced.vs.glsl b/aitviewer/shaders/lines_instanced.vs.glsl index c881505..efa1d6b 100644 --- a/aitviewer/shaders/lines_instanced.vs.glsl +++ b/aitviewer/shaders/lines_instanced.vs.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #include directional_lights.glsl #if defined VERTEX_SHADER diff --git a/aitviewer/shaders/lines_instanced_positions.vs.glsl b/aitviewer/shaders/lines_instanced_positions.vs.glsl index 932acde..953c732 100644 --- a/aitviewer/shaders/lines_instanced_positions.vs.glsl +++ b/aitviewer/shaders/lines_instanced_positions.vs.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #include directional_lights.glsl #if defined VERTEX_SHADER diff --git a/aitviewer/shaders/lit_with_edges.glsl b/aitviewer/shaders/lit_with_edges.glsl index 4006e8a..e60e216 100644 --- a/aitviewer/shaders/lit_with_edges.glsl +++ b/aitviewer/shaders/lit_with_edges.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #define SMOOTH_SHADING 0 #define TEXTURE 0 #define FACE_COLOR 0 diff --git a/aitviewer/shaders/marching_cubes/check_surface.cs.glsl b/aitviewer/shaders/marching_cubes/check_surface.cs.glsl index 2d919e1..356f18f 100644 --- a/aitviewer/shaders/marching_cubes/check_surface.cs.glsl +++ b/aitviewer/shaders/marching_cubes/check_surface.cs.glsl @@ -2,7 +2,7 @@ #extension GL_KHR_shader_subgroup_ballot : enable #extension GL_KHR_shader_subgroup_arithmetic : enable -/* Copyright (C) 2023 Dario Mylonopoulos */ +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos #include marching_cubes/common.glsl diff --git a/aitviewer/shaders/marching_cubes/common.glsl b/aitviewer/shaders/marching_cubes/common.glsl index 3c07268..de76183 100644 --- a/aitviewer/shaders/marching_cubes/common.glsl +++ b/aitviewer/shaders/marching_cubes/common.glsl @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Dario Mylonopoulos */ +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos #define BLOCK_SIZE_X 8 #define BLOCK_SIZE_Y 8 diff --git a/aitviewer/shaders/marching_cubes/compact.cs.glsl b/aitviewer/shaders/marching_cubes/compact.cs.glsl index 85e55d4..79883e3 100644 --- a/aitviewer/shaders/marching_cubes/compact.cs.glsl +++ b/aitviewer/shaders/marching_cubes/compact.cs.glsl @@ -2,7 +2,7 @@ #extension GL_KHR_shader_subgroup_ballot : enable #extension GL_KHR_shader_subgroup_arithmetic : enable -/* Copyright (C) 2023 Dario Mylonopoulos */ +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos #define COMPACT_GROUP_SIZE 128 diff --git a/aitviewer/shaders/marching_cubes/marching_cubes.cs.glsl b/aitviewer/shaders/marching_cubes/marching_cubes.cs.glsl index 7878b28..45513df 100644 --- a/aitviewer/shaders/marching_cubes/marching_cubes.cs.glsl +++ b/aitviewer/shaders/marching_cubes/marching_cubes.cs.glsl @@ -2,7 +2,7 @@ #extension GL_KHR_shader_subgroup_ballot : enable #extension GL_KHR_shader_subgroup_arithmetic : enable -/* Copyright (C) 2023 Dario Mylonopoulos */ +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos #include marching_cubes/common.glsl #include marching_cubes/tables.glsl diff --git a/aitviewer/shaders/marching_cubes/tables.glsl b/aitviewer/shaders/marching_cubes/tables.glsl index 5c7d952..6608c78 100644 --- a/aitviewer/shaders/marching_cubes/tables.glsl +++ b/aitviewer/shaders/marching_cubes/tables.glsl @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Dario Mylonopoulos */ +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos const uvec4 table_edge_mapping[12] = { diff --git a/aitviewer/shaders/mesh_positions.vs.glsl b/aitviewer/shaders/mesh_positions.vs.glsl index eee776a..ab90742 100644 --- a/aitviewer/shaders/mesh_positions.vs.glsl +++ b/aitviewer/shaders/mesh_positions.vs.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #define INSTANCED 0 #if defined VERTEX_SHADER diff --git a/aitviewer/shaders/outline/outline_draw.glsl b/aitviewer/shaders/outline/outline_draw.glsl index 6a23112..26ec44a 100644 --- a/aitviewer/shaders/outline/outline_draw.glsl +++ b/aitviewer/shaders/outline/outline_draw.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined VERTEX_SHADER in vec3 in_position; diff --git a/aitviewer/shaders/outline/outline_prepare.fs.glsl b/aitviewer/shaders/outline/outline_prepare.fs.glsl index 29f1f89..9c944c3 100644 --- a/aitviewer/shaders/outline/outline_prepare.fs.glsl +++ b/aitviewer/shaders/outline/outline_prepare.fs.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined VERTEX_SHADER in vec3 in_position; diff --git a/aitviewer/shaders/screen_texture.glsl b/aitviewer/shaders/screen_texture.glsl index 4911c62..5299e43 100644 --- a/aitviewer/shaders/screen_texture.glsl +++ b/aitviewer/shaders/screen_texture.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined VERTEX_SHADER in vec3 in_position; diff --git a/aitviewer/shaders/shadow_mapping/depth_only.fs.glsl b/aitviewer/shaders/shadow_mapping/depth_only.fs.glsl index 0d9de6b..ff9ef41 100644 --- a/aitviewer/shaders/shadow_mapping/depth_only.fs.glsl +++ b/aitviewer/shaders/shadow_mapping/depth_only.fs.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined FRAGMENT_SHADER #include clipping.glsl diff --git a/aitviewer/shaders/shadow_mapping/raw_depth.glsl b/aitviewer/shaders/shadow_mapping/raw_depth.glsl index 5d49e5d..b765aed 100644 --- a/aitviewer/shaders/shadow_mapping/raw_depth.glsl +++ b/aitviewer/shaders/shadow_mapping/raw_depth.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined VERTEX_SHADER in vec3 in_position; diff --git a/aitviewer/shaders/simple_unlit.glsl b/aitviewer/shaders/simple_unlit.glsl index 88f4095..1503e27 100644 --- a/aitviewer/shaders/simple_unlit.glsl +++ b/aitviewer/shaders/simple_unlit.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined VERTEX_SHADER in vec3 in_position; diff --git a/aitviewer/shaders/sphere_instanced.vs.glsl b/aitviewer/shaders/sphere_instanced.vs.glsl index 692bc3a..570ee53 100644 --- a/aitviewer/shaders/sphere_instanced.vs.glsl +++ b/aitviewer/shaders/sphere_instanced.vs.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #include directional_lights.glsl #if defined VERTEX_SHADER diff --git a/aitviewer/shaders/sphere_instanced_positions.vs.glsl b/aitviewer/shaders/sphere_instanced_positions.vs.glsl index fcacd36..d333d4a 100644 --- a/aitviewer/shaders/sphere_instanced_positions.vs.glsl +++ b/aitviewer/shaders/sphere_instanced_positions.vs.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined VERTEX_SHADER uniform mat4 view_projection_matrix; uniform mat4 model_matrix; diff --git a/aitviewer/shaders/visualize.glsl b/aitviewer/shaders/visualize.glsl index 3e2bc1c..81c8a6a 100644 --- a/aitviewer/shaders/visualize.glsl +++ b/aitviewer/shaders/visualize.glsl @@ -1,5 +1,7 @@ #version 400 +// Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + #if defined VERTEX_SHADER in vec3 in_position; diff --git a/aitviewer/streamables/streamable.py b/aitviewer/streamables/streamable.py index 2899bca..819b9f1 100644 --- a/aitviewer/streamables/streamable.py +++ b/aitviewer/streamables/streamable.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from aitviewer.scene.node import Node diff --git a/aitviewer/streamables/webcam.py b/aitviewer/streamables/webcam.py index 2ff8157..9eddc5d 100644 --- a/aitviewer/streamables/webcam.py +++ b/aitviewer/streamables/webcam.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import cv2 import numpy as np from moderngl_window import geometry diff --git a/aitviewer/utils/decorators.py b/aitviewer/utils/decorators.py index 99c27be..c1f9223 100644 --- a/aitviewer/utils/decorators.py +++ b/aitviewer/utils/decorators.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos def requires_ctx(func): diff --git a/aitviewer/utils/exceptions.py b/aitviewer/utils/exceptions.py index 5afa816..f41e1ba 100644 --- a/aitviewer/utils/exceptions.py +++ b/aitviewer/utils/exceptions.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos class ExceptionModule(object): diff --git a/aitviewer/utils/imgui_integration.py b/aitviewer/utils/imgui_integration.py index ea0ea00..49e4162 100644 --- a/aitviewer/utils/imgui_integration.py +++ b/aitviewer/utils/imgui_integration.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import ctypes diff --git a/aitviewer/utils/marching_cubes_table.py b/aitviewer/utils/marching_cubes_table.py index 96556dd..ae86b82 100644 --- a/aitviewer/utils/marching_cubes_table.py +++ b/aitviewer/utils/marching_cubes_table.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np X = 255 diff --git a/aitviewer/utils/path.py b/aitviewer/utils/path.py index 579b088..7aed7cd 100644 --- a/aitviewer/utils/path.py +++ b/aitviewer/utils/path.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np import scipy.ndimage diff --git a/aitviewer/utils/perf_timer.py b/aitviewer/utils/perf_timer.py index 71eb1e1..566b477 100644 --- a/aitviewer/utils/perf_timer.py +++ b/aitviewer/utils/perf_timer.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import time from typing import Tuple diff --git a/aitviewer/utils/pyqt5_window.py b/aitviewer/utils/pyqt5_window.py index ba198ae..4432969 100644 --- a/aitviewer/utils/pyqt5_window.py +++ b/aitviewer/utils/pyqt5_window.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from moderngl_window.context.pyqt5 import Window from PyQt5 import QtGui, QtOpenGL, QtWidgets diff --git a/aitviewer/utils/pyqt6_window.py b/aitviewer/utils/pyqt6_window.py new file mode 100644 index 0000000..41e4c36 --- /dev/null +++ b/aitviewer/utils/pyqt6_window.py @@ -0,0 +1,438 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos + +from typing import Tuple + +from moderngl_window.context.base import BaseKeys, BaseWindow +from PyQt6 import QtCore, QtGui, QtWidgets +from PyQt6.QtCore import Qt +from PyQt6.QtOpenGL import QOpenGLWindow + + +class Keys(BaseKeys): + """ + Namespace mapping pyqt specific key constants + """ + + ESCAPE = Qt.Key.Key_Escape + SPACE = Qt.Key.Key_Space + ENTER = Qt.Key.Key_Return + # ENTER = Qt.Key.Key_Enter #This is numpad enter + PAGE_UP = Qt.Key.Key_PageUp + PAGE_DOWN = Qt.Key.Key_PageDown + LEFT = Qt.Key.Key_Left + RIGHT = Qt.Key.Key_Right + UP = Qt.Key.Key_Up + DOWN = Qt.Key.Key_Down + + TAB = Qt.Key.Key_Tab + COMMA = Qt.Key.Key_Comma + MINUS = Qt.Key.Key_Minus + PERIOD = Qt.Key.Key_Period + SLASH = Qt.Key.Key_Slash + SEMICOLON = Qt.Key.Key_Semicolon + EQUAL = Qt.Key.Key_Equal + LEFT_BRACKET = Qt.Key.Key_BracketLeft + RIGHT_BRACKET = Qt.Key.Key_BracketRight + BACKSLASH = Qt.Key.Key_Backslash + BACKSPACE = Qt.Key.Key_Backspace + INSERT = Qt.Key.Key_Insert + DELETE = Qt.Key.Key_Delete + HOME = Qt.Key.Key_Home + END = Qt.Key.Key_End + CAPS_LOCK = Qt.Key.Key_CapsLock + + F1 = Qt.Key.Key_F1 + F2 = Qt.Key.Key_F2 + F3 = Qt.Key.Key_F3 + F4 = Qt.Key.Key_F4 + F5 = Qt.Key.Key_F5 + F6 = Qt.Key.Key_F6 + F7 = Qt.Key.Key_F7 + F8 = Qt.Key.Key_F8 + F9 = Qt.Key.Key_F9 + F10 = Qt.Key.Key_F10 + F11 = Qt.Key.Key_F11 + F12 = Qt.Key.Key_F12 + + NUMBER_0 = Qt.Key.Key_0 + NUMBER_1 = Qt.Key.Key_1 + NUMBER_2 = Qt.Key.Key_2 + NUMBER_3 = Qt.Key.Key_3 + NUMBER_4 = Qt.Key.Key_4 + NUMBER_5 = Qt.Key.Key_5 + NUMBER_6 = Qt.Key.Key_6 + NUMBER_7 = Qt.Key.Key_7 + NUMBER_8 = Qt.Key.Key_8 + NUMBER_9 = Qt.Key.Key_9 + + # Uses a modifier for numpad. We just repeat the numbers for compatibility + NUMPAD_0 = Qt.Key.Key_0 + NUMPAD_1 = Qt.Key.Key_1 + NUMPAD_2 = Qt.Key.Key_2 + NUMPAD_3 = Qt.Key.Key_3 + NUMPAD_4 = Qt.Key.Key_4 + NUMPAD_5 = Qt.Key.Key_5 + NUMPAD_6 = Qt.Key.Key_6 + NUMPAD_7 = Qt.Key.Key_7 + NUMPAD_8 = Qt.Key.Key_8 + NUMPAD_9 = Qt.Key.Key_9 + + A = Qt.Key.Key_A + B = Qt.Key.Key_B + C = Qt.Key.Key_C + D = Qt.Key.Key_D + E = Qt.Key.Key_E + F = Qt.Key.Key_F + G = Qt.Key.Key_G + H = Qt.Key.Key_H + I = Qt.Key.Key_I + J = Qt.Key.Key_J + K = Qt.Key.Key_K + L = Qt.Key.Key_L + M = Qt.Key.Key_M + N = Qt.Key.Key_N + O = Qt.Key.Key_O + P = Qt.Key.Key_P + Q = Qt.Key.Key_Q + R = Qt.Key.Key_R + S = Qt.Key.Key_S + T = Qt.Key.Key_T + U = Qt.Key.Key_U + V = Qt.Key.Key_V + W = Qt.Key.Key_W + X = Qt.Key.Key_X + Y = Qt.Key.Key_Y + Z = Qt.Key.Key_Z + + +class GLWindow(QOpenGLWindow): + def __init__(self, gl_version, vsync, samples): + super().__init__() + fmt = QtGui.QSurfaceFormat() + fmt.setVersion(gl_version[0], gl_version[1]) + fmt.setProfile(QtGui.QSurfaceFormat.OpenGLContextProfile.CoreProfile) + fmt.setDepthBufferSize(24) + fmt.setSwapBehavior(QtGui.QSurfaceFormat.SwapBehavior.DoubleBuffer) + fmt.setSwapInterval(1 if vsync else 0) + fmt.setAlphaBufferSize(8) + if samples > 1: + fmt.setSamples(int(samples)) + self.setFormat(fmt) + + def initializeGL(self): + pass + + def paintGL(self) -> None: + pass + + +class PyQt6Window(BaseWindow): + """ + A basic window implementation using PyQt5 with the goal of + creating an OpenGL context and handle keyboard and mouse input. + + This window bypasses Qt's own event loop to make things as flexible as possible. + + If you need to use the event loop and are using other features + in Qt as well, this example can still be useful as a reference + when creating your own window. + """ + + #: Name of the window + name = "pyqt6" + #: PyQt6 specific key constants + keys = Keys + + # PyQt supports mode buttons, but we are limited by other libraries + _mouse_button_map = { + QtCore.Qt.MouseButton.LeftButton: 1, + QtCore.Qt.MouseButton.RightButton: 2, + QtCore.Qt.MouseButton.MiddleButton: 3, + } + + def __init__(self, **kwargs): + super().__init__(**kwargs) + + # We need an application object, but we are bypassing the library's + # internal event loop to avoid unnecessary work + self._app = QtWidgets.QApplication([]) + # Create the OpenGL window + self._widget = GLWindow(self.gl_version, self._vsync, self.samples) + self.title = self._title + + if self.resizable: + self._widget.resize(self.width, self.height) + else: + self._widget.setMaximumSize(QtCore.QSize(self.width, self.height)) + self._widget.setMinimumSize(QtCore.QSize(self.width, self.height)) + + # Needs to be set before show() + self._widget.resizeGL = self.resize + + self.cursor = self._cursor + + if self.fullscreen: + self._widget.showFullScreen() + else: + self._widget.show() + + # Override event functions in qt + self._widget.keyPressEvent = self.key_pressed_event + self._widget.keyReleaseEvent = self.key_release_event + self._widget.mouseMoveEvent = self.mouse_move_event + self._widget.mousePressEvent = self.mouse_press_event + self._widget.mouseReleaseEvent = self.mouse_release_event + self._widget.wheelEvent = self.mouse_wheel_event + self._widget.closeEvent = self.close_event + self._widget.showEvent = self.show_event + self._widget.hideEvent = self.hide_event + + # # Attach to the context + self.init_mgl_context() + + # Ensure retina and 4k displays get the right viewport + self._buffer_width = int(self._width * self._widget.devicePixelRatio()) + self._buffer_height = int(self._height * self._widget.devicePixelRatio()) + + self.set_default_viewport() + + def _set_icon(self, icon_path: str) -> None: + self._widget.setIcon(QtGui.QIcon(str(icon_path))) + pass + + def _set_fullscreen(self, value: bool) -> None: + if value: + self._widget.showFullScreen() + else: + self._widget.showNormal() + + @property + def size(self) -> Tuple[int, int]: + """Tuple[int, int]: current window size. + + This property also support assignment:: + + # Resize the window to 1000 x 1000 + window.size = 1000, 1000 + """ + return self._width, self._height + + @size.setter + def size(self, value: Tuple[int, int]): + pos = self.position + self._widget.setGeometry(pos[0], pos[1], value[0], value[1]) + + @property + def position(self) -> Tuple[int, int]: + """Tuple[int, int]: The current window position. + + This property can also be set to move the window:: + + # Move window to 100, 100 + window.position = 100, 100 + """ + geo = self._widget.geometry() + return geo.x(), geo.y() + + @position.setter + def position(self, value: Tuple[int, int]): + self._widget.setGeometry(value[0], value[1], self._width, self._height) + + def swap_buffers(self) -> None: + """Swap buffers, set viewport, trigger events and increment frame counter""" + + # Trigger a redraw, equivalent to self._widget.swapBuffers for Qt5. + self._widget.event(QtGui.QPaintEvent(QtGui.QRegion())) + self.set_default_viewport() + QtWidgets.QApplication.processEvents() + self._frames += 1 + + @property + def cursor(self) -> bool: + """bool: Should the mouse cursor be visible inside the window? + + This property can also be assigned to:: + + # Disable cursor + window.cursor = False + """ + return self._cursor + + @cursor.setter + def cursor(self, value: bool): + if value is True: + self._widget.setCursor(QtCore.Qt.CursorShape.ArrowCursor) + else: + self._widget.setCursor(QtCore.Qt.CursorShape.BlankCursor) + + self._cursor = value + + @property + def title(self) -> str: + """str: Window title. + + This property can also be set:: + + window.title = "New Title" + """ + return self._title + + @title.setter + def title(self, value: str): + self._widget.setTitle(value) + self._title = value + + def resize(self, width: int, height: int) -> None: + """Replacement for Qt's ``resizeGL`` method. + + Args: + width: New window width + height: New window height + """ + # NOTE(dario): Do not attempt to resize if the window is closing. + # This crashes if the OpenGL context has already been destroyed, + # which seems to be the case when manually closing the window from + # the cross on windows. + if self.is_closing: + return + + self._width = width + self._height = height + self._buffer_width = int(width * self._widget.devicePixelRatio()) + self._buffer_height = int(height * self._widget.devicePixelRatio()) + + if self._ctx: + self.set_default_viewport() + + # Make sure we notify the example about the resize + super().resize(self._buffer_width, self._buffer_height) + + def _handle_modifiers(self, mods) -> None: + """Update modifiers""" + self._modifiers.shift = bool(mods & QtCore.Qt.KeyboardModifier.ShiftModifier) + self._modifiers.ctrl = bool(mods & QtCore.Qt.KeyboardModifier.ControlModifier) + self._modifiers.alt = bool(mods & QtCore.Qt.KeyboardModifier.AltModifier) + + def _set_icon(self, icon_path: str) -> None: + self._widget.setIcon(QtGui.QIcon(icon_path)) + + def key_pressed_event(self, event: QtGui.QKeyEvent) -> None: + """Process Qt key press events forwarding them to standard methods + + Args: + event: The qtevent instance + """ + if self._exit_key is not None and event.key() == self._exit_key: + self.close() + + if self._fs_key is not None and event.key() == self._fs_key: + self.fullscreen = not self.fullscreen + + self._handle_modifiers(event.modifiers()) + self._key_pressed_map[event.key()] = True + self._key_event_func(event.key(), self.keys.ACTION_PRESS, self._modifiers) + + text = event.text() + if text.strip() or event.key() == self.keys.SPACE: + self._unicode_char_entered_func(text) + + def key_release_event(self, event: QtGui.QKeyEvent) -> None: + """Process Qt key release events forwarding them to standard methods + + Args: + event: The qtevent instance + """ + self._handle_modifiers(event.modifiers()) + self._key_pressed_map[event.key()] = False + self._key_event_func(event.key(), self.keys.ACTION_RELEASE, self._modifiers) + + def mouse_move_event(self, event: QtGui.QMouseEvent) -> None: + """Forward mouse cursor position events to standard methods + + Args: + event: The qtevent instance + """ + x, y = event.pos().x(), event.pos().y() + dx, dy = self._calc_mouse_delta(x, y) + + if self.mouse_states.any: + self._mouse_drag_event_func(x, y, dx, dy) + else: + self._mouse_position_event_func(x, y, dx, dy) + + def mouse_press_event(self, event: QtGui.QMouseEvent) -> None: + """Forward mouse press events to standard methods + + Args: + event: The qtevent instance + """ + self._handle_modifiers(event.modifiers()) + button = self._mouse_button_map.get(event.button()) + if button is None: + return + self._handle_mouse_button_state_change(button, True) + self._mouse_press_event_func(event.pos().x(), event.pos().y(), button) + + def mouse_release_event(self, event: QtGui.QMouseEvent) -> None: + """Forward mouse release events to standard methods + + Args: + event: The qtevent instance + """ + self._handle_modifiers(event.modifiers()) + button = self._mouse_button_map.get(event.button()) + if button is None: + return + + self._handle_mouse_button_state_change(button, False) + self._mouse_release_event_func(event.pos().x(), event.pos().y(), button) + + def mouse_wheel_event(self, event: QtGui.QWheelEvent): + """Forward mouse wheel events to standard metods. + + From Qt docs: + + Returns the distance that the wheel is rotated, in eighths of a degree. + A positive value indicates that the wheel was rotated forwards away from the user; + a negative value indicates that the wheel was rotated backwards toward the user. + + Most mouse types work in steps of 15 degrees, in which case the delta value is a + multiple of 120; i.e., 120 units * 1/8 = 15 degrees. + + However, some mice have finer-resolution wheels and send delta values that are less + than 120 units (less than 15 degrees). To support this possibility, you can either + cumulatively add the delta values from events until the value of 120 is reached, + then scroll the widget, or you can partially scroll the widget in response to each + wheel event. + + Args: + event (QWheelEvent): Mouse wheel event + """ + self._handle_modifiers(event.modifiers()) + point = event.angleDelta() + self._mouse_scroll_event_func(point.x() / 120.0, point.y() / 120.0) + + def close_event(self, event) -> None: + """The standard PyQt close events + + Args: + event: The qtevent instance + """ + self.close() + + def close(self): + """Close the window""" + super().close() + self._close_func() + + def show_event(self, event): + """The standard Qt show event""" + self._iconify_func(False) + + def hide_event(self, event): + """The standard Qt hide event""" + self._iconify_func(True) + + def destroy(self) -> None: + """Quit the Qt application to exit the window gracefully""" + QtCore.QCoreApplication.instance().quit() diff --git a/aitviewer/utils/so3.py b/aitviewer/utils/so3.py index 75abc59..fd0d73d 100644 --- a/aitviewer/utils/so3.py +++ b/aitviewer/utils/so3.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np import roma import torch diff --git a/aitviewer/utils/usd.py b/aitviewer/utils/usd.py index 3b80333..61575ca 100644 --- a/aitviewer/utils/usd.py +++ b/aitviewer/utils/usd.py @@ -1,9 +1,10 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import shutil import numpy as np from PIL import Image -from pxr import Sdf, UsdShade +from pxr import Gf, Sdf, UsdGeom, UsdShade def _get_texture_paths(path, name, directory): @@ -27,6 +28,26 @@ def save_image_as_texture(img, img_name, name, directory): return usd_path +def add_color(stage, mesh, usd_path, color): + # Material. + mat_path = usd_path + "/material" + material = UsdShade.Material.Define(stage, mat_path) + + # Shader. + shader = UsdShade.Shader.Define(stage, mat_path + "/shader") + shader.CreateIdAttr("UsdPreviewSurface") + + # Connect the material to the shader. + material.CreateSurfaceOutput().ConnectToSource(shader.ConnectableAPI(), "surface") + + # Create a uniform color.np. + shader.CreateInput("diffuseColor", Sdf.ValueTypeNames.Color3f).Set(tuple(color)) + + # Bind the Material to the mesh. + mesh.GetPrim().ApplyAPI(UsdShade.MaterialBindingAPI) + UsdShade.MaterialBindingAPI(mesh).Bind(material) + + def add_texture(stage, mesh, usd_path, texture_path): # Material. mat_path = usd_path + "/material" @@ -57,3 +78,20 @@ def add_texture(stage, mesh, usd_path, texture_path): # Bind the Material to the mesh. mesh.GetPrim().ApplyAPI(UsdShade.MaterialBindingAPI) UsdShade.MaterialBindingAPI(mesh).Bind(material) + + +def add_mesh(stage, usd_path, name, vertices, faces, transform): + # Transform. + xform = UsdGeom.Xform.Define(stage, usd_path) + a_xform = xform.AddTransformOp() + a_xform.Set(Gf.Matrix4d(transform.astype(np.float64).T)) + + # Geometry. + mesh = UsdGeom.Mesh.Define(stage, usd_path + "/" + name.replace(" ", "_")) + a_vertices = mesh.CreatePointsAttr() + for i in range(vertices.shape[0]): + a_vertices.Set(time=i + 1, value=vertices[i]) + mesh.CreateFaceVertexCountsAttr(np.full(faces.shape[0], 3)) + mesh.CreateFaceVertexIndicesAttr(faces) + + return mesh diff --git a/aitviewer/utils/utils.py b/aitviewer/utils/utils.py index 6ead64c..f324223 100644 --- a/aitviewer/utils/utils.py +++ b/aitviewer/utils/utils.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import subprocess diff --git a/aitviewer/viewer.py b/aitviewer/viewer.py index 4f657b9..779beb8 100644 --- a/aitviewer/viewer.py +++ b/aitviewer/viewer.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import copy import os import sys @@ -121,6 +106,10 @@ def __init__( from aitviewer.utils.pyqt5_window import PyQt5Window base_window_cls = PyQt5Window + elif self.window_type == "pyqt6": + from aitviewer.utils.pyqt6_window import PyQt6Window + + base_window_cls = PyQt6Window else: base_window_cls = get_local_window_cls(self.window_type) @@ -791,7 +780,6 @@ def menu_entry(text, name): if clicked: self.center_view_on_selection() - # TODO (@Dario): correct to only use self.viewports[0] here? is_ortho = False if self.viewports[0].using_temp_camera else self.scene.camera.is_ortho _, is_ortho = imgui.menu_item( "Orthographic Camera", @@ -799,13 +787,12 @@ def menu_entry(text, name): is_ortho, True, ) - # TODO (@Dario): correct to only use self.viewports[0] here? + if is_ortho and self.viewports[0].using_temp_camera: self.reset_camera() self.scene.camera.is_ortho = is_ortho - # TODO (@Dario) - if not self.viewports[0].using_temp_camera and imgui.begin_menu("Control modes"): + if imgui.begin_menu("Control modes", enabled=not self.viewports[0].using_temp_camera): def mode(name, mode): selected = imgui.menu_item(name, None, self.scene.camera.control_mode == mode)[1] @@ -885,7 +872,9 @@ def mode(name, mode): def gui_export_video(self): imgui.set_next_window_size(570, 0) - if imgui.begin_popup_modal("Export Video", flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE)[0]: + if imgui.begin_popup_modal( + "Export Video", flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_SAVED_SETTINGS + )[0]: if self.scene.n_frames == 1: imgui.push_style_var(imgui.STYLE_ALPHA, 0.2) self.export_animation = False @@ -1117,7 +1106,7 @@ def gui_export_video(self): def gui_playback(self): """GUI to control playback settings.""" imgui.set_next_window_position(50, 100 + self.window_size[1] * 0.7, imgui.FIRST_USE_EVER) - imgui.set_next_window_size(self.window_size[0] * 0.4, self.window_size[1] * 0.15, imgui.FIRST_USE_EVER) + imgui.set_next_window_size(self.window_size[0] * 0.4, self.window_size[1] * 0.175, imgui.FIRST_USE_EVER) expanded, _ = imgui.begin("Playback", None) if expanded: u, run_animations = imgui.checkbox( @@ -1164,6 +1153,10 @@ def gui_playback(self): max_value=n_frames - 1, ) self.prevent_background_interactions() + if imgui.collapsing_header("Advanced options")[0]: + _, self.playback_without_skipping = imgui.checkbox( + "Playback without skipping", self.playback_without_skipping + ) imgui.end() def gui_shortcuts(self): @@ -1198,7 +1191,10 @@ def gui_go_to_frame(self): imgui.set_next_window_size(300, 0) if imgui.begin_popup_modal( "Go to frame##go-to-frame-popup", - flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_TITLE_BAR, + flags=imgui.WINDOW_NO_RESIZE + | imgui.WINDOW_NO_MOVE + | imgui.WINDOW_NO_TITLE_BAR + | imgui.WINDOW_NO_SAVED_SETTINGS, )[0]: if self._go_to_frame_popup_open: imgui.set_keyboard_focus_here() @@ -1236,7 +1232,7 @@ def gui_screenshot(self): imgui.set_next_window_size(250, 0) if imgui.begin_popup_modal( "Screenshot##screenshot-popup", - flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE, + flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_SAVED_SETTINGS, )[0]: if self._screenshot_popup_open: _, self.screenshot_transparent = imgui.checkbox("Transparent background", self.screenshot_transparent) @@ -1293,7 +1289,7 @@ def gui_export_usd(self): imgui.set_next_window_size(570, 0) if imgui.begin_popup_modal( "Export USD##export-usd-popup", - flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE, + flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_SAVED_SETTINGS, )[0]: if self._export_usd_popup_open: # Export selection tree. @@ -1348,7 +1344,7 @@ def tree(nodes): imgui.end_child() if self.export_usd_name is None: - self.export_usd_name = "frame_{:0>6}".format(self.scene.current_frame_id) + self.export_usd_name = "scene" # HACK: we need to set the focus twice when the modal is first opened for it to take effect. if self._modal_focus_count > 0: @@ -1388,7 +1384,8 @@ def tree(nodes): self.export_usd( os.path.join(C.export_dir, "usd", f"{self.export_usd_name}"), self.export_usd_directory, - True, + False, + False, ) imgui.close_current_popup() self._export_usd_popup_open = False @@ -1401,7 +1398,9 @@ def gui_exit(self): if self._exit_popup_open: imgui.open_popup("Exit##exit-popup") - if imgui.begin_popup_modal("Exit##exit-popup", flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE)[0]: + if imgui.begin_popup_modal( + "Exit##exit-popup", flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_SAVED_SETTINGS + )[0]: if self._exit_popup_open: imgui.text("Are you sure you want to exit?") imgui.spacing() @@ -1491,9 +1490,13 @@ def center_view_on_node(self, node, with_animation=False): diag = np.linalg.norm(bounds[:, 0] - bounds[:, 1]) dist = max(0.01, diag * 1.3) - center = bounds.mean(-1) - anim_time = 0.25 if with_animation else 0.0 - self.scene.camera.move_with_animation(center - forward * dist, center, anim_time) + target = bounds.mean(-1) + position = target - forward * dist + if with_animation: + self.scene.camera.move_with_animation(position, target, 0.25) + else: + self.scene.camera.position = position + self.scene.camera.target = target def resize(self, width: int, height: int): self.window_size = (width, height) @@ -1770,20 +1773,21 @@ def export_frame(self, file_path, scale_factor: float = None, transparent_backgr self.run_animations = run_animations self._last_frame_rendered_at = self.timer.time - def export_usd(self, path: str, export_as_directory=False, verbose=False): + def export_usd(self, path: str, export_as_directory=False, verbose=False, ascii=False): from pxr import Usd, UsdGeom + extension = ".usd" if not ascii else ".usda" if export_as_directory: - if path.endswith(".usd"): + if path.endswith(extension): directory = path[:-4] else: directory = path os.makedirs(directory, exist_ok=True) - path = os.path.join(directory, os.path.basename(directory) + ".usd") + path = os.path.join(directory, os.path.basename(directory) + extension) else: directory = None - if not path.endswith(".usd"): - path += ".usd" + if not path.endswith(extension): + path += extension # Create a new file and setup scene parameters. stage = Usd.Stage.CreateNew(path) diff --git a/examples/animation.py b/examples/animation.py index d809683..a520139 100644 --- a/examples/animation.py +++ b/examples/animation.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np import trimesh diff --git a/examples/camera_path.py b/examples/camera_path.py index 57f67a2..441aad6 100644 --- a/examples/camera_path.py +++ b/examples/camera_path.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.configuration import CONFIG as C diff --git a/examples/headless_rendering.py b/examples/headless_rendering.py index e1f43ed..7470fe4 100644 --- a/examples/headless_rendering.py +++ b/examples/headless_rendering.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import numpy as np diff --git a/examples/load_3DPW.py b/examples/load_3DPW.py index 1df7e77..37323fb 100644 --- a/examples/load_3DPW.py +++ b/examples/load_3DPW.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import glob import os diff --git a/examples/load_AMASS.py b/examples/load_AMASS.py index 88e1d38..24a3add 100644 --- a/examples/load_AMASS.py +++ b/examples/load_AMASS.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import numpy as np diff --git a/examples/load_DIP_IMU.py b/examples/load_DIP_IMU.py index 177e130..45dffe3 100644 --- a/examples/load_DIP_IMU.py +++ b/examples/load_DIP_IMU.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import pickle as pkl import torch diff --git a/examples/load_DIP_TC.py b/examples/load_DIP_TC.py index 5640fc8..6ff2da7 100644 --- a/examples/load_DIP_TC.py +++ b/examples/load_DIP_TC.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import pickle as pkl import torch diff --git a/examples/load_GLAMR.py b/examples/load_GLAMR.py index e7f6cf3..b1a2e32 100644 --- a/examples/load_GLAMR.py +++ b/examples/load_GLAMR.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import pickle import re diff --git a/examples/load_ROMP.py b/examples/load_ROMP.py index fda1d96..e2ad92b 100644 --- a/examples/load_ROMP.py +++ b/examples/load_ROMP.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import cv2 import numpy as np diff --git a/examples/load_STAR.py b/examples/load_STAR.py index 2a06892..f01039f 100644 --- a/examples/load_STAR.py +++ b/examples/load_STAR.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os from aitviewer.configuration import CONFIG as C diff --git a/examples/load_SUPR.py b/examples/load_SUPR.py index 667db32..f2fe3b3 100644 --- a/examples/load_SUPR.py +++ b/examples/load_SUPR.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from aitviewer.renderables.supr import SUPRLayer, SUPRSequence from aitviewer.viewer import Viewer diff --git a/examples/load_VIBE.py b/examples/load_VIBE.py index 3709e21..390c03a 100644 --- a/examples/load_VIBE.py +++ b/examples/load_VIBE.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import re diff --git a/examples/load_obj.py b/examples/load_obj.py index 11b4443..146caa0 100644 --- a/examples/load_obj.py +++ b/examples/load_obj.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import trimesh from aitviewer.renderables.meshes import Meshes diff --git a/examples/load_template.py b/examples/load_template.py index f53d8ac..6358b38 100644 --- a/examples/load_template.py +++ b/examples/load_template.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.configuration import CONFIG as C diff --git a/examples/missing_frames.py b/examples/missing_frames.py index 8fe2e07..7422f5e 100644 --- a/examples/missing_frames.py +++ b/examples/missing_frames.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import joblib import numpy as np diff --git a/examples/quickstart.py b/examples/quickstart.py index 921f811..1d723ac 100644 --- a/examples/quickstart.py +++ b/examples/quickstart.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from aitviewer.renderables.smpl import SMPLSequence from aitviewer.viewer import Viewer diff --git a/examples/remote.py b/examples/remote.py index 4244b09..5c51063 100644 --- a/examples/remote.py +++ b/examples/remote.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np import trimesh diff --git a/examples/remote_amass.py b/examples/remote_amass.py index c121b7d..b43868a 100644 --- a/examples/remote_amass.py +++ b/examples/remote_amass.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os from pathlib import Path from random import random, shuffle diff --git a/examples/remote_custom_viewer.py b/examples/remote_custom_viewer.py index c2b5f23..8cc2e2f 100644 --- a/examples/remote_custom_viewer.py +++ b/examples/remote_custom_viewer.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import argparse from typing import Tuple diff --git a/examples/remote_two_way_communication.py b/examples/remote_two_way_communication.py index d7c421c..d2f66b8 100644 --- a/examples/remote_two_way_communication.py +++ b/examples/remote_two_way_communication.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import argparse # Parse command line arguments. diff --git a/examples/render_primitives.py b/examples/render_primitives.py index cb40634..abaeade 100644 --- a/examples/render_primitives.py +++ b/examples/render_primitives.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.renderables.lines import Lines diff --git a/examples/sdf_gpu_shader.py b/examples/sdf_gpu_shader.py index d02d21e..a4f8cd0 100644 --- a/examples/sdf_gpu_shader.py +++ b/examples/sdf_gpu_shader.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.renderables.volume import Volume diff --git a/examples/sdf_skimage.py b/examples/sdf_skimage.py index 3321d84..ffc0850 100644 --- a/examples/sdf_skimage.py +++ b/examples/sdf_skimage.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.renderables.sdf import SDF diff --git a/examples/stream.py b/examples/stream.py index e1b9630..2147973 100644 --- a/examples/stream.py +++ b/examples/stream.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos from aitviewer.streamables.webcam import Webcam from aitviewer.viewer import Viewer diff --git a/examples/vertex_clicking.py b/examples/vertex_clicking.py index 1a43524..f941587 100644 --- a/examples/vertex_clicking.py +++ b/examples/vertex_clicking.py @@ -1,19 +1,4 @@ -""" -Copyright (C) 2022 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import numpy as np from aitviewer.configuration import CONFIG as C diff --git a/setup.py b/setup.py index 4eddf59..4f6bb6f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,39 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos +import os + from setuptools import find_packages, setup from aitviewer import __version__ +INSTALL_PYQT6 = os.getenv("AITVIEWER_INSTALL_PYQT6", 0) + +requirements = [ + "torch>=1.6.0", + "numpy>=1.18,<2", + "opencv-contrib-python-headless>=4.5.1.48", + "smplx", + "moderngl-window>=2.4.3", + "moderngl>=5.8.2,<6", + "imgui==2.0.0", + "tqdm>=4.60.0", + "trimesh>=3.9.15,<4", + "scipy>=1.5.2", + "omegaconf>=2.1.1", + "roma>=1.2.3", + "joblib", + "scikit-image>=0.9.0", + "scikit-video", + "Pillow", + "websockets", + "usd-core>=23.5", +] + +# Choose PyQt version depending on environment variable. +if INSTALL_PYQT6: + requirements.append("PyQt6>=6.5.2") +else: + requirements.append("PyQt5>=5.15.4") + setup( name="aitviewer", description="Viewing and rendering of sequences of 3D data.", @@ -25,26 +57,6 @@ "visualization", ], platforms=["any"], - python_requires=">=3.7", - install_requires=[ - "torch>=1.6.0", - "numpy>=1.18,<2", - "opencv-contrib-python-headless>=4.5.1.48", - "smplx", - "moderngl-window>=2.4.3", - "moderngl>=5.8.2,<6", - "PyQt5>=5.15.4", - "imgui==2.0.0", - "tqdm>=4.60.0", - "trimesh>=3.9.15,<4", - "scipy>=1.5.2,<1.8", - "omegaconf>=2.1.1", - "roma>=1.2.3", - "joblib", - "scikit-image>=0.9.0", - "scikit-video", - "Pillow", - "websockets", - "usd-core>=23.5", - ], + python_requires=">=3.7,<3.11", + install_requires=requirements, ) diff --git a/tests/conftest.py b/tests/conftest.py index ebc7a28..ea5f56c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import shutil diff --git a/tests/gen_references.py b/tests/gen_references.py index 1e3120d..fc6e438 100644 --- a/tests/gen_references.py +++ b/tests/gen_references.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import importlib import os import sys diff --git a/tests/test_misc.py b/tests/test_misc.py index 72c1519..8d94680 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os from tempfile import TemporaryDirectory diff --git a/tests/test_renderables.py b/tests/test_renderables.py index ed2846b..180c077 100644 --- a/tests/test_renderables.py +++ b/tests/test_renderables.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import os import numpy as np diff --git a/tests/utils.py b/tests/utils.py index a11be36..cfa731d 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,3 +1,4 @@ +# Copyright (C) 2023 ETH Zurich, Manuel Kaufmann, Velko Vechev, Dario Mylonopoulos import functools import os import shutil