From: Eleni Hikiko Date: Fri, 18 Jul 2014 04:13:36 +0000 (+0300) Subject: initial commit, eq circuit emulator X-Git-Url: http://git.mutantstargoat.com?p=eqemu;a=commitdiff_plain;h=0e2e8209f950a0a99bc08a0a6cc6896d304a7958 initial commit, eq circuit emulator --- 0e2e8209f950a0a99bc08a0a6cc6896d304a7958 diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + 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 +. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d10b33c --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +src = $(wildcard src/*.cc) +obj = $(src:.cc=.o) +dep = $(obj:.o=.d) +bin = eqemu + +libimago_path = libs/libimago +libimago = $(libimago_path)/libimago.a + +CFLAGS = -pedantic -Wall -g -I$(libimago_path)/src +CXXFLAGS = $(CFLAGS) +LDFLAGS = -lGL -lGLU -lGLEW -lX11 -lm -lpthread -L$(libimago_path) -limago -lpng -ljpeg -lz + +$(bin): $(obj) $(libimago) + $(CXX) -o $@ $(obj) $(LDFLAGS) + +-include $(dep) + +%.d: %.cc + @$(CPP) $< $(CXXFLAGS) -MM -MT $(@:.d=.o) >$@ + +.PHONY: $(libimago) +$(libimago): + cd $(libimago_path) && ./configure --disable-debug --enable-opt + $(MAKE) -C $(libimago_path) + +.PHONY: clean +clean: + rm -f $(obj) $(bin) + +.PHONY: clean-libs +clean-libs: + $(MAKE) -C $(libimago_path) clean diff --git a/README b/README new file mode 100644 index 0000000..a1ff5f0 --- /dev/null +++ b/README @@ -0,0 +1,19 @@ +equeue emulator usage +--------------------- +- execute the included RUN script to start a pseudoterminal pair and connect the + emulator to one end. +- then make sure your program connects to the pseudoterminal /tmp/ttyeqemu. + +For testing you can run minicom thus: minicom -D /tmp/ttyeqemu + + +build instructions +------------------ +dependencies: +- OpenGL +- GLEW +- libpng +- libjpeg +- zlib + +After installing all necessary depdencies, just type make. diff --git a/RUN b/RUN new file mode 100755 index 0000000..5616e12 --- /dev/null +++ b/RUN @@ -0,0 +1,13 @@ +#!/bin/sh + +socat PTY,link=emuport PTY,link=/tmp/ttyeqemu & +if [ $? != 0 ]; then + echo "failed to create PTY pair" >&2 + exit 1 +fi + +echo 'starting equeue system emulator. connect to the /tmp/ttyeqemu fake serial port' + +./eqemu emuport + +kill %1 # kill socat diff --git a/data/7seg.png b/data/7seg.png new file mode 100644 index 0000000..d1f5e57 Binary files /dev/null and b/data/7seg.png differ diff --git a/data/7seg_glow.png b/data/7seg_glow.png new file mode 100644 index 0000000..79f45f7 Binary files /dev/null and b/data/7seg_glow.png differ diff --git a/data/device.mtl b/data/device.mtl new file mode 100644 index 0000000..9d7ecbf --- /dev/null +++ b/data/device.mtl @@ -0,0 +1,56 @@ +# box material +newmtl 01___Default + Ns 50.0000 + Ni 1.5000 + d 1.0000 + Tr 0.0000 + Tf 1.0000 1.0000 1.0000 + illum 2 + Ka 0.0314 0.0314 0.0314 + Kd 0.0314 0.0314 0.0314 + Ks 0.8431 0.8431 0.8431 + Ke 0.0000 0.0000 0.0000 + map_Ka /Users/nuclear/code/equeue_dummy/data/labels.png + map_Kd /Users/nuclear/code/equeue_dummy/data/labels.png + map_refl /Users/nuclear/code/equeue_dummy/data/envmap.png + +# ? +newmtl 02___Default + Ns 10.0000 + Ni 1.5000 + d 1.0000 + Tr 0.0000 + Tf 1.0000 1.0000 1.0000 + illum 2 + Ka 0.2431 0.2431 0.2431 + Kd 0.2431 0.2431 0.2431 + Ks 0.0000 0.0000 0.0000 + Ke 0.0000 0.0000 0.0000 + +# LED material +newmtl 03___Default + Ns 24.0000 + Ni 1.5000 + d 1.0000 + Tr 0.0000 + Tf 1.0000 1.0000 1.0000 + illum 2 + Ka 0.2000 0.0100 0.0100 + Kd 0.2000 0.0100 0.0100 + Ks 0.6030 0.6030 0.6030 + Ke 1.0000 0.1 0.05 + +# 7seg material +newmtl 08___Default + Ns 10.0000 + Ni 1.5000 + d 1.0000 + Tr 0.0000 + Tf 1.0000 1.0000 1.0000 + illum 2 + Ka 0.5882 0.5882 0.5882 + Kd 0.5882 0.5882 0.5882 + Ks 0.0000 0.0000 0.0000 + Ke 1.0000 1.0000 1.0000 + map_Ka /Users/nuclear/code/equeue_dummy/data/7seg.png + map_Kd /Users/nuclear/code/equeue_dummy/data/7seg.png diff --git a/data/device.obj b/data/device.obj new file mode 100644 index 0000000..dc659ce --- /dev/null +++ b/data/device.obj @@ -0,0 +1,2255 @@ +# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware +# File Created: 14.07.2014 08:46:21 + +mtllib data/device.mtl + +# +# object box +# + +v -32.2640 59.7640 0.0000 +v -32.2640 33.4866 0.0000 +v -15.0099 33.4866 0.0000 +v -15.0099 59.7640 0.0000 +v 0.0000 33.4866 0.0000 +v 0.0000 59.7640 0.0000 +v -32.2640 13.4957 0.0000 +v -32.2640 -29.8820 -0.0000 +v -15.0099 -29.8820 -0.0000 +v -15.0099 13.4951 0.0000 +v 0.0000 -29.8820 -0.0000 +v 0.0000 13.4951 0.0000 +v -32.2640 -59.7640 -0.0000 +v -15.0099 -59.7640 -0.0000 +v 0.0000 -59.7640 -0.0000 +v -32.2640 61.1320 -0.3665 +v -32.9480 60.9487 -0.3665 +v -33.4487 60.4480 -0.3665 +v -33.6320 59.7640 -0.3665 +v -33.6320 33.4866 -0.3666 +v -33.6320 13.4957 -0.3666 +v -33.6320 -29.8820 -0.3666 +v -33.6320 -59.7640 -0.3666 +v -33.4487 -60.4480 -0.3666 +v -32.9480 -60.9487 -0.3666 +v -32.2640 -61.1320 -0.3666 +v -15.0099 -61.1320 -0.3666 +v 0.0000 -61.1320 -0.3666 +v 0.0000 61.1320 -0.3665 +v -15.0099 61.1320 -0.3665 +v -32.2640 62.1334 -1.3680 +v -33.4487 61.8160 -1.3680 +v -34.3160 60.9487 -1.3680 +v -34.6334 59.7640 -1.3680 +v -34.6334 33.4866 -1.3680 +v -34.6334 13.4957 -1.3680 +v -34.6334 -29.8820 -1.3680 +v -34.6334 -59.7640 -1.3680 +v -34.3160 -60.9487 -1.3680 +v -33.4487 -61.8160 -1.3680 +v -32.2640 -62.1334 -1.3680 +v -15.0099 -62.1334 -1.3680 +v 0.0000 -62.1334 -1.3680 +v 0.0000 62.1334 -1.3680 +v -15.0099 62.1334 -1.3680 +v -32.2640 62.5000 -2.7360 +v -33.6320 62.1334 -2.7360 +v -34.6334 61.1320 -2.7360 +v -35.0000 59.7640 -2.7360 +v -35.0000 33.4866 -2.7360 +v -35.0000 13.4957 -2.7360 +v -35.0000 -29.8820 -2.7360 +v -35.0000 -59.7640 -2.7360 +v -34.6334 -61.1320 -2.7360 +v -33.6320 -62.1334 -2.7360 +v -32.2640 -62.5000 -2.7360 +v -15.0099 -62.5000 -2.7360 +v 0.0000 -62.5000 -2.7360 +v 0.0000 62.5000 -2.7360 +v -15.0099 62.5000 -2.7360 +v -32.2640 62.5000 -37.2640 +v -33.6320 62.1334 -37.2640 +v -34.6334 61.1320 -37.2640 +v -35.0000 59.7640 -37.2640 +v -35.0000 33.4866 -37.2640 +v -35.0000 13.4957 -37.2640 +v -35.0000 -29.8820 -37.2640 +v -35.0000 -59.7640 -37.2640 +v -34.6334 -61.1320 -37.2640 +v -33.6320 -62.1334 -37.2640 +v -32.2640 -62.5000 -37.2640 +v -15.0099 -62.5000 -37.2640 +v 0.0000 -62.5000 -37.2640 +v 0.0000 62.5000 -37.2640 +v -15.0099 62.5000 -37.2640 +v -32.2640 62.1334 -38.6320 +v -33.4487 61.8160 -38.6320 +v -34.3160 60.9487 -38.6320 +v -34.6334 59.7640 -38.6320 +v -34.6334 33.4866 -38.6320 +v -34.6334 13.4957 -38.6320 +v -34.6334 -29.8820 -38.6320 +v -34.6334 -59.7640 -38.6320 +v -34.3160 -60.9487 -38.6320 +v -33.4487 -61.8160 -38.6320 +v -32.2640 -62.1334 -38.6320 +v -15.0099 -62.1334 -38.6320 +v 0.0000 -62.1334 -38.6320 +v 0.0000 62.1334 -38.6320 +v -15.0099 62.1334 -38.6320 +v -32.2640 61.1320 -39.6334 +v -32.9480 60.9487 -39.6334 +v -33.4487 60.4480 -39.6334 +v -33.6320 59.7640 -39.6334 +v -33.6320 33.4866 -39.6334 +v -33.6320 13.4957 -39.6334 +v -33.6320 -29.8820 -39.6334 +v -33.6320 -59.7640 -39.6334 +v -33.4487 -60.4480 -39.6334 +v -32.9480 -60.9487 -39.6334 +v -32.2640 -61.1320 -39.6334 +v -15.0099 -61.1320 -39.6334 +v 0.0000 -61.1320 -39.6334 +v 0.0000 61.1320 -39.6334 +v -15.0099 61.1320 -39.6334 +v -32.2640 59.7640 -40.0000 +v -32.2640 33.4866 -40.0000 +v -32.2640 13.4957 -40.0000 +v -32.2640 -29.8820 -40.0000 +v -32.2640 -59.7640 -40.0000 +v -15.0099 -59.7640 -40.0000 +v 0.0000 -59.7640 -40.0000 +v 0.0000 59.7640 -40.0000 +v -15.0099 59.7640 -40.0000 +v 0.0000 -29.8820 -40.0000 +v -15.0099 -29.8820 -40.0000 +v 0.0000 13.4957 -40.0000 +v -15.0099 13.4957 -40.0000 +v 0.0000 33.4866 -40.0000 +v -15.0099 33.4866 -40.0000 +v 0.0000 13.4946 -3.9078 +v -15.0099 13.4946 -3.9078 +v -15.0099 33.4866 -3.9078 +v 0.0000 33.4866 -3.9078 +v 15.0099 33.4866 0.0000 +v 32.2640 33.4866 0.0000 +v 32.2640 59.7640 0.0000 +v 15.0099 59.7640 0.0000 +v 15.0099 -29.8820 -0.0000 +v 32.2640 -29.8820 -0.0000 +v 32.2640 13.4957 0.0000 +v 15.0099 13.4951 0.0000 +v 15.0099 -59.7640 -0.0000 +v 32.2640 -59.7640 -0.0000 +v 32.9480 60.9487 -0.3665 +v 32.2640 61.1320 -0.3665 +v 33.4487 60.4480 -0.3665 +v 33.6320 59.7640 -0.3665 +v 33.6320 33.4866 -0.3666 +v 33.6320 -29.8820 -0.3666 +v 33.6320 13.4957 -0.3666 +v 33.6320 -59.7640 -0.3666 +v 33.4487 -60.4480 -0.3666 +v 32.9480 -60.9487 -0.3666 +v 32.2640 -61.1320 -0.3666 +v 15.0099 -61.1320 -0.3666 +v 15.0099 61.1320 -0.3665 +v 33.4487 61.8160 -1.3680 +v 32.2640 62.1334 -1.3680 +v 34.3160 60.9487 -1.3680 +v 34.6334 59.7640 -1.3680 +v 34.6334 33.4866 -1.3680 +v 34.6334 -29.8820 -1.3680 +v 34.6334 13.4957 -1.3680 +v 34.6334 -59.7640 -1.3680 +v 34.3160 -60.9487 -1.3680 +v 33.4487 -61.8160 -1.3680 +v 32.2640 -62.1334 -1.3680 +v 15.0099 -62.1334 -1.3680 +v 15.0099 62.1334 -1.3680 +v 33.6320 62.1334 -2.7360 +v 32.2640 62.5000 -2.7360 +v 34.6334 61.1320 -2.7360 +v 35.0000 59.7640 -2.7360 +v 35.0000 33.4866 -2.7360 +v 35.0000 -29.8820 -2.7360 +v 35.0000 13.4957 -2.7360 +v 35.0000 -59.7640 -2.7360 +v 34.6334 -61.1320 -2.7360 +v 33.6320 -62.1334 -2.7360 +v 32.2640 -62.5000 -2.7360 +v 15.0099 -62.5000 -2.7360 +v 15.0099 62.5000 -2.7360 +v 33.6320 62.1334 -37.2640 +v 32.2640 62.5000 -37.2640 +v 34.6334 61.1320 -37.2640 +v 35.0000 59.7640 -37.2640 +v 35.0000 33.4866 -37.2640 +v 35.0000 -29.8820 -37.2640 +v 35.0000 13.4957 -37.2640 +v 35.0000 -59.7640 -37.2640 +v 34.6334 -61.1320 -37.2640 +v 33.6320 -62.1334 -37.2640 +v 32.2640 -62.5000 -37.2640 +v 15.0099 -62.5000 -37.2640 +v 15.0099 62.5000 -37.2640 +v 33.4487 61.8160 -38.6320 +v 32.2640 62.1334 -38.6320 +v 34.3160 60.9487 -38.6320 +v 34.6334 59.7640 -38.6320 +v 34.6334 33.4866 -38.6320 +v 34.6334 -29.8820 -38.6320 +v 34.6334 13.4957 -38.6320 +v 34.6334 -59.7640 -38.6320 +v 34.3160 -60.9487 -38.6320 +v 33.4487 -61.8160 -38.6320 +v 32.2640 -62.1334 -38.6320 +v 15.0099 -62.1334 -38.6320 +v 15.0099 62.1334 -38.6320 +v 32.9480 60.9487 -39.6334 +v 32.2640 61.1320 -39.6334 +v 33.4487 60.4480 -39.6334 +v 33.6320 59.7640 -39.6334 +v 33.6320 33.4866 -39.6334 +v 33.6320 -29.8820 -39.6334 +v 33.6320 13.4957 -39.6334 +v 33.6320 -59.7640 -39.6334 +v 33.4487 -60.4480 -39.6334 +v 32.9480 -60.9487 -39.6334 +v 32.2640 -61.1320 -39.6334 +v 15.0099 -61.1320 -39.6334 +v 15.0099 61.1320 -39.6334 +v 32.2640 59.7640 -40.0000 +v 32.2640 33.4866 -40.0000 +v 32.2640 -29.8820 -40.0000 +v 32.2640 13.4957 -40.0000 +v 32.2640 -59.7640 -40.0000 +v 15.0099 -59.7640 -40.0000 +v 15.0099 59.7640 -40.0000 +v 15.0099 -29.8820 -40.0000 +v 15.0099 13.4957 -40.0000 +v 15.0099 33.4866 -40.0000 +v 15.0099 13.4946 -3.9078 +v 15.0099 33.4866 -3.9078 +v -15.0099 19.0761 0.0000 +v -32.2640 19.0761 0.0000 +v -15.0099 19.0761 -3.9078 +v 15.0099 19.0761 -3.9078 +v 15.0099 19.0761 0.0000 +v 32.2640 19.0761 0.0000 +v 33.6320 19.0761 -0.3666 +v 34.6334 19.0761 -1.3680 +v 35.0000 19.0761 -2.7360 +v 35.0000 19.0761 -37.2640 +v 34.6334 19.0761 -38.6320 +v 33.6320 19.0761 -39.6334 +v 32.2640 19.0761 -40.0000 +v 15.0099 19.0761 -40.0000 +v 0.0000 19.0761 -40.0000 +v -15.0099 19.0761 -40.0000 +v -32.2640 19.0761 -40.0000 +v -35.0000 19.0761 -2.7360 +v -35.0000 19.0761 -37.2640 +v -34.6334 19.0761 -38.6320 +v -33.6320 19.0761 -39.6334 +v -33.6320 19.0761 -0.3666 +v -34.6334 19.0761 -1.3680 +# 247 vertices + +vn -0.1087 0.1087 0.9881 +vn -0.1305 -0.0000 0.9914 +vn 0.0000 -0.0000 1.0000 +vn 0.0000 0.1305 0.9914 +vn -0.1087 -0.1087 0.9881 +vn 0.0000 -0.1305 0.9914 +vn -0.0698 0.5140 0.8549 +vn -0.2655 0.4598 0.8474 +vn -0.4598 0.2655 0.8474 +vn -0.5140 0.0698 0.8549 +vn -0.5000 -0.0000 0.8660 +vn -0.5140 -0.0698 0.8549 +vn -0.4598 -0.2655 0.8474 +vn -0.2655 -0.4598 0.8474 +vn -0.0698 -0.5140 0.8549 +vn 0.0000 -0.5000 0.8660 +vn 0.0000 0.5000 0.8660 +vn -0.1129 0.8653 0.4883 +vn -0.4380 0.7586 0.4823 +vn -0.7586 0.4380 0.4823 +vn -0.8653 0.1129 0.4883 +vn -0.8660 -0.0000 0.5000 +vn -0.8653 -0.1129 0.4883 +vn -0.7586 -0.4380 0.4823 +vn -0.4380 -0.7586 0.4823 +vn -0.1129 -0.8653 0.4883 +vn 0.0000 -0.8660 0.5000 +vn 0.0000 0.8660 0.5000 +vn -0.1281 0.9834 0.1281 +vn -0.4959 0.8589 0.1278 +vn -0.8589 0.4959 0.1278 +vn -0.9834 0.1281 0.1281 +vn -0.9914 -0.0000 0.1305 +vn -0.9834 -0.1281 0.1281 +vn -0.8589 -0.4959 0.1278 +vn -0.4959 -0.8589 0.1278 +vn -0.1281 -0.9834 0.1281 +vn -0.0000 -0.9914 0.1305 +vn 0.0000 -0.9914 0.1305 +vn 0.0000 0.9914 0.1305 +vn -0.1281 0.9834 -0.1281 +vn -0.4959 0.8589 -0.1278 +vn -0.8589 0.4959 -0.1278 +vn -0.9834 0.1281 -0.1281 +vn -0.9914 0.0000 -0.1305 +vn -0.9834 -0.1281 -0.1281 +vn -0.8589 -0.4959 -0.1278 +vn -0.4959 -0.8589 -0.1278 +vn -0.1281 -0.9834 -0.1281 +vn -0.0000 -0.9914 -0.1305 +vn 0.0000 -0.9914 -0.1305 +vn 0.0000 0.9914 -0.1305 +vn -0.1129 0.8653 -0.4883 +vn -0.4380 0.7586 -0.4823 +vn -0.7586 0.4380 -0.4823 +vn -0.8653 0.1129 -0.4883 +vn -0.8660 0.0000 -0.5000 +vn -0.8653 -0.1129 -0.4883 +vn -0.7586 -0.4380 -0.4823 +vn -0.4380 -0.7586 -0.4823 +vn -0.1129 -0.8653 -0.4883 +vn -0.0000 -0.8660 -0.5000 +vn 0.0000 -0.8660 -0.5000 +vn 0.0000 0.8660 -0.5000 +vn -0.0698 0.5140 -0.8549 +vn -0.2655 0.4598 -0.8474 +vn -0.4598 0.2655 -0.8474 +vn -0.5140 0.0698 -0.8549 +vn -0.5000 0.0000 -0.8660 +vn -0.5140 -0.0698 -0.8549 +vn -0.4598 -0.2655 -0.8474 +vn -0.2655 -0.4598 -0.8474 +vn -0.0698 -0.5140 -0.8549 +vn 0.0000 -0.5000 -0.8660 +vn 0.0000 0.5000 -0.8660 +vn -0.1087 0.1087 -0.9881 +vn -0.1305 0.0000 -0.9914 +vn -0.1087 -0.1087 -0.9881 +vn 0.0000 -0.1305 -0.9914 +vn 0.0000 0.1305 -0.9914 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 1.0000 -0.0001 +vn 0.0000 -1.0000 -0.0000 +vn 0.1305 -0.0000 0.9914 +vn 0.1087 0.1087 0.9881 +vn 0.1087 -0.1087 0.9881 +vn 0.2655 0.4598 0.8474 +vn 0.0698 0.5140 0.8549 +vn 0.4598 0.2655 0.8474 +vn 0.5140 0.0698 0.8549 +vn 0.5000 -0.0000 0.8660 +vn 0.5140 -0.0698 0.8549 +vn 0.4598 -0.2655 0.8474 +vn 0.2655 -0.4598 0.8474 +vn 0.0698 -0.5140 0.8549 +vn 0.4380 0.7586 0.4823 +vn 0.1129 0.8653 0.4883 +vn 0.7586 0.4380 0.4823 +vn 0.8653 0.1129 0.4883 +vn 0.8660 -0.0000 0.5000 +vn 0.8653 -0.1129 0.4883 +vn 0.7586 -0.4380 0.4823 +vn 0.4380 -0.7586 0.4823 +vn 0.1129 -0.8653 0.4883 +vn 0.4959 0.8589 0.1278 +vn 0.1281 0.9834 0.1281 +vn 0.8589 0.4959 0.1278 +vn 0.9834 0.1281 0.1281 +vn 0.9914 -0.0000 0.1305 +vn 0.9834 -0.1281 0.1281 +vn 0.8589 -0.4959 0.1278 +vn 0.4959 -0.8589 0.1278 +vn 0.1281 -0.9834 0.1281 +vn 0.4959 0.8589 -0.1278 +vn 0.1281 0.9834 -0.1281 +vn 0.8589 0.4959 -0.1278 +vn 0.9834 0.1281 -0.1281 +vn 0.9914 0.0000 -0.1305 +vn 0.9834 -0.1281 -0.1281 +vn 0.8589 -0.4959 -0.1278 +vn 0.4959 -0.8589 -0.1278 +vn 0.1281 -0.9834 -0.1281 +vn 0.4380 0.7586 -0.4823 +vn 0.1129 0.8653 -0.4883 +vn 0.7586 0.4380 -0.4823 +vn 0.8653 0.1129 -0.4883 +vn 0.8660 0.0000 -0.5000 +vn 0.8653 -0.1129 -0.4883 +vn 0.7586 -0.4380 -0.4823 +vn 0.4380 -0.7586 -0.4823 +vn 0.1129 -0.8653 -0.4883 +vn 0.2655 0.4598 -0.8474 +vn 0.0698 0.5140 -0.8549 +vn 0.4598 0.2655 -0.8474 +vn 0.5140 0.0698 -0.8549 +vn 0.5000 0.0000 -0.8660 +vn 0.5140 -0.0698 -0.8549 +vn 0.4598 -0.2655 -0.8474 +vn 0.2655 -0.4598 -0.8474 +vn 0.0698 -0.5140 -0.8549 +vn 0.1087 0.1087 -0.9881 +vn 0.1305 0.0000 -0.9914 +vn 0.1087 -0.1087 -0.9881 +vn 1.0000 0.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -1.0000 0.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +# 147 vertex normals + +vt 0.6861 0.4001 0.9995 +vt 0.6861 0.3350 0.9995 +vt 0.7409 0.3350 0.9995 +vt 0.7409 0.4001 0.9995 +vt 0.7885 0.3350 0.9995 +vt 0.7885 0.4001 0.9995 +vt 0.6861 0.2855 0.9995 +vt 0.6861 0.1780 0.9995 +vt 0.7409 0.1780 0.9995 +vt 0.7409 0.2855 0.9995 +vt 0.7885 0.1780 0.9995 +vt 0.7885 0.2855 0.9995 +vt 0.6861 0.1040 0.9995 +vt 0.7409 0.1040 0.9995 +vt 0.7885 0.1040 0.9995 +vt 0.6861 0.4035 0.9903 +vt 0.6839 0.4030 0.9903 +vt 0.6823 0.4018 0.9903 +vt 0.6817 0.4001 0.9903 +vt 0.6817 0.3350 0.9903 +vt 0.6817 0.2855 0.9903 +vt 0.6817 0.1780 0.9903 +vt 0.6817 0.1040 0.9903 +vt 0.6823 0.1023 0.9903 +vt 0.6839 0.1010 0.9903 +vt 0.6861 0.1006 0.9903 +vt 0.7409 0.1006 0.9903 +vt 0.7885 0.1006 0.9903 +vt 0.7885 0.4035 0.9903 +vt 0.7409 0.4035 0.9903 +vt 0.6861 0.4059 0.9653 +vt 0.6823 0.4052 0.9653 +vt 0.6795 0.4030 0.9653 +vt 0.6785 0.4001 0.9653 +vt 0.6785 0.3350 0.9653 +vt 0.6785 0.2855 0.9653 +vt 0.6785 0.1780 0.9653 +vt 0.6785 0.1040 0.9653 +vt 0.6795 0.1010 0.9653 +vt 0.6823 0.0989 0.9653 +vt 0.6861 0.0981 0.9653 +vt 0.7409 0.0981 0.9653 +vt 0.7885 0.0981 0.9653 +vt 0.7885 0.4059 0.9653 +vt 0.7409 0.4059 0.9653 +vt 0.6861 0.4068 0.9312 +vt 0.6817 0.4059 0.9312 +vt 0.6785 0.4035 0.9312 +vt 0.6774 0.4001 0.9312 +vt 0.6774 0.3350 0.9312 +vt 0.6774 0.2855 0.9312 +vt 0.6774 0.1780 0.9312 +vt 0.6774 0.1040 0.9312 +vt 0.6785 0.1006 0.9312 +vt 0.6817 0.0981 0.9312 +vt 0.6861 0.0972 0.9312 +vt 0.7409 0.0972 0.9312 +vt 0.7885 0.0972 0.9312 +vt 0.7885 0.4068 0.9312 +vt 0.7409 0.4068 0.9312 +vt 0.6861 0.4068 0.0688 +vt 0.6817 0.4059 0.0688 +vt 0.6785 0.4035 0.0688 +vt 0.6774 0.4001 0.0688 +vt 0.6774 0.3350 0.0688 +vt 0.6774 0.2855 0.0688 +vt 0.6774 0.1780 0.0688 +vt 0.6774 0.1040 0.0688 +vt 0.6785 0.1006 0.0688 +vt 0.6817 0.0981 0.0688 +vt 0.6861 0.0972 0.0688 +vt 0.7409 0.0972 0.0688 +vt 0.7885 0.0972 0.0688 +vt 0.7885 0.4068 0.0688 +vt 0.7409 0.4068 0.0688 +vt 0.6861 0.4059 0.0347 +vt 0.6823 0.4052 0.0347 +vt 0.6795 0.4030 0.0347 +vt 0.6785 0.4001 0.0347 +vt 0.6785 0.3350 0.0347 +vt 0.6785 0.2855 0.0347 +vt 0.6785 0.1780 0.0347 +vt 0.6785 0.1040 0.0347 +vt 0.6795 0.1010 0.0347 +vt 0.6823 0.0989 0.0347 +vt 0.6861 0.0981 0.0347 +vt 0.7409 0.0981 0.0347 +vt 0.7885 0.0981 0.0347 +vt 0.7885 0.4059 0.0347 +vt 0.7409 0.4059 0.0347 +vt 0.6861 0.4035 0.0097 +vt 0.6839 0.4030 0.0097 +vt 0.6823 0.4018 0.0097 +vt 0.6817 0.4001 0.0097 +vt 0.6817 0.3350 0.0097 +vt 0.6817 0.2855 0.0097 +vt 0.6817 0.1780 0.0097 +vt 0.6817 0.1040 0.0097 +vt 0.6823 0.1023 0.0097 +vt 0.6839 0.1010 0.0097 +vt 0.6861 0.1006 0.0097 +vt 0.7409 0.1006 0.0097 +vt 0.7885 0.1006 0.0097 +vt 0.7885 0.4035 0.0097 +vt 0.7409 0.4035 0.0097 +vt 0.6861 0.4001 0.0005 +vt 0.6861 0.3350 0.0005 +vt 0.6861 0.2855 0.0005 +vt 0.6861 0.1780 0.0005 +vt 0.6861 0.1040 0.0005 +vt 0.7409 0.1040 0.0005 +vt 0.7885 0.1040 0.0005 +vt 0.7885 0.4001 0.0005 +vt 0.7409 0.4001 0.0005 +vt 0.7885 0.1780 0.0005 +vt 0.7409 0.1780 0.0005 +vt 0.7885 0.2855 0.0005 +vt 0.7409 0.2855 0.0005 +vt 0.7885 0.3350 0.0005 +vt 0.7409 0.3350 0.0005 +vt 0.7885 0.2854 0.9019 +vt 0.7409 0.2854 0.9019 +vt 0.7409 0.3350 0.9019 +vt 0.7885 0.3350 0.9019 +vt 0.8362 0.3350 0.9995 +vt 0.8910 0.3350 0.9995 +vt 0.8910 0.4001 0.9995 +vt 0.8362 0.4001 0.9995 +vt 0.8362 0.1780 0.9995 +vt 0.8910 0.1780 0.9995 +vt 0.8910 0.2855 0.9995 +vt 0.8362 0.2855 0.9995 +vt 0.8362 0.1040 0.9995 +vt 0.8910 0.1040 0.9995 +vt 0.8932 0.4030 0.9903 +vt 0.8910 0.4035 0.9903 +vt 0.8948 0.4018 0.9903 +vt 0.8953 0.4001 0.9903 +vt 0.8953 0.3350 0.9903 +vt 0.8953 0.1780 0.9903 +vt 0.8953 0.2855 0.9903 +vt 0.8953 0.1040 0.9903 +vt 0.8948 0.1023 0.9903 +vt 0.8932 0.1010 0.9903 +vt 0.8910 0.1006 0.9903 +vt 0.8362 0.1006 0.9903 +vt 0.8362 0.4035 0.9903 +vt 0.8948 0.4052 0.9653 +vt 0.8910 0.4059 0.9653 +vt 0.8975 0.4030 0.9653 +vt 0.8985 0.4001 0.9653 +vt 0.8985 0.3350 0.9653 +vt 0.8985 0.1780 0.9653 +vt 0.8985 0.2855 0.9653 +vt 0.8985 0.1040 0.9653 +vt 0.8975 0.1010 0.9653 +vt 0.8948 0.0989 0.9653 +vt 0.8910 0.0981 0.9653 +vt 0.8362 0.0981 0.9653 +vt 0.8362 0.4059 0.9653 +vt 0.8953 0.4059 0.9312 +vt 0.8910 0.4068 0.9312 +vt 0.8985 0.4035 0.9312 +vt 0.8997 0.4001 0.9312 +vt 0.8997 0.3350 0.9312 +vt 0.8997 0.1780 0.9312 +vt 0.8997 0.2855 0.9312 +vt 0.8997 0.1040 0.9312 +vt 0.8985 0.1006 0.9312 +vt 0.8953 0.0981 0.9312 +vt 0.8910 0.0972 0.9312 +vt 0.8362 0.0972 0.9312 +vt 0.8362 0.4068 0.9312 +vt 0.8953 0.4059 0.0688 +vt 0.8910 0.4068 0.0688 +vt 0.8985 0.4035 0.0688 +vt 0.8997 0.4001 0.0688 +vt 0.8997 0.3350 0.0688 +vt 0.8997 0.1780 0.0688 +vt 0.8997 0.2855 0.0688 +vt 0.8997 0.1040 0.0688 +vt 0.8985 0.1006 0.0688 +vt 0.8953 0.0981 0.0688 +vt 0.8910 0.0972 0.0688 +vt 0.8362 0.0972 0.0688 +vt 0.8362 0.4068 0.0688 +vt 0.8948 0.4052 0.0347 +vt 0.8910 0.4059 0.0347 +vt 0.8975 0.4030 0.0347 +vt 0.8985 0.4001 0.0347 +vt 0.8985 0.3350 0.0347 +vt 0.8985 0.1780 0.0347 +vt 0.8985 0.2855 0.0347 +vt 0.8985 0.1040 0.0347 +vt 0.8975 0.1010 0.0347 +vt 0.8948 0.0989 0.0347 +vt 0.8910 0.0981 0.0347 +vt 0.8362 0.0981 0.0347 +vt 0.8362 0.4059 0.0347 +vt 0.8932 0.4030 0.0097 +vt 0.8910 0.4035 0.0097 +vt 0.8948 0.4018 0.0097 +vt 0.8953 0.4001 0.0097 +vt 0.8953 0.3350 0.0097 +vt 0.8953 0.1780 0.0097 +vt 0.8953 0.2855 0.0097 +vt 0.8953 0.1040 0.0097 +vt 0.8948 0.1023 0.0097 +vt 0.8932 0.1010 0.0097 +vt 0.8910 0.1006 0.0097 +vt 0.8362 0.1006 0.0097 +vt 0.8362 0.4035 0.0097 +vt 0.8910 0.4001 0.0005 +vt 0.8910 0.3350 0.0005 +vt 0.8910 0.1780 0.0005 +vt 0.8910 0.2855 0.0005 +vt 0.8910 0.1040 0.0005 +vt 0.8362 0.1040 0.0005 +vt 0.8362 0.4001 0.0005 +vt 0.8362 0.1780 0.0005 +vt 0.8362 0.2855 0.0005 +vt 0.8362 0.3350 0.0005 +vt 0.8362 0.2854 0.9019 +vt 0.8362 0.3350 0.9019 +vt 0.6622 0.0035 0.9995 +vt 0.6622 0.4468 0.9995 +vt -0.2323 0.4468 0.9995 +vt -0.2323 0.0035 0.9995 +vt 0.7409 0.2993 0.9995 +vt 0.7409 0.2993 0.9019 +vt 0.8362 0.2993 0.9019 +vt 0.8362 0.2993 0.9995 +vt 0.9822 0.5590 0.9995 +vt 0.9822 0.9711 0.9995 +vt 0.0132 0.9711 0.9995 +vt 0.0132 0.5590 0.9995 +vt 0.8953 0.2993 0.9903 +vt 0.8910 0.2993 0.9995 +vt 0.8985 0.2993 0.9653 +vt 0.8997 0.2993 0.9312 +vt 0.8997 0.2993 0.0688 +vt 0.8985 0.2993 0.0347 +vt 0.8953 0.2993 0.0097 +vt 0.8910 0.2993 0.0005 +vt 0.8362 0.2993 0.0005 +vt 0.7885 0.2993 0.0005 +vt 0.7409 0.2993 0.0005 +vt 0.6861 0.2993 0.0005 +vt 0.6774 0.2993 0.9312 +vt 0.6774 0.2993 0.0688 +vt 0.6785 0.2993 0.0347 +vt 0.6817 0.2993 0.0097 +vt 0.6861 0.2993 0.9995 +vt 0.6817 0.2993 0.9903 +vt 0.6785 0.2993 0.9653 +# 255 texture coords + +g box +usemtl 01___Default +s 1 +f 1/1/1 2/2/2 3/3/3 4/4/4 +f 4/4/4 3/3/3 5/5/3 6/6/4 +f 7/7/2 8/8/2 9/9/3 10/10/3 +f 10/10/3 9/9/3 11/11/3 12/12/3 +f 8/8/2 13/13/5 14/14/6 9/9/3 +f 9/9/3 14/14/6 15/15/6 11/11/3 +f 1/1/1 16/16/7 17/17/8 +f 1/1/1 17/17/8 18/18/9 +f 1/1/1 18/18/9 19/19/10 +f 1/1/1 19/19/10 20/20/11 2/2/2 +f 7/7/2 21/21/11 22/22/11 8/8/2 +f 8/8/2 22/22/11 23/23/12 13/13/5 +f 13/13/5 23/23/12 24/24/13 +f 13/13/5 24/24/13 25/25/14 +f 13/13/5 25/25/14 26/26/15 +f 13/13/5 26/26/15 27/27/16 14/14/6 +f 14/14/6 27/27/16 28/28/16 15/15/6 +f 6/6/4 29/29/17 30/30/17 4/4/4 +f 4/4/4 30/30/17 16/16/7 1/1/1 +f 16/16/7 31/31/18 32/32/19 17/17/8 +f 17/17/8 32/32/19 33/33/20 18/18/9 +f 18/18/9 33/33/20 34/34/21 19/19/10 +f 19/19/10 34/34/21 35/35/22 20/20/11 +f 21/21/11 36/36/22 37/37/22 22/22/11 +f 22/22/11 37/37/22 38/38/23 23/23/12 +f 23/23/12 38/38/23 39/39/24 24/24/13 +f 24/24/13 39/39/24 40/40/25 25/25/14 +f 25/25/14 40/40/25 41/41/26 26/26/15 +f 26/26/15 41/41/26 42/42/27 27/27/16 +f 27/27/16 42/42/27 43/43/27 28/28/16 +f 29/29/17 44/44/28 45/45/28 30/30/17 +f 30/30/17 45/45/28 31/31/18 16/16/7 +f 31/31/18 46/46/29 47/47/30 32/32/19 +f 32/32/19 47/47/30 48/48/31 33/33/20 +f 33/33/20 48/48/31 49/49/32 34/34/21 +f 34/34/21 49/49/32 50/50/33 35/35/22 +f 36/36/22 51/51/33 52/52/33 37/37/22 +f 37/37/22 52/52/33 53/53/34 38/38/23 +f 38/38/23 53/53/34 54/54/35 39/39/24 +f 39/39/24 54/54/35 55/55/36 40/40/25 +f 40/40/25 55/55/36 56/56/37 41/41/26 +f 41/41/26 56/56/37 57/57/38 42/42/27 +f 42/42/27 57/57/38 58/58/39 43/43/27 +f 44/44/28 59/59/40 60/60/40 45/45/28 +f 45/45/28 60/60/40 46/46/29 31/31/18 +f 46/46/29 61/61/41 62/62/42 47/47/30 +f 47/47/30 62/62/42 63/63/43 48/48/31 +f 48/48/31 63/63/43 64/64/44 49/49/32 +f 49/49/32 64/64/44 65/65/45 50/50/33 +f 51/51/33 66/66/45 67/67/45 52/52/33 +f 52/52/33 67/67/45 68/68/46 53/53/34 +f 53/53/34 68/68/46 69/69/47 54/54/35 +f 54/54/35 69/69/47 70/70/48 55/55/36 +f 55/55/36 70/70/48 71/71/49 56/56/37 +f 56/56/37 71/71/49 72/72/50 57/57/38 +f 57/57/38 72/72/50 73/73/51 58/58/39 +f 59/59/40 74/74/52 75/75/52 60/60/40 +f 60/60/40 75/75/52 61/61/41 46/46/29 +f 61/61/41 76/76/53 77/77/54 62/62/42 +f 62/62/42 77/77/54 78/78/55 63/63/43 +f 63/63/43 78/78/55 79/79/56 64/64/44 +f 64/64/44 79/79/56 80/80/57 65/65/45 +f 66/66/45 81/81/57 82/82/57 67/67/45 +f 67/67/45 82/82/57 83/83/58 68/68/46 +f 68/68/46 83/83/58 84/84/59 69/69/47 +f 69/69/47 84/84/59 85/85/60 70/70/48 +f 70/70/48 85/85/60 86/86/61 71/71/49 +f 71/71/49 86/86/61 87/87/62 72/72/50 +f 72/72/50 87/87/62 88/88/63 73/73/51 +f 74/74/52 89/89/64 90/90/64 75/75/52 +f 75/75/52 90/90/64 76/76/53 61/61/41 +f 76/76/53 91/91/65 92/92/66 77/77/54 +f 77/77/54 92/92/66 93/93/67 78/78/55 +f 78/78/55 93/93/67 94/94/68 79/79/56 +f 79/79/56 94/94/68 95/95/69 80/80/57 +f 81/81/57 96/96/69 97/97/69 82/82/57 +f 82/82/57 97/97/69 98/98/70 83/83/58 +f 83/83/58 98/98/70 99/99/71 84/84/59 +f 84/84/59 99/99/71 100/100/72 85/85/60 +f 85/85/60 100/100/72 101/101/73 86/86/61 +f 86/86/61 101/101/73 102/102/74 87/87/62 +f 87/87/62 102/102/74 103/103/74 88/88/63 +f 89/89/64 104/104/75 105/105/75 90/90/64 +f 90/90/64 105/105/75 91/91/65 76/76/53 +f 91/91/65 106/106/76 92/92/66 +f 92/92/66 106/106/76 93/93/67 +f 93/93/67 106/106/76 94/94/68 +f 94/94/68 106/106/76 107/107/77 95/95/69 +f 96/96/69 108/108/77 109/109/77 97/97/69 +f 97/97/69 109/109/77 110/110/78 98/98/70 +f 98/98/70 110/110/78 99/99/71 +f 99/99/71 110/110/78 100/100/72 +f 100/100/72 110/110/78 101/101/73 +f 101/101/73 110/110/78 111/111/79 102/102/74 +f 102/102/74 111/111/79 112/112/79 103/103/74 +f 104/104/75 113/113/80 114/114/80 105/105/75 +f 105/105/75 114/114/80 106/106/76 91/91/65 +f 115/115/81 112/112/79 111/111/79 116/116/81 +f 116/116/81 111/111/79 110/110/78 109/109/77 +f 117/117/81 115/115/81 116/116/81 118/118/81 +f 118/118/81 116/116/81 109/109/77 108/108/77 +f 113/113/80 119/119/81 120/120/81 114/114/80 +f 114/114/80 120/120/81 107/107/77 106/106/76 +s 2 +f 121/121/82 122/122/82 10/10/82 12/12/82 +f 123/123/83 124/124/83 5/5/83 3/3/83 +s 1 +f 125/125/3 126/126/84 127/127/85 128/128/4 +f 5/5/3 125/125/3 128/128/4 6/6/4 +f 129/129/3 130/130/84 131/131/84 132/132/3 +f 11/11/3 129/129/3 132/132/3 12/12/3 +f 133/133/6 134/134/86 130/130/84 129/129/3 +f 15/15/6 133/133/6 129/129/3 11/11/3 +f 127/127/85 135/135/87 136/136/88 +f 127/127/85 137/137/89 135/135/87 +f 127/127/85 138/138/90 137/137/89 +f 139/139/91 138/138/90 127/127/85 126/126/84 +f 140/140/91 141/141/91 131/131/84 130/130/84 +f 142/142/92 140/140/91 130/130/84 134/134/86 +f 134/134/86 143/143/93 142/142/92 +f 134/134/86 144/144/94 143/143/93 +f 134/134/86 145/145/95 144/144/94 +f 146/146/16 145/145/95 134/134/86 133/133/6 +f 28/28/16 146/146/16 133/133/6 15/15/6 +f 147/147/17 29/29/17 6/6/4 128/128/4 +f 136/136/88 147/147/17 128/128/4 127/127/85 +f 148/148/96 149/149/97 136/136/88 135/135/87 +f 150/150/98 148/148/96 135/135/87 137/137/89 +f 151/151/99 150/150/98 137/137/89 138/138/90 +f 152/152/100 151/151/99 138/138/90 139/139/91 +f 153/153/100 154/154/100 141/141/91 140/140/91 +f 155/155/101 153/153/100 140/140/91 142/142/92 +f 156/156/102 155/155/101 142/142/92 143/143/93 +f 157/157/103 156/156/102 143/143/93 144/144/94 +f 158/158/104 157/157/103 144/144/94 145/145/95 +f 159/159/27 158/158/104 145/145/95 146/146/16 +f 43/43/27 159/159/27 146/146/16 28/28/16 +f 160/160/28 44/44/28 29/29/17 147/147/17 +f 149/149/97 160/160/28 147/147/17 136/136/88 +f 161/161/105 162/162/106 149/149/97 148/148/96 +f 163/163/107 161/161/105 148/148/96 150/150/98 +f 164/164/108 163/163/107 150/150/98 151/151/99 +f 165/165/109 164/164/108 151/151/99 152/152/100 +f 166/166/109 167/167/109 154/154/100 153/153/100 +f 168/168/110 166/166/109 153/153/100 155/155/101 +f 169/169/111 168/168/110 155/155/101 156/156/102 +f 170/170/112 169/169/111 156/156/102 157/157/103 +f 171/171/113 170/170/112 157/157/103 158/158/104 +f 172/172/39 171/171/113 158/158/104 159/159/27 +f 58/58/39 172/172/39 159/159/27 43/43/27 +f 173/173/40 59/59/40 44/44/28 160/160/28 +f 162/162/106 173/173/40 160/160/28 149/149/97 +f 174/174/114 175/175/115 162/162/106 161/161/105 +f 176/176/116 174/174/114 161/161/105 163/163/107 +f 177/177/117 176/176/116 163/163/107 164/164/108 +f 178/178/118 177/177/117 164/164/108 165/165/109 +f 179/179/118 180/180/118 167/167/109 166/166/109 +f 181/181/119 179/179/118 166/166/109 168/168/110 +f 182/182/120 181/181/119 168/168/110 169/169/111 +f 183/183/121 182/182/120 169/169/111 170/170/112 +f 184/184/122 183/183/121 170/170/112 171/171/113 +f 185/185/51 184/184/122 171/171/113 172/172/39 +f 73/73/51 185/185/51 172/172/39 58/58/39 +f 186/186/52 74/74/52 59/59/40 173/173/40 +f 175/175/115 186/186/52 173/173/40 162/162/106 +f 187/187/123 188/188/124 175/175/115 174/174/114 +f 189/189/125 187/187/123 174/174/114 176/176/116 +f 190/190/126 189/189/125 176/176/116 177/177/117 +f 191/191/127 190/190/126 177/177/117 178/178/118 +f 192/192/127 193/193/127 180/180/118 179/179/118 +f 194/194/128 192/192/127 179/179/118 181/181/119 +f 195/195/129 194/194/128 181/181/119 182/182/120 +f 196/196/130 195/195/129 182/182/120 183/183/121 +f 197/197/131 196/196/130 183/183/121 184/184/122 +f 198/198/63 197/197/131 184/184/122 185/185/51 +f 88/88/63 198/198/63 185/185/51 73/73/51 +f 199/199/64 89/89/64 74/74/52 186/186/52 +f 188/188/124 199/199/64 186/186/52 175/175/115 +f 200/200/132 201/201/133 188/188/124 187/187/123 +f 202/202/134 200/200/132 187/187/123 189/189/125 +f 203/203/135 202/202/134 189/189/125 190/190/126 +f 204/204/136 203/203/135 190/190/126 191/191/127 +f 205/205/136 206/206/136 193/193/127 192/192/127 +f 207/207/137 205/205/136 192/192/127 194/194/128 +f 208/208/138 207/207/137 194/194/128 195/195/129 +f 209/209/139 208/208/138 195/195/129 196/196/130 +f 210/210/140 209/209/139 196/196/130 197/197/131 +f 211/211/74 210/210/140 197/197/131 198/198/63 +f 103/103/74 211/211/74 198/198/63 88/88/63 +f 212/212/75 104/104/75 89/89/64 199/199/64 +f 201/201/133 212/212/75 199/199/64 188/188/124 +f 201/201/133 200/200/132 213/213/141 +f 200/200/132 202/202/134 213/213/141 +f 202/202/134 203/203/135 213/213/141 +f 214/214/142 213/213/141 203/203/135 204/204/136 +f 215/215/142 216/216/142 206/206/136 205/205/136 +f 217/217/143 215/215/142 205/205/136 207/207/137 +f 207/207/137 208/208/138 217/217/143 +f 208/208/138 209/209/139 217/217/143 +f 209/209/139 210/210/140 217/217/143 +f 218/218/79 217/217/143 210/210/140 211/211/74 +f 112/112/79 218/218/79 211/211/74 103/103/74 +f 219/219/80 113/113/80 104/104/75 212/212/75 +f 213/213/141 219/219/80 212/212/75 201/201/133 +f 218/218/79 112/112/79 115/115/81 220/220/81 +f 217/217/143 218/218/79 220/220/81 215/215/142 +f 220/220/81 115/115/81 117/117/81 221/221/81 +f 215/215/142 220/220/81 221/221/81 216/216/142 +f 222/222/81 119/119/81 113/113/80 219/219/80 +f 214/214/142 222/222/81 219/219/80 213/213/141 +s 2 +f 132/132/82 223/223/82 121/121/82 12/12/82 +f 5/5/83 124/124/83 224/224/83 125/125/83 +s 1 +f 10/225/3 225/226/3 226/227/2 7/228/2 +s 4 +f 3/3/144 225/229/145 227/230/145 123/123/144 +f 224/224/146 228/231/146 229/232/147 125/125/146 +s 1 +f 131/233/84 230/234/84 229/235/3 132/236/3 +f 141/141/91 231/237/91 230/238/84 131/131/84 +f 154/154/100 232/239/100 231/237/91 141/141/91 +f 167/167/109 233/240/109 232/239/100 154/154/100 +f 180/180/118 234/241/118 233/240/109 167/167/109 +f 193/193/127 235/242/127 234/241/118 180/180/118 +f 206/206/136 236/243/136 235/242/127 193/193/127 +f 216/216/142 237/244/142 236/243/136 206/206/136 +f 214/214/142 237/244/142 238/245/81 222/222/81 +f 222/222/81 238/245/81 239/246/81 119/119/81 +f 119/119/81 239/246/81 240/247/81 120/120/81 +f 120/120/81 240/247/81 241/248/77 107/107/77 +f 51/51/33 242/249/33 243/250/45 66/66/45 +f 66/66/45 243/250/45 244/251/57 81/81/57 +f 81/81/57 244/251/57 245/252/69 96/96/69 +f 96/96/69 245/252/69 241/248/77 108/108/77 +f 7/7/2 226/253/2 246/254/11 21/21/11 +f 21/21/11 246/254/11 247/255/22 36/36/22 +f 36/36/22 247/255/22 242/249/33 51/51/33 +f 3/3/3 2/2/2 226/253/2 225/229/3 +s 4 +f 10/10/145 122/122/144 227/230/145 225/229/145 +f 223/223/147 132/132/147 229/232/147 228/231/146 +s 1 +f 126/126/84 125/125/3 229/232/3 230/238/84 +f 139/139/91 126/126/84 230/238/84 231/237/91 +f 152/152/100 139/139/91 231/237/91 232/239/100 +f 165/165/109 152/152/100 232/239/100 233/240/109 +f 178/178/118 165/165/109 233/240/109 234/241/118 +f 191/191/127 178/178/118 234/241/118 235/242/127 +f 204/204/136 191/191/127 235/242/127 236/243/136 +f 214/214/142 204/204/136 236/243/136 237/244/142 +f 216/216/142 221/221/81 238/245/81 237/244/142 +f 221/221/81 117/117/81 239/246/81 238/245/81 +f 117/117/81 118/118/81 240/247/81 239/246/81 +f 118/118/81 108/108/77 241/248/77 240/247/81 +f 50/50/33 65/65/45 243/250/45 242/249/33 +f 65/65/45 80/80/57 244/251/57 243/250/45 +f 80/80/57 95/95/69 245/252/69 244/251/57 +f 95/95/69 107/107/77 241/248/77 245/252/69 +f 2/2/2 20/20/11 246/254/11 226/253/2 +f 20/20/11 35/35/22 247/255/22 246/254/11 +f 35/35/22 50/50/33 242/249/33 247/255/22 +# 230 polygons - 24 triangles + +# +# object button2 +# + +v 25.4066 4.8805 4.4808 +v 26.0012 4.8805 4.4808 +v 25.9559 5.1080 4.4808 +v 25.8270 5.3009 4.4808 +v 25.6341 5.4298 4.4808 +v 25.4066 5.4750 4.4808 +v 25.1791 5.4298 4.4808 +v 24.9862 5.3009 4.4808 +v 24.8573 5.1080 4.4808 +v 24.8121 4.8805 4.4808 +v 24.8573 4.6529 4.4808 +v 24.9862 4.4601 4.4808 +v 25.1791 4.3312 4.4808 +v 25.4066 4.2859 4.4808 +v 25.6341 4.3312 4.4808 +v 25.8270 4.4601 4.4808 +v 25.9559 4.6529 4.4808 +v 26.9950 4.8805 4.0692 +v 26.8741 5.4883 4.0692 +v 26.5298 6.0036 4.0692 +v 26.0145 6.3479 4.0692 +v 25.4066 6.4688 4.0692 +v 24.7988 6.3479 4.0692 +v 24.2835 6.0036 4.0692 +v 23.9392 5.4883 4.0692 +v 23.8183 4.8805 4.0692 +v 23.9392 4.2726 4.0692 +v 24.2835 3.7573 4.0692 +v 24.7988 3.4130 4.0692 +v 25.4066 3.2921 4.0692 +v 26.0145 3.4130 4.0692 +v 26.5298 3.7573 4.0692 +v 26.8741 4.2726 4.0692 +v 27.4066 4.8805 3.0753 +v 27.2544 5.6458 3.0753 +v 26.8208 6.2947 3.0753 +v 26.1720 6.7282 3.0753 +v 25.4066 6.8805 3.0753 +v 24.6413 6.7282 3.0753 +v 23.9924 6.2947 3.0753 +v 23.5589 5.6458 3.0753 +v 23.4066 4.8805 3.0753 +v 23.5589 4.1151 3.0753 +v 23.9924 3.4663 3.0753 +v 24.6413 3.0327 3.0753 +v 25.4066 2.8805 3.0753 +v 26.1720 3.0327 3.0753 +v 26.8208 3.4663 3.0753 +v 27.2544 4.1151 3.0753 +v 27.4066 4.8805 -2.0476 +v 27.2544 5.6458 -2.0476 +v 26.8208 6.2947 -2.0476 +v 26.1720 6.7282 -2.0476 +v 25.4066 6.8805 -2.0476 +v 24.6413 6.7282 -2.0476 +v 23.9924 6.2947 -2.0476 +v 23.5589 5.6458 -2.0476 +v 23.4066 4.8805 -2.0476 +v 23.5589 4.1151 -2.0476 +v 23.9924 3.4663 -2.0476 +v 24.6413 3.0327 -2.0476 +v 25.4066 2.8805 -2.0476 +v 26.1720 3.0327 -2.0476 +v 26.8208 3.4663 -2.0476 +v 27.2544 4.1151 -2.0476 +v 26.9950 4.8805 -3.0415 +v 26.8741 5.4883 -3.0415 +v 26.5298 6.0036 -3.0415 +v 26.0145 6.3479 -3.0415 +v 25.4066 6.4688 -3.0415 +v 24.7988 6.3479 -3.0415 +v 24.2835 6.0036 -3.0415 +v 23.9392 5.4883 -3.0415 +v 23.8183 4.8805 -3.0415 +v 23.9392 4.2726 -3.0415 +v 24.2835 3.7573 -3.0415 +v 24.7988 3.4130 -3.0415 +v 25.4066 3.2921 -3.0415 +v 26.0145 3.4130 -3.0415 +v 26.5298 3.7573 -3.0415 +v 26.8741 4.2726 -3.0415 +v 26.0012 4.8805 -3.4531 +v 25.9559 5.1080 -3.4531 +v 25.8270 5.3009 -3.4531 +v 25.6341 5.4298 -3.4531 +v 25.4066 5.4750 -3.4531 +v 25.1791 5.4298 -3.4531 +v 24.9862 5.3009 -3.4531 +v 24.8573 5.1080 -3.4531 +v 24.8121 4.8805 -3.4531 +v 24.8573 4.6529 -3.4531 +v 24.9862 4.4601 -3.4531 +v 25.1791 4.3312 -3.4531 +v 25.4066 4.2859 -3.4531 +v 25.6341 4.3312 -3.4531 +v 25.8270 4.4601 -3.4531 +v 25.9559 4.6529 -3.4531 +v 25.4066 4.8805 -3.4531 +# 98 vertices + +vn 0.0000 -0.0000 1.0000 +vn 0.2183 -0.0000 0.9759 +vn 0.2017 0.0835 0.9759 +vn 0.1544 0.1544 0.9759 +vn 0.0835 0.2017 0.9759 +vn 0.0000 0.2183 0.9759 +vn -0.0835 0.2017 0.9759 +vn -0.1544 0.1544 0.9759 +vn -0.2017 0.0835 0.9759 +vn -0.2183 -0.0000 0.9759 +vn -0.2017 -0.0835 0.9759 +vn -0.1544 -0.1544 0.9759 +vn -0.0835 -0.2017 0.9759 +vn 0.0000 -0.2183 0.9759 +vn 0.0835 -0.2017 0.9759 +vn 0.1544 -0.1544 0.9759 +vn 0.2017 -0.0835 0.9759 +vn 0.7294 0.0000 0.6840 +vn 0.6739 0.2791 0.6840 +vn 0.5158 0.5158 0.6840 +vn 0.2791 0.6739 0.6840 +vn 0.0000 0.7294 0.6840 +vn -0.2791 0.6739 0.6840 +vn -0.5158 0.5158 0.6840 +vn -0.6739 0.2791 0.6840 +vn -0.7294 0.0000 0.6840 +vn -0.6739 -0.2791 0.6840 +vn -0.5158 -0.5158 0.6840 +vn -0.2791 -0.6739 0.6840 +vn 0.0000 -0.7294 0.6840 +vn 0.2791 -0.6739 0.6840 +vn 0.5158 -0.5158 0.6840 +vn 0.6739 -0.2791 0.6840 +vn 0.9817 0.0000 0.1906 +vn 0.9069 0.3757 0.1906 +vn 0.6941 0.6941 0.1906 +vn 0.3757 0.9069 0.1906 +vn 0.0000 0.9817 0.1906 +vn -0.3757 0.9069 0.1906 +vn -0.6941 0.6941 0.1906 +vn -0.9069 0.3757 0.1906 +vn -0.9817 0.0000 0.1906 +vn -0.9069 -0.3757 0.1906 +vn -0.6941 -0.6941 0.1906 +vn -0.3757 -0.9069 0.1906 +vn 0.0000 -0.9817 0.1906 +vn 0.3757 -0.9069 0.1906 +vn 0.6941 -0.6941 0.1906 +vn 0.9069 -0.3757 0.1906 +vn 0.9817 0.0000 -0.1906 +vn 0.9069 0.3757 -0.1906 +vn 0.6941 0.6941 -0.1906 +vn 0.3757 0.9069 -0.1906 +vn 0.0000 0.9817 -0.1906 +vn -0.3757 0.9069 -0.1906 +vn -0.6941 0.6941 -0.1906 +vn -0.9069 0.3757 -0.1906 +vn -0.9817 0.0000 -0.1906 +vn -0.9069 -0.3757 -0.1906 +vn -0.6941 -0.6941 -0.1906 +vn -0.3757 -0.9069 -0.1906 +vn 0.0000 -0.9817 -0.1906 +vn 0.3757 -0.9069 -0.1906 +vn 0.6941 -0.6941 -0.1906 +vn 0.9069 -0.3757 -0.1906 +vn 0.7294 0.0000 -0.6840 +vn 0.6739 0.2791 -0.6840 +vn 0.5158 0.5158 -0.6840 +vn 0.2791 0.6739 -0.6840 +vn -0.0000 0.7294 -0.6840 +vn -0.2791 0.6739 -0.6840 +vn -0.5158 0.5158 -0.6840 +vn -0.6739 0.2791 -0.6840 +vn -0.7294 0.0000 -0.6840 +vn -0.6739 -0.2791 -0.6840 +vn -0.5158 -0.5158 -0.6840 +vn -0.2791 -0.6739 -0.6840 +vn 0.0000 -0.7294 -0.6840 +vn 0.2791 -0.6739 -0.6840 +vn 0.5158 -0.5158 -0.6840 +vn 0.6739 -0.2791 -0.6840 +vn 0.2183 0.0000 -0.9759 +vn 0.2017 0.0835 -0.9759 +vn 0.1544 0.1544 -0.9759 +vn 0.0835 0.2017 -0.9759 +vn -0.0000 0.2183 -0.9759 +vn -0.0835 0.2017 -0.9759 +vn -0.1544 0.1544 -0.9759 +vn -0.2017 0.0835 -0.9759 +vn -0.2183 0.0000 -0.9759 +vn -0.2017 -0.0835 -0.9759 +vn -0.1544 -0.1544 -0.9759 +vn -0.0835 -0.2017 -0.9759 +vn 0.0000 -0.2183 -0.9759 +vn 0.0835 -0.2017 -0.9759 +vn 0.1544 -0.1544 -0.9759 +vn 0.2017 -0.0835 -0.9759 +vn 0.0000 0.0000 -1.0000 +# 98 vertex normals + +vt 0.5000 0.5000 0.0000 +vt 0.6486 0.5000 0.0000 +vt 0.6373 0.5569 0.0000 +vt 0.6051 0.6051 0.0000 +vt 0.5569 0.6373 0.0000 +vt 0.5000 0.6486 0.0000 +vt 0.4431 0.6373 0.0000 +vt 0.3949 0.6051 0.0000 +vt 0.3627 0.5569 0.0000 +vt 0.3514 0.5000 0.0000 +vt 0.3627 0.4431 0.0000 +vt 0.3949 0.3949 0.0000 +vt 0.4431 0.3627 0.0000 +vt 0.5000 0.3514 0.0000 +vt 0.5569 0.3627 0.0000 +vt 0.6051 0.3949 0.0000 +vt 0.6373 0.4431 0.0000 +vt 0.8971 0.5000 0.0000 +vt 0.8669 0.6520 0.0000 +vt 0.7808 0.7808 0.0000 +vt 0.6520 0.8669 0.0000 +vt 0.5000 0.8971 0.0000 +vt 0.3480 0.8669 0.0000 +vt 0.2192 0.7808 0.0000 +vt 0.1331 0.6520 0.0000 +vt 0.1029 0.5000 0.0000 +vt 0.1331 0.3480 0.0000 +vt 0.2192 0.2192 0.0000 +vt 0.3480 0.1331 0.0000 +vt 0.5000 0.1029 0.0000 +vt 0.6520 0.1331 0.0000 +vt 0.7808 0.2192 0.0000 +vt 0.8669 0.3480 0.0000 +vt 1.0000 0.5000 0.0000 +vt 0.9619 0.6913 0.0000 +vt 0.8536 0.8536 0.0000 +vt 0.6913 0.9619 0.0000 +vt 0.5000 1.0000 0.0000 +vt 0.3087 0.9619 0.0000 +vt 0.1464 0.8536 0.0000 +vt 0.0381 0.6913 0.0000 +vt 0.0000 0.5000 0.0000 +vt 0.0381 0.3087 0.0000 +vt 0.1464 0.1464 0.0000 +vt 0.3087 0.0381 0.0000 +vt 0.5000 0.0000 0.0000 +vt 0.6913 0.0381 0.0000 +vt 0.8536 0.1464 0.0000 +vt 0.9619 0.3087 0.0000 +vt 0.0000 1.0000 0.0000 +vt 0.0000 0.0000 0.0000 +vt 0.0625 0.0000 0.0000 +vt 0.0625 1.0000 0.0000 +vt 0.1250 0.0000 0.0000 +vt 0.1250 1.0000 0.0000 +vt 0.1875 0.0000 0.0000 +vt 0.1875 1.0000 0.0000 +vt 0.2500 0.0000 0.0000 +vt 0.2500 1.0000 0.0000 +vt 0.3125 0.0000 0.0000 +vt 0.3125 1.0000 0.0000 +vt 0.3750 0.0000 0.0000 +vt 0.3750 1.0000 0.0000 +vt 0.4375 0.0000 0.0000 +vt 0.4375 1.0000 0.0000 +vt 0.5625 0.0000 0.0000 +vt 0.5625 1.0000 0.0000 +vt 0.6250 0.0000 0.0000 +vt 0.6250 1.0000 0.0000 +vt 0.6875 0.0000 0.0000 +vt 0.6875 1.0000 0.0000 +vt 0.7500 0.0000 0.0000 +vt 0.7500 1.0000 0.0000 +vt 0.8125 0.0000 0.0000 +vt 0.8125 1.0000 0.0000 +vt 0.8750 0.0000 0.0000 +vt 0.8750 1.0000 0.0000 +vt 0.9375 0.0000 0.0000 +vt 0.9375 1.0000 0.0000 +vt 1.0000 0.0000 0.0000 +vt 1.0000 1.0000 0.0000 +# 81 texture coords + +g button2 +usemtl 02___Default +s 4 +f 248/256/148 249/257/149 250/258/150 +f 248/256/148 250/258/150 251/259/151 +f 248/256/148 251/259/151 252/260/152 +f 248/256/148 252/260/152 253/261/153 +f 248/256/148 253/261/153 254/262/154 +f 248/256/148 254/262/154 255/263/155 +f 248/256/148 255/263/155 256/264/156 +f 248/256/148 256/264/156 257/265/157 +f 248/256/148 257/265/157 258/266/158 +f 248/256/148 258/266/158 259/267/159 +f 248/256/148 259/267/159 260/268/160 +f 248/256/148 260/268/160 261/269/161 +f 248/256/148 261/269/161 262/270/162 +f 248/256/148 262/270/162 263/271/163 +f 248/256/148 263/271/163 264/272/164 +f 248/256/148 264/272/164 249/257/149 +f 249/257/149 265/273/165 266/274/166 250/258/150 +f 250/258/150 266/274/166 267/275/167 251/259/151 +f 251/259/151 267/275/167 268/276/168 252/260/152 +f 252/260/152 268/276/168 269/277/169 253/261/153 +f 253/261/153 269/277/169 270/278/170 254/262/154 +f 254/262/154 270/278/170 271/279/171 255/263/155 +f 255/263/155 271/279/171 272/280/172 256/264/156 +f 256/264/156 272/280/172 273/281/173 257/265/157 +f 257/265/157 273/281/173 274/282/174 258/266/158 +f 258/266/158 274/282/174 275/283/175 259/267/159 +f 259/267/159 275/283/175 276/284/176 260/268/160 +f 260/268/160 276/284/176 277/285/177 261/269/161 +f 261/269/161 277/285/177 278/286/178 262/270/162 +f 262/270/162 278/286/178 279/287/179 263/271/163 +f 263/271/163 279/287/179 280/288/180 264/272/164 +f 264/272/164 280/288/180 265/273/165 249/257/149 +f 265/273/165 281/289/181 282/290/182 266/274/166 +f 266/274/166 282/290/182 283/291/183 267/275/167 +f 267/275/167 283/291/183 284/292/184 268/276/168 +f 268/276/168 284/292/184 285/293/185 269/277/169 +f 269/277/169 285/293/185 286/294/186 270/278/170 +f 270/278/170 286/294/186 287/295/187 271/279/171 +f 271/279/171 287/295/187 288/296/188 272/280/172 +f 272/280/172 288/296/188 289/297/189 273/281/173 +f 273/281/173 289/297/189 290/298/190 274/282/174 +f 274/282/174 290/298/190 291/299/191 275/283/175 +f 275/283/175 291/299/191 292/300/192 276/284/176 +f 276/284/176 292/300/192 293/301/193 277/285/177 +f 277/285/177 293/301/193 294/302/194 278/286/178 +f 278/286/178 294/302/194 295/303/195 279/287/179 +f 279/287/179 295/303/195 296/304/196 280/288/180 +f 280/288/180 296/304/196 281/289/181 265/273/165 +f 281/305/181 297/306/197 298/307/198 282/308/182 +f 282/308/182 298/307/198 299/309/199 283/310/183 +f 283/310/183 299/309/199 300/311/200 284/312/184 +f 284/312/184 300/311/200 301/313/201 285/314/185 +f 285/314/185 301/313/201 302/315/202 286/316/186 +f 286/316/186 302/315/202 303/317/203 287/318/187 +f 287/318/187 303/317/203 304/319/204 288/320/188 +f 288/320/188 304/319/204 305/301/205 289/293/189 +f 289/293/189 305/301/205 306/321/206 290/322/190 +f 290/322/190 306/321/206 307/323/207 291/324/191 +f 291/324/191 307/323/207 308/325/208 292/326/192 +f 292/326/192 308/325/208 309/327/209 293/328/193 +f 293/328/193 309/327/209 310/329/210 294/330/194 +f 294/330/194 310/329/210 311/331/211 295/332/195 +f 295/332/195 311/331/211 312/333/212 296/334/196 +f 296/334/196 312/333/212 297/335/197 281/336/181 +f 297/289/197 313/273/213 314/274/214 298/290/198 +f 298/290/198 314/274/214 315/275/215 299/291/199 +f 299/291/199 315/275/215 316/276/216 300/292/200 +f 300/292/200 316/276/216 317/277/217 301/293/201 +f 301/293/201 317/277/217 318/278/218 302/294/202 +f 302/294/202 318/278/218 319/279/219 303/295/203 +f 303/295/203 319/279/219 320/280/220 304/296/204 +f 304/296/204 320/280/220 321/281/221 305/297/205 +f 305/297/205 321/281/221 322/282/222 306/298/206 +f 306/298/206 322/282/222 323/283/223 307/299/207 +f 307/299/207 323/283/223 324/284/224 308/300/208 +f 308/300/208 324/284/224 325/285/225 309/301/209 +f 309/301/209 325/285/225 326/286/226 310/302/210 +f 310/302/210 326/286/226 327/287/227 311/303/211 +f 311/303/211 327/287/227 328/288/228 312/304/212 +f 312/304/212 328/288/228 313/273/213 297/289/197 +f 313/273/213 329/257/229 330/258/230 314/274/214 +f 314/274/214 330/258/230 331/259/231 315/275/215 +f 315/275/215 331/259/231 332/260/232 316/276/216 +f 316/276/216 332/260/232 333/261/233 317/277/217 +f 317/277/217 333/261/233 334/262/234 318/278/218 +f 318/278/218 334/262/234 335/263/235 319/279/219 +f 319/279/219 335/263/235 336/264/236 320/280/220 +f 320/280/220 336/264/236 337/265/237 321/281/221 +f 321/281/221 337/265/237 338/266/238 322/282/222 +f 322/282/222 338/266/238 339/267/239 323/283/223 +f 323/283/223 339/267/239 340/268/240 324/284/224 +f 324/284/224 340/268/240 341/269/241 325/285/225 +f 325/285/225 341/269/241 342/270/242 326/286/226 +f 326/286/226 342/270/242 343/271/243 327/287/227 +f 327/287/227 343/271/243 344/272/244 328/288/228 +f 328/288/228 344/272/244 329/257/229 313/273/213 +f 329/257/229 345/256/245 330/258/230 +f 330/258/230 345/256/245 331/259/231 +f 331/259/231 345/256/245 332/260/232 +f 332/260/232 345/256/245 333/261/233 +f 333/261/233 345/256/245 334/262/234 +f 334/262/234 345/256/245 335/263/235 +f 335/263/235 345/256/245 336/264/236 +f 336/264/236 345/256/245 337/265/237 +f 337/265/237 345/256/245 338/266/238 +f 338/266/238 345/256/245 339/267/239 +f 339/267/239 345/256/245 340/268/240 +f 340/268/240 345/256/245 341/269/241 +f 341/269/241 345/256/245 342/270/242 +f 342/270/242 345/256/245 343/271/243 +f 343/271/243 345/256/245 344/272/244 +f 344/272/244 345/256/245 329/257/229 +# 80 polygons - 32 triangles + +# +# object button1 +# + +v -24.5934 4.8805 4.4808 +v -25.1879 4.8805 4.4808 +v -25.1427 5.1080 4.4808 +v -25.0138 5.3009 4.4808 +v -24.8209 5.4298 4.4808 +v -24.5934 5.4750 4.4808 +v -24.3659 5.4298 4.4808 +v -24.1730 5.3009 4.4808 +v -24.0441 5.1080 4.4808 +v -23.9988 4.8805 4.4808 +v -24.0441 4.6529 4.4808 +v -24.1730 4.4601 4.4808 +v -24.3659 4.3312 4.4808 +v -24.5934 4.2859 4.4808 +v -24.8209 4.3312 4.4808 +v -25.0138 4.4601 4.4808 +v -25.1427 4.6529 4.4808 +v -26.1817 4.8805 4.0692 +v -26.0608 5.4883 4.0692 +v -25.7165 6.0036 4.0692 +v -25.2012 6.3479 4.0692 +v -24.5934 6.4688 4.0692 +v -23.9855 6.3479 4.0692 +v -23.4702 6.0036 4.0692 +v -23.1259 5.4883 4.0692 +v -23.0050 4.8805 4.0692 +v -23.1259 4.2726 4.0692 +v -23.4702 3.7573 4.0692 +v -23.9855 3.4130 4.0692 +v -24.5934 3.2921 4.0692 +v -25.2012 3.4130 4.0692 +v -25.7165 3.7573 4.0692 +v -26.0608 4.2726 4.0692 +v -26.5934 4.8805 3.0753 +v -26.4411 5.6458 3.0753 +v -26.0076 6.2947 3.0753 +v -25.3587 6.7282 3.0753 +v -24.5934 6.8805 3.0753 +v -23.8280 6.7282 3.0753 +v -23.1792 6.2947 3.0753 +v -22.7456 5.6458 3.0753 +v -22.5934 4.8805 3.0753 +v -22.7456 4.1151 3.0753 +v -23.1792 3.4663 3.0753 +v -23.8280 3.0327 3.0753 +v -24.5934 2.8805 3.0753 +v -25.3587 3.0327 3.0753 +v -26.0076 3.4663 3.0753 +v -26.4411 4.1151 3.0753 +v -26.5934 4.8805 -2.0476 +v -26.4411 5.6458 -2.0476 +v -26.0076 6.2947 -2.0476 +v -25.3587 6.7282 -2.0476 +v -24.5934 6.8805 -2.0476 +v -23.8280 6.7282 -2.0476 +v -23.1792 6.2947 -2.0476 +v -22.7456 5.6458 -2.0476 +v -22.5934 4.8805 -2.0476 +v -22.7456 4.1151 -2.0476 +v -23.1792 3.4663 -2.0476 +v -23.8280 3.0327 -2.0476 +v -24.5934 2.8805 -2.0476 +v -25.3587 3.0327 -2.0476 +v -26.0076 3.4663 -2.0476 +v -26.4411 4.1151 -2.0476 +v -26.1817 4.8805 -3.0415 +v -26.0608 5.4883 -3.0415 +v -25.7165 6.0036 -3.0415 +v -25.2012 6.3479 -3.0415 +v -24.5934 6.4688 -3.0415 +v -23.9855 6.3479 -3.0415 +v -23.4702 6.0036 -3.0415 +v -23.1259 5.4883 -3.0415 +v -23.0050 4.8805 -3.0415 +v -23.1259 4.2726 -3.0415 +v -23.4702 3.7573 -3.0415 +v -23.9855 3.4130 -3.0415 +v -24.5934 3.2921 -3.0415 +v -25.2012 3.4130 -3.0415 +v -25.7165 3.7573 -3.0415 +v -26.0608 4.2726 -3.0415 +v -25.1879 4.8805 -3.4531 +v -25.1427 5.1080 -3.4531 +v -25.0138 5.3009 -3.4531 +v -24.8209 5.4298 -3.4531 +v -24.5934 5.4750 -3.4531 +v -24.3659 5.4298 -3.4531 +v -24.1730 5.3009 -3.4531 +v -24.0441 5.1080 -3.4531 +v -23.9988 4.8805 -3.4531 +v -24.0441 4.6529 -3.4531 +v -24.1730 4.4601 -3.4531 +v -24.3659 4.3312 -3.4531 +v -24.5934 4.2859 -3.4531 +v -24.8209 4.3312 -3.4531 +v -25.0138 4.4601 -3.4531 +v -25.1427 4.6529 -3.4531 +v -24.5934 4.8805 -3.4531 +# 98 vertices + +vn 0.0000 -0.0000 1.0000 +vn -0.2183 -0.0000 0.9759 +vn -0.2017 0.0835 0.9759 +vn -0.1544 0.1544 0.9759 +vn -0.0835 0.2017 0.9759 +vn -0.0000 0.2183 0.9759 +vn 0.0835 0.2017 0.9759 +vn 0.1544 0.1544 0.9759 +vn 0.2017 0.0835 0.9759 +vn 0.2183 -0.0000 0.9759 +vn 0.2017 -0.0835 0.9759 +vn 0.1544 -0.1544 0.9759 +vn 0.0835 -0.2017 0.9759 +vn -0.0000 -0.2183 0.9759 +vn -0.0835 -0.2017 0.9759 +vn -0.1544 -0.1544 0.9759 +vn -0.2017 -0.0835 0.9759 +vn -0.7294 0.0000 0.6840 +vn -0.6739 0.2791 0.6840 +vn -0.5158 0.5158 0.6840 +vn -0.2791 0.6739 0.6840 +vn -0.0000 0.7294 0.6840 +vn 0.2791 0.6739 0.6840 +vn 0.5158 0.5158 0.6840 +vn 0.6739 0.2791 0.6840 +vn 0.7294 0.0000 0.6840 +vn 0.6739 -0.2791 0.6840 +vn 0.5158 -0.5158 0.6840 +vn 0.2791 -0.6739 0.6840 +vn -0.0000 -0.7294 0.6840 +vn -0.2791 -0.6739 0.6840 +vn -0.5158 -0.5158 0.6840 +vn -0.6739 -0.2791 0.6840 +vn -0.9817 0.0000 0.1906 +vn -0.9069 0.3757 0.1906 +vn -0.6941 0.6941 0.1906 +vn -0.3757 0.9069 0.1906 +vn 0.0000 0.9817 0.1906 +vn 0.3757 0.9069 0.1906 +vn 0.6941 0.6941 0.1906 +vn 0.9069 0.3757 0.1906 +vn 0.9817 0.0000 0.1906 +vn 0.9069 -0.3757 0.1906 +vn 0.6941 -0.6941 0.1906 +vn 0.3757 -0.9069 0.1906 +vn -0.0000 -0.9817 0.1906 +vn -0.3757 -0.9069 0.1906 +vn -0.6941 -0.6941 0.1906 +vn -0.9069 -0.3757 0.1906 +vn -0.9817 0.0000 -0.1906 +vn -0.9069 0.3757 -0.1906 +vn -0.6941 0.6941 -0.1906 +vn -0.3757 0.9069 -0.1906 +vn -0.0000 0.9817 -0.1906 +vn 0.3757 0.9069 -0.1906 +vn 0.6941 0.6941 -0.1906 +vn 0.9069 0.3757 -0.1906 +vn 0.9817 0.0000 -0.1906 +vn 0.9069 -0.3757 -0.1906 +vn 0.6941 -0.6941 -0.1906 +vn 0.3757 -0.9069 -0.1906 +vn -0.0000 -0.9817 -0.1906 +vn -0.3757 -0.9069 -0.1906 +vn -0.6941 -0.6941 -0.1906 +vn -0.9069 -0.3757 -0.1906 +vn -0.7294 0.0000 -0.6840 +vn -0.6739 0.2791 -0.6840 +vn -0.5158 0.5158 -0.6840 +vn -0.2791 0.6739 -0.6840 +vn 0.0000 0.7294 -0.6840 +vn 0.2791 0.6739 -0.6840 +vn 0.5158 0.5158 -0.6840 +vn 0.6739 0.2791 -0.6840 +vn 0.7294 0.0000 -0.6840 +vn 0.6739 -0.2791 -0.6840 +vn 0.5158 -0.5158 -0.6840 +vn 0.2791 -0.6739 -0.6840 +vn -0.0000 -0.7294 -0.6840 +vn -0.2791 -0.6739 -0.6840 +vn -0.5158 -0.5158 -0.6840 +vn -0.6739 -0.2791 -0.6840 +vn -0.2183 0.0000 -0.9759 +vn -0.2017 0.0835 -0.9759 +vn -0.1544 0.1544 -0.9759 +vn -0.0835 0.2017 -0.9759 +vn 0.0000 0.2183 -0.9759 +vn 0.0835 0.2017 -0.9759 +vn 0.1544 0.1544 -0.9759 +vn 0.2017 0.0835 -0.9759 +vn 0.2183 0.0000 -0.9759 +vn 0.2017 -0.0835 -0.9759 +vn 0.1544 -0.1544 -0.9759 +vn 0.0835 -0.2017 -0.9759 +vn -0.0000 -0.2183 -0.9759 +vn -0.0835 -0.2017 -0.9759 +vn -0.1544 -0.1544 -0.9759 +vn -0.2017 -0.0835 -0.9759 +vn 0.0000 0.0000 -1.0000 +# 98 vertex normals + +vt 0.5000 0.5000 0.0000 +vt 0.6486 0.5000 0.0000 +vt 0.6373 0.5569 0.0000 +vt 0.6051 0.6051 0.0000 +vt 0.5569 0.6373 0.0000 +vt 0.5000 0.6486 0.0000 +vt 0.4431 0.6373 0.0000 +vt 0.3949 0.6051 0.0000 +vt 0.3627 0.5569 0.0000 +vt 0.3514 0.5000 0.0000 +vt 0.3627 0.4431 0.0000 +vt 0.3949 0.3949 0.0000 +vt 0.4431 0.3627 0.0000 +vt 0.5000 0.3514 0.0000 +vt 0.5569 0.3627 0.0000 +vt 0.6051 0.3949 0.0000 +vt 0.6373 0.4431 0.0000 +vt 0.8971 0.5000 0.0000 +vt 0.8669 0.6520 0.0000 +vt 0.7808 0.7808 0.0000 +vt 0.6520 0.8669 0.0000 +vt 0.5000 0.8971 0.0000 +vt 0.3480 0.8669 0.0000 +vt 0.2192 0.7808 0.0000 +vt 0.1331 0.6520 0.0000 +vt 0.1029 0.5000 0.0000 +vt 0.1331 0.3480 0.0000 +vt 0.2192 0.2192 0.0000 +vt 0.3480 0.1331 0.0000 +vt 0.5000 0.1029 0.0000 +vt 0.6520 0.1331 0.0000 +vt 0.7808 0.2192 0.0000 +vt 0.8669 0.3480 0.0000 +vt 1.0000 0.5000 0.0000 +vt 0.9619 0.6913 0.0000 +vt 0.8536 0.8536 0.0000 +vt 0.6913 0.9619 0.0000 +vt 0.5000 1.0000 0.0000 +vt 0.3087 0.9619 0.0000 +vt 0.1464 0.8536 0.0000 +vt 0.0381 0.6913 0.0000 +vt 0.0000 0.5000 0.0000 +vt 0.0381 0.3087 0.0000 +vt 0.1464 0.1464 0.0000 +vt 0.3087 0.0381 0.0000 +vt 0.5000 0.0000 0.0000 +vt 0.6913 0.0381 0.0000 +vt 0.8536 0.1464 0.0000 +vt 0.9619 0.3087 0.0000 +vt 0.0000 1.0000 0.0000 +vt 0.0000 0.0000 0.0000 +vt 0.0625 0.0000 0.0000 +vt 0.0625 1.0000 0.0000 +vt 0.1250 0.0000 0.0000 +vt 0.1250 1.0000 0.0000 +vt 0.1875 0.0000 0.0000 +vt 0.1875 1.0000 0.0000 +vt 0.2500 0.0000 0.0000 +vt 0.2500 1.0000 0.0000 +vt 0.3125 0.0000 0.0000 +vt 0.3125 1.0000 0.0000 +vt 0.3750 0.0000 0.0000 +vt 0.3750 1.0000 0.0000 +vt 0.4375 0.0000 0.0000 +vt 0.4375 1.0000 0.0000 +vt 0.5625 0.0000 0.0000 +vt 0.5625 1.0000 0.0000 +vt 0.6250 0.0000 0.0000 +vt 0.6250 1.0000 0.0000 +vt 0.6875 0.0000 0.0000 +vt 0.6875 1.0000 0.0000 +vt 0.7500 0.0000 0.0000 +vt 0.7500 1.0000 0.0000 +vt 0.8125 0.0000 0.0000 +vt 0.8125 1.0000 0.0000 +vt 0.8750 0.0000 0.0000 +vt 0.8750 1.0000 0.0000 +vt 0.9375 0.0000 0.0000 +vt 0.9375 1.0000 0.0000 +vt 1.0000 0.0000 0.0000 +vt 1.0000 1.0000 0.0000 +# 81 texture coords + +g button1 +usemtl 02___Default +s 4 +f 348/339/248 347/338/247 346/337/246 +f 349/340/249 348/339/248 346/337/246 +f 350/341/250 349/340/249 346/337/246 +f 351/342/251 350/341/250 346/337/246 +f 352/343/252 351/342/251 346/337/246 +f 353/344/253 352/343/252 346/337/246 +f 354/345/254 353/344/253 346/337/246 +f 355/346/255 354/345/254 346/337/246 +f 356/347/256 355/346/255 346/337/246 +f 357/348/257 356/347/256 346/337/246 +f 358/349/258 357/348/257 346/337/246 +f 359/350/259 358/349/258 346/337/246 +f 360/351/260 359/350/259 346/337/246 +f 361/352/261 360/351/260 346/337/246 +f 362/353/262 361/352/261 346/337/246 +f 347/338/247 362/353/262 346/337/246 +f 348/339/248 364/355/264 363/354/263 347/338/247 +f 349/340/249 365/356/265 364/355/264 348/339/248 +f 350/341/250 366/357/266 365/356/265 349/340/249 +f 351/342/251 367/358/267 366/357/266 350/341/250 +f 352/343/252 368/359/268 367/358/267 351/342/251 +f 353/344/253 369/360/269 368/359/268 352/343/252 +f 354/345/254 370/361/270 369/360/269 353/344/253 +f 355/346/255 371/362/271 370/361/270 354/345/254 +f 356/347/256 372/363/272 371/362/271 355/346/255 +f 357/348/257 373/364/273 372/363/272 356/347/256 +f 358/349/258 374/365/274 373/364/273 357/348/257 +f 359/350/259 375/366/275 374/365/274 358/349/258 +f 360/351/260 376/367/276 375/366/275 359/350/259 +f 361/352/261 377/368/277 376/367/276 360/351/260 +f 362/353/262 378/369/278 377/368/277 361/352/261 +f 347/338/247 363/354/263 378/369/278 362/353/262 +f 364/355/264 380/371/280 379/370/279 363/354/263 +f 365/356/265 381/372/281 380/371/280 364/355/264 +f 366/357/266 382/373/282 381/372/281 365/356/265 +f 367/358/267 383/374/283 382/373/282 366/357/266 +f 368/359/268 384/375/284 383/374/283 367/358/267 +f 369/360/269 385/376/285 384/375/284 368/359/268 +f 370/361/270 386/377/286 385/376/285 369/360/269 +f 371/362/271 387/378/287 386/377/286 370/361/270 +f 372/363/272 388/379/288 387/378/287 371/362/271 +f 373/364/273 389/380/289 388/379/288 372/363/272 +f 374/365/274 390/381/290 389/380/289 373/364/273 +f 375/366/275 391/382/291 390/381/290 374/365/274 +f 376/367/276 392/383/292 391/382/291 375/366/275 +f 377/368/277 393/384/293 392/383/292 376/367/276 +f 378/369/278 394/385/294 393/384/293 377/368/277 +f 363/354/263 379/370/279 394/385/294 378/369/278 +f 380/389/280 396/388/296 395/387/295 379/386/279 +f 381/391/281 397/390/297 396/388/296 380/389/280 +f 382/393/282 398/392/298 397/390/297 381/391/281 +f 383/395/283 399/394/299 398/392/298 382/393/282 +f 384/397/284 400/396/300 399/394/299 383/395/283 +f 385/399/285 401/398/301 400/396/300 384/397/284 +f 386/401/286 402/400/302 401/398/301 385/399/285 +f 387/374/287 403/382/303 402/400/302 386/401/286 +f 388/403/288 404/402/304 403/382/303 387/374/287 +f 389/405/289 405/404/305 404/402/304 388/403/288 +f 390/407/290 406/406/306 405/404/305 389/405/289 +f 391/409/291 407/408/307 406/406/306 390/407/290 +f 392/411/292 408/410/308 407/408/307 391/409/291 +f 393/413/293 409/412/309 408/410/308 392/411/292 +f 394/415/294 410/414/310 409/412/309 393/413/293 +f 379/417/279 395/416/295 410/414/310 394/415/294 +f 396/371/296 412/355/312 411/354/311 395/370/295 +f 397/372/297 413/356/313 412/355/312 396/371/296 +f 398/373/298 414/357/314 413/356/313 397/372/297 +f 399/374/299 415/358/315 414/357/314 398/373/298 +f 400/375/300 416/359/316 415/358/315 399/374/299 +f 401/376/301 417/360/317 416/359/316 400/375/300 +f 402/377/302 418/361/318 417/360/317 401/376/301 +f 403/378/303 419/362/319 418/361/318 402/377/302 +f 404/379/304 420/363/320 419/362/319 403/378/303 +f 405/380/305 421/364/321 420/363/320 404/379/304 +f 406/381/306 422/365/322 421/364/321 405/380/305 +f 407/382/307 423/366/323 422/365/322 406/381/306 +f 408/383/308 424/367/324 423/366/323 407/382/307 +f 409/384/309 425/368/325 424/367/324 408/383/308 +f 410/385/310 426/369/326 425/368/325 409/384/309 +f 395/370/295 411/354/311 426/369/326 410/385/310 +f 412/355/312 428/339/328 427/338/327 411/354/311 +f 413/356/313 429/340/329 428/339/328 412/355/312 +f 414/357/314 430/341/330 429/340/329 413/356/313 +f 415/358/315 431/342/331 430/341/330 414/357/314 +f 416/359/316 432/343/332 431/342/331 415/358/315 +f 417/360/317 433/344/333 432/343/332 416/359/316 +f 418/361/318 434/345/334 433/344/333 417/360/317 +f 419/362/319 435/346/335 434/345/334 418/361/318 +f 420/363/320 436/347/336 435/346/335 419/362/319 +f 421/364/321 437/348/337 436/347/336 420/363/320 +f 422/365/322 438/349/338 437/348/337 421/364/321 +f 423/366/323 439/350/339 438/349/338 422/365/322 +f 424/367/324 440/351/340 439/350/339 423/366/323 +f 425/368/325 441/352/341 440/351/340 424/367/324 +f 426/369/326 442/353/342 441/352/341 425/368/325 +f 411/354/311 427/338/327 442/353/342 426/369/326 +f 428/339/328 443/337/343 427/338/327 +f 429/340/329 443/337/343 428/339/328 +f 430/341/330 443/337/343 429/340/329 +f 431/342/331 443/337/343 430/341/330 +f 432/343/332 443/337/343 431/342/331 +f 433/344/333 443/337/343 432/343/332 +f 434/345/334 443/337/343 433/344/333 +f 435/346/335 443/337/343 434/345/334 +f 436/347/336 443/337/343 435/346/335 +f 437/348/337 443/337/343 436/347/336 +f 438/349/338 443/337/343 437/348/337 +f 439/350/339 443/337/343 438/349/338 +f 440/351/340 443/337/343 439/350/339 +f 441/352/341 443/337/343 440/351/340 +f 442/353/342 443/337/343 441/352/341 +f 427/338/327 443/337/343 442/353/342 +# 80 polygons - 32 triangles + +# +# object led1 +# + +v -20.0000 25.8495 0.8829 +v -20.5945 25.8495 0.8829 +v -20.5493 26.0771 0.8829 +v -20.4204 26.2699 0.8829 +v -20.2275 26.3988 0.8829 +v -20.0000 26.4441 0.8829 +v -19.7725 26.3988 0.8829 +v -19.5796 26.2699 0.8829 +v -19.4507 26.0771 0.8829 +v -19.4055 25.8495 0.8829 +v -19.4507 25.6220 0.8829 +v -19.5796 25.4291 0.8829 +v -19.7725 25.3002 0.8829 +v -20.0000 25.2550 0.8829 +v -20.2275 25.3002 0.8829 +v -20.4204 25.4291 0.8829 +v -20.5493 25.6220 0.8829 +v -21.5884 25.8495 0.4712 +v -21.4674 26.4574 0.4712 +v -21.1231 26.9727 0.4712 +v -20.6078 27.3170 0.4712 +v -20.0000 27.4379 0.4712 +v -19.3922 27.3170 0.4712 +v -18.8769 26.9727 0.4712 +v -18.5326 26.4574 0.4712 +v -18.4116 25.8495 0.4712 +v -18.5326 25.2417 0.4712 +v -18.8769 24.7264 0.4712 +v -19.3922 24.3821 0.4712 +v -20.0000 24.2612 0.4712 +v -20.6078 24.3821 0.4712 +v -21.1231 24.7264 0.4712 +v -21.4674 25.2417 0.4712 +v -22.0000 25.8495 -0.5226 +v -21.8478 26.6149 -0.5226 +v -21.4142 27.2637 -0.5226 +v -20.7654 27.6973 -0.5226 +v -20.0000 27.8495 -0.5226 +v -19.2346 27.6973 -0.5226 +v -18.5858 27.2637 -0.5226 +v -18.1522 26.6149 -0.5226 +v -18.0000 25.8495 -0.5226 +v -18.1522 25.0842 -0.5226 +v -18.5858 24.4353 -0.5226 +v -19.2346 24.0018 -0.5226 +v -20.0000 23.8495 -0.5226 +v -20.7654 24.0018 -0.5226 +v -21.4142 24.4353 -0.5226 +v -21.8478 25.0842 -0.5226 +# 49 vertices + +vn 0.0000 -0.0000 1.0000 +vn -0.2183 -0.0000 0.9759 +vn -0.2017 0.0835 0.9759 +vn -0.1544 0.1544 0.9759 +vn -0.0835 0.2017 0.9759 +vn -0.0000 0.2183 0.9759 +vn 0.0835 0.2017 0.9759 +vn 0.1544 0.1544 0.9759 +vn 0.2017 0.0835 0.9759 +vn 0.2183 -0.0000 0.9759 +vn 0.2017 -0.0835 0.9759 +vn 0.1544 -0.1544 0.9759 +vn 0.0835 -0.2017 0.9759 +vn -0.0000 -0.2183 0.9759 +vn -0.0835 -0.2017 0.9759 +vn -0.1544 -0.1544 0.9759 +vn -0.2017 -0.0835 0.9759 +vn -0.7294 0.0000 0.6840 +vn -0.6739 0.2791 0.6840 +vn -0.5158 0.5158 0.6840 +vn -0.2791 0.6739 0.6840 +vn -0.0000 0.7294 0.6840 +vn 0.2791 0.6739 0.6840 +vn 0.5158 0.5158 0.6840 +vn 0.6739 0.2791 0.6840 +vn 0.7294 0.0000 0.6840 +vn 0.6739 -0.2791 0.6840 +vn 0.5158 -0.5158 0.6840 +vn 0.2791 -0.6739 0.6840 +vn -0.0000 -0.7294 0.6840 +vn -0.2791 -0.6739 0.6840 +vn -0.5158 -0.5158 0.6840 +vn -0.6739 -0.2791 0.6840 +vn -0.9239 0.0000 0.3827 +vn -0.8536 0.3536 0.3827 +vn -0.6533 0.6533 0.3827 +vn -0.3536 0.8536 0.3827 +vn 0.0000 0.9239 0.3827 +vn 0.3536 0.8536 0.3827 +vn 0.6533 0.6533 0.3827 +vn 0.8536 0.3536 0.3827 +vn 0.9239 0.0000 0.3827 +vn 0.8536 -0.3536 0.3827 +vn 0.6533 -0.6533 0.3827 +vn 0.3536 -0.8536 0.3827 +vn -0.0000 -0.9239 0.3827 +vn -0.3536 -0.8536 0.3827 +vn -0.6533 -0.6533 0.3827 +vn -0.8536 -0.3536 0.3827 +# 49 vertex normals + +vt 0.5000 0.5000 0.0000 +vt 0.6486 0.5000 0.0000 +vt 0.6373 0.5569 0.0000 +vt 0.6051 0.6051 0.0000 +vt 0.5569 0.6373 0.0000 +vt 0.5000 0.6486 0.0000 +vt 0.4431 0.6373 0.0000 +vt 0.3949 0.6051 0.0000 +vt 0.3627 0.5569 0.0000 +vt 0.3514 0.5000 0.0000 +vt 0.3627 0.4431 0.0000 +vt 0.3949 0.3949 0.0000 +vt 0.4431 0.3627 0.0000 +vt 0.5000 0.3514 0.0000 +vt 0.5569 0.3627 0.0000 +vt 0.6051 0.3949 0.0000 +vt 0.6373 0.4431 0.0000 +vt 0.8971 0.5000 0.0000 +vt 0.8669 0.6520 0.0000 +vt 0.7808 0.7808 0.0000 +vt 0.6520 0.8669 0.0000 +vt 0.5000 0.8971 0.0000 +vt 0.3480 0.8669 0.0000 +vt 0.2192 0.7808 0.0000 +vt 0.1331 0.6520 0.0000 +vt 0.1029 0.5000 0.0000 +vt 0.1331 0.3480 0.0000 +vt 0.2192 0.2192 0.0000 +vt 0.3480 0.1331 0.0000 +vt 0.5000 0.1029 0.0000 +vt 0.6520 0.1331 0.0000 +vt 0.7808 0.2192 0.0000 +vt 0.8669 0.3480 0.0000 +vt 1.0000 0.5000 0.0000 +vt 0.9619 0.6913 0.0000 +vt 0.8536 0.8536 0.0000 +vt 0.6913 0.9619 0.0000 +vt 0.5000 1.0000 0.0000 +vt 0.3087 0.9619 0.0000 +vt 0.1464 0.8536 0.0000 +vt 0.0381 0.6913 0.0000 +vt 0.0000 0.5000 0.0000 +vt 0.0381 0.3087 0.0000 +vt 0.1464 0.1464 0.0000 +vt 0.3087 0.0381 0.0000 +vt 0.5000 0.0000 0.0000 +vt 0.6913 0.0381 0.0000 +vt 0.8536 0.1464 0.0000 +vt 0.9619 0.3087 0.0000 +# 49 texture coords + +g led1 +usemtl 03___Default +s 4 +f 446/420/346 445/419/345 444/418/344 +f 447/421/347 446/420/346 444/418/344 +f 448/422/348 447/421/347 444/418/344 +f 449/423/349 448/422/348 444/418/344 +f 450/424/350 449/423/349 444/418/344 +f 451/425/351 450/424/350 444/418/344 +f 452/426/352 451/425/351 444/418/344 +f 453/427/353 452/426/352 444/418/344 +f 454/428/354 453/427/353 444/418/344 +f 455/429/355 454/428/354 444/418/344 +f 456/430/356 455/429/355 444/418/344 +f 457/431/357 456/430/356 444/418/344 +f 458/432/358 457/431/357 444/418/344 +f 459/433/359 458/432/358 444/418/344 +f 460/434/360 459/433/359 444/418/344 +f 445/419/345 460/434/360 444/418/344 +f 446/420/346 462/436/362 461/435/361 445/419/345 +f 447/421/347 463/437/363 462/436/362 446/420/346 +f 448/422/348 464/438/364 463/437/363 447/421/347 +f 449/423/349 465/439/365 464/438/364 448/422/348 +f 450/424/350 466/440/366 465/439/365 449/423/349 +f 451/425/351 467/441/367 466/440/366 450/424/350 +f 452/426/352 468/442/368 467/441/367 451/425/351 +f 453/427/353 469/443/369 468/442/368 452/426/352 +f 454/428/354 470/444/370 469/443/369 453/427/353 +f 455/429/355 471/445/371 470/444/370 454/428/354 +f 456/430/356 472/446/372 471/445/371 455/429/355 +f 457/431/357 473/447/373 472/446/372 456/430/356 +f 458/432/358 474/448/374 473/447/373 457/431/357 +f 459/433/359 475/449/375 474/448/374 458/432/358 +f 460/434/360 476/450/376 475/449/375 459/433/359 +f 445/419/345 461/435/361 476/450/376 460/434/360 +f 462/436/362 478/452/378 477/451/377 461/435/361 +f 463/437/363 479/453/379 478/452/378 462/436/362 +f 464/438/364 480/454/380 479/453/379 463/437/363 +f 465/439/365 481/455/381 480/454/380 464/438/364 +f 466/440/366 482/456/382 481/455/381 465/439/365 +f 467/441/367 483/457/383 482/456/382 466/440/366 +f 468/442/368 484/458/384 483/457/383 467/441/367 +f 469/443/369 485/459/385 484/458/384 468/442/368 +f 470/444/370 486/460/386 485/459/385 469/443/369 +f 471/445/371 487/461/387 486/460/386 470/444/370 +f 472/446/372 488/462/388 487/461/387 471/445/371 +f 473/447/373 489/463/389 488/462/388 472/446/372 +f 474/448/374 490/464/390 489/463/389 473/447/373 +f 475/449/375 491/465/391 490/464/390 474/448/374 +f 476/450/376 492/466/392 491/465/391 475/449/375 +f 461/435/361 477/451/377 492/466/392 476/450/376 +# 32 polygons - 16 triangles + +# +# object led2 +# + +v 20.0000 25.8495 0.8829 +v 20.5945 25.8495 0.8829 +v 20.5493 26.0771 0.8829 +v 20.4204 26.2699 0.8829 +v 20.2275 26.3988 0.8829 +v 20.0000 26.4441 0.8829 +v 19.7725 26.3988 0.8829 +v 19.5796 26.2699 0.8829 +v 19.4507 26.0771 0.8829 +v 19.4055 25.8495 0.8829 +v 19.4507 25.6220 0.8829 +v 19.5796 25.4291 0.8829 +v 19.7725 25.3002 0.8829 +v 20.0000 25.2550 0.8829 +v 20.2275 25.3002 0.8829 +v 20.4204 25.4291 0.8829 +v 20.5493 25.6220 0.8829 +v 21.5884 25.8495 0.4712 +v 21.4674 26.4574 0.4712 +v 21.1231 26.9727 0.4712 +v 20.6078 27.3170 0.4712 +v 20.0000 27.4379 0.4712 +v 19.3922 27.3170 0.4712 +v 18.8769 26.9727 0.4712 +v 18.5326 26.4574 0.4712 +v 18.4116 25.8495 0.4712 +v 18.5326 25.2417 0.4712 +v 18.8769 24.7264 0.4712 +v 19.3922 24.3821 0.4712 +v 20.0000 24.2612 0.4712 +v 20.6078 24.3821 0.4712 +v 21.1231 24.7264 0.4712 +v 21.4674 25.2417 0.4712 +v 22.0000 25.8495 -0.5226 +v 21.8478 26.6149 -0.5226 +v 21.4142 27.2637 -0.5226 +v 20.7654 27.6973 -0.5226 +v 20.0000 27.8495 -0.5226 +v 19.2346 27.6973 -0.5226 +v 18.5858 27.2637 -0.5226 +v 18.1522 26.6149 -0.5226 +v 18.0000 25.8495 -0.5226 +v 18.1522 25.0842 -0.5226 +v 18.5858 24.4353 -0.5226 +v 19.2346 24.0018 -0.5226 +v 20.0000 23.8495 -0.5226 +v 20.7654 24.0018 -0.5226 +v 21.4142 24.4353 -0.5226 +v 21.8478 25.0842 -0.5226 +# 49 vertices + +vn 0.0000 -0.0000 1.0000 +vn 0.2183 -0.0000 0.9759 +vn 0.2017 0.0835 0.9759 +vn 0.1544 0.1544 0.9759 +vn 0.0835 0.2017 0.9759 +vn 0.0000 0.2183 0.9759 +vn -0.0835 0.2017 0.9759 +vn -0.1544 0.1544 0.9759 +vn -0.2017 0.0835 0.9759 +vn -0.2183 -0.0000 0.9759 +vn -0.2017 -0.0835 0.9759 +vn -0.1544 -0.1544 0.9759 +vn -0.0835 -0.2017 0.9759 +vn 0.0000 -0.2183 0.9759 +vn 0.0835 -0.2017 0.9759 +vn 0.1544 -0.1544 0.9759 +vn 0.2017 -0.0835 0.9759 +vn 0.7294 0.0000 0.6840 +vn 0.6739 0.2791 0.6840 +vn 0.5158 0.5158 0.6840 +vn 0.2791 0.6739 0.6840 +vn 0.0000 0.7294 0.6840 +vn -0.2791 0.6739 0.6840 +vn -0.5158 0.5158 0.6840 +vn -0.6739 0.2791 0.6840 +vn -0.7294 0.0000 0.6840 +vn -0.6739 -0.2791 0.6840 +vn -0.5158 -0.5158 0.6840 +vn -0.2791 -0.6739 0.6840 +vn 0.0000 -0.7294 0.6840 +vn 0.2791 -0.6739 0.6840 +vn 0.5158 -0.5158 0.6840 +vn 0.6739 -0.2791 0.6840 +vn 0.9239 0.0000 0.3827 +vn 0.8536 0.3536 0.3827 +vn 0.6533 0.6533 0.3827 +vn 0.3536 0.8536 0.3827 +vn 0.0000 0.9239 0.3827 +vn -0.3536 0.8536 0.3827 +vn -0.6533 0.6533 0.3827 +vn -0.8536 0.3536 0.3827 +vn -0.9239 0.0000 0.3827 +vn -0.8536 -0.3536 0.3827 +vn -0.6533 -0.6533 0.3827 +vn -0.3536 -0.8536 0.3827 +vn 0.0000 -0.9239 0.3827 +vn 0.3536 -0.8536 0.3827 +vn 0.6533 -0.6533 0.3827 +vn 0.8536 -0.3536 0.3827 +# 49 vertex normals + +vt 0.5000 0.5000 0.0000 +vt 0.6486 0.5000 0.0000 +vt 0.6373 0.5569 0.0000 +vt 0.6051 0.6051 0.0000 +vt 0.5569 0.6373 0.0000 +vt 0.5000 0.6486 0.0000 +vt 0.4431 0.6373 0.0000 +vt 0.3949 0.6051 0.0000 +vt 0.3627 0.5569 0.0000 +vt 0.3514 0.5000 0.0000 +vt 0.3627 0.4431 0.0000 +vt 0.3949 0.3949 0.0000 +vt 0.4431 0.3627 0.0000 +vt 0.5000 0.3514 0.0000 +vt 0.5569 0.3627 0.0000 +vt 0.6051 0.3949 0.0000 +vt 0.6373 0.4431 0.0000 +vt 0.8971 0.5000 0.0000 +vt 0.8669 0.6520 0.0000 +vt 0.7808 0.7808 0.0000 +vt 0.6520 0.8669 0.0000 +vt 0.5000 0.8971 0.0000 +vt 0.3480 0.8669 0.0000 +vt 0.2192 0.7808 0.0000 +vt 0.1331 0.6520 0.0000 +vt 0.1029 0.5000 0.0000 +vt 0.1331 0.3480 0.0000 +vt 0.2192 0.2192 0.0000 +vt 0.3480 0.1331 0.0000 +vt 0.5000 0.1029 0.0000 +vt 0.6520 0.1331 0.0000 +vt 0.7808 0.2192 0.0000 +vt 0.8669 0.3480 0.0000 +vt 1.0000 0.5000 0.0000 +vt 0.9619 0.6913 0.0000 +vt 0.8536 0.8536 0.0000 +vt 0.6913 0.9619 0.0000 +vt 0.5000 1.0000 0.0000 +vt 0.3087 0.9619 0.0000 +vt 0.1464 0.8536 0.0000 +vt 0.0381 0.6913 0.0000 +vt 0.0000 0.5000 0.0000 +vt 0.0381 0.3087 0.0000 +vt 0.1464 0.1464 0.0000 +vt 0.3087 0.0381 0.0000 +vt 0.5000 0.0000 0.0000 +vt 0.6913 0.0381 0.0000 +vt 0.8536 0.1464 0.0000 +vt 0.9619 0.3087 0.0000 +# 49 texture coords + +g led2 +usemtl 03___Default +s 4 +f 493/467/393 494/468/394 495/469/395 +f 493/467/393 495/469/395 496/470/396 +f 493/467/393 496/470/396 497/471/397 +f 493/467/393 497/471/397 498/472/398 +f 493/467/393 498/472/398 499/473/399 +f 493/467/393 499/473/399 500/474/400 +f 493/467/393 500/474/400 501/475/401 +f 493/467/393 501/475/401 502/476/402 +f 493/467/393 502/476/402 503/477/403 +f 493/467/393 503/477/403 504/478/404 +f 493/467/393 504/478/404 505/479/405 +f 493/467/393 505/479/405 506/480/406 +f 493/467/393 506/480/406 507/481/407 +f 493/467/393 507/481/407 508/482/408 +f 493/467/393 508/482/408 509/483/409 +f 493/467/393 509/483/409 494/468/394 +f 494/468/394 510/484/410 511/485/411 495/469/395 +f 495/469/395 511/485/411 512/486/412 496/470/396 +f 496/470/396 512/486/412 513/487/413 497/471/397 +f 497/471/397 513/487/413 514/488/414 498/472/398 +f 498/472/398 514/488/414 515/489/415 499/473/399 +f 499/473/399 515/489/415 516/490/416 500/474/400 +f 500/474/400 516/490/416 517/491/417 501/475/401 +f 501/475/401 517/491/417 518/492/418 502/476/402 +f 502/476/402 518/492/418 519/493/419 503/477/403 +f 503/477/403 519/493/419 520/494/420 504/478/404 +f 504/478/404 520/494/420 521/495/421 505/479/405 +f 505/479/405 521/495/421 522/496/422 506/480/406 +f 506/480/406 522/496/422 523/497/423 507/481/407 +f 507/481/407 523/497/423 524/498/424 508/482/408 +f 508/482/408 524/498/424 525/499/425 509/483/409 +f 509/483/409 525/499/425 510/484/410 494/468/394 +f 510/484/410 526/500/426 527/501/427 511/485/411 +f 511/485/411 527/501/427 528/502/428 512/486/412 +f 512/486/412 528/502/428 529/503/429 513/487/413 +f 513/487/413 529/503/429 530/504/430 514/488/414 +f 514/488/414 530/504/430 531/505/431 515/489/415 +f 515/489/415 531/505/431 532/506/432 516/490/416 +f 516/490/416 532/506/432 533/507/433 517/491/417 +f 517/491/417 533/507/433 534/508/434 518/492/418 +f 518/492/418 534/508/434 535/509/435 519/493/419 +f 519/493/419 535/509/435 536/510/436 520/494/420 +f 520/494/420 536/510/436 537/511/437 521/495/421 +f 521/495/421 537/511/437 538/512/438 522/496/422 +f 522/496/422 538/512/438 539/513/439 523/497/423 +f 523/497/423 539/513/439 540/514/440 524/498/424 +f 524/498/424 540/514/440 541/515/441 525/499/425 +f 525/499/425 541/515/441 526/500/426 510/484/410 +# 32 polygons - 16 triangles + +# +# object 7seg1 +# + +v -14.9101 33.4418 -3.5118 +v -14.9101 13.5418 -3.5118 +v -0.0434 13.5418 -3.5118 +v -0.0434 33.4418 -3.5118 +v -0.0434 13.5418 -8.5118 +v -14.9101 13.5418 -8.5118 +v -14.9101 33.4418 -8.5118 +v -0.0434 33.4418 -8.5118 +# 8 vertices + +vn 0.0000 -0.0000 1.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 -1.0000 -0.0000 +vn 1.0000 0.0000 -0.0000 +vn 0.0000 1.0000 0.0000 +vn -1.0000 0.0000 -0.0000 +# 6 vertex normals + +vt 0.0000 0.9995 0.9995 +vt 0.0000 0.0005 0.9995 +vt 0.0908 0.0005 0.9995 +vt 0.0908 0.9995 0.9995 +vt 0.0908 0.0005 0.0005 +vt 0.0000 0.0005 0.0005 +vt 0.0000 0.9995 0.0005 +vt 0.0908 0.9995 0.0005 +# 8 texture coords + +g 7seg1 +usemtl 08___Default +s 2 +f 542/516/442 543/517/442 544/518/442 545/519/442 +s 4 +f 546/520/443 547/521/443 548/522/443 549/523/443 +s 8 +f 544/518/444 543/517/444 547/521/444 546/520/444 +s 16 +f 545/519/445 544/518/445 546/520/445 549/523/445 +s 32 +f 542/516/446 545/519/446 549/523/446 548/522/446 +s 64 +f 543/517/447 542/516/447 548/522/447 547/521/447 +# 6 polygons + +# +# object 7seg0 +# + +v 0.0439 33.4418 -3.5118 +v 0.0439 13.5418 -3.5118 +v 14.9106 13.5418 -3.5118 +v 14.9106 33.4418 -3.5118 +v 14.9106 13.5418 -8.5118 +v 0.0439 13.5418 -8.5118 +v 0.0439 33.4418 -8.5118 +v 14.9106 33.4418 -8.5118 +# 8 vertices + +vn 0.0000 -0.0000 1.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 -1.0000 -0.0000 +vn 1.0000 0.0000 -0.0000 +vn 0.0000 1.0000 0.0000 +vn -1.0000 0.0000 -0.0000 +# 6 vertex normals + +vt 0.0000 0.9995 0.9995 +vt 0.0000 0.0005 0.9995 +vt 0.0908 0.0005 0.9995 +vt 0.0908 0.9995 0.9995 +vt 0.0908 0.0005 0.0005 +vt 0.0000 0.0005 0.0005 +vt 0.0000 0.9995 0.0005 +vt 0.0908 0.9995 0.0005 +# 8 texture coords + +g 7seg0 +usemtl 08___Default +s 2 +f 550/524/448 551/525/448 552/526/448 553/527/448 +s 4 +f 554/528/449 555/529/449 556/530/449 557/531/449 +s 8 +f 552/526/450 551/525/450 555/529/450 554/528/450 +s 16 +f 553/527/451 552/526/451 554/528/451 557/531/451 +s 32 +f 550/524/452 553/527/452 557/531/452 556/530/452 +s 64 +f 551/525/453 550/524/453 556/530/453 555/529/453 +# 6 polygons + diff --git a/data/envmap.png b/data/envmap.png new file mode 100644 index 0000000..2b34f96 Binary files /dev/null and b/data/envmap.png differ diff --git a/data/labels.png b/data/labels.png new file mode 100644 index 0000000..2fb90ac Binary files /dev/null and b/data/labels.png differ diff --git a/libs/libimago/COPYING b/libs/libimago/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/libs/libimago/COPYING @@ -0,0 +1,674 @@ + 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 +. diff --git a/libs/libimago/COPYING.LESSER b/libs/libimago/COPYING.LESSER new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/libs/libimago/COPYING.LESSER @@ -0,0 +1,165 @@ + GNU LESSER 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. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser 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 +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/libs/libimago/Makefile.in b/libs/libimago/Makefile.in new file mode 100644 index 0000000..7d7c912 --- /dev/null +++ b/libs/libimago/Makefile.in @@ -0,0 +1,76 @@ +dbg = -g +opt = + +csrc = $(wildcard src/*.c) +obj = $(csrc:.c=.o) +lib_a = libimago.a + +somajor = 2 +sominor = 0 + +incdir = -I$(PREFIX)/include +libdir = -L$(PREFIX)/lib + +ifeq ($(shell uname -s), Darwin) + lib_so = libimago.dylib + shared = -dynamiclib + # add macports and fink dirs to the include and lib paths + incdir += -I/opt/local/include -I/sw/local/include -I/usr/X11R6/include + libdir += -L/opt/local/lib -L/sw/local/lib -L/usr/X11R6/lib +else + soname = libimago.so.$(somajor) + lib_so = $(soname).$(sominor) + solink = libimago.so + shared = -shared -Wl,-soname,$(soname) +endif + +ifeq ($(shell uname -s), IRIX) + # add nekoware and SGI freeware dirs to the include and lib paths + incdir += -I/usr/nekoware/include -I/usr/freeware/include + libdir += -L/usr/nekoware/lib -L/usr/freeware/lib +endif + +CC = gcc +AR = ar +CFLAGS = -pedantic -Wall $(opt) $(dbg) -fPIC -Isrc $(incdir) +LDFLAGS = $(libdir) -lpng -lz -ljpeg -ldl + +.PHONY: all +all: $(lib_a) $(lib_so) + +$(lib_a): $(obj) + $(AR) rcs $@ $^ + +$(lib_so): $(obj) + $(CC) $(CFLAGS) $(shared) -o $@ $^ $(LDFLAGS) + +.PHONY: clean +clean: + rm -f $(obj) + +.PHONY: distclean +distclean: + rm -f $(obj) $(lib_so) $(lib_a) Makefile src/modules.c + +.PHONY: install +install: $(lib_so) $(lib_a) + mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib + cp src/imago2.h $(DESTDIR)$(PREFIX)/include/imago2.h + cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so) + cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a) + [ -n "$(solink)" ] \ + && cd $(DESTDIR)$(PREFIX)/lib \ + && rm -f $(solink) $(soname) \ + && ln -s $(lib_so) $(soname) \ + && ln -s $(soname) $(solink) \ + || true + +.PHONY: uninstall +uninstall: + rm -f $(DESTDIR)$(PREFIX)/include/imago2.h + rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so) + rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a) + [ -n "$(solink)" ] \ + && rm -f $(DESTDIR)$(PREFIX)/lib/$(solink) \ + && rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) \ + || true diff --git a/libs/libimago/README b/libs/libimago/README new file mode 100644 index 0000000..6d0eb13 --- /dev/null +++ b/libs/libimago/README @@ -0,0 +1,8 @@ +imago version 2.0 +----------------- + +Author: John Tsiombikas + +This library is released as free software under the term of the GNU Lesser +General Public License (LGPL) version 3 or any later version published by +the Free Software Foundation. See COPYING and COPYING.LESSER for details. diff --git a/libs/libimago/build/vcconfig.bat b/libs/libimago/build/vcconfig.bat new file mode 100644 index 0000000..2b8177d --- /dev/null +++ b/libs/libimago/build/vcconfig.bat @@ -0,0 +1,14 @@ +@set outfile=src/modules.c + +@echo /* this file is generated by vcconfig.bat, do not edit */ >%outfile% +@echo int img_register_png(); >>%outfile% +@echo int img_register_jpeg(); >>%outfile% +@echo int img_register_ppm(); >>%outfile% +@echo int img_register_rgbe(); >>%outfile% +@echo void img_modules_init(void) >>%outfile% +@echo { >>%outfile% +@echo img_register_png(); >>%outfile% +@echo img_register_jpeg(); >>%outfile% +@echo img_register_ppm(); >>%outfile% +@echo img_register_rgbe(); >>%outfile% +@echo } >>%outfile% diff --git a/libs/libimago/configure b/libs/libimago/configure new file mode 100755 index 0000000..370c179 --- /dev/null +++ b/libs/libimago/configure @@ -0,0 +1,27 @@ +#!/bin/sh + +gen_module_init() +{ + # collect all src/file_whatever.c files + modules=`ls src/file_*.c 2>/dev/null | sort | sed 's/src\/file_//' | sed 's/\.c//'` + + echo "/* this file is generated by $0, do not edit */" + for m in $modules; do + echo "int img_register_$m();" + done + + echo + echo 'void img_modules_init(void)' + echo '{' + + for m in $modules; do + echo " img_register_$m();" + done + + echo '}' +} + +gen_module_init >src/modules.c + +echo 'PREFIX = /usr/local' >Makefile +cat Makefile.in >>Makefile diff --git a/libs/libimago/imago-vs2012.sln b/libs/libimago/imago-vs2012.sln new file mode 100644 index 0000000..737c2e3 --- /dev/null +++ b/libs/libimago/imago-vs2012.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imago", "imago-vs2012.vcxproj", "{1FFDD3FB-E37E-4258-8955-5583AF3A0C29}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Debug|Win32.ActiveCfg = Debug|Win32 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Debug|Win32.Build.0 = Debug|Win32 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Debug|x64.ActiveCfg = Debug|x64 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Debug|x64.Build.0 = Debug|x64 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Release|Win32.ActiveCfg = Release|Win32 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Release|Win32.Build.0 = Release|Win32 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Release|x64.ActiveCfg = Release|x64 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/libimago/imago-vs2012.vcxproj b/libs/libimago/imago-vs2012.vcxproj new file mode 100644 index 0000000..b4bd4b6 --- /dev/null +++ b/libs/libimago/imago-vs2012.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + libimago2 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29} + imago + Win32Proj + + + + StaticLibrary + v110 + Unicode + true + + + StaticLibrary + v100 + Unicode + true + + + StaticLibrary + v110 + Unicode + + + StaticLibrary + v100 + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>11.0.60610.1 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + + $(ProjectName)-x64 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + + $(ProjectName)-x64 + + + + $(SolutionDir)\build\vcconfig.bat + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + Level3 + EditAndContinue + 4244;4996;%(DisableSpecificWarnings) + + + + + $(SolutionDir)\build\vcconfig.bat + + + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + 4244;4996;%(DisableSpecificWarnings) + + + mkdir $(SolutionDir)\usr\include +mkdir $(SolutionDir)\usr\lib +copy /Y $(SolutionDir)\src\imago2.h $(SolutionDir)\usr\include\ +copy /Y $(TargetPath) $(SolutionDir)\usr\lib\ + + + + + MaxSpeed + true + false + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + Level3 + ProgramDatabase + 4244;4996;%(DisableSpecificWarnings) + + + + + MaxSpeed + true + false + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level3 + ProgramDatabase + 4244;4996;%(DisableSpecificWarnings) + + + mkdir $(SolutionDir)\usr\include +mkdir $(SolutionDir)\usr\lib +copy /Y $(SolutionDir)\src\imago2.h $(SolutionDir)\usr\include\ +copy /Y $(TargetPath) $(SolutionDir)\usr\lib\ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/libimago/imago-vs2012.vcxproj.filters b/libs/libimago/imago-vs2012.vcxproj.filters new file mode 100644 index 0000000..de16c20 --- /dev/null +++ b/libs/libimago/imago-vs2012.vcxproj.filters @@ -0,0 +1,51 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/libs/libimago/imago.sln b/libs/libimago/imago.sln new file mode 100644 index 0000000..ab4ba84 --- /dev/null +++ b/libs/libimago/imago.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imago", "imago.vcproj", "{1FFDD3FB-E37E-4258-8955-5583AF3A0C29}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Debug|Win32.ActiveCfg = Debug|Win32 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Debug|Win32.Build.0 = Debug|Win32 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Release|Win32.ActiveCfg = Release|Win32 + {1FFDD3FB-E37E-4258-8955-5583AF3A0C29}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/libimago/imago.vcproj b/libs/libimago/imago.vcproj new file mode 100644 index 0000000..17fc3bf --- /dev/null +++ b/libs/libimago/imago.vcproj @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/libimago/install.bat b/libs/libimago/install.bat new file mode 100644 index 0000000..5bb1ad2 --- /dev/null +++ b/libs/libimago/install.bat @@ -0,0 +1,5 @@ +mkdir c:\usr\include\ +copy /Y usr\include\* c:\usr\include\ +mkdir c:\usr\lib +copy /Y usr\lib\* c:\usr\lib\ +pause diff --git a/libs/libimago/src/conv.c b/libs/libimago/src/conv.c new file mode 100644 index 0000000..334fe35 --- /dev/null +++ b/libs/libimago/src/conv.c @@ -0,0 +1,260 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include +#include "imago2.h" + +/* pixel-format conversions are sub-optimal at the moment to avoid + * writing a lot of code. optimize at some point ? + */ + +#define CLAMP(x, a, b) ((x) < (a) ? (a) : ((x) > (b) ? (b) : (x))) + +struct pixel { + float r, g, b, a; +}; + +static void unpack_grey8(struct pixel *unp, void *pptr, int count); +static void unpack_rgb24(struct pixel *unp, void *pptr, int count); +static void unpack_rgba32(struct pixel *unp, void *pptr, int count); +static void unpack_greyf(struct pixel *unp, void *pptr, int count); +static void unpack_rgbf(struct pixel *unp, void *pptr, int count); +static void unpack_rgbaf(struct pixel *unp, void *pptr, int count); + +static void pack_grey8(void *pptr, struct pixel *unp, int count); +static void pack_rgb24(void *pptr, struct pixel *unp, int count); +static void pack_rgba32(void *pptr, struct pixel *unp, int count); +static void pack_greyf(void *pptr, struct pixel *unp, int count); +static void pack_rgbf(void *pptr, struct pixel *unp, int count); +static void pack_rgbaf(void *pptr, struct pixel *unp, int count); + +/* XXX keep in sync with enum img_fmt at imago2.h */ +static void (*unpack[])(struct pixel*, void*, int) = { + unpack_grey8, + unpack_rgb24, + unpack_rgba32, + unpack_greyf, + unpack_rgbf, + unpack_rgbaf +}; + +/* XXX keep in sync with enum img_fmt at imago2.h */ +static void (*pack[])(void*, struct pixel*, int) = { + pack_grey8, + pack_rgb24, + pack_rgba32, + pack_greyf, + pack_rgbf, + pack_rgbaf +}; + + +int img_convert(struct img_pixmap *img, enum img_fmt tofmt) +{ + struct pixel pbuf[8]; + int bufsz = (img->width & 7) == 0 ? 8 : ((img->width & 3) == 0 ? 4 : 1); + int i, num_pix = img->width * img->height; + int num_iter = num_pix / bufsz; + char *sptr, *dptr; + struct img_pixmap nimg; + + if(img->fmt == tofmt) { + return 0; /* nothing to do */ + } + + img_init(&nimg); + if(img_set_pixels(&nimg, img->width, img->height, tofmt, 0) == -1) { + img_destroy(&nimg); + return -1; + } + + sptr = img->pixels; + dptr = nimg.pixels; + + for(i=0; ifmt](pbuf, sptr, bufsz); + pack[tofmt](dptr, pbuf, bufsz); + + sptr += bufsz * img->pixelsz; + dptr += bufsz * nimg.pixelsz; + } + + img_copy(img, &nimg); + img_destroy(&nimg); + return 0; +} + +/* the following functions *could* benefit from SIMD */ + +static void unpack_grey8(struct pixel *unp, void *pptr, int count) +{ + int i; + unsigned char *pix = pptr; + + for(i=0; ir = unp->g = unp->b = (float)*pix++ / 255.0; + unp->a = 1.0; + unp++; + } +} + +static void unpack_rgb24(struct pixel *unp, void *pptr, int count) +{ + int i; + unsigned char *pix = pptr; + + for(i=0; ir = (float)*pix++ / 255.0; + unp->g = (float)*pix++ / 255.0; + unp->b = (float)*pix++ / 255.0; + unp->a = 1.0; + unp++; + } +} + +static void unpack_rgba32(struct pixel *unp, void *pptr, int count) +{ + int i; + unsigned char *pix = pptr; + + for(i=0; ir = (float)*pix++ / 255.0; + unp->g = (float)*pix++ / 255.0; + unp->b = (float)*pix++ / 255.0; + unp->a = (float)*pix++ / 255.0; + unp++; + } +} + +static void unpack_greyf(struct pixel *unp, void *pptr, int count) +{ + int i; + float *pix = pptr; + + for(i=0; ir = unp->g = unp->b = *pix++; + unp->a = 1.0; + unp++; + } +} + +static void unpack_rgbf(struct pixel *unp, void *pptr, int count) +{ + int i; + float *pix = pptr; + + for(i=0; ir = *pix++; + unp->g = *pix++; + unp->b = *pix++; + unp->a = 1.0; + unp++; + } +} + +static void unpack_rgbaf(struct pixel *unp, void *pptr, int count) +{ + int i; + float *pix = pptr; + + for(i=0; ir = *pix++; + unp->g = *pix++; + unp->b = *pix++; + unp->a = *pix++; + unp++; + } +} + + +static void pack_grey8(void *pptr, struct pixel *unp, int count) +{ + int i; + unsigned char *pix = pptr; + + for(i=0; ir + unp->g + unp->b) / 3.0); + *pix++ = CLAMP(lum, 0, 255); + unp++; + } +} + +static void pack_rgb24(void *pptr, struct pixel *unp, int count) +{ + int i; + unsigned char *pix = pptr; + + for(i=0; ir * 255.0); + int g = (int)(unp->g * 255.0); + int b = (int)(unp->b * 255.0); + + *pix++ = CLAMP(r, 0, 255); + *pix++ = CLAMP(g, 0, 255); + *pix++ = CLAMP(b, 0, 255); + unp++; + } +} + +static void pack_rgba32(void *pptr, struct pixel *unp, int count) +{ + int i; + unsigned char *pix = pptr; + + for(i=0; ir * 255.0); + int g = (int)(unp->g * 255.0); + int b = (int)(unp->b * 255.0); + int a = (int)(unp->a * 255.0); + + *pix++ = CLAMP(r, 0, 255); + *pix++ = CLAMP(g, 0, 255); + *pix++ = CLAMP(b, 0, 255); + *pix++ = CLAMP(a, 0, 255); + unp++; + } +} + +static void pack_greyf(void *pptr, struct pixel *unp, int count) +{ + int i; + float *pix = pptr; + + for(i=0; ir + unp->g + unp->b) / 3.0; + unp++; + } +} + +static void pack_rgbf(void *pptr, struct pixel *unp, int count) +{ + int i; + float *pix = pptr; + + for(i=0; ir; + *pix++ = unp->g; + *pix++ = unp->b; + unp++; + } +} + +static void pack_rgbaf(void *pptr, struct pixel *unp, int count) +{ + memcpy(pptr, unp, count * sizeof *unp); +} + diff --git a/libs/libimago/src/file_jpeg.c b/libs/libimago/src/file_jpeg.c new file mode 100644 index 0000000..ba5247e --- /dev/null +++ b/libs/libimago/src/file_jpeg.c @@ -0,0 +1,294 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ + +/* -- JPEG module -- */ + +#include +#include +#include + +#ifdef WIN32 +#include +#define HAVE_BOOLEAN +#endif + +#include +#include "imago2.h" +#include "ftype_module.h" + +#define INPUT_BUF_SIZE 512 +#define OUTPUT_BUF_SIZE 512 + +/* data source manager: adapted from jdatasrc.c */ +struct src_mgr { + struct jpeg_source_mgr pub; + + struct img_io *io; + unsigned char buffer[INPUT_BUF_SIZE]; + int start_of_file; +}; + +/* data destination manager: adapted from jdatadst.c */ +struct dst_mgr { + struct jpeg_destination_mgr pub; + + struct img_io *io; + unsigned char buffer[OUTPUT_BUF_SIZE]; +}; + +static int check(struct img_io *io); +static int read(struct img_pixmap *img, struct img_io *io); +static int write(struct img_pixmap *img, struct img_io *io); + +/* read source functions */ +static void init_source(j_decompress_ptr jd); +static boolean fill_input_buffer(j_decompress_ptr jd); +static void skip_input_data(j_decompress_ptr jd, long num_bytes); +static void term_source(j_decompress_ptr jd); + +/* write destination functions */ +static void init_destination(j_compress_ptr jc); +static boolean empty_output_buffer(j_compress_ptr jc); +static void term_destination(j_compress_ptr jc); + +int img_register_jpeg(void) +{ + static struct ftype_module mod = {".jpg", check, read, write}; + return img_register_module(&mod); +} + + +static int check(struct img_io *io) +{ + unsigned char sig[10]; + + long pos = io->seek(0, SEEK_CUR, io->uptr); + + if(io->read(sig, 10, io->uptr) < 10) { + io->seek(pos, SEEK_SET, io->uptr); + return -1; + } + + if(memcmp(sig, "\xff\xd8\xff\xe0", 4) != 0 && memcmp(sig, "\xff\xd8\xff\xe1", 4) != 0 + && memcmp(sig + 6, "JFIF", 4) != 0) { + io->seek(pos, SEEK_SET, io->uptr); + return -1; + } + io->seek(pos, SEEK_SET, io->uptr); + return 0; +} + +static int read(struct img_pixmap *img, struct img_io *io) +{ + int i, nlines = 0; + struct jpeg_decompress_struct cinfo; + struct jpeg_error_mgr jerr; + struct src_mgr src; + unsigned char **scanlines; + + io->seek(0, SEEK_CUR, io->uptr); + + cinfo.err = jpeg_std_error(&jerr); /* XXX change... */ + jpeg_create_decompress(&cinfo); + + src.pub.init_source = init_source; + src.pub.fill_input_buffer = fill_input_buffer; + src.pub.skip_input_data = skip_input_data; + src.pub.resync_to_restart = jpeg_resync_to_restart; + src.pub.term_source = term_source; + src.pub.next_input_byte = 0; + src.pub.bytes_in_buffer = 0; + src.io = io; + cinfo.src = (struct jpeg_source_mgr*)&src; + + jpeg_read_header(&cinfo, 1); + cinfo.out_color_space = JCS_RGB; + + if(img_set_pixels(img, cinfo.image_width, cinfo.image_height, IMG_FMT_RGB24, 0) == -1) { + jpeg_destroy_decompress(&cinfo); + return -1; + } + + if(!(scanlines = malloc(img->height * sizeof *scanlines))) { + jpeg_destroy_decompress(&cinfo); + return -1; + } + scanlines[0] = img->pixels; + for(i=1; iheight; i++) { + scanlines[i] = scanlines[i - 1] + img->width * img->pixelsz; + } + + jpeg_start_decompress(&cinfo); + while(nlines < img->height) { + int res = jpeg_read_scanlines(&cinfo, scanlines + nlines, img->height - nlines); + nlines += res; + } + jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + + free(scanlines); + return 0; +} + +static int write(struct img_pixmap *img, struct img_io *io) +{ + int i, nlines = 0; + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + struct dst_mgr dest; + struct img_pixmap tmpimg; + unsigned char **scanlines; + + img_init(&tmpimg); + + if(img->fmt != IMG_FMT_RGB24) { + if(img_copy(&tmpimg, img) == -1) { + return -1; + } + if(img_convert(&tmpimg, IMG_FMT_RGB24) == -1) { + img_destroy(&tmpimg); + return -1; + } + img = &tmpimg; + } + + if(!(scanlines = malloc(img->height * sizeof *scanlines))) { + img_destroy(&tmpimg); + return -1; + } + scanlines[0] = img->pixels; + for(i=1; iheight; i++) { + scanlines[i] = scanlines[i - 1] + img->width * img->pixelsz; + } + + cinfo.err = jpeg_std_error(&jerr); /* XXX */ + jpeg_create_compress(&cinfo); + + dest.pub.init_destination = init_destination; + dest.pub.empty_output_buffer = empty_output_buffer; + dest.pub.term_destination = term_destination; + dest.io = io; + cinfo.dest = (struct jpeg_destination_mgr*)&dest; + + cinfo.image_width = img->width; + cinfo.image_height = img->height; + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + + jpeg_set_defaults(&cinfo); + + jpeg_start_compress(&cinfo, 1); + while(nlines < img->height) { + int res = jpeg_write_scanlines(&cinfo, scanlines + nlines, img->height - nlines); + nlines += res; + } + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + + free(scanlines); + img_destroy(&tmpimg); + return 0; +} + +/* -- read source functions -- + * the following functions are adapted from jdatasrc.c in jpeglib + */ +static void init_source(j_decompress_ptr jd) +{ + struct src_mgr *src = (struct src_mgr*)jd->src; + src->start_of_file = 1; +} + +static boolean fill_input_buffer(j_decompress_ptr jd) +{ + struct src_mgr *src = (struct src_mgr*)jd->src; + size_t nbytes; + + nbytes = src->io->read(src->buffer, INPUT_BUF_SIZE, src->io->uptr); + + if(nbytes <= 0) { + if(src->start_of_file) { + return 0; + } + /* insert a fake EOI marker */ + src->buffer[0] = 0xff; + src->buffer[1] = JPEG_EOI; + nbytes = 2; + } + + src->pub.next_input_byte = src->buffer; + src->pub.bytes_in_buffer = nbytes; + src->start_of_file = 0; + return 1; +} + +static void skip_input_data(j_decompress_ptr jd, long num_bytes) +{ + struct src_mgr *src = (struct src_mgr*)jd->src; + + if(num_bytes > 0) { + while(num_bytes > (long)src->pub.bytes_in_buffer) { + num_bytes -= (long)src->pub.bytes_in_buffer; + fill_input_buffer(jd); + } + src->pub.next_input_byte += (size_t)num_bytes; + src->pub.bytes_in_buffer -= (size_t)num_bytes; + } +} + +static void term_source(j_decompress_ptr jd) +{ + /* nothing to see here, move along */ +} + + +/* -- write destination functions -- + * the following functions are adapted from jdatadst.c in jpeglib + */ +static void init_destination(j_compress_ptr jc) +{ + struct dst_mgr *dest = (struct dst_mgr*)jc->dest; + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; +} + +static boolean empty_output_buffer(j_compress_ptr jc) +{ + struct dst_mgr *dest = (struct dst_mgr*)jc->dest; + + if(dest->io->write(dest->buffer, OUTPUT_BUF_SIZE, dest->io->uptr) != OUTPUT_BUF_SIZE) { + return 0; + } + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; + return 1; +} + +static void term_destination(j_compress_ptr jc) +{ + struct dst_mgr *dest = (struct dst_mgr*)jc->dest; + size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; + + /* write any remaining data in the buffer */ + if(datacount > 0) { + dest->io->write(dest->buffer, datacount, dest->io->uptr); + } + /* XXX flush? ... */ +} diff --git a/libs/libimago/src/file_png.c b/libs/libimago/src/file_png.c new file mode 100644 index 0000000..123a3c4 --- /dev/null +++ b/libs/libimago/src/file_png.c @@ -0,0 +1,261 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ + +/* -- PNG module -- */ + +#include +#include +#include "imago2.h" +#include "ftype_module.h" + +static int check_file(struct img_io *io); +static int read_file(struct img_pixmap *img, struct img_io *io); +static int write_file(struct img_pixmap *img, struct img_io *io); + +static void read_func(png_struct *png, unsigned char *data, size_t len); +static void write_func(png_struct *png, unsigned char *data, size_t len); +static void flush_func(png_struct *png); + +static int png_type_to_fmt(int color_type, int channel_bits); +static int fmt_to_png_type(enum img_fmt fmt); + + +int img_register_png(void) +{ + static struct ftype_module mod = {".png", check_file, read_file, write_file}; + return img_register_module(&mod); +} + +static int check_file(struct img_io *io) +{ + unsigned char sig[8]; + int res; + long pos = io->seek(0, SEEK_CUR, io->uptr); + + if(io->read(sig, 8, io->uptr) < 8) { + io->seek(pos, SEEK_SET, io->uptr); + return -1; + } + + res = png_sig_cmp(sig, 0, 8) == 0 ? 0 : -1; + io->seek(pos, SEEK_SET, io->uptr); + return res; +} + +static int read_file(struct img_pixmap *img, struct img_io *io) +{ + png_struct *png; + png_info *info; + int channel_bits, color_type, ilace_type, compression, filtering, fmt; + png_uint_32 xsz, ysz; + + if(!(png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0))) { + return -1; + } + + if(!(info = png_create_info_struct(png))) { + png_destroy_read_struct(&png, 0, 0); + return -1; + } + + if(setjmp(png_jmpbuf(png))) { + png_destroy_read_struct(&png, &info, 0); + return -1; + } + + png_set_read_fn(png, io, read_func); + png_set_sig_bytes(png, 0); + png_read_png(png, info, 0, 0); + + png_get_IHDR(png, info, &xsz, &ysz, &channel_bits, &color_type, &ilace_type, + &compression, &filtering); + if((fmt = png_type_to_fmt(color_type, channel_bits)) == -1) { + png_destroy_read_struct(&png, &info, 0); + return -1; + } + + if(img_set_pixels(img, xsz, ysz, fmt, 0) == -1) { + png_destroy_read_struct(&png, &info, 0); + return -1; + } + + + if(channel_bits == 8) { + unsigned int i; + unsigned char **lineptr = (unsigned char**)png_get_rows(png, info); + unsigned char *dest = img->pixels; + + for(i=0; ipixelsz); + dest += xsz * img->pixelsz; + } + } else { + unsigned int i, j, num_elem; + unsigned char **lineptr = (unsigned char**)png_get_rows(png, info); + float *dest = img->pixels; + + num_elem = img->pixelsz / sizeof(float); + for(i=0; ifmt); + png_set_IHDR(png, info, img->width, img->height, 8, coltype, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + png_set_text(png, info, &txt, 1); + + if(!(rows = malloc(img->height * sizeof *rows))) { + png_destroy_write_struct(&png, &info); + img_destroy(&tmpimg); + return -1; + } + + pixptr = img->pixels; + for(i=0; iheight; i++) { + rows[i] = pixptr; + pixptr += img->width * img->pixelsz; + } + png_set_rows(png, info, rows); + + png_write_png(png, info, 0, 0); + png_write_end(png, info); + png_destroy_write_struct(&png, &info); + + free(rows); + + img_destroy(&tmpimg); + return 0; +} + +static void read_func(png_struct *png, unsigned char *data, size_t len) +{ + struct img_io *io = (struct img_io*)png_get_io_ptr(png); + + if(io->read(data, len, io->uptr) == -1) { + longjmp(png_jmpbuf(png), 1); + } +} + +static void write_func(png_struct *png, unsigned char *data, size_t len) +{ + struct img_io *io = (struct img_io*)png_get_io_ptr(png); + + if(io->write(data, len, io->uptr) == -1) { + longjmp(png_jmpbuf(png), 1); + } +} + +static void flush_func(png_struct *png) +{ + /* XXX does it matter that we can't flush? */ +} + +static int png_type_to_fmt(int color_type, int channel_bits) +{ + /* only 8 and 16 bits per channel ar supported at the moment */ + if(channel_bits != 8 && channel_bits != 16) { + return -1; + } + + switch(color_type) { + case PNG_COLOR_TYPE_RGB: + return channel_bits == 16 ? IMG_FMT_RGBF : IMG_FMT_RGB24; + + case PNG_COLOR_TYPE_RGB_ALPHA: + return channel_bits == 16 ? IMG_FMT_RGBAF : IMG_FMT_RGBA32; + + case PNG_COLOR_TYPE_GRAY: + return channel_bits == 16 ? IMG_FMT_GREYF : IMG_FMT_GREY8; + + default: + break; + } + return -1; +} + +static int fmt_to_png_type(enum img_fmt fmt) +{ + switch(fmt) { + case IMG_FMT_GREY8: + return PNG_COLOR_TYPE_GRAY; + + case IMG_FMT_RGB24: + return PNG_COLOR_TYPE_RGB; + + case IMG_FMT_RGBA32: + return PNG_COLOR_TYPE_RGBA; + + default: + break; + } + return -1; +} diff --git a/libs/libimago/src/file_ppm.c b/libs/libimago/src/file_ppm.c new file mode 100644 index 0000000..ffe1e46 --- /dev/null +++ b/libs/libimago/src/file_ppm.c @@ -0,0 +1,153 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ + +/* -- Portable Pixmap (PPM) module -- */ + +#include +#include "imago2.h" +#include "ftype_module.h" + +static int check(struct img_io *io); +static int read(struct img_pixmap *img, struct img_io *io); +static int write(struct img_pixmap *img, struct img_io *io); + +int img_register_ppm(void) +{ + static struct ftype_module mod = {".ppm", check, read, write}; + return img_register_module(&mod); +} + + +static int check(struct img_io *io) +{ + char id[2]; + int res = -1; + long pos = io->seek(0, SEEK_CUR, io->uptr); + + if(io->read(id, 2, io->uptr) < 2) { + io->seek(pos, SEEK_SET, io->uptr); + return -1; + } + + if(id[0] == 'P' && (id[1] == '6' || id[1] == '3')) { + res = 0; + } + io->seek(pos, SEEK_SET, io->uptr); + return res; +} + +static int iofgetc(struct img_io *io) +{ + char c; + return io->read(&c, 1, io->uptr) < 1 ? -1 : c; +} + +static char *iofgets(char *buf, int size, struct img_io *io) +{ + int c; + char *ptr = buf; + + while(--size > 0 && (c = iofgetc(io)) != -1) { + *ptr++ = c; + if(c == '\n') break; + } + *ptr = 0; + + return ptr == buf ? 0 : buf; +} + +/* TODO: implement P3 reading */ +static int read(struct img_pixmap *img, struct img_io *io) +{ + char buf[256]; + int xsz, ysz, maxval, got_hdrlines = 1; + + if(!iofgets(buf, sizeof buf, io)) { + return -1; + } + if(!(buf[0] == 'P' && (buf[1] == '6' || buf[1] == '3'))) { + return -1; + } + + while(got_hdrlines < 3 && iofgets(buf, sizeof buf, io)) { + if(buf[0] == '#') continue; + + switch(got_hdrlines) { + case 1: + if(sscanf(buf, "%d %d\n", &xsz, &ysz) < 2) { + return -1; + } + break; + + case 2: + if(sscanf(buf, "%d\n", &maxval) < 1) { + return -1; + } + default: + break; + } + got_hdrlines++; + } + + if(xsz < 1 || ysz < 1 || maxval != 255) { + return -1; + } + + if(img_set_pixels(img, xsz, ysz, IMG_FMT_RGB24, 0) == -1) { + return -1; + } + + if(io->read(img->pixels, xsz * ysz * 3, io->uptr) < (unsigned int)(xsz * ysz * 3)) { + return -1; + } + return 0; +} + +static int write(struct img_pixmap *img, struct img_io *io) +{ + int sz; + char buf[256]; + struct img_pixmap tmpimg; + + img_init(&tmpimg); + + if(img->fmt != IMG_FMT_RGB24) { + if(img_copy(&tmpimg, img) == -1) { + return -1; + } + if(img_convert(&tmpimg, IMG_FMT_RGB24) == -1) { + return -1; + } + img = &tmpimg; + } + + sprintf(buf, "P6\n#written by libimago2\n%d %d\n255\n", img->width, img->height); + if(io->write(buf, strlen(buf), io->uptr) < strlen(buf)) { + img_destroy(&tmpimg); + return -1; + } + + sz = img->width * img->height * 3; + if(io->write(img->pixels, sz, io->uptr) < (unsigned int)sz) { + img_destroy(&tmpimg); + return -1; + } + + img_destroy(&tmpimg); + return 0; +} diff --git a/libs/libimago/src/file_rgbe.c b/libs/libimago/src/file_rgbe.c new file mode 100644 index 0000000..16f8efa --- /dev/null +++ b/libs/libimago/src/file_rgbe.c @@ -0,0 +1,501 @@ +/* This file contains code to read and write four byte rgbe file format + * developed by Greg Ward. It handles the conversions between rgbe and + * pixels consisting of floats. The data is assumed to be an array of floats. + * By default there are three floats per pixel in the order red, green, blue. + * (RGBE_DATA_??? values control this.) + * + * written by Bruce Walter (bjw@graphics.cornell.edu) 5/26/95 + * based on code written by Greg Ward + * minor modifications by John Tsiombikas (nuclear@member.fsf.org) apr.9 2007 + */ + +#include +#include +#include +#include +#include +#include +#include "imago2.h" +#include "ftype_module.h" + + +typedef struct { + int valid; /* indicate which fields are valid */ + char programtype[16]; /* listed at beginning of file to identify it + * after "#?". defaults to "RGBE" */ + float gamma; /* image has already been gamma corrected with + * given gamma. defaults to 1.0 (no correction) */ + float exposure; /* a value of 1.0 in an image corresponds to + * watts/steradian/m^2. + * defaults to 1.0 */ +} rgbe_header_info; + + +static int check(struct img_io *io); +static int read(struct img_pixmap *img, struct img_io *io); +static int write(struct img_pixmap *img, struct img_io *io); + +static int rgbe_read_header(struct img_io *io, int *width, int *height, rgbe_header_info * info); +static int rgbe_read_pixels_rle(struct img_io *io, float *data, int scanline_width, int num_scanlines); + + +int img_register_rgbe(void) +{ + static struct ftype_module mod = {".rgbe", check, read, write}; + return img_register_module(&mod); +} + + +static int check(struct img_io *io) +{ + int xsz, ysz, res; + long pos = io->seek(0, SEEK_CUR, io->uptr); + + rgbe_header_info hdr; + res = rgbe_read_header(io, &xsz, &ysz, &hdr); + + io->seek(pos, SEEK_SET, io->uptr); + return res; +} + +static int read(struct img_pixmap *img, struct img_io *io) +{ + int xsz, ysz; + rgbe_header_info hdr; + + if(rgbe_read_header(io, &xsz, &ysz, &hdr) == -1) { + return -1; + } + + if(img_set_pixels(img, xsz, ysz, IMG_FMT_RGBF, 0) == -1) { + return -1; + } + if(rgbe_read_pixels_rle(io, img->pixels, xsz, ysz) == -1) { + return -1; + } + return 0; +} + +static int write(struct img_pixmap *img, struct img_io *io) +{ + return -1; /* TODO */ +} + + +static int iofgetc(struct img_io *io) +{ + char c; + return io->read(&c, 1, io->uptr) < 1 ? -1 : c; +} + +static char *iofgets(char *buf, int size, struct img_io *io) +{ + int c; + char *ptr = buf; + + while(--size > 0 && (c = iofgetc(io)) != -1) { + *ptr++ = c; + if(c == '\n') break; + } + *ptr = 0; + + return ptr == buf ? 0 : buf; +} + + +/* flags indicating which fields in an rgbe_header_info are valid */ +#define RGBE_VALID_PROGRAMTYPE 0x01 +#define RGBE_VALID_GAMMA 0x02 +#define RGBE_VALID_EXPOSURE 0x04 + +/* return codes for rgbe routines */ +#define RGBE_RETURN_SUCCESS 0 +#define RGBE_RETURN_FAILURE -1 + + +#if defined(__cplusplus) || defined(GNUC) || __STDC_VERSION >= 199901L +#define INLINE inline +#else +#define INLINE +#endif + +/* offsets to red, green, and blue components in a data (float) pixel */ +#define RGBE_DATA_RED 0 +#define RGBE_DATA_GREEN 1 +#define RGBE_DATA_BLUE 2 + +/* number of floats per pixel */ +#define RGBE_DATA_SIZE 3 + +enum rgbe_error_codes { + rgbe_read_error, + rgbe_write_error, + rgbe_format_error, + rgbe_memory_error +}; + + +/* default error routine. change this to change error handling */ +static int rgbe_error(int rgbe_error_code, char *msg) +{ + switch (rgbe_error_code) { + case rgbe_read_error: + fprintf(stderr, "RGBE read error: %s\n", strerror(errno)); + break; + + case rgbe_write_error: + fprintf(stderr, "RGBE write error: %s\n", strerror(errno)); + break; + + case rgbe_format_error: + fprintf(stderr, "RGBE bad file format: %s\n", msg); + break; + + default: + case rgbe_memory_error: + fprintf(stderr, "RGBE error: %s\n", msg); + } + return RGBE_RETURN_FAILURE; +} + +/* standard conversion from float pixels to rgbe pixels */ +/*static INLINE void float2rgbe(unsigned char rgbe[4], float red, float green, float blue) +{ + float v; + int e; + + v = red; + if(green > v) + v = green; + if(blue > v) + v = blue; + if(v < 1e-32) { + rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; + } else { + v = frexp(v, &e) * 256.0 / v; + rgbe[0] = (unsigned char)(red * v); + rgbe[1] = (unsigned char)(green * v); + rgbe[2] = (unsigned char)(blue * v); + rgbe[3] = (unsigned char)(e + 128); + } +}*/ + +/* standard conversion from rgbe to float pixels */ +/* note: Ward uses ldexp(col+0.5,exp-(128+8)). However we wanted pixels */ +/* in the range [0,1] to map back into the range [0,1]. */ +static INLINE void rgbe2float(float *red, float *green, float *blue, unsigned char rgbe[4]) +{ + float f; + + if(rgbe[3]) { /*nonzero pixel */ + f = ldexp(1.0, rgbe[3] - (int)(128 + 8)); + *red = rgbe[0] * f; + *green = rgbe[1] * f; + *blue = rgbe[2] * f; + } else + *red = *green = *blue = 0.0; +} + +#if 0 +/* default minimal header. modify if you want more information in header */ +static int rgbe_write_header(FILE * fp, int width, int height, rgbe_header_info * info) +{ + char *programtype = "RGBE"; + + if(info && (info->valid & RGBE_VALID_PROGRAMTYPE)) + programtype = info->programtype; + if(fprintf(fp, "#?%s\n", programtype) < 0) + return rgbe_error(rgbe_write_error, NULL); + /* The #? is to identify file type, the programtype is optional. */ + if(info && (info->valid & RGBE_VALID_GAMMA)) { + if(fprintf(fp, "GAMMA=%g\n", info->gamma) < 0) + return rgbe_error(rgbe_write_error, NULL); + } + if(info && (info->valid & RGBE_VALID_EXPOSURE)) { + if(fprintf(fp, "EXPOSURE=%g\n", info->exposure) < 0) + return rgbe_error(rgbe_write_error, NULL); + } + if(fprintf(fp, "FORMAT=32-bit_rle_rgbe\n\n") < 0) + return rgbe_error(rgbe_write_error, NULL); + if(fprintf(fp, "-Y %d +X %d\n", height, width) < 0) + return rgbe_error(rgbe_write_error, NULL); + return RGBE_RETURN_SUCCESS; +} +#endif + +/* minimal header reading. modify if you want to parse more information */ +static int rgbe_read_header(struct img_io *io, int *width, int *height, rgbe_header_info * info) +{ + char buf[128]; + float tempf; + int i; + + if(info) { + info->valid = 0; + info->programtype[0] = 0; + info->gamma = info->exposure = 1.0; + } + if(iofgets(buf, sizeof(buf) / sizeof(buf[0]), io) == NULL) + return RGBE_RETURN_FAILURE;/*rgbe_error(rgbe_read_error, NULL);*/ + if((buf[0] != '#') || (buf[1] != '?')) { + /* if you want to require the magic token then uncomment the next line */ + /*return rgbe_error(rgbe_format_error,"bad initial token"); */ + } else if(info) { + info->valid |= RGBE_VALID_PROGRAMTYPE; + for(i = 0; i < sizeof(info->programtype) - 1; i++) { + if((buf[i + 2] == 0) || isspace(buf[i + 2])) + break; + info->programtype[i] = buf[i + 2]; + } + info->programtype[i] = 0; + if(iofgets(buf, sizeof(buf) / sizeof(buf[0]), io) == 0) + return rgbe_error(rgbe_read_error, NULL); + } + for(;;) { + if((buf[0] == 0) || (buf[0] == '\n')) + return RGBE_RETURN_FAILURE;/*rgbe_error(rgbe_format_error, "no FORMAT specifier found");*/ + else if(strcmp(buf, "FORMAT=32-bit_rle_rgbe\n") == 0) + break; /* format found so break out of loop */ + else if(info && (sscanf(buf, "GAMMA=%g", &tempf) == 1)) { + info->gamma = tempf; + info->valid |= RGBE_VALID_GAMMA; + } else if(info && (sscanf(buf, "EXPOSURE=%g", &tempf) == 1)) { + info->exposure = tempf; + info->valid |= RGBE_VALID_EXPOSURE; + } + if(iofgets(buf, sizeof(buf) / sizeof(buf[0]), io) == 0) + return RGBE_RETURN_FAILURE;/*rgbe_error(rgbe_read_error, NULL);*/ + } + if(iofgets(buf, sizeof(buf) / sizeof(buf[0]), io) == 0) + return RGBE_RETURN_FAILURE;/*rgbe_error(rgbe_read_error, NULL);*/ + if(strcmp(buf, "\n") != 0) + return RGBE_RETURN_FAILURE;/*rgbe_error(rgbe_format_error, "missing blank line after FORMAT specifier");*/ + if(iofgets(buf, sizeof(buf) / sizeof(buf[0]), io) == 0) + return RGBE_RETURN_FAILURE;/*rgbe_error(rgbe_read_error, NULL);*/ + if(sscanf(buf, "-Y %d +X %d", height, width) < 2) + return RGBE_RETURN_FAILURE;/*rgbe_error(rgbe_format_error, "missing image size specifier");*/ + return RGBE_RETURN_SUCCESS; +} + +#if 0 +/* simple write routine that does not use run length encoding */ + +/* These routines can be made faster by allocating a larger buffer and + fread-ing and fwrite-ing the data in larger chunks */ +static int rgbe_write_pixels(FILE * fp, float *data, int numpixels) +{ + unsigned char rgbe[4]; + + while(numpixels-- > 0) { + float2rgbe(rgbe, data[RGBE_DATA_RED], data[RGBE_DATA_GREEN], data[RGBE_DATA_BLUE]); + data += RGBE_DATA_SIZE; + if(fwrite(rgbe, sizeof(rgbe), 1, fp) < 1) + return rgbe_error(rgbe_write_error, NULL); + } + return RGBE_RETURN_SUCCESS; +} +#endif + +/* simple read routine. will not correctly handle run length encoding */ +static int rgbe_read_pixels(struct img_io *io, float *data, int numpixels) +{ + unsigned char rgbe[4]; + + while(numpixels-- > 0) { + if(io->read(rgbe, sizeof(rgbe), io->uptr) < 1) + return rgbe_error(rgbe_read_error, NULL); + rgbe2float(&data[RGBE_DATA_RED], &data[RGBE_DATA_GREEN], &data[RGBE_DATA_BLUE], rgbe); + data += RGBE_DATA_SIZE; + } + return RGBE_RETURN_SUCCESS; +} + +#if 0 +/* The code below is only needed for the run-length encoded files. */ + +/* Run length encoding adds considerable complexity but does */ + +/* save some space. For each scanline, each channel (r,g,b,e) is */ + +/* encoded separately for better compression. */ + +static int rgbe_write_bytes_rle(struct img_io *io, unsigned char *data, int numbytes) +{ +#define MINRUNLENGTH 4 + int cur, beg_run, run_count, old_run_count, nonrun_count; + unsigned char buf[2]; + + cur = 0; + while(cur < numbytes) { + beg_run = cur; + /* find next run of length at least 4 if one exists */ + run_count = old_run_count = 0; + while((run_count < MINRUNLENGTH) && (beg_run < numbytes)) { + beg_run += run_count; + old_run_count = run_count; + run_count = 1; + while((beg_run + run_count < numbytes) && (run_count < 127) + && (data[beg_run] == data[beg_run + run_count])) + run_count++; + } + /* if data before next big run is a short run then write it as such */ + if((old_run_count > 1) && (old_run_count == beg_run - cur)) { + buf[0] = 128 + old_run_count; /*write short run */ + buf[1] = data[cur]; + if(fwrite(buf, sizeof(buf[0]) * 2, 1, fp) < 1) + return rgbe_error(rgbe_write_error, NULL); + cur = beg_run; + } + /* write out bytes until we reach the start of the next run */ + while(cur < beg_run) { + nonrun_count = beg_run - cur; + if(nonrun_count > 128) + nonrun_count = 128; + buf[0] = nonrun_count; + if(fwrite(buf, sizeof(buf[0]), 1, fp) < 1) + return rgbe_error(rgbe_write_error, NULL); + if(fwrite(&data[cur], sizeof(data[0]) * nonrun_count, 1, fp) < 1) + return rgbe_error(rgbe_write_error, NULL); + cur += nonrun_count; + } + /* write out next run if one was found */ + if(run_count >= MINRUNLENGTH) { + buf[0] = 128 + run_count; + buf[1] = data[beg_run]; + if(fwrite(buf, sizeof(buf[0]) * 2, 1, fp) < 1) + return rgbe_error(rgbe_write_error, NULL); + cur += run_count; + } + } + return RGBE_RETURN_SUCCESS; +#undef MINRUNLENGTH +} + +static int rgbe_write_pixels_rle(struct img_io *io, float *data, int scanline_width, int num_scanlines) +{ + unsigned char rgbe[4]; + unsigned char *buffer; + int i, err; + + if((scanline_width < 8) || (scanline_width > 0x7fff)) + /* run length encoding is not allowed so write flat */ + return rgbe_write_pixels(io, data, scanline_width * num_scanlines); + buffer = (unsigned char *)malloc(sizeof(unsigned char) * 4 * scanline_width); + if(buffer == NULL) + /* no buffer space so write flat */ + return rgbe_write_pixels(fp, data, scanline_width * num_scanlines); + while(num_scanlines-- > 0) { + rgbe[0] = 2; + rgbe[1] = 2; + rgbe[2] = scanline_width >> 8; + rgbe[3] = scanline_width & 0xFF; + if(fwrite(rgbe, sizeof(rgbe), 1, fp) < 1) { + free(buffer); + return rgbe_error(rgbe_write_error, NULL); + } + for(i = 0; i < scanline_width; i++) { + float2rgbe(rgbe, data[RGBE_DATA_RED], data[RGBE_DATA_GREEN], data[RGBE_DATA_BLUE]); + buffer[i] = rgbe[0]; + buffer[i + scanline_width] = rgbe[1]; + buffer[i + 2 * scanline_width] = rgbe[2]; + buffer[i + 3 * scanline_width] = rgbe[3]; + data += RGBE_DATA_SIZE; + } + /* write out each of the four channels separately run length encoded */ + /* first red, then green, then blue, then exponent */ + for(i = 0; i < 4; i++) { + if((err = rgbe_write_bytes_rle(fp, &buffer[i * scanline_width], + scanline_width)) != RGBE_RETURN_SUCCESS) { + free(buffer); + return err; + } + } + } + free(buffer); + return RGBE_RETURN_SUCCESS; +} +#endif + +static int rgbe_read_pixels_rle(struct img_io *io, float *data, int scanline_width, int num_scanlines) +{ + unsigned char rgbe[4], *scanline_buffer, *ptr, *ptr_end; + int i, count; + unsigned char buf[2]; + + if((scanline_width < 8) || (scanline_width > 0x7fff)) + /* run length encoding is not allowed so read flat */ + return rgbe_read_pixels(io, data, scanline_width * num_scanlines); + scanline_buffer = NULL; + /* read in each successive scanline */ + while(num_scanlines > 0) { + if(io->read(rgbe, sizeof(rgbe), io->uptr) < 1) { + free(scanline_buffer); + return rgbe_error(rgbe_read_error, NULL); + } + if((rgbe[0] != 2) || (rgbe[1] != 2) || (rgbe[2] & 0x80)) { + /* this file is not run length encoded */ + rgbe2float(&data[0], &data[1], &data[2], rgbe); + data += RGBE_DATA_SIZE; + free(scanline_buffer); + return rgbe_read_pixels(io, data, scanline_width * num_scanlines - 1); + } + if((((int)rgbe[2]) << 8 | rgbe[3]) != scanline_width) { + free(scanline_buffer); + return rgbe_error(rgbe_format_error, "wrong scanline width"); + } + if(scanline_buffer == NULL) + scanline_buffer = (unsigned char *) + malloc(sizeof(unsigned char) * 4 * scanline_width); + if(scanline_buffer == NULL) + return rgbe_error(rgbe_memory_error, "unable to allocate buffer space"); + + ptr = &scanline_buffer[0]; + /* read each of the four channels for the scanline into the buffer */ + for(i = 0; i < 4; i++) { + ptr_end = &scanline_buffer[(i + 1) * scanline_width]; + while(ptr < ptr_end) { + if(io->read(buf, sizeof(buf[0]) * 2, io->uptr) < 1) { + free(scanline_buffer); + return rgbe_error(rgbe_read_error, NULL); + } + if(buf[0] > 128) { + /* a run of the same value */ + count = buf[0] - 128; + if((count == 0) || (count > ptr_end - ptr)) { + free(scanline_buffer); + return rgbe_error(rgbe_format_error, "bad scanline data"); + } + while(count-- > 0) + *ptr++ = buf[1]; + } else { + /* a non-run */ + count = buf[0]; + if((count == 0) || (count > ptr_end - ptr)) { + free(scanline_buffer); + return rgbe_error(rgbe_format_error, "bad scanline data"); + } + *ptr++ = buf[1]; + if(--count > 0) { + if(io->read(ptr, sizeof(*ptr) * count, io->uptr) < 1) { + free(scanline_buffer); + return rgbe_error(rgbe_read_error, NULL); + } + ptr += count; + } + } + } + } + /* now convert data from buffer into floats */ + for(i = 0; i < scanline_width; i++) { + rgbe[0] = scanline_buffer[i]; + rgbe[1] = scanline_buffer[i + scanline_width]; + rgbe[2] = scanline_buffer[i + 2 * scanline_width]; + rgbe[3] = scanline_buffer[i + 3 * scanline_width]; + rgbe2float(&data[RGBE_DATA_RED], &data[RGBE_DATA_GREEN], &data[RGBE_DATA_BLUE], rgbe); + data += RGBE_DATA_SIZE; + } + num_scanlines--; + } + free(scanline_buffer); + return RGBE_RETURN_SUCCESS; +} diff --git a/libs/libimago/src/ftype_module.c b/libs/libimago/src/ftype_module.c new file mode 100644 index 0000000..a3d3b04 --- /dev/null +++ b/libs/libimago/src/ftype_module.c @@ -0,0 +1,118 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ + +#include +#include +#include "ftype_module.h" + +static struct list_node { + struct ftype_module *module; + struct list_node *next; +} *modules; + +/* defined in modules.c which is generated by configure */ +void img_modules_init(); + +static int done_init; + +int img_register_module(struct ftype_module *mod) +{ + struct list_node *node; + + if(!(node = malloc(sizeof *node))) { + return -1; + } + + node->module = mod; + node->next = modules; + modules = node; + return 0; +} + +struct ftype_module *img_find_format_module(struct img_io *io) +{ + struct list_node *node; + + if(!done_init) { + img_modules_init(); + done_init = 1; + } + + node = modules; + while(node) { + if(node->module->check(io) != -1) { + return node->module; + } + node = node->next; + } + return 0; +} + +struct ftype_module *img_guess_format(const char *fname) +{ + struct list_node *node; + char *suffix; + int suffix_len; + + if(!done_init) { + img_modules_init(); + done_init = 1; + } + + if(!(suffix = strrchr(fname, '.'))) { + return 0; /* no suffix, can't guess ... */ + } + suffix_len = (int)strlen(suffix); + + node = modules; + while(node) { + char *suflist = node->module->suffix; + char *start, *end; + + while(*suflist) { + if(!(start = strstr(suflist, suffix))) { + break; + } + end = start + suffix_len; + + if(*end == ':' || *end == 0) { + return node->module; /* found it */ + } + suflist = end; + } + + node = node->next; + } + return 0; +} + +struct ftype_module *img_get_module(int idx) +{ + struct list_node *node; + + if(!done_init) { + img_modules_init(); + done_init = 1; + } + + node = modules; + while(node && idx--) { + node = node->next; + } + return node->module; +} diff --git a/libs/libimago/src/ftype_module.h b/libs/libimago/src/ftype_module.h new file mode 100644 index 0000000..7c3bd54 --- /dev/null +++ b/libs/libimago/src/ftype_module.h @@ -0,0 +1,39 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ + +#ifndef FTYPE_MODULE_H_ +#define FTYPE_MODULE_H_ + +#include "imago2.h" + +struct ftype_module { + char *suffix; /* used for format autodetection during saving only */ + + int (*check)(struct img_io *io); + int (*read)(struct img_pixmap *img, struct img_io *io); + int (*write)(struct img_pixmap *img, struct img_io *io); +}; + +int img_register_module(struct ftype_module *mod); + +struct ftype_module *img_find_format_module(struct img_io *io); +struct ftype_module *img_guess_format(const char *fname); +struct ftype_module *img_get_module(int idx); + + +#endif /* FTYPE_MODULE_H_ */ diff --git a/libs/libimago/src/imago2.c b/libs/libimago/src/imago2.c new file mode 100644 index 0000000..b910693 --- /dev/null +++ b/libs/libimago/src/imago2.c @@ -0,0 +1,449 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include "imago2.h" +#include "ftype_module.h" + +static int pixel_size(enum img_fmt fmt); +static size_t def_read(void *buf, size_t bytes, void *uptr); +static size_t def_write(void *buf, size_t bytes, void *uptr); +static long def_seek(long offset, int whence, void *uptr); + + +void img_init(struct img_pixmap *img) +{ + img->pixels = 0; + img->width = img->height = 0; + img->fmt = IMG_FMT_RGBA32; + img->pixelsz = pixel_size(img->fmt); + img->name = 0; +} + + +void img_destroy(struct img_pixmap *img) +{ + free(img->pixels); + img->pixels = 0; /* just in case... */ + img->width = img->height = 0xbadbeef; + free(img->name); +} + +struct img_pixmap *img_create(void) +{ + struct img_pixmap *p; + + if(!(p = malloc(sizeof *p))) { + return 0; + } + img_init(p); + return p; +} + +void img_free(struct img_pixmap *img) +{ + img_destroy(img); + free(img); +} + +int img_set_name(struct img_pixmap *img, const char *name) +{ + char *tmp; + + if(!(tmp = malloc(strlen(name) + 1))) { + return -1; + } + strcpy(tmp, name); + img->name = tmp; + return 0; +} + +int img_set_format(struct img_pixmap *img, enum img_fmt fmt) +{ + if(img->pixels) { + return img_convert(img, fmt); + } + img->fmt = fmt; + return 0; +} + +int img_copy(struct img_pixmap *dest, struct img_pixmap *src) +{ + return img_set_pixels(dest, src->width, src->height, src->fmt, src->pixels); +} + +int img_set_pixels(struct img_pixmap *img, int w, int h, enum img_fmt fmt, void *pix) +{ + void *newpix; + int pixsz = pixel_size(fmt); + + if(!(newpix = malloc(w * h * pixsz))) { + return -1; + } + + if(pix) { + memcpy(newpix, pix, w * h * pixsz); + } else { + memset(newpix, 0, w * h * pixsz); + } + + free(img->pixels); + img->pixels = newpix; + img->width = w; + img->height = h; + img->pixelsz = pixsz; + img->fmt = fmt; + return 0; +} + +void *img_load_pixels(const char *fname, int *xsz, int *ysz, enum img_fmt fmt) +{ + struct img_pixmap img; + + img_init(&img); + + if(img_load(&img, fname) == -1) { + return 0; + } + if(img.fmt != fmt) { + if(img_convert(&img, fmt) == -1) { + img_destroy(&img); + return 0; + } + } + + *xsz = img.width; + *ysz = img.height; + return img.pixels; +} + +int img_save_pixels(const char *fname, void *pix, int xsz, int ysz, enum img_fmt fmt) +{ + struct img_pixmap img; + + img_init(&img); + img.fmt = fmt; + img.name = (char*)fname; + img.width = xsz; + img.height = ysz; + img.pixels = pix; + + return img_save(&img, fname); +} + +void img_free_pixels(void *pix) +{ + free(pix); +} + +int img_load(struct img_pixmap *img, const char *fname) +{ + int res; + FILE *fp; + + if(!(fp = fopen(fname, "rb"))) { + return -1; + } + res = img_read_file(img, fp); + fclose(fp); + return res; +} + +/* TODO implement filetype selection */ +int img_save(struct img_pixmap *img, const char *fname) +{ + int res; + FILE *fp; + + img_set_name(img, fname); + + if(!(fp = fopen(fname, "wb"))) { + return -1; + } + res = img_write_file(img, fp); + fclose(fp); + return res; +} + +int img_read_file(struct img_pixmap *img, FILE *fp) +{ + struct img_io io = {0, def_read, def_write, def_seek}; + + io.uptr = fp; + return img_read(img, &io); +} + +int img_write_file(struct img_pixmap *img, FILE *fp) +{ + struct img_io io = {0, def_read, def_write, def_seek}; + + io.uptr = fp; + return img_write(img, &io); +} + +int img_read(struct img_pixmap *img, struct img_io *io) +{ + struct ftype_module *mod; + + if((mod = img_find_format_module(io))) { + return mod->read(img, io); + } + return -1; +} + +int img_write(struct img_pixmap *img, struct img_io *io) +{ + struct ftype_module *mod; + + if(!img->name || !(mod = img_guess_format(img->name))) { + /* TODO throw some sort of warning? */ + /* TODO implement some sort of module priority or let the user specify? */ + if(!(mod = img_get_module(0))) { + return -1; + } + } + + return mod->write(img, io); +} + +int img_to_float(struct img_pixmap *img) +{ + enum img_fmt targ_fmt; + + switch(img->fmt) { + case IMG_FMT_GREY8: + targ_fmt = IMG_FMT_GREYF; + break; + + case IMG_FMT_RGB24: + targ_fmt = IMG_FMT_RGBF; + break; + + case IMG_FMT_RGBA32: + targ_fmt = IMG_FMT_RGBAF; + break; + + default: + return 0; /* already float */ + } + + return img_convert(img, targ_fmt); +} + +int img_to_integer(struct img_pixmap *img) +{ + enum img_fmt targ_fmt; + + switch(img->fmt) { + case IMG_FMT_GREYF: + targ_fmt = IMG_FMT_GREY8; + break; + + case IMG_FMT_RGBF: + targ_fmt = IMG_FMT_RGB24; + break; + + case IMG_FMT_RGBAF: + targ_fmt = IMG_FMT_RGBA32; + break; + + default: + return 0; /* already integer */ + } + + return img_convert(img, targ_fmt); +} + +int img_is_float(struct img_pixmap *img) +{ + return img->fmt >= IMG_FMT_GREYF && img->fmt <= IMG_FMT_RGBAF; +} + +int img_has_alpha(struct img_pixmap *img) +{ + if(img->fmt == IMG_FMT_RGBA32 || img->fmt == IMG_FMT_RGBAF) { + return 1; + } + return 0; +} + + +void img_setpixel(struct img_pixmap *img, int x, int y, void *pixel) +{ + char *dest = (char*)img->pixels + (y * img->width + x) * img->pixelsz; + memcpy(dest, pixel, img->pixelsz); +} + +void img_getpixel(struct img_pixmap *img, int x, int y, void *pixel) +{ + char *dest = (char*)img->pixels + (y * img->width + x) * img->pixelsz; + memcpy(pixel, dest, img->pixelsz); +} + +void img_setpixel1i(struct img_pixmap *img, int x, int y, int pix) +{ + img_setpixel4i(img, x, y, pix, pix, pix, pix); +} + +void img_setpixel1f(struct img_pixmap *img, int x, int y, float pix) +{ + img_setpixel4f(img, x, y, pix, pix, pix, pix); +} + +void img_setpixel4i(struct img_pixmap *img, int x, int y, int r, int g, int b, int a) +{ + if(img_is_float(img)) { + img_setpixel4f(img, x, y, r / 255.0, g / 255.0, b / 255.0, a / 255.0); + } else { + unsigned char pixel[4]; + pixel[0] = r; + pixel[1] = g; + pixel[2] = b; + pixel[3] = a; + + img_setpixel(img, x, y, pixel); + } +} + +void img_setpixel4f(struct img_pixmap *img, int x, int y, float r, float g, float b, float a) +{ + if(img_is_float(img)) { + float pixel[4]; + pixel[0] = r; + pixel[1] = g; + pixel[2] = b; + pixel[3] = a; + + img_setpixel(img, x, y, pixel); + } else { + img_setpixel4i(img, x, y, (int)(r * 255.0), (int)(g * 255.0), (int)(b * 255.0), (int)(a * 255.0)); + } +} + +void img_getpixel1i(struct img_pixmap *img, int x, int y, int *pix) +{ + int junk[3]; + img_getpixel4i(img, x, y, pix, junk, junk + 1, junk + 2); +} + +void img_getpixel1f(struct img_pixmap *img, int x, int y, float *pix) +{ + float junk[3]; + img_getpixel4f(img, x, y, pix, junk, junk + 1, junk + 2); +} + +void img_getpixel4i(struct img_pixmap *img, int x, int y, int *r, int *g, int *b, int *a) +{ + if(img_is_float(img)) { + float pixel[4] = {0, 0, 0, 0}; + img_getpixel(img, x, y, pixel); + *r = pixel[0] * 255.0; + *g = pixel[1] * 255.0; + *b = pixel[2] * 255.0; + *a = pixel[3] * 255.0; + } else { + unsigned char pixel[4]; + img_getpixel(img, x, y, pixel); + *r = pixel[0]; + *g = pixel[1]; + *b = pixel[2]; + *a = pixel[3]; + } +} + +void img_getpixel4f(struct img_pixmap *img, int x, int y, float *r, float *g, float *b, float *a) +{ + if(img_is_float(img)) { + float pixel[4] = {0, 0, 0, 0}; + img_getpixel(img, x, y, pixel); + *r = pixel[0]; + *g = pixel[1]; + *b = pixel[2]; + *a = pixel[3]; + } else { + unsigned char pixel[4]; + img_getpixel(img, x, y, pixel); + *r = pixel[0] / 255.0; + *g = pixel[1] / 255.0; + *b = pixel[2] / 255.0; + *a = pixel[3] / 255.0; + } +} + +void img_io_set_user_data(struct img_io *io, void *uptr) +{ + io->uptr = uptr; +} + +void img_io_set_read_func(struct img_io *io, size_t (*read)(void*, size_t, void*)) +{ + io->read = read; +} + +void img_io_set_write_func(struct img_io *io, size_t (*write)(void*, size_t, void*)) +{ + io->write = write; +} + +void img_io_set_seek_func(struct img_io *io, long (*seek)(long, int, void*)) +{ + io->seek = seek; +} + + +static int pixel_size(enum img_fmt fmt) +{ + switch(fmt) { + case IMG_FMT_GREY8: + return 1; + case IMG_FMT_RGB24: + return 3; + case IMG_FMT_RGBA32: + return 4; + case IMG_FMT_GREYF: + return sizeof(float); + case IMG_FMT_RGBF: + return 3 * sizeof(float); + case IMG_FMT_RGBAF: + return 4 * sizeof(float); + default: + break; + } + return 0; +} + +static size_t def_read(void *buf, size_t bytes, void *uptr) +{ + return uptr ? fread(buf, 1, bytes, uptr) : 0; +} + +static size_t def_write(void *buf, size_t bytes, void *uptr) +{ + return uptr ? fwrite(buf, 1, bytes, uptr) : 0; +} + +static long def_seek(long offset, int whence, void *uptr) +{ + if(!uptr || fseek(uptr, offset, whence) == -1) { + return -1; + } + return ftell(uptr); +} + diff --git a/libs/libimago/src/imago2.h b/libs/libimago/src/imago2.h new file mode 100644 index 0000000..b0bea09 --- /dev/null +++ b/libs/libimago/src/imago2.h @@ -0,0 +1,222 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010-2012 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ + +#ifndef IMAGO2_H_ +#define IMAGO2_H_ + +#include + +#ifdef __cplusplus +#define IMG_OPTARG(arg, val) arg = val +#else +#define IMG_OPTARG(arg, val) arg +#endif + +/* XXX if you change this make sure to also change pack/unpack arrays in conv.c */ +enum img_fmt { + IMG_FMT_GREY8, + IMG_FMT_RGB24, + IMG_FMT_RGBA32, + IMG_FMT_GREYF, + IMG_FMT_RGBF, + IMG_FMT_RGBAF, + + NUM_IMG_FMT +}; + +struct img_pixmap { + void *pixels; + int width, height; + enum img_fmt fmt; + int pixelsz; + char *name; +}; + +struct img_io { + void *uptr; /* user-data */ + + size_t (*read)(void *buf, size_t bytes, void *uptr); + size_t (*write)(void *buf, size_t bytes, void *uptr); + long (*seek)(long offs, int whence, void *uptr); +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/* initialize the img_pixmap structure */ +void img_init(struct img_pixmap *img); +/* destroys the img_pixmap structure, freeing the pixel buffer (if available) + * and any other memory held by the pixmap. + */ +void img_destroy(struct img_pixmap *img); + +/* convenience function that allocates an img_pixmap struct and then initializes it. + * returns null if the malloc fails. + */ +struct img_pixmap *img_create(void); +/* frees a pixmap previously allocated with img_create (free followed by img_destroy) */ +void img_free(struct img_pixmap *img); + +int img_set_name(struct img_pixmap *img, const char *name); + +/* set the image pixel format */ +int img_set_format(struct img_pixmap *img, enum img_fmt fmt); + +/* copies one pixmap to another. + * equivalent to: img_set_pixels(dest, src->width, src->height, src->fmt, src->pixels) + */ +int img_copy(struct img_pixmap *dest, struct img_pixmap *src); + +/* allocates a pixel buffer of the specified dimensions and format, and copies the + * pixels given through the pix pointer into it. + * the pix pointer can be null, in which case there's no copy, just allocation. + * + * C++: fmt and pix have default parameters IMG_FMT_RGBA32 and null respectively. + */ +int img_set_pixels(struct img_pixmap *img, int w, int h, IMG_OPTARG(enum img_fmt fmt, IMG_FMT_RGBA32), IMG_OPTARG(void *pix, 0)); + +/* Simplified image loading + * Loads the specified file, and returns a pointer to an array of pixels of the + * requested pixel format. The width and height of the image are returned through + * the xsz and ysz pointers. + * If the image cannot be loaded, the function returns null. + * + * C++: the format argument is optional and defaults to IMG_FMT_RGBA32 + */ +void *img_load_pixels(const char *fname, int *xsz, int *ysz, IMG_OPTARG(enum img_fmt fmt, IMG_FMT_RGBA32)); + +/* Simplified image saving + * Reads an array of pixels supplied through the pix pointer, of dimensions xsz + * and ysz, and pixel-format fmt, and saves it to a file. + * The output filetype is guessed by the filename suffix. + * + * C++: the format argument is optional and defaults to IMG_FMT_RGBA32 + */ +int img_save_pixels(const char *fname, void *pix, int xsz, int ysz, IMG_OPTARG(enum img_fmt fmt, IMG_FMT_RGBA32)); + +/* Frees the memory allocated by img_load_pixels */ +void img_free_pixels(void *pix); + +/* Loads an image file into the supplied pixmap */ +int img_load(struct img_pixmap *img, const char *fname); +/* Saves the supplied pixmap to a file. The output filetype is guessed by the filename suffix */ +int img_save(struct img_pixmap *img, const char *fname); + +/* Reads an image from an open FILE* into the supplied pixmap */ +int img_read_file(struct img_pixmap *img, FILE *fp); +/* Writes the supplied pixmap to an open FILE* */ +int img_write_file(struct img_pixmap *img, FILE *fp); + +/* Reads an image using user-defined file-i/o functions (see img_io_set_*) */ +int img_read(struct img_pixmap *img, struct img_io *io); +/* Writes an image using user-defined file-i/o functions (see img_io_set_*) */ +int img_write(struct img_pixmap *img, struct img_io *io); + +/* Converts an image to the specified pixel format */ +int img_convert(struct img_pixmap *img, enum img_fmt tofmt); + +/* Converts an image from an integer pixel format to the corresponding floating point one */ +int img_to_float(struct img_pixmap *img); +/* Converts an image from a floating point pixel format to the corresponding integer one */ +int img_to_integer(struct img_pixmap *img); + +/* Returns non-zero (true) if the supplied image is in a floating point pixel format */ +int img_is_float(struct img_pixmap *img); +/* Returns non-zero (true) if the supplied image has an alpha channel */ +int img_has_alpha(struct img_pixmap *img); + + +/* don't use these for anything performance-critical */ +void img_setpixel(struct img_pixmap *img, int x, int y, void *pixel); +void img_getpixel(struct img_pixmap *img, int x, int y, void *pixel); + +void img_setpixel1i(struct img_pixmap *img, int x, int y, int pix); +void img_setpixel1f(struct img_pixmap *img, int x, int y, float pix); +void img_setpixel4i(struct img_pixmap *img, int x, int y, int r, int g, int b, int a); +void img_setpixel4f(struct img_pixmap *img, int x, int y, float r, float g, float b, float a); + +void img_getpixel1i(struct img_pixmap *img, int x, int y, int *pix); +void img_getpixel1f(struct img_pixmap *img, int x, int y, float *pix); +void img_getpixel4i(struct img_pixmap *img, int x, int y, int *r, int *g, int *b, int *a); +void img_getpixel4f(struct img_pixmap *img, int x, int y, float *r, float *g, float *b, float *a); + + +/* OpenGL helper functions */ + +/* Returns the equivalent OpenGL "format" as expected by the 7th argument of glTexImage2D */ +unsigned int img_fmt_glfmt(enum img_fmt fmt); +/* Returns the equivalent OpenGL "type" as expected by the 8th argument of glTexImage2D */ +unsigned int img_fmt_gltype(enum img_fmt fmt); +/* Returns the equivalent OpenGL "internal format" as expected by the 3rd argument of glTexImage2D */ +unsigned int img_fmt_glintfmt(enum img_fmt fmt); + +/* Same as above, based on the pixel format of the supplied image */ +unsigned int img_glfmt(struct img_pixmap *img); +unsigned int img_gltype(struct img_pixmap *img); +unsigned int img_glintfmt(struct img_pixmap *img); + +/* Creates an OpenGL texture from the image, and returns the texture id, or 0 for failure */ +unsigned int img_gltexture(struct img_pixmap *img); + +/* Load an image and create an OpenGL texture out of it */ +unsigned int img_gltexture_load(const char *fname); +unsigned int img_gltexture_read_file(FILE *fp); +unsigned int img_gltexture_read(struct img_io *io); + +/* These functions can be used to fill an img_io struct before it's passed to + * one of the user-defined i/o image reading/writing functions (img_read/img_write). + * + * User-defined i/o functions: + * + * - size_t read_func(void *buffer, size_t bytes, void *user_ptr) + * Must try to fill the buffer with the specified number of bytes, and return + * the number of bytes actually read. + * + * - size_t write_func(void *buffer, size_t bytes, void *user_ptr) + * Must write the specified number of bytes from the supplied buffer and return + * the number of bytes actually written. + * + * - long seek_func(long offset, int whence, void *user_ptr) + * Must seek offset bytes from: the beginning of the file if whence is SEEK_SET, + * the current position if whence is SEEK_CUR, or the end of the file if whence is + * SEEK_END, and return the resulting file offset from the beginning of the file. + * (i.e. seek_func(0, SEEK_CUR, user_ptr); must be equivalent to an ftell). + * + * All three functions get the user-data pointer set through img_io_set_user_data + * as their last argument. + * + * Note: obviously you don't need to set a write function if you're only going + * to call img_read, or the read and seek function if you're only going to call + * img_write. + * + * Note: if the user-supplied write function is buffered, make sure to flush + * (or close the file) after img_write returns. + */ +void img_io_set_user_data(struct img_io *io, void *uptr); +void img_io_set_read_func(struct img_io *io, size_t (*read)(void*, size_t, void*)); +void img_io_set_write_func(struct img_io *io, size_t (*write)(void*, size_t, void*)); +void img_io_set_seek_func(struct img_io *io, long (*seek)(long, int, void*)); + + +#ifdef __cplusplus +} +#endif + + +#endif /* IMAGO_H_ */ diff --git a/libs/libimago/src/imago_gl.c b/libs/libimago/src/imago_gl.c new file mode 100644 index 0000000..32c540e --- /dev/null +++ b/libs/libimago/src/imago_gl.c @@ -0,0 +1,223 @@ +#include "imago2.h" + + +/* to avoid dependency to OpenGL, I'll define all the relevant GL macros manually */ +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_FLOAT 0x1406 + +#define GL_LUMINANCE 0x1909 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 + +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_LUMINANCE32F 0x8818 + +#define GL_TEXTURE_2D 0x0de1 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_LINEAR 0x2601 +#define GL_REPEAT 0x2901 + + +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef int GLint; +typedef int GLsizei; +typedef void GLvoid; + +/* for the same reason I'll load GL functions dynamically */ +typedef void (*gl_gen_textures_func)(GLsizei, GLuint*); +typedef void (*gl_bind_texture_func)(GLenum, GLuint); +typedef void (*gl_tex_parameteri_func)(GLenum, GLenum, GLint); +typedef void (*gl_tex_image2d_func)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); + +static gl_gen_textures_func gl_gen_textures; +static gl_bind_texture_func gl_bind_texture; +static gl_tex_parameteri_func gl_tex_parameteri; +static gl_tex_image2d_func gl_tex_image2d; + +static int load_glfunc(void); + +unsigned int img_fmt_glfmt(enum img_fmt fmt) +{ + switch(fmt) { + case IMG_FMT_GREY8: + case IMG_FMT_GREYF: + return GL_LUMINANCE; + + case IMG_FMT_RGB24: + case IMG_FMT_RGBF: + return GL_RGB; + + case IMG_FMT_RGBA32: + case IMG_FMT_RGBAF: + return GL_RGBA; + + default: + break; + } + return 0; +} + +unsigned int img_fmt_gltype(enum img_fmt fmt) +{ + switch(fmt) { + case IMG_FMT_GREY8: + case IMG_FMT_RGB24: + case IMG_FMT_RGBA32: + return GL_UNSIGNED_BYTE; + + case IMG_FMT_GREYF: + case IMG_FMT_RGBF: + case IMG_FMT_RGBAF: + return GL_FLOAT; + + default: + break; + } + return 0; +} + +unsigned int img_fmt_glintfmt(enum img_fmt fmt) +{ + switch(fmt) { + case IMG_FMT_GREY8: + return GL_LUMINANCE; + case IMG_FMT_RGB24: + return GL_RGB; + case IMG_FMT_RGBA32: + return GL_RGBA; + case IMG_FMT_GREYF: + return GL_LUMINANCE32F; + case IMG_FMT_RGBF: + return GL_RGB32F; + case IMG_FMT_RGBAF: + return GL_RGBA32F; + default: + break; + } + return 0; +} + +unsigned int img_glfmt(struct img_pixmap *img) +{ + return img_fmt_glfmt(img->fmt); +} + +unsigned int img_gltype(struct img_pixmap *img) +{ + return img_fmt_gltype(img->fmt); +} + +unsigned int img_glintfmt(struct img_pixmap *img) +{ + return img_fmt_glintfmt(img->fmt); +} + +unsigned int img_gltexture(struct img_pixmap *img) +{ + unsigned int tex; + unsigned int intfmt, fmt, type; + + if(!gl_gen_textures) { + if(load_glfunc() == -1) { + fprintf(stderr, "imago: failed to initialize the OpenGL helpers\n"); + return 0; + } + } + + intfmt = img_glintfmt(img); + fmt = img_glfmt(img); + type = img_gltype(img); + + gl_gen_textures(1, &tex); + gl_bind_texture(GL_TEXTURE_2D, tex); + gl_tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + gl_tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl_tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + gl_tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + gl_tex_image2d(GL_TEXTURE_2D, 0, intfmt, img->width, img->height, 0, fmt, type, img->pixels); + return tex; +} + +unsigned int img_gltexture_load(const char *fname) +{ + struct img_pixmap img; + unsigned int tex; + + img_init(&img); + if(img_load(&img, fname) == -1) { + img_destroy(&img); + return 0; + } + + tex = img_gltexture(&img); + img_destroy(&img); + return tex; +} + +unsigned int img_gltexture_read_file(FILE *fp) +{ + struct img_pixmap img; + unsigned int tex; + + img_init(&img); + if(img_read_file(&img, fp) == -1) { + img_destroy(&img); + return 0; + } + + tex = img_gltexture(&img); + img_destroy(&img); + return tex; +} + +unsigned int img_gltexture_read(struct img_io *io) +{ + struct img_pixmap img; + unsigned int tex; + + img_init(&img); + if(img_read(&img, io) == -1) { + img_destroy(&img); + return 0; + } + + tex = img_gltexture(&img); + img_destroy(&img); + return tex; +} + +#if defined(__unix__) || defined(__APPLE__) +#ifndef __USE_GNU +#define __USE_GNU +#endif + +#include +#endif +#ifdef WIN32 +#include +#endif + +static int load_glfunc(void) +{ +#if defined(__unix__) || defined(__APPLE__) + gl_gen_textures = (gl_gen_textures_func)dlsym(RTLD_DEFAULT, "glGenTextures"); + gl_bind_texture = (gl_bind_texture_func)dlsym(RTLD_DEFAULT, "glBindTexture"); + gl_tex_parameteri = (gl_tex_parameteri_func)dlsym(RTLD_DEFAULT, "glTexParameteri"); + gl_tex_image2d = (gl_tex_image2d_func)dlsym(RTLD_DEFAULT, "glTexImage2D"); +#endif + +#ifdef WIN32 + HMODULE handle = GetModuleHandle(0); + gl_gen_textures = (gl_gen_textures_func)GetProcAddress(handle, "glGenTextures"); + gl_bind_texture = (gl_bind_texture_func)GetProcAddress(handle, "glBindTexture"); + gl_tex_parameteri = (gl_tex_parameteri_func)GetProcAddress(handle, "glTexParameteri"); + gl_tex_image2d = (gl_tex_image2d_func)GetProcAddress(handle, "glTexImage2D"); +#endif + + return (gl_gen_textures && gl_bind_texture && gl_tex_parameteri && gl_tex_image2d) ? 0 : -1; +} diff --git a/libs/libimago/test/Makefile b/libs/libimago/test/Makefile new file mode 100644 index 0000000..901c7a7 --- /dev/null +++ b/libs/libimago/test/Makefile @@ -0,0 +1,19 @@ +obj = test.o +bin = test + +CC = gcc +CFLAGS = -pedantic -Wall -g -I../src +LDFLAGS = $(lib) + +ifeq ($(shell uname -s), Darwin) + lib = ../libimago.dylib +else + lib = ../libimago.so.2.0 +endif + +$(bin): $(obj) $(lib) + $(CC) -o $@ $(obj) $(LDFLAGS) + +.PHONY: clean +clean: + rm -f $(obj) $(bin) diff --git a/libs/libimago/test/test.c b/libs/libimago/test/test.c new file mode 100644 index 0000000..4bf2789 --- /dev/null +++ b/libs/libimago/test/test.c @@ -0,0 +1,63 @@ +#include +#include + +int main(int argc, char **argv) +{ + const char *infile = "foo.jpg"; + const char *outfile = "bar.jpg"; + int i, j, xsz = 512, ysz = 512; + struct img_pixmap img; + + for(i=1; i> 5) & 1) == ((j >> 5) & 1); + + *pix++ = bw ? 255 : 0; + *pix++ = 127; + *pix++ = bw ? 0 : 255; + } + } + } + + if(img_save(&img, outfile) == -1) { + fprintf(stderr, "failed to save file %s\n", outfile); + return 1; + } + + img_destroy(&img); + return 0; +} diff --git a/src/bvol.cc b/src/bvol.cc new file mode 100644 index 0000000..d313eec --- /dev/null +++ b/src/bvol.cc @@ -0,0 +1,80 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include +#include "bvol.h" + +BSphere::BSphere() +{ + radius = 1.0f; +} + +BSphere::BSphere(const Vector3 &c, float rad) + : center(c) +{ + radius = rad; +} + +void BSphere::set_center(const Vector3 ¢er) +{ + this->center = center; +} + +const Vector3 &BSphere::get_center() const +{ + return center; +} + +void BSphere::set_radius(float rad) +{ + radius = rad; +} + +float BSphere::get_radius() const +{ + return radius; +} + +bool BSphere::intersect(const Ray &ray, HitPoint *hit) const +{ + float a = dot(ray.dir, ray.dir); + float b = 2.0 * dot(ray.dir, ray.origin - center); + float c = dot(ray.origin, ray.origin) + dot(center, center) - + 2.0 * dot(ray.origin, center) - radius * radius; + + float disc = b * b - 4.0f * a * c; + if(disc < 1e-6) { + return false; + } + + float sqrt_disc = sqrt(disc); + float x1 = (-b + sqrt_disc) / (2.0f * a); + float x2 = (-b - sqrt_disc) / (2.0f * a); + + if(x1 < 1e-6) x1 = x2; + if(x2 < 1e-6) x2 = x1; + + float t = x1 < x2 ? x1 : x2; + if(t < 1e-6) { + return false; + } + + hit->t = t; + hit->pos = ray.origin + ray.dir * t; + return true; +} diff --git a/src/bvol.h b/src/bvol.h new file mode 100644 index 0000000..fd305d7 --- /dev/null +++ b/src/bvol.h @@ -0,0 +1,54 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#ifndef BVOL_H_ +#define BVOL_H_ + +#include "vmath.h" + +struct HitPoint { + float t; + Vector3 pos; +}; + +class BVolume { +public: + virtual ~BVolume() {} + + virtual bool intersect(const Ray &ray, HitPoint *hit) const = 0; +}; + +class BSphere : public BVolume { +private: + Vector3 center; + float radius; + +public: + BSphere(); + explicit BSphere(const Vector3 &c, float rad = 1.0); + + void set_center(const Vector3 ¢er); + const Vector3 &get_center() const; + + void set_radius(float rad); + float get_radius() const; + + bool intersect(const Ray &ray, HitPoint *hit) const; +}; + +#endif // BVOL_H_ diff --git a/src/dev.cc b/src/dev.cc new file mode 100644 index 0000000..463be30 --- /dev/null +++ b/src/dev.cc @@ -0,0 +1,218 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dev.h" +#include "timer.h" + +void post_redisplay(); // defined in main.cc + +int customer, ticket; +static int report_inputs, cmd_echo; +static long last_ticket_msec = LONG_MIN; + +static void runcmd(const char *cmd); + +static int fd = -1; +static FILE *fp; +static std::string cur_line; + +int start_dev(const char *devpath) +{ + if((fd = open(devpath, O_RDWR | O_NONBLOCK)) == -1) { + fprintf(stderr, "failed to open device: %s: %s\n", devpath, strerror(errno)); + return -1; + } + if(isatty(fd)) { + struct termios term; + + if(tcgetattr(fd, &term) == -1) { + perror("failed to retrieve terminal attributes"); + stop_dev(); + return -1; + } + term.c_cflag = CS8 | CLOCAL; + term.c_iflag &= ~(IXON | IXOFF); + term.c_lflag = 0; + + cfsetispeed(&term, B38400); + cfsetospeed(&term, B38400); + + if(tcsetattr(fd, TCSANOW, &term) == -1) { + perror("failed to set terminal attributes"); + stop_dev(); + return -1; + } + } + + if(!(fp = fdopen(fd, "r+"))) { + perror("failed to attach an I/O stream to the device file\n"); + stop_dev(); + return -1; + } + setvbuf(fp, 0, _IONBF, 0); + + return fd; +} + +void stop_dev() +{ + if(fp) + fclose(fp); + else if(fd >= 0) + close(fd); +} + + +void proc_dev_input() +{ + int rdbytes; + char buf[256]; + static bool skip_line; + + while((rdbytes = read(fd, buf, sizeof buf - 1)) > 0) { + buf[rdbytes] = 0; + + /* ignore our own crap */ + if(memcmp(buf, "OK,", 3) == 0 || memcmp(buf, "ERR,", 4) == 0) { + skip_line = true; + } + + for(int i=0; i, + Eleni-Maria Stea + +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 . +*/ +#ifndef DEV_H_ +#define DEV_H_ + +extern int customer, ticket; + +int start_dev(const char *devpath); +void stop_dev(); +void proc_dev_input(); + +void next_customer(); +void issue_ticket(); + +int get_display_number(); +int get_led_state(int led); + +#endif /* DEV_H_ */ diff --git a/src/fblur.cc b/src/fblur.cc new file mode 100644 index 0000000..dcca0d0 --- /dev/null +++ b/src/fblur.cc @@ -0,0 +1,138 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include +#include +#include "fblur.h" + +#if defined(__i386__) || defined(__ia64__) || defined(WIN32) || \ + (defined(__alpha__) || defined(__alpha)) || \ + defined(__arm__) || \ + (defined(__mips__) && defined(__MIPSEL__)) || \ + defined(__SYMBIAN32__) || \ + defined(__x86_64__) || \ + defined(__LITTLE_ENDIAN__) +#define FBLUR_LITTLE_ENDIAN +#else +#define FBLUR_BIG_ENDIAN +#endif + +/* some color packing/unpacking macros */ +#ifdef FBLUR_BIG_ENDIAN +#define RSHIFT 24 +#define GSHIFT 16 +#define BSHIFT 8 +#else /* little endian */ +#define RSHIFT 0 +#define GSHIFT 8 +#define BSHIFT 16 +#endif + +#define RED(p) (((p) >> RSHIFT) & 0xff) +#define GREEN(p) (((p) >> GSHIFT) & 0xff) +#define BLUE(p) (((p) >> BSHIFT) & 0xff) +#define RGB(r, g, b) \ + ((((r) & 0xff) << RSHIFT) | \ + (((g) & 0xff) << GSHIFT) | \ + (((b) & 0xff) << BSHIFT)) + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + + +void fast_blur(int dir, int amount, uint32_t *buf, int x, int y) +{ + int i, j, half; + uint32_t *dptr, *sptr, *tmp_buf; + + int blur_len = dir == BLUR_HORIZ ? x : y; + int blur_times = dir == BLUR_HORIZ ? y : x; + + if(amount <= 1) return; + + dptr = buf; + half = amount / 2; + + tmp_buf = (uint32_t*)alloca(blur_len * sizeof(uint32_t)); + + for(i=0; i half) { + uint32_t out = *(sptr - half - 1); + ar -= RED(out); + ag -= GREEN(out); + ab -= BLUE(out); + divisor--; + } + + if(j < blur_len - half) { + uint32_t in = *(sptr + half); + ar += RED(in); + ag += GREEN(in); + ab += BLUE(in); + divisor++; + } + + r = ar / divisor; + g = ag / divisor; + b = ab / divisor; + + r = MAX(MIN(r, 255), 0); + g = MAX(MIN(g, 255), 0); + b = MAX(MIN(b, 255), 0); + + *dptr = RGB(r, g, b); + dptr += dir == BLUR_HORIZ ? 1 : x; + sptr++; + } + + } + + if(dir == BLUR_BOTH) { + fast_blur(BLUR_HORIZ, amount, buf, x, y); + } +} diff --git a/src/fblur.h b/src/fblur.h new file mode 100644 index 0000000..405cb06 --- /dev/null +++ b/src/fblur.h @@ -0,0 +1,32 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#ifndef FBLUR_H_ +#define FBLUR_H_ + +#include + +enum { + BLUR_BOTH, /* blur in X and Y */ + BLUR_HORIZ, /* blur in X */ + BLUR_VERT /* blur in Y */ +}; + +void fast_blur(int dir, int amount, uint32_t *buf, int x, int y); + +#endif /* FBLUR_H_ */ diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..3263c87 --- /dev/null +++ b/src/main.cc @@ -0,0 +1,677 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dev.h" +#include "scene.h" +#include "timer.h" +#include "fblur.h" + + +enum { + REGULAR_PASS, + GLOW_PASS +}; + +void post_redisplay(); +static bool init(); +static void cleanup(); +static void display(); +static void draw_scene(int pass = REGULAR_PASS); +static void post_glow(void); +static void keyb(int key, bool pressed); +static void mouse(int bn, bool pressed, int x, int y); +static void motion(int x, int y); +static Ray calc_pick_ray(int x, int y); +static int next_pow2(int x); + +static Window create_window(const char *title, int xsz, int ysz); +static void process_events(); +static int translate_keysym(KeySym sym); + +static int proc_args(int argc, char **argv); + +static Display *dpy; +static Window win; +static GLXContext ctx; +static Atom xa_wm_prot, xa_wm_del_win; + +static int win_width, win_height; + +static bool draw_pending; +static bool win_mapped; + +static int fakefd = -1; +static char *fake_devpath; + +static float cam_theta, cam_phi, cam_dist = 140; +static Scene *scn; + +enum { BN_TICKET, BN_NEXT, NUM_BUTTONS }; +static const char *button_names[] = { "button1", "button2" }; +static Object *button_obj[NUM_BUTTONS]; +static Object *disp_obj[2]; +static Object *led_obj[2]; +static Vector3 led_on_emissive; + +static bool opt_use_glow = true; +#define GLOW_SZ_DIV 3 +static unsigned int glow_tex; +static int glow_tex_xsz, glow_tex_ysz, glow_xsz, glow_ysz; +static int glow_iter = 1; +static int blur_size = 5; +unsigned char *glow_framebuf; + + +int main(int argc, char **argv) +{ + if(proc_args(argc, argv) == -1) { + return 1; + } + if(!init()) { + return 1; + } + atexit(cleanup); + + int xfd = ConnectionNumber(dpy); + + // run once through pending events before going into the select loop + process_events(); + + for(;;) { + fd_set rd; + FD_ZERO(&rd); + + FD_SET(xfd, &rd); + FD_SET(fakefd, &rd); + + struct timeval noblock = {0, 0}; + int maxfd = xfd > fakefd ? xfd : fakefd; + while(!XPending(dpy) && select(maxfd + 1, &rd, 0, 0, draw_pending ? &noblock : 0) == -1 && errno == EINTR); + + if(XPending(dpy) || FD_ISSET(xfd, &rd)) { + process_events(); + } + if(FD_ISSET(fakefd, &rd)) { + proc_dev_input(); + } + + if(draw_pending) { + draw_pending = false; + display(); + } + } + return 0; +} + +void post_redisplay() +{ + draw_pending = true; +} + +static bool init() +{ + if(fake_devpath) { + if((fakefd = start_dev(fake_devpath)) == -1) { + return false; + } + } + + if(!(dpy = XOpenDisplay(0))) { + fprintf(stderr, "failed to connect to the X server!\n"); + return false; + } + + if(!(win = create_window("equeue device emulator", 512, 512))) { + return false; + } + + glewInit(); + + scn = new Scene; + if(!scn->load("data/device.obj")) { + fprintf(stderr, "failed to load device 3D model\n"); + return false; + } + + for(int i=0; iget_object(button_names[i]); + if(!button_obj[i]) { + fprintf(stderr, "invalid 3D model\n"); + return false; + } + BSphere &bs = button_obj[i]->get_mesh()->get_bounds(); + bs.set_radius(bs.get_radius() * 1.5); + } + + disp_obj[0] = scn->get_object("7seg0"); + disp_obj[1] = scn->get_object("7seg1"); + if(!disp_obj[0] || !disp_obj[1]) { + fprintf(stderr, "invalid 3D model\n"); + return false; + } + scn->remove_object(disp_obj[0]); + scn->remove_object(disp_obj[1]); + + led_obj[0] = scn->get_object("led1"); + led_obj[1] = scn->get_object("led2"); + if(!led_obj[0] || !led_obj[1]) { + fprintf(stderr, "invalid 3D model\n"); + return false; + } + scn->remove_object(led_obj[0]); + scn->remove_object(led_obj[1]); + led_on_emissive = led_obj[0]->mtl.emissive; + + // create the glow texture + glGenTextures(1, &glow_tex); + glBindTexture(GL_TEXTURE_2D, glow_tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glClearColor(0.1, 0.1, 0.1, 1); + + return true; +} + +static void cleanup() +{ + delete scn; + + stop_dev(); + + if(!dpy) return; + + if(win) { + XDestroyWindow(dpy, win); + } + XCloseDisplay(dpy); +} + +#define DIGIT_USZ (1.0 / 11.0) +#define MIN_REDRAW_INTERVAL (1000 / 40) /* 40fps */ + +static void display() +{ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -cam_dist); + glRotatef(cam_phi, 1, 0, 0); + glRotatef(cam_theta, 0, 1, 0); + + float lpos[] = {-7, 5, 10, 0}; + glLightfv(GL_LIGHT0, GL_POSITION, lpos); + + if(opt_use_glow) { + glViewport(0, 0, glow_xsz, glow_ysz); + + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + draw_scene(GLOW_PASS); + + glReadPixels(0, 0, glow_xsz, glow_ysz, GL_RGBA, GL_UNSIGNED_BYTE, glow_framebuf); + glViewport(0, 0, win_width, win_height); + } + + glClearColor(0.05, 0.05, 0.05, 1); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + draw_scene(); + + if(opt_use_glow) { + for(int i=0; irender(); + } + + // shift the textures and modify the materials to make the display match our state + for(int i=0; i<2; i++) { + // 7seg + int digit = get_display_number(); + for(int j=0; jmtl.tex_offset[TEX_DIFFUSE] = Vector2(uoffs, 0); + disp_obj[i]->render(); + + // LEDs + if(get_led_state(i)) { + led_obj[i]->mtl.emissive = led_on_emissive; + } else { + led_obj[i]->mtl.emissive = Vector3(0, 0, 0); + } + led_obj[i]->render(); + } +} + +static void post_glow(void) +{ + float max_s = (float)glow_xsz / (float)glow_tex_xsz; + float max_t = (float)glow_ysz / (float)glow_tex_ysz; + + glPushAttrib(GL_ENABLE_BIT); + + glBlendFunc(GL_ONE, GL_ONE); + glEnable(GL_BLEND); + glDisable(GL_CULL_FACE); + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, glow_tex); + + glBegin(GL_QUADS); + glColor4f(1, 1, 1, 1); + glTexCoord2f(0, 0); + glVertex2f(-1, -1); + glTexCoord2f(max_s, 0); + glVertex2f(1, -1); + glTexCoord2f(max_s, max_t); + glVertex2f(1, 1); + glTexCoord2f(0, max_t); + glVertex2f(-1, 1); + glEnd(); + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + glPopAttrib(); +} + + +static void reshape(int x, int y) +{ + glViewport(0, 0, x, y); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(50.0, (float)x / (float)y, 1.0, 1000.0); + + win_width = x; + win_height = y; + + if(opt_use_glow) { + glow_xsz = x / GLOW_SZ_DIV; + glow_ysz = y / GLOW_SZ_DIV; + printf("glow image size: %dx%d\n", glow_xsz, glow_ysz); + + delete [] glow_framebuf; + glow_framebuf = new unsigned char[glow_xsz * glow_ysz * 4]; + + glow_tex_xsz = next_pow2(glow_xsz); + glow_tex_ysz = next_pow2(glow_ysz); + glBindTexture(GL_TEXTURE_2D, glow_tex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, glow_tex_xsz, glow_tex_ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + } +} + +static void keyb(int key, bool pressed) +{ + if(pressed) { + switch(key) { + case 27: + exit(0); + } + } +} + +static bool bnstate[32]; +static int prev_x, prev_y; + +static void mouse(int bn, bool pressed, int x, int y) +{ + bnstate[bn] = pressed; + prev_x = x; + prev_y = y; + + if(bn == 0 && pressed) { + // do picking + Ray ray = calc_pick_ray(x, win_height - y); + + HitPoint minhit; + minhit.t = FLT_MAX; + int hit_found = -1; + + for(int i=0; iget_mesh()->get_bounds().intersect(ray, &hit) && hit.t < minhit.t) { + minhit = hit; + hit_found = i; + } + } + + if(hit_found != -1) { + switch(hit_found) { + case BN_TICKET: + issue_ticket(); + break; + + case BN_NEXT: + next_customer(); + break; + } + draw_pending = true; + } + } +} + +static void motion(int x, int y) +{ + int dx = x - prev_x; + int dy = y - prev_y; + prev_x = x; + prev_y = y; + + if(bnstate[0]) { + cam_theta += dx * 0.5; + cam_phi += dy * 0.5; + if(cam_phi < -90) cam_phi = -90; + if(cam_phi > 90) cam_phi = 90; + + } else if(bnstate[2]) { + cam_dist += dy * 0.5; + if(cam_dist < 0.0) cam_dist = 0.0; + + } else { + float xoffs = 2.0 * x / win_width - 1.0; + float yoffs = 2.0 * y / win_height - 1.0; + cam_theta = -xoffs * 15.0 * (win_width / win_height); + cam_phi = -yoffs * 15.0; + } + draw_pending = true; +} + +static Ray calc_pick_ray(int x, int y) +{ + double mv[16], proj[16]; + int vp[4]; + double resx, resy, resz; + Ray ray; + + glGetDoublev(GL_MODELVIEW_MATRIX, mv); + glGetDoublev(GL_PROJECTION_MATRIX, proj); + glGetIntegerv(GL_VIEWPORT, vp); + + gluUnProject(x, y, 0, mv, proj, vp, &resx, &resy, &resz); + ray.origin = Vector3(resx, resy, resz); + + gluUnProject(x, y, 1, mv, proj, vp, &resx, &resy, &resz); + ray.dir = normalize(Vector3(resx, resy, resz) - ray.origin); + + return ray; +} + +static int next_pow2(int x) +{ + x--; + x = (x >> 1) | x; + x = (x >> 2) | x; + x = (x >> 4) | x; + x = (x >> 8) | x; + x = (x >> 16) | x; + return x + 1; +} + +static Window create_window(const char *title, int xsz, int ysz) +{ + int scr = DefaultScreen(dpy); + Window root = RootWindow(dpy, scr); + + int glxattr[] = { + GLX_RGBA, + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + GLX_DEPTH_SIZE, 24, + GLX_DOUBLEBUFFER, +#if defined(GLX_VERSION_1_4) || defined(GLX_ARB_multisample) + GLX_SAMPLE_BUFFERS_ARB, 1, + GLX_SAMPLES_ARB, 1, +#endif + None + }; + + XVisualInfo *vis = glXChooseVisual(dpy, scr, glxattr); + if(!vis) { + fprintf(stderr, "failed to find a suitable visual\n"); + return 0; + } + + if(!(ctx = glXCreateContext(dpy, vis, 0, True))) { + fprintf(stderr, "failed to create OpenGL context\n"); + XFree(vis); + return -1; + } + + XSetWindowAttributes xattr; + xattr.background_pixel = xattr.border_pixel = BlackPixel(dpy, scr); + xattr.colormap = XCreateColormap(dpy, root, vis->visual, AllocNone); + unsigned int xattr_mask = CWColormap | CWBackPixel | CWBorderPixel; + + Window win = XCreateWindow(dpy, root, 0, 0, xsz, ysz, 0, vis->depth, InputOutput, + vis->visual, xattr_mask, &xattr); + if(!win) { + fprintf(stderr, "failed to create window\n"); + glXDestroyContext(dpy, ctx); + XFree(vis); + return -1; + } + XFree(vis); + + unsigned int evmask = StructureNotifyMask | VisibilityChangeMask | ExposureMask | + KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | LeaveWindowMask; + XSelectInput(dpy, win, evmask); + + xa_wm_prot = XInternAtom(dpy, "WM_PROTOCOLS", False); + xa_wm_del_win = XInternAtom(dpy, "WM_DELETE_WINDOW", False); + XSetWMProtocols(dpy, win, &xa_wm_del_win, 1); + + XClassHint hint; + hint.res_name = hint.res_class = (char*)"equeue_win"; + XSetClassHint(dpy, win, &hint); + + XTextProperty wm_name; + XStringListToTextProperty((char**)&title, 1, &wm_name); + XSetWMName(dpy, win, &wm_name); + XSetWMIconName(dpy, win, &wm_name); + XFree(wm_name.value); + + XMapWindow(dpy, win); + glXMakeCurrent(dpy, win, ctx); + + return win; +} + +static void process_events() +{ + XEvent ev; + + while(XPending(dpy)) { + XNextEvent(dpy, &ev); + switch(ev.type) { + case MapNotify: + win_mapped = true; + break; + + case UnmapNotify: + win_mapped = false; + break; + + case Expose: + if(win_mapped && ev.xexpose.count == 0) { + draw_pending = true; + } + break; + + case MotionNotify: + motion(ev.xmotion.x, ev.xmotion.y); + break; + + case ButtonPress: + mouse(ev.xbutton.button - 1, true, ev.xbutton.x, ev.xbutton.y); + break; + + case ButtonRelease: + mouse(ev.xbutton.button - 1, false, ev.xbutton.x, ev.xbutton.y); + break; + + case KeyPress: + { + KeySym sym = XLookupKeysym(&ev.xkey, 0); + keyb(translate_keysym(sym), true); + } + break; + + case KeyRelease: + { + KeySym sym = XLookupKeysym(&ev.xkey, 0); + keyb(translate_keysym(sym), false); + } + break; + + case ConfigureNotify: + { + int xsz = ev.xconfigure.width; + int ysz = ev.xconfigure.height; + + if(xsz != win_width || ysz != win_height) { + win_width = xsz; + win_height = ysz; + reshape(xsz, ysz); + } + } + break; + + case ClientMessage: + if(ev.xclient.message_type == xa_wm_prot) { + if((Atom)ev.xclient.data.l[0] == xa_wm_del_win) { + exit(0); + } + } + break; + + case LeaveNotify: + if(ev.xcrossing.mode == NotifyNormal) { + cam_theta = cam_phi = 0; + draw_pending = true; + } + break; + + default: + break; + } + + } +} + +static int translate_keysym(KeySym sym) +{ + switch(sym) { + case XK_BackSpace: + return '\b'; + case XK_Tab: + return '\t'; + case XK_Linefeed: + return '\r'; + case XK_Return: + return '\n'; + case XK_Escape: + return 27; + default: + break; + } + return (int)sym; +} + +static int proc_args(int argc, char **argv) +{ + for(int i=1; i, + Eleni-Maria Stea + +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 . +*/ +#include +#include +#include +#include "material.h" + +static const char *find_path(const char *fname); + +Material::Material() + : diffuse(1, 1, 1), specular(0, 0, 0) +{ + shininess = 1.0; + alpha = 1.0; + + for(int i=0; i 128 ? 128 : shininess); + + float emit[] = {emissive.x, emissive.y, emissive.z, 1.0}; + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, emit); + + int num_tex = 0; + if(tex[TEX_DIFFUSE]) { + glActiveTexture(GL_TEXTURE0 + num_tex++); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glTranslatef(tex_offset[TEX_DIFFUSE].x, tex_offset[TEX_DIFFUSE].y, 0); + glScalef(tex_scale[TEX_DIFFUSE].x, tex_scale[TEX_DIFFUSE].y, 1); + + glBindTexture(GL_TEXTURE_2D, tex[TEX_DIFFUSE]); + glEnable(GL_TEXTURE_2D); + + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + } + + if(tex[TEX_ENVMAP]) { + glActiveTexture(GL_TEXTURE0 + num_tex++); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glTranslatef(tex_offset[TEX_ENVMAP].x, tex_offset[TEX_ENVMAP].y, 0); + glScalef(tex_scale[TEX_ENVMAP].x, tex_scale[TEX_ENVMAP].y, 1); + + glBindTexture(GL_TEXTURE_2D, tex[TEX_ENVMAP]); + glEnable(GL_TEXTURE_2D); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); + } + + + glMatrixMode(GL_TEXTURE); + for(int i=num_tex; i<4; i++) { + glActiveTexture(GL_TEXTURE0 + i); + glDisable(GL_TEXTURE_2D); + glLoadIdentity(); + } + + glActiveTexture(GL_TEXTURE0); + glMatrixMode(GL_MODELVIEW); +} + +unsigned int load_texture(const char *fname) +{ + int xsz, ysz; + void *pixels; + unsigned int tex; + + const char *path = find_path(fname); + + if(!(pixels = img_load_pixels(path, &xsz, &ysz, IMG_FMT_RGBA32))) { + fprintf(stderr, "failed to load texture: %s\n", fname); + return 0; + } + + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + img_free_pixels(pixels); + return tex; +} + +static const char *find_path(const char *fname) +{ + const char *ptr = fname + strlen(fname) - 1; + + do { + while(*ptr != '/' && ptr > fname - 1) { + ptr--; + } + + FILE *fp = fopen(ptr + 1, "rb"); + if(fp) { + fclose(fp); + return ptr + 1; + } + ptr -= 1; + + } while(ptr >= fname); + + return fname; +} diff --git a/src/material.h b/src/material.h new file mode 100644 index 0000000..57c5696 --- /dev/null +++ b/src/material.h @@ -0,0 +1,53 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#ifndef MATERIAL_H_ +#define MATERIAL_H_ + +#include "vmath.h" + +enum { + TEX_DIFFUSE, + TEX_ENVMAP, + + NUM_TEXTURES +}; + +class Material { +public: + Vector3 emissive; + Vector3 ambient; + Vector3 diffuse; + Vector3 specular; + float shininess; + float alpha; + + unsigned int tex[NUM_TEXTURES]; + Vector2 tex_scale[NUM_TEXTURES], tex_offset[NUM_TEXTURES]; + + unsigned int sdr; + + Material(); + + void setup() const; +}; + +unsigned int load_texture(const char *fname); +unsigned int load_shader_program(const char *vname, const char *pname); + +#endif // MATERIAL_H_ diff --git a/src/mesh.cc b/src/mesh.cc new file mode 100644 index 0000000..94eb061 --- /dev/null +++ b/src/mesh.cc @@ -0,0 +1,174 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include +#include +#include +#include +#include "mesh.h" + +#define ALL_VALID 0xffffffff + +Mesh::Mesh() +{ + buf_valid = ALL_VALID; + bsph_valid = false; + + for(int i=0; i max_lensq) { + max_lensq = lensq; + } + } + + bsph.set_center(center); + bsph.set_radius(sqrt(max_lensq)); + + bsph_valid = true; +} diff --git a/src/mesh.h b/src/mesh.h new file mode 100644 index 0000000..2019029 --- /dev/null +++ b/src/mesh.h @@ -0,0 +1,60 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#ifndef MESH_H_ +#define MESH_H_ + +#include "bvol.h" + +enum { + MESH_ATTR_VERTEX, + MESH_ATTR_NORMAL, + MESH_ATTR_TEXCOORD, + + NUM_MESH_ATTRIBS +}; + +class Mesh { +private: + float *attr[NUM_MESH_ATTRIBS]; + int vcount; + unsigned int vbo[NUM_MESH_ATTRIBS]; + int attr_size[NUM_MESH_ATTRIBS]; + + mutable unsigned int buf_valid; /* bitmask */ + void update_buffers() const; + + mutable BSphere bsph; + mutable bool bsph_valid; + void calc_bsph() const; + +public: + Mesh(); + ~Mesh(); + + float *set_attrib(int aidx, int count, int elemsz, float *data = 0); + float *get_attrib(int aidx); + const float *get_attrib(int aidx) const; + + void draw() const; + + BSphere &get_bounds(); + const BSphere &get_bounds() const; +}; + +#endif // MESH_H_ diff --git a/src/object.cc b/src/object.cc new file mode 100644 index 0000000..05d6ac0 --- /dev/null +++ b/src/object.cc @@ -0,0 +1,52 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include "object.h" + +Object::Object() +{ + mesh = 0; +} + +void Object::set_name(const char *name) +{ + this->name = std::string(name); +} + +const char *Object::get_name() const +{ + return name.c_str(); +} + +void Object::set_mesh(Mesh *mesh) +{ + this->mesh = mesh; +} + +Mesh *Object::get_mesh() const +{ + return mesh; +} + +void Object::render() const +{ + if(!mesh) return; + + mtl.setup(); + mesh->draw(); +} diff --git a/src/object.h b/src/object.h new file mode 100644 index 0000000..6947339 --- /dev/null +++ b/src/object.h @@ -0,0 +1,45 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#ifndef OBJECT_H_ +#define OBJECT_H_ + +#include +#include "mesh.h" +#include "material.h" + +class Object { +private: + std::string name; + Mesh *mesh; + +public: + Material mtl; + + Object(); + + void set_name(const char *name); + const char *get_name() const; + + void set_mesh(Mesh *mesh); + Mesh *get_mesh() const; + + void render() const; +}; + +#endif // OBJECT_H_ diff --git a/src/objfile.cc b/src/objfile.cc new file mode 100644 index 0000000..6d926e3 --- /dev/null +++ b/src/objfile.cc @@ -0,0 +1,583 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "scene.h" + +using namespace std; + +#define COMMANDS \ + CMD(V), \ + CMD(VN), \ + CMD(VT), \ + CMD(F), \ + CMD(O), \ + CMD(G), \ + CMD(MTLLIB), \ + CMD(USEMTL), \ + CMD(NEWMTL), \ + CMD(KE), \ + CMD(KA), \ + CMD(KD), \ + CMD(KS), \ + CMD(NS), \ + CMD(NI), \ + CMD(D), \ + CMD(TR), \ + CMD(MAP_KD), \ + CMD(MAP_REFL), \ + CMD(MAP_BUMP), \ + CMD(MAP_KS), \ + CMD(MAP_NS), \ + CMD(MAP_D), \ + CMD(REFL), \ + CMD(BUMP) + +#define CMD(x) CMD_##x +enum { + COMMANDS, + CMD_UNK +}; +#undef CMD + +#define CMD(x) #x +static const char *cmd_names[] = { + COMMANDS, + 0 +}; +#undef CMD + + +struct ObjFace { + int elem; + int v[4], n[4], t[4]; +}; + +struct ObjFile { + string cur_obj, cur_mat; + vector v, vn; + vector vt; + vector f; +}; + +typedef Vector3 Color; + +struct ObjMat { + string name; // newmtl + Color ambient, diffuse, specular; // Ka, Kd, Ks + Color emissive; // Ke + float shininess; // Ns + float ior; // Ni + float alpha; // d, Tr + + string tex_dif, tex_spec, tex_shin, tex_alpha; // map_Kd, map_Ks, map_Ns, map_d + string tex_refl; // refl -type sphere|cube file + string tex_bump; // bump + + ObjMat() { reset(); } + + void reset() { + ambient = diffuse = Color(0.5, 0.5, 0.5); + specular = Color(0.0, 0.0, 0.0); + name = tex_dif = tex_spec = tex_shin = tex_alpha = tex_refl = tex_bump = ""; + shininess = 0; + ior = alpha = 1; + } +}; + +static bool read_materials(FILE *fp, vector *vmtl); +static Object *cons_object(ObjFile *obj); + +static int get_cmd(char *str); +static bool is_int(const char *str); +static bool is_float(const char *str); +static bool parse_vec(Vector3 *vec); +static bool parse_color(Color *col); +static bool parse_face(ObjFace *face); +static const char *parse_map(); + + +static map matlib; + + +#define INVALID_IDX INT_MIN + +#define SEP " \t\n\r\v" +#define BUF_SZ 512 +bool Scene::load_obj(FILE *fp) +{ + static int seq; + char cur_name[16]; + stringstream sstr; + + ObjFile obj; + + sprintf(cur_name, "default%02d.obj", seq++); + obj.cur_obj = cur_name; + + int prev_cmd = 0, obj_added = 0; + for(;;) { + Vector3 vec; + ObjFace face; + + char line[BUF_SZ]; + fgets(line, sizeof line, fp); + if(feof(fp)) { + break; + } + + char *tok; + if(!(tok = strtok(line, SEP))) { + continue; // ignore empty lines + } + + int cmd; + if((cmd = get_cmd(tok)) == -1) { + continue; // ignore unknown commands ... + } + + switch(cmd) { + case CMD_V: + if(!parse_vec(&vec)) { + continue; + } + obj.v.push_back(vec); + break; + + case CMD_VN: + if(!parse_vec(&vec)) { + continue; + } + obj.vn.push_back(vec); + break; + + case CMD_VT: + if(!parse_vec(&vec)) { + continue; + } + vec.y = 1.0 - vec.y; + obj.vt.push_back(Vector2(vec.x, vec.y)); + break; + + case CMD_O: + case CMD_G: + if(prev_cmd == CMD_O || prev_cmd == CMD_G) { + break; // just in case we've got both of them in a row + } + /* if we have any previous data, group them up, add the object + * and continue with the new one... + */ + if(!obj.f.empty()) { + Object *robj = cons_object(&obj); + robj->mtl = matlib[obj.cur_mat]; + add_object(robj); + obj_added++; + + obj.f.clear(); // clean the face list + } + if((tok = strtok(0, SEP))) { + obj.cur_obj = tok; + } else { + sprintf(cur_name, "default%02d.obj", seq++); + obj.cur_obj = cur_name; + } + break; + + case CMD_MTLLIB: + if((tok = strtok(0, SEP))) { + FILE *mfile; + if(!(mfile = fopen(tok, "rb"))) { + fprintf(stderr, "failed to open material library: %s\n", tok); + continue; + } + + // load all materials of the mtl file into a vector + vector vmtl; + if(!read_materials(mfile, &vmtl)) { + continue; + } + fclose(mfile); + + // and add them all to the scene + for(size_t i=0; imtl = matlib[obj.cur_mat]; + add_object(robj); + obj_added++; + } + + return obj_added > 0; +} + +static Object *cons_object(ObjFile *obj) +{ + Object *robj; + Vector3 *varr, *narr; + Vector2 *tarr; + + int nelem = obj->f.size() * 3; + + assert(sizeof(Vector3) == 3 * sizeof(float)); + assert(sizeof(Vector2) == 2 * sizeof(float)); + + try { + robj = new Object; + varr = new Vector3[nelem]; + narr = new Vector3[nelem]; + tarr = new Vector2[nelem]; + } + catch(...) { + return 0; + } + if(obj->cur_obj.length() > 0) { + robj->set_name(obj->cur_obj.c_str()); + } + + // need at least one of each element + bool added_norm = false, added_tc = false; + if(obj->vn.empty()) { + obj->vn.push_back(Vector3(0, 0, 0)); + added_norm = true; + } + if(obj->vt.empty()) { + obj->vt.push_back(Vector2(0, 0)); + added_tc = true; + } + + for(size_t i=0; if.size(); i++) { + for(int j=0; j<3; j++) { + int idx = i * 3 + j; + ObjFace *f = &obj->f[i]; + + varr[idx] = obj->v[f->v[j]]; + narr[idx] = obj->vn[f->n[j] < 0 ? 0 : f->n[j]]; + + float t = obj->vt[f->t[j] < 0 ? 0 : f->t[j]].x; + float s = obj->vt[f->t[j] < 0 ? 0 : f->t[j]].y; + tarr[idx] = Vector2(t, s); + } + } + + if(added_norm) { + obj->vn.pop_back(); + } + if(added_tc) { + obj->vt.pop_back(); + } + + Mesh *mesh = new Mesh; + mesh->set_attrib(MESH_ATTR_VERTEX, nelem, 3, &varr->x); + mesh->set_attrib(MESH_ATTR_NORMAL, nelem, 3, &narr->x); + mesh->set_attrib(MESH_ATTR_TEXCOORD, nelem, 2, &tarr->x); + robj->set_mesh(mesh); + + printf("loaded object %s: %d faces\n", obj->cur_obj.c_str(), nelem / 3); + + delete [] varr; + delete [] narr; + delete [] tarr; + return robj; +} + +static bool read_materials(FILE *fp, vector *vmtl) +{ + ObjMat mat; + + for(;;) { + char line[BUF_SZ]; + fgets(line, sizeof line, fp); + if(feof(fp)) { + break; + } + + char *tok; + if(!(tok = strtok(line, SEP))) { + continue; + } + + int cmd; + if((cmd = get_cmd(tok)) == -1) { + continue; + } + + switch(cmd) { + case CMD_NEWMTL: + // add the previous material, and start a new one + if(mat.name.length() > 0) { + vmtl->push_back(mat); + mat.reset(); + } + if((tok = strtok(0, SEP))) { + mat.name = tok; + } + break; + + case CMD_KE: + parse_color(&mat.emissive); + break; + + case CMD_KA: + parse_color(&mat.ambient); + break; + + case CMD_KD: + parse_color(&mat.diffuse); + break; + + case CMD_KS: + parse_color(&mat.specular); + break; + + case CMD_NS: + if((tok = strtok(0, SEP)) && is_float(tok)) { + mat.shininess = atof(tok); + } + break; + + case CMD_NI: + if((tok = strtok(0, SEP)) && is_float(tok)) { + mat.ior = atof(tok); + } + break; + + case CMD_D: + case CMD_TR: + { + Color c; + if(parse_color(&c)) { + mat.alpha = cmd == CMD_D ? c.x : 1.0 - c.x; + } + } + break; + + case CMD_MAP_KD: + mat.tex_dif = parse_map(); + break; + + case CMD_MAP_REFL: + mat.tex_refl = parse_map(); + break; + + default: + break; + } + } + + if(mat.name.length() > 0) { + vmtl->push_back(mat); + } + return true; +} + +static int get_cmd(char *str) +{ + char *s = str; + while((*s = toupper(*s))) s++; + + for(int i=0; cmd_names[i]; i++) { + if(strcmp(str, cmd_names[i]) == 0) { + return i; + } + } + return CMD_UNK; +} + +static bool is_int(const char *str) +{ + char *tmp; + strtol(str, &tmp, 10); + return tmp != str; +} + +static bool is_float(const char *str) +{ + char *tmp; + strtod(str, &tmp); + return tmp != str; +} + +static bool parse_vec(Vector3 *vec) +{ + for(int i=0; i<3; i++) { + char *tok; + + if(!(tok = strtok(0, SEP)) || !is_float(tok)) { + if(i < 2) { + return false; + } + vec->z = 0.0; + } else { + (*vec)[i] = atof(tok); + } + } + return true; +} + +static bool parse_color(Color *col) +{ + for(int i=0; i<3; i++) { + char *tok; + + if(!(tok = strtok(0, SEP)) || !is_float(tok)) { + col->y = col->z = col->x; + return i > 0 ? true : false; + } + (*col)[i] = atof(tok); + } + return true; +} + +static bool parse_face(ObjFace *face) +{ + char *tok[] = {0, 0, 0, 0}; + face->elem = 0; + + for(int i=0; i<4; i++) { + if((!(tok[i] = strtok(0, SEP)) || !is_int(tok[i]))) { + if(i < 3) return false; // less than 3 verts? not a polygon + } else { + face->elem++; + } + } + + for(int i=0; i<4; i++) { + char *subtok = tok[i]; + + if(!subtok || !*subtok || !is_int(subtok)) { + if(i < 3) { + return false; + } + face->v[i] = INVALID_IDX; + } else { + face->v[i] = atoi(subtok); + if(face->v[i] > 0) face->v[i]--; /* convert to 0-based */ + } + + while(subtok && *subtok && *subtok != '/') { + subtok++; + } + if(subtok && *subtok && *++subtok && is_int(subtok)) { + face->t[i] = atoi(subtok); + if(face->t[i] > 0) face->t[i]--; /* convert to 0-based */ + } else { + face->t[i] = INVALID_IDX; + } + + while(subtok && *subtok && *subtok != '/') { + subtok++; + } + if(subtok && *subtok && *++subtok && is_int(subtok)) { + face->n[i] = atoi(subtok); + if(face->n[i] > 0) face->n[i]--; /* convert to 0-based */ + } else { + face->n[i] = INVALID_IDX; + } + } + + return true; +} + +static const char *parse_map() +{ + char *tok, *prev = 0; + + while((tok = strtok(0, SEP))) { + prev = tok; + } + + return prev ? prev : ""; +} diff --git a/src/scene.cc b/src/scene.cc new file mode 100644 index 0000000..bbaeadc --- /dev/null +++ b/src/scene.cc @@ -0,0 +1,107 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include +#include +#include +#include "scene.h" + +Scene::~Scene() +{ + for(size_t i=0; iget_name(), name) == 0) { + return objects[i]; + } + } + return 0; +} + +bool Scene::remove_object(Object *obj) +{ + for(size_t i=0; irender(); + } +} diff --git a/src/scene.h b/src/scene.h new file mode 100644 index 0000000..9d07854 --- /dev/null +++ b/src/scene.h @@ -0,0 +1,55 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#ifndef SCENE_H_ +#define SCENE_H_ + +#include +#include +#include "mesh.h" +#include "object.h" + +class Scene { +private: + std::vector objects; + std::vector meshes; + + bool load_obj(FILE *fp); // defined in objfile.cc + +public: + ~Scene(); + + bool load(const char *fname); + + void add_object(Object *obj); + void add_mesh(Mesh *mesh); + + int get_num_objects() const; + int get_num_meshes() const; + + Object *get_object(int idx) const; + Mesh *get_mesh(int idx) const; + + Object *get_object(const char *name) const; + bool remove_object(Object *obj); + + void update(long msec); + void render() const; +}; + +#endif // SCENE_H_ diff --git a/src/timer.cc b/src/timer.cc new file mode 100644 index 0000000..4e9019d --- /dev/null +++ b/src/timer.cc @@ -0,0 +1,38 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#include +#include + +unsigned long get_msec() +{ + static struct timeval tv0; + struct timeval tv; + + gettimeofday(&tv, 0); + if(tv0.tv_sec == 0 && tv0.tv_usec == 0) { + tv0 = tv; + return 0; + } + return (tv.tv_sec - tv0.tv_sec) * 1000 + (tv.tv_usec - tv0.tv_usec) / 1000; +} + +void wait_for(unsigned long msec) +{ + usleep(msec * 1000); +} diff --git a/src/timer.h b/src/timer.h new file mode 100644 index 0000000..733ecb8 --- /dev/null +++ b/src/timer.h @@ -0,0 +1,25 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#ifndef TIMER_H_ +#define TIMER_H_ + +unsigned long get_msec(); +void wait_for(unsigned long msec); + +#endif /* TIMER_H_ */ diff --git a/src/vmath.h b/src/vmath.h new file mode 100644 index 0000000..69411ca --- /dev/null +++ b/src/vmath.h @@ -0,0 +1,99 @@ +/* +eqemu - electronic queue system emulator +Copyright (C) 2014 John Tsiombikas , + Eleni-Maria Stea + +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 . +*/ +#ifndef VMATH_H_ +#define VMATH_H_ + +#include + +class Vector2 { +public: + float x, y; + + Vector2() : x(0), y(0) {} + Vector2(float xa, float ya) : x(xa), y(ya) {} + + float &operator [](int idx) { return (&x)[idx]; } + const float &operator [](int idx) const { return (&x)[idx]; } +}; + +class Vector3 { +public: + float x, y, z; + + Vector3() : x(0), y(0), z(0) {} + Vector3(float xa, float ya, float za) : x(xa), y(ya), z(za) {} + + float &operator [](int idx) { return (&x)[idx]; } + const float &operator [](int idx) const { return (&x)[idx]; } +}; + +inline Vector3 operator +(const Vector3 &a, const Vector3 &b) +{ + return Vector3(a.x + b.x, a.y + b.y, a.z + b.z); +} + +inline Vector3 operator -(const Vector3 &a, const Vector3 &b) +{ + return Vector3(a.x - b.x, a.y - b.y, a.z - b.z); +} + +inline Vector3 operator *(const Vector3 &a, float s) +{ + return Vector3(a.x * s, a.y * s, a.z * s); +} + +inline float dot(const Vector3 &a, const Vector3 &b) +{ + return a.x * b.x + a.y * b.y + a.z * b.z; +} + +inline float length(const Vector3 &v) +{ + return sqrt(dot(v, v)); +} + +inline Vector3 normalize(const Vector3 &v) +{ + float len = length(v); + if(len == 0.0) { + return v; + } + return Vector3(v.x / len, v.y / len, v.z / len); +} + +class Vector4 { +public: + float x, y, z, w; + + Vector4() : x(0), y(0), z(0), w(0) {} + Vector4(float xa, float ya, float za, float wa) : x(xa), y(ya), z(za), w(wa) {} + + float &operator [](int idx) { return (&x)[idx]; } + const float &operator [](int idx) const { return (&x)[idx]; } +}; + +class Ray { +public: + Vector3 origin, dir; + + Ray() : origin(0, 0, 0), dir(0, 0, 1) {} + Ray(const Vector3 &o, const Vector3 &d) : origin(o), dir(d) {} +}; + +#endif // VMATH_H_