From 078cdbed49ca475c04b89aa0767ad31bf1e7b44c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 26 Jul 2002 15:37:23 +0000 Subject: [PATCH] Added Ruben Lopez's Inventor/VRML 1.0 loader. --- AUTHORS | 3 +- Make/makedirdefs | 1 + src/osgDB/Registry.cpp | 1 + src/osgPlugins/iv/COPYING | 481 ++++++ src/osgPlugins/iv/Makefile | 20 + src/osgPlugins/iv/Makefile.orig | 16 + src/osgPlugins/iv/README | 21 + src/osgPlugins/iv/atrfloat.h | 35 + src/osgPlugins/iv/atrstring.h | 36 + src/osgPlugins/iv/atrvec.h | 56 + src/osgPlugins/iv/attribute.h | 46 + src/osgPlugins/iv/coordinate3.h | 39 + src/osgPlugins/iv/geometry.h | 32 + src/osgPlugins/iv/indexedfaceset.h | 52 + src/osgPlugins/iv/ltstr.h | 38 + src/osgPlugins/iv/main.cpp | 53 + src/osgPlugins/iv/main.h | 22 + src/osgPlugins/iv/material.h | 33 + src/osgPlugins/iv/matrixtransform.h | 36 + src/osgPlugins/iv/mynode.h | 88 ++ src/osgPlugins/iv/mynodevisitor.h | 59 + src/osgPlugins/iv/nodecache.cpp | 22 + src/osgPlugins/iv/nodecache.h | 44 + src/osgPlugins/iv/normals.cpp | 107 ++ src/osgPlugins/iv/normals.h | 27 + src/osgPlugins/iv/osgvisitor.cpp | 299 ++++ src/osgPlugins/iv/osgvisitor.h | 53 + src/osgPlugins/iv/parser.cpp | 1218 ++++++++++++++ src/osgPlugins/iv/parser.cpp.h | 40 + src/osgPlugins/iv/parser.hpp | 49 + src/osgPlugins/iv/parser.y | 159 ++ src/osgPlugins/iv/readerwriter.cpp | 32 + src/osgPlugins/iv/readerwriter.h | 40 + src/osgPlugins/iv/scanner.cpp | 2094 +++++++++++++++++++++++++ src/osgPlugins/iv/scanner.l | 85 + src/osgPlugins/iv/separator.h | 33 + src/osgPlugins/iv/texture2.h | 33 + src/osgPlugins/iv/texturecoordinate.h | 37 + src/osgPlugins/iv/transform.h | 33 + 39 files changed, 5572 insertions(+), 1 deletion(-) create mode 100644 src/osgPlugins/iv/COPYING create mode 100644 src/osgPlugins/iv/Makefile create mode 100644 src/osgPlugins/iv/Makefile.orig create mode 100644 src/osgPlugins/iv/README create mode 100644 src/osgPlugins/iv/atrfloat.h create mode 100644 src/osgPlugins/iv/atrstring.h create mode 100644 src/osgPlugins/iv/atrvec.h create mode 100644 src/osgPlugins/iv/attribute.h create mode 100644 src/osgPlugins/iv/coordinate3.h create mode 100644 src/osgPlugins/iv/geometry.h create mode 100644 src/osgPlugins/iv/indexedfaceset.h create mode 100644 src/osgPlugins/iv/ltstr.h create mode 100644 src/osgPlugins/iv/main.cpp create mode 100644 src/osgPlugins/iv/main.h create mode 100644 src/osgPlugins/iv/material.h create mode 100644 src/osgPlugins/iv/matrixtransform.h create mode 100644 src/osgPlugins/iv/mynode.h create mode 100644 src/osgPlugins/iv/mynodevisitor.h create mode 100644 src/osgPlugins/iv/nodecache.cpp create mode 100644 src/osgPlugins/iv/nodecache.h create mode 100644 src/osgPlugins/iv/normals.cpp create mode 100644 src/osgPlugins/iv/normals.h create mode 100644 src/osgPlugins/iv/osgvisitor.cpp create mode 100644 src/osgPlugins/iv/osgvisitor.h create mode 100644 src/osgPlugins/iv/parser.cpp create mode 100644 src/osgPlugins/iv/parser.cpp.h create mode 100644 src/osgPlugins/iv/parser.hpp create mode 100644 src/osgPlugins/iv/parser.y create mode 100644 src/osgPlugins/iv/readerwriter.cpp create mode 100644 src/osgPlugins/iv/readerwriter.h create mode 100644 src/osgPlugins/iv/scanner.cpp create mode 100644 src/osgPlugins/iv/scanner.l create mode 100644 src/osgPlugins/iv/separator.h create mode 100644 src/osgPlugins/iv/texture2.h create mode 100644 src/osgPlugins/iv/texturecoordinate.h create mode 100644 src/osgPlugins/iv/transform.h diff --git a/AUTHORS b/AUTHORS index 6c52a127d..7b80d3db2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -114,7 +114,8 @@ Kristopher Bixler Tino Schwarze -port to HP-UX. - +Ruben Lopez + - Inventor ascii/VRML 1.0 loader. Indirect Contributors --------------------- diff --git a/Make/makedirdefs b/Make/makedirdefs index 2802ab9ee..415671036 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -26,6 +26,7 @@ PLUGIN_DIRS = \ rgb\ lib3ds\ flt\ + iv\ obj\ lwo\ txp\ diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 562ef7c54..5b7b152c9 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -73,6 +73,7 @@ Registry::Registry() addFileExtensionAlias("geo", "lwo"); addFileExtensionAlias("lw", "lwo"); + addFileExtensionAlias("wrl", "iv"); } diff --git a/src/osgPlugins/iv/COPYING b/src/osgPlugins/iv/COPYING new file mode 100644 index 000000000..92b8903ff --- /dev/null +++ b/src/osgPlugins/iv/COPYING @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + 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 Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the 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 a program 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. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + 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, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +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 compile 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) 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. + + c) 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. + + d) 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 source code 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 to +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 Library 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. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/src/osgPlugins/iv/Makefile b/src/osgPlugins/iv/Makefile new file mode 100644 index 000000000..eaa17cb44 --- /dev/null +++ b/src/osgPlugins/iv/Makefile @@ -0,0 +1,20 @@ +TOPDIR = ../../.. +include $(TOPDIR)/Make/makedefs + +CXXFILES =\ + main.cpp\ + nodecache.cpp\ + normals.cpp\ + osgvisitor.cpp\ + readerwriter.cpp\ + scanner.cpp\ + parser.cpp\ + +LIBS += $(OSG_LIBS) $(OTHER_LIBS) + +TARGET_BASENAME = iv + +include $(TOPDIR)/Make/cygwin_plugin_def +PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT) + +include $(TOPDIR)/Make/makerules diff --git a/src/osgPlugins/iv/Makefile.orig b/src/osgPlugins/iv/Makefile.orig new file mode 100644 index 000000000..981f0a5d9 --- /dev/null +++ b/src/osgPlugins/iv/Makefile.orig @@ -0,0 +1,16 @@ + +CXXFLAGS=-g -Wall +OBJS=scanner.o parser.o main.o nodecache.o osgvisitor.o normals.o readerwriter.o +TARGET=osgdb_iv.so + +$(TARGET): $(OBJS) + $(CXX) -shared $(OBJS) -o osgdb_wrl.so + +scanner.cpp: scanner.l parser.cpp + flex -oscanner.cpp scanner.l + +parser.cpp: parser.y + bison --debug -d -o parser.cpp parser.y + +clean: + rm -f *.o main $(TARGET) $(OBJS) scanner.cpp parser.cpp *~ diff --git a/src/osgPlugins/iv/README b/src/osgPlugins/iv/README new file mode 100644 index 000000000..61b14cab3 --- /dev/null +++ b/src/osgPlugins/iv/README @@ -0,0 +1,21 @@ +This shared library can load both VRML1.0 and Inventor (they are practically +the same, only changes the header). + +Features: + +* Polygonal geometry (IndexedFaceSet) +* Materials +* Transformations +* External Textures (no inline ones) +* Doesn't crash when unknown nodes or attributes are found, only ignores +them. + +To-Do: + +* Use the new Geometry node of osg 0.9.0 that has support of vertex arrays +* Use the front face attribute (clockwise/counterclockwise) +* Implement more nodes. Maybe the cone, sphere, etc could be implemented + with a fixed number of polygons, always the same, or maybe as a LOD node, + that uses more or less polys depending on the distance to the camera. + +Ruben lopez diff --git a/src/osgPlugins/iv/atrfloat.h b/src/osgPlugins/iv/atrfloat.h new file mode 100644 index 000000000..e767d5933 --- /dev/null +++ b/src/osgPlugins/iv/atrfloat.h @@ -0,0 +1,35 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ATR_FLOAT_H__ +#define __ATR_FLOAT_H__ + +#include "attribute.h" + +class AtrFloat: public Attribute { + float value; +public: + AtrFloat(char *name, float val):Attribute(name) { value=val; } + virtual char *type() { return "AtrFloat"; } + float getValue() { return value; } + /** clone the an object of the same type as the node.*/ + virtual Object* cloneType() const { return new AtrFloat(name,value); } +}; + +#endif diff --git a/src/osgPlugins/iv/atrstring.h b/src/osgPlugins/iv/atrstring.h new file mode 100644 index 000000000..ca4c2d4af --- /dev/null +++ b/src/osgPlugins/iv/atrstring.h @@ -0,0 +1,36 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ATR_STRING_H__ +#define __ATR_STRING_H__ + +#include "attribute.h" + +class AtrString: public Attribute { + char *value; +public: + AtrString(char *name, char *value):Attribute(name) { this->value=strdup(value); } + ~AtrString() { free (value); } + virtual char *type() { return "AtrString"; } + char *getValue() { return value; } + /** clone the an object of the same type as the node.*/ + virtual Object* cloneType() const { return new AtrString(name,value); } +}; + +#endif diff --git a/src/osgPlugins/iv/atrvec.h b/src/osgPlugins/iv/atrvec.h new file mode 100644 index 000000000..40f7bc3fa --- /dev/null +++ b/src/osgPlugins/iv/atrvec.h @@ -0,0 +1,56 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ATR_VEC_H__ +#define __ATR_VEC_H__ + +#include "attribute.h" + +class AtrVec: public Attribute { + std::vector values; +public: + AtrVec(char *name):Attribute(name) { } + AtrVec(char *name, float x, float y):Attribute(name) { + values.push_back(x); + values.push_back(y); + } + AtrVec(char *name, float x, float y, float z):Attribute(name) { + values.push_back(x); + values.push_back(y); + values.push_back(z); + } + AtrVec(char *name, float x, float y, float z, float k):Attribute(name) { + values.push_back(x); + values.push_back(y); + values.push_back(z); + values.push_back(k); + } + void addVal(float val) { values.push_back(val); } + float getVal(int pos) { return values[pos]; } + float getValABS(int pos) { return values[pos]>0?values[pos]:-values[pos]; } + float getValCut(int pos) { return values[pos]>0?values[pos]:0.0f; } + int getSize() { return values.size(); } + virtual char *type() { return "AtrVec"; } + + /** clone the an object of the same type as the node.*/ + virtual Object* cloneType() const { return new AtrVec(name); } +}; + + +#endif diff --git a/src/osgPlugins/iv/attribute.h b/src/osgPlugins/iv/attribute.h new file mode 100644 index 000000000..7c90bd523 --- /dev/null +++ b/src/osgPlugins/iv/attribute.h @@ -0,0 +1,46 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ATTRIBUTE_H__ +#define __ATTRIBUTE_H__ + +#include + +class SG_EXPORT Attribute: public osg::Object { +public: + char *name; + virtual char *type()=0; + char *getName() { return name; } + + // OSG Object API + + /** clone the an object of the same type as the node.*/ + virtual Object* cloneType() const =0; + /** return a clone of a node, with Object* return type.*/ + virtual Object* clone(const osg::CopyOp& copyop) const { return cloneType(); } + /** return the name of the node's library.*/ + virtual const char* libraryName() const { return "osgdb_wrl"; } + /** return the name of the node's class type.*/ + virtual const char* className() const { return "Attribute"; } +protected: + Attribute(char *name) {this->name=strdup(name); } + ~Attribute() {free(name); } +}; + +#endif diff --git a/src/osgPlugins/iv/coordinate3.h b/src/osgPlugins/iv/coordinate3.h new file mode 100644 index 000000000..8505f3a7a --- /dev/null +++ b/src/osgPlugins/iv/coordinate3.h @@ -0,0 +1,39 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __COORDINATE3_H__ +#define __COORDINATE3_H__ + +#include "geometry.h" +#include "mynode.h" + +class Coordinate3: public MyNode { + VertexList vertices; +public: + Coordinate3(VertexList *vertices) { + this->vertices=*vertices; + } + virtual char *type() { return "Coordinate3"; } + virtual void accept(MyNodeVisitor *v) { v->applyCoordinate3(this); } + VertexList getVertices() { return vertices; } + +}; + + +#endif diff --git a/src/osgPlugins/iv/geometry.h b/src/osgPlugins/iv/geometry.h new file mode 100644 index 000000000..9c9147b7e --- /dev/null +++ b/src/osgPlugins/iv/geometry.h @@ -0,0 +1,32 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __GEOMETRY_H__ +#define __GEOMETRY_H__ + +#include +#include + +typedef std::vector VertexList; +typedef std::vector VertexIndexList; +typedef std::pair TextureCoordVal; +typedef std::vector TextureCoordList; +typedef std::vector PolygonList; +typedef float Matrix[16]; +#endif diff --git a/src/osgPlugins/iv/indexedfaceset.h b/src/osgPlugins/iv/indexedfaceset.h new file mode 100644 index 000000000..454e64f29 --- /dev/null +++ b/src/osgPlugins/iv/indexedfaceset.h @@ -0,0 +1,52 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __INDEXED_FACE_SET_H__ +#define __INDEXED_FACE_SET_H__ + +#include "mynode.h" + +class IndexedFaceSet: public MyNode { + PolygonList polys; + PolygonList textureIndices; // Indexed texture set. + bool _hasTextureIndices; +public: + IndexedFaceSet() {} + + IndexedFaceSet(PolygonList *p) { + polys=*p; + _hasTextureIndices=false; + } + + IndexedFaceSet(PolygonList *p, PolygonList *t) { + polys=*p; + textureIndices=*t; + _hasTextureIndices=true; + } + + bool hasTextureIndices() { return _hasTextureIndices; } + PolygonList getPolygons() { return polys; } + PolygonList getTextureIndices() { return textureIndices; } + virtual char *type() { return "IndexedFaceSet"; } + virtual void accept(MyNodeVisitor *v) { v->applyIndexedFaceSet(this); } + +}; + + +#endif diff --git a/src/osgPlugins/iv/ltstr.h b/src/osgPlugins/iv/ltstr.h new file mode 100644 index 000000000..eb9308a8d --- /dev/null +++ b/src/osgPlugins/iv/ltstr.h @@ -0,0 +1,38 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LTSTR_H__ +#define __LTSTR_H__ + +#include + +/** @class ltstr + * + * @brief clase/estructura que implementa un algoritmo de comparacion + * de dos cadenas para mapas cuyo indice es una cadena. + */ +struct ltstr +{ + bool operator()(const char* s1, const char* s2) const + { + return strcmp(s1, s2) < 0; + } +}; + +#endif diff --git a/src/osgPlugins/iv/main.cpp b/src/osgPlugins/iv/main.cpp new file mode 100644 index 000000000..40a55b66c --- /dev/null +++ b/src/osgPlugins/iv/main.cpp @@ -0,0 +1,53 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef WIN32 +# pragma warning (disable:4786) +# pragma warning (disable:4541) +#endif +#include +#include +#include "mynode.h" +#include "osgvisitor.h" + +#include +#include + +extern int yyparse(); +extern int yydebug; +extern MyNode *getRoot(); +extern FILE *yyin; + +int isatty(int t) { return 0; } + +osg::Node *readVRMLNode(const char *file) { + yydebug=0; + yyin=fopen(file,"r"); + std::cout << "Parsing..." << std::endl; + yyparse(); + osg::ref_ptr n=getRoot(); + try { + std::cout << "Generating OSG tree..." << std::endl; + osg::ref_ptr visitante=new OSGVisitor(n.get()); + return visitante->getRoot(); + } catch (...) { + std::cerr << "VRML: error reading" << std::endl; + return 0; + } +} diff --git a/src/osgPlugins/iv/main.h b/src/osgPlugins/iv/main.h new file mode 100644 index 000000000..bede0c6cd --- /dev/null +++ b/src/osgPlugins/iv/main.h @@ -0,0 +1,22 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +osg::Node *readVRMLNode(const char *file); diff --git a/src/osgPlugins/iv/material.h b/src/osgPlugins/iv/material.h new file mode 100644 index 000000000..6913c0454 --- /dev/null +++ b/src/osgPlugins/iv/material.h @@ -0,0 +1,33 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MATERIAL_H__ +#define __MATERIAL_H__ + +#include "mynode.h" + +class Material: public MyNode { +public: + Material() {} + Material(MyNode *n): MyNode(n) {} + virtual char *type() { return "Material"; } + virtual void accept(MyNodeVisitor *v) { v->applyMaterial(this); } +}; + +#endif diff --git a/src/osgPlugins/iv/matrixtransform.h b/src/osgPlugins/iv/matrixtransform.h new file mode 100644 index 000000000..429a65062 --- /dev/null +++ b/src/osgPlugins/iv/matrixtransform.h @@ -0,0 +1,36 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MATRIX_TRANSFORM_H__ +#define __MATRIX_TRANSFORM_H__ + +#include "mynode.h" +#include "geometry.h" + +class MatrixTransform: public MyNode { + Matrix m; +public: + MatrixTransform(Matrix m) {memcpy(this->m,m,sizeof(float)*16);} + float getElem(int i) { return m[i]; } + virtual char *type() { return "MatrixTransform"; } + virtual void accept(MyNodeVisitor *v) { v->applyMatrixTransform(this); } + +}; + +#endif diff --git a/src/osgPlugins/iv/mynode.h b/src/osgPlugins/iv/mynode.h new file mode 100644 index 000000000..bd59442d8 --- /dev/null +++ b/src/osgPlugins/iv/mynode.h @@ -0,0 +1,88 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __NODE_H__ +#define __NODE_H__ + +#include +#include +#include +#include "attribute.h" +#include "mynodevisitor.h" +#include "ltstr.h" + +#ifdef WIN32 +# pragma warning (disable:4786) +#endif + +class MyNode : public osg::Object { +public: + typedef std::vector< osg::ref_ptr > MyNodeList; + typedef std::map< const char*, osg::ref_ptr, ltstr > AttributeMap; +protected: + MyNodeList children; + AttributeMap attributes; + bool two_sided; +public: + MyNode() {two_sided=false;} + MyNode(const MyNode *other) { children=other->children; attributes=other->attributes; two_sided=false; } + virtual char *type() { return "MyNode"; } ///< Returns generic type + void addAttribute(char *name, Attribute *atr) { attributes[name]=atr; } + void addChild(MyNode *node) { children.push_back(node); } + MyNodeList getChildren() { return children; } + AttributeMap getAttributes() { return attributes; } + Attribute *getAttribute(char *name) { + if (attributes.find(name) != attributes.end()) { + return attributes[name].get(); + } else { + return 0; + } + } + void setChildren(MyNodeList children) { this->children=children; } + void setAttributes(AttributeMap attributes) { this->attributes=attributes; } + + void print(int indent) { + for (int i=0;i node = *iter; + node->print(indent+4); + } + } + void setTwoSided() { two_sided=true; } + bool getTwoSided() { return two_sided; } + virtual void accept(MyNodeVisitor *v) { v->applyMyNode(this); } + + // OSG Object API + + /** clone the an object of the same type as the node.*/ + virtual Object* cloneType() const { return new MyNode(); } + /** return a clone of a node, with Object* return type.*/ + virtual Object* clone(const osg::CopyOp& copyop) const { return new MyNode(this); } + /** return the name of the node's library.*/ + virtual const char* libraryName() const { return "osgdb_wrl"; } + /** return the name of the node's class type.*/ + virtual const char* className() const { return "MyNode"; } + + + +}; + +#endif diff --git a/src/osgPlugins/iv/mynodevisitor.h b/src/osgPlugins/iv/mynodevisitor.h new file mode 100644 index 000000000..eb1bb75ab --- /dev/null +++ b/src/osgPlugins/iv/mynodevisitor.h @@ -0,0 +1,59 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MY_NODE_VISITOR_H__ +#define __MY_NODE_VISITOR_H__ + +class MyNode; +class Material; +class Coordinate3; +class MatrixTransform; +class Separator; +class IndexedFaceSet; +class TextureCoordinate; +class Texture2; +class Transform; + +#include + +class MyNodeVisitor: public osg::Object { +public: + virtual void applyMyNode(MyNode *node)=0; + virtual void applyMaterial(Material *material)=0; + virtual void applyCoordinate3(Coordinate3 *coord)=0; + virtual void applyMatrixTransform(MatrixTransform *tr)=0; + virtual void applySeparator(Separator *sep)=0; + virtual void applyIndexedFaceSet(IndexedFaceSet *ifs)=0; + virtual void applyTextureCoordinate(TextureCoordinate *texc)=0; + virtual void applyTexture2(Texture2 *tex)=0; + virtual void applyTransform(Transform *trans)=0; + + /** clone the an object of the same type as the node.*/ + virtual Object* cloneType() const = 0; + /** return a clone of a node, with Object* return type.*/ + virtual Object* clone(const osg::CopyOp& copyop) const { return cloneType(); } + /** return the name of the node's library.*/ + virtual const char* libraryName() const { return "osgdb_wrl"; } + /** return the name of the node's class type.*/ + virtual const char* className() const { return "MyNodeVisitor"; } +}; + + +#endif + diff --git a/src/osgPlugins/iv/nodecache.cpp b/src/osgPlugins/iv/nodecache.cpp new file mode 100644 index 000000000..52013609b --- /dev/null +++ b/src/osgPlugins/iv/nodecache.cpp @@ -0,0 +1,22 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "nodecache.h" + +NodeCache::NodeMap NodeCache::nodes; diff --git a/src/osgPlugins/iv/nodecache.h b/src/osgPlugins/iv/nodecache.h new file mode 100644 index 000000000..7148e9858 --- /dev/null +++ b/src/osgPlugins/iv/nodecache.h @@ -0,0 +1,44 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __CACHE_NODOS_H__ +#define __CACHE_NODOS_H__ + +#include +#include "mynode.h" +#include "ltstr.h" + +class NodeCache { + typedef std::map, ltstr > NodeMap; + static NodeMap nodes; +public: + static void addNode(char *name, MyNode *node) { + nodes[name]=node; + } + static MyNode* getNode(char *name) { + if (nodes.find(name) != nodes.end()) { + return nodes[name].get(); + } else { + std::cerr << "Node does not exist" << std::endl; + return new MyNode(); + } + } +}; + +#endif diff --git a/src/osgPlugins/iv/normals.cpp b/src/osgPlugins/iv/normals.cpp new file mode 100644 index 000000000..d0a43c892 --- /dev/null +++ b/src/osgPlugins/iv/normals.cpp @@ -0,0 +1,107 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "normals.h" +#include + +#define CREASE_ANGLE 3.14159265356 * 45 / 180 + +float difAng(osg::Vec3 a, osg::Vec3 b) { + float div = a.length() * b.length(); + return (div != 0.0f ? acosf( (a*b) / div) : 0.0f ); +} + +osg::Vec3 calcNormal(osg::Vec3 &a, osg::Vec3 &b, osg::Vec3 &c) { + osg::Vec3 norm; + osg::Vec3 v1; + osg::Vec3 v2; + v1=b-c; + v2=a-b; + norm=v1 ^ v2; // cross product + norm.normalize(); + return norm; +} + +void get3v(VertexList &vertices, VertexIndexList &vindex, int &a, int &b, int &c) { + unsigned tam=vindex.size(); + unsigned i; + b=0;c=0; + a=vindex[0]; + for (i=1;i 2) { + int v0,v1,v2; + get3v(vertices,vindex,v0,v1,v2); + if (v0 == v1 || v0 == v2) { + std::cerr << "ERROR: Vertices alineados: nv=" << vindex.size() << std::endl; + } + normales_polys[poly] = calcNormal(vertices[v0], + vertices[v1], + vertices[v2]); + if (normales_polys[poly] == osg::Vec3(0,0,0) && vindex.size() > 2) { + std::cerr << "##***" << "Normal nula VERTICES=" << vindex.size() << " " << vertices[v0] << " " << vertices[v1] << " " << vertices[v2] << std::endl; + } + } + } + /* Phase 2: Selective smooth depending on crease angle */ + for (poly=0;poly + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include "geometry.h" + +osg::Vec3 calcNormal(osg::Vec3 &a, osg::Vec3 &b, osg::Vec3 &c); + +osg::Vec3 *calcNormals(VertexList &vertices, + PolygonList &polygons, + unsigned nvert_total); diff --git a/src/osgPlugins/iv/osgvisitor.cpp b/src/osgPlugins/iv/osgvisitor.cpp new file mode 100644 index 000000000..eee3073fa --- /dev/null +++ b/src/osgPlugins/iv/osgvisitor.cpp @@ -0,0 +1,299 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef WIN32 +# pragma warning (disable:4786) +# pragma warning (disable:4541) +#endif +#include +#include "osgvisitor.h" +#include "material.h" +#include "coordinate3.h" +#include "separator.h" +#include "matrixtransform.h" +#include "indexedfaceset.h" +#include "texturecoordinate.h" +#include "texture2.h" +#include "transform.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include ///< Para calcular normals +#include ///< Para convertir a tristrip + + +#include "atrvec.h" +#include "atrfloat.h" +#include "atrstring.h" + +#include "ltstr.h" +#include "normals.h" + +#define CREASE_ANGLE 2//3.14159265359 * 2.0 / 3.0 + +class CacheObjetos { + typedef std::map, osg::ref_ptr > MaterialMap; + typedef std::map, ltstr> TextureMap; + typedef std::map, osg::ref_ptr > NodeMap; + + static MaterialMap materiales; + static TextureMap textures; + static NodeMap nodos; +public: + static osg::Node* getMyNode(MyNode* _node) { + return 0; + } + + static osg::Material* getMaterial(Material* _material) { + if (materiales.find(_material) == materiales.end()) { + AtrVec *ambient=(AtrVec*)_material->getAttribute("ambientColor"); + AtrVec *diffuse=(AtrVec*)_material->getAttribute("diffuseColor"); + AtrVec *specular=(AtrVec*)_material->getAttribute("specularColor"); + AtrFloat *shininess=(AtrFloat*)_material->getAttribute("shininess"); + AtrFloat *transparency=(AtrFloat*)_material->getAttribute("transparency"); + osg::Material *material=new osg::Material(); + if (ambient) material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(ambient->getValCut(0),ambient->getValCut(1),ambient->getValCut(2),1.0f)); + if (diffuse) material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(diffuse->getValCut(0),diffuse->getValCut(1),diffuse->getValCut(2),1.0f)); + if (specular) material->setSpecular(osg::Material::FRONT_AND_BACK,osg::Vec4(specular->getValCut(0),specular->getValCut(1),specular->getValCut(2),1.0f)); + if (shininess) material->setShininess(osg::Material::FRONT_AND_BACK,shininess->getValue()); + if (transparency) material->setTransparency(osg::Material::FRONT_AND_BACK,transparency->getValue()); + materiales[_material]=material; + } + return materiales[_material].get(); + } + + static osg::Texture* getTextura(const char* _texture) { + if (textures.find(_texture) == textures.end()) { + osg::Texture *texture=new osg::Texture(); + texture->setImage(osgDB::readImageFile(_texture)); + texture->setWrap(osg::Texture::WRAP_S,osg::Texture::REPEAT); + texture->setWrap(osg::Texture::WRAP_T,osg::Texture::REPEAT); + std::cout << "Loading texture " << _texture << std::endl; + textures[_texture]=texture; + } + return textures[_texture].get(); + } +}; + +CacheObjetos::MaterialMap CacheObjetos::materiales; +CacheObjetos::TextureMap CacheObjetos::textures; +CacheObjetos::NodeMap CacheObjetos::nodos; + +static void makeTransform(MatrixTransform *matriz_active, osg::Transform *nodo) { + // Original + osg::Matrix m(matriz_active->getElem(0),matriz_active->getElem(1),matriz_active->getElem(2),matriz_active->getElem(3), + matriz_active->getElem(4),matriz_active->getElem(5),matriz_active->getElem(6),matriz_active->getElem(7), + matriz_active->getElem(8),matriz_active->getElem(9),matriz_active->getElem(10),matriz_active->getElem(11), + matriz_active->getElem(12),matriz_active->getElem(13),matriz_active->getElem(14),matriz_active->getElem(15)); + nodo->setMatrix(m); +} + +OSGVisitor::OSGVisitor(MyNode *nodo) { + root=0; + parent=0; + coord3_active=0; + tcoord_active=0; + texture_active=0; + material_active=0; + total_vert=0; + two_sided=false; + nodo->accept(this); + std::cout << "Model of " << total_vert << " vertices" << std::endl; +} + +void OSGVisitor::applyMyNode(MyNode *nodo) { +} + +void OSGVisitor::applyMaterial(Material *material) { + material_active=material; +} + +void OSGVisitor::applyCoordinate3(Coordinate3 *coord) { + coord3_active=coord; +} + +void OSGVisitor::applyMatrixTransform(MatrixTransform *tr) { + makeTransform(tr,parent); +} + +void OSGVisitor::applySeparator(Separator *sep) { + osg::Transform *group=new osg::Transform(); + if (root==0) { + root=group; + } + if (parent!=0) { + parent->addChild(group); + } + two_sided=false; + MyNode::MyNodeList hijos=sep->getChildren(); + for (MyNode::MyNodeList::iterator iter=hijos.begin();iter!=hijos.end();iter++) { + osg::ref_ptr hijo=*iter; + parent=group; + hijo->accept(this); + } +} + +void OSGVisitor::applyIndexedFaceSet(IndexedFaceSet *ifs) { + unsigned i,j; + if (coord3_active == 0) { + std::cerr << "ERROR: IndexedFaceSet without previous Coordinate3!" << std::endl; + throw -1; + } + osg::Geode *geode=new osg::Geode(); + osg::GeoSet *objeto=new osg::GeoSet(); + osg::StateSet *state=new osg::StateSet(); + osg::FrontFace *frontface=new osg::FrontFace(); + frontface->setMode(osg::FrontFace::CLOCKWISE); + state->setAttributeAndModes(frontface,osg::StateAttribute::ON); + osg::CullFace *cull=new osg::CullFace(); + cull->setMode(osg::CullFace::BACK); + if (ifs->getTwoSided() == false) { + state->setAttributeAndModes(cull,osg::StateAttribute::ON); + } else { + std::cout << "Deactivating culling for this object" << std::endl; + state->setAttributeAndModes(cull,osg::StateAttribute::OFF); + osg::Transparency *transp=new osg::Transparency(); + transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + state->setAttribute(transp); + state->setMode(GL_BLEND,osg::StateAttribute::ON); + state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); + } + geode->setStateSet(state); + /** Applying the material */ + if (material_active!=0) { + osg::Material *material = CacheObjetos::getMaterial(material_active); + state->setAttributeAndModes(material,osg::StateAttribute::ON); + } + /** Applying the texture */ + if (texture_active!=0) { + AtrString *filename=(AtrString*)texture_active->getAttribute("filename"); + if (filename) { + osg::Texture *texture=CacheObjetos::getTextura(filename->getValue()); + state->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON); + } + + } + VertexList vertices=coord3_active->getVertices(); + PolygonList polys=ifs->getPolygons(); + TextureCoordList tcoord; + if (tcoord_active) tcoord=tcoord_active->getTextureCoords(); + unsigned nPoly=polys.size(); + unsigned nvert_total=0; + + objeto->setPrimType(osg::GeoSet::POLYGON); + objeto->setNumPrims(nPoly); + + /** Calculating length of primitives */ + int *long_primitivas=new int[nPoly]; + for (j=0;jsize(); + nvert_total+=long_primitivas[j]; + } + objeto->setPrimLengths(long_primitivas); + this->total_vert+=nvert_total; + + /** We change from the ad-hoc scenegraph to the OSG one */ + unsigned posCoords=0; + osg::Vec3 *coords = new osg::Vec3[nvert_total]; + osg::Vec2 *tcoords = new osg::Vec2[nvert_total]; + osg::Vec3 *normalsFlat = new osg::Vec3[nvert_total]; + bool hasTextureIndices=ifs->hasTextureIndices(); + PolygonList textureIndices = ifs->getTextureIndices(); + for (j=0; j < nPoly; j++) { + VertexIndexList vindex=*polys[j]; + VertexIndexList texindex; + if (hasTextureIndices) texindex=*textureIndices[j]; + unsigned nVert=vindex.size(); + osg::Vec3 normal; + if (nVert > 2) { + normal = calcNormal(vertices[vindex[0]],vertices[vindex[1]],vertices[vindex[2]]); + } else { + normal = osg::Vec3(0,0,0); + } + for (i=0; i < nVert; i++) { + int vert = vindex[i]; + coords[posCoords].set(vertices[vert][0],vertices[vert][1],vertices[vert][2]); + normalsFlat[posCoords].set(normal[0],normal[1],normal[2]); + if (tcoord_active) { + if (hasTextureIndices) { + int coord=texindex[i]; + tcoords[posCoords].set(tcoord[coord].first,tcoord[coord].second); + } else { + tcoords[posCoords].set(tcoord[vert].first,tcoord[vert].second); + } + } + posCoords++; + } + } + + /** Establishing parameters of the geoset */ + objeto->setCoords(coords); + if (tcoord_active) { + objeto->setTextureCoords(tcoords); + objeto->setTextureBinding(osg::GeoSet::BIND_PERVERTEX); + } + //osg::Vec3 *normals=calcNormals(vertices,polys,nvert_total); + //objeto->setNormals(normals); + + geode->addDrawable(objeto); + parent->addChild(geode); +} + +void OSGVisitor::applyTextureCoordinate(TextureCoordinate *texc) { + tcoord_active=texc; +} + +void OSGVisitor::applyTexture2(Texture2 *tex) { + texture_active=tex; +} + +void OSGVisitor::applyTransform(Transform *trans) { + osg::Matrix scale; + osg::Matrix rotate; + osg::Matrix translate; + AtrVec *_scale=(AtrVec*)trans->getAttribute("scaleFactor"); + AtrVec *_rotate=(AtrVec*)trans->getAttribute("rotation"); + AtrVec *_translate=(AtrVec*)trans->getAttribute("translation"); + if (_scale) { + scale.makeScale(_scale->getVal(0),_scale->getVal(1),_scale->getVal(2)); + } + if (_rotate) { + rotate.makeRotate(_rotate->getVal(3),_rotate->getVal(0),_rotate->getVal(1),_rotate->getVal(2)); + } + if (_translate) { + translate.makeTranslate(_translate->getVal(0),_translate->getVal(1),_translate->getVal(2)); + } + parent->setMatrix(scale*rotate*translate); +} + + +osg::Node* OSGVisitor::getRoot() { + return root; +} + diff --git a/src/osgPlugins/iv/osgvisitor.h b/src/osgPlugins/iv/osgvisitor.h new file mode 100644 index 000000000..0e08fd56c --- /dev/null +++ b/src/osgPlugins/iv/osgvisitor.h @@ -0,0 +1,53 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __VISITANTE_OSG_H__ +#define __VISITANTE_OSG_H__ + +#include "mynodevisitor.h" +#include + +class OSGVisitor: public MyNodeVisitor { + osg::Node *root; + osg::Transform *parent; + Coordinate3 *coord3_active; + TextureCoordinate *tcoord_active; + Texture2 *texture_active; + Material *material_active; + int total_vert; + bool two_sided; +public: + OSGVisitor(MyNode *node); + + virtual void applyMyNode(MyNode* node); + virtual void applyMaterial(Material *material); + virtual void applyCoordinate3(Coordinate3 *coord); + virtual void applyMatrixTransform(MatrixTransform *tr); + virtual void applySeparator(Separator *sep); + virtual void applyIndexedFaceSet(IndexedFaceSet *ifs); + virtual void applyTextureCoordinate(TextureCoordinate *texc); + virtual void applyTexture2(Texture2 *tex); + virtual void applyTransform(Transform *trans); + osg::Node* getRoot(); + + virtual Object* cloneType() const { return new OSGVisitor(0); } + +}; + +#endif diff --git a/src/osgPlugins/iv/parser.cpp b/src/osgPlugins/iv/parser.cpp new file mode 100644 index 000000000..ad53dbd38 --- /dev/null +++ b/src/osgPlugins/iv/parser.cpp @@ -0,0 +1,1218 @@ + +/* A Bison parser, made from parser.y + by GNU Bison version 1.28 */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define STRING 257 +#define QUOTED_STRING 258 +#define FLOAT 259 +#define INT 260 +#define SEPARATOR 261 +#define DEF 262 +#define UN_MATERIAL 263 +#define DIFFUSE_COLOR 264 +#define COORDINATE3 265 +#define INDEXED_FACE_SET 266 +#define A_POINT 267 +#define COORD_INDEX 268 +#define TEXTURE_COORD_INDEX 269 +#define NORMAL_INDEX 270 +#define TEXTURE_COORDINATE 271 +#define TEXTURE2 272 +#define MATRIX_TRANSFORM 273 +#define MATRIX 274 +#define LISTA_VACIA 275 +#define FINPOLY 276 +#define DOBLE_CARA 277 +#define VECTOR 278 +#define VRML_HEADER 279 +#define TRANSFORM 280 +#define USE 281 + +#line 1 "parser.y" + +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef WIN32 +# pragma warning (disable:4786) +# pragma warning (disable:4541) +#endif + +#include +#include "mynode.h" +#include +#include "geometry.h" +#include "nodecache.h" + +#include "material.h" +#include "coordinate3.h" +#include "separator.h" +#include "matrixtransform.h" +#include "indexedfaceset.h" +#include "texturecoordinate.h" +#include "texture2.h" +#include "transform.h" + +#include "atrfloat.h" +#include "atrstring.h" +#include "atrvec.h" +#include "string.h" +extern int yyline; +extern int yylex(); +void yyerror(char *str,...); +static MyNode *root_node; + + +#line 52 "parser.y" +typedef union { + char *s_value; + float f_value; + MyNode *nodo; + Attribute *attribute; + VertexList *vlist; + VertexIndexList *vindex; + TextureCoordList *tcoord; + PolygonList *plist; + Matrix matrix; + int i_value; +} YYSTYPE; +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif + +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 120 +#define YYFLAG -32768 +#define YYNTBASE 32 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 281 ? yytranslate[x] : 41) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 30, 2, 31, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 28, 2, 29, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 3, 8, 13, 21, 29, 41, 53, 62, 75, + 88, 94, 102, 107, 112, 117, 118, 121, 126, 129, + 133, 138, 143, 144, 147, 148, 151, 153, 170, 173, + 176, 180, 185, 191, 194, 198 +}; + +static const short yyrhs[] = { 25, + 33, 0, 9, 28, 34, 29, 0, 18, 28, 34, + 29, 0, 11, 28, 13, 30, 35, 31, 29, 0, + 12, 28, 14, 30, 36, 31, 29, 0, 12, 28, + 14, 30, 36, 31, 15, 30, 36, 31, 29, 0, + 12, 28, 14, 30, 36, 31, 16, 30, 36, 31, + 29, 0, 12, 28, 23, 14, 30, 36, 31, 29, + 0, 12, 28, 23, 14, 30, 36, 31, 15, 30, + 36, 31, 29, 0, 12, 28, 23, 14, 30, 36, + 31, 16, 30, 36, 31, 29, 0, 19, 28, 20, + 38, 29, 0, 17, 28, 13, 30, 40, 31, 29, + 0, 26, 28, 34, 29, 0, 3, 28, 34, 29, + 0, 7, 28, 34, 29, 0, 0, 34, 39, 0, + 34, 8, 3, 33, 0, 34, 33, 0, 34, 27, + 3, 0, 24, 30, 35, 31, 0, 35, 5, 5, + 5, 0, 0, 36, 37, 0, 0, 6, 37, 0, + 22, 0, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 0, 3, + 5, 0, 3, 3, 0, 3, 5, 5, 0, 3, + 5, 5, 5, 0, 3, 5, 5, 5, 5, 0, + 3, 4, 0, 40, 5, 5, 0, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 92, 95, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 112, 113, 114, 115, 116, + 117, 120, 121, 124, 125, 128, 129, 132, 140, 141, + 142, 143, 144, 145, 148, 149 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","STRING", +"QUOTED_STRING","FLOAT","INT","SEPARATOR","DEF","UN_MATERIAL","DIFFUSE_COLOR", +"COORDINATE3","INDEXED_FACE_SET","A_POINT","COORD_INDEX","TEXTURE_COORD_INDEX", +"NORMAL_INDEX","TEXTURE_COORDINATE","TEXTURE2","MATRIX_TRANSFORM","MATRIX","LISTA_VACIA", +"FINPOLY","DOBLE_CARA","VECTOR","VRML_HEADER","TRANSFORM","USE","'{'","'}'", +"'['","']'","vrml_file","node","node_contents","points","polylist","vertexilist", +"matrix","attr","coords", NULL +}; +#endif + +static const short yyr1[] = { 0, + 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, + 34, 35, 35, 36, 36, 37, 37, 38, 39, 39, + 39, 39, 39, 39, 40, 40 +}; + +static const short yyr2[] = { 0, + 2, 4, 4, 7, 7, 11, 11, 8, 12, 12, + 5, 7, 4, 4, 4, 0, 2, 4, 2, 3, + 4, 4, 0, 2, 0, 2, 1, 16, 2, 2, + 3, 4, 5, 2, 3, 0 +}; + +static const short yydefact[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 16, 16, 16, 0, 0, 0, 16, 0, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 23, 0, 0, 0, 14, 19, 17, 15, 2, + 23, 25, 0, 36, 3, 0, 0, 13, 0, 30, + 34, 29, 0, 20, 0, 0, 25, 0, 0, 11, + 0, 21, 31, 18, 0, 0, 27, 0, 24, 0, + 0, 0, 0, 0, 32, 4, 26, 0, 0, 5, + 0, 35, 12, 0, 22, 33, 25, 25, 0, 0, + 8, 0, 0, 0, 25, 25, 0, 0, 0, 0, + 0, 0, 6, 7, 0, 0, 0, 9, 10, 0, + 0, 0, 0, 0, 0, 0, 28, 0, 0, 0 +}; + +static const short yydefgoto[] = { 118, + 37, 22, 49, 56, 69, 47, 38, 58 +}; + +static const short yypact[] = { -20, + 121, -22, 2, 16, 23, 25, 33, 43, 44, 45, +-32768, 1, 1, 1, 35, 20, 62, 1, 13, 1, + 46, 0, 38, 51, 56, 59, 67, 84, 76, 116, + 89,-32768, 10, 119, 120,-32768,-32768,-32768,-32768,-32768, +-32768,-32768, 101,-32768,-32768, 132, 112,-32768, -3,-32768, +-32768, 137, 121,-32768, 5, 60,-32768, 11, 138,-32768, + 139,-32768, 140,-32768, 117, -2,-32768, 6,-32768, 68, + 143, 122, 144, 145, 147,-32768,-32768, 123, 124,-32768, + 8,-32768,-32768, 150,-32768,-32768,-32768,-32768, 126, 127, +-32768, 153, 98, 103,-32768,-32768, 154, 131, 133, 104, + 105, 156,-32768,-32768, 134, 135, 160,-32768,-32768, 161, + 162, 163, 164, 165, 166, 167,-32768, 173, 174,-32768 +}; + +static const short yypgoto[] = {-32768, + -1, 99, 136, -56, 109,-32768,-32768,-32768 +}; + + +#define YYLAST 177 + + +static const short yytable[] = { 11, + 70, 61, 33, 66, 1, 12, 3, 34, 4, 61, + 5, 6, 50, 51, 52, 71, 7, 8, 9, 67, + 78, 79, 89, 90, 21, 10, 35, 62, 36, 13, + 93, 94, 30, 26, 80, 65, 91, 12, 100, 101, + 33, 72, 27, 14, 3, 34, 4, 25, 5, 6, + 15, 64, 16, 33, 7, 8, 9, 3, 34, 4, + 17, 5, 6, 10, 35, 66, 39, 7, 8, 9, + 18, 19, 20, 66, 28, 32, 10, 35, 33, 40, + 43, 67, 3, 34, 4, 41, 5, 6, 42, 67, + 68, 33, 7, 8, 9, 3, 34, 4, 81, 5, + 6, 10, 35, 66, 45, 7, 8, 9, 66, 66, + 66, 23, 24, 44, 10, 35, 29, 48, 31, 67, + 46, 53, 54, 2, 67, 67, 67, 3, 98, 4, + 57, 5, 6, 99, 105, 106, 59, 7, 8, 9, + 60, 63, 73, 74, 75, 76, 10, 82, 84, 85, + 83, 86, 87, 88, 92, 95, 96, 97, 102, 103, + 107, 104, 108, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 119, 120, 77, 0, 55 +}; + +static const short yycheck[] = { 1, + 57, 5, 3, 6, 25, 28, 7, 8, 9, 5, + 11, 12, 3, 4, 5, 5, 17, 18, 19, 22, + 15, 16, 15, 16, 24, 26, 27, 31, 29, 28, + 87, 88, 20, 14, 29, 31, 29, 28, 95, 96, + 3, 31, 23, 28, 7, 8, 9, 13, 11, 12, + 28, 53, 28, 3, 17, 18, 19, 7, 8, 9, + 28, 11, 12, 26, 27, 6, 29, 17, 18, 19, + 28, 28, 28, 6, 13, 30, 26, 27, 3, 29, + 14, 22, 7, 8, 9, 30, 11, 12, 30, 22, + 31, 3, 17, 18, 19, 7, 8, 9, 31, 11, + 12, 26, 27, 6, 29, 17, 18, 19, 6, 6, + 6, 13, 14, 30, 26, 27, 18, 29, 20, 22, + 5, 3, 3, 3, 22, 22, 22, 7, 31, 9, + 30, 11, 12, 31, 31, 31, 5, 17, 18, 19, + 29, 5, 5, 5, 5, 29, 26, 5, 5, 5, + 29, 5, 30, 30, 5, 30, 30, 5, 5, 29, + 5, 29, 29, 29, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 66, -1, 41 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/lib/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 217 "/usr/lib/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 1: +#line 92 "parser.y" +{ root_node=yyvsp[0].nodo; ; + break;} +case 2: +#line 96 "parser.y" +{ yyval.nodo=new Material(yyvsp[-1].nodo); delete yyvsp[-1].nodo;; + break;} +case 3: +#line 97 "parser.y" +{ yyval.nodo=new Texture2(yyvsp[-1].nodo); delete yyvsp[-1].nodo;; + break;} +case 4: +#line 98 "parser.y" +{ yyval.nodo=new Coordinate3(yyvsp[-2].vlist); delete yyvsp[-2].vlist; ; + break;} +case 5: +#line 99 "parser.y" +{yyval.nodo=new IndexedFaceSet(yyvsp[-2].plist); delete yyvsp[-2].plist; ; + break;} +case 6: +#line 100 "parser.y" +{yyval.nodo=new IndexedFaceSet(yyvsp[-6].plist,yyvsp[-2].plist); delete yyvsp[-6].plist; delete yyvsp[-2].plist; ; + break;} +case 7: +#line 101 "parser.y" +{yyval.nodo=new IndexedFaceSet(yyvsp[-6].plist); delete yyvsp[-6].plist; delete yyvsp[-2].plist; ; + break;} +case 8: +#line 102 "parser.y" +{yyval.nodo=new IndexedFaceSet(yyvsp[-2].plist); delete yyvsp[-2].plist; yyval.nodo->setTwoSided(); ; + break;} +case 9: +#line 103 "parser.y" +{yyval.nodo=new IndexedFaceSet(yyvsp[-6].plist,yyvsp[-2].plist); delete yyvsp[-6].plist; delete yyvsp[-2].plist; yyval.nodo->setTwoSided(); yyval.nodo->setTwoSided(); ; + break;} +case 10: +#line 104 "parser.y" +{yyval.nodo=new IndexedFaceSet(yyvsp[-6].plist); delete yyvsp[-6].plist; delete yyvsp[-2].plist; yyval.nodo->setTwoSided(); ; + break;} +case 11: +#line 105 "parser.y" +{ yyval.nodo=new MatrixTransform(yyvsp[-1].matrix); ; + break;} +case 12: +#line 106 "parser.y" +{ yyval.nodo=new TextureCoordinate(yyvsp[-2].tcoord); delete yyvsp[-2].tcoord; ; + break;} +case 13: +#line 107 "parser.y" +{ yyval.nodo=new Transform(yyvsp[-1].nodo); delete yyvsp[-1].nodo; ; + break;} +case 14: +#line 108 "parser.y" +{ yyval.nodo=yyvsp[-1].nodo; ; + break;} +case 15: +#line 109 "parser.y" +{yyval.nodo=new Separator(yyvsp[-1].nodo); delete yyvsp[-1].nodo; ; + break;} +case 16: +#line 112 "parser.y" +{ yyval.nodo=new MyNode(); ; + break;} +case 17: +#line 113 "parser.y" +{ yyvsp[-1].nodo->addAttribute(yyvsp[0].attribute->getName(), yyvsp[0].attribute); yyval.nodo=yyvsp[-1].nodo; ; + break;} +case 18: +#line 114 "parser.y" +{ NodeCache::addNode(yyvsp[-1].s_value,yyvsp[0].nodo); yyvsp[-3].nodo->addChild(yyvsp[0].nodo); yyval.nodo=yyvsp[-3].nodo; ; + break;} +case 19: +#line 115 "parser.y" +{ yyvsp[-1].nodo->addChild(yyvsp[0].nodo); yyval.nodo=yyvsp[-1].nodo; ; + break;} +case 20: +#line 116 "parser.y" +{yyvsp[-2].nodo->addChild(NodeCache::getNode(yyvsp[0].s_value)); yyval.nodo=yyvsp[-2].nodo; ; + break;} +case 21: +#line 117 "parser.y" +{ delete yyvsp[-1].vlist;yyval.nodo=new MyNode(); ; + break;} +case 22: +#line 120 "parser.y" +{ yyvsp[-3].vlist->push_back(osg::Vec3(yyvsp[-2].f_value,yyvsp[-1].f_value,yyvsp[0].f_value)); yyval.vlist=yyvsp[-3].vlist; ; + break;} +case 23: +#line 121 "parser.y" +{ yyval.vlist=new VertexList(); ; + break;} +case 24: +#line 124 "parser.y" +{ yyvsp[-1].plist->push_back(yyvsp[0].vindex);yyval.plist=yyvsp[-1].plist; ; + break;} +case 25: +#line 125 "parser.y" +{ yyval.plist=new PolygonList(); ; + break;} +case 26: +#line 128 "parser.y" +{ yyvsp[0].vindex->push_back(yyvsp[-1].i_value);yyval.vindex=yyvsp[0].vindex; ; + break;} +case 27: +#line 129 "parser.y" +{ yyval.vindex=new VertexIndexList(); ; + break;} +case 28: +#line 136 "parser.y" +{Matrix m; m[0]=yyvsp[-15].f_value; m[1]=yyvsp[-14].f_value; m[2]=yyvsp[-13].f_value;m[3]=yyvsp[-12].f_value;m[4]=yyvsp[-11].f_value;m[5]=yyvsp[-10].f_value;m[6]=yyvsp[-9].f_value;m[7]=yyvsp[-8].f_value;m[8]=yyvsp[-7].f_value;m[9]=yyvsp[-6].f_value;m[10]=yyvsp[-5].f_value;m[11]=yyvsp[-4].f_value;m[12]=yyvsp[-3].f_value;m[13]=yyvsp[-2].f_value;m[14]=yyvsp[-1].f_value;m[15]=yyvsp[0].f_value; memcpy(yyval.matrix,m,sizeof(m));; + break;} +case 29: +#line 140 "parser.y" +{ yyval.attribute=new AtrFloat(yyvsp[-1].s_value,yyvsp[0].f_value); ; + break;} +case 30: +#line 141 "parser.y" +{ yyval.attribute=new AtrString(yyvsp[-1].s_value,yyvsp[0].s_value); ; + break;} +case 31: +#line 142 "parser.y" +{ yyval.attribute=new AtrVec(yyvsp[-2].s_value,yyvsp[-1].f_value,yyvsp[0].f_value); ; + break;} +case 32: +#line 143 "parser.y" +{ yyval.attribute=new AtrVec(yyvsp[-3].s_value,yyvsp[-2].f_value,yyvsp[-1].f_value,yyvsp[0].f_value); ; + break;} +case 33: +#line 144 "parser.y" +{ yyval.attribute=new AtrVec(yyvsp[-4].s_value,yyvsp[-3].f_value,yyvsp[-2].f_value,yyvsp[-1].f_value,yyvsp[0].f_value); ; + break;} +case 34: +#line 145 "parser.y" +{ yyval.attribute=new AtrString(yyvsp[-1].s_value,yyvsp[0].s_value); ; + break;} +case 35: +#line 148 "parser.y" +{ yyvsp[-2].tcoord->push_back(TextureCoordVal(yyvsp[-1].f_value,yyvsp[0].f_value));yyval.tcoord=yyvsp[-2].tcoord; ; + break;} +case 36: +#line 149 "parser.y" +{ yyval.tcoord=new TextureCoordList(); ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/lib/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 152 "parser.y" + + +void yyerror(char *str,...) +{ + printf("There was an error near line %d : \"%s\"!!!\n",yyline,str);fflush(stdout); +} + +MyNode *getRoot() { return root_node; } diff --git a/src/osgPlugins/iv/parser.cpp.h b/src/osgPlugins/iv/parser.cpp.h new file mode 100644 index 000000000..50572229b --- /dev/null +++ b/src/osgPlugins/iv/parser.cpp.h @@ -0,0 +1,40 @@ +typedef union { + char *s_value; + float f_value; + MyNode *nodo; + Attribute *attribute; + VertexList *vlist; + VertexIndexList *vindex; + TextureCoordList *tcoord; + PolygonList *plist; + Matrix matrix; + int i_value; +} YYSTYPE; +#define STRING 257 +#define QUOTED_STRING 258 +#define FLOAT 259 +#define INT 260 +#define SEPARATOR 261 +#define DEF 262 +#define UN_MATERIAL 263 +#define DIFFUSE_COLOR 264 +#define COORDINATE3 265 +#define INDEXED_FACE_SET 266 +#define A_POINT 267 +#define COORD_INDEX 268 +#define TEXTURE_COORD_INDEX 269 +#define NORMAL_INDEX 270 +#define TEXTURE_COORDINATE 271 +#define TEXTURE2 272 +#define MATRIX_TRANSFORM 273 +#define MATRIX 274 +#define LISTA_VACIA 275 +#define FINPOLY 276 +#define DOBLE_CARA 277 +#define VECTOR 278 +#define VRML_HEADER 279 +#define TRANSFORM 280 +#define USE 281 + + +extern YYSTYPE yylval; diff --git a/src/osgPlugins/iv/parser.hpp b/src/osgPlugins/iv/parser.hpp new file mode 100644 index 000000000..2da3bcd1f --- /dev/null +++ b/src/osgPlugins/iv/parser.hpp @@ -0,0 +1,49 @@ +#ifndef BISON_PARSER_HPP +# define BISON_PARSER_HPP + +#ifndef YYSTYPE +typedef union { + char *s_value; + float f_value; + MyNode *nodo; + Attribute *attribute; + VertexList *vlist; + VertexIndexList *vindex; + TextureCoordList *tcoord; + PolygonList *plist; + Matrix matrix; + int i_value; +} yystype; +# define YYSTYPE yystype +# define YYSTYPE_IS_TRIVIAL 1 +#endif +# define STRING 257 +# define QUOTED_STRING 258 +# define FLOAT 259 +# define INT 260 +# define SEPARATOR 261 +# define DEF 262 +# define UN_MATERIAL 263 +# define DIFFUSE_COLOR 264 +# define COORDINATE3 265 +# define INDEXED_FACE_SET 266 +# define A_POINT 267 +# define COORD_INDEX 268 +# define TEXTURE_COORD_INDEX 269 +# define NORMAL_INDEX 270 +# define TEXTURE_COORDINATE 271 +# define TEXTURE2 272 +# define MATRIX_TRANSFORM 273 +# define MATRIX 274 +# define LISTA_VACIA 275 +# define FINPOLY 276 +# define DOBLE_CARA 277 +# define VECTOR 278 +# define VRML_HEADER 279 +# define TRANSFORM 280 +# define USE 281 + + +extern YYSTYPE yylval; + +#endif /* not BISON_PARSER_HPP */ diff --git a/src/osgPlugins/iv/parser.y b/src/osgPlugins/iv/parser.y new file mode 100644 index 000000000..a660f6a3f --- /dev/null +++ b/src/osgPlugins/iv/parser.y @@ -0,0 +1,159 @@ +%{ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef WIN32 +# pragma warning (disable:4786) +# pragma warning (disable:4541) +#endif + +#include +#include "mynode.h" +#include +#include "geometry.h" +#include "nodecache.h" + +#include "material.h" +#include "coordinate3.h" +#include "separator.h" +#include "matrixtransform.h" +#include "indexedfaceset.h" +#include "texturecoordinate.h" +#include "texture2.h" +#include "transform.h" + +#include "atrfloat.h" +#include "atrstring.h" +#include "atrvec.h" +#include "string.h" +extern int yyline; +extern int yylex(); +void yyerror(char *str,...); +static MyNode *root_node; + +%} + +%union { + char *s_value; + float f_value; + MyNode *nodo; + Attribute *attribute; + VertexList *vlist; + VertexIndexList *vindex; + TextureCoordList *tcoord; + PolygonList *plist; + Matrix matrix; + int i_value; +}; + +%token STRING +%token QUOTED_STRING +%token FLOAT +%token INT +%token SEPARATOR DEF UN_MATERIAL DIFFUSE_COLOR COORDINATE3 INDEXED_FACE_SET +%token A_POINT COORD_INDEX TEXTURE_COORD_INDEX NORMAL_INDEX TEXTURE_COORDINATE TEXTURE2 +%token MATRIX_TRANSFORM MATRIX +%token LISTA_VACIA FINPOLY +%token DOBLE_CARA +%token VECTOR +%token VRML_HEADER +%token TRANSFORM +%token USE + +%type points +%type polylist +%type vertexilist +%type coords +%type node_contents +%type node +%type attr +%type matrix +%start vrml_file + + +%% + +vrml_file: VRML_HEADER node { root_node=$2; } +; + +node: + UN_MATERIAL '{' node_contents '}' { $$=new Material($3); delete $3;} + | TEXTURE2 '{' node_contents '}' { $$=new Texture2($3); delete $3;} + | COORDINATE3 '{' A_POINT '[' points ']' '}' { $$=new Coordinate3($5); delete $5; } + | INDEXED_FACE_SET '{' COORD_INDEX '[' polylist ']' '}' {$$=new IndexedFaceSet($5); delete $5; } + | INDEXED_FACE_SET '{' COORD_INDEX '[' polylist ']' TEXTURE_COORD_INDEX '[' polylist ']' '}' {$$=new IndexedFaceSet($5,$9); delete $5; delete $9; } + | INDEXED_FACE_SET '{' COORD_INDEX '[' polylist ']' NORMAL_INDEX '[' polylist ']' '}' {$$=new IndexedFaceSet($5); delete $5; delete $9; } + | INDEXED_FACE_SET '{' DOBLE_CARA COORD_INDEX '[' polylist ']' '}' {$$=new IndexedFaceSet($6); delete $6; $$->setTwoSided(); } + | INDEXED_FACE_SET '{' DOBLE_CARA COORD_INDEX '[' polylist ']' TEXTURE_COORD_INDEX '[' polylist ']' '}' {$$=new IndexedFaceSet($6,$10); delete $6; delete $10; $$->setTwoSided(); $$->setTwoSided(); } + | INDEXED_FACE_SET '{' DOBLE_CARA COORD_INDEX '[' polylist ']' NORMAL_INDEX '[' polylist ']' '}' {$$=new IndexedFaceSet($6); delete $6; delete $10; $$->setTwoSided(); } + | MATRIX_TRANSFORM '{' MATRIX matrix '}' { $$=new MatrixTransform($4); } + | TEXTURE_COORDINATE '{' A_POINT '[' coords ']' '}' { $$=new TextureCoordinate($5); delete $5; } + | TRANSFORM '{' node_contents '}' { $$=new Transform($3); delete $3; } + | STRING '{' node_contents '}' { $$=$3; } + | SEPARATOR '{' node_contents '}' {$$=new Separator($3); delete $3; } +; + +node_contents: { $$=new MyNode(); } + | node_contents attr { $1->addAttribute($2->getName(), $2); $$=$1; } + | node_contents DEF STRING node { NodeCache::addNode($3,$4); $1->addChild($4); $$=$1; } + | node_contents node { $1->addChild($2); $$=$1; } + | node_contents USE STRING {$1->addChild(NodeCache::getNode($3)); $$=$1; } + | VECTOR '[' points ']' { delete $3;$$=new MyNode(); } +; + +points: points FLOAT FLOAT FLOAT { $1->push_back(osg::Vec3($2,$3,$4)); $$=$1; } + | { $$=new VertexList(); } +; + +polylist: polylist vertexilist { $1->push_back($2);$$=$1; } + | { $$=new PolygonList(); } +; + +vertexilist: INT vertexilist { $2->push_back($1);$$=$2; } + | FINPOLY { $$=new VertexIndexList(); } +; + +matrix: + FLOAT FLOAT FLOAT FLOAT + FLOAT FLOAT FLOAT FLOAT + FLOAT FLOAT FLOAT FLOAT + FLOAT FLOAT FLOAT FLOAT {Matrix m; m[0]=$1; m[1]=$2; m[2]=$3;m[3]=$4;m[4]=$5;m[5]=$6;m[6]=$7;m[7]=$8;m[8]=$9;m[9]=$10;m[10]=$11;m[11]=$12;m[12]=$13;m[13]=$14;m[14]=$15;m[15]=$16; memcpy($$,m,sizeof(m));} + +; + +attr: STRING FLOAT { $$=new AtrFloat($1,$2); } + | STRING STRING { $$=new AtrString($1,$2); } + | STRING FLOAT FLOAT { $$=new AtrVec($1,$2,$3); } + | STRING FLOAT FLOAT FLOAT { $$=new AtrVec($1,$2,$3,$4); } + | STRING FLOAT FLOAT FLOAT FLOAT { $$=new AtrVec($1,$2,$3,$4,$5); } + | STRING QUOTED_STRING { $$=new AtrString($1,$2); } +; + +coords: coords FLOAT FLOAT { $1->push_back(TextureCoordVal($2,$3));$$=$1; } + | { $$=new TextureCoordList(); } +; + +%% + +void yyerror(char *str,...) +{ + printf("There was an error near line %d : \"%s\"!!!\n",yyline,str);fflush(stdout); +} + +MyNode *getRoot() { return root_node; } diff --git a/src/osgPlugins/iv/readerwriter.cpp b/src/osgPlugins/iv/readerwriter.cpp new file mode 100644 index 000000000..11f86aa8b --- /dev/null +++ b/src/osgPlugins/iv/readerwriter.cpp @@ -0,0 +1,32 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef WIN32 +# pragma warning (disable:4786) +# pragma warning (disable:4541) +#endif +#include "readerwriter.h" +#include "main.h" + +osgDB::ReaderWriter::ReadResult VrmlReaderWriter::readNode(const std::string& fileName, + const osgDB::ReaderWriter::Options*) { + return readVRMLNode(fileName.c_str()); +} + +osgDB::RegisterReaderWriterProxy g_readerWriter_VRML_Proxy; diff --git a/src/osgPlugins/iv/readerwriter.h b/src/osgPlugins/iv/readerwriter.h new file mode 100644 index 000000000..a3158d87f --- /dev/null +++ b/src/osgPlugins/iv/readerwriter.h @@ -0,0 +1,40 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LECTOR_ESCRITOR_H__ +#define __LECTOR_ESCRITOR_H__ + +#include +#include +#include +#include +#include + +class VrmlReaderWriter: public osgDB::ReaderWriter { +public: + VrmlReaderWriter() { } + virtual const char* className() { return "VRML"; } + virtual bool acceptsExtension(const std::string& extension) { + return osgDB::equalCaseInsensitive(extension,"wrl") + || osgDB::equalCaseInsensitive(extension,"iv"); + } + virtual ReadResult readNode(const std::string& fileName,const osgDB::ReaderWriter::Options*); +}; + +#endif diff --git a/src/osgPlugins/iv/scanner.cpp b/src/osgPlugins/iv/scanner.cpp new file mode 100644 index 000000000..8745f4c94 --- /dev/null +++ b/src/osgPlugins/iv/scanner.cpp @@ -0,0 +1,2094 @@ +#line 2 "scanner.cpp" +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header$ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 34 +#define YY_END_OF_BUFFER 35 +static yyconst short int yy_accept[232] = + { 0, + 32, 32, 0, 0, 32, 32, 35, 34, 1, 2, + 1, 32, 34, 24, 32, 1, 32, 28, 32, 32, + 32, 32, 32, 32, 32, 30, 20, 32, 32, 32, + 32, 32, 32, 30, 34, 29, 0, 0, 32, 0, + 33, 24, 24, 24, 32, 28, 25, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 31, 32, 32, + 32, 32, 32, 32, 29, 19, 24, 24, 25, 32, + 0, 32, 32, 3, 32, 32, 32, 32, 32, 32, + 21, 32, 32, 32, 32, 32, 32, 24, 24, 0, + 32, 27, 27, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 24, 24, 26, + 26, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 14, 32, 32, 24, 24, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 13, 32, 32, 18, + 24, 24, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 24, 24, 32, 32, 32, 7, 32, + 32, 5, 32, 32, 32, 32, 32, 24, 24, 32, + 12, 32, 32, 6, 32, 10, 32, 32, 32, 24, + 24, 32, 32, 32, 32, 15, 32, 32, 24, 24, + 4, 32, 32, 32, 17, 32, 24, 24, 32, 32, + + 32, 32, 24, 24, 32, 32, 32, 32, 24, 24, + 8, 32, 32, 32, 24, 24, 11, 32, 32, 24, + 22, 32, 32, 24, 32, 16, 24, 9, 24, 23, + 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 6, 7, 8, 1, 1, 1, 1, 1, + 1, 9, 10, 11, 12, 13, 1, 14, 15, 16, + 17, 18, 18, 18, 18, 18, 18, 1, 1, 1, + 1, 1, 1, 1, 9, 9, 19, 20, 21, 22, + 9, 9, 23, 9, 9, 24, 25, 9, 9, 9, + 9, 26, 27, 28, 29, 30, 9, 9, 9, 9, + 31, 1, 32, 1, 9, 1, 33, 34, 35, 36, + + 37, 38, 9, 9, 39, 9, 9, 40, 41, 42, + 43, 44, 9, 45, 46, 47, 48, 49, 9, 50, + 9, 9, 51, 1, 51, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[52] = + { 0, + 1, 1, 2, 2, 3, 4, 1, 1, 4, 1, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 3, 1, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 1 + } ; + +static yyconst short int yy_base[238] = + { 0, + 0, 0, 50, 100, 151, 202, 181, 1353, 1353, 1353, + 52, 0, 173, 33, 64, 1353, 249, 59, 79, 114, + 94, 133, 136, 163, 165, 147, 1353, 180, 184, 213, + 215, 237, 246, 1353, 72, 221, 66, 145, 0, 168, + 1353, 0, 132, 146, 265, 100, 270, 287, 289, 299, + 303, 309, 318, 320, 322, 337, 342, 1353, 353, 356, + 369, 373, 375, 384, 377, 393, 116, 138, 406, 48, + 414, 419, 433, 435, 439, 444, 449, 454, 471, 477, + 483, 486, 492, 498, 507, 519, 521, 123, 126, 526, + 539, 544, 555, 569, 571, 573, 575, 585, 588, 590, + + 604, 609, 621, 623, 626, 636, 638, 106, 142, 647, + 660, 666, 677, 680, 682, 693, 696, 709, 713, 725, + 728, 740, 744, 755, 757, 97, 113, 759, 761, 776, + 778, 790, 792, 809, 811, 814, 820, 824, 830, 844, + 97, 119, 847, 853, 857, 859, 863, 876, 887, 891, + 896, 907, 910, 88, 117, 920, 929, 939, 934, 948, + 951, 953, 963, 972, 984, 986, 995, 124, 114, 999, + 1014, 1018, 1027, 1029, 1041, 1046, 1050, 1060, 1062, 96, + 119, 1065, 1081, 1093, 1096, 1098, 1102, 1115, 107, 76, + 1117, 1130, 1132, 1145, 1149, 1159, 95, 60, 1161, 1172, + + 1178, 1181, 84, 59, 1183, 1194, 1200, 1205, 88, 52, + 1214, 1227, 1238, 1243, 46, 39, 1247, 1249, 1260, 30, + 0, 1270, 1279, 40, 1282, 1299, 35, 1303, 34, 0, + 1353, 1334, 1338, 55, 1342, 1346, 1348 + } ; + +static yyconst short int yy_def[238] = + { 0, + 231, 1, 232, 232, 233, 233, 231, 231, 231, 231, + 231, 234, 235, 236, 237, 231, 237, 17, 237, 237, + 237, 237, 237, 237, 237, 231, 231, 237, 237, 237, + 237, 237, 237, 231, 231, 231, 231, 231, 234, 235, + 231, 236, 236, 236, 237, 17, 234, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 231, 237, 237, + 237, 237, 237, 237, 231, 231, 236, 236, 234, 234, + 231, 17, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 236, 236, 231, + 234, 231, 17, 237, 237, 237, 237, 237, 237, 237, + + 237, 237, 237, 237, 237, 237, 237, 236, 236, 231, + 234, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 236, 236, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 236, 236, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 236, 236, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 236, 236, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 236, + 236, 237, 237, 237, 237, 237, 237, 237, 236, 236, + 237, 237, 237, 237, 237, 237, 236, 236, 237, 237, + + 237, 237, 236, 236, 237, 237, 237, 237, 236, 236, + 237, 237, 237, 237, 236, 236, 237, 237, 237, 236, + 236, 237, 237, 236, 237, 237, 236, 237, 236, 236, + 0, 231, 231, 231, 231, 231, 231 + } ; + +static yyconst short int yy_nxt[1405] = + { 0, + 8, 9, 10, 9, 11, 12, 13, 14, 15, 8, + 16, 17, 12, 18, 18, 18, 18, 18, 19, 20, + 15, 15, 21, 15, 22, 15, 23, 24, 25, 15, + 26, 27, 15, 15, 28, 15, 15, 15, 15, 15, + 29, 30, 15, 31, 15, 15, 32, 15, 33, 15, + 34, 9, 10, 9, 9, 43, 37, 90, 39, 91, + 16, 35, 44, 36, 36, 36, 36, 36, 37, 39, + 37, 47, 230, 229, 227, 224, 39, 221, 220, 48, + 34, 27, 38, 37, 39, 65, 66, 65, 65, 65, + 216, 39, 215, 210, 38, 48, 38, 209, 37, 39, + + 34, 9, 10, 9, 9, 204, 39, 203, 198, 38, + 16, 35, 47, 36, 36, 36, 36, 36, 37, 39, + 48, 49, 197, 190, 38, 189, 39, 181, 180, 169, + 34, 27, 168, 155, 50, 52, 48, 37, 39, 154, + 37, 39, 142, 141, 38, 39, 127, 126, 39, 109, + 34, 8, 8, 8, 8, 8, 51, 8, 8, 108, + 8, 8, 89, 38, 88, 53, 38, 37, 39, 37, + 39, 68, 54, 67, 41, 39, 58, 39, 58, 41, + 231, 8, 8, 231, 37, 39, 231, 231, 37, 39, + 231, 57, 39, 38, 231, 38, 39, 231, 231, 55, + + 231, 8, 8, 8, 8, 8, 8, 56, 8, 8, + 38, 8, 8, 231, 38, 231, 60, 37, 39, 37, + 39, 231, 59, 231, 231, 39, 231, 39, 231, 231, + 231, 231, 8, 8, 65, 65, 65, 65, 65, 231, + 231, 37, 39, 38, 231, 38, 231, 231, 231, 39, + 37, 39, 8, 37, 39, 61, 231, 62, 39, 231, + 231, 39, 46, 46, 46, 46, 46, 38, 231, 37, + 39, 231, 231, 63, 231, 231, 38, 39, 231, 38, + 231, 231, 64, 69, 69, 69, 69, 69, 231, 231, + 70, 37, 39, 37, 39, 38, 71, 231, 72, 39, + + 231, 39, 231, 37, 39, 231, 70, 37, 39, 231, + 231, 39, 231, 37, 39, 39, 231, 38, 231, 38, + 74, 39, 37, 39, 37, 39, 37, 39, 231, 38, + 39, 73, 39, 38, 39, 231, 75, 231, 231, 38, + 231, 37, 39, 231, 76, 231, 37, 39, 38, 39, + 38, 231, 38, 231, 39, 231, 231, 37, 39, 231, + 37, 39, 81, 78, 77, 39, 231, 38, 39, 80, + 231, 79, 38, 37, 39, 231, 231, 37, 39, 37, + 39, 39, 231, 38, 231, 39, 38, 39, 37, 39, + 65, 65, 65, 65, 65, 82, 39, 231, 231, 38, + + 231, 231, 83, 38, 231, 38, 65, 65, 65, 65, + 65, 85, 231, 84, 38, 231, 231, 231, 87, 69, + 69, 69, 69, 69, 86, 231, 70, 92, 92, 92, + 92, 92, 93, 93, 93, 93, 93, 37, 39, 37, + 39, 231, 70, 37, 39, 39, 231, 39, 37, 39, + 231, 39, 231, 37, 39, 231, 39, 231, 37, 39, + 231, 39, 231, 38, 231, 38, 39, 231, 231, 38, + 231, 231, 231, 231, 38, 37, 39, 94, 95, 38, + 96, 37, 39, 39, 38, 97, 99, 37, 39, 39, + 37, 39, 231, 98, 231, 39, 37, 39, 39, 231, + + 231, 38, 37, 39, 39, 231, 231, 38, 231, 231, + 39, 37, 39, 38, 231, 231, 38, 100, 101, 39, + 231, 231, 38, 37, 39, 37, 39, 231, 38, 231, + 102, 39, 231, 39, 231, 231, 103, 38, 104, 110, + 110, 110, 110, 110, 231, 231, 231, 231, 105, 38, + 231, 38, 111, 111, 111, 111, 111, 92, 92, 92, + 92, 92, 231, 231, 231, 106, 231, 107, 93, 93, + 93, 93, 93, 37, 39, 37, 39, 37, 39, 37, + 39, 39, 231, 39, 231, 39, 231, 39, 231, 37, + 39, 231, 37, 39, 37, 39, 231, 39, 231, 38, + + 39, 38, 39, 38, 112, 38, 231, 113, 37, 39, + 231, 231, 231, 37, 39, 38, 39, 231, 38, 115, + 38, 39, 114, 116, 231, 37, 39, 37, 39, 231, + 37, 39, 117, 39, 38, 39, 231, 118, 39, 38, + 37, 39, 37, 39, 120, 231, 231, 231, 39, 119, + 39, 38, 231, 38, 231, 122, 38, 231, 231, 121, + 110, 110, 110, 110, 110, 231, 38, 231, 38, 231, + 37, 39, 123, 111, 111, 111, 111, 111, 39, 231, + 125, 37, 39, 124, 37, 39, 37, 39, 231, 39, + 231, 231, 39, 231, 39, 129, 38, 37, 39, 231, + + 37, 39, 231, 231, 128, 39, 231, 38, 39, 231, + 38, 231, 38, 37, 39, 231, 130, 37, 39, 231, + 131, 39, 231, 38, 231, 39, 38, 231, 133, 37, + 39, 231, 37, 39, 231, 231, 231, 39, 231, 38, + 39, 231, 132, 38, 37, 39, 231, 136, 37, 39, + 135, 231, 39, 134, 231, 38, 39, 231, 38, 37, + 39, 37, 39, 37, 39, 37, 39, 39, 231, 39, + 38, 39, 231, 39, 38, 231, 231, 137, 231, 138, + 37, 39, 37, 39, 231, 38, 231, 38, 39, 38, + 39, 38, 231, 144, 37, 39, 37, 39, 231, 139, + + 143, 140, 39, 231, 39, 231, 38, 231, 38, 231, + 146, 145, 231, 37, 39, 37, 39, 147, 37, 39, + 38, 39, 38, 39, 37, 39, 39, 231, 37, 39, + 231, 231, 39, 231, 37, 39, 39, 231, 148, 38, + 231, 38, 39, 231, 38, 149, 152, 231, 37, 39, + 38, 37, 39, 150, 38, 151, 39, 37, 39, 39, + 38, 37, 39, 37, 39, 39, 153, 37, 39, 39, + 231, 39, 231, 231, 38, 39, 231, 38, 158, 156, + 37, 39, 231, 38, 231, 231, 231, 38, 39, 38, + 231, 37, 39, 38, 231, 37, 39, 157, 159, 39, + + 37, 39, 162, 39, 231, 163, 38, 160, 39, 231, + 231, 37, 39, 231, 37, 39, 231, 38, 161, 39, + 231, 38, 39, 231, 37, 39, 38, 231, 167, 231, + 231, 165, 39, 37, 39, 164, 231, 38, 37, 39, + 38, 39, 231, 37, 39, 231, 39, 231, 166, 231, + 38, 39, 37, 39, 231, 37, 39, 37, 39, 38, + 39, 171, 231, 39, 38, 39, 170, 37, 39, 38, + 231, 172, 231, 231, 231, 39, 37, 39, 38, 231, + 173, 38, 231, 38, 39, 231, 231, 231, 37, 39, + 37, 39, 231, 38, 231, 174, 39, 231, 39, 37, + + 39, 231, 38, 37, 39, 175, 231, 39, 231, 231, + 231, 39, 176, 231, 38, 231, 38, 231, 37, 39, + 177, 178, 37, 39, 231, 38, 39, 231, 231, 38, + 39, 37, 39, 37, 39, 182, 231, 179, 231, 39, + 231, 39, 231, 231, 38, 37, 39, 231, 38, 231, + 37, 39, 183, 39, 37, 39, 231, 38, 39, 38, + 231, 231, 39, 231, 37, 39, 37, 39, 184, 37, + 39, 38, 39, 231, 39, 231, 38, 39, 231, 231, + 38, 191, 231, 185, 231, 37, 39, 231, 231, 231, + 38, 231, 38, 39, 231, 38, 187, 37, 39, 186, + + 37, 39, 37, 39, 188, 39, 37, 39, 39, 231, + 39, 38, 231, 231, 39, 231, 231, 192, 231, 37, + 39, 37, 39, 38, 231, 231, 38, 39, 38, 39, + 231, 231, 38, 231, 37, 39, 37, 39, 193, 231, + 194, 231, 39, 231, 39, 38, 231, 38, 231, 37, + 39, 195, 231, 37, 39, 231, 199, 39, 231, 196, + 38, 39, 38, 37, 39, 37, 39, 231, 231, 200, + 231, 39, 231, 39, 231, 38, 37, 39, 231, 38, + 201, 231, 37, 39, 39, 37, 39, 37, 39, 38, + 39, 38, 231, 39, 202, 39, 231, 205, 37, 39, + + 231, 231, 38, 208, 37, 39, 39, 231, 38, 37, + 39, 38, 39, 38, 206, 231, 207, 39, 37, 39, + 231, 231, 231, 231, 38, 231, 39, 231, 231, 211, + 38, 37, 39, 231, 231, 38, 231, 231, 212, 39, + 231, 213, 37, 39, 38, 231, 214, 37, 39, 231, + 39, 37, 39, 37, 39, 39, 231, 38, 231, 39, + 231, 39, 231, 231, 37, 39, 231, 217, 38, 231, + 218, 231, 39, 38, 37, 39, 231, 38, 219, 38, + 231, 231, 39, 37, 39, 231, 37, 39, 231, 231, + 38, 39, 231, 231, 39, 222, 223, 228, 231, 231, + + 38, 231, 231, 37, 39, 231, 225, 37, 39, 38, + 231, 39, 38, 231, 231, 39, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 226, 38, + 231, 231, 231, 38, 8, 8, 8, 8, 12, 12, + 12, 12, 40, 40, 40, 40, 42, 231, 42, 42, + 45, 45, 7, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, + + 231, 231, 231, 231 + } ; + +static yyconst short int yy_chk[1405] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 3, 3, 3, 14, 11, 70, 234, 70, + 3, 3, 14, 3, 3, 3, 3, 3, 15, 15, + 37, 18, 229, 227, 224, 220, 15, 216, 215, 18, + 3, 3, 11, 19, 19, 35, 35, 35, 35, 35, + 210, 19, 209, 204, 15, 18, 37, 203, 21, 21, + + 3, 4, 4, 4, 4, 198, 21, 197, 190, 19, + 4, 4, 46, 4, 4, 4, 4, 4, 20, 20, + 46, 19, 189, 181, 21, 180, 20, 169, 168, 155, + 4, 4, 154, 142, 20, 21, 46, 22, 22, 141, + 23, 23, 127, 126, 20, 22, 109, 108, 23, 89, + 4, 5, 5, 5, 5, 5, 20, 5, 5, 88, + 5, 5, 68, 22, 67, 22, 23, 24, 24, 25, + 25, 44, 23, 43, 40, 24, 38, 25, 26, 13, + 7, 5, 5, 0, 28, 28, 0, 0, 29, 29, + 0, 25, 28, 24, 0, 25, 29, 0, 0, 24, + + 0, 5, 6, 6, 6, 6, 6, 24, 6, 6, + 28, 6, 6, 0, 29, 0, 29, 30, 30, 31, + 31, 0, 28, 0, 0, 30, 0, 31, 0, 0, + 0, 0, 6, 6, 36, 36, 36, 36, 36, 0, + 0, 32, 32, 30, 0, 31, 0, 0, 0, 32, + 33, 33, 6, 17, 17, 30, 0, 31, 33, 0, + 0, 17, 17, 17, 17, 17, 17, 32, 0, 45, + 45, 0, 0, 32, 0, 0, 33, 45, 0, 17, + 0, 0, 33, 47, 47, 47, 47, 47, 0, 0, + 47, 48, 48, 49, 49, 45, 48, 0, 48, 48, + + 0, 49, 0, 50, 50, 0, 47, 51, 51, 0, + 0, 50, 0, 52, 52, 51, 0, 48, 0, 49, + 50, 52, 53, 53, 54, 54, 55, 55, 0, 50, + 53, 49, 54, 51, 55, 0, 51, 0, 0, 52, + 0, 56, 56, 0, 52, 0, 57, 57, 53, 56, + 54, 0, 55, 0, 57, 0, 0, 59, 59, 0, + 60, 60, 57, 54, 53, 59, 0, 56, 60, 56, + 0, 55, 57, 61, 61, 0, 0, 62, 62, 63, + 63, 61, 0, 59, 0, 62, 60, 63, 64, 64, + 65, 65, 65, 65, 65, 59, 64, 0, 0, 61, + + 0, 0, 60, 62, 0, 63, 66, 66, 66, 66, + 66, 62, 0, 61, 64, 0, 0, 0, 64, 69, + 69, 69, 69, 69, 63, 0, 69, 71, 71, 71, + 71, 71, 72, 72, 72, 72, 72, 73, 73, 74, + 74, 0, 69, 75, 75, 73, 0, 74, 76, 76, + 0, 75, 0, 77, 77, 0, 76, 0, 78, 78, + 0, 77, 0, 73, 0, 74, 78, 0, 0, 75, + 0, 0, 0, 0, 76, 79, 79, 73, 75, 77, + 76, 80, 80, 79, 78, 77, 78, 81, 81, 80, + 82, 82, 0, 77, 0, 81, 83, 83, 82, 0, + + 0, 79, 84, 84, 83, 0, 0, 80, 0, 0, + 84, 85, 85, 81, 0, 0, 82, 79, 80, 85, + 0, 0, 83, 86, 86, 87, 87, 0, 84, 0, + 82, 86, 0, 87, 0, 0, 83, 85, 84, 90, + 90, 90, 90, 90, 0, 0, 0, 0, 85, 86, + 0, 87, 91, 91, 91, 91, 91, 92, 92, 92, + 92, 92, 0, 0, 0, 86, 0, 87, 93, 93, + 93, 93, 93, 94, 94, 95, 95, 96, 96, 97, + 97, 94, 0, 95, 0, 96, 0, 97, 0, 98, + 98, 0, 99, 99, 100, 100, 0, 98, 0, 94, + + 99, 95, 100, 96, 94, 97, 0, 95, 101, 101, + 0, 0, 0, 102, 102, 98, 101, 0, 99, 97, + 100, 102, 96, 98, 0, 103, 103, 104, 104, 0, + 105, 105, 99, 103, 101, 104, 0, 100, 105, 102, + 106, 106, 107, 107, 102, 0, 0, 0, 106, 101, + 107, 103, 0, 104, 0, 104, 105, 0, 0, 103, + 110, 110, 110, 110, 110, 0, 106, 0, 107, 0, + 112, 112, 105, 111, 111, 111, 111, 111, 112, 0, + 107, 113, 113, 106, 114, 114, 115, 115, 0, 113, + 0, 0, 114, 0, 115, 113, 112, 116, 116, 0, + + 117, 117, 0, 0, 112, 116, 0, 113, 117, 0, + 114, 0, 115, 118, 118, 0, 114, 119, 119, 0, + 115, 118, 0, 116, 0, 119, 117, 0, 117, 120, + 120, 0, 121, 121, 0, 0, 0, 120, 0, 118, + 121, 0, 116, 119, 122, 122, 0, 120, 123, 123, + 119, 0, 122, 118, 0, 120, 123, 0, 121, 124, + 124, 125, 125, 128, 128, 129, 129, 124, 0, 125, + 122, 128, 0, 129, 123, 0, 0, 121, 0, 122, + 130, 130, 131, 131, 0, 124, 0, 125, 130, 128, + 131, 129, 0, 129, 132, 132, 133, 133, 0, 124, + + 128, 125, 132, 0, 133, 0, 130, 0, 131, 0, + 131, 130, 0, 134, 134, 135, 135, 132, 136, 136, + 132, 134, 133, 135, 137, 137, 136, 0, 138, 138, + 0, 0, 137, 0, 139, 139, 138, 0, 133, 134, + 0, 135, 139, 0, 136, 134, 138, 0, 140, 140, + 137, 143, 143, 135, 138, 136, 140, 144, 144, 143, + 139, 145, 145, 146, 146, 144, 139, 147, 147, 145, + 0, 146, 0, 0, 140, 147, 0, 143, 145, 143, + 148, 148, 0, 144, 0, 0, 0, 145, 148, 146, + 0, 149, 149, 147, 0, 150, 150, 144, 146, 149, + + 151, 151, 149, 150, 0, 149, 148, 147, 151, 0, + 0, 152, 152, 0, 153, 153, 0, 149, 148, 152, + 0, 150, 153, 0, 156, 156, 151, 0, 153, 0, + 0, 151, 156, 157, 157, 150, 0, 152, 159, 159, + 153, 157, 0, 158, 158, 0, 159, 0, 152, 0, + 156, 158, 160, 160, 0, 161, 161, 162, 162, 157, + 160, 157, 0, 161, 159, 162, 156, 163, 163, 158, + 0, 158, 0, 0, 0, 163, 164, 164, 160, 0, + 160, 161, 0, 162, 164, 0, 0, 0, 165, 165, + 166, 166, 0, 163, 0, 161, 165, 0, 166, 167, + + 167, 0, 164, 170, 170, 163, 0, 167, 0, 0, + 0, 170, 164, 0, 165, 0, 166, 0, 171, 171, + 165, 166, 172, 172, 0, 167, 171, 0, 0, 170, + 172, 173, 173, 174, 174, 170, 0, 167, 0, 173, + 0, 174, 0, 0, 171, 175, 175, 0, 172, 0, + 176, 176, 172, 175, 177, 177, 0, 173, 176, 174, + 0, 0, 177, 0, 178, 178, 179, 179, 173, 182, + 182, 175, 178, 0, 179, 0, 176, 182, 0, 0, + 177, 182, 0, 175, 0, 183, 183, 0, 0, 0, + 178, 0, 179, 183, 0, 182, 178, 184, 184, 177, + + 185, 185, 186, 186, 179, 184, 187, 187, 185, 0, + 186, 183, 0, 0, 187, 0, 0, 183, 0, 188, + 188, 191, 191, 184, 0, 0, 185, 188, 186, 191, + 0, 0, 187, 0, 192, 192, 193, 193, 184, 0, + 185, 0, 192, 0, 193, 188, 0, 191, 0, 194, + 194, 187, 0, 195, 195, 0, 192, 194, 0, 188, + 192, 195, 193, 196, 196, 199, 199, 0, 0, 193, + 0, 196, 0, 199, 0, 194, 200, 200, 0, 195, + 194, 0, 201, 201, 200, 202, 202, 205, 205, 196, + 201, 199, 0, 202, 196, 205, 0, 199, 206, 206, + + 0, 0, 200, 202, 207, 207, 206, 0, 201, 208, + 208, 202, 207, 205, 200, 0, 201, 208, 211, 211, + 0, 0, 0, 0, 206, 0, 211, 0, 0, 205, + 207, 212, 212, 0, 0, 208, 0, 0, 206, 212, + 0, 207, 213, 213, 211, 0, 208, 214, 214, 0, + 213, 217, 217, 218, 218, 214, 0, 212, 0, 217, + 0, 218, 0, 0, 219, 219, 0, 212, 213, 0, + 213, 0, 219, 214, 222, 222, 0, 217, 214, 218, + 0, 0, 222, 223, 223, 0, 225, 225, 0, 0, + 219, 223, 0, 0, 225, 218, 219, 225, 0, 0, + + 222, 0, 0, 226, 226, 0, 222, 228, 228, 223, + 0, 226, 225, 0, 0, 228, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 223, 226, + 0, 0, 0, 228, 232, 232, 232, 232, 233, 233, + 233, 233, 235, 235, 235, 235, 236, 0, 236, 236, + 237, 237, 231, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, + + 231, 231, 231, 231 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "scanner.l" +#define INITIAL 0 +#line 2 "scanner.l" +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "mynode.h" +#include "geometry.h" +#include "parser.hpp" +#include +int yyline=1; +#define cindex 1 + +#define def 2 + +#line 780 "scanner.cpp" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 30 "scanner.l" + +#line 933 "scanner.cpp" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 232 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 1353 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 31 "scanner.l" + + YY_BREAK +case 2: +YY_RULE_SETUP +#line 32 "scanner.l" +{ yyline++; } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 33 "scanner.l" +{ BEGIN def;return DEF; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 34 "scanner.l" +{ return COORDINATE3; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 35 "scanner.l" +{ return TEXTURE2; } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 36 "scanner.l" +{ return SEPARATOR; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 37 "scanner.l" +{ return UN_MATERIAL; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 38 "scanner.l" +{ return INDEXED_FACE_SET; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 39 "scanner.l" +{ return TEXTURE_COORDINATE; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 40 "scanner.l" +{ return TRANSFORM; } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 41 "scanner.l" +{ return MATRIX_TRANSFORM; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 42 "scanner.l" +{ return DOBLE_CARA; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 43 "scanner.l" +{ return MATRIX; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 44 "scanner.l" +{ return A_POINT; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 45 "scanner.l" +{ BEGIN cindex;return COORD_INDEX; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 46 "scanner.l" +{ BEGIN cindex;return TEXTURE_COORD_INDEX; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 47 "scanner.l" +{ BEGIN cindex;return NORMAL_INDEX; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 48 "scanner.l" +{ return VECTOR; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 49 "scanner.l" +{ return FINPOLY; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 50 "scanner.l" +{ BEGIN INITIAL; return ']'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 51 "scanner.l" +{ BEGIN def;return USE; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 52 "scanner.l" +{ return VRML_HEADER; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 53 "scanner.l" +{ return VRML_HEADER; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 54 "scanner.l" + + YY_BREAK +case 25: +YY_RULE_SETUP +#line 55 "scanner.l" +{ + yylval.f_value=strtod(yytext,NULL); + return FLOAT; +} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 59 "scanner.l" +{ + yylval.f_value=strtod(yytext,NULL); + return FLOAT; +} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 63 "scanner.l" +{ + yylval.f_value=strtod(yytext,NULL); + return FLOAT; +} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 67 "scanner.l" +{ + yylval.f_value=(float)strtol(yytext,NULL,10); + return FLOAT; +} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 71 "scanner.l" +{ + yylval.i_value=strtol(yytext,NULL,10); + return INT; +} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 75 "scanner.l" +{ return yytext[0]; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 76 "scanner.l" + + YY_BREAK +case 32: +YY_RULE_SETUP +#line 77 "scanner.l" +{ BEGIN INITIAL;yylval.s_value=strdup(yytext);return STRING; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 78 "scanner.l" +{ yylval.s_value=strdup(yytext+1);yylval.s_value[strlen(yylval.s_value)-1]=0;return QUOTED_STRING; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 80 "scanner.l" +ECHO; + YY_BREAK +#line 1201 "scanner.cpp" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(cindex): +case YY_STATE_EOF(def): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 232 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 232 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 231); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 80 "scanner.l" + + +int yywrap(void) +{ +return (1); +} diff --git a/src/osgPlugins/iv/scanner.l b/src/osgPlugins/iv/scanner.l new file mode 100644 index 000000000..620775bc4 --- /dev/null +++ b/src/osgPlugins/iv/scanner.l @@ -0,0 +1,85 @@ +%{ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "mynode.h" +#include "geometry.h" +#include "parser.hpp" +#include +int yyline=1; +%} + +DIGIT [0-9] +%x cindex +%x def +%% +[ \t\r,] +"\n" { yyline++; } +DEF { BEGIN def;return DEF; } +Coordinate3 { return COORDINATE3; } +Texture2 { return TEXTURE2; } +Separator { return SEPARATOR; } +Material { return UN_MATERIAL; } +IndexedFaceSet { return INDEXED_FACE_SET; } +TextureCoordinate2 { return TEXTURE_COORDINATE; } +Transform { return TRANSFORM; } +MatrixTransform { return MATRIX_TRANSFORM; } +DobleCara { return DOBLE_CARA; } +matrix { return MATRIX; } +point { return A_POINT; } +coordIndex { BEGIN cindex;return COORD_INDEX; } +textureCoordIndex { BEGIN cindex;return TEXTURE_COORD_INDEX; } +normalIndex { BEGIN cindex;return NORMAL_INDEX; } +vector { return VECTOR; } +-1 { return FINPOLY; } +\] { BEGIN INITIAL; return ']'; } +USE { BEGIN def;return USE; } +"#VRML\ V1.0 ascii" { return VRML_HEADER; } +"#Inventor\ V2.0 ascii" { return VRML_HEADER; } +#[^\n\r]* +"-"?{DIGIT}+"."{DIGIT}* { + yylval.f_value=strtod(yytext,NULL); + return FLOAT; +} +"-"?{DIGIT}+"."{DIGIT}*[Ee][\+-]{DIGIT}+ { + yylval.f_value=strtod(yytext,NULL); + return FLOAT; +} +"-"?{DIGIT}+[Ee][\+-]{DIGIT}+ { + yylval.f_value=strtod(yytext,NULL); + return FLOAT; +} +"-"?{DIGIT}+ { + yylval.f_value=(float)strtol(yytext,NULL,10); + return FLOAT; +} +"-"?{DIGIT}+ { + yylval.i_value=strtol(yytext,NULL,10); + return INT; +} +[,{}\[\]] { return yytext[0]; } +[a-zA-Z0-9\-\_\*]*\ *\[\] +[a-zA-Z0-9\-\_\*\!\.]* { BEGIN INITIAL;yylval.s_value=strdup(yytext);return STRING; } +\"[^\"]*\" { yylval.s_value=strdup(yytext+1);yylval.s_value[strlen(yylval.s_value)-1]=0;return QUOTED_STRING; } + +%% + +int yywrap(void) +{ +return (1); +} diff --git a/src/osgPlugins/iv/separator.h b/src/osgPlugins/iv/separator.h new file mode 100644 index 000000000..509d51762 --- /dev/null +++ b/src/osgPlugins/iv/separator.h @@ -0,0 +1,33 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __SEPARATOR_H__ +#define __SEPARATOR_H__ + +#include "mynode.h" + +class Separator: public MyNode { +public: + Separator() {} + Separator(MyNode *n): MyNode(n) {} + virtual char *type() { return "Separator"; } + virtual void accept(MyNodeVisitor *v) { v->applySeparator(this); } +}; + +#endif diff --git a/src/osgPlugins/iv/texture2.h b/src/osgPlugins/iv/texture2.h new file mode 100644 index 000000000..2a52015b9 --- /dev/null +++ b/src/osgPlugins/iv/texture2.h @@ -0,0 +1,33 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __TEXTURE2_H__ +#define __TEXTURE2_H__ + +#include "mynode.h" + +class Texture2: public MyNode { +public: + Texture2() {} + Texture2(MyNode *n): MyNode(n) {} + virtual char *type() { return "Texture2"; } + virtual void accept(MyNodeVisitor *v) { v->applyTexture2(this); } +}; + +#endif diff --git a/src/osgPlugins/iv/texturecoordinate.h b/src/osgPlugins/iv/texturecoordinate.h new file mode 100644 index 000000000..434e1dae8 --- /dev/null +++ b/src/osgPlugins/iv/texturecoordinate.h @@ -0,0 +1,37 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __TEXTURE_COORDINATE_H__ +#define __TEXTURE_COORDINATE_H__ + +#include "mynode.h" + +class TextureCoordinate: public MyNode { + TextureCoordList tcoords; +public: + TextureCoordinate() {} + TextureCoordinate(TextureCoordList *t) { + tcoords=*t; + } + virtual char *type() { return "TextureCoordinate"; } + virtual void accept(MyNodeVisitor *v) { v->applyTextureCoordinate(this); } + TextureCoordList getTextureCoords() { return tcoords; } +}; + +#endif diff --git a/src/osgPlugins/iv/transform.h b/src/osgPlugins/iv/transform.h new file mode 100644 index 000000000..1463ac1ff --- /dev/null +++ b/src/osgPlugins/iv/transform.h @@ -0,0 +1,33 @@ +/* + * osgDB::wrl - a VRML 1.0 loader for OpenSceneGraph + * Copyright (C) 2002 Ruben Lopez + * + * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __TRANSFORM_H__ +#define __TRANSFORM_H__ + +#include "mynode.h" + +class Transform: public MyNode { +public: + Transform() {} + Transform(MyNode *n): MyNode(n) {} + virtual char *type() { return "Transform"; } + virtual void accept(MyNodeVisitor *v) { v->applyTransform(this); } +}; + +#endif