| author | Neil Roberts <bpeeluk@yahoo.co.uk> | 2011-03-29 13:03:32 (GMT) |
|---|---|---|
| committer | Neil Roberts <bpeeluk@yahoo.co.uk> | 2011-03-29 13:03:32 (GMT) |
| commit | 354b86a4dbef8c9cb19515c03f51e85171aaa460 (patch) (side-by-side diff) | |
| tree | 94f82b29f1a5a1532b4c1fb7438b88c787aa8b45 | |
| parent | aa96c125cdf85dc582a3c62dc8aa12bccc9531f8 (diff) | |
| download | mash-master.zip mash-master.tar.gz | |
to:
git://github.com/clutter-project/mash.git
Please update your repo by typing:
git remote set-url origin git://github.com/clutter-project/mash.git
Sorry for the inconvenience.
49 files changed, 5 insertions, 10762 deletions
diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4ba184b..0000000 --- a/.gitignore +++ b/dev/null @@ -1,61 +0,0 @@ -/Makefile -/Makefile.in -/aclocal.m4 -/autom4te.cache -/mash-*.pc -/mash/Makefile -/mash/Makefile.in -/mash/rply/Makefile -/mash/rply/Makefile.in -/mash/rply/convert -/mash/Mash-*.gir -/mash/Mash-*.typelib -/mash/mash-enum-types.[ch] -/mash/stamp-enum-types -/docs/Makefile -/docs/Makefile.in -/docs/reference/mash-*.txt -!/docs/reference/mash-sections.txt -/docs/reference/Makefile -/docs/reference/Makefile.in -/docs/reference/mash.args -/docs/reference/mash.hierarchy -/docs/reference/mash.interfaces -/docs/reference/mash.prerequisites -/docs/reference/mash.signals -/docs/reference/mash-docs.sgml -/docs/reference/mash-scan.c -/docs/reference/mash.types -/docs/reference/html -/docs/reference/*.stamp -/docs/reference/xml -/gtk-doc.make -/config.guess -/config.h -/config.h.in -/config.log -/config.status -/config.sub -/configure -/depcomp -/example/Makefile -/example/Makefile.in -/example/viewer -/example/lights -/install-sh -/libtool -/ltmain.sh -/m4/gtk-doc.m4 -/m4/libtool.m4 -/m4/lt~obsolete.m4 -/m4/ltoptions.m4 -/m4/ltsugar.m4 -/m4/ltversion.m4 -/missing -/stamp-h1 - -.deps -.libs -*.la -*.lo -*.o diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 3ff5cfb..0000000 --- a/AUTHORS +++ b/dev/null @@ -1,2 +0,0 @@ -Neil Roberts <bpeeluk@yahoo.co.uk> -Luca Bruno <lethalman88@gmail.com> diff --git a/COPYING.LIB b/COPYING.LIB deleted file mode 100644 index 5ab7695..0000000 --- a/COPYING.LIB +++ b/dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -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 this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. 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 not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the 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 -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "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 -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY 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 -LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library 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 2.1 of the License, or (at your option) any later version. - - This library 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 library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index f1b5dde..0000000 --- a/ChangeLog +++ b/dev/null @@ -1,3 +0,0 @@ -This is a stub file to keep automake happy. - -Please see the git log for the changes. diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 2550dab..0000000 --- a/INSTALL +++ b/dev/null @@ -1,302 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007, 2008, 2009 Free Software Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. - - Running `configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - - 6. Often, you can also type `make uninstall' to remove the installed - files again. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - With a non-GNU `make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before -reconfiguring for another architecture. - - On MacOS X 10.5 and later systems, you can create libraries and -executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like -this: - - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CPP="gcc -E" CXXCPP="g++ -E" - - This is not guaranteed to produce working output in all cases, you -may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. - -Installation Names -================== - - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Particular systems -================== - - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in -order to use an ANSI C compiler: - - ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" - -and if that doesn't work, install pre-built binaries of GCC for HP-UX. - - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `<wchar.h>' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try - - ./configure CC="cc" - -and if that doesn't work, try - - ./configure CC="cc -nodtk" - - On Solaris, don't put `/usr/ucb' early in your `PATH'. This -directory contains several dysfunctional programs; working variants of -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' -in your `PATH', put it _after_ `/usr/bin'. - - On Haiku, software installed for all users goes in `/boot/common', -not `/usr/local'. It is recommended to use the following options: - - ./configure --prefix=/boot/common - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS - KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: - - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. - -`--help=short' -`--help=recursive' - Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--prefix=DIR' - Use DIR as the installation prefix. *Note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. - -`--no-create' -`-n' - Run the configure checks, but stop before creating any output - files. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 2f24a93..0000000 --- a/Makefile.am +++ b/dev/null @@ -1,14 +0,0 @@ -SUBDIRS = mash example docs - -ACLOCAL_AMFLAGS = -I m4 - -pcfile = mash-@MASH_API_VERSION@.pc - -pkgconfig_DATA = $(pcfile) -pkgconfigdir = $(libdir)/pkgconfig - -EXTRA_DIST = mash.pc.in - -DISTCLEANFILES = $(pcfile) - -DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc @@ -1,4 +0,0 @@ -Mash 0.1.0 -========== - -This is the first release of Mash. @@ -1,45 +1,9 @@ -Mash - README -=============================================================================== +The Mash repo has moved to: -Mash is a small library for using real 3D models within a Clutter -scene. Models can be exported from Blender or other 3D modelling -software as PLY files and then used as actors. It also supports a -lighting model with animatable lights. + git://github.com/clutter-project/mash.git -REQUIREMENTS -------------------------------------------------------------------------------- +Please update your repo by typing: -Mash currently requires: + git remote set-url origin git://github.com/clutter-project/mash.git - • Clutter >= 1.2.0 - -Mash can also optionally depend on Mx >= 1.1.0. This is only used in -the lighting example so it is not neccessary for the library. - -For lighting, Mash requires GLSL shader support. - -RESOURCES -------------------------------------------------------------------------------- - -The official Mash website is: - - http://wiki.clutter-project.org/wiki/Mash - -The API reference for the latest stable release is available at: - - http://docs.clutter-project.org/docs/mash/ - -New releases of Mash are available at: - - http://source.clutter-project.org/sources/mash/ - -New bug page on Bugzilla: - - http://bugzilla.clutter-project.org/enter_bug.cgi?product=Mash - -Development on Mash is done in a git repository at: - - git://git.clutter-project.org/mash - -Mash is licensed under the terms of the GNU Lesser General Public -License, version 2.1 or (at your option) later. +Sorry for the inconvenience. diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 5ab225d..0000000 --- a/autogen.sh +++ b/dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -REQUIRED_AUTOMAKE_VERSION=1.10 exec gnome-autogen.sh $@ diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 08a2591..0000000 --- a/configure.ac +++ b/dev/null @@ -1,102 +0,0 @@ -dnl The version system for Mash has a major, minor and micro version -dnl number. The ABI and API is stable only between micro version -dnl numbers (although this will likely change if Mash ever makes a -dnl 1.0.0 release). The micro is odd numbered between releases. Only -dnl on the commit that contains a release should it be an even number. - -m4_define([mash_major_version], [0]) -m4_define([mash_minor_version], [1]) -m4_define([mash_micro_version], [1]) -m4_define([mash_version], - [mash_major_version.mash_minor_version.mash_micro_version]) - -dnl The major and minor currently number define the API version so -dnl these become part of the library name. - -m4_define([mash_api_version], [mash_major_version.mash_minor_version]) - -dnl The interface version is managed manually, separately from the -dnl public package version number. The numbers here are modified -dnl according to the guidelines set out in the libtool manual. This is -dnl different from the semi-automatic usage implemented in Gtk and -dnl Clutter. I did this because I was convinced by the reasoning in -dnl the UProf configure script. The 'current' age here will -dnl effectively always be zero because whenever Mash breaks API it -dnl will change the library name so it's effectively a completely -dnl different library. - -m4_define([mash_lt_current], 0) -m4_define([mash_lt_revision], 0) -m4_define([mash_lt_age], 0) - -AC_INIT([mash], [mash_version]) - -AC_CONFIG_SRCDIR([mash/mash.h]) -AC_CONFIG_HEADER([config.h]) -AC_CONFIG_MACRO_DIR([m4]) - -AM_INIT_AUTOMAKE([1.9]) - -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -AC_PROG_LIBTOOL - -dnl Version number variables for the Makefiles -MASH_MAJOR_VERSION=mash_major_version -MASH_MINOR_VERSION=mash_minor_version -MASH_MICRO_VERSION=mash_micro_version -MASH_VERSION=mash_version -MASH_API_VERSION=mash_api_version -AC_SUBST(MASH_MAJOR_VERSION) -AC_SUBST(MASH_MINOR_VERSION) -AC_SUBST(MASH_MICRO_VERSION) -AC_SUBST(MASH_VERSION) -AC_SUBST(MASH_API_VERSION) - -MASH_LT_CURRENT=mash_lt_current -MASH_LT_REVISION=mash_lt_revision -MASH_LT_AGE=mash_lt_age -AC_SUBST(MASH_LT_CURRENT) -AC_SUBST(MASH_LT_REVISION) -AC_SUBST(MASH_LT_AGE) - -dnl Check if we need to link to -lm -AC_SEARCH_LIBS([atan2f], [m], [have_atan2f=yes], [have_atan2f=no]) -AS_IF([test "x$have_atan2f" = "xno"], - AC_MSG_ERROR([Could not find math library])) - -PKG_PROG_PKG_CONFIG - -PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.16 gobject-2.0 >= 2.16]) -PKG_CHECK_MODULES(CLUTTER, [clutter-1.0 >= 1.5.10]) - -dnl Optionally depend on Mx just for the test-lights example -PKG_CHECK_MODULES(MX, [mx-1.0 >= 1.1.0], [have_mx=yes], [have_mx=no]) - -AS_IF([test "x$have_mx" = "xno"], - AC_MSG_WARN([Mx was not found. It is not required but the lighting example will not be built without it])) - -AM_CONDITIONAL([HAVE_MX], [test "x$have_mx" = "xyes"]) - -# prefixes for fixing gtk-doc references -CLUTTER_PREFIX="`$PKG_CONFIG --variable=prefix clutter-1.0`" -AC_SUBST(CLUTTER_PREFIX) - -GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) - -GOBJECT_INTROSPECTION_CHECK([0.6.1]) - -AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]) - -AC_CONFIG_FILES([ - Makefile - mash/Makefile - mash/rply/Makefile - example/Makefile - docs/Makefile - docs/reference/Makefile - docs/reference/mash-docs.sgml - mash-$MASH_API_VERSION.pc:mash.pc.in -]) - -AC_OUTPUT diff --git a/docs/Makefile.am b/docs/Makefile.am deleted file mode 100644 index f3ddc22..0000000 --- a/docs/Makefile.am +++ b/dev/null @@ -1 +0,0 @@ -SUBDIRS = reference diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am deleted file mode 100644 index 9de8556..0000000 --- a/docs/reference/Makefile.am +++ b/dev/null @@ -1,101 +0,0 @@ -## Process this file with automake to produce Makefile.in - -# We require automake 1.6 at least. -AUTOMAKE_OPTIONS = 1.6 - -# The name of the module, e.g. 'glib'. -DOC_MODULE=mash - -# Uncomment for versioned docs and specify the version of the module, e.g. '2'. -#DOC_MODULE_VERSION=2 - - -# The top-level SGML file. You can change this if you want to. -DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml - -# The directory containing the source code. Relative to $(srcdir). -# gtk-doc will search all .c & .h files beneath here for inline comments -# documenting the functions and macros. -# e.g. DOC_SOURCE_DIR=../../../gtk -DOC_SOURCE_DIR=../../mash - -# Extra options to pass to gtkdoc-scangobj. Not normally needed. -SCANGOBJ_OPTIONS= - -# Extra options to supply to gtkdoc-scan. -# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" -SCAN_OPTIONS=--rebuild-types - -# Extra options to supply to gtkdoc-mkdb. -# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml -MKDB_OPTIONS=--sgml-mode --output-format=xml - -# Extra options to supply to gtkdoc-mktmpl -# e.g. MKTMPL_OPTIONS=--only-section-tmpl -MKTMPL_OPTIONS= - -# Extra options to supply to gtkdoc-mkhtml -MKHTML_OPTIONS= - -# Extra options to supply to gtkdoc-fixref. Not normally needed. -# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html -FIXXREF_OPTIONS= \ - --extra-dir=$(CLUTTER_PREFIX)/share/gtk-doc/html/clutter \ - --extra-dir=$(CLUTTER_PREFIX)/share/gtk-doc/html/cogl - -# Used for dependencies. The docs will be rebuilt if any of these change. -# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h -# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c -HFILE_GLOB= -CFILE_GLOB= - -# Extra header to include when scanning, which are not under DOC_SOURCE_DIR -# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h -EXTRA_HFILES= - -# Header files to ignore when scanning. Use base file name, no paths -# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h -IGNORE_HFILES= \ - mash-enum-types.h \ - rply - -# Images to copy into HTML directory. -# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png -HTML_IMAGES= - -# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). -# e.g. content_files=running.sgml building.sgml changes-2.0.sgml -content_files= - -# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded -# These files must be listed here *and* in content_files -# e.g. expand_content_files=running.sgml -expand_content_files= - -# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. -# Only needed if you are using gtkdoc-scangobj to dynamically query widget -# signals and properties. -# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) -# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) -GTKDOC_CFLAGS=$(GLIB_CFLAGS) $(CLUTTER_CFLAGS) -GTKDOC_LIBS=$(top_builddir)/mash/libmash-@MASH_API_VERSION@.la $(GLIB_LIBS) $(CLUTTER_LIBS) - -# This includes the standard gtk-doc make rules, copied by gtkdocize. -include $(top_srcdir)/gtk-doc.make - -# Other files to distribute -# e.g. EXTRA_DIST += version.xml.in -EXTRA_DIST += - -# Files not to distribute -# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types -# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt -DISTCLEANFILES = $(DOC_MODULE).types - -# Comment this out if you want your docs-status tested during 'make check' -if ENABLE_GTK_DOC -#TESTS_ENVIRONMENT = cd $(srcsrc) -#TESTS = $(GTKDOC_CHECK) -endif - --include $(top_srcdir)/git.mk diff --git a/docs/reference/mash-docs.sgml.in b/docs/reference/mash-docs.sgml.in deleted file mode 100644 index 4661260..0000000 --- a/docs/reference/mash-docs.sgml.in +++ b/dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" - "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" -[ - <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'"> -]> -<book id="index"> - <bookinfo> - <title>Mash Reference Manual</title> - <releaseinfo> - for Mash @VERSION@. - The latest version of this documentation can be found on-line at - <ulink role="online-location" - url="http://www.clutter-project.org/mash/index.html"> - http://www.clutter-project.org/mash/</ulink>. - </releaseinfo> - - <copyright> - <year>2010</year> - <holder>Intel Corporation</holder> - </copyright> - - <legalnotice> - <para> - Permission is granted to copy, distribute and/or modify this - document under the terms of the <citetitle>GNU Free - Documentation License</citetitle>, Version 1.1 or any later - version published by the Free Software Foundation with no - Invariant Sections, no Front-Cover Texts, and no Back-Cover - Texts. You may obtain a copy of the <citetitle>GNU Free - Documentation License</citetitle> from the Free Software - Foundation by visiting <ulink type="http" - url="http://www.fsf.org">their Web site</ulink> or by writing - to: - - <address> - The Free Software Foundation, Inc., - <street>59 Temple Place</street> - Suite 330, - <city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>, - <country>USA</country> - </address> - </para> - </legalnotice> - </bookinfo> - - <chapter> - <title>Models</title> - <xi:include href="xml/mash-model.xml"/> - <xi:include href="xml/mash-data.xml"/> - </chapter> - <chapter> - <title>Lights</title> - <xi:include href="xml/mash-light-set.xml"/> - <xi:include href="xml/mash-light.xml"/> - <xi:include href="xml/mash-directional-light.xml"/> - <xi:include href="xml/mash-point-light.xml"/> - <xi:include href="xml/mash-spot-light.xml"/> - </chapter> - <chapter id="object-tree"> - <title>Object Hierarchy</title> - <xi:include href="xml/tree_index.sgml"/> - </chapter> - <index id="api-index-full"> - <title>API Index</title> - <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include> - </index> -</book> diff --git a/docs/reference/mash-sections.txt b/docs/reference/mash-sections.txt deleted file mode 100644 index f481d55..0000000 --- a/docs/reference/mash-sections.txt +++ b/dev/null @@ -1,167 +0,0 @@ -<SECTION> -<FILE>mash-data</FILE> -<TITLE>MashData</TITLE> -MASH_DATA_ERROR -MashData -MashDataClass -MashDataError -MashDataFlags -mash_data_new -mash_data_load -mash_data_render -mash_data_get_extents -<SUBSECTION Standard> -MASH_DATA -MASH_IS_DATA -MASH_TYPE_DATA -mash_data_get_type -MASH_DATA_CLASS -MASH_IS_DATA_CLASS -MASH_DATA_GET_CLASS - -<SUBSECTION Private> -MashDataPrivate -mash_data_error_quark -</SECTION> - -<SECTION> -<FILE>mash-model</FILE> -<TITLE>MashModel</TITLE> -MashModel -MashModelClass -mash_model_new -mash_model_new_from_file -mash_model_get_material -mash_model_set_material -mash_model_get_data -mash_model_set_data -mash_model_get_fit_to_allocation -mash_model_set_fit_to_allocation -mash_model_get_light_set -mash_model_set_light_set -<SUBSECTION Standard> -MASH_MODEL -MASH_IS_MODEL -MASH_TYPE_MODEL -mash_model_get_type -MASH_MODEL_CLASS -MASH_IS_MODEL_CLASS -MASH_MODEL_GET_CLASS -<SUBSECTION Private> -MashModelPrivate -</SECTION> - -<SECTION> -<FILE>mash-light-set</FILE> -<TITLE>MashLightSet</TITLE> -MashLightSet -MashLightSetClass -mash_light_set_new -mash_light_set_add_light -mash_light_set_remove_light -mash_light_set_begin_paint -<SUBSECTION Standard> -MASH_LIGHT_SET -MASH_IS_LIGHT_SET -MASH_TYPE_LIGHT_SET -mash_light_set_get_type -MASH_LIGHT_SET_CLASS -MASH_IS_LIGHT_SET_CLASS -MASH_LIGHT_SET_GET_CLASS -<SUBSECTION Private> -MashLightSetPrivate -</SECTION> - -<SECTION> -<FILE>mash-light</FILE> -<TITLE>MashLight</TITLE> -MashLight -MashLightClass -mash_light_set_ambient -mash_light_get_ambient -mash_light_set_diffuse -mash_light_get_diffuse -mash_light_set_specular -mash_light_get_specular -<SUBSECTION> -mash_light_generate_shader -mash_light_update_uniforms -mash_light_append_shader -mash_light_get_uniform_location -mash_light_set_direction_uniform -mash_light_get_modelview_matrix -<SUBSECTION Standard> -MASH_LIGHT -MASH_IS_LIGHT -MASH_TYPE_LIGHT -mash_light_get_type -MASH_LIGHT_CLASS -MASH_IS_LIGHT_CLASS -MASH_LIGHT_GET_CLASS -<SUBSECTION Private> -MashLightPrivate -</SECTION> - -<SECTION> -<FILE>mash-directional-light</FILE> -<TITLE>MashDirectionalLight</TITLE> -MashDirectionalLight -MashDirectionalLightClass -mash_directional_light_new -<SUBSECTION Standard> -MASH_DIRECTIONAL_LIGHT -MASH_IS_DIRECTIONAL_LIGHT -MASH_TYPE_DIRECTIONAL_LIGHT -mash_directional_light_get_type -MASH_DIRECTIONAL_LIGHT_CLASS -MASH_IS_DIRECTIONAL_LIGHT_CLASS -MASH_DIRECTIONAL_LIGHT_GET_CLASS -<SUBSECTION Private> -MashDirectionalLightPrivate -</SECTION> - -<SECTION> -<FILE>mash-point-light</FILE> -<TITLE>MashPointLight</TITLE> -MashPointLight -MashPointLightClass -mash_point_light_new -mash_point_light_set_constant_attenuation -mash_point_light_get_constant_attenuation -mash_point_light_set_linear_attenuation -mash_point_light_get_linear_attenuation -mash_point_light_set_quadratic_attenuation -mash_point_light_get_quadratic_attenuation -<SUBSECTION Standard> -MASH_POINT_LIGHT -MASH_IS_POINT_LIGHT -MASH_TYPE_POINT_LIGHT -mash_point_light_get_type -MASH_POINT_LIGHT_CLASS -MASH_IS_POINT_LIGHT_CLASS -MASH_POINT_LIGHT_GET_CLASS -<SUBSECTION Private> -MashPointLightPrivate -</SECTION> - -<SECTION> -<FILE>mash-spot-light</FILE> -<TITLE>MashSpotLight</TITLE> -MashSpotLight -MashSpotLightClass -mash_spot_light_new -mash_spot_light_set_spot_cutoff -mash_spot_light_get_spot_cutoff -mash_spot_light_set_spot_exponent -mash_spot_light_get_spot_exponent -<SUBSECTION Standard> -MASH_SPOT_LIGHT -MASH_IS_SPOT_LIGHT -MASH_TYPE_SPOT_LIGHT -mash_spot_light_get_type -MASH_SPOT_LIGHT_CLASS -MASH_IS_SPOT_LIGHT_CLASS -MASH_SPOT_LIGHT_GET_CLASS -<SUBSECTION Private> -MashSpotLightPrivate -</SECTION> diff --git a/example/Makefile.am b/example/Makefile.am deleted file mode 100644 index 64d6dd6..0000000 --- a/example/Makefile.am +++ b/dev/null @@ -1,35 +0,0 @@ -noinst_PROGRAMS = viewer - -INCLUDES = \ - -I $(top_srcdir) \ - -I $(top_builddir) \ - -I $(top_builddir)/mash - -AM_CPPFLAGS = \ - @CLUTTER_CFLAGS@ - -viewer_SOURCES = \ - viewer.c - -viewer_LDADD = \ - @CLUTTER_LIBS@ \ - $(top_builddir)/mash/libmash-@MASH_API_VERSION@.la - -if HAVE_MX - -AM_CPPFLAGS += \ - @MX_CFLAGS@ - -noinst_PROGRAMS += lights - -lights_SOURCES = \ - lights.c - -lights_LDADD = \ - @CLUTTER_LIBS@ \ - @MX_LIBS@ \ - $(top_builddir)/mash/libmash-@MASH_API_VERSION@.la - -endif # HAVE_MX - -EXTRA_DIST = suzanne.ply diff --git a/example/lights.c b/example/lights.c deleted file mode 100644 index bdde97e..0000000 --- a/example/lights.c +++ b/dev/null @@ -1,618 +0,0 @@ -#include <mx/mx.h> -#include <mash/mash.h> -#include <math.h> - -#define N_LIGHTS 3 -#define N_PAGES (N_LIGHTS + 1) - -/* Since version 1.3.8 of Clutter, Cogl has started using - CoglMaterial* instead of CoglHandle to point to materials. This - doesn't usually cause any problems because CoglHandle is typedef'd - to a gpointer so it gets silently cast to and from - CoglMaterial*. However in this case we are using a function pointer - with CoglHandle as one of the arguments so GCC will give a warning - that the function doesn't match the typedef */ - -#if CLUTTER_CHECK_VERSION (1, 3, 8) -typedef CoglMaterial *MaterialType; -#else -typedef CoglHandle MaterialType; -#endif - -typedef void (* MaterialColorSetFunc) (MaterialType material, - const CoglColor *color); - -typedef void (* MaterialColorGetFunc) (MaterialType material, - CoglColor *color); - -typedef void (* MaterialFloatSetFunc) (MaterialType material, float value); - -typedef float (* MaterialFloatGetFunc) (MaterialType material); - -typedef struct -{ - ClutterActor *lights[N_LIGHTS]; - ClutterActor *model; - CoglHandle light_marker_material; - - ClutterActor *notebook; - ClutterActor *notebook_buttons[N_PAGES]; - ClutterActor *notebook_pages[N_PAGES]; -} Data; - -typedef struct -{ - char *prop_name; - GObject *object; - CoglHandle material; - ClutterActor *rect; - MaterialColorSetFunc set_func; - MaterialColorGetFunc get_func; -} ColorProp; - -typedef struct -{ - ColorProp *prop; - gint comp_num; - ClutterActor *label; -} ColorPropComp; - -typedef struct -{ - char *prop_name; - GObject *object; - CoglHandle material; - ClutterActor *label; - float min, max; - MaterialFloatSetFunc set_func; - MaterialFloatGetFunc get_func; -} FloatProp; - -static void -color_prop_free (ColorProp *prop) -{ - if (prop->object) - g_object_unref (prop->object); - if (prop->material) - cogl_handle_unref (prop->material); - g_free (prop->prop_name); - g_slice_free (ColorProp, prop); -} - -static void -color_prop_comp_free (ColorPropComp *prop_comp) -{ - if (prop_comp->comp_num == 0) - color_prop_free (prop_comp->prop); - - g_slice_free (ColorPropComp, prop_comp); -} - -static void -float_prop_free (FloatProp *prop) -{ - if (prop->object) - g_object_unref (prop->object); - if (prop->material) - cogl_handle_unref (prop->material); - g_free (prop->prop_name); - g_slice_free (FloatProp, prop); -} - -static void -update_prop_comp_label (ColorPropComp *prop_comp, guint8 value) -{ - char *label_text; - - label_text = g_strdup_printf ("%i", value); - mx_label_set_text (MX_LABEL (prop_comp->label), label_text); - g_free (label_text); -} - -static void -color_prop_value_cb (MxSlider *slider, - GParamSpec *pspec, - ColorPropComp *prop_comp) -{ - float value = mx_slider_get_value (slider) * 255.0f + 0.5f; - ColorProp *prop = prop_comp->prop; - - if (prop->object) - { - ClutterColor *color; - g_object_get (prop->object, prop->prop_name, &color, NULL); - ((guint8 *) color)[prop_comp->comp_num] = value; - clutter_rectangle_set_color (CLUTTER_RECTANGLE (prop->rect), color); - g_object_set (prop->object, prop->prop_name, color, NULL); - clutter_color_free (color); - } - else - { - ClutterColor color; - CoglColor cogl_color; - - prop->get_func (prop->material, &cogl_color); - - color.red = cogl_color_get_red_byte (&cogl_color); - color.green = cogl_color_get_green_byte (&cogl_color); - color.blue = cogl_color_get_blue_byte (&cogl_color); - color.alpha = 255; - - ((guint8 *) &color)[prop_comp->comp_num] = value; - - cogl_color_set_from_4ub (&cogl_color, - color.red, - color.green, - color.blue, - 255); - - clutter_rectangle_set_color (CLUTTER_RECTANGLE (prop->rect), &color); - - prop->set_func (prop->material, &cogl_color); - } - - update_prop_comp_label (prop_comp, value); -} - -static void -update_float_prop_label (FloatProp *prop, float value) -{ - char *value_text = g_strdup_printf ("%.2f", value); - mx_label_set_text (MX_LABEL (prop->label), value_text); - g_free (value_text); -} - -static void -float_prop_value_cb (MxSlider *slider, - GParamSpec *pspec, - FloatProp *prop) -{ - float value = mx_slider_get_value (slider); - - value = value * (prop->max - prop->min) + prop->min; - - if (prop->object) - g_object_set (prop->object, prop->prop_name, value, NULL); - else if (prop->material) - prop->set_func (prop->material, value); - - update_float_prop_label (prop, value); -} - -static void -add_color_prop_base (ClutterActor *table, - const char *name, - ColorProp *prop, - const ClutterColor *value) -{ - int table_y = mx_table_get_row_count (MX_TABLE (table)); - ClutterActor *label; - static const char *color_names[] = { "red", "green", "blue" }; - int i; - - label = mx_label_new_with_text (name); - mx_table_add_actor (MX_TABLE (table), label, table_y, 0); - prop->rect = clutter_rectangle_new (); - clutter_rectangle_set_color (CLUTTER_RECTANGLE (prop->rect), value); - clutter_actor_set_size (prop->rect, 20, 0); - mx_table_add_actor (MX_TABLE (table), prop->rect, table_y++, 1); - - for (i = 0; i < G_N_ELEMENTS (color_names); i++) - { - ClutterActor *slider; - char *label_name = g_strconcat (name, " ", color_names[i], NULL); - ColorPropComp *prop_comp = g_slice_new (ColorPropComp); - - label = mx_label_new_with_text (label_name); - mx_table_add_actor (MX_TABLE (table), label, table_y, 0); - g_free (label_name); - - slider = mx_slider_new (); - mx_table_add_actor (MX_TABLE (table), slider, table_y, 1); - - mx_slider_set_value (MX_SLIDER (slider), - ((guint8 *) value)[i] / 255.0f); - - prop_comp->comp_num = i; - prop_comp->prop = prop; - - prop_comp->label = mx_label_new (); - mx_table_add_actor (MX_TABLE (table), prop_comp->label, table_y, 2); - update_prop_comp_label (prop_comp, ((guint8 *) value)[i]); - - g_signal_connect_data (slider, "notify::value", - G_CALLBACK (color_prop_value_cb), - prop_comp, - (GClosureNotify) color_prop_comp_free, - 0); - - table_y++; - } -} - -static void -add_color_prop (ClutterActor *table, - const char *name, - GObject *object, - const char *prop_name) -{ - ColorProp *prop = g_slice_new (ColorProp); - ClutterColor *value; - - prop->prop_name = g_strdup (prop_name); - prop->object = g_object_ref (object); - prop->material = COGL_INVALID_HANDLE; - - g_object_get (object, prop_name, &value, NULL); - - add_color_prop_base (table, name, prop, value); - - clutter_color_free (value); -} - -static void -add_material_color_prop (ClutterActor *table, - const char *name, - CoglHandle material, - MaterialColorSetFunc set_func, - MaterialColorGetFunc get_func) -{ - ColorProp *prop = g_slice_new (ColorProp); - ClutterColor value; - CoglColor cogl_color; - - prop->prop_name = NULL; - prop->material = cogl_handle_ref (material); - prop->object = NULL; - prop->set_func = set_func; - prop->get_func = get_func; - - get_func (material, &cogl_color); - value.red = cogl_color_get_red_byte (&cogl_color); - value.green = cogl_color_get_green_byte (&cogl_color); - value.blue = cogl_color_get_blue_byte (&cogl_color); - value.alpha = cogl_color_get_alpha_byte (&cogl_color); - - add_color_prop_base (table, name, prop, &value); -} - -static void -add_float_prop_base (ClutterActor *table, - const char *name, - FloatProp *prop, - float value) -{ - int table_y = mx_table_get_row_count (MX_TABLE (table)); - ClutterActor *label; - ClutterActor *slider; - - label = mx_label_new_with_text (name); - mx_table_add_actor (MX_TABLE (table), label, table_y, 0); - - slider = mx_slider_new (); - mx_table_add_actor (MX_TABLE (table), slider, table_y, 1); - - prop->label = mx_label_new (); - mx_table_add_actor (MX_TABLE (table), prop->label, table_y, 2); - - mx_slider_set_value (MX_SLIDER (slider), - (value - prop->min) / (prop->max - prop->min)); - - update_float_prop_label (prop, value); - - g_signal_connect_data (slider, "notify::value", - G_CALLBACK (float_prop_value_cb), - prop, - (GClosureNotify) float_prop_free, - 0); -} - -static void -add_float_prop (ClutterActor *table, - const char *name, - GObject *object, - const char *prop_name, - float min, - float max) -{ - FloatProp *prop = g_slice_new (FloatProp); - float value; - - prop->prop_name = g_strdup (prop_name); - prop->object = g_object_ref (object); - prop->material = COGL_INVALID_HANDLE; - prop->min = min; - prop->max = max; - - g_object_get (object, prop_name, &value, NULL); - - add_float_prop_base (table, name, prop, value); -} - -static void -add_material_float_prop (ClutterActor *table, - const char *name, - CoglHandle material, - float min, - float max, - MaterialFloatSetFunc set_func, - MaterialFloatGetFunc get_func) -{ - FloatProp *prop = g_slice_new (FloatProp); - float value; - - prop->prop_name = NULL; - prop->object = NULL; - prop->material = cogl_handle_ref (material); - prop->min = min; - prop->max = max; - prop->set_func = set_func; - prop->get_func = get_func; - - value = get_func (material); - - add_float_prop_base (table, name, prop, value); -} - -static void -notebook_button_cb (ClutterActor *button, GParamSpec *spec, Data *data) -{ - if (mx_button_get_toggled (MX_BUTTON (button))) - { - int i; - - for (i = 0; i < N_PAGES; i++) - if (data->notebook_buttons[i] == button) - mx_notebook_set_current_page (MX_NOTEBOOK (data->notebook), - data->notebook_pages[i]); - else - mx_button_set_toggled (MX_BUTTON (button), FALSE); - } -} - -static gboolean -motion_event_cb (ClutterActor *stage, - const ClutterButtonEvent *event, - Data *data) -{ - int i; - - /* Move all of the lights to follow the cursor */ - for (i = 0; i < N_LIGHTS; i++) - clutter_actor_set_position (data->lights[i], - event->x, - event->y); - - return FALSE; -} - -int -main (int argc, char **argv) -{ - ClutterActor *stage = stage; - ClutterActor *side_box; - ClutterActor *button_box; - ClutterActor *box; - ClutterAnimation *anim; - MashLightSet *light_set; - MxStyle *style; - GError *error = NULL; - Data data; - int i; - - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; - - style = mx_style_get_default (); - if (!mx_style_load_from_file (style, "lights.css", - &error)) - { - g_warning ("Error setting style: %s", error->message); - g_clear_error (&error); - } - - stage = clutter_stage_get_default (); - clutter_actor_set_size (stage, 800, 600); - - side_box = mx_table_new (); - clutter_actor_set_name (side_box, "side-box"); - clutter_container_add_actor (CLUTTER_CONTAINER (stage), side_box); - clutter_actor_set_size (side_box, 300, - clutter_actor_get_height (stage)); - clutter_actor_set_x (side_box, - clutter_actor_get_width (stage) - - clutter_actor_get_width (side_box)); - - button_box = mx_table_new (); - mx_table_add_actor (MX_TABLE (side_box), button_box, 0, 0); - - data.notebook = mx_notebook_new (); - - mx_table_add_actor (MX_TABLE (side_box), data.notebook, 1, 0); - - data.model = mash_model_new_from_file (MASH_DATA_NONE, - argc > 1 - ? argv[1] - : "suzanne.ply", - &error); - if (data.model == NULL) - { - g_warning ("Error loading model: %s", error->message); - g_clear_error (&error); - return 1; - } - - light_set = mash_light_set_new (); - - box = clutter_box_new (clutter_fixed_layout_new ()); - - clutter_actor_set_size (data.model, 400, 400); - clutter_actor_set_position (data.model, 50.0, 100.0); - clutter_container_add_actor (CLUTTER_CONTAINER (box), data.model); - - clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); - - g_signal_connect_swapped (box, "paint", - G_CALLBACK (cogl_set_depth_test_enabled), - GINT_TO_POINTER (TRUE)); - g_signal_connect_data (box, "paint", - G_CALLBACK (cogl_set_depth_test_enabled), - GINT_TO_POINTER (FALSE), NULL, - G_CONNECT_AFTER | G_CONNECT_SWAPPED); - - data.light_marker_material = cogl_material_new (); - { - CoglColor color; - cogl_color_set_from_4ub (&color, 255, 0, 0, 255); - /* Use the layer state to ignore the vertex color from the shader so - that the light marker won't itself be lit */ - cogl_material_set_layer_combine_constant (data.light_marker_material, 0, - &color); - cogl_material_set_layer_combine (data.light_marker_material, 0, - "RGBA = REPLACE(CONSTANT)", - NULL); - } - - clutter_actor_set_rotation (data.model, CLUTTER_Y_AXIS, - 0.0f, - clutter_actor_get_width (data.model) / 2.0f, - 0.0f, - 0.0f); - - anim = clutter_actor_animate (data.model, CLUTTER_LINEAR, 3000, - "rotation-angle-y", 360.0f, - NULL); - clutter_animation_set_loop (anim, TRUE); - - for (i = 0; i < N_LIGHTS; i++) - { - ClutterActor *table = mx_table_new (); - ClutterActor *button; - static ClutterActor *(* constructors[N_LIGHTS]) (void) = - { mash_directional_light_new, - mash_point_light_new, - mash_spot_light_new }; - static const ClutterColor black = { 0, 0, 0, 255 }; - - data.lights[i] = constructors[i] (); - - button = mx_button_new_with_label (G_OBJECT_TYPE_NAME (data.lights[i])); - mx_table_add_actor (MX_TABLE (button_box), button, i, 0); - - /* Default to disable all of the lights */ - g_object_set (data.lights[i], - "ambient", &black, - "diffuse", &black, - "specular", &black, - NULL); - - data.notebook_buttons[i] = button; - - clutter_container_add_actor (CLUTTER_CONTAINER (box), data.lights[i]); - mash_light_set_add_light (light_set, MASH_LIGHT (data.lights[i])); - - add_color_prop (table, "ambient light", - G_OBJECT (data.lights[i]), "ambient"); - add_color_prop (table, "diffuse light", - G_OBJECT (data.lights[i]), "diffuse"); - add_color_prop (table, "specular light", - G_OBJECT (data.lights[i]), "specular"); - - if (MASH_IS_POINT_LIGHT (data.lights[i])) - { - add_float_prop (table, "constant attenuation", - G_OBJECT (data.lights[i]), "constant-attenuation", - 0.0f, 10.0f); - add_float_prop (table, "linear attenuation", - G_OBJECT (data.lights[i]), "linear-attenuation", - 0.0f, 10.0f); - add_float_prop (table, "quadratic attenuation", - G_OBJECT (data.lights[i]), "quadratic-attenuation", - 0.0f, 10.0f); - } - - if (MASH_IS_SPOT_LIGHT (data.lights[i])) - { - clutter_actor_set_x (data.lights[i], 250); - - add_float_prop (table, "spot cutoff", - G_OBJECT (data.lights[i]), "spot-cutoff", - 0.0f, 90.0f); - add_float_prop (table, "spot exponent", - G_OBJECT (data.lights[i]), "spot-exponent", - 0.0f, 128.0f); - } - - clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); - - data.notebook_pages[i] = table; - } - - { - ClutterActor *button; - ClutterActor *table; - CoglHandle material; - float maximum_shininess; - - material = mash_model_get_material (MASH_MODEL (data.model)); - - /* Before version 1.3.10 on the 1.3 branch and 1.2.14 on the 1.2 - branch Cogl would remap the shininess property to the range - [0,1]. After this it is just a value greater or equal to zero - (but GL imposes a limit of 128.0) */ - if (clutter_check_version (1, 3, 9) - || (clutter_major_version == 1 - && clutter_minor_version == 2 - && clutter_micro_version >= 13)) - maximum_shininess = 128.0f; - else - maximum_shininess = 1.0f; - - cogl_material_set_shininess (material, maximum_shininess); - - button = mx_button_new_with_label ("Material"); - data.notebook_buttons[i] = button; - mx_table_add_actor (MX_TABLE (button_box), button, i, 0); - table = mx_table_new (); - data.notebook_pages[i] = table; - clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); - - add_material_color_prop (table, "diffuse", material, - cogl_material_set_diffuse, - cogl_material_get_diffuse); - add_material_color_prop (table, "ambient", material, - cogl_material_set_ambient, - cogl_material_get_ambient); - add_material_color_prop (table, "specular", material, - cogl_material_set_specular, - cogl_material_get_specular); - add_material_float_prop (table, "shininess", material, - 0.0f, maximum_shininess, - cogl_material_set_shininess, - cogl_material_get_shininess); - } - - mash_model_set_light_set (MASH_MODEL (data.model), light_set); - g_object_unref (light_set); - - for (i = 0; i < N_PAGES; i++) - { - g_signal_connect (data.notebook_buttons[i], "notify::toggled", - G_CALLBACK (notebook_button_cb), &data); - mx_button_set_is_toggle (MX_BUTTON (data.notebook_buttons[i]), TRUE); - } - - mx_button_set_toggled (MX_BUTTON (data.notebook_buttons[0]), TRUE); - - g_signal_connect (stage, "motion-event", - G_CALLBACK (motion_event_cb), - &data); - - clutter_actor_show (stage); - - clutter_main (); - - cogl_handle_unref (data.light_marker_material); - - return 0; -} diff --git a/example/lights.css b/example/lights.css deleted file mode 100644 index a3bcace..0000000 --- a/example/lights.css +++ b/dev/null @@ -1,3 +0,0 @@ -#side-box { - background-color: #c0c0ff; -} diff --git a/example/suzanne.ply b/example/suzanne.ply deleted file mode 100644 index 4e1aaf2..0000000 --- a/example/suzanne.ply +++ b/dev/null @@ -1,1020 +0,0 @@ -ply -format ascii 1.0 -comment Created by Blender3D 249 - www.blender.org, source file: -element vertex 507 -property float x -property float y -property float z -property float nx -property float ny -property float nz -element face 500 -property list uchar uint vertex_indices -end_header -1.066808 -0.378677 1.597090 0.987976 -0.010102 0.154088 -1.035558 -0.456802 1.604902 0.722587 -0.669759 0.171026 -1.098058 -0.527115 1.526777 0.601306 -0.478561 0.639790 -1.160558 -0.378677 1.511152 0.782739 -0.003113 0.622303 -0.098058 -0.527115 1.526777 -0.601306 -0.478561 0.639790 -0.160558 -0.456802 1.604902 -0.722587 -0.669759 0.171026 -0.129308 -0.378677 1.597090 -0.987976 -0.010102 0.154088 -0.035558 -0.378677 1.511152 -0.782739 -0.003113 0.622303 -1.144933 -0.566177 1.417402 0.657216 -0.579058 0.482406 -1.223058 -0.378677 1.401777 0.868435 -0.004364 0.495773 -0.051183 -0.566177 1.417402 -0.657216 -0.579058 0.482406 --0.026942 -0.378677 1.401777 -0.868435 -0.004364 0.495773 -0.949621 -0.589615 1.558027 0.114994 -0.722190 0.682028 -0.949621 -0.644302 1.456465 0.077670 -0.870296 0.486343 -0.246496 -0.644302 1.456465 -0.077670 -0.870296 0.486343 -0.246496 -0.589615 1.558027 -0.114994 -0.722190 0.682028 -0.949621 -0.488052 1.620527 0.023530 -0.972900 0.229926 -0.246496 -0.488052 1.620527 -0.023530 -0.972900 0.229926 -0.871496 -0.456802 1.636152 -0.662374 -0.691763 0.287545 -0.801183 -0.527115 1.581465 -0.431898 -0.519486 0.737236 -0.394933 -0.527115 1.581465 0.431898 -0.519486 0.737236 -0.324621 -0.456802 1.636152 0.662374 -0.691763 0.287545 -0.754308 -0.566177 1.487715 -0.557054 -0.629994 0.541093 -0.441808 -0.566177 1.487715 0.557054 -0.629994 0.541093 -0.738683 -0.378677 1.581465 -0.661702 -0.003235 0.749718 -0.676183 -0.378677 1.495527 -0.814814 -0.004639 0.579699 -0.519933 -0.378677 1.495527 0.814814 -0.004639 0.579699 -0.457433 -0.378677 1.581465 0.661702 -0.003235 0.749718 -0.840246 -0.378677 1.636152 -0.956328 -0.010956 0.292062 -0.355871 -0.378677 1.636152 0.956328 -0.010956 0.292062 -0.871496 -0.292740 1.636152 -0.671163 0.687918 0.276162 -0.801183 -0.230240 1.581465 -0.429914 0.514573 0.741844 -0.394933 -0.230240 1.581465 0.429914 0.514573 0.741844 -0.324621 -0.292740 1.636152 0.671163 0.687918 0.276162 -0.754308 -0.183365 1.487715 -0.545335 0.612018 0.572710 -0.441808 -0.183365 1.487715 0.545335 0.612018 0.572710 -0.949621 -0.167740 1.558027 0.115513 0.716453 0.687948 -0.949621 -0.105240 1.456465 0.086001 0.840602 0.534745 -0.246496 -0.105240 1.456465 -0.086001 0.840602 0.534745 -0.246496 -0.167740 1.558027 -0.115513 0.716453 0.687948 -0.949621 -0.261490 1.620527 0.019715 0.977477 0.210089 -0.246496 -0.261490 1.620527 -0.019715 0.977477 0.210089 -1.035558 -0.292740 1.604902 0.728233 0.666128 0.160955 -1.098058 -0.230240 1.526777 0.601123 0.473678 0.643605 -0.098058 -0.230240 1.526777 -0.601123 0.473678 0.643605 -0.160558 -0.292740 1.604902 -0.728233 0.666128 0.160955 -1.144933 -0.183365 1.417402 0.653920 0.559496 0.509201 -0.051183 -0.183365 1.417402 -0.653920 0.559496 0.509201 -1.043371 -0.284927 1.620527 0.731864 0.581988 0.354411 -1.074621 -0.378677 1.612715 0.942412 -0.012391 0.334178 -0.152746 -0.284927 1.620527 -0.731864 0.581988 0.354411 -0.121496 -0.378677 1.612715 -0.942412 -0.012391 0.334178 -0.949621 -0.245865 1.643965 0.086215 0.899411 0.428480 -0.246496 -0.245865 1.643965 -0.086215 0.899411 0.428480 -0.863683 -0.284927 1.659590 -0.585681 0.630634 0.509140 -0.332433 -0.284927 1.659590 0.585681 0.630634 0.509140 -0.824621 -0.378677 1.659590 -0.855861 -0.013886 0.516953 -0.371496 -0.378677 1.659590 0.855861 -0.013886 0.516953 -0.863683 -0.464615 1.659590 -0.577105 -0.642933 0.503525 -0.332433 -0.464615 1.659590 0.577105 -0.642933 0.503525 -0.949621 -0.503677 1.643965 0.084780 -0.902005 0.423261 -0.246496 -0.503677 1.643965 -0.084780 -0.902005 0.423261 -1.043371 -0.464615 1.620527 0.723075 -0.595386 0.350169 -0.152746 -0.464615 1.620527 -0.723075 -0.595386 0.350169 -0.949621 -0.378677 1.667402 0.189764 -0.003571 0.981811 -0.246496 -0.378677 1.667402 -0.189764 -0.003571 0.981811 -0.777746 -1.589615 1.393965 0.152806 -0.976196 0.153874 -0.762121 -1.550552 1.472090 0.153172 -0.764061 0.626667 -0.598058 -1.566177 1.479902 0.000000 -0.790765 0.612079 -0.598058 -1.605240 1.417402 0.000000 -0.982116 0.188147 -0.433996 -1.550552 1.472090 -0.153172 -0.764061 0.626667 -0.418371 -1.589615 1.393965 -0.152806 -0.976196 0.153874 -0.926183 -1.566177 1.362715 0.622059 -0.756493 0.201727 -0.832433 -1.534927 1.472090 0.345653 -0.570208 0.745201 -0.363683 -1.534927 1.472090 -0.345653 -0.570208 0.745201 -0.269933 -1.566177 1.362715 -0.622059 -0.756493 0.201727 -0.965246 -1.511490 1.370527 0.972228 -0.105045 0.209113 -0.863683 -1.441177 1.503340 0.521104 -0.236183 0.820124 -0.332433 -1.441177 1.503340 -0.521104 -0.236183 0.820124 -0.230871 -1.511490 1.370527 -0.972228 -0.105045 0.209113 -0.949621 -1.316177 1.409590 0.981689 0.098209 0.163152 -0.848058 -1.323990 1.526777 0.569689 -0.030732 0.821284 -0.348058 -1.323990 1.526777 -0.569689 -0.030732 0.821284 -0.246496 -1.316177 1.409590 -0.981689 0.098209 0.163152 -0.910558 -1.058365 1.409590 0.959136 0.242775 0.145268 -0.808996 -1.066177 1.550215 0.584613 0.110233 0.803766 -0.387121 -1.066177 1.550215 -0.584613 0.110233 0.803766 -0.285558 -1.058365 1.409590 -0.959136 0.242775 0.145268 -0.801183 -0.808365 1.401777 0.887234 -0.449416 0.103977 -1.035558 -0.761490 1.370527 0.370678 -0.926145 0.069582 -0.996496 -0.667740 1.511152 0.385968 -0.463973 0.797296 -0.723058 -0.722427 1.651777 0.183203 -0.202307 0.962004 -0.199621 -0.667740 1.511152 -0.385968 -0.463973 0.797296 -0.160558 -0.761490 1.370527 -0.370678 -0.926145 0.069582 -0.394933 -0.808365 1.401777 -0.887234 -0.449416 0.103977 -0.473058 -0.722427 1.651777 -0.183203 -0.202307 0.962004 -1.230871 -0.659927 1.378340 0.602344 -0.790857 0.108097 -1.215246 -0.566177 1.464277 0.465285 -0.402997 0.788079 --0.019129 -0.566177 1.464277 -0.465285 -0.402997 0.788079 --0.034754 -0.659927 1.378340 -0.602344 -0.790857 0.108097 -1.426183 -0.472427 1.284590 0.889431 -0.445601 0.101535 -1.324621 -0.417740 1.440840 0.518754 -0.304361 0.798883 --0.128504 -0.417740 1.440840 -0.518754 -0.304361 0.798883 --0.230067 -0.472427 1.284590 -0.889431 -0.445601 0.101535 -1.457433 -0.191177 1.433027 0.886013 0.399396 0.235359 -1.340246 -0.245865 1.495527 0.424543 -0.214423 0.879635 --0.144129 -0.245865 1.495527 -0.424543 -0.214423 0.879635 --0.261317 -0.191177 1.433027 -0.886013 0.399396 0.235359 -1.308996 -0.136490 1.464277 0.506607 0.835017 0.214637 -1.285558 -0.206802 1.565840 0.330638 -0.067354 0.941343 --0.089442 -0.206802 1.565840 -0.330638 -0.067354 0.941343 --0.112879 -0.136490 1.464277 -0.506607 0.835017 0.214637 -1.090246 -0.019302 1.526777 0.590136 0.791589 0.158391 -1.035558 -0.073990 1.636152 0.326182 -0.009033 0.945250 -0.160558 -0.073990 1.636152 -0.326182 -0.009033 0.945250 -0.105871 -0.019302 1.526777 -0.590136 0.791589 0.158391 -0.918371 0.136948 1.573652 0.304239 0.930296 0.204779 -0.910558 0.019760 1.675215 0.225379 0.056307 0.972625 -0.285558 0.019760 1.675215 -0.225379 0.056307 0.972625 -0.277746 0.136948 1.573652 -0.304239 0.930296 0.204779 -0.754308 0.097885 1.597090 -0.632191 0.751671 0.187872 -0.801183 -0.003677 1.690840 -0.003998 0.040407 0.999146 -0.394933 -0.003677 1.690840 0.003998 0.040407 0.999146 -0.441808 0.097885 1.597090 0.632191 0.751671 0.187872 -0.660558 -0.128677 1.589277 -0.783776 0.597674 0.168676 -0.699621 -0.191177 1.683027 -0.136662 0.018342 0.990417 -0.496496 -0.191177 1.683027 0.136662 0.018342 0.990417 -0.535558 -0.128677 1.589277 0.783776 0.597674 0.168676 -0.598058 -0.191177 1.581465 0.000000 0.970092 0.242714 -0.598058 -0.269302 1.659590 0.000000 -0.052767 0.998596 -0.762121 -0.206802 1.612715 0.195318 -0.148320 0.969451 -0.848058 -0.152115 1.597090 0.249855 -0.069094 0.965789 -0.348058 -0.152115 1.597090 -0.249855 -0.069094 0.965789 -0.433996 -0.206802 1.612715 -0.195318 -0.148320 0.969451 -0.926183 -0.144302 1.581465 0.165838 -0.008484 0.986114 -0.269933 -0.144302 1.581465 -0.165838 -0.008484 0.986114 -1.027746 -0.183365 1.558027 0.189398 -0.005219 0.981872 -0.168371 -0.183365 1.558027 -0.189398 -0.005219 0.981872 -1.199621 -0.245865 1.503340 0.310984 -0.166540 0.935697 --0.003504 -0.245865 1.503340 -0.310984 -0.166540 0.935697 -1.238683 -0.323990 1.487715 0.387616 -0.201270 0.899564 --0.042567 -0.323990 1.487715 -0.387616 -0.201270 0.899564 -1.223058 -0.433365 1.487715 0.458663 -0.230628 0.858119 --0.026942 -0.433365 1.487715 -0.458663 -0.230628 0.858119 -1.090246 -0.558365 1.511152 0.434614 -0.380993 0.816034 -0.105871 -0.558365 1.511152 -0.434614 -0.380993 0.816034 -0.973058 -0.605240 1.542402 0.268868 -0.433882 0.859890 -0.223058 -0.605240 1.542402 -0.268868 -0.433882 0.859890 -0.801183 -0.527115 1.581465 -0.139805 -0.269326 0.952818 -0.394933 -0.527115 1.581465 0.139805 -0.269326 0.952818 -0.762121 -0.480240 1.589277 -0.327006 -0.184149 0.926878 -0.598058 -0.573990 1.565840 0.000000 -0.031190 0.999512 -0.433996 -0.480240 1.589277 0.327006 -0.184149 0.926878 -0.723058 -0.316177 1.604902 -0.002930 -0.183660 0.982971 -0.473058 -0.316177 1.604902 0.002930 -0.183660 0.982971 -0.598058 -0.409927 1.604902 0.000000 -0.223151 0.974761 -0.730871 -0.409927 1.597090 -0.182928 -0.199255 0.962706 -0.465246 -0.409927 1.597090 0.182928 -0.199255 0.962706 -0.660558 -1.503677 1.534590 -0.030854 -0.322977 0.945891 -0.598058 -1.511490 1.526777 0.000000 -0.284494 0.958647 -0.535558 -1.503677 1.534590 0.030854 -0.322977 0.945891 -0.715246 -1.456802 1.550215 0.019715 -0.300668 0.953520 -0.480871 -1.456802 1.550215 -0.019715 -0.300668 0.953520 -0.707433 -1.339615 1.573652 0.149632 -0.263649 0.952910 -0.488683 -1.339615 1.573652 -0.149632 -0.263649 0.952910 -0.676183 -1.066177 1.589277 0.149754 0.003906 0.988708 -0.715246 -1.308365 1.573652 0.159825 -0.056490 0.985504 -0.480871 -1.308365 1.573652 -0.159825 -0.056490 0.985504 -0.519933 -1.066177 1.589277 -0.149754 0.003906 0.988708 -0.683996 -0.909927 1.581465 0.503586 -0.379254 0.776208 -0.598058 -0.948990 1.581465 0.000000 -0.558824 0.829249 -0.598058 -1.066177 1.589277 0.000000 -0.004089 0.999969 -0.512121 -0.909927 1.581465 -0.503586 -0.379254 0.776208 -0.598058 -1.300552 1.573652 0.000000 -0.032838 0.999451 -0.598058 -1.386490 1.573652 0.000000 -0.354869 0.934904 -0.723058 -0.847427 1.589277 0.747917 -0.343333 0.568072 -0.730871 -0.847427 1.636152 0.925962 -0.243446 0.288552 -0.691808 -0.894302 1.620527 0.520737 -0.745781 0.415448 -0.504308 -0.894302 1.620527 -0.520737 -0.745781 0.415448 -0.465246 -0.847427 1.636152 -0.925962 -0.243446 0.288552 -0.473058 -0.847427 1.589277 -0.747917 -0.343333 0.568072 -0.699621 -0.769302 1.581465 0.282846 0.414136 0.865108 -0.707433 -0.753677 1.620527 0.637928 0.746513 0.189001 -0.488683 -0.753677 1.620527 -0.637928 0.746513 0.189001 -0.496496 -0.769302 1.581465 -0.282846 0.414136 0.865108 -0.598058 -0.761490 1.581465 0.000000 0.818537 0.574419 -0.637121 -0.745865 1.620527 -0.431745 0.848659 0.305490 -0.558996 -0.745865 1.620527 0.431745 0.848659 0.305490 -0.598058 -0.816177 1.589277 0.000000 0.759239 0.650777 -0.598058 -0.808365 1.636152 0.000000 0.782128 0.623066 -0.598058 -0.941177 1.620527 0.000000 -0.827143 0.561968 -0.676183 -0.870865 1.643965 0.243599 -0.579913 0.777367 -0.598058 -0.909927 1.643965 0.000000 -0.502182 0.864742 -0.519933 -0.870865 1.643965 -0.243599 -0.579913 0.777367 -0.598058 -0.823990 1.667402 0.000000 0.180975 0.983459 -0.644933 -0.769302 1.651777 -0.189642 0.612110 0.767663 -0.551183 -0.769302 1.651777 0.189642 0.612110 0.767663 -0.691808 -0.777115 1.651777 0.338633 0.488479 0.804132 -0.504308 -0.777115 1.651777 -0.338633 0.488479 0.804132 -0.707433 -0.847427 1.667402 0.366924 -0.176977 0.913236 -0.488683 -0.847427 1.667402 -0.366924 -0.176977 0.913236 -0.762121 -0.863052 1.550215 0.632679 -0.046083 0.773003 -0.433996 -0.863052 1.550215 -0.632679 -0.046083 0.773003 -0.777746 -0.933365 1.550215 0.655019 0.129673 0.744377 -0.418371 -0.933365 1.550215 -0.655019 0.129673 0.744377 -0.855871 -0.933365 1.393965 0.938231 0.321360 0.128025 -0.340246 -0.933365 1.393965 -0.938231 0.321360 0.128025 -0.832433 -0.870865 1.393965 0.953887 0.275491 0.119144 -0.363683 -0.870865 1.393965 -0.953887 0.275491 0.119144 -0.598058 -1.394302 1.558027 0.000000 -0.885037 0.465438 -0.691808 -1.363052 1.565840 -0.237892 -0.684866 0.688711 -0.504308 -1.363052 1.565840 0.237892 -0.684866 0.688711 -0.691808 -1.441177 1.550215 -0.711051 0.136143 0.689810 -0.504308 -1.441177 1.550215 0.711051 0.136143 0.689810 -0.644933 -1.488052 1.526777 -0.386242 0.552995 0.738212 -0.551183 -1.488052 1.526777 0.386242 0.552995 0.738212 -0.598058 -1.495865 1.526777 0.000000 0.676138 0.736747 -0.644933 -1.472427 1.472090 -0.264840 0.390210 0.881771 -0.598058 -1.480240 1.472090 0.000000 0.469314 0.882992 -0.551183 -1.472427 1.472090 0.264840 0.390210 0.881771 -0.691808 -1.433365 1.479902 -0.811975 0.187750 0.552629 -0.504308 -1.433365 1.479902 0.811975 0.187750 0.552629 -0.691808 -1.370865 1.503340 -0.202979 -0.609577 0.766259 -0.504308 -1.370865 1.503340 0.202979 -0.609577 0.766259 -0.598058 -1.402115 1.495527 0.000000 -0.757225 0.653127 -0.785558 -0.464615 1.612715 0.072481 -0.038026 0.996612 -0.769933 -0.402115 1.620527 0.234504 -0.090915 0.967834 -0.410558 -0.464615 1.612715 -0.072481 -0.038026 0.996612 -0.426183 -0.402115 1.620527 -0.234504 -0.090915 0.967834 -0.777746 -0.323990 1.620527 0.270791 -0.124943 0.954466 -0.418371 -0.323990 1.620527 -0.270791 -0.124943 0.954466 -0.808996 -0.245865 1.620527 0.214789 -0.129521 0.968017 -0.387121 -0.245865 1.620527 -0.214789 -0.129521 0.968017 -0.824621 -0.511490 1.620527 0.054933 -0.042543 0.997559 -0.371496 -0.511490 1.620527 -0.054933 -0.042543 0.997559 -0.973058 -0.558365 1.581465 0.205725 -0.055239 0.977020 -0.223058 -0.558365 1.581465 -0.205725 -0.055239 0.977020 -1.074621 -0.519302 1.558027 0.258431 0.017914 0.965850 -0.121496 -0.519302 1.558027 -0.258431 0.017914 0.965850 -1.176183 -0.425552 1.518965 0.192907 -0.017640 0.981048 -0.019933 -0.425552 1.518965 -0.192907 -0.017640 0.981048 -1.183996 -0.331802 1.526777 0.123569 -0.071505 0.989746 -0.012121 -0.331802 1.526777 -0.123569 -0.071505 0.989746 -1.160558 -0.269302 1.534590 0.223121 -0.140843 0.964538 -0.035558 -0.269302 1.534590 -0.223121 -0.140843 0.964538 -1.019933 -0.222427 1.612715 0.169622 -0.118595 0.978332 -0.176183 -0.222427 1.612715 -0.169622 -0.118595 0.978332 -0.933996 -0.191177 1.597090 0.135289 0.017884 0.990631 -0.262121 -0.191177 1.597090 -0.135289 0.017884 0.990631 -0.871496 -0.198990 1.612715 0.201972 -0.018036 0.979217 -0.324621 -0.198990 1.612715 -0.201972 -0.018036 0.979217 -0.832433 -0.261490 1.597090 0.506912 -0.382427 0.772485 -0.879308 -0.222427 1.604902 0.305429 -0.340159 0.889370 -0.363683 -0.261490 1.597090 -0.506912 -0.382427 0.772485 -0.316808 -0.222427 1.604902 -0.305429 -0.340159 0.889370 -0.933996 -0.214615 1.589277 0.014313 -0.486435 0.873562 -0.262121 -0.214615 1.589277 -0.014313 -0.486435 0.873562 -1.012121 -0.230240 1.589277 -0.142277 -0.760186 0.633900 -0.183996 -0.230240 1.589277 0.142277 -0.760186 0.633900 -1.129308 -0.284927 1.518965 -0.204352 -0.598285 0.774773 -0.066808 -0.284927 1.518965 0.204352 -0.598285 0.774773 -1.152746 -0.339615 1.511152 -0.354869 -0.136876 0.924802 -0.043371 -0.339615 1.511152 0.354869 -0.136876 0.924802 -1.144933 -0.409927 1.511152 -0.250740 0.233009 0.939573 -0.051183 -0.409927 1.511152 0.250740 0.233009 0.939573 -1.058996 -0.503677 1.542402 -0.083346 0.541185 0.836726 -0.137121 -0.503677 1.542402 0.083346 0.541185 0.836726 -0.973058 -0.534927 1.565840 0.166387 0.612140 0.773003 -0.223058 -0.534927 1.565840 -0.166387 0.612140 0.773003 -0.840246 -0.495865 1.597090 0.430799 0.558428 0.708884 -0.355871 -0.495865 1.597090 -0.430799 0.558428 0.708884 -0.801183 -0.448990 1.589277 0.663167 0.333995 0.669790 -0.394933 -0.448990 1.589277 -0.663167 0.333995 0.669790 -0.793371 -0.323990 1.597090 0.750908 -0.205786 0.627491 -0.402746 -0.323990 1.597090 -0.750908 -0.205786 0.627491 -0.793371 -0.394302 1.589277 0.804071 0.021607 0.594104 -0.402746 -0.394302 1.589277 -0.804071 0.021607 0.594104 -0.707433 -0.159927 1.448652 -0.572558 0.816126 -0.077975 -0.598058 -0.214615 1.440840 0.000000 0.809076 0.587695 -0.488683 -0.159927 1.448652 0.572558 0.816126 -0.077975 -0.793371 0.043198 1.456465 -0.493667 0.522385 -0.695242 -0.402746 0.043198 1.456465 0.493667 0.522385 -0.695242 -0.933996 0.066635 1.433027 0.072115 0.705863 -0.704611 -0.262121 0.066635 1.433027 -0.072115 0.705863 -0.704611 -1.082433 -0.066177 1.393965 0.294107 0.893826 -0.338389 -0.113683 -0.066177 1.393965 -0.294107 0.893826 -0.338389 -1.277746 -0.167740 1.331465 0.353618 0.907498 -0.226539 --0.081629 -0.167740 1.331465 -0.353618 0.907498 -0.226539 -1.394933 -0.214615 1.300215 0.737449 0.624439 -0.257271 --0.198817 -0.214615 1.300215 -0.737449 0.624439 -0.257271 -1.371496 -0.456802 1.214277 0.945067 -0.265664 -0.190283 --0.175379 -0.456802 1.214277 -0.945067 -0.265664 -0.190283 -1.199621 -0.620865 1.253340 0.598498 -0.793664 -0.108798 --0.003504 -0.620865 1.253340 -0.598498 -0.793664 -0.108798 -1.035558 -0.714615 1.308027 0.443739 -0.889859 0.105777 -0.160558 -0.714615 1.308027 -0.443739 -0.889859 0.105777 -0.598058 -1.191177 1.159590 0.000000 -0.343272 -0.939207 -0.598058 -1.105240 1.120527 0.000000 -0.844111 -0.536119 -0.777746 -1.034927 1.097090 0.662008 -0.585345 -0.468032 -0.723058 -1.159927 1.198652 0.375225 -0.245033 -0.893918 -0.418371 -1.034927 1.097090 -0.662008 -0.585345 -0.468032 -0.473058 -1.159927 1.198652 -0.375225 -0.245033 -0.893918 -0.598058 -1.425552 1.183027 0.000000 -0.266396 -0.963836 -0.738683 -1.378677 1.206465 0.129063 -0.181158 -0.974914 -0.457433 -1.378677 1.206465 -0.129063 -0.181158 -0.974914 -0.598058 -1.597427 1.300215 0.000000 -0.814783 -0.579730 -0.762121 -1.566177 1.276777 0.095828 -0.758995 -0.643971 -0.433996 -1.566177 1.276777 -0.095828 -0.758995 -0.643971 -0.926183 -1.534927 1.237715 0.486373 -0.547777 -0.680685 -0.269933 -1.534927 1.237715 -0.486373 -0.547777 -0.680685 -0.887121 -1.331802 1.222090 0.621204 -0.013001 -0.783502 -0.308996 -1.331802 1.222090 -0.621204 -0.013001 -0.783502 -0.848058 -1.120865 1.229902 0.773614 0.008057 -0.633595 -0.348058 -1.120865 1.229902 -0.773614 0.008057 -0.633595 -0.832433 -0.972427 1.245527 0.943541 -0.006714 -0.331126 -0.363683 -0.972427 1.245527 -0.943541 -0.006714 -0.331126 -0.816808 -0.902115 1.268965 0.974731 -0.223334 -0.001617 -0.808996 -0.847427 1.308027 0.938414 -0.192114 0.287149 -0.387121 -0.847427 1.308027 -0.938414 -0.192114 0.287149 -0.379308 -0.902115 1.268965 -0.974731 -0.223334 -0.001617 -0.801183 -0.792740 1.339277 0.793970 -0.573138 0.202643 -0.394933 -0.792740 1.339277 -0.793970 -0.573138 0.202643 -0.598058 -0.550552 0.011152 0.000000 -0.322214 -0.946654 -0.933996 -0.566177 0.175215 0.434828 -0.332621 -0.836787 -0.941808 -0.769302 0.300215 0.498337 -0.624256 -0.601581 -0.598058 -0.816177 0.167402 0.000000 -0.717124 -0.696921 -0.254308 -0.769302 0.300215 -0.498337 -0.624256 -0.601581 -0.262121 -0.566177 0.175215 -0.434828 -0.332621 -0.836787 -0.894933 -0.933365 0.573652 0.531236 -0.819056 -0.216529 -0.598058 -1.003677 0.487715 0.000000 -0.948454 -0.316874 -0.301183 -0.933365 0.573652 -0.531236 -0.819056 -0.216529 -0.808996 -1.011490 1.003340 0.659932 -0.751091 -0.017396 -0.598058 -1.081802 1.026777 0.000000 -0.986755 -0.162084 -0.387121 -1.011490 1.003340 -0.659932 -0.751091 -0.017396 -1.332433 -0.667740 0.909590 0.697653 -0.714530 0.051790 -1.449621 -0.386490 0.893965 0.981597 -0.158544 0.106326 --0.136317 -0.667740 0.909590 -0.697653 -0.714530 0.051790 --0.253504 -0.386490 0.893965 -0.981597 -0.158544 0.106326 -0.598058 -0.058365 -0.012285 0.000000 0.277841 -0.960601 -1.058996 -0.183365 0.136152 0.456893 0.171026 -0.872890 -0.137121 -0.183365 0.136152 -0.456893 0.171026 -0.872890 -0.598058 0.277573 1.128340 0.000000 0.832881 0.553423 -1.051183 0.230698 1.073652 0.499496 0.723777 0.476028 -1.051183 0.308823 0.768965 0.431349 0.902127 0.007294 -0.598058 0.363510 0.761152 0.000000 0.999634 0.025941 -0.144933 0.308823 0.768965 -0.431349 0.902127 0.007294 -0.144933 0.230698 1.073652 -0.499496 0.723777 0.476028 -1.051183 0.246323 0.456465 0.438551 0.747093 -0.499496 -0.598058 0.277573 0.292402 0.000000 0.865200 -0.501358 -0.144933 0.246323 0.456465 -0.438551 0.747093 -0.499496 -1.324621 -0.214615 1.175215 0.769982 0.576373 0.273629 -1.230871 -0.167740 1.120527 0.480514 0.835902 0.265175 --0.128504 -0.214615 1.175215 -0.769982 0.576373 0.273629 --0.034754 -0.167740 1.120527 -0.480514 0.835902 0.265175 -1.394933 -0.058365 0.964277 0.794794 0.516495 0.318583 -1.238683 0.082260 0.893965 0.600909 0.684317 0.413007 --0.198817 -0.058365 0.964277 -0.794794 0.516495 0.318583 --0.042567 0.082260 0.893965 -0.600909 0.684317 0.413007 -1.394933 -0.003677 0.722090 0.888424 0.455214 -0.058870 -1.238683 0.129135 0.643965 0.679067 0.733848 -0.017182 --0.198817 -0.003677 0.722090 -0.888424 0.455214 -0.058870 --0.042567 0.129135 0.643965 -0.679067 0.733848 -0.017182 -1.394933 -0.081802 0.479902 0.864467 0.333537 -0.376049 -1.238683 0.058823 0.393965 0.671163 0.551592 -0.495224 --0.198817 -0.081802 0.479902 -0.864467 0.333537 -0.376049 --0.042567 0.058823 0.393965 -0.671163 0.551592 -0.495224 -1.371496 -0.355240 0.401777 0.634968 0.106082 -0.765191 -1.215246 -0.292740 0.253340 0.587725 0.009552 -0.808985 --0.019129 -0.292740 0.253340 -0.587725 0.009552 -0.808985 --0.175379 -0.355240 0.401777 -0.634968 0.106082 -0.765191 -1.058996 -0.097427 1.268965 0.386578 0.804682 0.450514 -0.137121 -0.097427 1.268965 -0.386578 0.804682 0.450514 -0.598058 -0.050552 1.409590 0.000000 0.612903 0.790124 -1.457433 -0.300552 0.792402 0.989715 -0.139927 -0.029237 --0.261317 -0.300552 0.792402 -0.989715 -0.139927 -0.029237 -1.418371 -0.292740 0.636152 0.896573 0.322764 0.303201 --0.222254 -0.292740 0.636152 -0.896573 0.322764 0.303201 -1.027746 -0.816177 0.628340 0.557421 -0.816828 -0.148412 -1.004308 -0.792740 0.987715 0.585223 -0.792230 0.172735 -0.168371 -0.816177 0.628340 -0.557421 -0.816828 -0.148412 -0.191808 -0.792740 0.987715 -0.585223 -0.792230 0.172735 -1.191808 -0.745865 0.675215 0.299722 -0.952116 0.060244 -0.004308 -0.745865 0.675215 -0.299722 -0.952116 0.060244 -1.238683 -0.628677 0.409590 0.339183 -0.665212 -0.665120 -1.082433 -0.597427 0.292402 0.549120 -0.534593 -0.642354 -0.113683 -0.597427 0.292402 -0.549120 -0.534593 -0.642354 --0.042567 -0.628677 0.409590 -0.339183 -0.665212 -0.665120 -1.621496 -0.144302 0.526777 0.044588 0.869655 0.491592 -1.488683 -0.214615 0.604902 -0.279061 0.732902 0.620441 -1.519933 -0.261490 0.620527 0.491043 -0.096927 0.865688 -1.613683 -0.206802 0.550215 0.546281 -0.129246 0.827540 --0.323817 -0.261490 0.620527 -0.491043 -0.096927 0.865688 --0.292567 -0.214615 0.604902 0.279061 0.732902 0.620441 --0.425379 -0.144302 0.526777 -0.044588 0.869655 0.491592 --0.417567 -0.206802 0.550215 -0.546281 -0.129246 0.827540 -1.785558 -0.183365 0.448652 0.188543 -0.189062 0.963683 -1.832433 -0.113052 0.417402 0.491928 0.655202 0.573290 --0.589442 -0.183365 0.448652 -0.188543 -0.189062 0.963683 --0.636317 -0.113052 0.417402 -0.491928 0.655202 0.573290 -1.863683 -0.331802 0.433027 -0.255715 -0.030763 0.966247 -1.949621 -0.300552 0.417402 0.720420 0.100833 0.686117 --0.667567 -0.331802 0.433027 0.255715 -0.030763 0.966247 --0.753504 -0.300552 0.417402 -0.720420 0.100833 0.686117 -1.808996 -0.542740 0.433027 -0.127598 0.304697 0.943846 -1.879308 -0.566177 0.409590 0.653920 -0.383831 0.651936 --0.612879 -0.542740 0.433027 0.127598 0.304697 0.943846 --0.683192 -0.566177 0.409590 -0.653920 -0.383831 0.651936 -1.629308 -0.659927 0.534590 0.398724 0.353282 0.846278 -1.637121 -0.722427 0.511152 0.528459 -0.698935 0.481826 --0.433192 -0.659927 0.534590 -0.398724 0.353282 0.846278 --0.441004 -0.722427 0.511152 -0.528459 -0.698935 0.481826 -1.426183 -0.691177 0.706465 0.301370 0.491226 0.817194 -1.371496 -0.761490 0.714277 0.118107 -0.827113 0.549455 --0.230067 -0.691177 0.706465 -0.301370 0.491226 0.817194 --0.175379 -0.761490 0.714277 -0.118107 -0.827113 0.549455 -1.637121 -0.620865 0.472090 -0.128025 0.955870 0.264290 -1.480871 -0.644302 0.628340 0.124271 0.948576 0.291025 --0.284754 -0.644302 0.628340 -0.124271 0.948576 0.291025 --0.441004 -0.620865 0.472090 0.128025 0.955870 0.264290 -1.785558 -0.527115 0.393965 -0.765404 0.638997 0.075961 --0.589442 -0.527115 0.393965 0.765404 0.638997 0.075961 -1.832433 -0.370865 0.393965 -0.974761 -0.128391 0.182592 --0.636317 -0.370865 0.393965 0.974761 -0.128391 0.182592 -1.769933 -0.261490 0.401777 -0.217933 -0.804041 0.553178 --0.573817 -0.261490 0.401777 0.217933 -0.804041 0.553178 -1.621496 -0.277115 0.479902 0.533250 -0.679800 0.503464 --0.425379 -0.277115 0.479902 -0.533250 -0.679800 0.503464 -1.543371 -0.316177 0.550215 0.680013 -0.575915 0.453719 --0.347254 -0.316177 0.550215 -0.680013 -0.575915 0.453719 -1.316808 -0.644302 0.667402 0.762413 0.144871 0.630634 -1.324621 -0.620865 0.768965 0.915250 -0.380810 -0.131382 --0.120692 -0.644302 0.667402 -0.762413 0.144871 0.630634 --0.128504 -0.620865 0.768965 -0.915250 -0.380810 -0.131382 -1.441808 -0.331802 0.628340 0.675344 -0.259835 0.690176 --0.245692 -0.331802 0.628340 -0.675344 -0.259835 0.690176 -1.410558 -0.636490 0.565840 0.640858 0.506882 0.576434 --0.214442 -0.636490 0.565840 -0.640858 0.506882 0.576434 -1.441808 -0.605240 0.565840 0.842280 -0.009583 0.538896 -1.316808 -0.581802 0.651777 0.906796 -0.122990 0.403150 --0.120692 -0.581802 0.651777 -0.906796 -0.122990 0.403150 --0.245692 -0.605240 0.565840 -0.842280 -0.009583 0.538896 -1.355871 -0.527115 0.565840 0.868496 0.110019 0.483291 -1.418371 -0.534927 0.565840 0.617298 0.711081 0.336528 --0.159754 -0.527115 0.565840 -0.868496 0.110019 0.483291 --0.222254 -0.534927 0.565840 -0.617298 0.711081 0.336528 -1.433996 -0.448990 0.565840 0.748192 -0.574877 0.331187 -1.394933 -0.417740 0.628340 0.886258 -0.398785 0.235572 --0.198817 -0.417740 0.628340 -0.886258 -0.398785 0.235572 --0.237879 -0.448990 0.565840 -0.748192 -0.574877 0.331187 -1.488683 -0.378677 0.573652 0.706351 -0.552843 0.441969 --0.292567 -0.378677 0.573652 -0.706351 -0.552843 0.441969 -1.488683 -0.386490 0.518965 0.646474 -0.403150 0.647664 -1.551183 -0.331802 0.495527 0.631062 -0.332835 0.700674 --0.292567 -0.386490 0.518965 -0.646474 -0.403150 0.647664 --0.355067 -0.331802 0.495527 -0.631062 -0.332835 0.700674 -1.441808 -0.448990 0.518965 0.573321 -0.437483 0.692709 --0.245692 -0.448990 0.518965 -0.573321 -0.437483 0.692709 -1.363683 -0.527115 0.518965 0.654530 0.185125 0.732963 --0.167567 -0.527115 0.518965 -0.654530 0.185125 0.732963 -1.426183 -0.542740 0.518965 0.476058 0.474563 0.740349 --0.230067 -0.542740 0.518965 -0.476058 0.474563 0.740349 -1.449621 -0.605240 0.518965 0.606159 0.136204 0.783563 --0.253504 -0.605240 0.518965 -0.606159 0.136204 0.783563 -1.410558 -0.636490 0.518965 0.234077 0.767602 0.596637 --0.214442 -0.636490 0.518965 -0.234077 0.767602 0.596637 -1.480871 -0.636490 0.573652 0.064241 0.870754 0.487472 --0.284754 -0.636490 0.573652 -0.064241 0.870754 0.487472 -1.637121 -0.292740 0.425215 0.531968 -0.252754 0.808130 --0.441004 -0.292740 0.425215 -0.531968 -0.252754 0.808130 -1.785558 -0.277115 0.354902 0.145665 -0.307749 0.940245 --0.589442 -0.277115 0.354902 -0.145665 -0.307749 0.940245 -1.855871 -0.378677 0.347090 -0.553941 -0.194433 0.809503 --0.659754 -0.378677 0.347090 0.553941 -0.194433 0.809503 -1.808996 -0.534927 0.354902 -0.365886 0.500015 0.784906 --0.612879 -0.534927 0.354902 0.365886 0.500015 0.784906 -1.644933 -0.620865 0.417402 0.204718 0.726096 0.656362 --0.448817 -0.620865 0.417402 -0.204718 0.726096 0.656362 -1.535558 -0.558365 0.503340 0.211005 0.236152 0.948515 -1.488683 -0.511490 0.511152 0.199469 0.003967 0.979888 --0.339442 -0.558365 0.503340 -0.211005 0.236152 0.948515 --0.292567 -0.511490 0.511152 -0.199469 0.003967 0.979888 -1.598058 -0.495865 0.472090 0.436354 -0.019593 0.899533 -1.558996 -0.448990 0.487715 0.325327 -0.001740 0.945585 --0.401942 -0.495865 0.472090 -0.436354 -0.019593 0.899533 --0.362879 -0.448990 0.487715 -0.325327 -0.001740 0.945585 -1.652746 -0.433365 0.456465 0.365734 -0.092502 0.926084 -1.613683 -0.386490 0.464277 0.311930 0.076144 0.947020 --0.456629 -0.433365 0.456465 -0.365734 -0.092502 0.926084 --0.417567 -0.386490 0.464277 -0.311930 0.076144 0.947020 -1.707433 -0.409927 0.448652 0.416211 0.026002 0.908872 -1.683996 -0.347427 0.448652 0.346782 0.297983 0.889309 --0.511317 -0.409927 0.448652 -0.416211 0.026002 0.908872 --0.487879 -0.347427 0.448652 -0.346782 0.297983 0.889309 -1.387121 -0.745865 0.511152 -0.050844 -0.722861 -0.689077 -1.637121 -0.706802 0.347090 -0.050600 -0.705344 -0.707022 --0.191004 -0.745865 0.511152 0.050844 -0.722861 -0.689077 --0.441004 -0.706802 0.347090 0.050600 -0.705344 -0.707022 -1.910558 -0.566177 0.308027 0.642445 -0.435224 -0.630696 --0.714442 -0.566177 0.308027 -0.642445 -0.435224 -0.630696 -1.965246 -0.323990 0.339277 0.945433 0.138951 -0.294656 --0.769129 -0.323990 0.339277 -0.945433 0.138951 -0.294656 -1.848058 -0.152115 0.292402 0.295114 0.535020 -0.791589 --0.651942 -0.152115 0.292402 -0.295114 0.535020 -0.791589 -1.621496 -0.183365 0.354902 -0.445540 0.562609 -0.696371 --0.425379 -0.183365 0.354902 0.445540 0.562609 -0.696371 -1.457433 -0.238052 0.456465 -0.489364 0.514664 -0.703970 --0.261317 -0.238052 0.456465 0.489364 0.514664 -0.703970 -4 0 1 2 3 -4 4 5 6 7 -4 3 2 8 9 -4 10 4 7 11 -4 2 12 13 8 -4 14 15 4 10 -4 1 16 12 2 -4 15 17 5 4 -4 16 18 19 12 -4 20 21 17 15 -4 12 19 22 13 -4 23 20 15 14 -4 19 24 25 22 -4 26 27 20 23 -4 18 28 24 19 -4 27 29 21 20 -4 28 30 31 24 -4 32 33 29 27 -4 24 31 34 25 -4 35 32 27 26 -4 31 36 37 34 -4 38 39 32 35 -4 30 40 36 31 -4 39 41 33 32 -4 40 42 43 36 -4 44 45 41 39 -4 36 43 46 37 -4 47 44 39 38 -4 43 3 9 46 -4 11 7 44 47 -4 42 0 3 43 -4 7 6 45 44 -4 0 42 48 49 -4 50 45 6 51 -4 42 40 52 48 -4 53 41 45 50 -4 40 30 54 52 -4 55 33 41 53 -4 30 28 56 54 -4 57 29 33 55 -4 28 18 58 56 -4 59 21 29 57 -4 18 16 60 58 -4 61 17 21 59 -4 16 1 62 60 -4 63 5 17 61 -4 1 0 49 62 -4 51 6 5 63 -3 64 62 49 -3 51 63 65 -3 60 62 64 -3 65 63 61 -3 64 58 60 -3 61 59 65 -3 64 56 58 -3 59 57 65 -3 64 54 56 -3 57 55 65 -3 64 52 54 -3 55 53 65 -3 64 48 52 -3 53 50 65 -3 64 49 48 -3 50 51 65 -4 66 67 68 69 -4 68 70 71 69 -4 72 73 67 66 -4 70 74 75 71 -4 76 77 73 72 -4 74 78 79 75 -4 80 81 77 76 -4 78 82 83 79 -4 84 85 81 80 -4 82 86 87 83 -4 88 89 90 91 -4 92 93 94 95 -4 89 96 97 90 -4 98 99 93 92 -4 96 100 101 97 -4 102 103 99 98 -4 100 104 105 101 -4 106 107 103 102 -4 104 108 109 105 -4 110 111 107 106 -4 108 112 113 109 -4 114 115 111 110 -4 112 116 117 113 -4 118 119 115 114 -4 116 120 121 117 -4 122 123 119 118 -4 120 124 125 121 -4 126 127 123 122 -4 124 128 129 125 -4 129 128 127 126 -4 130 131 121 125 -4 122 132 133 126 -4 131 134 117 121 -4 118 135 132 122 -4 136 113 117 134 -4 118 114 137 135 -4 138 109 113 136 -4 114 110 139 137 -4 140 105 109 138 -4 110 106 141 139 -4 142 101 105 140 -4 106 102 143 141 -4 144 97 101 142 -4 102 98 145 143 -4 146 90 97 144 -4 98 92 147 145 -4 148 91 90 146 -4 92 95 149 147 -4 148 150 151 91 -4 151 152 149 95 -4 130 125 129 153 -4 129 126 133 154 -4 153 129 155 156 -4 155 129 154 157 -4 151 150 156 155 -4 157 152 151 155 -4 158 159 68 67 -4 68 159 160 70 -4 161 158 67 73 -4 70 160 162 74 -4 163 161 73 77 -4 74 162 164 78 -4 85 165 166 81 -4 167 168 86 82 -4 163 77 81 166 -4 82 78 164 167 -4 169 170 171 165 -4 171 170 172 168 -4 166 165 171 173 -4 171 168 167 173 -4 174 163 166 173 -4 167 164 174 173 -4 175 176 177 169 -4 178 179 180 172 -4 181 182 176 175 -4 179 183 184 180 -4 185 186 182 181 -4 183 187 185 184 -4 188 189 186 185 -4 187 189 188 185 -4 170 169 177 190 -4 178 172 170 190 -4 190 177 191 192 -4 193 178 190 192 -4 189 194 195 186 -4 196 194 189 187 -4 186 195 197 182 -4 198 196 187 183 -4 182 197 199 176 -4 200 198 183 179 -4 176 199 191 177 -4 193 200 179 178 -4 194 199 197 195 -4 198 200 194 196 -4 194 192 191 199 -4 193 192 194 200 -4 185 181 91 151 -4 95 184 185 151 -4 181 175 201 91 -4 202 180 184 95 -4 175 169 203 201 -4 204 172 180 202 -4 169 165 85 203 -4 86 168 172 204 -4 84 205 203 85 -4 204 206 87 86 -4 205 207 201 203 -4 202 208 206 204 -4 88 91 201 207 -4 202 95 94 208 -4 163 174 209 210 -4 209 174 164 211 -4 161 163 210 212 -4 211 164 162 213 -4 158 161 212 214 -4 213 162 160 215 -4 159 158 214 216 -4 215 160 159 216 -4 216 214 217 218 -4 219 215 216 218 -4 214 212 220 217 -4 221 213 215 219 -4 212 210 222 220 -4 223 211 213 221 -4 210 209 224 222 -4 224 209 211 223 -4 224 218 217 222 -4 219 218 224 223 -3 222 217 220 -3 221 219 223 -4 156 150 225 226 -4 227 152 157 228 -4 153 156 226 229 -4 228 157 154 230 -4 130 153 229 231 -4 230 154 133 232 -4 150 148 233 225 -4 234 149 152 227 -4 148 146 235 233 -4 236 147 149 234 -4 146 144 237 235 -4 238 145 147 236 -4 144 142 239 237 -4 240 143 145 238 -4 142 140 241 239 -4 242 141 143 240 -4 140 138 243 241 -4 244 139 141 242 -4 138 136 245 243 -4 246 137 139 244 -4 136 134 247 245 -4 248 135 137 246 -4 134 131 249 247 -4 250 132 135 248 -4 131 130 231 249 -4 232 133 132 250 -4 249 231 251 252 -4 253 232 250 254 -4 247 249 252 255 -4 254 250 248 256 -4 245 247 255 257 -4 256 248 246 258 -4 243 245 257 259 -4 258 246 244 260 -4 241 243 259 261 -4 260 244 242 262 -4 239 241 261 263 -4 262 242 240 264 -4 237 239 263 265 -4 264 240 238 266 -4 235 237 265 267 -4 266 238 236 268 -4 233 235 267 269 -4 268 236 234 270 -4 225 233 269 271 -4 270 234 227 272 -4 231 229 273 251 -4 274 230 232 253 -4 229 226 275 273 -4 276 228 230 274 -4 226 225 271 275 -4 272 227 228 276 -4 128 124 277 278 -4 279 127 128 278 -4 124 120 280 277 -4 281 123 127 279 -4 120 116 282 280 -4 283 119 123 281 -4 116 112 284 282 -4 285 115 119 283 -4 112 108 286 284 -4 287 111 115 285 -4 108 104 288 286 -4 289 107 111 287 -4 104 100 290 288 -4 291 103 107 289 -4 100 96 292 290 -4 293 99 103 291 -4 96 89 294 292 -4 295 93 99 293 -4 296 297 298 299 -4 300 297 296 301 -4 302 296 299 303 -4 301 296 302 304 -4 305 302 303 306 -4 304 302 305 307 -4 66 69 305 306 -4 305 69 71 307 -4 72 66 306 308 -4 307 71 75 309 -4 76 72 308 310 -4 309 75 79 311 -4 80 76 310 312 -4 311 79 83 313 -4 310 303 299 312 -4 301 304 311 313 -4 310 308 306 303 -4 307 309 311 304 -4 314 312 299 298 -4 301 313 315 300 -4 84 80 312 314 -4 313 83 87 315 -4 205 316 317 207 -4 318 319 206 208 -4 84 314 316 205 -4 319 315 87 206 -4 88 207 317 320 -4 318 208 94 321 -4 88 320 294 89 -4 295 321 94 93 -4 322 323 324 325 -4 326 327 322 325 -4 325 324 328 329 -4 330 326 325 329 -4 329 328 331 332 -4 333 330 329 332 -4 332 331 298 297 -4 300 333 332 297 -4 314 298 331 316 -4 333 300 315 319 -4 290 292 334 335 -4 336 293 291 337 -4 338 339 323 322 -4 327 340 338 322 -4 341 342 343 344 -4 345 346 341 344 -4 344 343 347 348 -4 349 345 344 348 -4 348 347 339 338 -4 340 349 348 338 -4 286 288 350 351 -4 352 289 287 353 -4 351 350 354 355 -4 356 352 353 357 -4 355 354 358 359 -4 360 356 357 361 -4 359 358 362 363 -4 364 360 361 365 -4 366 367 363 362 -4 365 368 369 364 -4 339 347 363 367 -4 365 349 340 368 -4 347 343 359 363 -4 361 345 349 365 -4 343 342 355 359 -4 357 346 345 361 -4 342 370 351 355 -4 353 371 346 357 -4 284 286 351 370 -4 353 287 285 371 -4 372 370 342 341 -4 346 371 372 341 -4 277 280 282 284 -4 283 281 279 285 -4 277 284 370 372 -4 371 285 279 372 -3 278 277 372 -3 372 279 278 -4 288 290 335 350 -4 337 291 289 352 -4 335 373 354 350 -4 356 374 337 352 -4 373 375 358 354 -4 360 376 374 356 -4 366 362 358 375 -4 360 364 369 376 -4 331 328 377 378 -4 379 330 333 380 -4 334 378 377 381 -4 379 380 336 382 -4 292 294 378 334 -4 380 295 293 336 -4 294 317 316 378 -4 319 318 295 380 -3 316 331 378 -3 380 333 319 -3 294 320 317 -3 318 321 295 -4 366 383 384 367 -4 385 386 369 368 -4 339 367 384 323 -4 385 368 340 327 -4 381 377 384 383 -4 385 379 382 386 -4 328 324 384 377 -4 385 326 330 379 -3 323 384 324 -3 326 385 327 -4 387 388 389 390 -4 391 392 393 394 -4 387 390 395 396 -4 397 394 393 398 -4 396 395 399 400 -4 401 397 398 402 -4 400 399 403 404 -4 405 401 402 406 -4 404 403 407 408 -4 409 405 406 410 -4 408 407 411 412 -4 413 409 410 414 -4 407 415 416 411 -4 417 418 409 413 -4 403 419 415 407 -4 418 420 405 409 -4 399 421 419 403 -4 420 422 401 405 -4 395 423 421 399 -4 422 424 397 401 -4 390 425 423 395 -4 424 426 394 397 -4 390 389 427 425 -4 428 391 394 426 -4 334 381 429 430 -4 431 382 336 432 -4 381 412 411 429 -4 413 414 382 431 -4 335 334 430 373 -4 432 336 337 374 -4 375 433 389 388 -4 391 434 376 392 -4 411 416 435 429 -4 436 417 413 431 -4 437 438 429 435 -4 431 439 440 436 -4 441 438 437 442 -4 440 439 443 444 -4 445 446 438 441 -4 439 447 448 443 -4 433 446 445 449 -4 448 447 434 450 -4 389 433 449 427 -4 450 434 391 428 -4 373 446 433 375 -4 434 447 374 376 -4 373 430 438 446 -4 439 432 374 447 -3 430 429 438 -3 439 431 432 -4 427 449 451 452 -4 453 450 428 454 -4 449 445 455 451 -4 456 448 450 453 -4 445 441 457 455 -4 458 443 448 456 -4 441 442 459 457 -4 460 444 443 458 -4 442 437 461 459 -4 462 440 444 460 -4 437 435 463 461 -4 464 436 440 462 -4 435 416 465 463 -4 466 417 436 464 -4 425 427 452 467 -4 454 428 426 468 -4 423 425 467 469 -4 468 426 424 470 -4 421 423 469 471 -4 470 424 422 472 -4 419 421 471 473 -4 472 422 420 474 -4 415 419 473 475 -4 474 420 418 476 -4 416 415 475 465 -4 476 418 417 466 -4 459 461 477 478 -4 479 462 460 480 -4 478 477 481 482 -4 483 479 480 484 -4 482 481 485 486 -4 487 483 484 488 -4 486 485 489 490 -4 491 487 488 492 -4 467 452 486 490 -4 488 454 468 492 -4 451 482 486 452 -4 488 484 453 454 -4 451 455 478 482 -4 480 456 453 484 -4 459 478 455 457 -4 456 480 460 458 -4 463 465 477 461 -4 479 466 464 462 -4 475 481 477 465 -4 479 483 476 466 -4 473 485 481 475 -4 483 487 474 476 -4 471 489 485 473 -4 487 491 472 474 -4 469 490 489 471 -4 491 492 470 472 -3 467 490 469 -3 470 492 468 -4 408 412 493 494 -4 495 414 410 496 -4 404 408 494 497 -4 496 410 406 498 -4 400 404 497 499 -4 498 406 402 500 -4 396 400 499 501 -4 500 402 398 502 -4 387 396 501 503 -4 502 398 393 504 -4 388 387 503 505 -4 504 393 392 506 -4 503 494 493 505 -4 495 496 504 506 -4 503 501 497 494 -4 498 502 504 496 -3 501 499 497 -3 498 500 502 -4 366 375 388 505 -4 392 376 369 506 -4 366 505 493 383 -4 495 506 369 386 -4 381 383 493 412 -4 495 386 382 414 diff --git a/example/viewer.c b/example/viewer.c deleted file mode 100644 index 0247d60..0000000 --- a/example/viewer.c +++ b/dev/null @@ -1,114 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <clutter/clutter.h> -#include <mash/mash.h> -#include <stdio.h> -#include <stdlib.h> - -int -main (int argc, char **argv) -{ - ClutterActor *stage = stage, *model; - GError *error = NULL; - - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; - - if (argc != 2 && argc != 3) - { - fprintf (stderr, "usage: %s <ply-file> [texture]\n", argv[0]); - exit (1); - } - - stage = clutter_stage_get_default (); - - if ((model = mash_model_new_from_file (MASH_DATA_NONE, argv[1], &error)) - == NULL) - { - g_warning ("%s", error->message); - g_clear_error (&error); - } - else - { - ClutterAnimation *anim; - ClutterVertex center_vertex; - - /* If a texture was specified then set that as a material */ - if (argc > 2) - { - CoglHandle texture = - cogl_texture_new_from_file (argv[2], - COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_ANY, - &error); - - if (texture == COGL_INVALID_HANDLE) - { - g_warning ("%s", error->message); - g_clear_error (&error); - } - else - { - CoglHandle material = cogl_material_new (); - cogl_material_set_layer (material, 0, texture); - cogl_handle_unref (texture); - - mash_model_set_material (MASH_MODEL (model), - material); - - cogl_handle_unref (material); - } - } - - clutter_actor_set_size (model, - clutter_actor_get_width (stage) * 0.7f, - clutter_actor_get_height (stage) * 0.7f); - clutter_actor_set_position (model, - clutter_actor_get_width (stage) * 0.15f, - clutter_actor_get_height (stage) * 0.15f); - - center_vertex.x = clutter_actor_get_width (stage) * 0.35f; - center_vertex.y = 0.0f; - center_vertex.z = 0.0f; - - anim = clutter_actor_animate (model, - CLUTTER_LINEAR, 3000, - "rotation-angle-y", 360.0f, - "fixed::rotation-center-y", ¢er_vertex, - NULL); - clutter_animation_set_loop (anim, TRUE); - - clutter_container_add_actor (CLUTTER_CONTAINER (stage), model); - - /* Enable depth testing only for this actor */ - g_signal_connect_swapped (model, "paint", - G_CALLBACK (cogl_set_depth_test_enabled), - GINT_TO_POINTER (TRUE)); - g_signal_connect_data (model, "paint", - G_CALLBACK (cogl_set_depth_test_enabled), - GINT_TO_POINTER (FALSE), NULL, - G_CONNECT_AFTER | G_CONNECT_SWAPPED); - } - - clutter_actor_show (stage); - - clutter_main (); - - return 0; -} diff --git a/m4/introspection.m4 b/m4/introspection.m4 deleted file mode 100644 index bb3a0da..0000000 --- a/m4/introspection.m4 +++ b/dev/null @@ -1,88 +0,0 @@ -dnl -*- mode: autoconf -*- -dnl Copyright 2009 Johan Dahlin -dnl -dnl This file is free software; the author(s) gives unlimited -dnl permission to copy and/or distribute it, with or without -dnl modifications, as long as this notice is preserved. -dnl - -# serial 1 - -m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], -[ - AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first - AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first - AC_BEFORE([LT_INIT],[$0])dnl setup libtool first - - dnl enable/disable introspection - m4_if([$2], [require], - [dnl - enable_introspection=yes - ],[dnl - AC_ARG_ENABLE(introspection, - AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], - [Enable introspection for this build]),, - [enable_introspection=auto]) - ])dnl - - AC_MSG_CHECKING([for gobject-introspection]) - - dnl presence/version checking - AS_CASE([$enable_introspection], - [no], [dnl - found_introspection="no (disabled, use --enable-introspection to enable)" - ],dnl - [yes],[dnl - PKG_CHECK_EXISTS([gobject-introspection-1.0],, - AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) - PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], - found_introspection=yes, - AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) - ],dnl - [auto],[dnl - PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) - ],dnl - [dnl - AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) - ])dnl - - AC_MSG_RESULT([$found_introspection]) - - INTROSPECTION_SCANNER= - INTROSPECTION_COMPILER= - INTROSPECTION_GENERATE= - INTROSPECTION_GIRDIR= - INTROSPECTION_TYPELIBDIR= - if test "x$found_introspection" = "xyes"; then - INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` - INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` - INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` - INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` - INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" - fi - AC_SUBST(INTROSPECTION_SCANNER) - AC_SUBST(INTROSPECTION_COMPILER) - AC_SUBST(INTROSPECTION_GENERATE) - AC_SUBST(INTROSPECTION_GIRDIR) - AC_SUBST(INTROSPECTION_TYPELIBDIR) - - AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") -]) - - -dnl Usage: -dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) - -AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], -[ - _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) -]) - -dnl Usage: -dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) - - -AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], -[ - _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) -]) diff --git a/mash.pc.in b/mash.pc.in deleted file mode 100644 index acc33da..0000000 --- a/mash.pc.in +++ b/dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -requires=clutter-1.0 - -Name: Mash -Description: A library for adding PLY files to a Clutter scene -Version: @MASH_VERSION@ -Libs: -L${libdir} -lmash-@MASH_API_VERSION@ -Cflags: -I${includedir}/mash-@MASH_API_VERSION@ -Requires: ${requires} diff --git a/mash/Makefile.am b/mash/Makefile.am deleted file mode 100644 index 25fde1f..0000000 --- a/mash/Makefile.am +++ b/dev/null @@ -1,159 +0,0 @@ -SUBDIRS = rply - -lib_LTLIBRARIES = libmash-@MASH_API_VERSION@.la - -INCLUDES = \ - -I$(top_srcdir) - -AM_CPPFLAGS = \ - -DMASH_COMPILATION=1 \ - @CLUTTER_CFLAGS@ - -enum_h = \ - $(srcdir)/mash-data.h - -private_h = \ - $(srcdir)/mash-data-loaders.h \ - $(srcdir)/mash-data-loader.h \ - $(srcdir)/mash-ply-loader.h - -public_h = \ - $(enum_h) \ - $(srcdir)/mash.h \ - $(srcdir)/mash-model.h \ - $(srcdir)/mash-light-set.h \ - $(srcdir)/mash-light.h \ - $(srcdir)/mash-directional-light.h \ - $(srcdir)/mash-spot-light.h \ - $(srcdir)/mash-point-light.h - -source_h = \ - $(public_h) \ - $(private_h) - -built_source_h = \ - $(builddir)/mash-enum-types.h - -built_source_c = \ - $(builddir)/mash-enum-types.c - -loaders_c = \ - $(srcdir)/mash-ply-loader.c - -libmash_@MASH_API_VERSION@_la_SOURCES = \ - $(source_h) \ - $(loaders_c) \ - $(srcdir)/mash-data.c \ - $(srcdir)/mash-data-loader.c \ - $(srcdir)/mash-model.c \ - $(srcdir)/mash-light-set.c \ - $(srcdir)/mash-light.c \ - $(srcdir)/mash-directional-light.c \ - $(srcdir)/mash-spot-light.c \ - $(srcdir)/mash-point-light.c - -nodist_libmash_@MASH_API_VERSION@_la_SOURCES = \ - $(built_source_h) \ - $(built_source_c) - -mashdir = $(includedir)/mash-@MASH_API_VERSION@/mash - -mash_HEADERS = \ - $(public_h) - -nodist_mash_HEADERS = \ - $(built_source_h) - -libmash_@MASH_API_VERSION@_la_LDFLAGS = \ - -version-info "@MASH_LT_CURRENT@:@MASH_LT_REVISION@:@MASH_LT_AGE@" - -libmash_@MASH_API_VERSION@_la_LIBADD = \ - @CLUTTER_LIBS@ \ - rply/librply.la - -CLEANFILES = - -BUILT_GIRSOURCES = - -if HAVE_INTROSPECTION - -Mash-@MASH_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libmash-@MASH_API_VERSION@.la - $(QUIET_GEN)$(INTROSPECTION_SCANNER) -v \ - --namespace Mash \ - --nsversion=@MASH_API_VERSION@ \ - $(INCLUDES) \ - $(AM_CPPFLAGS) \ - $(json_gir_include_path) \ - --c-include='mash/mash.h' \ - --include=Clutter-1.0 \ - --output $@ \ - --library=libmash-@MASH_API_VERSION@.la \ - $(libmash_@MASH_API_VERSION@_la_SOURCES) - -BUILT_GIRSOURCES += Mash-@MASH_API_VERSION@.gir - -# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to -# install anything - we need to install inside our prefix. -girdir = $(datadir)/gir-1.0 -gir_DATA = $(BUILT_GIRSOURCES) - -typelibsdir = $(libdir)/girepository-1.0/ - -typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib) - -.gir.typelib : %.typelib: $(INTROSPECTION_COMPILER) - $(QUIET_GEN) \ - LD_LIBRARY_PATH=.libs$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH} \ - $(INTROSPECTION_COMPILER) \ - --includedir=$(srcdir) \ - --includedir=. \ - $(INTROSPECTION_COMPILER_OPTS) $< -o $(@F) - -CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA) - -endif # HAVE_INTROSPECTION - -# These need to be defined before we can include the glib Makefiles -# below -DISTCLEANFILES = -BUILT_SOURCES = -EXTRA_DIST = - -# glib-mkenums rules -glib_enum_h = mash-enum-types.h -glib_enum_c = mash-enum-types.c -glib_enum_headers = $(enum_h) - -# This used to use ebassi's magic Makefile.am.enums but I can't really -# use that anymore because I need to do a sed hack to post-process the -# output to cope with the fact that CLUTTER_PLY is a two-word -# namespace. glib-mkenums doesn't seem to deal with this as far as I -# can tell. - -enum_tmpl_h=$(glib_enum_h:.h=.h.in) -enum_tmpl_c=$(glib_enum_c:.c=.c.in) - -CLEANFILES += stamp-enum-types -DISTCLEANFILES += $(glib_enum_h) $(glib_enum_c) -BUILT_SOURCES += $(glib_enum_h) $(glib_enum_c) -EXTRA_DIST += $(srcdir)/$(enum_tmpl_h) $(srcdir)/$(enum_tmpl_c) - -stamp-enum-types: $(glib_enum_headers) $(srcdir)/$(enum_tmpl_h) - $(QUIET_GEN)$(GLIB_MKENUMS) \ - --template $(srcdir)/$(enum_tmpl_h) \ - $(glib_enum_headers) \ - | sed s/CLUTTER_TYPE_PLY_/CLUTTER_PLY_TYPE_/g > xgen-eh \ - && (cmp -s xgen-eh $(glib_enum_h) || cp -f xgen-eh $(glib_enum_h)) \ - && rm -f xgen-eh \ - && echo timestamp > $(@F) - -$(glib_enum_h): stamp-enum-types - @true - -$(glib_enum_c): $(glib_enum_h) $(srcdir)/$(enum_tmpl_c) - $(QUIET_GEN)$(GLIB_MKENUMS) \ - --template $(srcdir)/$(enum_tmpl_c) \ - $(glib_enum_headers) > xgen-ec \ - && cp -f xgen-ec $(glib_enum_c) \ - && rm -f xgen-ec - diff --git a/mash/mash-data-loader.c b/mash/mash-data-loader.c deleted file mode 100644 index e95ca18..0000000 --- a/mash/mash-data-loader.c +++ b/dev/null @@ -1,98 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * Copyright (C) 2010 Luca Bruno <lethalman88@gmail.com> - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * SECTION:mash-data-loader - * @short_description: An object for loading data from a file in a specific format. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib-object.h> -#include <string.h> -#include <cogl/cogl.h> -#include <clutter/clutter.h> - -#include "mash-data-loader.h" - -G_DEFINE_ABSTRACT_TYPE (MashDataLoader, mash_data_loader, G_TYPE_OBJECT); - -#define MASH_DATA_LOADER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_DATA_LOADER, \ - MashDataLoaderPrivate)) - -/* reserved for future use */ -struct _MashDataLoaderPrivate -{ -}; - -static void -mash_data_loader_class_init (MashDataLoaderClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; -} - -static void -mash_data_loader_init (MashDataLoader *self) -{ -} - -/** - * mash_data_loader_load: - * @data_loader: The #MashDataLoader instance - * @flags: Flags used to specify load-time modifications to the data - * @filename: The name of a file to load - * @error: Return location for an error or %NULL - * - * Loads the data from the file called @filename into @self. - * This function is not usually called by applications. - */ -gboolean -mash_data_loader_load (MashDataLoader *data_loader, - MashDataFlags flags, - const gchar *filename, - GError **error) -{ - g_return_val_if_fail (MASH_IS_DATA_LOADER (data_loader), FALSE); - - return MASH_DATA_LOADER_GET_CLASS (data_loader)->load (data_loader, - flags, - filename, - error); -} - -/** - * mash_data_loader_load: - * @data_loader: The #MashDataLoader instance - * @loader_data: The #MashDataLoaderData to set the loaded data. - * - * Obtains the loaded data after calling mash_data_loader_load(). - * This function is not usually called by applications. - */ -void -mash_data_loader_get_data (MashDataLoader *data_loader, - MashDataLoaderData *loader_data) -{ - g_return_if_fail (MASH_IS_DATA_LOADER (data_loader)); - g_return_if_fail (loader_data != NULL); - - MASH_DATA_LOADER_GET_CLASS (data_loader)->get_data (data_loader, loader_data); -} diff --git a/mash/mash-data-loader.h b/mash/mash-data-loader.h deleted file mode 100644 index fe88344..0000000 --- a/mash/mash-data-loader.h +++ b/dev/null @@ -1,119 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_DATA_LOADER_H__ -#define __MASH_DATA_LOADER_H__ - -#include <cogl/cogl.h> -#include <clutter/clutter.h> - -#include "mash-data.h" - -G_BEGIN_DECLS - -#define MASH_TYPE_DATA_LOADER \ - (mash_data_get_type()) -#define MASH_DATA_LOADER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_DATA_LOADER, \ - MashDataLoader)) -#define MASH_DATA_LOADER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_DATA_LOADER, \ - MashDataLoaderClass)) -#define MASH_IS_DATA_LOADER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_DATA_LOADER)) -#define MASH_IS_DATA_LOADER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_DATA_LOADER)) -#define MASH_DATA_LOADER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_TYPE_DATA_LOADER, \ - MashDataLoaderClass)) - -typedef struct _MashDataLoader MashDataLoader; -typedef struct _MashDataLoaderClass MashDataLoaderClass; -typedef struct _MashDataLoaderPrivate MashDataLoaderPrivate; -typedef struct _MashDataLoaderData MashDataLoaderData; - -/** - * MashDataLoaderClass: - * @load: Virtual used for loading the model from the file - * @get_data: Virtual used to get the loaded data - */ -struct _MashDataLoaderClass -{ - /*< private >*/ - GObjectClass parent_class; - - /*< public >*/ - gboolean (* load) (MashDataLoader *data_loader, - MashDataFlags flags, - const gchar *filename, - GError **error); - void (* get_data) (MashDataLoader *data_loader, - MashDataLoaderData *loader_data); -}; - -/** - * MashDataLoader: - * - * The #MashDataLoader structure contains only private data. - */ -struct _MashDataLoader -{ - /*< private >*/ - GObject parent; - - MashDataLoaderPrivate *priv; -}; - -/** - * MashDataLoaderData: - * - * The #MashDataLoaderData structure contains the loaded data. - */ -struct _MashDataLoaderData -{ - CoglHandle vertices_vbo; - CoglHandle indices; - guint min_index, max_index; - guint n_triangles; - - /* Bounding cuboid of the data */ - ClutterVertex min_vertex, max_vertex; -}; - -GType mash_data_loader_get_type (void) G_GNUC_CONST; - -gboolean mash_data_loader_load (MashDataLoader *self, - MashDataFlags flags, - const gchar *filename, - GError **error); - -void mash_data_loader_get_data (MashDataLoader *self, - MashDataLoaderData *loader_data); - -G_END_DECLS - -#endif /* __MASH_DATA_LOADER_H__ */ diff --git a/mash/mash-data-loaders.h b/mash/mash-data-loaders.h deleted file mode 100644 index 24567bb..0000000 --- a/mash/mash-data-loaders.h +++ b/dev/null @@ -1,29 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * Copyright (C) 2010 Luca Bruno <lethalman88@gmail.com> - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_DATA_LOADERS_H__ -#define __MASH_DATA_LOADERS_H__ - -#include "mash-ply-loader.h" - -#endif /* __MASH_DATA_LOADERS_H__ */ diff --git a/mash/mash-data.c b/mash/mash-data.c deleted file mode 100644 index ffd243d..0000000 --- a/mash/mash-data.c +++ b/dev/null @@ -1,248 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * Copyright (C) 2010 Luca Bruno <lethalman88@gmail.com> - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * SECTION:mash-data - * @short_description: An object that contains the data for a model. - * - * #MashData is an object that can represent the data contained - * in a 3D model file. The data is internally converted to a - * Cogl vertex buffer so that it can be rendered efficiently. - * - * The #MashData object is usually associated with a - * #MashModel so that it can be animated as a regular actor. The - * data is separated from the actor in this way to make it easy to - * share data with multiple actors without having to keep two copies - * of the data. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib-object.h> -#include <string.h> -#include <cogl/cogl.h> -#include <clutter/clutter.h> - -#include "mash-data.h" -#include "mash-data-loader.h" -#include "mash-data-loaders.h" - -static void mash_data_finalize (GObject *object); - -G_DEFINE_TYPE (MashData, mash_data, G_TYPE_OBJECT); - -#define MASH_DATA_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_DATA, \ - MashDataPrivate)) - -struct _MashDataPrivate -{ - MashDataLoaderData loaded_data; -}; - -static void -mash_data_class_init (MashDataClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - - gobject_class->finalize = mash_data_finalize; - - g_type_class_add_private (klass, sizeof (MashDataPrivate)); -} - -static void -mash_data_init (MashData *self) -{ - self->priv = MASH_DATA_GET_PRIVATE (self); -} - -static void -mash_data_free_vbos (MashData *self) -{ - MashDataPrivate *priv = self->priv; - - if (priv->loaded_data.vertices_vbo) - { - cogl_handle_unref (priv->loaded_data.vertices_vbo); - priv->loaded_data.vertices_vbo = NULL; - } - - if (priv->loaded_data.indices) - { - cogl_handle_unref (priv->loaded_data.indices); - priv->loaded_data.indices = NULL; - } -} - -static void -mash_data_finalize (GObject *object) -{ - MashData *self = (MashData *) object; - - mash_data_free_vbos (self); - - G_OBJECT_CLASS (mash_data_parent_class)->finalize (object); -} - -/** - * mash_data_new: - * - * Constructs a new #MashData instance. The object initially has - * no data so nothing will be drawn when mash_data_render() is - * called. To load data into the object, call mash_data_load(). - * - * Return value: a new #MashData. - */ -MashData * -mash_data_new (void) -{ - MashData *self = g_object_new (MASH_TYPE_DATA, NULL); - - return self; -} - -/** - * mash_data_load: - * @self: The #MashData instance - * @flags: Flags used to specify load-time modifications to the data - * @filename: The name of a file to load - * @error: Return location for an error or %NULL - * - * Loads the data from the file called @filename into @self. The - * model can then be rendered using mash_data_render(). If - * there is an error loading the file it will return %FALSE and @error - * will be set to a GError instance. - * - * Return value: %TRUE if the load succeeded or %FALSE otherwise. - */ -gboolean -mash_data_load (MashData *self, - MashDataFlags flags, - const gchar *filename, - GError **error) -{ - MashDataPrivate *priv; - MashDataLoader *loader; - gchar *display_name; - gboolean ret; - - g_return_val_if_fail (MASH_IS_DATA (self), FALSE); - - priv = self->priv; - - loader = NULL; - display_name = g_filename_display_name (filename); - - if (g_str_has_suffix (filename, ".ply")) - loader = g_object_new (MASH_TYPE_PLY_LOADER, NULL); - - if (loader != NULL) - { - if (!mash_data_loader_load (loader, flags, filename, error)) - ret = FALSE; - else - { - /* Get rid of the old VBOs (if any) */ - mash_data_free_vbos (self); - - mash_data_loader_get_data (loader, &priv->loaded_data); - ret = TRUE; - } - } - else - { - /* Unknown file format */ - - g_set_error (error, MASH_DATA_ERROR, - MASH_DATA_ERROR_UNKNOWN_FORMAT, - "Unknown format for file %s", - display_name); - ret = FALSE; - } - - g_free (display_name); - if (loader) - g_object_unref (loader); - - return ret; -} - -/** - * mash_data_render: - * @self: A #MashData instance - * - * Renders the data contained in the model to the Clutter - * scene. The current Cogl source material will be used to affect the - * appearance of the model. This function is not usually called - * directly but instead the #MashData instance is added to a - * #MashModel and this function will be automatically called by - * the paint method of the model. - */ -void -mash_data_render (MashData *self) -{ - MashDataPrivate *priv; - - g_return_if_fail (MASH_IS_DATA (self)); - - priv = self->priv; - - /* Silently fail if we didn't load any data */ - if (priv->loaded_data.vertices_vbo == NULL || priv->loaded_data.indices == NULL) - return; - - cogl_vertex_buffer_draw_elements (priv->loaded_data.vertices_vbo, - COGL_VERTICES_MODE_TRIANGLES, - priv->loaded_data.indices, - priv->loaded_data.min_index, - priv->loaded_data.max_index, - 0, priv->loaded_data.n_triangles * 3); -} - -/** - * mash_data_get_extents: - * @self: A #MashData instance - * @min_vertex: A location to return the minimum vertex - * @max_vertex: A location to return the maximum vertex - * - * Gets the bounding cuboid of the vertices in @self. The cuboid is - * represented by two vertices representing the minimum and maximum - * extents. The x, y and z components of @min_vertex will contain the - * minimum x, y and z values of all the vertices and @max_vertex will - * contain the maximum. The extents of the model are cached so it is - * cheap to call this function. - */ -void -mash_data_get_extents (MashData *self, - ClutterVertex *min_vertex, - ClutterVertex *max_vertex) -{ - MashDataPrivate *priv = self->priv; - - *min_vertex = priv->loaded_data.min_vertex; - *max_vertex = priv->loaded_data.max_vertex; -} - -GQuark -mash_data_error_quark (void) -{ - return g_quark_from_static_string ("mash-data-error-quark"); -} diff --git a/mash/mash-data.h b/mash/mash-data.h deleted file mode 100644 index eee1234..0000000 --- a/mash/mash-data.h +++ b/dev/null @@ -1,164 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_DATA_H__ -#define __MASH_DATA_H__ - -#include <clutter/clutter.h> - -G_BEGIN_DECLS - -#define MASH_TYPE_DATA \ - (mash_data_get_type()) -#define MASH_DATA(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_DATA, \ - MashData)) -#define MASH_DATA_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_DATA, \ - MashDataClass)) -#define MASH_IS_DATA(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_DATA)) -#define MASH_IS_DATA_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_DATA)) -#define MASH_DATA_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_TYPE_DATA, \ - MashDataClass)) - -/** - * MASH_DATA_ERROR: - * - * Error domain for #MashData errors - */ -#define MASH_DATA_ERROR mash_data_error_quark () - -typedef struct _MashData MashData; -typedef struct _MashDataClass MashDataClass; -typedef struct _MashDataPrivate MashDataPrivate; - -/** - * MashDataClass: - * - * The #MashDataClass structure contains only private data. - */ -struct _MashDataClass -{ - /*< private >*/ - GObjectClass parent_class; -}; - -/** - * MashData: - * - * The #MashData structure contains only private data. - */ -struct _MashData -{ - /*< private >*/ - GObject parent; - - MashDataPrivate *priv; -}; - -/** - * MashDataError: - * @MASH_DATA_ERROR_UNKNOWN_FORMAT: The file has an unknown format. - * @MASH_DATA_ERROR_UNKNOWN: The underlying library reported an error. - * @MASH_DATA_ERROR_MISSING_PROPERTY: A property that is needed - * by #MashData is not present in the file. For example, this - * will happen if the file does not contain the x, y and z properties. - * @MASH_DATA_ERROR_INVALID: The file is not valid. - * @MASH_DATA_ERROR_UNSUPPORTED: The file is not supported - * by your GL driver. This will happen if your driver can't support - * GL_UNSIGNED_INT indices but the model has more than 65,536 - * vertices. - * - * Error enumeration for #MashData - */ -typedef enum - { - MASH_DATA_ERROR_UNKNOWN_FORMAT, - MASH_DATA_ERROR_UNKNOWN, - MASH_DATA_ERROR_MISSING_PROPERTY, - MASH_DATA_ERROR_INVALID, - MASH_DATA_ERROR_UNSUPPORTED - } MashDataError; - -/** - * MashDataFlags: - * @MASH_DATA_NONE: No flags - * @MASH_DATA_NEGATE_X: Negate the X axis - * @MASH_DATA_NEGATE_Y: Negate the Y axis - * @MASH_DATA_NEGATE_Z: Negate the Z axis - * - * Flags used for modifying the data as it is loaded. These can be - * passed to mash_data_load(). - * - * If any of the negate flags are set then they cause the vertex and - * normal coordinates for the specified axis to be negated. This could - * be useful when loading a model from a tool which uses a different - * coordinate system than the one used in your application. For - * example, in Blender if the view is rotated such that the x-axis is - * pointing to the right, and the z-axis is pointing out of the screen - * then y-axis would be pointing directly up. However in Clutter the - * default transformation is set up such that the y-axis would be - * pointing down. Therefore if a model is loaded from Blender it would - * appear upside-down. Also all of the front faces would be in - * clockwise order. If backface culling is then enabled then the wrong - * faces would be culled with the default Cogl settings. - * - * To avoid these issues when exporting from Blender it is common to - * pass the %MASH_DATA_NEGATE_Y flag. - */ -/* The flip flags must be in sequential order */ -typedef enum - { - MASH_DATA_NONE = 0, - MASH_DATA_NEGATE_X = 1, - MASH_DATA_NEGATE_Y = 2, - MASH_DATA_NEGATE_Z = 4 - } MashDataFlags; - -GType mash_data_get_type (void) G_GNUC_CONST; - -MashData *mash_data_new (void); - -gboolean mash_data_load (MashData *self, - MashDataFlags flags, - const gchar *filename, - GError **error); - -void mash_data_render (MashData *self); - -GQuark mash_data_error_quark (void); - -void mash_data_get_extents (MashData *self, - ClutterVertex *min_vertex, - ClutterVertex *max_vertex); - -G_END_DECLS - -#endif /* __MASH_DATA_H__ */ diff --git a/mash/mash-directional-light.c b/mash/mash-directional-light.c deleted file mode 100644 index 32b4d7f..0000000 --- a/mash/mash-directional-light.c +++ b/dev/null @@ -1,185 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * SECTION:mash-directional-light - * @short_description: An light with a direction - * - * #MashDirectionalLight is the simplest light type implemented in - * Mash. It is intended to model a light that has a direction but it - * is infinitely far away. This means that the light will always reach - * the model regardless of its position. The light does however have a - * direction so the light intensity will be altered depending on the - * orientation of the vertex. Directional lights are useful for - * example to model the light emitted from the sun in an outdoor - * scene. - * - * The actor position of a #MashDirectionalLight is ignored. The - * direction of the light is always along the positive y axis (which - * is towards the bottom of the stage by default in Clutter). However - * the direction of the light is affected by the actor's - * transformation so it can be modified using the rotation properties. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <clutter/clutter.h> - -#include "mash-light.h" -#include "mash-directional-light.h" - -static void mash_directional_light_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source); -static void mash_directional_light_update_uniforms (MashLight *light, - CoglHandle program); - -G_DEFINE_TYPE (MashDirectionalLight, mash_directional_light, MASH_TYPE_LIGHT); - -#define MASH_DIRECTIONAL_LIGHT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_DIRECTIONAL_LIGHT, \ - MashDirectionalLightPrivate)) - -struct _MashDirectionalLightPrivate -{ - int light_direction_uniform_location; - - /* TRUE if the shader has changed since we last called - cogl_program_get_uniform_location for the uniforms */ - gboolean uniform_locations_dirty; -}; - -static const char -mash_directional_light_shader[] = - /* Add the ambient light term */ - " vec3 lit_color$ = mash_material.ambient.rgb * ambient_light$;\n" - /* Calculate the diffuse factor based on the angle between the - vertex normal and light direction */ - " float diffuse_factor$ = max (0.0, dot (light_direction$, normal));\n" - /* Skip the specular and diffuse terms if the vertex is not facing - the light */ - " if (diffuse_factor$ > 0.0)\n" - " {\n" - /* Add the diffuse term */ - " lit_color$ += (diffuse_factor$ * mash_material.diffuse.rgb\n" - " * diffuse_light$);\n" - /* Direction for maximum specular highlights is half way between the - eye vector and the light vector. The eye vector is hard-coded to - look down the negative z axis */ - " vec3 half_vector$ = normalize (light_direction$\n" - " + vec3 (0.0, 0.0, 1.0));\n" - " float spec_factor$ = max (0.0, dot (half_vector$, normal));\n" - " float spec_power$ = pow (spec_factor$, mash_material.shininess);\n" - /* Add the specular term */ - " lit_color$ += (mash_material.specular.rgb\n" - " * specular_light$ * spec_power$);\n" - " }\n" - /* Add it to the total computed color value */ - " cogl_color_out.xyz += lit_color$;\n" - ; - -static void -mash_directional_light_class_init (MashDirectionalLightClass *klass) -{ - MashLightClass *light_class = (MashLightClass *) klass; - - light_class->generate_shader = mash_directional_light_generate_shader; - light_class->update_uniforms = mash_directional_light_update_uniforms; - - g_type_class_add_private (klass, sizeof (MashDirectionalLightPrivate)); -} - -static void -mash_directional_light_init (MashDirectionalLight *self) -{ - MashDirectionalLightPrivate *priv; - - priv = self->priv = MASH_DIRECTIONAL_LIGHT_GET_PRIVATE (self); - - priv->uniform_locations_dirty = TRUE; -} - -/** - * mash_directional_light_new: - * - * Constructs a new directional light actor. - * - * Return value: the new light. - */ -ClutterActor * -mash_directional_light_new (void) -{ - ClutterActor *self = g_object_new (MASH_TYPE_DIRECTIONAL_LIGHT, NULL); - - return self; -} - -static void -mash_directional_light_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source) -{ - MashDirectionalLight *plight = MASH_DIRECTIONAL_LIGHT (light); - MashDirectionalLightPrivate *priv = plight->priv; - - MASH_LIGHT_CLASS (mash_directional_light_parent_class) - ->generate_shader (light, uniform_source, main_source); - - /* If the shader is being generated then the uniform locations also - need updating */ - priv->uniform_locations_dirty = TRUE; - - mash_light_append_shader (light, uniform_source, - "uniform vec3 light_direction$;\n"); - - mash_light_append_shader (light, main_source, mash_directional_light_shader); -} - -static void -mash_directional_light_update_uniforms (MashLight *light, - CoglHandle program) -{ - MashDirectionalLight *dlight = MASH_DIRECTIONAL_LIGHT (light); - MashDirectionalLightPrivate *priv = dlight->priv; - /* The light is assumed to always be pointing directly down. This - can be modified by rotating the actor */ - static const float light_direction[4] = { 0.0f, -1.0f, 0.0f, 0.0f }; - - MASH_LIGHT_CLASS (mash_directional_light_parent_class) - ->update_uniforms (light, program); - - if (priv->uniform_locations_dirty) - { - priv->light_direction_uniform_location - = mash_light_get_uniform_location (light, program, "light_direction"); - priv->uniform_locations_dirty = FALSE; - } - - /* I can't think of a good way to recognise when the transformation - of the actor may have changed so this just always updates the - light direction. Any transformations in the parent hierarchy - could cause the transformation to change without affecting the - allocation */ - - mash_light_set_direction_uniform (light, - program, - priv->light_direction_uniform_location, - light_direction); -} diff --git a/mash/mash-directional-light.h b/mash/mash-directional-light.h deleted file mode 100644 index 27f552e..0000000 --- a/mash/mash-directional-light.h +++ b/dev/null @@ -1,85 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_DIRECTIONAL_LIGHT_H__ -#define __MASH_DIRECTIONAL_LIGHT_H__ - -#include <mash/mash-light.h> - -G_BEGIN_DECLS - -#define MASH_TYPE_DIRECTIONAL_LIGHT \ - (mash_directional_light_get_type()) -#define MASH_DIRECTIONAL_LIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_DIRECTIONAL_LIGHT, \ - MashDirectionalLight)) -#define MASH_DIRECTIONAL_LIGHT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_DIRECTIONAL_LIGHT, \ - MashDirectionalLightClass)) -#define MASH_IS_DIRECTIONAL_LIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_DIRECTIONAL_LIGHT)) -#define MASH_IS_DIRECTIONAL_LIGHT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_DIRECTIONAL_LIGHT)) -#define MASH_DIRECTIONAL_LIGHT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_DIRECTIONAL_LIGHT, \ - MashDirectionalLightClass)) - -typedef struct _MashDirectionalLight MashDirectionalLight; -typedef struct _MashDirectionalLightClass MashDirectionalLightClass; -typedef struct _MashDirectionalLightPrivate MashDirectionalLightPrivate; - -/** - * MashDirectionalLight: - * - * The #MashDirectionalLight structure contains only private data. - */ -struct _MashDirectionalLightClass -{ - /*< private >*/ - MashLightClass parent_class; -}; - -/** - * MashDirectionalLight: - * - * The #MashDirectionalLight structure contains only private data. - */ -struct _MashDirectionalLight -{ - /*< private >*/ - MashLight parent; - - MashDirectionalLightPrivate *priv; -}; - -GType mash_directional_light_get_type (void) G_GNUC_CONST; - -ClutterActor *mash_directional_light_new (void); - -G_END_DECLS - -#endif /* __MASH_DIRECTIONAL_LIGHT_H__ */ diff --git a/mash/mash-enum-types.c.in b/mash/mash-enum-types.c.in deleted file mode 100644 index 7057045..0000000 --- a/mash/mash-enum-types.c.in +++ b/dev/null @@ -1,41 +0,0 @@ -/*** BEGIN file-header ***/ -#include "mash-enum-types.h" -/*** END file-header ***/ - -/*** BEGIN file-production ***/ - -/* enumerations from "@filename@" */ -#include "@filename@" - -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GType -@enum_name@_get_type (void) -{ - static volatile gsize g_enum_type_id__volatile = 0; - - if (g_once_init_enter (&g_enum_type_id__volatile)) - { - static const G@Type@Value values[] = { -/*** END value-header ***/ - -/*** BEGIN value-production ***/ - { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, -/*** END value-production ***/ - -/*** BEGIN value-tail ***/ - { 0, NULL, NULL } - }; - GType g_enum_type_id; - - g_enum_type_id = - g_@type@_register_static (g_intern_static_string ("@EnumName@"), - values); - - g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id); - } - - return g_enum_type_id__volatile; -} -/*** END value-tail ***/ diff --git a/mash/mash-enum-types.h.in b/mash/mash-enum-types.h.in deleted file mode 100644 index 63df477..0000000 --- a/mash/mash-enum-types.h.in +++ b/dev/null @@ -1,25 +0,0 @@ -/*** BEGIN file-header ***/ -#ifndef __MASH_ENUM_TYPES_H__ -#define __MASH_ENUM_TYPES_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* enumerations from "@filename@" */ -/*** END file-production ***/ - -/*** BEGIN file-tail ***/ -G_END_DECLS - -#endif /* !__MASH_ENUM_TYPES_H__ */ -/*** END file-tail ***/ - -/*** BEGIN value-header ***/ -GType @enum_name@_get_type (void) G_GNUC_CONST; -#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) - -/*** END value-header ***/ diff --git a/mash/mash-light-set.c b/mash/mash-light-set.c deleted file mode 100644 index 925d697..0000000 --- a/mash/mash-light-set.c +++ b/dev/null @@ -1,531 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * SECTION:mash-light-set - * @short_description: A group of #MashLight<!-- -->s which can be - * used to affect the appearance of a #MashModel. - * - * #MashLightSet is a toplevel object that contains a list of - * #MashLight<!-- -->s. The set which a light belongs to is separate - * from its parent actor. For a light to be useful it needs to be - * added to both a light set and a parent container. - * - * The #MashLightSet can only be used with actors that are - * specifically designed to support it. #MashModel is one such - * actor. It can be told to use a light set with - * mash_model_set_light_set(). - * - * The light set implements the Blinn-Phong lighting model which is - * the standard model used in fixed function version of OpenGL and - * Direct3D. The lighting calculations are performed per-vertex and - * then interpolated across the surface of the primitives. - * - * Lights are positioned as normal actors by adding #MashLight<!-- - * -->s them to a container and moving them. The lights do not have to - * be in any particular position relative to the models in the - * hierarchy of actors, although it wouldn't make much sense if they - * were on different stages. The lights are subclasses of - * #ClutterActor so they can be positioned and animated using the - * usual Clutter animation framework. - * - * The lighting implementation requires GLSL support from Clutter. If - * the application can still work without lighting it would be worth - * checking for shader support by passing %COGL_FEATURE_SHADERS_GLSL - * to cogl_features_available(). - * - * It should be possible to extend the lighting model and implement - * application-specific lighting algorithms by subclassing #MashLight - * and adding shader snippets by overriding - * mash_light_generate_shader(). - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <clutter/clutter.h> - -#include "mash-light-set.h" -#include "mash-light.h" - -static void mash_light_set_dispose (GObject *object); -static void mash_light_set_finalize (GObject *object); - -static gboolean mash_light_set_repaint_func (gpointer data); - -G_DEFINE_TYPE (MashLightSet, mash_light_set, G_TYPE_OBJECT); - -#define MASH_LIGHT_SET_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_LIGHT_SET, \ - MashLightSetPrivate)) - -typedef void (* MaterialColorGetFunc) (CoglMaterial *material, - CoglColor *color); - -typedef float (* MaterialFloatGetFunc) (CoglMaterial *material); - -typedef enum -{ - MATERIAL_PROP_TYPE_COLOR, - MATERIAL_PROP_TYPE_FLOAT -} MaterialPropType; - -static struct -{ - MaterialPropType type; - const char *uniform_name; - void *get_func; -} -mash_light_set_material_properties[] = - { - { - MATERIAL_PROP_TYPE_COLOR, - "mash_material.emission", - cogl_material_get_emission - }, - { - MATERIAL_PROP_TYPE_COLOR, - "mash_material.ambient", - cogl_material_get_ambient - }, - { - MATERIAL_PROP_TYPE_COLOR, - "mash_material.diffuse", - cogl_material_get_diffuse - }, - { - MATERIAL_PROP_TYPE_COLOR, - "mash_material.specular", - cogl_material_get_specular - }, - { - MATERIAL_PROP_TYPE_FLOAT, - "mash_material.shininess", - cogl_material_get_shininess - } - }; - -struct _MashLightSetPrivate -{ - CoglHandle program; - - GSList *lights; - - guint repaint_func_id; - - int normal_matrix_uniform; - - int material_uniforms[G_N_ELEMENTS (mash_light_set_material_properties)]; - - /* Set to TRUE at the beginning of every paint so that we know we - need to update the uniforms on the program before painting any - actor */ - gboolean uniforms_dirty; -}; - -static void -mash_light_set_class_init (MashLightSetClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - - gobject_class->dispose = mash_light_set_dispose; - gobject_class->finalize = mash_light_set_finalize; - - g_type_class_add_private (klass, sizeof (MashLightSetPrivate)); -} - -static void -mash_light_set_init (MashLightSet *self) -{ - MashLightSetPrivate *priv; - - priv = self->priv = MASH_LIGHT_SET_GET_PRIVATE (self); - - priv->repaint_func_id = - clutter_threads_add_repaint_func (mash_light_set_repaint_func, self, NULL); -} - -static void -mash_light_set_dispose (GObject *object) -{ - MashLightSet *self = (MashLightSet *) object; - MashLightSetPrivate *priv = self->priv; - - g_slist_foreach (priv->lights, (GFunc) g_object_unref, NULL); - g_slist_free (priv->lights); - priv->lights = NULL; - - if (priv->repaint_func_id) - { - clutter_threads_remove_repaint_func (priv->repaint_func_id); - priv->repaint_func_id = 0; - } - - G_OBJECT_CLASS (mash_light_set_parent_class)->dispose (object); -} - -static void -mash_light_set_finalize (GObject *object) -{ - MashLightSet *self = (MashLightSet *) object; - MashLightSetPrivate *priv = self->priv; - - if (priv->program) - cogl_handle_unref (priv->program); - - G_OBJECT_CLASS (mash_light_set_parent_class)->finalize (object); -} - -/** - * mash_light_set_new: - * - * Constructs a new #MashLightSet. - * - * Return value: a new #MashLightSet. - */ -MashLightSet * -mash_light_set_new (void) -{ - return g_object_new (MASH_TYPE_LIGHT_SET, NULL); -} - -static CoglHandle -mash_light_set_get_program (MashLightSet *light_set) -{ - MashLightSetPrivate *priv = light_set->priv; - - if (priv->program == COGL_INVALID_HANDLE) - { - GString *uniform_source, *main_source; - char *full_source; - CoglHandle shader; - char *info_log; - GSList *l; - int i; - - uniform_source = g_string_new (NULL); - main_source = g_string_new (NULL); - - /* Give all of the lights in the scene a chance to modify the - shader source */ - for (l = priv->lights; l; l = l->next) - mash_light_generate_shader (l->data, - uniform_source, - main_source); - - /* Append the shader boiler plate */ - g_string_append (uniform_source, - "\n" - "uniform mat3 mash_normal_matrix;\n" - "\n" - "struct MashMaterialParameters {\n" - " vec4 emission;\n" - " vec4 ambient;\n" - " vec4 diffuse;\n" - " vec4 specular;\n" - " float shininess;\n" - "};\n" - "\n" - "uniform MashMaterialParameters mash_material;\n" - "\n" - "void\n" - "main ()\n" - "{\n" - /* Start with a completely unlit vertex. The - lights should add to this color */ - " cogl_color_out = vec4 (0.0, 0.0, 0.0, 1.0);\n" - /* Calculate a transformed and normalized - vertex normal */ - " vec3 normal = normalize (mash_normal_matrix\n" - " * cogl_normal_in);\n" - /* Calculate the vertex position in eye coordinates */ - " vec4 homogenous_eye_coord\n" - " = cogl_modelview_matrix * cogl_position_in;\n" - " vec3 eye_coord = homogenous_eye_coord.xyz\n" - " / homogenous_eye_coord.w;\n"); - /* Append the main source to the uniform source to get the full - source for the shader */ - g_string_append_len (uniform_source, - main_source->str, - main_source->len); - /* Perform the standard vertex transformation and copy the - texture coordinates. FIXME: This is limited to CoglMaterials - that only have one layer. Hopefully this could be fixed when - Cogl has a way to insert shader snippets rather than having - to replace the whole pipeline. */ - g_string_append (uniform_source, - " cogl_position_out =\n" - " cogl_modelview_projection_matrix *\n" - " cogl_position_in;\n" - " cogl_tex_coord_out[0] = cogl_tex_coord_in;\n" - "}\n"); - - full_source = g_string_free (uniform_source, FALSE); - g_string_free (main_source, TRUE); - - priv->program = cogl_create_program (); - - shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX); - cogl_shader_source (shader, full_source); - g_free (full_source); - cogl_shader_compile (shader); - - if (!cogl_shader_is_compiled (shader)) - g_warning ("Error compiling light box shader"); - - info_log = cogl_shader_get_info_log (shader); - - if (info_log) - { - if (*info_log) - g_warning ("The light box shader has an info log:\n%s", info_log); - - g_free (info_log); - } - - cogl_program_attach_shader (priv->program, shader); - cogl_program_link (priv->program); - - priv->normal_matrix_uniform = - cogl_program_get_uniform_location (priv->program, "mash_normal_matrix"); - - for (i = 0; i < G_N_ELEMENTS (mash_light_set_material_properties); i++) - { - const char *uniform_name = - mash_light_set_material_properties[i].uniform_name; - - priv->material_uniforms[i] = - cogl_program_get_uniform_location (priv->program, uniform_name); - } - } - - return priv->program; -} - -/** - * mash_light_set_begin_paint: - * @light_set: A #MashLightSet instance - * @material: The material that will be used to paint - * - * This function should only be needed by custom actors that wish to - * use the lighting model of Mash. The function should be called every - * time the actor is painted. The @material parameter is used to - * specify the lighting material properties. The material is not - * otherwise read or modified. The material properties that are used - * are: the emission color, the ambient color, the diffuse color, the - * specular color and the shininess. - * - * The return value is a CoglProgram that should be used to paint the - * actor. The actor should attach this to its material using - * cogl_material_set_user_program(). - * - * #MashModel<!-- -->s are already designed to use this function when - * a light set is passed to mash_model_set_light_set(). - * - * Return value: a CoglProgram to use for rendering. - * - * Since: 0.2 - */ -CoglHandle -mash_light_set_begin_paint (MashLightSet *light_set, - CoglHandle material) -{ - MashLightSetPrivate *priv = light_set->priv; - CoglHandle program = mash_light_set_get_program (light_set); - int i; - - if (priv->uniforms_dirty) - { - GSList *l; - - /* Give all of the lights a chance to update the uniforms before we - paint the first actor using the light set */ - for (l = priv->lights; l; l = l->next) - mash_light_update_uniforms (l->data, program); - - priv->uniforms_dirty = FALSE; - } - - /* Calculate the normal matrix from the modelview matrix */ - if (priv->normal_matrix_uniform != -1) - { - CoglMatrix modelview_matrix; - CoglMatrix inverse_matrix; - float transpose_matrix[3 * 3]; - - /* Invert the matrix */ - cogl_get_modelview_matrix (&modelview_matrix); - cogl_matrix_get_inverse (&modelview_matrix, &inverse_matrix); - - /* Transpose it while converting it to 3x3 */ - transpose_matrix[0] = inverse_matrix.xx; - transpose_matrix[1] = inverse_matrix.xy; - transpose_matrix[2] = inverse_matrix.xz; - - transpose_matrix[3] = inverse_matrix.yx; - transpose_matrix[4] = inverse_matrix.yy; - transpose_matrix[5] = inverse_matrix.yz; - - transpose_matrix[6] = inverse_matrix.zx; - transpose_matrix[7] = inverse_matrix.zy; - transpose_matrix[8] = inverse_matrix.zz; - - cogl_program_set_uniform_matrix (program, - priv->normal_matrix_uniform, - 3, /* dimensions */ - 1, /* count */ - FALSE, /* transpose */ - transpose_matrix); - } - - for (i = 0; i < G_N_ELEMENTS (mash_light_set_material_properties); i++) - if (priv->material_uniforms[i] != -1) - switch (mash_light_set_material_properties[i].type) - { - case MATERIAL_PROP_TYPE_COLOR: - { - CoglColor color; - MaterialColorGetFunc get_func = - mash_light_set_material_properties[i].get_func; - float vec[4]; - - get_func (material, &color); - - vec[0] = cogl_color_get_red_float (&color); - vec[1] = cogl_color_get_green_float (&color); - vec[2] = cogl_color_get_blue_float (&color); - vec[3] = cogl_color_get_alpha_float (&color); - - cogl_program_set_uniform_float (program, - priv->material_uniforms[i], - 4, /* n_components */ - 1, /* count */ - vec); - } - break; - - case MATERIAL_PROP_TYPE_FLOAT: - { - MaterialFloatGetFunc get_func = - mash_light_set_material_properties[i].get_func; - float value; - - value = get_func (material); - - cogl_program_set_uniform_1f (program, - priv->material_uniforms[i], - value); - } - break; - } - - return program; -} - -static gboolean -mash_light_set_repaint_func (gpointer data) -{ - MashLightSet *light_set = MASH_LIGHT_SET (data); - MashLightSetPrivate *priv = light_set->priv; - - /* Mark that we need to update the uniforms the next time an actor - is painted. We can't just update the uniforms immediately because - the repaint function is called before the allocation is run so - the lights may not have the correct position yet */ - - priv->uniforms_dirty = TRUE; - - return TRUE; -} - -static void -mash_light_set_dirty_program (MashLightSet *light_set) -{ - MashLightSetPrivate *priv = light_set->priv; - - /* If we've added or removed a light then we need to regenerate the - shader */ - if (priv->program != COGL_INVALID_HANDLE) - { - cogl_handle_unref (priv->program); - priv->program = COGL_INVALID_HANDLE; - } -} - -/** - * mash_light_set_add_light: - * @light_set: A #MashLightSet instance - * @light: A #MashLight - * - * This adds a light to the set. Lights need to be added to the light - * set as well as to a container somewhere in the Clutter actor - * hierarchy in order to be useful. - */ -void -mash_light_set_add_light (MashLightSet *light_set, - MashLight *light) -{ - MashLightSetPrivate *priv; - - g_return_if_fail (MASH_IS_LIGHT_SET (light_set)); - g_return_if_fail (MASH_IS_LIGHT (light)); - - priv = light_set->priv; - - priv->lights = g_slist_prepend (priv->lights, g_object_ref_sink (light)); - - mash_light_set_dirty_program (light_set); -} - -/** - * mash_light_set_remove_light: - * @light_set: A #MashLightSet instance - * @light: A #MashLight - * - * Removes a light from the set. - */ -void -mash_light_set_remove_light (MashLightSet *light_set, - MashLight *light) -{ - MashLightSetPrivate *priv; - GSList *l, *prev = NULL; - - g_return_if_fail (MASH_IS_LIGHT_SET (light_set)); - g_return_if_fail (MASH_IS_LIGHT (light)); - - priv = light_set->priv; - - for (l = priv->lights; l; l = l->next) - if (l->data == light) - { - g_object_unref (light); - if (prev) - prev->next = l->next; - else - priv->lights = l->next; - g_slist_free_1 (l); - - mash_light_set_dirty_program (light_set); - - break; - } - else - prev = l; -} diff --git a/mash/mash-light-set.h b/mash/mash-light-set.h deleted file mode 100644 index 20c21d3..0000000 --- a/mash/mash-light-set.h +++ b/dev/null @@ -1,95 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_LIGHT_SET_H__ -#define __MASH_LIGHT_SET_H__ - -#include <clutter/clutter.h> -#include <mash/mash-light.h> - -G_BEGIN_DECLS - -#define MASH_TYPE_LIGHT_SET \ - (mash_light_set_get_type()) -#define MASH_LIGHT_SET(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_LIGHT_SET, \ - MashLightSet)) -#define MASH_LIGHT_SET_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_LIGHT_SET, \ - MashLightSetClass)) -#define MASH_IS_LIGHT_SET(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_LIGHT_SET)) -#define MASH_IS_LIGHT_SET_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_LIGHT_SET)) -#define MASH_LIGHT_SET_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_LIGHT_SET, \ - MashLightSetClass)) - -typedef struct _MashLightSet MashLightSet; -typedef struct _MashLightSetClass MashLightSetClass; -typedef struct _MashLightSetPrivate MashLightSetPrivate; - -/** - * MashLightSetClass: - * - * The #MashLightSetClass structure contains only private data. - */ -struct _MashLightSetClass -{ - /*< private >*/ - GObjectClass parent_class; -}; - -/** - * MashLightSet: - * - * The #MashLightSet structure contains only private data. - */ -struct _MashLightSet -{ - /*< private >*/ - GObjectClass parent; - - MashLightSetPrivate *priv; -}; - -GType mash_light_set_get_type (void) G_GNUC_CONST; - -MashLightSet *mash_light_set_new (void); - -void mash_light_set_add_light (MashLightSet *light_set, - MashLight *light); - -void mash_light_set_remove_light (MashLightSet *light_set, - MashLight *light); - -CoglHandle mash_light_set_begin_paint (MashLightSet *light_set, - CoglHandle material); - -G_END_DECLS - -#endif /* __MASH_LIGHT_SET_H__ */ diff --git a/mash/mash-light.c b/mash/mash-light.c deleted file mode 100644 index 592de87..0000000 --- a/mash/mash-light.c +++ b/dev/null @@ -1,802 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * SECTION:mash-light - * @short_description: An object for the common state of all light types - * - * #MashLight is the abstract base class of all lights in Mash. It can - * not be instantiated directly. Instead one of its subclasses should - * be used such as #MashPointLight, #MashSpotLight or - * #MashDirectionalLight. - * - * #MashLight<!-- -->s must be added to a #MashLightSet and a parent - * container before they will have any effect. - * - * #MashLight contains three light colors that are common to all - * three light types that Mash supports. These are ambient, diffuse - * and specular. The colors are of the lights are combined with the - * corresponding colors of the #CoglMaterial to give a final fragment - * color. The material colors can be changed for a #MashModel by - * extracting the #CoglMaterial with mash_model_get_material() and - * then calling functions such as cogl_material_set_diffuse(). - * - * #MashLight can be subclassed in an application to provide custom - * lighting algorithms. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <clutter/clutter.h> -#include <string.h> -#include <math.h> - -#include "mash-light.h" -#include "mash-light-set.h" - -static void mash_light_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void mash_light_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); - -static void mash_light_real_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source); -static void mash_light_real_update_uniforms (MashLight *light, - CoglHandle program); - -/* Length in characters not including any terminating NULL of the - unique string that we append to uniform symbols */ -#define MASH_LIGHT_UNIQUE_SYMBOL_SIZE (1 + 8) - -static const ClutterColor -mash_light_default_color = { 0xff, 0xff, 0xff, 0xff }; - -G_DEFINE_ABSTRACT_TYPE (MashLight, mash_light, CLUTTER_TYPE_ACTOR); - -#define MASH_LIGHT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_LIGHT, \ - MashLightPrivate)) - -#define MASH_LIGHT_COLOR_AMBIENT 0 -#define MASH_LIGHT_COLOR_DIFFUSE 1 -#define MASH_LIGHT_COLOR_SPECULAR 2 -#define MASH_LIGHT_COLOR_COUNT 3 - -static const char * -mash_light_color_names[MASH_LIGHT_COLOR_COUNT] = - { - "ambient_light", - "diffuse_light", - "specular_light" - }; - -struct _MashLightPrivate -{ - /* This string gets appended to symbols that we want to be unique to - this light in the shader snippets */ - char unique_str[MASH_LIGHT_UNIQUE_SYMBOL_SIZE + 1]; - - /* Light colors for the different lighting effects that are shared - by all light types */ - ClutterColor light_colors[MASH_LIGHT_COLOR_COUNT]; - - int uniform_locations[MASH_LIGHT_COLOR_COUNT]; - - /* TRUE if the shader has changed since we last called - cogl_program_get_uniform_location for the color uniforms */ - gboolean uniform_locations_dirty; - - /* Contains a bit for each light color. The bit is set if the color - value has changed since we last copied the values to the - uniforms */ - guint dirty_uniforms; - - /* This contains the modelview matrix for the light including all of - its parent's transformations. It is probably expensive to - calculate and the matrix is used to update the uniforms for both - spot lights and point lights so it is cached to avoid calculating - it twice */ - gboolean modelview_matrix_dirty; - CoglMatrix modelview_matrix; -}; - -enum - { - PROP_0, - - PROP_AMBIENT, - PROP_DIFFUSE, - PROP_SPECULAR - }; - -static void -mash_light_class_init (MashLightClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - GParamSpec *pspec; - - gobject_class->get_property = mash_light_get_property; - gobject_class->set_property = mash_light_set_property; - - klass->generate_shader = mash_light_real_generate_shader; - klass->update_uniforms = mash_light_real_update_uniforms; - - pspec = clutter_param_spec_color ("ambient", - "Ambient", - "The ambient color emitted by the light", - &mash_light_default_color, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, PROP_AMBIENT, pspec); - - pspec = clutter_param_spec_color ("diffuse", - "Diffuse", - "The diffuse color emitted by the light", - &mash_light_default_color, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, PROP_DIFFUSE, pspec); - - pspec = clutter_param_spec_color ("specular", - "Specular", - "The specular color emitted by the light", - &mash_light_default_color, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, PROP_SPECULAR, pspec); - - g_type_class_add_private (klass, sizeof (MashLightPrivate)); -} - -static void -mash_light_init (MashLight *self) -{ - MashLightPrivate *priv; - guint32 gid; - int i; - - priv = self->priv = MASH_LIGHT_GET_PRIVATE (self); - - /* We append the gid of the actor to any symbols that need to be - unique to this */ - gid = clutter_actor_get_gid (CLUTTER_ACTOR (self)); - g_snprintf (priv->unique_str, MASH_LIGHT_UNIQUE_SYMBOL_SIZE + 1, - "g%08" G_GUINT32_FORMAT, gid); - - for (i = 0; i < MASH_LIGHT_COLOR_COUNT; i++) - priv->light_colors[i] = mash_light_default_color; - - priv->uniform_locations_dirty = TRUE; - priv->dirty_uniforms = (1 << MASH_LIGHT_COLOR_COUNT) - 1; - - priv->modelview_matrix_dirty = TRUE; -} - -static void -mash_light_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MashLight *light = MASH_LIGHT (object); - - switch (prop_id) - { - case PROP_AMBIENT: - { - ClutterColor ambient; - mash_light_get_ambient (light, &ambient); - clutter_value_set_color (value, &ambient); - } - break; - - case PROP_DIFFUSE: - { - ClutterColor diffuse; - mash_light_get_diffuse (light, &diffuse); - clutter_value_set_color (value, &diffuse); - } - break; - - case PROP_SPECULAR: - { - ClutterColor specular; - mash_light_get_specular (light, &specular); - clutter_value_set_color (value, &specular); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -mash_light_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MashLight *light = MASH_LIGHT (object); - - switch (prop_id) - { - case PROP_AMBIENT: - mash_light_set_ambient (light, clutter_value_get_color (value)); - break; - - case PROP_DIFFUSE: - mash_light_set_diffuse (light, clutter_value_get_color (value)); - break; - - case PROP_SPECULAR: - mash_light_set_specular (light, clutter_value_get_color (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/** - * mash_light_set_ambient: - * @light: The #MashLight to modify - * @ambient: The new color value - * - * Sets the ‘ambient’ color emitted by the light. If the light reaches - * a vertex at all then the ambient color affects the vertex - * regardless of its orientation or distance from the light. In - * real-world lighting, even if an object isn't in a direct line of - * sight to a light it can still be partially lit due to the fact that - * light can bounce off other objects to reach it. The Mash lighting - * model doesn't simulate this bouncing so the ambient color is often - * used to give an approximation of the effect. - */ -void -mash_light_set_ambient (MashLight *light, const ClutterColor *ambient) -{ - MashLightPrivate *priv; - - g_return_if_fail (MASH_IS_LIGHT (light)); - - priv = light->priv; - - if (!clutter_color_equal (ambient, - &priv->light_colors + MASH_LIGHT_COLOR_AMBIENT)) - { - priv->light_colors[MASH_LIGHT_COLOR_AMBIENT] = *ambient; - priv->dirty_uniforms |= 1 << MASH_LIGHT_COLOR_AMBIENT; - g_object_notify (G_OBJECT (light), "ambient"); - } -} - -/** - * mash_light_get_ambient: - * @light: The #MashLight to query - * @ambient: A return location for the color - * - * Retrieves the ‘ambient’ color emitted by the light. - */ -void -mash_light_get_ambient (MashLight *light, ClutterColor *ambient) -{ - g_return_if_fail (MASH_IS_LIGHT (light)); - - *ambient = light->priv->light_colors[MASH_LIGHT_COLOR_AMBIENT]; -} - -/** - * mash_light_set_diffuse: - * @light: The #MashLight to modify - * @diffuse: The new color value - * - * Sets the ‘diffuse’ color emitted by the light. The diffuse color is - * only visible on an object if is facing the light. The orientation - * of the object is determined per-vertex using the vertex's - * normal. The diffuse color will be darkened depending on how - * directly the object faces the light. - */ -void -mash_light_set_diffuse (MashLight *light, const ClutterColor *diffuse) -{ - MashLightPrivate *priv; - - g_return_if_fail (MASH_IS_LIGHT (light)); - - priv = light->priv; - - if (!clutter_color_equal (diffuse, - &priv->light_colors + MASH_LIGHT_COLOR_DIFFUSE)) - { - priv->light_colors[MASH_LIGHT_COLOR_DIFFUSE] = *diffuse; - priv->dirty_uniforms |= 1 << MASH_LIGHT_COLOR_DIFFUSE; - g_object_notify (G_OBJECT (light), "diffuse"); - } -} - -/** - * mash_light_get_diffuse: - * @light: The #MashLight to query - * @diffuse: A return location for the color - * - * Retrieves the ‘diffuse’ color emitted by the light. - */ -void -mash_light_get_diffuse (MashLight *light, ClutterColor *diffuse) -{ - g_return_if_fail (MASH_IS_LIGHT (light)); - - *diffuse = light->priv->light_colors[MASH_LIGHT_COLOR_DIFFUSE]; -} - -/** - * mash_light_set_specular: - * @light: The #MashLight to modify - * @specular: The new color value - * - * Sets the ‘specular’ color emitted by the light. The specular color - * is used to add highlights to an object wherever the angle to the - * light is close to the angle that the object is being viewed - * from. For example, if you were modelling a snooker ball with a - * bright light above it, this property will allow you add a bright - * part where the light can directly reflect off the ball into the - * eye. It is common to set this to a bright white value. - */ -void -mash_light_set_specular (MashLight *light, const ClutterColor *specular) -{ - MashLightPrivate *priv; - - g_return_if_fail (MASH_IS_LIGHT (light)); - - priv = light->priv; - - if (!clutter_color_equal (specular, - &priv->light_colors + MASH_LIGHT_COLOR_SPECULAR)) - { - priv->light_colors[MASH_LIGHT_COLOR_SPECULAR] = *specular; - priv->dirty_uniforms |= 1 << MASH_LIGHT_COLOR_SPECULAR; - g_object_notify (G_OBJECT (light), "specular"); - } -} - -/** - * mash_light_get_specular: - * @light: The #MashLight to query - * @specular: A return location for the color - * - * Retrieves the ‘specular’ color emitted by the light. - */ -void -mash_light_get_specular (MashLight *light, ClutterColor *specular) -{ - g_return_if_fail (MASH_IS_LIGHT (light)); - - *specular = light->priv->light_colors[MASH_LIGHT_COLOR_SPECULAR]; -} - -/** - * mash_light_generate_shader: - * @light: A #MashLight - * @uniform_source: A location to append uniforms declarations to - * @main_source: A location to append lighting algorithm snippets to - * - * This function is used to generate the shader code required to - * implement a paraticular. It would not usually need to be called - * from an application. Instead it is called automatically by - * #MashLightSet. - * - * This function can be overriden in subclasses of #MashLight to - * implement custom lighting algorithms. The function will be called - * before the first actor that is using the light set is painted - * whenever it deems that the shader needs to be regenerated. It - * currently will do this whenever a light is added or removed from - * the box. The implementation should append any GLSL code to - * @uniform_source and @main_source needed to implement the algorithm. - * - * The implementation should use mash_light_append_shader() to append - * code to either of the shader strings so that it can declare - * variables that are unique to the individual actor. - * - * The code in @uniform_source is inserted at the global level of a - * vertex shader. It is expected that the light will add uniform - * declarations here. For example, if the light depends on the light's - * position it could define a uniform for the position like so: - * - * |[ - * mash_light_append_shader (light, uniform_source, - * "uniform vec3 position$;\n"); - * ]| - * - * The code in @main_source is inserted with the main function of a - * vertex shader. The snippet added by a light is expected to modify - * the cogl_color_out attribute according to its algorithm. The snippet - * can also use the following variables which will be initialized - * before the snippet is run: - * - * normal: This will be a vec3 which is initialized to the transformed - * and normalized vertex normal. - * - * eye_coord: This will be a vec3 containing the vertex coordinates in - * eye-space. - * - * ambient_light: A vec3 uniform containing the ambient light color. - * - * diffuse_light: A vec3 uniform containing the diffuse light color. - * - * specular_light: A vec3 uniform containing the specular light color. - * - * mash_material.ambient: A vec4 containing the current material's - * ambient color. - * - * mash_material.diffuse: A vec4 containing the current material's - * diffuse color. - * - * mash_material.specular: A vec4 containing the current material's - * specular color. - * - * mash_material.emission: A vec4 containing the current material's - * emission color. - * - * mash_material.shininess: A float containing the current material's - * shininess value. - * - * mash_normal_matrix: A version of the modelview matrix used to - * transform normals. - * - * In addition to these variables the shader can use all of the - * built-in Cogl uniforms. Please see a future version of the Cogl - * documentation for a description of these. - * - * The implementation should always chain up to the #MashLight - * implementation so that it can declare the built-in uniforms. - */ -void -mash_light_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source) -{ - g_return_if_fail (MASH_IS_LIGHT (light)); - - MASH_LIGHT_GET_CLASS (light)->generate_shader (light, - uniform_source, - main_source); -} - -/** - * mash_light_update_uniforms: - * @light: The #MashLight that needs updating - * @program: A #CoglProgram containing the uniforms - * - * This function is used by #MashLightSet to implement the lights. It - * should not need to be called by an application directly. - * - * This function is virtual and can be overriden by subclasses to - * implement custom lighting algorithms. The function is called during - * the paint sequence of #MashLightSet on every light before any other - * actors are painted. This gives the light implementation a chance to - * update any uniforms it may have declared in the override of - * mash_light_generate_shader(). - * - * The program is always made current with cogl_program_use() before - * this method is called so it is safe to directly call - * cogl_program_uniform_1f() and friends to update the uniforms. The - * @program handle is passed in so that the program can also be - * queried to the locations of named - * uniforms. mash_light_get_uniform_location() can be used to make - * this easier when a uniform is named uniquely using the ‘$’ symbol - * in mash_light_append_shader(). - */ -void -mash_light_update_uniforms (MashLight *light, CoglHandle program) -{ - g_return_if_fail (MASH_IS_LIGHT (light)); - - MASH_LIGHT_GET_CLASS (light)->update_uniforms (light, program); -} - -/** - * mash_light_append_shader: - * @light: The #MashLight which is generating the shader - * @shader_source: The string to append to - * @snippet: A snippet of GLSL - * - * This is a convenience intended to be used within - * mash_light_generate_shader() to generate shader snippets with - * actor-specific variable names. It should not generally need to be - * called by an application unless it is implementing its own lighting - * algorithms. - * - * The code in @snippet is appended to @shader_source but all - * occurences of the ‘$’ symbol are replaced with a string that is - * unique to @light object. This is useful when multiple lights of the - * same type are added to a single light box. For example, if a light - * needs to have a position uniform it could make a call like the - * following: - * - * |[ - * mash_light_append_shader (light, uniform_source, - * "uniform vec3 position$;\n"); - * ]| - * - * The ‘position’ will get translated to something like - * ‘positiong00000002’. - */ -void -mash_light_append_shader (MashLight *light, - GString *shader_source, - const char *snippet) -{ - MashLightPrivate *priv; - const char *dollar_pos; - - g_return_if_fail (MASH_IS_LIGHT (light)); - - priv = light->priv; - - /* Replace any '$' symbols in the shader with the unique - identifier */ - while ((dollar_pos = strchr (snippet, '$'))) - { - g_string_append_len (shader_source, snippet, dollar_pos - snippet); - g_string_append_len (shader_source, priv->unique_str, - MASH_LIGHT_UNIQUE_SYMBOL_SIZE); - snippet = dollar_pos + 1; - } - - g_string_append (shader_source, snippet); -} - -/** - * mash_light_get_uniform_location: - * @light: The #MashLight which is generating the shader - * @program: The program passed in from mash_light_update_uniforms(). - * @uniform_name: The name of a uniform - * - * This is a convenience intended to be used within - * mash_light_update_uniforms() to help query uniform locations. It - * should not generally need to be called by an application unless it - * is implementing its own lighting algorithms. - * - * This is a wrapper around cogl_program_get_uniform_location() which - * appends an actor specific string to the uniform name. This is - * useful when uniforms have been declared like ‘position$’ within - * mash_light_append_shader(). - */ -int -mash_light_get_uniform_location (MashLight *light, - CoglHandle program, - const char *uniform_name) -{ - MashLightPrivate *priv; - char *unique_name; - int location; - - g_return_val_if_fail (MASH_IS_LIGHT (light), -1); - - priv = light->priv; - - /* Append this light's unique identifier to the uniform name */ - unique_name = g_strconcat (uniform_name, priv->unique_str, NULL); - - location = cogl_program_get_uniform_location (program, unique_name); - - g_free (unique_name); - - return location; -} - -static void -transpose_matrix (const CoglMatrix *matrix, - CoglMatrix *transpose) -{ - const float *matrix_p = cogl_matrix_get_array (matrix); - float matrix_array[16]; - int i, j; - - /* This should probably be in Cogl */ - for (j = 0; j < 4; j++) - for (i = 0; i < 4; i++) - matrix_array[i * 4 + j] = matrix_p[j * 4 + i]; - - cogl_matrix_init_from_array (transpose, matrix_array); -} - -/** - * mash_light_get_modelview_matrix: - * @light: A #MashLight - * @matrix: The return location for the matrix - * - * Gets the modelview matrix for the light including all of the - * transformations for its parent actors. This should be used for - * updating uniforms that depend on the actor's transformation or - * position. - */ -void -mash_light_get_modelview_matrix (MashLight *light, - CoglMatrix *matrix) -{ - MashLightPrivate *priv = light->priv; - - if (priv->modelview_matrix_dirty) - { - ClutterActor *actor; - GSList *parents = NULL, *l; - - cogl_matrix_init_identity (&priv->modelview_matrix); - - /* Get the complete modelview matrix for light by applying all of - its parent transformations as well as its own in reverse */ - for (actor = CLUTTER_ACTOR (light); - actor; - actor = clutter_actor_get_parent (actor)) - parents = g_slist_prepend (parents, actor); - - for (l = parents; l; l = l->next) - { - CoglMatrix actor_matrix; - - cogl_matrix_init_identity (&actor_matrix); - clutter_actor_get_transformation_matrix (CLUTTER_ACTOR (l->data), - &actor_matrix); - - cogl_matrix_multiply (&priv->modelview_matrix, - &priv->modelview_matrix, - &actor_matrix); - } - - g_slist_free (parents); - - priv->modelview_matrix_dirty = FALSE; - } - - *matrix = priv->modelview_matrix; -} - -/** - * mash_light_set_direction_uniform: - * @light: The #MashLight which is generating the shader - * @uniform_location: The location of the uniform - * @direction_in: The untransformed direction uniform - * - * This is a convenience intended to be used within - * mash_light_update_uniforms() to help set uniforms. It - * should not generally need to be called by an application unless it - * is implementing its own lighting algorithms. - * - * This is intended to help when setting a direction - * uniform. @direction_in should be an untransformed array of 3 floats - * representing a vector. The vector will be transformed into eye - * space according to the inverse transposed matrix of @light so that - * it won't change direction for non-uniform scaling transformations. - */ -void -mash_light_set_direction_uniform (MashLight *light, - CoglHandle program, - int uniform_location, - const float *direction_in) -{ - float light_direction[4]; - CoglMatrix matrix, inverse_matrix; - float magnitude; - - memcpy (light_direction, direction_in, sizeof (light_direction)); - - mash_light_get_modelview_matrix (light, &matrix); - - /* To safely transform the direction when the matrix might not be - orthogonal we need the transposed inverse matrix */ - - cogl_matrix_get_inverse (&matrix, &inverse_matrix); - transpose_matrix (&inverse_matrix, &matrix); - - cogl_matrix_transform_point (&matrix, - light_direction + 0, - light_direction + 1, - light_direction + 2, - light_direction + 3); - - /* Normalize the light direction */ - magnitude = sqrtf ((light_direction[0] * light_direction[0]) - + (light_direction[1] * light_direction[1]) - + (light_direction[2] * light_direction[2])); - light_direction[0] /= magnitude; - light_direction[1] /= magnitude; - light_direction[2] /= magnitude; - - cogl_program_set_uniform_float (program, - uniform_location, - 3, 1, - light_direction); -} - -static void -mash_light_real_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source) -{ - MashLightPrivate *priv = light->priv; - - /* If the shader is being regenerated then we know that the uniform - locations are dirty */ - priv->uniform_locations_dirty = TRUE; - priv->dirty_uniforms = (1 << MASH_LIGHT_COLOR_COUNT) - 1; - - /* Add the uniform definitions for the colors of this light */ - mash_light_append_shader (light, - uniform_source, - "uniform vec3 ambient_light$;\n" - "uniform vec3 diffuse_light$;\n" - "uniform vec3 specular_light$;\n"); -} - -static void -mash_light_real_update_uniforms (MashLight *light, - CoglHandle program) -{ - MashLightPrivate *priv = light->priv; - int i; - - /* We need to recalculate the light's transformation matrix. It is - assumed the subclasses will chain-up first before calling - mash_light_get_transformation_matrix(), otherwise this won't work - correctly */ - priv->modelview_matrix_dirty = TRUE; - - if (priv->uniform_locations_dirty) - { - for (i = 0; i < MASH_LIGHT_COLOR_COUNT; i++) - priv->uniform_locations[i] - = mash_light_get_uniform_location (light, program, - mash_light_color_names[i]); - - priv->uniform_locations_dirty = FALSE; - } - - for (i = 0; i < MASH_LIGHT_COLOR_COUNT; i++) - if (priv->dirty_uniforms & (1 << i)) - { - const ClutterColor *color = priv->light_colors + i; - float vec[3]; - - vec[0] = color->red / 255.0f; - vec[1] = color->green / 255.0f; - vec[2] = color->blue / 255.0f; - - cogl_program_set_uniform_float (program, - priv->uniform_locations[i], - 3, 1, vec); - } - - priv->dirty_uniforms = 0; -} diff --git a/mash/mash-light.h b/mash/mash-light.h deleted file mode 100644 index ef16104..0000000 --- a/mash/mash-light.h +++ b/dev/null @@ -1,121 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_LIGHT_H__ -#define __MASH_LIGHT_H__ - -#include <clutter/clutter.h> - -G_BEGIN_DECLS - -#define MASH_TYPE_LIGHT \ - (mash_light_get_type()) -#define MASH_LIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_LIGHT, \ - MashLight)) -#define MASH_LIGHT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_LIGHT, \ - MashLightClass)) -#define MASH_IS_LIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_LIGHT)) -#define MASH_IS_LIGHT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_LIGHT)) -#define MASH_LIGHT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_LIGHT, \ - MashLightClass)) - -typedef struct _MashLight MashLight; -typedef struct _MashLightClass MashLightClass; -typedef struct _MashLightPrivate MashLightPrivate; - -/** - * MashLightClass: - * @generate_shader: Virtual used for creating custom light types - * @update_uniforms: Virtual used for creating custom light types - */ -struct _MashLightClass -{ - /*< private >*/ - ClutterActorClass parent_class; - - /*< public >*/ - void (* generate_shader) (MashLight *light, - GString *uniform_source, - GString *main_source); - void (* update_uniforms) (MashLight *light, - CoglHandle program); -}; - -/** - * MashLight: - * - * The #MashLight structure contains only private data. - */ -struct _MashLight -{ - /*< private >*/ - ClutterActor parent; - - MashLightPrivate *priv; -}; - -GType mash_light_get_type (void) G_GNUC_CONST; - -void mash_light_set_ambient (MashLight *light, const ClutterColor *ambient); -void mash_light_get_ambient (MashLight *light, ClutterColor *ambient); - -void mash_light_set_diffuse (MashLight *light, const ClutterColor *diffuse); -void mash_light_get_diffuse (MashLight *light, ClutterColor *diffuse); - -void mash_light_set_specular (MashLight *light, const ClutterColor *specular); -void mash_light_get_specular (MashLight *light, ClutterColor *specular); - -void mash_light_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source); -void mash_light_update_uniforms (MashLight *light, - CoglHandle program); - -int mash_light_get_uniform_location (MashLight *light, - CoglHandle program, - const char *uniform_name); - -void mash_light_append_shader (MashLight *light, - GString *shader_source, - const char *snippet); - -void mash_light_get_modelview_matrix (MashLight *light, - CoglMatrix *matrix); - -void mash_light_set_direction_uniform (MashLight *light, - CoglHandle program, - int uniform_location, - const float *direction_in); - -G_END_DECLS - -#endif /* __MASH_LIGHT_H__ */ diff --git a/mash/mash-model.c b/mash/mash-model.c deleted file mode 100644 index 77c424b..0000000 --- a/mash/mash-model.c +++ b/dev/null @@ -1,817 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * SECTION:mash-model - * @short_description: An actor that can be used to render a PLY model. - * - * #MashModel is an actor subclass that can be used to render a - * 3D model. The model is a normal #ClutterActor that can be animated - * and positioned with the methods of #ClutterActor. - * - * By default the model will be scaled to best fit within the size of - * the actor. Therefore it is possible to take a small model that may - * have positions ranging between -1 and 1 and draw it at a larger - * size just by setting the size on the actor. This behaviour can be - * disabled with mash_model_set_fit_to_allocation(). - * - * The actual data for the model is stored in a separate object called - * #MashData. This can be used to share the data for a model - * between multiple actors without having to duplicate resources of - * the data. Alternatively mash_model_new_from_file() can be - * used as a convenience wrapper to easily make an actor out of a PLY - * without having to worry about #MashData. To share the data - * with another actor, call mash_model_get_data() on an - * existing actor then call mash_model_set_data() with the - * return value on a new actor. - * - * The model can be rendered with any Cogl material. By default the - * model will use a solid white material. The material color is - * blended with the model's vertex colors so the white material will - * cause the vertex colors to be used directly. #MashData is - * able to load texture coordinates from the PLY file so it is - * possible to render a textured model by setting a texture layer on - * the material, like so: - * - * |[ - * /* Create an actor out of a PLY model file */ - * ClutterActor *model - * = mash_model_new_from_file ("some-model.ply", NULL); - * /* Get a handle to the default material for the actor */ - * CoglHandle material - * = mash_model_get_material (MASH_MODEL (model)); - * /* Load a texture image from a file */ - * CoglHandle texture - * = cogl_texture_new_from_file ("some-image.png", COGL_TEXTURE_NONE, - * COGL_PIXEL_FORMAT_ANY, NULL); - * /* Set a texture layer on the material */ - * cogl_material_set_layer (material, 0, texture); - * /* The texture is now referenced by the material so we can - * drop the reference we have */ - * cogl_handle_unref (texture); - * ]| - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib-object.h> -#include <string.h> -#include <cogl/cogl.h> -#include <clutter/clutter.h> - -#include "mash-model.h" -#include "mash-data.h" - -static void mash_model_dispose (GObject *object); - -static void mash_model_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void mash_model_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); - -static void mash_model_paint (ClutterActor *actor); - -static void mash_model_pick (ClutterActor *actor, - const ClutterColor *pick_color); - -static void mash_model_get_preferred_width (ClutterActor *actor, - gfloat for_height, - gfloat *minimum_width, - gfloat *natural_width); -static void mash_model_get_preferred_height (ClutterActor *actor, - gfloat for_width, - gfloat *minimum_height, - gfloat *natural_height); - -static void mash_model_allocate (ClutterActor *actor, - const ClutterActorBox *box, - ClutterAllocationFlags flags); - -G_DEFINE_TYPE (MashModel, mash_model, CLUTTER_TYPE_ACTOR); - -#define MASH_MODEL_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_MODEL, \ - MashModelPrivate)) - -struct _MashModelPrivate -{ - MashData *data; - MashLightSet *light_set; - CoglHandle material, pick_material; - /* Whether the model should be transformed to fill the allocation */ - gboolean fit_to_allocation; - /* The amount to scale (on all axes) when fit_to_allocation is - TRUE. This is calculated in the allocate method */ - gfloat scale; - /* Translation used when fit_to_allocation is TRUE. This is - calculated in the allocate method */ - gfloat translate_x, translate_y, translate_z; -}; - -enum - { - PROP_0, - - PROP_MATERIAL, - PROP_DATA, - PROP_LIGHT_SET, - PROP_FIT_TO_ALLOCATION - }; - -static void -mash_model_class_init (MashModelClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - ClutterActorClass *actor_class = (ClutterActorClass *) klass; - GParamSpec *pspec; - - gobject_class->dispose = mash_model_dispose; - gobject_class->get_property = mash_model_get_property; - gobject_class->set_property = mash_model_set_property; - - actor_class->paint = mash_model_paint; - actor_class->pick = mash_model_pick; - actor_class->get_preferred_width = mash_model_get_preferred_width; - actor_class->get_preferred_height = mash_model_get_preferred_height; - actor_class->allocate = mash_model_allocate; - - pspec = g_param_spec_boxed ("material", - "Material", - "The Cogl material to render with", - COGL_TYPE_HANDLE, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, PROP_MATERIAL, pspec); - - pspec = g_param_spec_object ("data", - "Data", - "The MashData to render", - MASH_TYPE_DATA, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, PROP_DATA, pspec); - - pspec = g_param_spec_object ("light-set", - "Light set", - "The MashLightSet to use for the lighting model", - MASH_TYPE_LIGHT_SET, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, PROP_LIGHT_SET, pspec); - - pspec = g_param_spec_boolean ("fit-to-allocation", - "Fit to allocation", - "Whether to transform the model so that " - "it fills the actor's allocation while " - "preserving the aspect ratio", - TRUE, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, - PROP_FIT_TO_ALLOCATION, pspec); - - g_type_class_add_private (klass, sizeof (MashModelPrivate)); -} - -static void -mash_model_init (MashModel *self) -{ - MashModelPrivate *priv; - - priv = self->priv = MASH_MODEL_GET_PRIVATE (self); - - /* Default to a plain white material */ - priv->material = cogl_material_new (); - - priv->fit_to_allocation = TRUE; -} - -/** - * mash_model_new: - * - * Constructs a new #MashModel. Nothing will be rendered by the - * model until a #MashData is attached using - * mash_model_set_data(). - * - * Return value: a new #MashModel. - */ - -ClutterActor * -mash_model_new (void) -{ - ClutterActor *self = g_object_new (MASH_TYPE_MODEL, NULL); - - return self; -} - -/** - * mash_model_new_from_file: - * @flags: Flags for loading the data. - * @filename: The name of a PLY file to load. - * @error: Return location for a #GError or %NULL. - * - * This is a convenience function that creates a new #MashData - * and immediately loads the data in @filename. If the load succeeds a - * new #MashModel will be created for the data. The model has a - * default white material so that if vertices of the model have any - * color attributes they will be used directly. The material does not - * have textures by default so if you want the model to be textured - * you will need to modify the material. - * - * Return value: a new #MashModel or %NULL if the load failed. - */ -ClutterActor * -mash_model_new_from_file (MashDataFlags flags, - const gchar *filename, - GError **error) -{ - MashData *data = mash_data_new (); - ClutterActor *model = NULL; - - if (mash_data_load (data, flags, filename, error)) - { - model = mash_model_new (); - mash_model_set_data (MASH_MODEL (model), data); - } - - g_object_unref (data); - - return model; -} - -static void -mash_model_dispose (GObject *object) -{ - MashModel *self = (MashModel *) object; - MashModelPrivate *priv = self->priv; - - mash_model_set_data (self, NULL); - mash_model_set_material (self, COGL_INVALID_HANDLE); - - if (priv->pick_material) - { - cogl_handle_unref (priv->pick_material); - priv->pick_material = COGL_INVALID_HANDLE; - } - - mash_model_set_light_set (self, NULL); - - G_OBJECT_CLASS (mash_model_parent_class)->dispose (object); -} - -/** - * mash_model_set_material: - * @self: A #MashModel instance - * @material: A handle to a Cogl material - * - * Replaces the material that will be used to render the model with - * the given one. By default a #MashModel will use a solid white - * material. However the color of the material is still blended with - * the vertex colors so the white material will cause the vertex - * colors to be used directly. If you want the model to be textured - * you will need to create a material that has a texture layer and set - * it with this function. - * - * If a #MashLightSet is used with the model then the material given - * here will be modified to use the program generated by that light - * set. If multiple models are expected to use the same material with - * different light sets, it would be better to use a different copy of - * the same material for each set of models so that they don't - * repeatedly change the program on the material during paint. - */ -void -mash_model_set_material (MashModel *self, - CoglHandle material) -{ - MashModelPrivate *priv; - - g_return_if_fail (MASH_IS_MODEL (self)); - g_return_if_fail (material == COGL_INVALID_HANDLE - || cogl_is_material (material)); - - priv = self->priv; - - if (material) - cogl_handle_ref (material); - - if (priv->material) - cogl_handle_unref (priv->material); - - priv->material = material; - - clutter_actor_queue_redraw (CLUTTER_ACTOR (self)); - - g_object_notify (G_OBJECT (self), "material"); -} - -/** - * mash_model_get_material: - * @self: A #MashModel instance - * - * Gets the material that will be used to render the model. The - * material can be modified to affect the appearence of the model. By - * default the material will be solid white. - * - * Return value: a handle to the Cogl material used by the model. - */ -CoglHandle -mash_model_get_material (MashModel *self) -{ - g_return_val_if_fail (MASH_IS_MODEL (self), COGL_INVALID_HANDLE); - - return self->priv->material; -} - -static void -mash_model_render_data (MashModel *self) -{ - MashModelPrivate *priv = self->priv; - - if (priv->fit_to_allocation) - { - cogl_push_matrix (); - - cogl_translate (priv->translate_x, - priv->translate_y, - priv->translate_z); - cogl_scale (priv->scale, priv->scale, priv->scale); - } - - mash_data_render (priv->data); - - if (priv->fit_to_allocation) - cogl_pop_matrix (); -} - -static void -mash_model_paint (ClutterActor *actor) -{ - MashModel *self = MASH_MODEL (actor); - MashModelPrivate *priv; - - g_return_if_fail (MASH_IS_MODEL (self)); - - priv = self->priv; - - /* Silently fail if we haven't got any data or a material */ - if (priv->data == NULL || priv->material == COGL_INVALID_HANDLE) - return; - - if (priv->light_set) - { - CoglHandle program = mash_light_set_begin_paint (priv->light_set, - priv->material); - cogl_material_set_user_program (priv->material, program); - } - - cogl_set_source (priv->material); - - mash_model_render_data (self); -} - -static void -mash_model_pick (ClutterActor *actor, - const ClutterColor *pick_color) -{ - MashModel *self = MASH_MODEL (actor); - MashModelPrivate *priv; - CoglColor color; - - g_return_if_fail (MASH_IS_MODEL (self)); - - priv = self->priv; - - /* Silently fail if we haven't got any data */ - if (priv->data == NULL) - return; - - if (priv->pick_material == COGL_INVALID_HANDLE) - { - GError *error = NULL; - priv->pick_material = cogl_material_new (); - if (!cogl_material_set_layer_combine (priv->pick_material, 0, - "RGBA=REPLACE(CONSTANT)", - &error)) - { - g_warning ("Error setting pick combine: %s", error->message); - g_clear_error (&error); - } - } - - cogl_color_set_from_4ub (&color, - pick_color->red, - pick_color->green, - pick_color->blue, - 255); - cogl_material_set_layer_combine_constant (priv->pick_material, 0, &color); - - cogl_set_source (priv->pick_material); - - mash_model_render_data (self); -} - -/** - * mash_model_get_data: - * @self: A #MashModel instance - * - * Gets the model data that will be used to render the actor. - * - * Return value: A pointer to a #MashData instance or %NULL if - * no data has been set yet. - */ -MashData * -mash_model_get_data (MashModel *self) -{ - g_return_val_if_fail (MASH_IS_MODEL (self), NULL); - - return self->priv->data; -} - -/** - * mash_model_set_data: - * @self: A #MashModel instance - * @data: The new #MashData - * - * Replaces the data used by the actor with @data. A reference is - * taken on @data so if you no longer need it you should unref it with - * g_object_unref(). - */ -void -mash_model_set_data (MashModel *self, - MashData *data) -{ - MashModelPrivate *priv; - - g_return_if_fail (MASH_IS_MODEL (self)); - g_return_if_fail (data == NULL || MASH_IS_DATA (data)); - - priv = self->priv; - - if (data) - g_object_ref (data); - - if (priv->data) - g_object_unref (priv->data); - - priv->data = data; - - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); - - g_object_notify (G_OBJECT (self), "data"); -} - -/** - * mash_model_get_light_set: - * @self: A #MashModel instance - * - * Return value: the #MashLightSet previously set with - * mash_model_set_light_set(). - * - * Since: 0.2 - */ -MashLightSet * -mash_model_get_light_set (MashModel *self) -{ - g_return_val_if_fail (MASH_IS_MODEL (self), NULL); - - return self->priv->light_set; -} - -/** - * mash_model_set_light_set: - * @self: A #MashModel instance - * @light_set: A new #MashLightSet - * - * This sets the #MashLightSet that will be used to render the - * model. Alternatively %NULL can be passed to disable lighting for - * this model. The light set represents a collection of #MashLight<!-- - * -->s that will affect the appearance of the model. - * - * Since: 0.2 - */ -void -mash_model_set_light_set (MashModel *self, - MashLightSet *light_set) -{ - MashModelPrivate *priv; - - g_return_if_fail (MASH_IS_MODEL (self)); - g_return_if_fail (light_set == NULL || MASH_IS_LIGHT_SET (light_set)); - - priv = self->priv; - - if (light_set) - g_object_ref (light_set); - - if (priv->light_set) - g_object_unref (priv->light_set); - - priv->light_set = light_set; - - if (light_set == NULL && priv->material) - cogl_material_set_user_program (priv->material, COGL_INVALID_HANDLE); - - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); - - g_object_notify (G_OBJECT (self), "light-set"); -} - -/** - * mash_model_get_fit_to_allocation: - * @self: A #MashModel instance - * - * Return value: whether the actor will try to scale the model to fit - * within the allocation. - */ -gboolean -mash_model_get_fit_to_allocation (MashModel *self) -{ - g_return_val_if_fail (MASH_IS_MODEL (self), FALSE); - - return self->priv->fit_to_allocation; -} - -/** - * mash_model_set_fit_to_allocation: - * @self: A #MashModel instance - * @fit_to_allocation: New value - * - * This sets whether the actor should scale the model to fit the - * actor's allocation. If it's %TRUE then all of the axes of the model - * will be scaled by the same amount to fill the allocation as much as - * possible without distorting the aspect ratio. The model is also - * translated so that it is at the center of the allocation and - * centered at 0 along the z axis. The size along the z axis is not - * considered when calculating a scale so if the model is largest - * along that axis then the actor may appear too large. The - * transformations are applied in addition to the actor's - * transformations so it is still possible scale the actor further - * using the scale-x and scale-y properties. The preferred size of the - * actor will be the width and height of the model. If - * width-for-height or height-for-width allocation is being used then - * #MashModel will return whatever width or height will exactly - * preserve the aspect ratio. - * - * If the value is %FALSE then the actor is not transformed so the - * origin of the model will be the top left corner of the actor. The - * preferred size of the actor will be maximum extents of the model - * although the allocation is not considered during paint so if the - * model extends past the allocated size then it will draw outside the - * allocation. - * - * The default value is %TRUE. - */ -void -mash_model_set_fit_to_allocation (MashModel *self, - gboolean fit_to_allocation) -{ - MashModelPrivate *priv; - - g_return_if_fail (MASH_IS_MODEL (self)); - - priv = self->priv; - - if (priv->fit_to_allocation != fit_to_allocation) - { - priv->fit_to_allocation = fit_to_allocation; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); - g_object_notify (G_OBJECT (self), "fit-to-allocation"); - } -} - -static void -mash_model_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MashModel *model = MASH_MODEL (object); - - switch (prop_id) - { - case PROP_MATERIAL: - g_value_set_boxed (value, mash_model_get_material (model)); - break; - - case PROP_DATA: - g_value_set_object (value, mash_model_get_data (model)); - break; - - case PROP_LIGHT_SET: - g_value_set_object (value, mash_model_get_light_set (model)); - break; - - case PROP_FIT_TO_ALLOCATION: - g_value_set_boolean (value, - mash_model_get_fit_to_allocation (model)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -mash_model_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MashModel *model = MASH_MODEL (object); - - switch (prop_id) - { - case PROP_MATERIAL: - mash_model_set_material (model, g_value_get_boxed (value)); - break; - - case PROP_DATA: - mash_model_set_data (model, g_value_get_object (value)); - break; - - case PROP_LIGHT_SET: - mash_model_set_light_set (model, g_value_get_object (value)); - break; - - case PROP_FIT_TO_ALLOCATION: - mash_model_set_fit_to_allocation (model, - g_value_get_boolean (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -mash_model_get_preferred_width (ClutterActor *actor, - gfloat for_height, - gfloat *minimum_width_p, - gfloat *natural_width_p) -{ - MashModel *model = MASH_MODEL (actor); - MashModelPrivate *priv = model->priv; - ClutterVertex min_vertex, max_vertex; - gfloat minimum_width, natural_width; - - if (priv->data) - { - mash_data_get_extents (priv->data, &min_vertex, &max_vertex); - - if (priv->fit_to_allocation) - { - gfloat model_width = max_vertex.x - min_vertex.x; - gfloat model_height = max_vertex.y - min_vertex.y; - - if (for_height < 0.0f || model_height == 0.0f) - natural_width = model_width; - else - /* Pick a width that would preserve the aspect ratio */ - natural_width = for_height * model_width / model_height; - - minimum_width = 0.0f; - } - else - /* We can't report if the actor draws to the left of the origin so - the best we can do is to report the extent to the right of the - origin. If the data also contains vertices to the left of the - origin then this won't be the actual width */ - minimum_width = natural_width = max_vertex.x; - } - else - minimum_width = natural_width = 0.0f; - - if (minimum_width_p) - *minimum_width_p = minimum_width; - if (natural_width_p) - *natural_width_p = natural_width; -} - -static void -mash_model_get_preferred_height (ClutterActor *actor, - gfloat for_width, - gfloat *minimum_height_p, - gfloat *natural_height_p) -{ - MashModel *model = MASH_MODEL (actor); - MashModelPrivate *priv = model->priv; - ClutterVertex min_vertex, max_vertex; - gfloat minimum_height, natural_height; - - if (priv->data) - { - mash_data_get_extents (priv->data, &min_vertex, &max_vertex); - - if (priv->fit_to_allocation) - { - gfloat model_width = max_vertex.x - min_vertex.x; - gfloat model_height = max_vertex.y - min_vertex.y; - - if (for_width < 0.0f || model_width == 0.0f) - natural_height = model_height; - else - /* Pick a height that would preserve the aspect ratio */ - natural_height = for_width * model_height / model_width; - - minimum_height = 0.0f; - } - else - /* We can't report if the actor draws above the origin so the - best we can do is to report the extent below the origin. If - the data also contains vertices above the origin then this - won't be the actual height */ - minimum_height = natural_height = max_vertex.y; - } - else - minimum_height = natural_height = 0.0f; - - if (minimum_height_p) - *minimum_height_p = minimum_height; - if (natural_height_p) - *natural_height_p = natural_height; -} - -static gfloat -mash_model_calculate_scale (gfloat target_extents, - gfloat min, - gfloat max) -{ - if (min == max) - return G_MAXFLOAT; - else - return target_extents / (max - min); -} - -static void -mash_model_allocate (ClutterActor *actor, - const ClutterActorBox *box, - ClutterAllocationFlags flags) -{ - MashModel *self = MASH_MODEL (actor); - MashModelPrivate *priv = self->priv; - - CLUTTER_ACTOR_CLASS (mash_model_parent_class) - ->allocate (actor, box, flags); - - if (priv->fit_to_allocation && priv->data) - { - ClutterVertex min_vertex, max_vertex; - gfloat scale, min_scale; - - /* Try to scale the model uniformly so that it will fill the - maximum amount of space without breaking the aspect - ratio. The model is then centered in the allocation */ - mash_data_get_extents (priv->data, &min_vertex, &max_vertex); - - min_scale = mash_model_calculate_scale (box->x2 - box->x1, - min_vertex.x, - max_vertex.x); - scale = mash_model_calculate_scale (box->y2 - box->y1, - min_vertex.y, - max_vertex.y); - if (min_scale > scale) - min_scale = scale; - - if (min_scale >= G_MAXFLOAT) - min_scale = 0.0f; - - priv->scale = min_scale; - - priv->translate_x = ((box->x2 - box->x1) / 2.0f - - (min_vertex.x + max_vertex.x) / 2.0f * min_scale); - priv->translate_y = ((box->y2 - box->y1) / 2.0f - - (min_vertex.y + max_vertex.y) / 2.0f * min_scale); - priv->translate_z = -(min_vertex.z + max_vertex.z) / 2.0f * min_scale; - } -} diff --git a/mash/mash-model.h b/mash/mash-model.h deleted file mode 100644 index ea1a40f..0000000 --- a/mash/mash-model.h +++ b/dev/null @@ -1,108 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_MODEL_H__ -#define __MASH_MODEL_H__ - -#include <glib-object.h> -#include <clutter/clutter.h> -#include <mash/mash-data.h> -#include <mash/mash-light-set.h> - -G_BEGIN_DECLS - -#define MASH_TYPE_MODEL \ - (mash_model_get_type()) -#define MASH_MODEL(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_MODEL, \ - MashModel)) -#define MASH_MODEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_MODEL, \ - MashModelClass)) -#define MASH_IS_MODEL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_MODEL)) -#define MASH_IS_MODEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_MODEL)) -#define MASH_MODEL_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_TYPE_MODEL, \ - MashModelClass)) - -typedef struct _MashModel MashModel; -typedef struct _MashModelClass MashModelClass; -typedef struct _MashModelPrivate MashModelPrivate; - -/** - * MashModelClass: - * - * The #MashModelClass structure contains only private data. - */ -struct _MashModelClass -{ - /*< private >*/ - ClutterActorClass parent_class; -}; - -/** - * MashModel: - * - * The #MashModel structure contains only private data. - */ -struct _MashModel -{ - /*< private >*/ - ClutterActor parent; - - MashModelPrivate *priv; -}; - -GType mash_model_get_type (void) G_GNUC_CONST; - -ClutterActor *mash_model_new (void); - -ClutterActor *mash_model_new_from_file (MashDataFlags flags, - const gchar *filename, - GError **error); - -CoglHandle mash_model_get_material (MashModel *self); -void mash_model_set_material (MashModel *self, - CoglHandle material); - -MashData *mash_model_get_data (MashModel *self); -void mash_model_set_data (MashModel *self, - MashData *data); - -MashLightSet *mash_model_get_light_set (MashModel *self); -void mash_model_set_light_set (MashModel *self, - MashLightSet *light_set); - -gboolean mash_model_get_fit_to_allocation (MashModel *self); -void mash_model_set_fit_to_allocation (MashModel *self, - gboolean fit_to_allocation); - -G_END_DECLS - -#endif /* __MASH_MODEL_H__ */ diff --git a/mash/mash-ply-loader.c b/mash/mash-ply-loader.c deleted file mode 100644 index 8135c6f..0000000 --- a/mash/mash-ply-loader.c +++ b/dev/null @@ -1,571 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * Copyright (C) 2010 Luca Bruno <lethalman88@gmail.com> - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib-object.h> -#include <string.h> -#include <cogl/cogl.h> -#include <clutter/clutter.h> - -#include "mash-ply-loader.h" -#include "rply/rply.h" - -static void mash_ply_loader_finalize (GObject *object); -static gboolean mash_ply_loader_load (MashDataLoader *data_loader, - MashDataFlags flags, - const gchar *filename, - GError **error); -static void mash_ply_loader_get_data (MashDataLoader *data_loader, - MashDataLoaderData *loader_data); - -G_DEFINE_TYPE (MashPlyLoader, mash_ply_loader, MASH_TYPE_DATA_LOADER); - -#define MASH_PLY_LOADER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_PLY_LOADER, \ - MashPlyLoaderPrivate)) - -static const struct -{ - const gchar *name; - int size; -} -mash_ply_loader_properties[] = -{ - /* These should be sorted in descending order of size so that it - never ends doing an unaligned write */ - { "x", sizeof (gfloat) }, - { "y", sizeof (gfloat) }, - { "z", sizeof (gfloat) }, - { "nx", sizeof (gfloat) }, - { "ny", sizeof (gfloat) }, - { "nz", sizeof (gfloat) }, - { "s", sizeof (gfloat) }, - { "t", sizeof (gfloat) }, - { "red", sizeof (guint8) }, - { "green", sizeof (guint8) }, - { "blue", sizeof (guint8) } -}; - -#define MASH_PLY_LOADER_VERTEX_PROPS 7 -#define MASH_PLY_LOADER_NORMAL_PROPS (7 << 3) -#define MASH_PLY_LOADER_TEX_COORD_PROPS (3 << 6) -#define MASH_PLY_LOADER_COLOR_PROPS (7 << 8) - -typedef struct _MashPlyLoaderData MashPlyLoaderData; - -struct _MashPlyLoaderData -{ - p_ply ply; - GError *error; - /* Data for the current vertex */ - guint8 current_vertex[G_N_ELEMENTS (mash_ply_loader_properties) * 4]; - /* Map from property number to byte offset in the current_vertex array */ - gint prop_map[G_N_ELEMENTS (mash_ply_loader_properties)]; - /* Number of bytes for a vertex */ - guint n_vertex_bytes; - gint available_props, got_props; - guint first_vertex, last_vertex; - GByteArray *vertices; - GArray *faces; - CoglIndicesType indices_type; - MashDataFlags flags; - - /* Bounding cuboid of the data */ - ClutterVertex min_vertex, max_vertex; - - /* Range of indices used */ - guint min_index, max_index; -}; - -struct _MashPlyLoaderPrivate -{ - CoglHandle vertices_vbo; - CoglHandle indices; - guint min_index, max_index; - guint n_triangles; - - /* Bounding cuboid of the data */ - ClutterVertex min_vertex, max_vertex; -}; - -static void -mash_ply_loader_class_init (MashPlyLoaderClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - MashDataLoaderClass *data_loader_class = (MashDataLoaderClass *) klass; - - gobject_class->finalize = mash_ply_loader_finalize; - - data_loader_class->load = mash_ply_loader_load; - data_loader_class->get_data = mash_ply_loader_get_data; - - g_type_class_add_private (klass, sizeof (MashPlyLoaderPrivate)); -} - -static void -mash_ply_loader_init (MashPlyLoader *self) -{ - self->priv = MASH_PLY_LOADER_GET_PRIVATE (self); -} - -static void -mash_ply_loader_free_vbos (MashPlyLoader *self) -{ - MashPlyLoaderPrivate *priv = self->priv; - - if (priv->vertices_vbo) - { - cogl_handle_unref (priv->vertices_vbo); - priv->vertices_vbo = NULL; - } - - if (priv->indices) - { - cogl_handle_unref (priv->indices); - priv->indices = NULL; - } -} - -static void -mash_ply_loader_finalize (GObject *object) -{ - MashPlyLoader *self = (MashPlyLoader *) object; - - mash_ply_loader_free_vbos (self); - - G_OBJECT_CLASS (mash_ply_loader_parent_class)->finalize (object); -} - -static void -mash_ply_loader_error_cb (const char *message, gpointer data) -{ - MashPlyLoaderData *load_ply_loader = data; - - if (load_ply_loader->error == NULL) - g_set_error_literal (&load_ply_loader->error, MASH_DATA_ERROR, - MASH_DATA_ERROR_UNKNOWN, message); -} - -static void -mash_ply_loader_check_unknown_error (MashPlyLoaderData *data) -{ - if (data->error == NULL) - g_set_error_literal (&data->error, - MASH_DATA_ERROR, - MASH_DATA_ERROR_UNKNOWN, - "Unknown error loading PLY file"); -} - -static int -mash_ply_loader_vertex_read_cb (p_ply_argument argument) -{ - long prop_num; - MashPlyLoaderData *data; - gint32 length, index; - double value; - - ply_get_argument_user_data (argument, (void **) &data, &prop_num); - ply_get_argument_property (argument, NULL, &length, &index); - - if (length != 1 || index != 0) - { - g_set_error (&data->error, MASH_DATA_ERROR, - MASH_DATA_ERROR_INVALID, - "List type property not supported for vertex element '%s'", - mash_ply_loader_properties[prop_num].name); - - return 0; - } - - value = ply_get_argument_value (argument); - - /* Colors are specified as a byte so we need to treat them specially */ - if (((1 << prop_num) & MASH_PLY_LOADER_COLOR_PROPS)) - data->current_vertex[data->prop_map[prop_num]] = value; - else - *(gfloat *) (data->current_vertex + data->prop_map[prop_num]) = value; - - data->got_props |= 1 << prop_num; - - /* If we've got enough properties for a complete vertex then add it - to the array */ - if (data->got_props == data->available_props) - { - int i; - - /* Flip any axes that have been specified in the MashPlyLoaderFlags */ - if ((data->available_props & MASH_PLY_LOADER_VERTEX_PROPS) - == MASH_PLY_LOADER_VERTEX_PROPS) - for (i = 0; i < 3; i++) - if ((data->flags & (MASH_DATA_NEGATE_X << i))) - { - gfloat *pos = (gfloat *) (data->current_vertex - + data->prop_map[i]); - *pos = -*pos; - } - if ((data->available_props & MASH_PLY_LOADER_NORMAL_PROPS) - == MASH_PLY_LOADER_NORMAL_PROPS) - for (i = 0; i < 3; i++) - if ((data->flags & (MASH_DATA_NEGATE_X << i))) - { - gfloat *pos = (gfloat *) (data->current_vertex - + data->prop_map[i + 3]); - *pos = -*pos; - } - - g_byte_array_append (data->vertices, data->current_vertex, - data->n_vertex_bytes); - data->got_props = 0; - - /* Update the bounding box for the data */ - for (i = 0; i < 3; i++) - { - gfloat *min = &data->min_vertex.x + i; - gfloat *max = &data->max_vertex.x + i; - gfloat value = *(gfloat *) (data->current_vertex + data->prop_map[i]); - - if (value < *min) - *min = value; - if (value > *max) - *max = value; - } - } - - return 1; -} - -static void -mash_ply_loader_add_face_index (MashPlyLoaderData *data, - guint index) -{ - if (index > data->max_index) - data->max_index = index; - if (index < data->min_index) - data->min_index = index; - - switch (data->indices_type) - { - case COGL_INDICES_TYPE_UNSIGNED_BYTE: - { - guint8 value = index; - g_array_append_val (data->faces, value); - } - break; - case COGL_INDICES_TYPE_UNSIGNED_SHORT: - { - guint16 value = index; - g_array_append_val (data->faces, value); - } - break; - case COGL_INDICES_TYPE_UNSIGNED_INT: - { - guint32 value = index; - g_array_append_val (data->faces, value); - } - break; - } -} - -static gboolean -mash_ply_loader_get_indices_type (MashPlyLoaderData *data, - GError **error) -{ - p_ply_element elem = NULL; - - /* Look for the 'vertices' element */ - while ((elem = ply_get_next_element (data->ply, elem))) - { - const char *name; - gint32 n_instances; - - if (ply_get_element_info (elem, &name, &n_instances)) - { - if (!strcmp (name, "vertex")) - { - if (n_instances <= 0x100) - { - data->indices_type = COGL_INDICES_TYPE_UNSIGNED_BYTE; - data->faces = g_array_new (FALSE, FALSE, sizeof (guint8)); - } - else if (n_instances <= 0x10000) - { - data->indices_type = COGL_INDICES_TYPE_UNSIGNED_SHORT; - data->faces = g_array_new (FALSE, FALSE, sizeof (guint16)); - } - else if (cogl_features_available - (COGL_FEATURE_UNSIGNED_INT_INDICES)) - { - data->indices_type = COGL_INDICES_TYPE_UNSIGNED_INT; - data->faces = g_array_new (FALSE, FALSE, sizeof (guint32)); - } - else - { - g_set_error (error, MASH_DATA_ERROR, - MASH_DATA_ERROR_UNSUPPORTED, - "The PLY file requires unsigned int indices " - "but this is not supported by your GL driver"); - return FALSE; - } - - return TRUE; - } - } - else - { - g_set_error (error, MASH_DATA_ERROR, - MASH_DATA_ERROR_UNKNOWN, - "Error getting element info"); - return FALSE; - } - } - - g_set_error (error, MASH_DATA_ERROR, - MASH_DATA_ERROR_MISSING_PROPERTY, - "PLY file is missing the vertex element"); - - return FALSE; -} - -static int -mash_ply_loader_face_read_cb (p_ply_argument argument) -{ - long prop_num; - MashPlyLoaderData *data; - gint32 length, index; - - ply_get_argument_user_data (argument, (void **) &data, &prop_num); - ply_get_argument_property (argument, NULL, &length, &index); - - if (index == 0) - data->first_vertex = ply_get_argument_value (argument); - else if (index == 1) - data->last_vertex = ply_get_argument_value (argument); - else if (index != -1) - { - guint new_vertex = ply_get_argument_value (argument); - - /* Add a triangle with the first vertex, the last vertex and - this new vertex */ - mash_ply_loader_add_face_index (data, data->first_vertex); - mash_ply_loader_add_face_index (data, data->last_vertex); - mash_ply_loader_add_face_index (data, new_vertex); - - /* Use the new vertex as one of the vertices next time around */ - data->last_vertex = new_vertex; - } - - return 1; -} - -static gboolean -mash_ply_loader_load (MashDataLoader *data_loader, - MashDataFlags flags, - const gchar *filename, - GError **error) -{ - MashPlyLoader *self = MASH_PLY_LOADER (data_loader); - MashPlyLoaderPrivate *priv; - MashPlyLoaderData data; - gchar *display_name; - gboolean ret; - - priv = self->priv; - - data.error = NULL; - data.n_vertex_bytes = 0; - data.available_props = 0; - data.got_props = 0; - data.vertices = g_byte_array_new (); - data.faces = NULL; - data.min_vertex.x = G_MAXFLOAT; - data.min_vertex.y = G_MAXFLOAT; - data.min_vertex.z = G_MAXFLOAT; - data.max_vertex.x = -G_MAXFLOAT; - data.max_vertex.y = -G_MAXFLOAT; - data.max_vertex.z = -G_MAXFLOAT; - data.min_index = G_MAXUINT; - data.max_index = 0; - data.flags = flags; - - display_name = g_filename_display_name (filename); - - if ((data.ply = ply_open (filename, - mash_ply_loader_error_cb, - &data)) == NULL) - mash_ply_loader_check_unknown_error (&data); - else - { - if (!ply_read_header (data.ply)) - mash_ply_loader_check_unknown_error (&data); - else - { - int i; - - for (i = 0; i < G_N_ELEMENTS (mash_ply_loader_properties); i++) - if (ply_set_read_cb (data.ply, "vertex", - mash_ply_loader_properties[i].name, - mash_ply_loader_vertex_read_cb, - &data, i)) - { - data.prop_map[i] = data.n_vertex_bytes; - data.n_vertex_bytes += mash_ply_loader_properties[i].size; - data.available_props |= 1 << i; - } - - /* Align the size of a vertex to 32 bits */ - data.n_vertex_bytes = (data.n_vertex_bytes + 3) & ~(guint) 3; - - if ((data.available_props & MASH_PLY_LOADER_VERTEX_PROPS) - != MASH_PLY_LOADER_VERTEX_PROPS) - g_set_error (&data.error, MASH_DATA_ERROR, - MASH_DATA_ERROR_MISSING_PROPERTY, - "PLY file %s is missing the vertex properties", - display_name); - else if (!ply_set_read_cb (data.ply, "face", "vertex_indices", - mash_ply_loader_face_read_cb, - &data, i)) - g_set_error (&data.error, MASH_DATA_ERROR, - MASH_DATA_ERROR_MISSING_PROPERTY, - "PLY file %s is missing face property " - "'vertex_indices'", - display_name); - else if (mash_ply_loader_get_indices_type (&data, &data.error) - && !ply_read (data.ply)) - mash_ply_loader_check_unknown_error (&data); - } - - ply_close (data.ply); - } - - if (data.error) - { - g_propagate_error (error, data.error); - ret = FALSE; - } - else if (data.faces->len < 3) - { - g_set_error (error, MASH_DATA_ERROR, - MASH_DATA_ERROR_INVALID, - "No faces found in %s", - display_name); - ret = FALSE; - } - else - { - /* Make sure all of the indices are valid */ - if (data.max_index >= data.vertices->len / data.n_vertex_bytes) - { - g_set_error (error, MASH_DATA_ERROR, - MASH_DATA_ERROR_INVALID, - "Index out of range in %s", - display_name); - ret = FALSE; - } - else - { - /* Get rid of the old VBOs (if any) */ - mash_ply_loader_free_vbos (self); - - /* Create a new VBO for the vertices */ - priv->vertices_vbo = cogl_vertex_buffer_new (data.vertices->len - / data.n_vertex_bytes); - - /* Upload the data */ - if ((data.available_props & MASH_PLY_LOADER_VERTEX_PROPS) - == MASH_PLY_LOADER_VERTEX_PROPS) - cogl_vertex_buffer_add (priv->vertices_vbo, - "gl_Vertex", - 3, COGL_ATTRIBUTE_TYPE_FLOAT, - FALSE, data.n_vertex_bytes, - data.vertices->data - + data.prop_map[0]); - - if ((data.available_props & MASH_PLY_LOADER_NORMAL_PROPS) - == MASH_PLY_LOADER_NORMAL_PROPS) - cogl_vertex_buffer_add (priv->vertices_vbo, - "gl_Normal", - 3, COGL_ATTRIBUTE_TYPE_FLOAT, - FALSE, data.n_vertex_bytes, - data.vertices->data - + data.prop_map[3]); - - if ((data.available_props & MASH_PLY_LOADER_TEX_COORD_PROPS) - == MASH_PLY_LOADER_TEX_COORD_PROPS) - cogl_vertex_buffer_add (priv->vertices_vbo, - "gl_MultiTexCoord0", - 2, COGL_ATTRIBUTE_TYPE_FLOAT, - FALSE, data.n_vertex_bytes, - data.vertices->data - + data.prop_map[6]); - - if ((data.available_props & MASH_PLY_LOADER_COLOR_PROPS) - == MASH_PLY_LOADER_COLOR_PROPS) - cogl_vertex_buffer_add (priv->vertices_vbo, - "gl_Color", - 3, COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE, - FALSE, data.n_vertex_bytes, - data.vertices->data - + data.prop_map[8]); - - cogl_vertex_buffer_submit (priv->vertices_vbo); - - /* Create a VBO for the indices */ - priv->indices - = cogl_vertex_buffer_indices_new (data.indices_type, - data.faces->data, - data.faces->len); - - priv->min_index = data.min_index; - priv->max_index = data.max_index; - priv->n_triangles = data.faces->len / 3; - - priv->min_vertex = data.min_vertex; - priv->max_vertex = data.max_vertex; - - ret = TRUE; - } - } - - g_free (display_name); - g_byte_array_free (data.vertices, TRUE); - if (data.faces) - g_array_free (data.faces, TRUE); - - return ret; -} - -static void -mash_ply_loader_get_data (MashDataLoader *data_loader, MashDataLoaderData *loader_data) -{ - MashPlyLoader *self = MASH_PLY_LOADER (data_loader); - MashPlyLoaderPrivate *priv = self->priv; - - loader_data->vertices_vbo = cogl_handle_ref (priv->vertices_vbo); - loader_data->indices = cogl_handle_ref (priv->indices); - - loader_data->min_index = priv->min_index; - loader_data->max_index = priv->max_index; - loader_data->n_triangles = priv->n_triangles; - - loader_data->min_vertex = priv->min_vertex; - loader_data->max_vertex = priv->max_vertex; -} diff --git a/mash/mash-ply-loader.h b/mash/mash-ply-loader.h deleted file mode 100644 index 4d8ec56..0000000 --- a/mash/mash-ply-loader.h +++ b/dev/null @@ -1,74 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * Copyright (C) 2010 Luca Bruno <lethalman88@gmail.com> - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_PLY_LOADER_H__ -#define __MASH_PLY_LOADER_H__ - -#include "mash-data-loader.h" - -G_BEGIN_DECLS - -#define MASH_TYPE_PLY_LOADER \ - (mash_ply_loader_get_type()) -#define MASH_PLY_LOADER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_PLY_LOADER, \ - MashPlyLoader)) -#define MASH_PLY_LOADER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_PLY_LOADER, \ - MashPlyLoaderClass)) -#define MASH_IS_PLY_LOADER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_PLY_LOADER)) -#define MASH_IS_PLY_LOADER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_PLY_LOADER)) -#define MASH_PLY_LOADER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_TYPE_PLY_LOADER, \ - MashPlyLoaderClass)) - -typedef struct _MashPlyLoader MashPlyLoader; -typedef struct _MashPlyLoaderClass MashPlyLoaderClass; -typedef struct _MashPlyLoaderPrivate MashPlyLoaderPrivate; - -struct _MashPlyLoaderClass -{ - /*< private >*/ - MashDataLoaderClass parent_class; -}; - -struct _MashPlyLoader -{ - /*< private >*/ - GObject parent; - - MashPlyLoaderPrivate *priv; -}; - -GType mash_ply_loader_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __MASH_PLY_LOADER_H__ */ diff --git a/mash/mash-point-light.c b/mash/mash-point-light.c deleted file mode 100644 index 5f5d574..0000000 --- a/mash/mash-point-light.c +++ b/dev/null @@ -1,507 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * SECTION:mash-point-light - * @short_description: An actor for a light with a position that emits - * light in all directions. - * - * A #MashPointLight models a light that has a position and emits - * light evenly in all directions. The position of the light is taken - * from the actor's position so it can be easily modified and even - * animated using the #ClutterActor properties. The intensity of the - * light can be attenuated using the attenuation properties to make - * objects that are further from the light receive less intensity. The - * intensity of the light is divided by ad² + bd + c, where d is the - * distance between the light and the vertex and a, b and c are the - * following properties which can be modified on the light: - * quadratic-attenuation, linear-attenuation and constant-attenuation. - * - * By default the attenuation values are all zero except for the - * constant attenuation. This causes the light to never be attenuated - * so that the light intensity is not affected by the distance from - * the light. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <clutter/clutter.h> - -#include "mash-light.h" -#include "mash-point-light.h" - -static void mash_point_light_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void mash_point_light_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); - -static void mash_point_light_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source); -static void mash_point_light_update_uniforms (MashLight *light, - CoglHandle program); - -G_DEFINE_TYPE (MashPointLight, mash_point_light, MASH_TYPE_LIGHT); - -#define MASH_POINT_LIGHT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_POINT_LIGHT, \ - MashPointLightPrivate)) - -#define MASH_POINT_LIGHT_ATTENUATION_CONSTANT 0 -#define MASH_POINT_LIGHT_ATTENUATION_LINEAR 1 -#define MASH_POINT_LIGHT_ATTENUATION_QUADRATIC 2 -#define MASH_POINT_LIGHT_ATTENUATION_COUNT 3 - -struct _MashPointLightPrivate -{ - /* The three attenuation factors. These are stored in an array so we - can upload them as one vector and use a dot product in the - shader */ - float attenuation[MASH_POINT_LIGHT_ATTENUATION_COUNT]; - - int attenuation_uniform_location; - int light_eye_coord_uniform_location; - - /* TRUE if the attenuation factors have been modified since - update_uniforms was last called */ - gboolean attenuation_dirty; - - /* TRUE if the shader has changed since we last called - cogl_program_get_uniform_location for the uniforms */ - gboolean uniform_locations_dirty; -}; - -enum - { - PROP_0, - - PROP_CONSTANT_ATTENUATION, - PROP_LINEAR_ATTENUATION, - PROP_QUADRATIC_ATTENUATION - }; - -static const char -mash_point_light_shader[] = - /* Vector from the vertex to the light */ - " vec3 light_vec$ = light_eye_coord$ - eye_coord;\n" - /* Distance from the vertex to the light */ - " float d$ = length (light_vec$);\n" - /* Normalize the light vector */ - " light_vec$ /= d$;\n" - /* Add the ambient light term */ - " vec3 lit_color$ = mash_material.ambient.rgb * ambient_light$;\n" - /* Calculate the diffuse factor based on the angle between the - vertex normal and the angle between the light and the vertex */ - " float diffuse_factor$ = max (0.0, dot (light_vec$, normal));\n" - /* Skip the specular and diffuse terms if the vertex is not facing - the light */ - " if (diffuse_factor$ > 0.0)\n" - " {\n" - /* Add the diffuse term */ - " lit_color$ += (diffuse_factor$ * mash_material.diffuse.rgb\n" - " * diffuse_light$);\n" - /* Direction for maximum specular highlights is half way between the - eye vector and the light vector. The eye vector is hard-coded to - look down the negative z axis */ - " vec3 half_vector$ = normalize (light_vec$ + vec3 (0.0, 0.0, 1.0));\n" - " float spec_factor$ = max (0.0, dot (half_vector$, normal));\n" - " float spec_power$ = pow (spec_factor$, mash_material.shininess);\n" - /* Add the specular term */ - " lit_color$ += (mash_material.specular.rgb\n" - " * specular_light$ * spec_power$);\n" - " }\n" - /* Attenuate the lit color based on the distance to the light and - the attenuation formula properties */ - " lit_color$ /= dot (attenuation$, vec3 (1.0, d$, d$ * d$));\n" - /* Add it to the total computed color value */ - " cogl_color_out.xyz += lit_color$;\n" - ; - -static void -mash_point_light_class_init (MashPointLightClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - MashLightClass *light_class = (MashLightClass *) klass; - GParamSpec *pspec; - - gobject_class->get_property = mash_point_light_get_property; - gobject_class->set_property = mash_point_light_set_property; - - light_class->generate_shader = mash_point_light_generate_shader; - light_class->update_uniforms = mash_point_light_update_uniforms; - - pspec = g_param_spec_float ("constant-attenuation", - "Constant Attenuation", - "A constant number to add to " - "the attenuation value", - 0.0f, G_MAXFLOAT, - 1.0f, /* default */ - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, - PROP_CONSTANT_ATTENUATION, - pspec); - - pspec = g_param_spec_float ("linear-attenuation", - "Linear Attenuation", - "This number is multiplied by the distance " - "from the vertex to the light source and " - "added to the attenuation factor.", - 0.0f, G_MAXFLOAT, - 0.0f, /* default */ - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, - PROP_LINEAR_ATTENUATION, - pspec); - - pspec = g_param_spec_float ("quadratic-attenuation", - "Quadratic Attenuation", - "This number is multiplied by the square of the " - "distance from the vertex to the light source " - "and added to the attenuation factor.", - 0.0f, G_MAXFLOAT, - 0.0f, /* default */ - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, - PROP_QUADRATIC_ATTENUATION, - pspec); - - g_type_class_add_private (klass, sizeof (MashPointLightPrivate)); -} - -static void -mash_point_light_init (MashPointLight *self) -{ - MashPointLightPrivate *priv; - - priv = self->priv = MASH_POINT_LIGHT_GET_PRIVATE (self); - - /* These is the default lighting parameters providing by OpenGL. This - results in no attenuation */ - priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_CONSTANT] = 1.0f; - priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_LINEAR] = 0.0f; - priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_QUADRATIC] = 0.0f; - - priv->attenuation_dirty = TRUE; - - priv->uniform_locations_dirty = TRUE; -} - -static void -mash_point_light_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MashPointLight *light = MASH_POINT_LIGHT (object); - - switch (prop_id) - { - case PROP_CONSTANT_ATTENUATION: - { - gfloat attenuation = mash_point_light_get_constant_attenuation (light); - g_value_set_float (value, attenuation); - } - break; - - case PROP_LINEAR_ATTENUATION: - { - gfloat attenuation = mash_point_light_get_linear_attenuation (light); - g_value_set_float (value, attenuation); - } - break; - - case PROP_QUADRATIC_ATTENUATION: - { - gfloat attenuation = mash_point_light_get_quadratic_attenuation (light); - g_value_set_float (value, attenuation); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -mash_point_light_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MashPointLight *light = MASH_POINT_LIGHT (object); - - switch (prop_id) - { - case PROP_CONSTANT_ATTENUATION: - { - gfloat attenuation = g_value_get_float (value); - mash_point_light_set_constant_attenuation (light, attenuation); - } - break; - - case PROP_LINEAR_ATTENUATION: - { - gfloat attenuation = g_value_get_float (value); - mash_point_light_set_linear_attenuation (light, attenuation); - } - break; - - case PROP_QUADRATIC_ATTENUATION: - { - gfloat attenuation = g_value_get_float (value); - mash_point_light_set_quadratic_attenuation (light, attenuation); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/** - * mash_point_light_new: - * - * Constructs a new #MashPointLight. - * - * Return value: the new light. - */ -ClutterActor * -mash_point_light_new (void) -{ - ClutterActor *self = g_object_new (MASH_TYPE_POINT_LIGHT, NULL); - - return self; -} - -/** - * mash_point_light_set_constant_attenuation: - * @light: The light to modify - * @attenuation: The new value - * - * Sets the constant attenuation value on a light. The light intensity - * is divided by this value. Setting a higher value will cause the - * light to appear dimmer. - */ -void -mash_point_light_set_constant_attenuation (MashPointLight *light, - gfloat attenuation) -{ - MashPointLightPrivate *priv; - - g_return_if_fail (MASH_IS_POINT_LIGHT (light)); - - priv = light->priv; - - if (attenuation != priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_CONSTANT]) - { - priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_CONSTANT] = attenuation; - priv->attenuation_dirty = TRUE; - g_object_notify (G_OBJECT (light), "constant-attenuation"); - } -} - -/** - * mash_point_light_get_constant_attenuation: - * @light: The light to query - * - * Return value: the constant light attenuation value. - */ -gfloat -mash_point_light_get_constant_attenuation (MashPointLight *light) -{ - g_return_val_if_fail (MASH_IS_POINT_LIGHT (light), 0.0f); - - return light->priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_CONSTANT]; -} - -/** - * mash_point_light_set_linear_attenuation: - * @light: The light to modify - * @attenuation: The new value - * - * Sets the linear attenuation value on a light. The light intensity - * is divided by this value multiplied by the distance to the - * light. Setting a higher value will cause the intensity to dim faster - * as the vertex moves away from the light. - */ -void -mash_point_light_set_linear_attenuation (MashPointLight *light, - gfloat attenuation) -{ - MashPointLightPrivate *priv; - - g_return_if_fail (MASH_IS_POINT_LIGHT (light)); - - priv = light->priv; - - if (attenuation != priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_LINEAR]) - { - priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_LINEAR] = attenuation; - priv->attenuation_dirty = TRUE; - g_object_notify (G_OBJECT (light), "linear-attenuation"); - } -} - -/** - * mash_point_light_get_linear_attenuation: - * @light: The light to query - * - * Return value: the linear light attenuation value. - */ -gfloat -mash_point_light_get_linear_attenuation (MashPointLight *light) -{ - g_return_val_if_fail (MASH_IS_POINT_LIGHT (light), 0.0f); - - return light->priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_LINEAR]; -} - -/** - * mash_point_light_set_quadratic_attenuation: - * @light: The light to modify - * @attenuation: The new value - * - * Sets the quadratic attenuation value on a light. The light - * intensity is divided by this value multiplied by the square of the - * distance to the light. Setting a higher value will cause the - * intensity to dim sharply as the vertex moves away from the light. - */ -void -mash_point_light_set_quadratic_attenuation (MashPointLight *light, - gfloat attenuation) -{ - MashPointLightPrivate *priv; - - g_return_if_fail (MASH_IS_POINT_LIGHT (light)); - - priv = light->priv; - - if (attenuation != priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_QUADRATIC]) - { - priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_QUADRATIC] = attenuation; - priv->attenuation_dirty = TRUE; - g_object_notify (G_OBJECT (light), "quadratic-attenuation"); - } -} - -/** - * mash_point_light_get_quadratic_attenuation: - * @light: The light to query - * - * Return value: the quadratic light attenuation value. - */ -gfloat -mash_point_light_get_quadratic_attenuation (MashPointLight *light) -{ - g_return_val_if_fail (MASH_IS_POINT_LIGHT (light), 0.0f); - - return light->priv->attenuation[MASH_POINT_LIGHT_ATTENUATION_QUADRATIC]; -} - -static void -mash_point_light_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source) -{ - MashPointLight *plight = MASH_POINT_LIGHT (light); - MashPointLightPrivate *priv = plight->priv; - - MASH_LIGHT_CLASS (mash_point_light_parent_class) - ->generate_shader (light, uniform_source, main_source); - - /* If the shader is being generated then the uniform locations also - need updating */ - priv->uniform_locations_dirty = TRUE; - priv->attenuation_dirty = TRUE; - - mash_light_append_shader (light, uniform_source, - "uniform vec3 attenuation$;\n" - "uniform vec3 light_eye_coord$;\n"); - - mash_light_append_shader (light, main_source, mash_point_light_shader); -} - -static void -mash_point_light_update_uniforms (MashLight *light, - CoglHandle program) -{ - MashPointLight *plight = MASH_POINT_LIGHT (light); - MashPointLightPrivate *priv = plight->priv; - gfloat light_eye_coord[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; - CoglMatrix matrix; - - MASH_LIGHT_CLASS (mash_point_light_parent_class) - ->update_uniforms (light, program); - - if (priv->uniform_locations_dirty) - { - priv->attenuation_uniform_location - = mash_light_get_uniform_location (light, program, "attenuation"); - priv->light_eye_coord_uniform_location - = mash_light_get_uniform_location (light, program, "light_eye_coord"); - priv->uniform_locations_dirty = FALSE; - } - - if (priv->attenuation_dirty) - { - cogl_program_set_uniform_float (program, - priv->attenuation_uniform_location, - 3, 1, - priv->attenuation); - priv->attenuation_dirty = FALSE; - } - - /* I can't think of a good way to recognise when the position of the - actor may have changed so this just always updates the light eye - coordinates. Any transformations in the parent hierarchy could - cause the position to change without affecting the allocation */ - - mash_light_get_modelview_matrix (light, - &matrix); - - cogl_matrix_transform_point (&matrix, - light_eye_coord + 0, - light_eye_coord + 1, - light_eye_coord + 2, - light_eye_coord + 3); - light_eye_coord[0] /= light_eye_coord[3]; - light_eye_coord[1] /= light_eye_coord[3]; - light_eye_coord[2] /= light_eye_coord[3]; - - cogl_program_set_uniform_float (program, - priv->light_eye_coord_uniform_location, - 3, 1, - light_eye_coord); -} diff --git a/mash/mash-point-light.h b/mash/mash-point-light.h deleted file mode 100644 index 6e4218f..0000000 --- a/mash/mash-point-light.h +++ b/dev/null @@ -1,97 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_POINT_LIGHT_H__ -#define __MASH_POINT_LIGHT_H__ - -#include <mash/mash-light.h> - -G_BEGIN_DECLS - -#define MASH_TYPE_POINT_LIGHT \ - (mash_point_light_get_type()) -#define MASH_POINT_LIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_POINT_LIGHT, \ - MashPointLight)) -#define MASH_POINT_LIGHT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_POINT_LIGHT, \ - MashPointLightClass)) -#define MASH_IS_POINT_LIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_POINT_LIGHT)) -#define MASH_IS_POINT_LIGHT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_POINT_LIGHT)) -#define MASH_POINT_LIGHT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_POINT_LIGHT, \ - MashPointLightClass)) - -typedef struct _MashPointLight MashPointLight; -typedef struct _MashPointLightClass MashPointLightClass; -typedef struct _MashPointLightPrivate MashPointLightPrivate; - -/** - * MashPointLightClass: - * - * The #MashPointLightClass structure contains only private data. - */ -struct _MashPointLightClass -{ - /*< private >*/ - MashLightClass parent_class; -}; - -/** - * MashPointLight: - * - * The #MashLightClass structure contains only private data. - */ -struct _MashPointLight -{ - /*< private >*/ - MashLight parent; - - MashPointLightPrivate *priv; -}; - -GType mash_point_light_get_type (void) G_GNUC_CONST; - -ClutterActor *mash_point_light_new (void); - -void mash_point_light_set_constant_attenuation (MashPointLight *light, - gfloat attenuation); -gfloat mash_point_light_get_constant_attenuation (MashPointLight *light); - -void mash_point_light_set_linear_attenuation (MashPointLight *light, - gfloat attenuation); -gfloat mash_point_light_get_linear_attenuation (MashPointLight *light); - -void mash_point_light_set_quadratic_attenuation (MashPointLight *light, - gfloat attenuation); -gfloat mash_point_light_get_quadratic_attenuation (MashPointLight *light); - -G_END_DECLS - -#endif /* __MASH_POINT_LIGHT_H__ */ diff --git a/mash/mash-spot-light.c b/mash/mash-spot-light.c deleted file mode 100644 index 0e23f30..0000000 --- a/mash/mash-spot-light.c +++ b/dev/null @@ -1,445 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * SECTION:mash-spot-light - * @short_description: A light with a position which emits light - * within a cone shape. - * - * A #MashSpotLight is a subclass of #MashPointLight which - * additionally restricts the light emitted to a cone shape eminating - * from the light's position. The same attenuation properties provided - * by #MashPointLight can be used to modify the intensity based on the - * distance to the light. The angle of the cone can be modified with - * the spot-cutoff property and the spot-exponent property. The cutoff - * sets a hard restriction on the maximum angle which light will be - * emitted. The exponent sets the rate at which light dims as the - * angle expands out. - * - * The direction of a spot light is always along the positive y axis - * which is towards the bottom of the stage in a default Clutter - * scene. The direction is affected by the actor's transformation so - * it can be modified or animated by rotating the actor. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <clutter/clutter.h> -#include <math.h> - -#include "mash-light.h" -#include "mash-spot-light.h" - -static void mash_spot_light_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void mash_spot_light_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); - -static void mash_spot_light_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source); -static void mash_spot_light_update_uniforms (MashLight *light, - CoglHandle program); - -G_DEFINE_TYPE (MashSpotLight, mash_spot_light, MASH_TYPE_POINT_LIGHT); - -#define MASH_SPOT_LIGHT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MASH_TYPE_SPOT_LIGHT, \ - MashSpotLightPrivate)) - -struct _MashSpotLightPrivate -{ - int light_direction_uniform_location; - int spot_cos_cutoff_uniform_location; - int spot_exponent_uniform_location; - - float spot_cutoff; - float spot_exponent; - - /* TRUE if the spot parameters have been modified since - update_uniforms was last called */ - gboolean spot_params_dirty; - - /* TRUE if the shader has changed since we last called - cogl_program_get_uniform_location for the uniforms */ - gboolean uniform_locations_dirty; -}; - -enum - { - PROP_0, - - PROP_SPOT_CUTOFF, - PROP_SPOT_EXPONENT - }; - -static const char -mash_spot_light_shader[] = - /* Vector from the vertex to the light */ - " vec3 light_vec$ = light_eye_coord$ - eye_coord;\n" - /* Distance from the vertex to the light */ - " float d$ = length (light_vec$);\n" - /* Normalize the light vector */ - " light_vec$ /= d$;\n" - /* Check if the point on the surface is inside the cone of - illumination */ - /* FIXME: This is doing light_vec$ * -1.0 instead of using unary - negation (-light_vec$) because the latter appears to trigger a - bug in Mesa: - https://bugs.freedesktop.org/show_bug.cgi?id=29199 */ - " float spot_cos$ = dot (light_vec$ * -1.0, spot_direction$);\n" - " if (spot_cos$ > spot_cos_cutoff$)\n" - " {\n" - /* Add the ambient light term */ - " vec3 lit_color$ = mash_material.ambient.rgb * ambient_light$;\n" - /* Calculate the diffuse factor based on the angle between the - vertex normal and the angle between the light and the vertex */ - " float diffuse_factor$ = max (0.0, dot (light_vec$, normal));\n" - /* Skip the specular and diffuse terms if the vertex is not facing - the light */ - " if (diffuse_factor$ > 0.0)\n" - " {\n" - /* Add the diffuse term */ - " lit_color$ += (diffuse_factor$ * mash_material.diffuse.rgb\n" - " * diffuse_light$);\n" - /* Direction for maximum specular highlights is half way between the - eye vector and the light vector. The eye vector is hard-coded to - look down the negative z axis */ - " vec3 half_vector$ = normalize (light_vec$\n" - " + vec3 (0.0, 0.0, 1.0));\n" - " float spec_factor$ = max (0.0, dot (half_vector$, normal));\n" - " float spec_power$ = pow (spec_factor$,\n" - " mash_material.shininess);\n" - /* Add the specular term */ - " lit_color$ += (mash_material.specular.rgb\n" - " * specular_light$ * spec_power$);\n" - " }\n" - /* Attenuate the lit color based on the distance to the light and - the attenuation formula properties */ - " float att = dot (attenuation$, vec3 (1.0, d$, d$ * d$));\n" - /* Also attenuate based on the angle to the light and the spot exponent */ - " att *= pow (spot_cos$, spot_exponent$);\n" - /* Add it to the total computed color value */ - " cogl_color_out.xyz += lit_color$ * att;\n" - " }\n" - ; - -static void -mash_spot_light_class_init (MashSpotLightClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - MashLightClass *light_class = (MashLightClass *) klass; - GParamSpec *pspec; - - gobject_class->get_property = mash_spot_light_get_property; - gobject_class->set_property = mash_spot_light_set_property; - - light_class->generate_shader = mash_spot_light_generate_shader; - light_class->update_uniforms = mash_spot_light_update_uniforms; - - pspec = g_param_spec_float ("spot-cutoff", - "Spot Cutoff", - "The cut off angle where the spot light emits " - "no light", - 0.0f, 90.0f, - 45.0f, /* default */ - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, - PROP_SPOT_CUTOFF, - pspec); - - pspec = g_param_spec_float ("spot-exponent", - "Spot Exponent", - "A value used to set the decay of the light " - "as the angle increases from the light " - "direction.", - 0.0f, 128.0f, - 0.0f, /* default */ - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_STATIC_NAME - | G_PARAM_STATIC_NICK - | G_PARAM_STATIC_BLURB); - g_object_class_install_property (gobject_class, - PROP_SPOT_EXPONENT, - pspec); - - g_type_class_add_private (klass, sizeof (MashSpotLightPrivate)); -} - -static void -mash_spot_light_init (MashSpotLight *self) -{ - MashSpotLightPrivate *priv; - - priv = self->priv = MASH_SPOT_LIGHT_GET_PRIVATE (self); - - /* Default to no attenuation based on the angle */ - priv->spot_exponent = 0.0f; - /* Default to a 45° cone. This isn't the same as the default for - OpenGL which uses 180°. However 180° results in a point light - which doesn't make sense here */ - priv->spot_cutoff = 45.0f; - - priv->spot_params_dirty = TRUE; - priv->uniform_locations_dirty = TRUE; -} - -static void -mash_spot_light_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MashSpotLight *light = MASH_SPOT_LIGHT (object); - - switch (prop_id) - { - case PROP_SPOT_CUTOFF: - { - gfloat cutoff = mash_spot_light_get_spot_cutoff (light); - g_value_set_float (value, cutoff); - } - break; - - case PROP_SPOT_EXPONENT: - { - gfloat exponent = mash_spot_light_get_spot_exponent (light); - g_value_set_float (value, exponent); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -mash_spot_light_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MashSpotLight *light = MASH_SPOT_LIGHT (object); - - switch (prop_id) - { - case PROP_SPOT_CUTOFF: - { - gfloat cutoff = g_value_get_float (value); - mash_spot_light_set_spot_cutoff (light, cutoff); - } - break; - - case PROP_SPOT_EXPONENT: - { - gfloat exponent = g_value_get_float (value); - mash_spot_light_set_spot_exponent (light, exponent); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/** - * mash_spot_light_new: - * - * Constructs a new #MashSpotLight. - * - * Return value: the new light. - */ -ClutterActor * -mash_spot_light_new (void) -{ - ClutterActor *self = g_object_new (MASH_TYPE_SPOT_LIGHT, NULL); - - return self; -} - -/** - * mash_spot_light_set_spot_cutoff - * @light: The light to modify - * @cutoff: The new value - * - * Sets the spot cut off value on a light. This is an angle in degrees - * which defines the shape of the cone of light emitted from the - * light. It should be within the range 0° to 90° - */ -void -mash_spot_light_set_spot_cutoff (MashSpotLight *light, - gfloat cutoff) -{ - MashSpotLightPrivate *priv; - - g_return_if_fail (MASH_IS_SPOT_LIGHT (light)); - - priv = light->priv; - - if (cutoff != priv->spot_cutoff) - { - priv->spot_cutoff = cutoff; - priv->spot_params_dirty = TRUE; - g_object_notify (G_OBJECT (light), "spot-cutoff"); - } -} - -/** - * mash_spot_light_get_spot_cutoff - * @light: The light to query - * - * Return value: the spot cut off value - */ -gfloat -mash_spot_light_get_spot_cutoff (MashSpotLight *light) -{ - g_return_val_if_fail (MASH_IS_SPOT_LIGHT (light), 0.0f); - - return light->priv->spot_cutoff; -} - -/** - * mash_spot_light_set_spot_exponent - * @light: The light to modify - * @exponent: The new value - * - * Sets the spot exponent value on a light. The light intensity is - * multiplied by the angle between the light direction and the vector - * to the vertex raised to the power of the exponent. A higher - * exponent value makes the cone of the light appear smaller. - */ -void -mash_spot_light_set_spot_exponent (MashSpotLight *light, - gfloat exponent) -{ - MashSpotLightPrivate *priv; - - g_return_if_fail (MASH_IS_SPOT_LIGHT (light)); - - priv = light->priv; - - if (exponent != priv->spot_exponent) - { - priv->spot_exponent = exponent; - priv->spot_params_dirty = TRUE; - g_object_notify (G_OBJECT (light), "spot-exponent"); - } -} - -/** - * mash_spot_light_get_spot_exponent - * @light: The light to query - * - * Return value: the spot exponent value - */ -gfloat -mash_spot_light_get_spot_exponent (MashSpotLight *light) -{ - g_return_val_if_fail (MASH_IS_SPOT_LIGHT (light), 0.0f); - - return light->priv->spot_exponent; -} - -static void -mash_spot_light_generate_shader (MashLight *light, - GString *uniform_source, - GString *main_source) -{ - MashSpotLight *plight = MASH_SPOT_LIGHT (light); - MashSpotLightPrivate *priv = plight->priv; - guint old_len; - - /* We need to ignore the shader generation of MashPointLight so we - keep track of the size of the main source before it ran and trim - back to that */ - old_len = main_source->len; - - MASH_LIGHT_CLASS (mash_spot_light_parent_class) - ->generate_shader (light, uniform_source, main_source); - - g_string_set_size (main_source, old_len); - - /* If the shader is being generated then the uniform locations also - need updating */ - priv->uniform_locations_dirty = TRUE; - priv->spot_params_dirty = TRUE; - - mash_light_append_shader (light, uniform_source, - "uniform float spot_cos_cutoff$;\n" - "uniform float spot_exponent$;\n" - "uniform vec3 spot_direction$;\n"); - - mash_light_append_shader (light, main_source, mash_spot_light_shader); -} - -static void -mash_spot_light_update_uniforms (MashLight *light, - CoglHandle program) -{ - MashSpotLight *slight = MASH_SPOT_LIGHT (light); - MashSpotLightPrivate *priv = slight->priv; - /* The light is assumed to always be pointing directly down. This - can be modified by rotating the actor */ - static const float light_direction[4] = { 0.0f, 1.0f, 0.0f, 0.0f }; - - MASH_LIGHT_CLASS (mash_spot_light_parent_class) - ->update_uniforms (light, program); - - if (priv->uniform_locations_dirty) - { - priv->spot_cos_cutoff_uniform_location - = mash_light_get_uniform_location (light, program, "spot_cos_cutoff"); - priv->spot_exponent_uniform_location - = mash_light_get_uniform_location (light, program, "spot_exponent"); - priv->light_direction_uniform_location - = mash_light_get_uniform_location (light, program, "spot_direction"); - priv->uniform_locations_dirty = FALSE; - } - - if (priv->spot_params_dirty) - { - cogl_program_set_uniform_1f (program, - priv->spot_cos_cutoff_uniform_location, - cosf (priv->spot_cutoff * G_PI / 180.0)); - cogl_program_set_uniform_1f (program, - priv->spot_exponent_uniform_location, - priv->spot_exponent); - priv->spot_params_dirty = FALSE; - } - - /* I can't think of a good way to recognise when the transformation - of the actor may have changed so this just always updates the - light direction. Any transformations in the parent hierarchy - could cause the transformation to change without affecting the - allocation */ - - mash_light_set_direction_uniform (light, - program, - priv->light_direction_uniform_location, - light_direction); -} diff --git a/mash/mash-spot-light.h b/mash/mash-spot-light.h deleted file mode 100644 index 69b416d..0000000 --- a/mash/mash-spot-light.h +++ b/dev/null @@ -1,93 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#if !defined(__MASH_H_INSIDE__) && !defined(MASH_COMPILATION) -#error "Only <mash/mash.h> can be included directly." -#endif - -#ifndef __MASH_SPOT_LIGHT_H__ -#define __MASH_SPOT_LIGHT_H__ - -#include <mash/mash-point-light.h> - -G_BEGIN_DECLS - -#define MASH_TYPE_SPOT_LIGHT \ - (mash_spot_light_get_type()) -#define MASH_SPOT_LIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MASH_TYPE_SPOT_LIGHT, \ - MashSpotLight)) -#define MASH_SPOT_LIGHT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MASH_TYPE_SPOT_LIGHT, \ - MashSpotLightClass)) -#define MASH_IS_SPOT_LIGHT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MASH_TYPE_SPOT_LIGHT)) -#define MASH_IS_SPOT_LIGHT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MASH_TYPE_SPOT_LIGHT)) -#define MASH_SPOT_LIGHT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MASH_SPOT_LIGHT, \ - MashSpotLightClass)) - -typedef struct _MashSpotLight MashSpotLight; -typedef struct _MashSpotLightClass MashSpotLightClass; -typedef struct _MashSpotLightPrivate MashSpotLightPrivate; - -/** - * MashSpotLightClass: - * - * The #MashSpotLightClass structure contains only private data. - */ -struct _MashSpotLightClass -{ - /*< private >*/ - MashPointLightClass parent_class; -}; - -/** - * MashSpotLight: - * - * The #MashSpotLight structure contains only private data. - */ -struct _MashSpotLight -{ - /*< private >*/ - MashPointLight parent; - - MashSpotLightPrivate *priv; -}; - -GType mash_spot_light_get_type (void) G_GNUC_CONST; - -ClutterActor *mash_spot_light_new (void); - -void mash_spot_light_set_spot_cutoff (MashSpotLight *light, - gfloat cutoff); -gfloat mash_spot_light_get_spot_cutoff (MashSpotLight *light); - -void mash_spot_light_set_spot_exponent (MashSpotLight *light, - gfloat exponent); -gfloat mash_spot_light_get_spot_exponent (MashSpotLight *light); - -G_END_DECLS - -#endif /* __MASH_SPOT_LIGHT_H__ */ diff --git a/mash/mash.h b/mash/mash.h deleted file mode 100644 index 5dd0c5a..0000000 --- a/mash/mash.h +++ b/dev/null @@ -1,35 +0,0 @@ -/* - * Mash - A library for displaying PLY models in a Clutter scene - * Copyright (C) 2010 Intel Corporation - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __MASH_H__ -#define __MASH_H__ - -#define __MASH_H_INSIDE__ - -#include "mash-model.h" -#include "mash-data.h" -#include "mash-light.h" -#include "mash-point-light.h" -#include "mash-spot-light.h" -#include "mash-directional-light.h" -#include "mash-light-set.h" -#include "mash-enum-types.h" - -#undef __MASH_H_INSIDE__ - -#endif /* __MASH_H__ */ diff --git a/mash/rply/LICENSE b/mash/rply/LICENSE deleted file mode 100644 index 02e7c5f..0000000 --- a/mash/rply/LICENSE +++ b/dev/null @@ -1,20 +0,0 @@ -RPly 1.01 license -Copyright © 2003-2005 Diego Nehab. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/mash/rply/Makefile.am b/mash/rply/Makefile.am deleted file mode 100644 index e2eeea9..0000000 --- a/mash/rply/Makefile.am +++ b/dev/null @@ -1,14 +0,0 @@ -noinst_LTLIBRARIES = librply.la -noinst_PROGRAMS = convert - -AM_CPPFLAGS = \ - @GLIB_CFLAGS@ - -librply_la_SOURCES = \ - rply.c \ - rply.h - -convert_SOURCES = \ - convert.c - -convert_LDADD = librply.la @GLIB_LIBS@ diff --git a/mash/rply/convert.c b/mash/rply/convert.c deleted file mode 100644 index 62c66d9..0000000 --- a/mash/rply/convert.c +++ b/dev/null @@ -1,140 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include "rply.h" - -/* internal function prototypes */ -static void error(const char *fmt, ...); -static void help(void); -static void parse_arguments(int argc, char **argv, - e_ply_storage_mode *storage_mode, - const char **iname, const char **oname); -static void setup_callbacks(p_ply iply, p_ply oply); - -/* given a format mode, an input file name and an output file name, - * convert input file to output in given format mode */ -int main(int argc, char **argv) -{ - const char *value = NULL; - e_ply_storage_mode storage_mode = PLY_LITTLE_ENDIAN; - const char *iname = NULL, *oname = NULL; - p_ply iply = NULL, oply = NULL; - /* parse command line arguments */ - parse_arguments(argc, argv, &storage_mode, &iname, &oname); - /* open input file and make sure we parsed its header */ - iply = ply_open(iname, NULL, NULL); - if (!iply) error("Unable to open file '%s'", iname); - if (!ply_read_header(iply)) error("Failed reading '%s' header", iname); - /* create output file */ - oply = ply_create(oname, storage_mode, NULL, NULL); - if (!oply) error("Unable to create file '%s'", oname); - /* create elements and properties in output file and - * setup callbacks for them in input file */ - setup_callbacks(iply, oply); - /* pass comments and obj_infos from input to output */ - value = NULL; - while ((value = ply_get_next_comment(iply, value))) - if (!ply_add_comment(oply, value)) - error("Failed adding comments"); - value = NULL; - while ((value = ply_get_next_obj_info(iply, value))) - if (!ply_add_obj_info(oply, value)) - error("Failed adding comments"); - /* write output header */ - if (!ply_write_header(oply)) error("Failed writing '%s' header", oname); - /* read input file generating callbacks that pass data to output file */ - if (!ply_read(iply)) error("Conversion failed"); - /* close up, we are done */ - if (!ply_close(iply)) error("Error closing file '%s'", iname); - if (!ply_close(oply)) error("Error closing file '%s'", oname); - return 0; -} - -/* prints an error message and exits */ -static void error(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "\n"); - exit(1); -} - -/* prints the help message and exits */ -static void help(void) -{ - error("Usage:\n" - " convert <option> <input> <output>\n" - "Options:\n" - " -a, --ascii: convert to ascii format\n" - " -b, --big-endian: convert to big-endian format\n" - " -l, --little-endian: convert to little-endian format\n"); -} - -/* parse command line parameters */ -static void parse_arguments(int argc, char **argv, - e_ply_storage_mode *storage_mode, - const char **iname, const char **oname) -{ - if (argc < 4) help(); - if (strcmp(argv[1], "--ascii") == 0 || - strcmp(argv[1], "-a") == 0) - *storage_mode = PLY_ASCII; - else if (strcmp(argv[1], "--little-endian") == 0 || - strcmp(argv[1], "-l") == 0) - *storage_mode = PLY_LITTLE_ENDIAN; - else if (strcmp(argv[1], "--big-endian") == 0 || - strcmp(argv[1], "-b") == 0) - *storage_mode = PLY_BIG_ENDIAN; - else help(); - *iname = argv[2]; - *oname = argv[3]; -} - -/* read callback */ -static int callback(p_ply_argument argument) -{ - void *pdata; - /* just pass the value from the input file to the output file */ - ply_get_argument_user_data(argument, &pdata, NULL); - ply_write((p_ply) pdata, ply_get_argument_value(argument)); - return 1; -} - -/* prepares the conversion */ -static void setup_callbacks(p_ply iply, p_ply oply) -{ - p_ply_element element = NULL; - /* iterate over all elements in input file */ - while ((element = ply_get_next_element(iply, element))) { - p_ply_property property = NULL; - gint32 ninstances = 0; - const char *element_name; - ply_get_element_info(element, &element_name, &ninstances); - /* add this element to output file */ - if (!ply_add_element(oply, element_name, ninstances)) - error("Unable to add output element '%s'", element_name); - /* iterate over all properties of current element */ - while ((property = ply_get_next_property(element, property))) { - const char *property_name; - e_ply_type type, length_type, value_type; - ply_get_property_info(property, &property_name, &type, - &length_type, &value_type); - /* setup input callback for this property */ - if (!ply_set_read_cb(iply, element_name, property_name, callback, - oply, 0)) - error("Unable to setup input callback for property '%s'", - property_name); - /* add this property to output file */ - if (!ply_add_property(oply, property_name, type, length_type, - value_type)) - error("Unable to add output property '%s'", property_name); - } - } -} diff --git a/mash/rply/rply.c b/mash/rply/rply.c deleted file mode 100644 index 7beb1e4..0000000 --- a/mash/rply/rply.c +++ b/dev/null @@ -1,1510 +0,0 @@ -/* ---------------------------------------------------------------------- - * RPly library, read/write PLY files - * Diego Nehab, Princeton University - * http://www.cs.princeton.edu/~diego/professional/rply - * - * This library is distributed under the MIT License. See notice - * at the end of this file. - * ---------------------------------------------------------------------- */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <stdio.h> -#include <ctype.h> -#include <assert.h> -#include <string.h> -#include <limits.h> -#include <float.h> -#include <stdarg.h> -#include <stdlib.h> -#include <stddef.h> - -#include "rply.h" - -/* ---------------------------------------------------------------------- - * Constants - * ---------------------------------------------------------------------- */ -#define WORDSIZE 256 -#define LINESIZE 1024 -#define BUFFERSIZE (8*1024) - -typedef enum e_ply_io_mode_ { - PLY_READ, - PLY_WRITE -} e_ply_io_mode; - -static const char *const ply_storage_mode_list[] = { - "binary_big_endian", "binary_little_endian", "ascii", NULL -}; /* order matches e_ply_storage_mode enum */ - -static const char *const ply_type_list[] = { - "int8", "uint8", "int16", "uint16", - "int32", "uint32", "float32", "float64", - "char", "uchar", "short", "ushort", - "int", "uint", "float", "double", - "list", NULL -}; /* order matches e_ply_type enum */ - -/* ---------------------------------------------------------------------- - * Property reading callback argument - * - * element: name of element being processed - * property: name of property being processed - * nelements: number of elements of this kind in file - * instance_index: index current element of this kind being processed - * length: number of values in current list (or 1 for scalars) - * value_index: index of current value int this list (or 0 for scalars) - * value: value of property - * pdata/idata: user data defined with ply_set_cb - * - * Returns handle to ply file if succesful, NULL otherwise. - * ---------------------------------------------------------------------- */ -typedef struct t_ply_argument_ { - p_ply_element element; - gint32 instance_index; - p_ply_property property; - gint32 length, value_index; - double value; - void *pdata; - long idata; -} t_ply_argument; - -/* ---------------------------------------------------------------------- - * Property information - * - * name: name of this property - * type: type of this property (list or type of scalar value) - * length_type, value_type: type of list property count and values - * read_cb: function to be called when this property is called - * - * Returns 1 if should continue processing file, 0 if should abort. - * ---------------------------------------------------------------------- */ -typedef struct t_ply_property_ { - char name[WORDSIZE]; - e_ply_type type, value_type, length_type; - p_ply_read_cb read_cb; - void *pdata; - long idata; -} t_ply_property; - -/* ---------------------------------------------------------------------- - * Element information - * - * name: name of this property - * ninstances: number of elements of this type in file - * property: property descriptions for this element - * nproperty: number of properties in this element - * - * Returns 1 if should continue processing file, 0 if should abort. - * ---------------------------------------------------------------------- */ -typedef struct t_ply_element_ { - char name[WORDSIZE]; - gint32 ninstances; - p_ply_property property; - gint32 nproperties; -} t_ply_element; - -/* ---------------------------------------------------------------------- - * Input/output driver - * - * Depending on file mode, different functions are used to read/write - * property fields. The drivers make it transparent to read/write in ascii, - * big endian or little endian cases. - * ---------------------------------------------------------------------- */ -typedef int (*p_ply_ihandler)(p_ply ply, double *value); -typedef int (*p_ply_ichunk)(p_ply ply, void *anydata, size_t size); -typedef struct t_ply_idriver_ { - p_ply_ihandler ihandler[16]; - p_ply_ichunk ichunk; - const char *name; -} t_ply_idriver; -typedef t_ply_idriver *p_ply_idriver; - -typedef int (*p_ply_ohandler)(p_ply ply, double value); -typedef int (*p_ply_ochunk)(p_ply ply, void *anydata, size_t size); -typedef struct t_ply_odriver_ { - p_ply_ohandler ohandler[16]; - p_ply_ochunk ochunk; - const char *name; -} t_ply_odriver; -typedef t_ply_odriver *p_ply_odriver; - -/* ---------------------------------------------------------------------- - * Ply file handle. - * - * io_mode: read or write (from e_ply_io_mode) - * storage_mode: mode of file associated with handle (from e_ply_storage_mode) - * element: elements description for this file - * nelement: number of different elements in file - * comment: comments for this file - * ncomments: number of comments in file - * obj_info: obj_info items for this file - * nobj_infos: number of obj_info items in file - * fp: file pointer associated with ply file - * c: last character read from ply file - * buffer: last word/chunck of data read from ply file - * buffer_first, buffer_last: interval of untouched good data in buffer - * buffer_token: start of parsed token (line or word) in buffer - * idriver, odriver: input driver used to get property fields from file - * argument: storage space for callback arguments - * welement, wproperty: element/property type being written - * winstance_index: index of instance of current element being written - * wvalue_index: index of list property value being written - * wlength: number of values in list property being written - * error_cb: callback for error messages - * ---------------------------------------------------------------------- */ -typedef struct t_ply_ { - e_ply_io_mode io_mode; - e_ply_storage_mode storage_mode; - p_ply_element element; - gint32 nelements; - char *comment; - gint32 ncomments; - char *obj_info; - gint32 nobj_infos; - FILE *fp; - int c; - char buffer[BUFFERSIZE]; - size_t buffer_first, buffer_token, buffer_last; - p_ply_idriver idriver; - p_ply_odriver odriver; - t_ply_argument argument; - gint32 welement, wproperty; - gint32 winstance_index, wvalue_index, wlength; - p_ply_error_cb error_cb; - gpointer cb_data; -} t_ply; - -/* ---------------------------------------------------------------------- - * I/O functions and drivers - * ---------------------------------------------------------------------- */ -static t_ply_idriver ply_idriver_ascii; -static t_ply_idriver ply_idriver_binary; -static t_ply_idriver ply_idriver_binary_reverse; -static t_ply_odriver ply_odriver_ascii; -static t_ply_odriver ply_odriver_binary; -static t_ply_odriver ply_odriver_binary_reverse; - -static int ply_read_word(p_ply ply); -static int ply_check_word(p_ply ply); -static int ply_read_line(p_ply ply); -static int ply_check_line(p_ply ply); -static int ply_read_chunk(p_ply ply, void *anybuffer, size_t size); -static int ply_read_chunk_reverse(p_ply ply, void *anybuffer, size_t size); -static int ply_write_chunk(p_ply ply, void *anybuffer, size_t size); -static int ply_write_chunk_reverse(p_ply ply, void *anybuffer, size_t size); -static void ply_reverse(void *anydata, size_t size); - -/* ---------------------------------------------------------------------- - * String functions - * ---------------------------------------------------------------------- */ -static int ply_find_string(const char *item, const char* const list[]); -static p_ply_element ply_find_element(p_ply ply, const char *name); -static p_ply_property ply_find_property(p_ply_element element, - const char *name); - -/* ---------------------------------------------------------------------- - * Header parsing - * ---------------------------------------------------------------------- */ -static int ply_read_header_format(p_ply ply); -static int ply_read_header_comment(p_ply ply); -static int ply_read_header_obj_info(p_ply ply); -static int ply_read_header_property(p_ply ply); -static int ply_read_header_element(p_ply ply); - -/* ---------------------------------------------------------------------- - * Error handling - * ---------------------------------------------------------------------- */ -static void ply_error_cb(const char *message, gpointer data); -static void ply_error(p_ply ply, const char *fmt, ...); - -/* ---------------------------------------------------------------------- - * Memory allocation and initialization - * ---------------------------------------------------------------------- */ -static void ply_init(p_ply ply); -static void ply_element_init(p_ply_element element); -static void ply_property_init(p_ply_property property); -static p_ply ply_alloc(void); -static p_ply_element ply_grow_element(p_ply ply); -static p_ply_property ply_grow_property(p_ply ply, p_ply_element element); -static void *ply_grow_array(p_ply ply, void **pointer, gint32 *nmemb, gint32 size); - -/* ---------------------------------------------------------------------- - * Special functions - * ---------------------------------------------------------------------- */ -static e_ply_storage_mode ply_arch_endian(void); -static int ply_type_check(void); - -/* ---------------------------------------------------------------------- - * Auxiliary read functions - * ---------------------------------------------------------------------- */ -static int ply_read_element(p_ply ply, p_ply_element element, - p_ply_argument argument); -static int ply_read_property(p_ply ply, p_ply_element element, - p_ply_property property, p_ply_argument argument); -static int ply_read_list_property(p_ply ply, p_ply_element element, - p_ply_property property, p_ply_argument argument); -static int ply_read_scalar_property(p_ply ply, p_ply_element element, - p_ply_property property, p_ply_argument argument); - - -/* ---------------------------------------------------------------------- - * Buffer support functions - * ---------------------------------------------------------------------- */ -/* pointers to tokenized word and line in buffer */ -#define BWORD(p) (p->buffer + p->buffer_token) -#define BLINE(p) (p->buffer + p->buffer_token) - -/* pointer to start of untouched bytes in buffer */ -#define BFIRST(p) (p->buffer + p->buffer_first) - -/* number of bytes untouched in buffer */ -#define BSIZE(p) (p->buffer_last - p->buffer_first) - -/* consumes data from buffer */ -#define BSKIP(p, s) (p->buffer_first += s) - -/* refills the buffer */ -static int BREFILL(p_ply ply) { - /* move untouched data to beginning of buffer */ - size_t size = BSIZE(ply); - memmove(ply->buffer, BFIRST(ply), size); - ply->buffer_last = size; - ply->buffer_first = ply->buffer_token = 0; - /* fill remaining with new data */ - size = fread(ply->buffer+size, 1, BUFFERSIZE-size-1, ply->fp); - /* place sentinel so we can use str* functions with buffer */ - ply->buffer[BUFFERSIZE-1] = '\0'; - /* check if read failed */ - if (size <= 0) return 0; - /* increase size to account for new data */ - ply->buffer_last += size; - return 1; -} - -/* ---------------------------------------------------------------------- - * Exported functions - * ---------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - * Read support functions - * ---------------------------------------------------------------------- */ -p_ply ply_open(const char *name, p_ply_error_cb error_cb, gpointer cb_data) { - char magic[5] = " "; - FILE *fp = NULL; - p_ply ply = NULL; - if (error_cb == NULL) error_cb = ply_error_cb; - if (!ply_type_check()) { - error_cb("Incompatible type system", cb_data); - return NULL; - } - assert(name); - fp = fopen(name, "rb"); - if (!fp) { - error_cb("Unable to open file", cb_data); - return NULL; - } - if (fread(magic, 1, 4, fp) < 4) { - error_cb("Error reading from file", cb_data); - fclose(fp); - return NULL; - } - if (strcmp(magic, "ply\n")) { - fclose(fp); - error_cb("Not a PLY file. Expected magic number 'ply\\n'", cb_data); - return NULL; - } - ply = ply_alloc(); - if (!ply) { - error_cb("Out of memory", cb_data); - fclose(fp); - return NULL; - } - ply->fp = fp; - ply->io_mode = PLY_READ; - ply->error_cb = error_cb; - ply->cb_data = cb_data; - return ply; -} - -int ply_read_header(p_ply ply) { - assert(ply && ply->fp && ply->io_mode == PLY_READ); - if (!ply_read_word(ply)) return 0; - /* parse file format */ - if (!ply_read_header_format(ply)) { - ply_error(ply, "Invalid file format"); - return 0; - } - /* parse elements, comments or obj_infos until the end of header */ - while (strcmp(BWORD(ply), "end_header")) { - if (!ply_read_header_comment(ply) && - !ply_read_header_element(ply) && - !ply_read_header_obj_info(ply)) { - ply_error(ply, "Unexpected token '%s'", BWORD(ply)); - return 0; - } - } - return 1; -} - -long ply_set_read_cb(p_ply ply, const char *element_name, - const char* property_name, p_ply_read_cb read_cb, - void *pdata, long idata) { - p_ply_element element = NULL; - p_ply_property property = NULL; - assert(ply && element_name && property_name); - element = ply_find_element(ply, element_name); - if (!element) return 0; - property = ply_find_property(element, property_name); - if (!property) return 0; - property->read_cb = read_cb; - property->pdata = pdata; - property->idata = idata; - return (int) element->ninstances; -} - -int ply_read(p_ply ply) { - gint32 i; - p_ply_argument argument; - assert(ply && ply->fp && ply->io_mode == PLY_READ); - argument = &ply->argument; - /* for each element type */ - for (i = 0; i < ply->nelements; i++) { - p_ply_element element = &ply->element[i]; - argument->element = element; - if (!ply_read_element(ply, element, argument)) - return 0; - } - return 1; -} - -/* ---------------------------------------------------------------------- - * Write support functions - * ---------------------------------------------------------------------- */ -p_ply ply_create(const char *name, e_ply_storage_mode storage_mode, - p_ply_error_cb error_cb, gpointer cb_data) { - FILE *fp = NULL; - p_ply ply = NULL; - if (error_cb == NULL) error_cb = ply_error_cb; - if (!ply_type_check()) { - error_cb("Incompatible type system", cb_data); - return NULL; - } - assert(name && storage_mode <= PLY_DEFAULT); - fp = fopen(name, "wb"); - if (!fp) { - error_cb("Unable to create file", cb_data); - return NULL; - } - ply = ply_alloc(); - if (!ply) { - fclose(fp); - error_cb("Out of memory", cb_data); - return NULL; - } - ply->io_mode = PLY_WRITE; - if (storage_mode == PLY_DEFAULT) storage_mode = ply_arch_endian(); - if (storage_mode == PLY_ASCII) ply->odriver = &ply_odriver_ascii; - else if (storage_mode == ply_arch_endian()) - ply->odriver = &ply_odriver_binary; - else ply->odriver = &ply_odriver_binary_reverse; - ply->storage_mode = storage_mode; - ply->fp = fp; - ply->error_cb = error_cb; - ply->cb_data = cb_data; - return ply; -} - -int ply_add_element(p_ply ply, const char *name, gint32 ninstances) { - p_ply_element element = NULL; - assert(ply && ply->fp && ply->io_mode == PLY_WRITE); - assert(name && strlen(name) < WORDSIZE && ninstances >= 0); - if (strlen(name) >= WORDSIZE || ninstances < 0) { - ply_error(ply, "Invalid arguments"); - return 0; - } - element = ply_grow_element(ply); - if (!element) return 0; - strcpy(element->name, name); - element->ninstances = ninstances; - return 1; -} - -int ply_add_scalar_property(p_ply ply, const char *name, e_ply_type type) { - p_ply_element element = NULL; - p_ply_property property = NULL; - assert(ply && ply->fp && ply->io_mode == PLY_WRITE); - assert(name && strlen(name) < WORDSIZE); - assert(type < PLY_LIST); - if (strlen(name) >= WORDSIZE || type >= PLY_LIST) { - ply_error(ply, "Invalid arguments"); - return 0; - } - element = &ply->element[ply->nelements-1]; - property = ply_grow_property(ply, element); - if (!property) return 0; - strcpy(property->name, name); - property->type = type; - return 1; -} - -int ply_add_list_property(p_ply ply, const char *name, - e_ply_type length_type, e_ply_type value_type) { - p_ply_element element = NULL; - p_ply_property property = NULL; - assert(ply && ply->fp && ply->io_mode == PLY_WRITE); - assert(name && strlen(name) < WORDSIZE); - if (strlen(name) >= WORDSIZE) { - ply_error(ply, "Invalid arguments"); - return 0; - } - assert(length_type < PLY_LIST); - assert(value_type < PLY_LIST); - if (length_type >= PLY_LIST || value_type >= PLY_LIST) { - ply_error(ply, "Invalid arguments"); - return 0; - } - element = &ply->element[ply->nelements-1]; - property = ply_grow_property(ply, element); - if (!property) return 0; - strcpy(property->name, name); - property->type = PLY_LIST; - property->length_type = length_type; - property->value_type = value_type; - return 1; -} - -int ply_add_property(p_ply ply, const char *name, e_ply_type type, - e_ply_type length_type, e_ply_type value_type) { - if (type == PLY_LIST) - return ply_add_list_property(ply, name, length_type, value_type); - else - return ply_add_scalar_property(ply, name, type); -} - -int ply_add_comment(p_ply ply, const char *comment) { - char *new_comment = NULL; - assert(ply && comment && strlen(comment) < LINESIZE); - if (!comment || strlen(comment) >= LINESIZE) { - ply_error(ply, "Invalid arguments"); - return 0; - } - new_comment = (char *) ply_grow_array(ply, (void **) &ply->comment, - &ply->ncomments, LINESIZE); - if (!new_comment) return 0; - strcpy(new_comment, comment); - return 1; -} - -int ply_add_obj_info(p_ply ply, const char *obj_info) { - char *new_obj_info = NULL; - assert(ply && obj_info && strlen(obj_info) < LINESIZE); - if (!obj_info || strlen(obj_info) >= LINESIZE) { - ply_error(ply, "Invalid arguments"); - return 0; - } - new_obj_info = (char *) ply_grow_array(ply, (void **) &ply->obj_info, - &ply->nobj_infos, LINESIZE); - if (!new_obj_info) return 0; - strcpy(new_obj_info, obj_info); - return 1; -} - -int ply_write_header(p_ply ply) { - gint32 i, j; - assert(ply && ply->fp && ply->io_mode == PLY_WRITE); - assert(ply->element || ply->nelements == 0); - assert(!ply->element || ply->nelements > 0); - if (fprintf(ply->fp, "ply\nformat %s 1.0\n", - ply_storage_mode_list[ply->storage_mode]) <= 0) goto error; - for (i = 0; i < ply->ncomments; i++) - if (fprintf(ply->fp, "comment %s\n", ply->comment + LINESIZE*i) <= 0) - goto error; - for (i = 0; i < ply->nobj_infos; i++) - if (fprintf(ply->fp, "obj_info %s\n", ply->obj_info + LINESIZE*i) <= 0) - goto error; - for (i = 0; i < ply->nelements; i++) { - p_ply_element element = &ply->element[i]; - assert(element->property || element->nproperties == 0); - assert(!element->property || element->nproperties > 0); - if (fprintf(ply->fp, "element %s %" G_GINT32_FORMAT " \n", element->name, - element->ninstances) <= 0) goto error; - for (j = 0; j < element->nproperties; j++) { - p_ply_property property = &element->property[j]; - if (property->type == PLY_LIST) { - if (fprintf(ply->fp, "property list %s %s %s\n", - ply_type_list[property->length_type], - ply_type_list[property->value_type], - property->name) <= 0) goto error; - } else { - if (fprintf(ply->fp, "property %s %s\n", - ply_type_list[property->type], - property->name) <= 0) goto error; - } - } - } - return fprintf(ply->fp, "end_header\n") > 0; -error: - ply_error(ply, "Error writing to file"); - return 0; -} - -int ply_write(p_ply ply, double value) { - p_ply_element element = NULL; - p_ply_property property = NULL; - int type = -1; - int breakafter = 0; - if (ply->welement > ply->nelements) return 0; - element = &ply->element[ply->welement]; - if (ply->wproperty > element->nproperties) return 0; - property = &element->property[ply->wproperty]; - if (property->type == PLY_LIST) { - if (ply->wvalue_index == 0) { - type = property->length_type; - ply->wlength = (gint32) value; - } else type = property->value_type; - } else { - type = property->type; - ply->wlength = 0; - } - if (!ply->odriver->ohandler[type](ply, value)) { - ply_error(ply, "Failed writing %s of %s %d (%s: %s)", - property->name, element->name, - ply->winstance_index, - ply->odriver->name, ply_type_list[type]); - return 0; - } - ply->wvalue_index++; - if (ply->wvalue_index > ply->wlength) { - ply->wvalue_index = 0; - ply->wproperty++; - } - if (ply->wproperty >= element->nproperties) { - ply->wproperty = 0; - ply->winstance_index++; - if (ply->storage_mode == PLY_ASCII) breakafter = 1; - } - if (ply->winstance_index >= element->ninstances) { - ply->winstance_index = 0; - ply->welement++; - } - return !breakafter || putc('\n', ply->fp) > 0; -} - -int ply_close(p_ply ply) { - gint32 i; - assert(ply && ply->fp); - assert(ply->element || ply->nelements == 0); - assert(!ply->element || ply->nelements > 0); - /* write last chunk to file */ - if (ply->io_mode == PLY_WRITE && - fwrite(ply->buffer, 1, ply->buffer_last, ply->fp) < ply->buffer_last) { - ply_error(ply, "Error closing up"); - return 0; - } - fclose(ply->fp); - /* free all memory used by handle */ - if (ply->element) { - for (i = 0; i < ply->nelements; i++) { - p_ply_element element = &ply->element[i]; - if (element->property) free(element->property); - } - free(ply->element); - } - if (ply->obj_info) free(ply->obj_info); - if (ply->comment) free(ply->comment); - free(ply); - return 1; -} - -/* ---------------------------------------------------------------------- - * Query support functions - * ---------------------------------------------------------------------- */ -p_ply_element ply_get_next_element(p_ply ply, - p_ply_element last) { - assert(ply); - if (!last) return ply->element; - last++; - if (last < ply->element + ply->nelements) return last; - else return NULL; -} - -int ply_get_element_info(p_ply_element element, const char** name, - gint32 *ninstances) { - assert(element); - if (name) *name = element->name; - if (ninstances) *ninstances = (gint32) element->ninstances; - return 1; -} - -p_ply_property ply_get_next_property(p_ply_element element, - p_ply_property last) { - assert(element); - if (!last) return element->property; - last++; - if (last < element->property + element->nproperties) return last; - else return NULL; -} - -int ply_get_property_info(p_ply_property property, const char** name, - e_ply_type *type, e_ply_type *length_type, e_ply_type *value_type) { - assert(property); - if (name) *name = property->name; - if (type) *type = property->type; - if (length_type) *length_type = property->length_type; - if (value_type) *value_type = property->value_type; - return 1; - -} - -const char *ply_get_next_comment(p_ply ply, const char *last) { - assert(ply); - if (!last) return ply->comment; - last += LINESIZE; - if (last < ply->comment + LINESIZE*ply->ncomments) return last; - else return NULL; -} - -const char *ply_get_next_obj_info(p_ply ply, const char *last) { - assert(ply); - if (!last) return ply->obj_info; - last += LINESIZE; - if (last < ply->obj_info + LINESIZE*ply->nobj_infos) return last; - else return NULL; -} - -/* ---------------------------------------------------------------------- - * Callback argument support functions - * ---------------------------------------------------------------------- */ -int ply_get_argument_element(p_ply_argument argument, - p_ply_element *element, gint32 *instance_index) { - assert(argument); - if (!argument) return 0; - if (element) *element = argument->element; - if (instance_index) *instance_index = argument->instance_index; - return 1; -} - -int ply_get_argument_property(p_ply_argument argument, - p_ply_property *property, gint32 *length, gint32 *value_index) { - assert(argument); - if (!argument) return 0; - if (property) *property = argument->property; - if (length) *length = argument->length; - if (value_index) *value_index = argument->value_index; - return 1; -} - -int ply_get_argument_user_data(p_ply_argument argument, void **pdata, - long *idata) { - assert(argument); - if (!argument) return 0; - if (pdata) *pdata = argument->pdata; - if (idata) *idata = argument->idata; - return 1; -} - -double ply_get_argument_value(p_ply_argument argument) { - assert(argument); - if (!argument) return 0.0; - return argument->value; -} - -/* ---------------------------------------------------------------------- - * Internal functions - * ---------------------------------------------------------------------- */ -static int ply_read_list_property(p_ply ply, p_ply_element element, - p_ply_property property, p_ply_argument argument) { - int l; - p_ply_read_cb read_cb = property->read_cb; - p_ply_ihandler *driver = ply->idriver->ihandler; - /* get list length */ - p_ply_ihandler handler = driver[property->length_type]; - double length; - if (!handler(ply, &length)) { - ply_error(ply, "Error reading '%s' of '%s' number %d", - property->name, element->name, argument->instance_index); - return 0; - } - /* invoke callback to pass length in value field */ - argument->length = (gint32) length; - argument->value_index = -1; - argument->value = length; - if (read_cb && !read_cb(argument)) { - ply_error(ply, "Aborted by user"); - return 0; - } - /* read list values */ - handler = driver[property->value_type]; - /* for each value in list */ - for (l = 0; l < (gint32) length; l++) { - /* read value from file */ - argument->value_index = l; - if (!handler(ply, &argument->value)) { - ply_error(ply, "Error reading value number %d of '%s' of " - "'%s' number %d", l+1, property->name, - element->name, argument->instance_index); - return 0; - } - /* invoke callback to pass value */ - if (read_cb && !read_cb(argument)) { - ply_error(ply, "Aborted by user"); - return 0; - } - } - return 1; -} - -static int ply_read_scalar_property(p_ply ply, p_ply_element element, - p_ply_property property, p_ply_argument argument) { - p_ply_read_cb read_cb = property->read_cb; - p_ply_ihandler *driver = ply->idriver->ihandler; - p_ply_ihandler handler = driver[property->type]; - argument->length = 1; - argument->value_index = 0; - if (!handler(ply, &argument->value)) { - ply_error(ply, "Error reading '%s' of '%s' number %d", - property->name, element->name, argument->instance_index); - return 0; - } - if (read_cb && !read_cb(argument)) { - ply_error(ply, "Aborted by user"); - return 0; - } - return 1; -} - -static int ply_read_property(p_ply ply, p_ply_element element, - p_ply_property property, p_ply_argument argument) { - if (property->type == PLY_LIST) - return ply_read_list_property(ply, element, property, argument); - else - return ply_read_scalar_property(ply, element, property, argument); -} - -static int ply_read_element(p_ply ply, p_ply_element element, - p_ply_argument argument) { - gint32 j, k; - /* for each element of this type */ - for (j = 0; j < element->ninstances; j++) { - argument->instance_index = j; - /* for each property */ - for (k = 0; k < element->nproperties; k++) { - p_ply_property property = &element->property[k]; - argument->property = property; - argument->pdata = property->pdata; - argument->idata = property->idata; - if (!ply_read_property(ply, element, property, argument)) - return 0; - } - } - return 1; -} - -static int ply_find_string(const char *item, const char* const list[]) { - int i; - assert(item && list); - for (i = 0; list[i]; i++) - if (!strcmp(list[i], item)) return i; - return -1; -} - -static p_ply_element ply_find_element(p_ply ply, const char *name) { - p_ply_element element; - int i, nelements; - assert(ply && name); - element = ply->element; - nelements = ply->nelements; - assert(element || nelements == 0); - assert(!element || nelements > 0); - for (i = 0; i < nelements; i++) - if (!strcmp(element[i].name, name)) return &element[i]; - return NULL; -} - -static p_ply_property ply_find_property(p_ply_element element, - const char *name) { - p_ply_property property; - int i, nproperties; - assert(element && name); - property = element->property; - nproperties = element->nproperties; - assert(property || nproperties == 0); - assert(!property || nproperties > 0); - for (i = 0; i < nproperties; i++) - if (!strcmp(property[i].name, name)) return &property[i]; - return NULL; -} - -static int ply_check_word(p_ply ply) { - if (strlen(BLINE(ply)) >= WORDSIZE) { - ply_error(ply, "Word too gint32"); - return 0; - } - return 1; -} - -static int ply_read_word(p_ply ply) { - size_t t = 0; - assert(ply && ply->fp && ply->io_mode == PLY_READ); - /* skip leading blanks */ - while (1) { - t = strspn(BFIRST(ply), " \n\r\t"); - /* check if all buffer was made of blanks */ - if (t >= BSIZE(ply)) { - if (!BREFILL(ply)) { - ply_error(ply, "Unexpected end of file"); - return 0; - } - } else break; - } - BSKIP(ply, t); - /* look for a space after the current word */ - t = strcspn(BFIRST(ply), " \n\r\t"); - /* if we didn't reach the end of the buffer, we are done */ - if (t < BSIZE(ply)) { - ply->buffer_token = ply->buffer_first; - BSKIP(ply, t); - *BFIRST(ply) = '\0'; - BSKIP(ply, 1); - return ply_check_word(ply); - } - /* otherwise, try to refill buffer */ - if (!BREFILL(ply)) { - ply_error(ply, "Unexpected end of file"); - return 0; - } - /* keep looking from where we left */ - t += strcspn(BFIRST(ply) + t, " \n\r\t"); - /* check if the token is too large for our buffer */ - if (t >= BSIZE(ply)) { - ply_error(ply, "Token too large"); - return 0; - } - /* we are done */ - ply->buffer_token = ply->buffer_first; - BSKIP(ply, t); - *BFIRST(ply) = '\0'; - BSKIP(ply, 1); - return ply_check_word(ply); -} - -static int ply_check_line(p_ply ply) { - if (strlen(BLINE(ply)) >= LINESIZE) { - ply_error(ply, "Line too gint32"); - return 0; - } - return 1; -} - -static int ply_read_line(p_ply ply) { - const char *end = NULL; - assert(ply && ply->fp && ply->io_mode == PLY_READ); - /* look for a end of line */ - end = strchr(BFIRST(ply), '\n'); - /* if we didn't reach the end of the buffer, we are done */ - if (end) { - ply->buffer_token = ply->buffer_first; - BSKIP(ply, end - BFIRST(ply)); - *BFIRST(ply) = '\0'; - BSKIP(ply, 1); - return ply_check_line(ply); - } else { - end = ply->buffer + BSIZE(ply); - /* otherwise, try to refill buffer */ - if (!BREFILL(ply)) { - ply_error(ply, "Unexpected end of file"); - return 0; - } - } - /* keep looking from where we left */ - end = strchr(end, '\n'); - /* check if the token is too large for our buffer */ - if (!end) { - ply_error(ply, "Token too large"); - return 0; - } - /* we are done */ - ply->buffer_token = ply->buffer_first; - BSKIP(ply, end - BFIRST(ply)); - *BFIRST(ply) = '\0'; - BSKIP(ply, 1); - return ply_check_line(ply); -} - -static int ply_read_chunk(p_ply ply, void *anybuffer, size_t size) { - char *buffer = (char *) anybuffer; - size_t i = 0; - assert(ply && ply->fp && ply->io_mode == PLY_READ); - assert(ply->buffer_first <= ply->buffer_last); - while (i < size) { - if (ply->buffer_first < ply->buffer_last) { - buffer[i] = ply->buffer[ply->buffer_first]; - ply->buffer_first++; - i++; - } else { - ply->buffer_first = 0; - ply->buffer_last = fread(ply->buffer, 1, BUFFERSIZE, ply->fp); - if (ply->buffer_last <= 0) return 0; - } - } - return 1; -} - -static int ply_write_chunk(p_ply ply, void *anybuffer, size_t size) { - char *buffer = (char *) anybuffer; - size_t i = 0; - assert(ply && ply->fp && ply->io_mode == PLY_WRITE); - assert(ply->buffer_last <= BUFFERSIZE); - while (i < size) { - if (ply->buffer_last < BUFFERSIZE) { - ply->buffer[ply->buffer_last] = buffer[i]; - ply->buffer_last++; - i++; - } else { - ply->buffer_last = 0; - if (fwrite(ply->buffer, 1, BUFFERSIZE, ply->fp) < BUFFERSIZE) - return 0; - } - } - return 1; -} - -static int ply_write_chunk_reverse(p_ply ply, void *anybuffer, size_t size) { - int ret = 0; - ply_reverse(anybuffer, size); - ret = ply_write_chunk(ply, anybuffer, size); - ply_reverse(anybuffer, size); - return ret; -} - -static int ply_read_chunk_reverse(p_ply ply, void *anybuffer, size_t size) { - if (!ply_read_chunk(ply, anybuffer, size)) return 0; - ply_reverse(anybuffer, size); - return 1; -} - -static void ply_reverse(void *anydata, size_t size) { - char *data = (char *) anydata; - char temp; - size_t i; - for (i = 0; i < size/2; i++) { - temp = data[i]; - data[i] = data[size-i-1]; - data[size-i-1] = temp; - } -} - -static void ply_init(p_ply ply) { - ply->c = ' '; - ply->element = NULL; - ply->nelements = 0; - ply->comment = NULL; - ply->ncomments = 0; - ply->obj_info = NULL; - ply->nobj_infos = 0; - ply->idriver = NULL; - ply->odriver = NULL; - ply->buffer[0] = '\0'; - ply->buffer_first = ply->buffer_last = ply->buffer_token = 0; - ply->welement = 0; - ply->wproperty = 0; - ply->winstance_index = 0; - ply->wlength = 0; - ply->wvalue_index = 0; -} - -static void ply_element_init(p_ply_element element) { - element->name[0] = '\0'; - element->ninstances = 0; - element->property = NULL; - element->nproperties = 0; -} - -static void ply_property_init(p_ply_property property) { - property->name[0] = '\0'; - property->type = -1; - property->length_type = -1; - property->value_type = -1; - property->read_cb = (p_ply_read_cb) NULL; - property->pdata = NULL; - property->idata = 0; -} - -static p_ply ply_alloc(void) { - p_ply ply = (p_ply) malloc(sizeof(t_ply)); - if (!ply) return NULL; - ply_init(ply); - return ply; -} - -static void *ply_grow_array(p_ply ply, void **pointer, - gint32 *nmemb, gint32 size) { - void *temp = *pointer; - gint32 count = *nmemb + 1; - if (!temp) temp = malloc(count*size); - else temp = realloc(temp, count*size); - if (!temp) { - ply_error(ply, "Out of memory"); - return NULL; - } - *pointer = temp; - *nmemb = count; - return (char *) temp + (count-1) * size; -} - -static p_ply_element ply_grow_element(p_ply ply) { - p_ply_element element = NULL; - assert(ply); - assert(ply->element || ply->nelements == 0); - assert(!ply->element || ply->nelements > 0); - element = (p_ply_element) ply_grow_array(ply, (void **) &ply->element, - &ply->nelements, sizeof(t_ply_element)); - if (!element) return NULL; - ply_element_init(element); - return element; -} - -static p_ply_property ply_grow_property(p_ply ply, p_ply_element element) { - p_ply_property property = NULL; - assert(ply); - assert(element); - assert(element->property || element->nproperties == 0); - assert(!element->property || element->nproperties > 0); - property = (p_ply_property) ply_grow_array(ply, - (void **) &element->property, - &element->nproperties, sizeof(t_ply_property)); - if (!property) return NULL; - ply_property_init(property); - return property; -} - -static int ply_read_header_format(p_ply ply) { - assert(ply && ply->fp && ply->io_mode == PLY_READ); - if (strcmp(BWORD(ply), "format")) return 0; - if (!ply_read_word(ply)) return 0; - ply->storage_mode = ply_find_string(BWORD(ply), ply_storage_mode_list); - if (ply->storage_mode == (e_ply_storage_mode) (-1)) return 0; - if (ply->storage_mode == PLY_ASCII) ply->idriver = &ply_idriver_ascii; - else if (ply->storage_mode == ply_arch_endian()) - ply->idriver = &ply_idriver_binary; - else ply->idriver = &ply_idriver_binary_reverse; - if (!ply_read_word(ply)) return 0; - if (strcmp(BWORD(ply), "1.0")) return 0; - if (!ply_read_word(ply)) return 0; - return 1; -} - -static int ply_read_header_comment(p_ply ply) { - assert(ply && ply->fp && ply->io_mode == PLY_READ); - if (strcmp(BWORD(ply), "comment")) return 0; - if (!ply_read_line(ply)) return 0; - if (!ply_add_comment(ply, BLINE(ply))) return 0; - if (!ply_read_word(ply)) return 0; - return 1; -} - -static int ply_read_header_obj_info(p_ply ply) { - assert(ply && ply->fp && ply->io_mode == PLY_READ); - if (strcmp(BWORD(ply), "obj_info")) return 0; - if (!ply_read_line(ply)) return 0; - if (!ply_add_obj_info(ply, BLINE(ply))) return 0; - if (!ply_read_word(ply)) return 0; - return 1; -} - -static int ply_read_header_property(p_ply ply) { - p_ply_element element = NULL; - p_ply_property property = NULL; - /* make sure it is a property */ - if (strcmp(BWORD(ply), "property")) return 0; - element = &ply->element[ply->nelements-1]; - property = ply_grow_property(ply, element); - if (!property) return 0; - /* get property type */ - if (!ply_read_word(ply)) return 0; - property->type = ply_find_string(BWORD(ply), ply_type_list); - if (property->type == (e_ply_type) (-1)) return 0; - if (property->type == PLY_LIST) { - /* if it's a list, we need the base types */ - if (!ply_read_word(ply)) return 0; - property->length_type = ply_find_string(BWORD(ply), ply_type_list); - if (property->length_type == (e_ply_type) (-1)) return 0; - if (!ply_read_word(ply)) return 0; - property->value_type = ply_find_string(BWORD(ply), ply_type_list); - if (property->value_type == (e_ply_type) (-1)) return 0; - } - /* get property name */ - if (!ply_read_word(ply)) return 0; - strcpy(property->name, BWORD(ply)); - if (!ply_read_word(ply)) return 0; - return 1; -} - -static int ply_read_header_element(p_ply ply) { - p_ply_element element = NULL; - gint32 dummy; - assert(ply && ply->fp && ply->io_mode == PLY_READ); - if (strcmp(BWORD(ply), "element")) return 0; - /* allocate room for new element */ - element = ply_grow_element(ply); - if (!element) return 0; - /* get element name */ - if (!ply_read_word(ply)) return 0; - strcpy(element->name, BWORD(ply)); - /* get number of elements of this type */ - if (!ply_read_word(ply)) return 0; - if (sscanf(BWORD(ply), "%" G_GINT32_FORMAT, &dummy) != 1) { - ply_error(ply, "Expected number got '%s'", BWORD(ply)); - return 0; - } - element->ninstances = dummy; - /* get all properties for this element */ - if (!ply_read_word(ply)) return 0; - while (ply_read_header_property(ply) || - ply_read_header_comment(ply) || ply_read_header_obj_info(ply)) - /* do nothing */; - return 1; -} - -static void ply_error_cb(const char *message, gpointer data) { - fprintf(stderr, "RPly: %s\n", message); -} - -static void ply_error(p_ply ply, const char *fmt, ...) { - char buffer[1024]; - va_list ap; - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); - va_end(ap); - ply->error_cb(buffer, ply->cb_data); -} - -static e_ply_storage_mode ply_arch_endian(void) { - guint32 i = 1; - unsigned char *s = (unsigned char *) &i; - if (*s == 1) return PLY_LITTLE_ENDIAN; - else return PLY_BIG_ENDIAN; -} - -static int ply_type_check(void) { - assert(sizeof(char) == 1); - assert(sizeof(unsigned char) == 1); - assert(sizeof(gint16) == 2); - assert(sizeof(guint16) == 2); - assert(sizeof(gint32) == 4); - assert(sizeof(guint32) == 4); - assert(sizeof(float) == 4); - assert(sizeof(double) == 8); - if (sizeof(char) != 1) return 0; - if (sizeof(unsigned char) != 1) return 0; - if (sizeof(gint16) != 2) return 0; - if (sizeof(guint16) != 2) return 0; - if (sizeof(gint32) != 4) return 0; - if (sizeof(guint32) != 4) return 0; - if (sizeof(float) != 4) return 0; - if (sizeof(double) != 8) return 0; - return 1; -} - -/* ---------------------------------------------------------------------- - * Output handlers - * ---------------------------------------------------------------------- */ -static int oascii_int8(p_ply ply, double value) { - if (value > CHAR_MAX || value < CHAR_MIN) return 0; - return fprintf(ply->fp, "%d ", (char) value) > 0; -} - -static int oascii_uint8(p_ply ply, double value) { - if (value > UCHAR_MAX || value < 0) return 0; - return fprintf(ply->fp, "%d ", (unsigned char) value) > 0; -} - -static int oascii_int16(p_ply ply, double value) { - if (value > G_MAXINT16 || value < G_MININT16) return 0; - return fprintf(ply->fp, "%d ", (gint16) value) > 0; -} - -static int oascii_uint16(p_ply ply, double value) { - if (value > G_MAXUINT16 || value < 0) return 0; - return fprintf(ply->fp, "%d ", (guint16) value) > 0; -} - -static int oascii_int32(p_ply ply, double value) { - if (value > G_MAXINT32 || value < G_MININT32) return 0; - return fprintf(ply->fp, "%d ", (int) value) > 0; -} - -static int oascii_uint32(p_ply ply, double value) { - if (value > G_MAXUINT32 || value < 0) return 0; - return fprintf(ply->fp, "%d ", (unsigned int) value) > 0; -} - -static int oascii_float32(p_ply ply, double value) { - char buf[G_ASCII_DTOSTR_BUF_SIZE]; - if (value < -FLT_MAX || value > FLT_MAX) return 0; - return fprintf(ply->fp, "%s ", - g_ascii_formatd(buf, sizeof (buf), "%g", (float) value)) > 0; -} - -static int oascii_float64(p_ply ply, double value) { - char buf[G_ASCII_DTOSTR_BUF_SIZE]; - if (value < -DBL_MAX || value > DBL_MAX) return 0; - return fprintf(ply->fp, "%s ", - g_ascii_formatd(buf, sizeof (buf), "%g", value)) > 0; -} - -static int obinary_int8(p_ply ply, double value) { - char int8 = (char) value; - if (value > CHAR_MAX || value < CHAR_MIN) return 0; - return ply->odriver->ochunk(ply, &int8, sizeof(int8)); -} - -static int obinary_uint8(p_ply ply, double value) { - unsigned char uint8 = (unsigned char) value; - if (value > UCHAR_MAX || value < 0) return 0; - return ply->odriver->ochunk(ply, &uint8, sizeof(uint8)); -} - -static int obinary_int16(p_ply ply, double value) { - gint16 int16 = (gint16) value; - if (value > G_MAXINT16 || value < G_MININT16) return 0; - return ply->odriver->ochunk(ply, &int16, sizeof(int16)); -} - -static int obinary_uint16(p_ply ply, double value) { - guint16 uint16 = (guint16) value; - if (value > G_MAXUINT16 || value < 0) return 0; - return ply->odriver->ochunk(ply, &uint16, sizeof(uint16)); -} - -static int obinary_int32(p_ply ply, double value) { - gint32 int32 = (gint32) value; - if (value > G_MAXINT32 || value < G_MININT32) return 0; - return ply->odriver->ochunk(ply, &int32, sizeof(int32)); -} - -static int obinary_uint32(p_ply ply, double value) { - guint32 uint32 = (guint32) value; - if (value > G_MAXUINT32 || value < 0) return 0; - return ply->odriver->ochunk(ply, &uint32, sizeof(uint32)); -} - -static int obinary_float32(p_ply ply, double value) { - float float32 = (float) value; - if (value > FLT_MAX || value < -FLT_MAX) return 0; - return ply->odriver->ochunk(ply, &float32, sizeof(float32)); -} - -static int obinary_float64(p_ply ply, double value) { - return ply->odriver->ochunk(ply, &value, sizeof(value)); -} - -/* ---------------------------------------------------------------------- - * Input handlers - * ---------------------------------------------------------------------- */ -static int iascii_int8(p_ply ply, double *value) { - char *end; - if (!ply_read_word(ply)) return 0; - *value = strtol(BWORD(ply), &end, 10); - if (*end || *value > CHAR_MAX || *value < CHAR_MIN) return 0; - return 1; -} - -static int iascii_uint8(p_ply ply, double *value) { - char *end; - if (!ply_read_word(ply)) return 0; - *value = strtol(BWORD(ply), &end, 10); - if (*end || *value > UCHAR_MAX || *value < 0) return 0; - return 1; -} - -static int iascii_int16(p_ply ply, double *value) { - char *end; - if (!ply_read_word(ply)) return 0; - *value = strtol(BWORD(ply), &end, 10); - if (*end || *value > G_MAXINT16 || *value < G_MININT16) return 0; - return 1; -} - -static int iascii_uint16(p_ply ply, double *value) { - char *end; - if (!ply_read_word(ply)) return 0; - *value = strtol(BWORD(ply), &end, 10); - if (*end || *value > G_MAXUINT16 || *value < 0) return 0; - return 1; -} - -static int iascii_int32(p_ply ply, double *value) { - char *end; - if (!ply_read_word(ply)) return 0; - *value = strtol(BWORD(ply), &end, 10); - if (*end || *value > G_MAXINT32 || *value < G_MININT32) return 0; - return 1; -} - -static int iascii_uint32(p_ply ply, double *value) { - char *end; - if (!ply_read_word(ply)) return 0; - *value = strtol(BWORD(ply), &end, 10); - if (*end || *value < 0) return 0; - return 1; -} - -static int iascii_float32(p_ply ply, double *value) { - char *end; - if (!ply_read_word(ply)) return 0; - *value = g_ascii_strtod(BWORD(ply), &end); - if (*end || *value < -FLT_MAX || *value > FLT_MAX) return 0; - return 1; -} - -static int iascii_float64(p_ply ply, double *value) { - char *end; - if (!ply_read_word(ply)) return 0; - *value = g_ascii_strtod(BWORD(ply), &end); - if (*end || *value < -DBL_MAX || *value > DBL_MAX) return 0; - return 1; -} - -static int ibinary_int8(p_ply ply, double *value) { - char int8; - if (!ply->idriver->ichunk(ply, &int8, 1)) return 0; - *value = int8; - return 1; -} - -static int ibinary_uint8(p_ply ply, double *value) { - unsigned char uint8; - if (!ply->idriver->ichunk(ply, &uint8, 1)) return 0; - *value = uint8; - return 1; -} - -static int ibinary_int16(p_ply ply, double *value) { - gint16 int16; - if (!ply->idriver->ichunk(ply, &int16, sizeof(int16))) return 0; - *value = int16; - return 1; -} - -static int ibinary_uint16(p_ply ply, double *value) { - guint16 uint16; - if (!ply->idriver->ichunk(ply, &uint16, sizeof(uint16))) return 0; - *value = uint16; - return 1; -} - -static int ibinary_int32(p_ply ply, double *value) { - gint32 int32; - if (!ply->idriver->ichunk(ply, &int32, sizeof(int32))) return 0; - *value = int32; - return 1; -} - -static int ibinary_uint32(p_ply ply, double *value) { - guint32 uint32; - if (!ply->idriver->ichunk(ply, &uint32, sizeof(uint32))) return 0; - *value = uint32; - return 1; -} - -static int ibinary_float32(p_ply ply, double *value) { - float float32; - if (!ply->idriver->ichunk(ply, &float32, sizeof(float32))) return 0; - *value = float32; - ply_reverse(&float32, sizeof(float32)); - return 1; -} - -static int ibinary_float64(p_ply ply, double *value) { - return ply->idriver->ichunk(ply, value, sizeof(double)); -} - -/* ---------------------------------------------------------------------- - * Constants - * ---------------------------------------------------------------------- */ -static t_ply_idriver ply_idriver_ascii = { - { iascii_int8, iascii_uint8, iascii_int16, iascii_uint16, - iascii_int32, iascii_uint32, iascii_float32, iascii_float64, - iascii_int8, iascii_uint8, iascii_int16, iascii_uint16, - iascii_int32, iascii_uint32, iascii_float32, iascii_float64 - }, /* order matches e_ply_type enum */ - NULL, - "ascii input" -}; - -static t_ply_idriver ply_idriver_binary = { - { ibinary_int8, ibinary_uint8, ibinary_int16, ibinary_uint16, - ibinary_int32, ibinary_uint32, ibinary_float32, ibinary_float64, - ibinary_int8, ibinary_uint8, ibinary_int16, ibinary_uint16, - ibinary_int32, ibinary_uint32, ibinary_float32, ibinary_float64 - }, /* order matches e_ply_type enum */ - ply_read_chunk, - "binary input" -}; - -static t_ply_idriver ply_idriver_binary_reverse = { - { ibinary_int8, ibinary_uint8, ibinary_int16, ibinary_uint16, - ibinary_int32, ibinary_uint32, ibinary_float32, ibinary_float64, - ibinary_int8, ibinary_uint8, ibinary_int16, ibinary_uint16, - ibinary_int32, ibinary_uint32, ibinary_float32, ibinary_float64 - }, /* order matches e_ply_type enum */ - ply_read_chunk_reverse, - "reverse binary input" -}; - -static t_ply_odriver ply_odriver_ascii = { - { oascii_int8, oascii_uint8, oascii_int16, oascii_uint16, - oascii_int32, oascii_uint32, oascii_float32, oascii_float64, - oascii_int8, oascii_uint8, oascii_int16, oascii_uint16, - oascii_int32, oascii_uint32, oascii_float32, oascii_float64 - }, /* order matches e_ply_type enum */ - NULL, - "ascii output" -}; - -static t_ply_odriver ply_odriver_binary = { - { obinary_int8, obinary_uint8, obinary_int16, obinary_uint16, - obinary_int32, obinary_uint32, obinary_float32, obinary_float64, - obinary_int8, obinary_uint8, obinary_int16, obinary_uint16, - obinary_int32, obinary_uint32, obinary_float32, obinary_float64 - }, /* order matches e_ply_type enum */ - ply_write_chunk, - "binary output" -}; - -static t_ply_odriver ply_odriver_binary_reverse = { - { obinary_int8, obinary_uint8, obinary_int16, obinary_uint16, - obinary_int32, obinary_uint32, obinary_float32, obinary_float64, - obinary_int8, obinary_uint8, obinary_int16, obinary_uint16, - obinary_int32, obinary_uint32, obinary_float32, obinary_float64 - }, /* order matches e_ply_type enum */ - ply_write_chunk_reverse, - "reverse binary output" -}; - -/* ---------------------------------------------------------------------- - * Copyright (C) 2003 Diego Nehab. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * ---------------------------------------------------------------------- */ diff --git a/mash/rply/rply.h b/mash/rply/rply.h deleted file mode 100644 index b9e7ab4..0000000 --- a/mash/rply/rply.h +++ b/dev/null @@ -1,367 +0,0 @@ -#ifndef PLY_H -#define PLY_H -/* ---------------------------------------------------------------------- - * RPly library, read/write PLY files - * Diego Nehab, Princeton University - * http://www.cs.princeton.edu/~diego/professional/rply - * - * This library is distributed under the MIT License. See notice - * at the end of this file. - * ---------------------------------------------------------------------- */ - -#include <glib.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define RPLY_VERSION "RPly 1.01" -#define RPLY_COPYRIGHT "Copyright (C) 2003-2005 Diego Nehab" -#define RPLY_AUTHORS "Diego Nehab" - -/* ---------------------------------------------------------------------- - * Types - * ---------------------------------------------------------------------- */ -/* structures are opaque */ -typedef struct t_ply_ *p_ply; -typedef struct t_ply_element_ *p_ply_element; -typedef struct t_ply_property_ *p_ply_property; -typedef struct t_ply_argument_ *p_ply_argument; - -/* ply format mode type */ -typedef enum e_ply_storage_mode_ { - PLY_BIG_ENDIAN, - PLY_LITTLE_ENDIAN, - PLY_ASCII, - PLY_DEFAULT /* has to be the last in enum */ -} e_ply_storage_mode; /* order matches ply_storage_mode_list */ - -/* ply data type */ -typedef enum e_ply_type { - PLY_INT8, PLY_UINT8, PLY_INT16, PLY_UINT16, - PLY_INT32, PLY_UIN32, PLY_FLOAT32, PLY_FLOAT64, - PLY_CHAR, PLY_UCHAR, PLY_SHORT, PLY_USHORT, - PLY_INT, PLY_UINT, PLY_FLOAT, PLY_DOUBLE, - PLY_LIST /* has to be the last in enum */ -} e_ply_type; /* order matches ply_type_list */ - -/* ---------------------------------------------------------------------- - * Property reading callback prototype - * - * message: error message - * ---------------------------------------------------------------------- */ -typedef void (*p_ply_error_cb)(const char *message, gpointer data); - -/* ---------------------------------------------------------------------- - * Opens a ply file for reading (fails if file is not a ply file) - * - * error_cb: error callback function - * name: file name - * - * Returns 1 if successful, 0 otherwise - * ---------------------------------------------------------------------- */ -p_ply ply_open(const char *name, p_ply_error_cb error_cb, gpointer cb_data); - -/* ---------------------------------------------------------------------- - * Reads and parses the header of a ply file returned by ply_open - * - * ply: handle returned by ply_open - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_read_header(p_ply ply); - -/* ---------------------------------------------------------------------- - * Property reading callback prototype - * - * argument: parameters for property being processed when callback is called - * - * Returns 1 if should continue processing file, 0 if should abort. - * ---------------------------------------------------------------------- */ -typedef int (*p_ply_read_cb)(p_ply_argument argument); - -/* ---------------------------------------------------------------------- - * Sets up callbacks for property reading after header was parsed - * - * ply: handle returned by ply_open - * element_name: element where property is - * property_name: property to associate element with - * read_cb: function to be called for each property value - * pdata/idata: user data that will be passed to callback - * - * Returns 0 if no element or no property in element, returns the - * number of element instances otherwise. - * ---------------------------------------------------------------------- */ -long ply_set_read_cb(p_ply ply, const char *element_name, - const char *property_name, p_ply_read_cb read_cb, - void *pdata, long idata); - -/* ---------------------------------------------------------------------- - * Returns information about the element originating a callback - * - * argument: handle to argument - * element: receives a the element handle (if non-null) - * instance_index: receives the index of the current element instance - * (if non-null) - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_get_argument_element(p_ply_argument argument, - p_ply_element *element, gint32 *instance_index); - -/* ---------------------------------------------------------------------- - * Returns information about the property originating a callback - * - * argument: handle to argument - * property: receives the property handle (if non-null) - * length: receives the number of values in this property (if non-null) - * value_index: receives the index of current property value (if non-null) - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_get_argument_property(p_ply_argument argument, - p_ply_property *property, gint32 *length, gint32 *value_index); - -/* ---------------------------------------------------------------------- - * Returns user data associated with callback - * - * pdata: receives a copy of user custom data pointer (if non-null) - * idata: receives a copy of user custom data integer (if non-null) - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_get_argument_user_data(p_ply_argument argument, void **pdata, - long *idata); - -/* ---------------------------------------------------------------------- - * Returns the value associated with a callback - * - * argument: handle to argument - * - * Returns the current data item - * ---------------------------------------------------------------------- */ -double ply_get_argument_value(p_ply_argument argument); - -/* ---------------------------------------------------------------------- - * Reads all elements and properties calling the callbacks defined with - * calls to ply_set_read_cb - * - * ply: handle returned by ply_open - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_read(p_ply ply); - -/* ---------------------------------------------------------------------- - * Iterates over all elements by returning the next element. - * Call with NULL to return handle to first element. - * - * ply: handle returned by ply_open - * last: handle of last element returned (NULL for first element) - * - * Returns element if successfull or NULL if no more elements - * ---------------------------------------------------------------------- */ -p_ply_element ply_get_next_element(p_ply ply, p_ply_element last); - -/* ---------------------------------------------------------------------- - * Iterates over all comments by returning the next comment. - * Call with NULL to return pointer to first comment. - * - * ply: handle returned by ply_open - * last: pointer to last comment returned (NULL for first comment) - * - * Returns comment if successfull or NULL if no more comments - * ---------------------------------------------------------------------- */ -const char *ply_get_next_comment(p_ply ply, const char *last); - -/* ---------------------------------------------------------------------- - * Iterates over all obj_infos by returning the next obj_info. - * Call with NULL to return pointer to first obj_info. - * - * ply: handle returned by ply_open - * last: pointer to last obj_info returned (NULL for first obj_info) - * - * Returns obj_info if successfull or NULL if no more obj_infos - * ---------------------------------------------------------------------- */ -const char *ply_get_next_obj_info(p_ply ply, const char *last); - -/* ---------------------------------------------------------------------- - * Returns information about an element - * - * element: element of interest - * name: receives a pointer to internal copy of element name (if non-null) - * ninstances: receives the number of instances of this element (if non-null) - * - * Returns 1 if successfull or 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_get_element_info(p_ply_element element, const char** name, - gint32 *ninstances); - -/* ---------------------------------------------------------------------- - * Iterates over all properties by returning the next property. - * Call with NULL to return handle to first property. - * - * element: handle of element with the properties of interest - * last: handle of last property returned (NULL for first property) - * - * Returns element if successfull or NULL if no more properties - * ---------------------------------------------------------------------- */ -p_ply_property ply_get_next_property(p_ply_element element, - p_ply_property last); - -/* ---------------------------------------------------------------------- - * Returns information about a property - * - * property: handle to property of interest - * name: receives a pointer to internal copy of property name (if non-null) - * type: receives the property type (if non-null) - * length_type: for list properties, receives the scalar type of - * the length field (if non-null) - * value_type: for list properties, receives the scalar type of the value - * fields (if non-null) - * - * Returns 1 if successfull or 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_get_property_info(p_ply_property property, const char** name, - e_ply_type *type, e_ply_type *length_type, e_ply_type *value_type); - -/* ---------------------------------------------------------------------- - * Creates new ply file - * - * name: file name - * storage_mode: file format mode - * - * Returns handle to ply file if successfull, NULL otherwise - * ---------------------------------------------------------------------- */ -p_ply ply_create(const char *name, e_ply_storage_mode storage_mode, - p_ply_error_cb error_cb, gpointer cb_data); - -/* ---------------------------------------------------------------------- - * Adds a new element to the ply file created by ply_create - * - * ply: handle returned by ply_create - * name: name of new element - * ninstances: number of element of this time in file - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_add_element(p_ply ply, const char *name, gint32 ninstances); - -/* ---------------------------------------------------------------------- - * Adds a new property to the last element added by ply_add_element - * - * ply: handle returned by ply_create - * name: name of new property - * type: property type - * length_type: scalar type of length field of a list property - * value_type: scalar type of value fields of a list property - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_add_property(p_ply ply, const char *name, e_ply_type type, - e_ply_type length_type, e_ply_type value_type); - -/* ---------------------------------------------------------------------- - * Adds a new list property to the last element added by ply_add_element - * - * ply: handle returned by ply_create - * name: name of new property - * length_type: scalar type of length field of a list property - * value_type: scalar type of value fields of a list property - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_add_list_property(p_ply ply, const char *name, - e_ply_type length_type, e_ply_type value_type); - -/* ---------------------------------------------------------------------- - * Adds a new property to the last element added by ply_add_element - * - * ply: handle returned by ply_create - * name: name of new property - * type: property type - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_add_scalar_property(p_ply ply, const char *name, e_ply_type type); - -/* ---------------------------------------------------------------------- - * Adds a new comment item - * - * ply: handle returned by ply_create - * comment: pointer to string with comment text - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_add_comment(p_ply ply, const char *comment); - -/* ---------------------------------------------------------------------- - * Adds a new obj_info item - * - * ply: handle returned by ply_create - * comment: pointer to string with obj_info data - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_add_obj_info(p_ply ply, const char *obj_info); - -/* ---------------------------------------------------------------------- - * Writes the ply file header after all element and properties have been - * defined by calls to ply_add_element and ply_add_property - * - * ply: handle returned by ply_create - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_write_header(p_ply ply); - -/* ---------------------------------------------------------------------- - * Writes one property value, in the order they should be written to the - * file. For each element type, write all elements of that type in order. - * For each element, write all its properties in order. For scalar - * properties, just write the value. For list properties, write the length - * and then each of the values. - * - * ply: handle returned by ply_create - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_write(p_ply ply, double value); - -/* ---------------------------------------------------------------------- - * Closes a ply file handle. Releases all memory used by handle - * - * ply: handle to be closed. - * - * Returns 1 if successfull, 0 otherwise - * ---------------------------------------------------------------------- */ -int ply_close(p_ply ply); - -#ifdef __cplusplus -} -#endif - -#endif /* RPLY_H */ - -/* ---------------------------------------------------------------------- - * Copyright (C) 2003-2005 Diego Nehab. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * ---------------------------------------------------------------------- */ |
