lightspeed-1.2a/0000777000175000017500000000000007334276241007422 5lightspeed-1.2a/config/0000755000175000017500000000000007334276241010663 5lightspeed-1.2a/config/install-sh0000755000175000017500000001273607334275467012631 #!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 lightspeed-1.2a/config/missing0000755000175000017500000001421307334275467012214 #! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997 Free Software Foundation, Inc. # Franc,ois Pinard , 1996. # 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. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing - GNU libit 0.0" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; makeinfo) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 lightspeed-1.2a/config/mkinstalldirs0000755000175000017500000000132207334275467013420 #! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here lightspeed-1.2a/README0000644000175000017500000000677307325202133010220 ==== Light Speed! ==== DESCRIPTION This is a simulator designed to illustrate relativistic effects on the appearance of objects moving at ultra-high velocities. It simulates a geometrical lattice object traveling at a given speed in a straight line through space. Specifically, the object moves along the x-axis of this space, in the positive-x direction; at time t=0, the object is precisely centered on the origin. The simulator displays, in essence, a still image of the vicinity of the origin snapped at the exact moment that the object is *seen* to be at the origin; i.e. the moment that light reflected off the object, when the object was exactly at the origin (at t=0), eventually reaches the camera. This moment will usually be a few billionths of a second after t=0, accounting for the time needed for the light to traverse this distance. (The camera's info display will explicitly indicate the time of the snapshot, to 0.001 microsecond accuracy). Light Speed! will allow you to move around and see interactively how the object appears to change with observer position. At low velocities, this isn't much the case, but up in the several-million-meters-per-second range, the object as viewed from one angle to another can vary significantly. To get started, drag the slider at the right of the window upward. Relativistic effects will immediately become noticeable. Click and drag in the graphics window to move around. CONTROLS Most interactive control is performed with the mouse. By holding down a particular button, and dragging the pointer around, various camera motions can be obtained: Left button: Revolve camera around view target Shift key + Left button: Revolve view target around camera Middle button: Translate camera left, right, up or down Right button: Dolly in or out The first and last motions are generally the most useful. Should the camera become difficult to control at any point, it may be re-initialized by selecting Camera -> Reset View. THEORY Light Speed! takes into account the following consequences of special relativity: 1. Lorentz contraction (fast objects appear shorter) 2. Doppler red/blue shift (the Doppler effect on light/color) 3. Headlight effect (redistribution of reflected light) 4. Optical aberration (warping due to the finite speed of light) A lengthier treatment of the above phenomena, complete with the formulae used (really, they're not that bad!) may be found in the file MATH. LIMITATIONS The only major weakness of this simulator is color. The Doppler shifts produced are only approximations, and in certain cases may be wildly inaccurate. If color fidelity is a must, Antony Searle's BACKLIGHT raytracer program may be a better choice. (See the Acknowledgements section below for details). REQUIREMENTS Light Speed! requires the X Window System with OpenGL or Mesa3D support, as well as the GTK+ libraries to function. Compilation will additionally need Janne Lof's GtkGLArea widget. See the file INSTALL for details. ACKNOWLEDGEMENTS I would like to thank Antony Searle, of the Australian National University, for allowing me to make use of the Doppler-shift code from his well-received relativistic raytracer, BACKLIGHT. This program illustrates relativistic effects via a four-dimensional raytracing engine, and I highly recommend it in case greater scientific rigor or creative flexibility is desired. You may find it at: http://www.anu.edu.au/Physics/Searle/ ========================================= Daniel Richard G. // lightspeed-1.2a/stamp-h.in0000644000175000017500000000000007334275467011236 lightspeed-1.2a/AUTHORS0000644000175000017500000000004707325175354010412 Daniel Richard G. lightspeed-1.2a/COPYING0000644000175000017500000006347407325175422010406 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 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 Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 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! lightspeed-1.2a/ChangeLog0000644000175000017500000000373707325202756011122 1.3 (?? July 2001) ------------------ * Project moved to SourceForge. * Updated documentation (e-mail addresses, links, writing style, etc.) 1.2 (24 April 1999) ------------------- * Added keybindings for most operations. Those GtkAccelerator functions really need better documentation. * Upgraded profiler to calculate framerate using a variable-length frametime buffer. The fps readout shouldn't fluctuate so wildly anymore on super-fast hardware. * Small fix to velocity_entry( ) so that commas are also added when velocity units are changed. * Small changes to set_entry_width( ) and some GtkEntry handling. * Updated gtkgl interface to use the newer API. (Note: compat.h maintains older GtkGLArea compatibility) * More configure script fixes. 1.1 (14 April 1999) ------------------- * Added a vertical slider for velocity control. Thanks go to Stijn Buys for [being the first to send in] this excellent suggestion! * Added kilometers/hour velocity units, and removed kilometers/second (km/s was kind of redundant anyway) * Moved all language-specific program strings into lstrings.c. Light Speed! is ready to go international! (Please contact me if you wish to do translations, I will greatly appreciate it) * TIFF exporter fixed. (no segfaults! yay!) * Added heuristic for calculating camera distance when specifying its position with xyz/angles. This needs field testing; any opinions? * Remade title.xpm (for the About dialog), toning down the glow a bit. (you see, I have a *really dark* monitor :-) * Modified break_transition( ) and related code in transition_engine( ) to work more efficiently (was causing problems with the velocity slider) * Exported time-string generation code from infodisp.c to misc.c. This whole bit is all in time_string( ) now. * configure script fixes. Test for libpng now leaves off the -lgtkgl; a few other rough edges filed down too. Should I add a prefix option for libpng, libtiff, et. al.? 1.0 (4 April 1999) ------------------ * Initial release. lightspeed-1.2a/INSTALL0000644000175000017500000001552107325201015010356 ==== Light Speed! installation ==== Program requirements: * GTK+ 1.0.1 or newer * OpenGL/Mesa3D libraries * GtkGLArea widget (gtkgl) Optional: * libpng * libtiff Where to obtain the above: * GTK+ ftp://ftp.gtk.org/pub/gtk/v1.2/ * Mesa3D http://sourceforge.net/projects/mesa3d * GtkGLArea http://www.student.oulu.fi/~jlof/gtkglarea/download/ * libpng http://www.libpng.org/pub/png/libpng.html (needs zlib) http://www.gzip.org/zlib/ * libtiff http://www.libtiff.org/ Installation procedure ====================== 1. Run 'configure' with any desired options. (If you are unfamiliar with Autoconf scripts, see the "Basic Installation" section below) 2. If you would like to customize certain aspects of the program, edit 'settings.h'. ('globals.c' too, if that isn't enough) 3. Run 'make'. 4. Run 'make install' to install the program. Basic Installation ================== (generic instructions for the uninitiated) The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. lightspeed-1.2a/Makefile.am0000644000175000017500000000027307334274717011402 # Makefile.am SUBDIRS = src CONFIG_FILES = \ config/install-sh \ config/missing \ config/mkinstalldirs EXTRA_DIST = \ MATH \ lightspeed.spec \ $(CONFIG_FILES) # end Makefile.am lightspeed-1.2a/Makefile.in0000644000175000017500000002526307334276114011412 # Makefile.in generated automatically by automake 1.4-p4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # Makefile.am SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ CPP = @CPP@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_CONFIG = @GTK_CONFIG@ GTK_LIBS = @GTK_LIBS@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ SUBDIRS = src CONFIG_FILES = config/install-sh config/missing config/mkinstalldirs EXTRA_DIST = MATH lightspeed.spec $(CONFIG_FILES) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ Makefile.am Makefile.in NEWS TODO acconfig.h aclocal.m4 config.h.in \ configure configure.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) config.h: stamp-h @if test ! -f $@; then \ rm -f stamp-h; \ $(MAKE) stamp-h; \ else :; fi stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES= CONFIG_HEADERS=config.h \ $(SHELL) ./config.status @echo timestamp > stamp-h 2> /dev/null $(srcdir)/config.h.in: $(srcdir)/stamp-h.in @if test ! -f $@; then \ rm -f $(srcdir)/stamp-h.in; \ $(MAKE) $(srcdir)/stamp-h.in; \ else :; fi $(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h cd $(top_srcdir) && $(AUTOHEADER) @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null mostlyclean-hdr: clean-hdr: distclean-hdr: -rm -f config.h maintainer-clean-hdr: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. @SET_MAKE@ all-recursive install-data-recursive install-exec-recursive \ installdirs-recursive install-recursive uninstall-recursive \ check-recursive installcheck-recursive info-recursive dvi-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ dot_seen=no; \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev="$$subdir $$rev"; \ test "$$subdir" = "." && dot_seen=yes; \ done; \ test "$$dot_seen" = "no" && rev=". $$rev"; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist -rm -rf $(distdir) GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz mkdir $(distdir)/=build mkdir $(distdir)/=inst dc_install_base=`cd $(distdir)/=inst && pwd`; \ cd $(distdir)/=build \ && ../configure --srcdir=.. --prefix=$$dc_install_base \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) dist -rm -rf $(distdir) @banner="$(distdir).tar.gz is ready for distribution"; \ dashes=`echo "$$banner" | sed s/./=/g`; \ echo "$$dashes"; \ echo "$$banner"; \ echo "$$dashes" dist: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) dist-all: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) distdir: $(DISTFILES) -rm -rf $(distdir) mkdir $(distdir) -chmod 777 $(distdir) $(mkinstalldirs) $(distdir)/config @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done for subdir in $(SUBDIRS); do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ chmod 777 $(distdir)/$$subdir; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ || exit 1; \ fi; \ done info-am: info: info-recursive dvi-am: dvi: dvi-recursive check-am: all-am check: check-recursive installcheck-am: installcheck: installcheck-recursive all-recursive-am: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive install-exec-am: install-exec: install-exec-recursive install-data-am: install-data: install-data-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-recursive uninstall-am: uninstall: uninstall-recursive all-am: Makefile config.h all-redirect: all-recursive-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: installdirs-recursive installdirs-am: mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-recursive clean-am: clean-hdr clean-tags clean-generic mostlyclean-am clean: clean-recursive distclean-am: distclean-hdr distclean-tags distclean-generic clean-am distclean: distclean-recursive -rm -f config.status maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-recursive -rm -f config.status .PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ install-data-recursive uninstall-data-recursive install-exec-recursive \ uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ all-recursive check-recursive installcheck-recursive info-recursive \ dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ install-exec-am install-exec install-data-am install-data install-am \ install uninstall-am uninstall all-redirect all-am all installdirs-am \ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # end Makefile.am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: lightspeed-1.2a/NEWS0000644000175000017500000000002507176115553010034 http://slashdot.org/ lightspeed-1.2a/TODO0000644000175000017500000000154407176115553010034 BUG:importobjs.c: triangulate_polygon( ) does not work properly. Some LightWave models may get a wee bit mangled... BUG:menu_cbs.c: highlight_entry( ) does not work after a set_entry_text( ) (appears to be a bug in GTK+, I've sent in a report) BUG:menu_cbs.c: Dialogs do not hide properly before viewport is blanked (e.g. when generating a lattice, or loading a file. The dialog either leaves a lovely grey rectangle on the viewport, or doesn't hide at all until too late :P ) Not sure how to fix this. BUG:menu_cbs.c: Velocity input entry should have automagically inserted commas. gtk_entry_set_position( ) isn't cooperating, however :( TODO: Anyone want to translate lstrings.c? E-mail me if so, I will appreciate it greatly! TODO: Note in docs that Lorentz contraction / optical aberration toggles have no effect on exported SRS file lightspeed-1.2a/acconfig.h0000644000175000017500000000011707334275452011262 /* acconfig.h */ #undef HAVE_LIBPNG #undef HAVE_LIBTIFF /* end acconfig.h */ lightspeed-1.2a/aclocal.m40000644000175000017500000003061507334275463011210 dnl aclocal.m4 generated automatically by aclocal 1.4-p4 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN(AM_CONFIG_HEADER, [AC_PREREQ([2.12]) AC_CONFIG_HEADER([$1]) dnl When config.status generates a header, we must update the stamp-h file. dnl This file resides in the same directory as the config header dnl that is generated. We must strip everything past the first ":", dnl and everything past the last "/". AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, <>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, <>; do case " <<$>>CONFIG_HEADERS " in *" <<$>>am_file "*<<)>> echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx ;; esac am_indx=`expr "<<$>>am_indx" + 1` done<<>>dnl>>) changequote([,]))]) # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. # serial 1 dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) AC_DEFUN(AM_INIT_AUTOMAKE, [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) VERSION=[$2] AC_SUBST(VERSION) dnl test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi ifelse([$3],, AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) AC_REQUIRE([AM_SANITY_CHECK]) AC_REQUIRE([AC_ARG_PROGRAM]) dnl FIXME This is truly gross. missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_REQUIRE([AC_PROG_MAKE_SET])]) # # Check to make sure that the build environment is sane. # AC_DEFUN(AM_SANITY_CHECK, [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "[$]*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "[$]*" != "X $srcdir/configure conftestfile" \ && test "[$]*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "[$]2" = conftestfile ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi rm -f conftest* AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. AC_DEFUN(AM_MISSING_PROG, [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if ($2 --version) < /dev/null > /dev/null 2>&1; then $1=$2 AC_MSG_RESULT(found) else $1="$3/missing $2" AC_MSG_RESULT(missing) fi AC_SUBST($1)]) # Configure paths for GTK+ # Owen Taylor 97-11-3 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS dnl AC_DEFUN(AM_PATH_GTK, [dnl dnl Get the cflags and libraries from the gtk-config script dnl AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)], gtk_config_prefix="$withval", gtk_config_prefix="") AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)], gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="") AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program], , enable_gtktest=yes) for module in . $4 do case "$module" in gthread) gtk_config_args="$gtk_config_args gthread" ;; esac done if test x$gtk_config_exec_prefix != x ; then gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix" if test x${GTK_CONFIG+set} != xset ; then GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config fi fi if test x$gtk_config_prefix != x ; then gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix" if test x${GTK_CONFIG+set} != xset ; then GTK_CONFIG=$gtk_config_prefix/bin/gtk-config fi fi AC_PATH_PROG(GTK_CONFIG, gtk-config, no) min_gtk_version=ifelse([$1], ,0.99.7,$1) AC_MSG_CHECKING(for GTK - version >= $min_gtk_version) no_gtk="" if test "$GTK_CONFIG" = "no" ; then no_gtk=yes else GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_gtktest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$GTK_LIBS $LIBS" dnl dnl Now check if the installed GTK is sufficiently new. (Also sanity dnl checks the results of gtk-config to some extent dnl rm -f conf.gtktest AC_TRY_RUN([ #include #include #include int main () { int major, minor, micro; char *tmp_version; system ("touch conf.gtktest"); /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = g_strdup("$min_gtk_version"); if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_gtk_version"); exit(1); } if ((gtk_major_version != $gtk_config_major_version) || (gtk_minor_version != $gtk_config_minor_version) || (gtk_micro_version != $gtk_config_micro_version)) { printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, gtk_major_version, gtk_minor_version, gtk_micro_version); printf ("*** was found! If gtk-config was correct, then it is best\n"); printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); printf("*** required on your system.\n"); printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n"); printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); printf("*** before re-running configure\n"); } #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION) else if ((gtk_major_version != GTK_MAJOR_VERSION) || (gtk_minor_version != GTK_MINOR_VERSION) || (gtk_micro_version != GTK_MICRO_VERSION)) { printf("*** GTK+ header files (version %d.%d.%d) do not match\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); printf("*** library (version %d.%d.%d)\n", gtk_major_version, gtk_minor_version, gtk_micro_version); } #endif /* defined (GTK_MAJOR_VERSION) ... */ else { if ((gtk_major_version > major) || ((gtk_major_version == major) && (gtk_minor_version > minor)) || ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) { return 0; } else { printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", gtk_major_version, gtk_minor_version, gtk_micro_version); printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", major, minor, micro); printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n"); printf("***\n"); printf("*** If you have already installed a sufficiently new version, this error\n"); printf("*** probably means that the wrong copy of the gtk-config shell script is\n"); printf("*** being found. The easiest way to fix this is to remove the old version\n"); printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n"); printf("*** correct copy of gtk-config. (In this case, you will have to\n"); printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); printf("*** so that the correct libraries are found at run-time))\n"); } } return 1; } ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_gtk" = x ; then AC_MSG_RESULT(yes) ifelse([$2], , :, [$2]) else AC_MSG_RESULT(no) if test "$GTK_CONFIG" = "no" ; then echo "*** The gtk-config script installed by GTK could not be found" echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the GTK_CONFIG environment variable to the" echo "*** full path to gtk-config." else if test -f conf.gtktest ; then : else echo "*** Could not run GTK test program, checking why..." CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" AC_TRY_LINK([ #include #include ], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GTK or finding the wrong" echo "*** version of GTK. If it is not finding GTK, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" echo "***" echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that" echo "*** came with the system with the command" echo "***" echo "*** rpm --erase --nodeps gtk gtk-devel" ], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means GTK was incorrectly installed" echo "*** or that you have moved GTK since it was installed. In the latter case, you" echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi GTK_CFLAGS="" GTK_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) rm -f conf.gtktest ]) lightspeed-1.2a/config.h.in0000644000175000017500000000371207334275465011373 /* config.h.in. Generated automatically from configure.in by autoheader. */ /* acconfig.h */ #undef HAVE_LIBPNG #undef HAVE_LIBTIFF /* end acconfig.h */ /* Define if you have the header file. */ #undef HAVE_GETOPT_H /* Define if you have the `getopt_long' function. */ #undef HAVE_GETOPT_LONG /* Define if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define if you have the header file. */ #undef HAVE_INTTYPES_H /* Define if you have the `GL' library (-lGL). */ #undef HAVE_LIBGL /* Define if you have the `gtkgl' library (-lgtkgl). */ #undef HAVE_LIBGTKGL /* Define if you have the header file. */ #undef HAVE_MALLOC_H /* Define if you have the header file. */ #undef HAVE_MEMORY_H /* Define if you have the header file. */ #undef HAVE_STDINT_H /* Define if you have the header file. */ #undef HAVE_STDLIB_H /* Define if you have the `strcspn' function. */ #undef HAVE_STRCSPN /* Define if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define if you have the header file. */ #undef HAVE_STRINGS_H /* Define if you have the header file. */ #undef HAVE_STRING_H /* Define if you have the `strtod' function. */ #undef HAVE_STRTOD /* Define if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define if you have the header file. */ #undef HAVE_UNISTD_H /* Name of package */ #undef PACKAGE /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `unsigned' if does not define. */ #undef size_t lightspeed-1.2a/configure0000755000175000017500000042630607334275467011271 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by Autoconf 2.52. # # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Sed expression to map a string onto a valid variable name. as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # Name of the executable. as_me=`echo "$0" |sed 's,.*[\\/],,'` if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file as_executable_p="test -f" # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # NLS nuisances. $as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } $as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } $as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } $as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : ${ac_max_here_lines=38} ac_unique_file="src/lightspeed.c" # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #endif" # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. build=$build_alias host=$host_alias target=$target_alias # FIXME: should be removed in autoconf 3.0. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat < if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. EOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue cd $ac_subdir # A "../" for each directory in /$ac_subdir. ac_dots=`echo $ac_subdir | sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'` case $srcdir in .) # No --srcdir option. We are building in place. ac_sub_srcdir=$srcdir ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_sub_srcdir=$srcdir/$ac_subdir ;; *) # Relative path. ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;; esac # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_sub_srcdir/configure.gnu; then echo $SHELL $ac_sub_srcdir/configure.gnu --help=recursive elif test -f $ac_sub_srcdir/configure; then echo $SHELL $ac_sub_srcdir/configure --help=recursive elif test -f $ac_sub_srcdir/configure.ac || test -f $ac_sub_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2 fi cd $ac_popdir done fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\EOF Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. EOF exit 0 fi exec 5>config.log cat >&5 </dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` PATH = $PATH _ASUNAME } >&5 cat >&5 <\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" ac_sep=" " ;; *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg" ac_sep=" " ;; esac # Get rid of the leading space. done # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. trap 'exit_status=$? # Save into config.log some information that might help in debugging. echo >&5 echo "## ----------------- ##" >&5 echo "## Cache variables. ##" >&5 echo "## ----------------- ##" >&5 echo >&5 # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } >&5 sed "/^$/d" confdefs.h >conftest.log if test -s conftest.log; then echo >&5 echo "## ------------ ##" >&5 echo "## confdefs.h. ##" >&5 echo "## ------------ ##" >&5 echo >&5 cat conftest.log >&5 fi (echo; echo) >&5 test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" >&5 echo "$as_me: exit $exit_status" >&5 rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:873: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} cat "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:884: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:892: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:908: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:912: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:918: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:920: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:922: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. It doesn't matter if # we pass some twice (in addition to the command line arguments). if test "$ac_new_set" = set; then case $ac_new_val in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:941: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:943: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac echo "#! $SHELL" >conftest.sh echo "exit 0" >>conftest.sh chmod +x conftest.sh if { (echo "$as_me:963: PATH=\".;.\"; conftest.sh") >&5 (PATH=".;."; conftest.sh) 2>&5 ac_status=$? echo "$as_me:966: \$? = $ac_status" >&5 (exit $ac_status); }; then ac_path_separator=';' else ac_path_separator=: fi PATH_SEPARATOR="$ac_path_separator" rm -f conftest.sh ac_aux_dir= for ac_dir in config $srcdir/config; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f $ac_dir/shtool; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:992: error: cannot find install-sh or install.sh in config $srcdir/config" >&5 echo "$as_me: error: cannot find install-sh or install.sh in config $srcdir/config" >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. ac_config_headers="$ac_config_headers config.h" ac_config_commands="$ac_config_commands default-1" LIGHTSPEED_VERSION_MAJOR=1 LIGHTSPEED_VERSION_MINOR=2a LIGHTSPEED_VERSION=$LIGHTSPEED_VERSION_MAJOR.$LIGHTSPEED_VERSION_MINOR # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:1020: checking for a BSD compatible install" >&5 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_IFS=$IFS; IFS=$ac_path_separator for ac_dir in $PATH; do IFS=$ac_save_IFS # Account for people who put trailing slashes in PATH elements. case $ac_dir/ in / | ./ | .// | /cC/* \ | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \ | /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if $as_executable_p "$ac_dir/$ac_prog"; then if test $ac_prog = install && grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:1069: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo "$as_me:1080: checking whether build environment is sane" >&5 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "$*" != "X $srcdir/configure conftestfile" \ && test "$*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { { echo "$as_me:1103: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&2;} { (exit 1); exit 1; }; } fi test "$2" = conftestfile ) then # Ok. : else { { echo "$as_me:1116: error: newly created file is older than distributed files! Check your system clock" >&5 echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest* echo "$as_me:1123: result: yes" >&5 echo "${ECHO_T}yes" >&6 test "$program_prefix" != NONE && program_transform_name="s,^,$program_prefix,;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s,\$,$program_suffix,;$program_transform_name" # Double any \ or $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed s/[\\$]/&&/g;s/;s,x,x,$// _ACEOF program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm conftest.sed echo "$as_me:1138: checking whether ${MAKE-make} sets \${MAKE}" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\EOF all: @echo 'ac_maketemp="${MAKE}"' EOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$as_me:1158: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else echo "$as_me:1162: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi PACKAGE=lightspeed VERSION=$LIGHTSPEED_VERSION if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { { echo "$as_me:1172: error: source directory already configured; run \"make distclean\" there first" >&5 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } fi cat >>confdefs.h <>confdefs.h <&5 echo $ECHO_N "checking for working aclocal... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (aclocal --version) < /dev/null > /dev/null 2>&1; then ACLOCAL=aclocal echo "$as_me:1193: result: found" >&5 echo "${ECHO_T}found" >&6 else ACLOCAL="$missing_dir/missing aclocal" echo "$as_me:1197: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi echo "$as_me:1201: checking for working autoconf" >&5 echo $ECHO_N "checking for working autoconf... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoconf --version) < /dev/null > /dev/null 2>&1; then AUTOCONF=autoconf echo "$as_me:1208: result: found" >&5 echo "${ECHO_T}found" >&6 else AUTOCONF="$missing_dir/missing autoconf" echo "$as_me:1212: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi echo "$as_me:1216: checking for working automake" >&5 echo $ECHO_N "checking for working automake... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (automake --version) < /dev/null > /dev/null 2>&1; then AUTOMAKE=automake echo "$as_me:1223: result: found" >&5 echo "${ECHO_T}found" >&6 else AUTOMAKE="$missing_dir/missing automake" echo "$as_me:1227: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi echo "$as_me:1231: checking for working autoheader" >&5 echo $ECHO_N "checking for working autoheader... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoheader --version) < /dev/null > /dev/null 2>&1; then AUTOHEADER=autoheader echo "$as_me:1238: result: found" >&5 echo "${ECHO_T}found" >&6 else AUTOHEADER="$missing_dir/missing autoheader" echo "$as_me:1242: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi echo "$as_me:1246: checking for working makeinfo" >&5 echo $ECHO_N "checking for working makeinfo... $ECHO_C" >&6 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (makeinfo --version) < /dev/null > /dev/null 2>&1; then MAKEINFO=makeinfo echo "$as_me:1253: result: found" >&5 echo "${ECHO_T}found" >&6 else MAKEINFO="$missing_dir/missing makeinfo" echo "$as_me:1257: result: missing" >&5 echo "${ECHO_T}missing" >&6 fi # Check for programs # echo "$as_me:1263: checking whether build environment is sane" >&5 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "$*" != "X $srcdir/configure conftestfile" \ && test "$*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { { echo "$as_me:1286: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&2;} { (exit 1); exit 1; }; } fi test "$2" = conftestfile ) then # Ok. : else { { echo "$as_me:1299: error: newly created file is older than distributed files! Check your system clock" >&5 echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest* echo "$as_me:1306: result: yes" >&5 echo "${ECHO_T}yes" >&6 # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:1320: checking for a BSD compatible install" >&5 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_IFS=$IFS; IFS=$ac_path_separator for ac_dir in $PATH; do IFS=$ac_save_IFS # Account for people who put trailing slashes in PATH elements. case $ac_dir/ in / | ./ | .// | /cC/* \ | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \ | /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if $as_executable_p "$ac_dir/$ac_prog"; then if test $ac_prog = install && grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:1369: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:1388: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:1403: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1411: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:1414: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:1423: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:1438: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:1446: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:1449: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:1462: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:1477: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1485: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:1488: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:1497: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="cc" echo "$as_me:1512: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:1520: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:1523: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:1536: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:1556: found $ac_dir/$ac_word" >&5 break done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" ${1+"$@"} shift ac_cv_prog_CC="$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1578: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:1581: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:1592: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:1607: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1615: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:1618: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:1631: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:1646: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:1654: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:1657: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:1669: error: no acceptable cc found in \$PATH" >&5 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:1674:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:1677: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:1680: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:1682: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:1685: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:1687: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:1690: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF #line 1694 "configure" #include "confdefs.h" int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:1710: checking for C compiler default output" >&5 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:1713: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:1716: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. for ac_file in `ls a.exe conftest.exe 2>/dev/null; ls a.out conftest 2>/dev/null; ls a.* conftest.* 2>/dev/null`; do case $ac_file in *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; a.out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 { { echo "$as_me:1739: error: C compiler cannot create executables" >&5 echo "$as_me: error: C compiler cannot create executables" >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:1745: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:1750: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:1756: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1759: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:1766: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:1774: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:1781: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:1783: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:1786: checking for executable suffix" >&5 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 if { (eval echo "$as_me:1788: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:1791: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:1807: error: cannot compute EXEEXT: cannot compile and link" >&5 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext echo "$as_me:1813: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:1819: checking for object suffix" >&5 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 1825 "configure" #include "confdefs.h" int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:1837: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1840: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 { { echo "$as_me:1852: error: cannot compute OBJEXT: cannot compile" >&5 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi echo "$as_me:1859: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:1863: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 1869 "configure" #include "confdefs.h" int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:1884: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1887: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:1890: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1893: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:1905: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:1911: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 1917 "configure" #include "confdefs.h" int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:1929: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1932: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:1935: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1938: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:1948: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >conftest.$ac_ext <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:1975: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1978: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:1981: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1984: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ ''\ '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF #line 1996 "configure" #include "confdefs.h" #include $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:2009: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2012: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:2015: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2018: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 continue fi rm -f conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF #line 2028 "configure" #include "confdefs.h" $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:2040: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2043: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:2046: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2049: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:2081: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF #line 2102 "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:2107: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2113: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF #line 2136 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:2140: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2146: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi echo "$as_me:2183: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF #line 2193 "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:2198: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2204: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF #line 2227 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:2231: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2237: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:2265: error: C preprocessor \"$CPP\" fails sanity check" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Check for header files # echo "$as_me:2279: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 2285 "configure" #include "confdefs.h" #include #include #include #include _ACEOF if { (eval echo "$as_me:2293: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2299: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.err conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF #line 2321 "configure" #include "confdefs.h" #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF #line 2339 "configure" #include "confdefs.h" #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF #line 2360 "configure" #include "confdefs.h" #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:2386: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:2389: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:2391: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2394: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:2407: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi for ac_header in getopt.h malloc.h sys/time.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:2420: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 2426 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF if { (eval echo "$as_me:2430: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2436: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_ext fi echo "$as_me:2455: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF #line 2475 "configure" #include "confdefs.h" #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX 10.20 and later -Ae # HP-UX older versions -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:2524: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2527: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:2530: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2533: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi case "x$ac_cv_prog_cc_stdc" in x|xno) echo "$as_me:2550: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) echo "$as_me:2553: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac echo "$as_me:2558: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 2564 "configure" #include "confdefs.h" int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset x; /* SunOS 4.1.1 cc rejects this. */ char const *const *ccp; char **p; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; ccp = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++ccp; p = (char**) ccp; ccp = (char const *const *) p; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:2622: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2625: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:2628: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2631: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:2641: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6 if test $ac_cv_c_const = no; then cat >>confdefs.h <<\EOF #define const EOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:2657: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 2663 "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:2669: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2672: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:2675: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2678: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:2688: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for size_t... $ECHO_C" >&6 if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 2704 "configure" #include "confdefs.h" $ac_includes_default int main () { if ((size_t *) 0) return 0; if (sizeof (size_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:2719: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2722: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:2725: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2728: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_type_size_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:2738: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6 if test $ac_cv_type_size_t = yes; then : else cat >>confdefs.h <&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 2756 "configure" #include "confdefs.h" #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:2772: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2775: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:2778: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2781: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:2791: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6 if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\EOF #define TIME_WITH_SYS_TIME 1 EOF fi # Check for library functions # for ac_func in getopt_long gettimeofday strcspn strdup strtod do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:2807: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 2813 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); char (*f) (); int main () { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else f = $ac_func; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:2844: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:2847: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:2850: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2853: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:2863: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_GTK_CONFIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $GTK_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_GTK_CONFIG="$GTK_CONFIG" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_GTK_CONFIG="$ac_dir/$ac_word" echo "$as_me:2940: found $ac_dir/$ac_word" >&5 break fi done test -z "$ac_cv_path_GTK_CONFIG" && ac_cv_path_GTK_CONFIG="no" ;; esac fi GTK_CONFIG=$ac_cv_path_GTK_CONFIG if test -n "$GTK_CONFIG"; then echo "$as_me:2952: result: $GTK_CONFIG" >&5 echo "${ECHO_T}$GTK_CONFIG" >&6 else echo "$as_me:2955: result: no" >&5 echo "${ECHO_T}no" >&6 fi min_gtk_version=1.0.1 echo "$as_me:2960: checking for GTK - version >= $min_gtk_version" >&5 echo $ECHO_N "checking for GTK - version >= $min_gtk_version... $ECHO_C" >&6 no_gtk="" if test "$GTK_CONFIG" = "no" ; then no_gtk=yes else GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` if test "x$enable_gtktest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$GTK_LIBS $LIBS" rm -f conf.gtktest if test "$cross_compiling" = yes; then echo $ac_n "cross compiling; assumed OK... $ac_c" else cat >conftest.$ac_ext <<_ACEOF #line 2984 "configure" #include "confdefs.h" #include #include #include int main () { int major, minor, micro; char *tmp_version; system ("touch conf.gtktest"); /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = g_strdup("$min_gtk_version"); if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_gtk_version"); exit(1); } if ((gtk_major_version != $gtk_config_major_version) || (gtk_minor_version != $gtk_config_minor_version) || (gtk_micro_version != $gtk_config_micro_version)) { printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, gtk_major_version, gtk_minor_version, gtk_micro_version); printf ("*** was found! If gtk-config was correct, then it is best\n"); printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); printf("*** required on your system.\n"); printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n"); printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); printf("*** before re-running configure\n"); } #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION) else if ((gtk_major_version != GTK_MAJOR_VERSION) || (gtk_minor_version != GTK_MINOR_VERSION) || (gtk_micro_version != GTK_MICRO_VERSION)) { printf("*** GTK+ header files (version %d.%d.%d) do not match\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); printf("*** library (version %d.%d.%d)\n", gtk_major_version, gtk_minor_version, gtk_micro_version); } #endif /* defined (GTK_MAJOR_VERSION) ... */ else { if ((gtk_major_version > major) || ((gtk_major_version == major) && (gtk_minor_version > minor)) || ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) { return 0; } else { printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", gtk_major_version, gtk_minor_version, gtk_micro_version); printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", major, minor, micro); printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n"); printf("***\n"); printf("*** If you have already installed a sufficiently new version, this error\n"); printf("*** probably means that the wrong copy of the gtk-config shell script is\n"); printf("*** being found. The easiest way to fix this is to remove the old version\n"); printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n"); printf("*** correct copy of gtk-config. (In this case, you will have to\n"); printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); printf("*** so that the correct libraries are found at run-time))\n"); } } return 1; } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:3063: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3066: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:3068: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3071: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 no_gtk=yes fi rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_gtk" = x ; then echo "$as_me:3087: result: yes" >&5 echo "${ECHO_T}yes" >&6 : else echo "$as_me:3091: result: no" >&5 echo "${ECHO_T}no" >&6 if test "$GTK_CONFIG" = "no" ; then echo "*** The gtk-config script installed by GTK could not be found" echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the GTK_CONFIG environment variable to the" echo "*** full path to gtk-config." else if test -f conf.gtktest ; then : else echo "*** Could not run GTK test program, checking why..." CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" cat >conftest.$ac_ext <<_ACEOF #line 3106 "configure" #include "confdefs.h" #include #include int main () { return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:3121: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3124: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:3127: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3130: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GTK or finding the wrong" echo "*** version of GTK. If it is not finding GTK, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" echo "***" echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that" echo "*** came with the system with the command" echo "***" echo "*** rpm --erase --nodeps gtk gtk-devel" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means GTK was incorrectly installed" echo "*** or that you have moved GTK since it was installed. In the latter case, you" echo "*** may want to edit the gtk-config script: $GTK_CONFIG" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi GTK_CFLAGS="" GTK_LIBS="" { { echo "$as_me:3161: error: Cannot find proper GTK+ version" >&5 echo "$as_me: error: Cannot find proper GTK+ version" >&2;} { (exit 1); exit 1; }; } fi rm -f conf.gtktest # # Check for OpenGL libraries # # Check whether --with-GL-prefix or --without-GL-prefix was given. if test "${with_GL_prefix+set}" = set; then withval="$with_GL_prefix" fi; GL_CFLAGS="" GL_LDOPTS="" if test -n "$with_GL_prefix" ; then GL_CFLAGS="-I$with_GL_prefix/include" GL_LDOPTS="-L$with_GL_prefix/lib" fi echo "$as_me:3185: checking for glBegin in -lGL" >&5 echo $ECHO_N "checking for glBegin in -lGL... $ECHO_C" >&6 if test "${ac_cv_lib_GL_glBegin+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lGL $GL_LDOPTS $LIBS" cat >conftest.$ac_ext <<_ACEOF #line 3193 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char glBegin (); int main () { glBegin (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:3212: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3215: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:3218: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3221: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_GL_glBegin=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_GL_glBegin=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:3232: result: $ac_cv_lib_GL_glBegin" >&5 echo "${ECHO_T}$ac_cv_lib_GL_glBegin" >&6 if test $ac_cv_lib_GL_glBegin = yes; then cat >>confdefs.h <&5 echo "$as_me: error: OpenGL library not found." >&2;} { (exit 1); exit 1; }; } fi GL_LIBS="$GL_LDOPTS -lGL" # # Check for GtkGLArea widget # # Check whether --with-gtkgl-prefix or --without-gtkgl-prefix was given. if test "${with_gtkgl_prefix+set}" = set; then withval="$with_gtkgl_prefix" fi; GTKGL_CFLAGS="" GTKGL_LDOPTS="" if test -n "$with_gtkgl_prefix" ; then GTKGL_CFLAGS="-I$with_gtkgl_prefix/include" GTKGL_LDOPTS="-L$with_gtkgl_prefix/lib" fi echo "$as_me:3266: checking for gtk_gl_area_new in -lgtkgl" >&5 echo $ECHO_N "checking for gtk_gl_area_new in -lgtkgl... $ECHO_C" >&6 if test "${ac_cv_lib_gtkgl_gtk_gl_area_new+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgtkgl $GTKGL_LDOPTS $GTK_LIBS $GL_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF #line 3274 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gtk_gl_area_new (); int main () { gtk_gl_area_new (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:3293: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3296: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:3299: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3302: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_gtkgl_gtk_gl_area_new=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_gtkgl_gtk_gl_area_new=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:3313: result: $ac_cv_lib_gtkgl_gtk_gl_area_new" >&5 echo "${ECHO_T}$ac_cv_lib_gtkgl_gtk_gl_area_new" >&6 if test $ac_cv_lib_gtkgl_gtk_gl_area_new = yes; then cat >>confdefs.h <&5 echo "$as_me: error: Cannot find GtkGLArea library." >&2;} { (exit 1); exit 1; }; } fi GTKGL_LIBS="$GTKGL_LDOPTS -lgtkgl" # # Test for libpng # if test -z "$LIBPNG_LIB"; then echo "$as_me:3335: checking for png_read_info in -lpng" >&5 echo $ECHO_N "checking for png_read_info in -lpng... $ECHO_C" >&6 if test "${ac_cv_lib_png_png_read_info+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpng -lz -lm $LIBS" cat >conftest.$ac_ext <<_ACEOF #line 3343 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char png_read_info (); int main () { png_read_info (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:3362: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3365: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:3368: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3371: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_png_png_read_info=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_png_png_read_info=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:3382: result: $ac_cv_lib_png_png_read_info" >&5 echo "${ECHO_T}$ac_cv_lib_png_png_read_info" >&6 if test $ac_cv_lib_png_png_read_info = yes; then echo "$as_me:3385: checking for png.h" >&5 echo $ECHO_N "checking for png.h... $ECHO_C" >&6 if test "${ac_cv_header_png_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 3391 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:3395: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:3401: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_png_h=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_header_png_h=no fi rm -f conftest.err conftest.$ac_ext fi echo "$as_me:3420: result: $ac_cv_header_png_h" >&5 echo "${ECHO_T}$ac_cv_header_png_h" >&6 if test $ac_cv_header_png_h = yes; then png_ok=yes else png_ok=no fi else { echo "$as_me:3429: WARNING: *** PNG exporter cannot be built (PNG library not found) ***" >&5 echo "$as_me: WARNING: *** PNG exporter cannot be built (PNG library not found) ***" >&2;} fi if test "$png_ok" = yes; then echo "$as_me:3434: checking for png_structp in png.h" >&5 echo $ECHO_N "checking for png_structp in png.h... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line 3437 "configure" #include "confdefs.h" #include int main () { png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:3449: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3452: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:3455: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3458: \$? = $ac_status" >&5 (exit $ac_status); }; }; then png_ok=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 png_ok=no fi rm -f conftest.$ac_objext conftest.$ac_ext echo "$as_me:3467: result: $png_ok" >&5 echo "${ECHO_T}$png_ok" >&6 if test "$png_ok" = yes; then PNG='png'; LIBPNG_LIB='-lpng -lz' else { echo "$as_me:3472: WARNING: *** PNG exporter cannot be built (PNG library is too old) ***" >&5 echo "$as_me: WARNING: *** PNG exporter cannot be built (PNG library is too old) ***" >&2;} fi else { echo "$as_me:3476: WARNING: *** PNG exporter cannot be built (PNG header file not found) ***" >&5 echo "$as_me: WARNING: *** PNG exporter cannot be built (PNG header file not found) ***" >&2;} fi fi # # Test for libtiff # if test -z "$LIBTIFF_LIB"; then echo "$as_me:3486: checking for TIFFReadScanline in -ltiff" >&5 echo $ECHO_N "checking for TIFFReadScanline in -ltiff... $ECHO_C" >&6 if test "${ac_cv_lib_tiff_TIFFReadScanline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltiff -lm $LIBS" cat >conftest.$ac_ext <<_ACEOF #line 3494 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char TIFFReadScanline (); int main () { TIFFReadScanline (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:3513: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3516: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:3519: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3522: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_tiff_TIFFReadScanline=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_tiff_TIFFReadScanline=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:3533: result: $ac_cv_lib_tiff_TIFFReadScanline" >&5 echo "${ECHO_T}$ac_cv_lib_tiff_TIFFReadScanline" >&6 if test $ac_cv_lib_tiff_TIFFReadScanline = yes; then echo "$as_me:3536: checking for tiffio.h" >&5 echo $ECHO_N "checking for tiffio.h... $ECHO_C" >&6 if test "${ac_cv_header_tiffio_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 3542 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:3546: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:3552: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_tiffio_h=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_header_tiffio_h=no fi rm -f conftest.err conftest.$ac_ext fi echo "$as_me:3571: result: $ac_cv_header_tiffio_h" >&5 echo "${ECHO_T}$ac_cv_header_tiffio_h" >&6 if test $ac_cv_header_tiffio_h = yes; then TIFF='tiff'; LIBTIFF_LIB='-ltiff' else { echo "$as_me:3576: WARNING: *** TIFF exporter cannot be built (TIFF header files not found) ***" >&5 echo "$as_me: WARNING: *** TIFF exporter cannot be built (TIFF header files not found) ***" >&2;} fi else echo "$as_me:3581: checking for TIFFWriteScanline in -ltiff" >&5 echo $ECHO_N "checking for TIFFWriteScanline in -ltiff... $ECHO_C" >&6 if test "${ac_cv_lib_tiff_TIFFWriteScanline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltiff -ljpeg -lz -lm $LIBS" cat >conftest.$ac_ext <<_ACEOF #line 3589 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char TIFFWriteScanline (); int main () { TIFFWriteScanline (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:3608: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3611: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:3614: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3617: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_tiff_TIFFWriteScanline=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_tiff_TIFFWriteScanline=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:3628: result: $ac_cv_lib_tiff_TIFFWriteScanline" >&5 echo "${ECHO_T}$ac_cv_lib_tiff_TIFFWriteScanline" >&6 if test $ac_cv_lib_tiff_TIFFWriteScanline = yes; then echo "$as_me:3631: checking for tiffio.h" >&5 echo $ECHO_N "checking for tiffio.h... $ECHO_C" >&6 if test "${ac_cv_header_tiffio_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 3637 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:3641: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:3647: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_tiffio_h=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_header_tiffio_h=no fi rm -f conftest.err conftest.$ac_ext fi echo "$as_me:3666: result: $ac_cv_header_tiffio_h" >&5 echo "${ECHO_T}$ac_cv_header_tiffio_h" >&6 if test $ac_cv_header_tiffio_h = yes; then TIFF='tiff'; LIBTIFF_LIB='-ltiff -ljpeg -lz' else { echo "$as_me:3671: WARNING: *** TIFF exporter cannot be built (TIFF header files not found) ***" >&5 echo "$as_me: WARNING: *** TIFF exporter cannot be built (TIFF header files not found) ***" >&2;} fi else echo "$as_me:3676: checking for TIFFFlushData in -ltiff34" >&5 echo $ECHO_N "checking for TIFFFlushData in -ltiff34... $ECHO_C" >&6 if test "${ac_cv_lib_tiff34_TIFFFlushData+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltiff34 -ljpeg -lz -lm $LIBS" cat >conftest.$ac_ext <<_ACEOF #line 3684 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char TIFFFlushData (); int main () { TIFFFlushData (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:3703: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:3706: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:3709: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3712: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_tiff34_TIFFFlushData=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_tiff34_TIFFFlushData=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:3723: result: $ac_cv_lib_tiff34_TIFFFlushData" >&5 echo "${ECHO_T}$ac_cv_lib_tiff34_TIFFFlushData" >&6 if test $ac_cv_lib_tiff34_TIFFFlushData = yes; then echo "$as_me:3726: checking for tiffio.h" >&5 echo $ECHO_N "checking for tiffio.h... $ECHO_C" >&6 if test "${ac_cv_header_tiffio_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line 3732 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:3736: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:3742: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_tiffio_h=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_header_tiffio_h=no fi rm -f conftest.err conftest.$ac_ext fi echo "$as_me:3761: result: $ac_cv_header_tiffio_h" >&5 echo "${ECHO_T}$ac_cv_header_tiffio_h" >&6 if test $ac_cv_header_tiffio_h = yes; then TIFF='tiff'; LIBTIFF_LIB='-ltiff34 -ljpeg -lz' else { echo "$as_me:3766: WARNING: *** TIFF exporter cannot be built (TIFF header files not found) ***" >&5 echo "$as_me: WARNING: *** TIFF exporter cannot be built (TIFF header files not found) ***" >&2;} fi else { echo "$as_me:3771: WARNING: *** TIFF exporter cannot be built (TIFF library not found) ***" >&5 echo "$as_me: WARNING: *** TIFF exporter cannot be built (TIFF library not found) ***" >&2;} fi fi fi fi if test "$PNG" = png ; then cat >>confdefs.h <<\EOF #define HAVE_LIBPNG 1 EOF fi if test "$TIFF" = tiff ; then cat >>confdefs.h <<\EOF #define HAVE_LIBTIFF 1 EOF fi IMG_LIBS="$LIBPNG_LIB $LIBTIFF_LIB" # # That's a wrap! # CFLAGS="$CFLAGS $GTK_CFLAGS $GL_CFLAGS $GTKGL_CFLAGS" LIBS="$LIBS $GTKGL_LIBS $GTK_LIBS $GL_LIBS $IMG_LIBS" ac_config_files="$ac_config_files Makefile src/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overriden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if cmp -s $cache_file confcache; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi DEFS=-DHAVE_CONFIG_H : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:3883: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated automatically by configure. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false SHELL=\${CONFIG_SHELL-$SHELL} ac_cs_invocation="\$0 \$@" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # Name of the executable. as_me=`echo "$0" |sed 's,.*[\\/],,'` if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file as_executable_p="test -f" # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # NLS nuisances. $as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } $as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } $as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } $as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } exec 6>&1 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS fi cat >>$CONFIG_STATUS <<\EOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." EOF cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` shift set dummy "$ac_option" "$ac_optarg" ${1+"$@"} shift ;; -*);; *) # This is not an option, so the user has probably given explicit # arguments. ac_need_defaults=false;; esac case $1 in # Handling of the options. EOF cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:4059: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) shift CONFIG_FILES="$CONFIG_FILES $1" ac_need_defaults=false;; --header | --heade | --head | --hea ) shift CONFIG_HEADERS="$CONFIG_HEADERS $1" ac_need_defaults=false;; # This is an error. -*) { { echo "$as_me:4078: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done exec 5>>config.log cat >&5 << _ACEOF ## ----------------------- ## ## Running config.status. ## ## ----------------------- ## This file was extended by $as_me 2.52, executed with CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS > $ac_cs_invocation on `(hostname || uname -n) 2>/dev/null | sed 1q` _ACEOF EOF cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:4124: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. : ${TMPDIR=/tmp} { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=$TMPDIR/cs$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 { (exit 1); exit 1; } } EOF cat >>$CONFIG_STATUS <\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@DEFS@,$DEFS,;t t s,@LIBS@,$LIBS,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@PACKAGE@,$PACKAGE,;t t s,@VERSION@,$VERSION,;t t s,@ACLOCAL@,$ACLOCAL,;t t s,@AUTOCONF@,$AUTOCONF,;t t s,@AUTOMAKE@,$AUTOMAKE,;t t s,@AUTOHEADER@,$AUTOHEADER,;t t s,@MAKEINFO@,$MAKEINFO,;t t s,@SET_MAKE@,$SET_MAKE,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@CPP@,$CPP,;t t s,@GTK_CONFIG@,$GTK_CONFIG,;t t s,@GTK_CFLAGS@,$GTK_CFLAGS,;t t s,@GTK_LIBS@,$GTK_LIBS,;t t CEOF EOF cat >>$CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_lines` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" EOF cat >>$CONFIG_STATUS <<\EOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then { case "$ac_dir" in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy="$ac_dir" for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" ;; esac done; } ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'` else ac_dir_suffix= ac_dots= fi case $srcdir in .) ac_srcdir=. if test -z "$ac_dots"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_dots$srcdir$ac_dir_suffix ac_top_srcdir=$ac_dots$srcdir ;; esac case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_dots$INSTALL ;; esac if test x"$ac_file" != x-; then { echo "$as_me:4342: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated automatically by config.status. */ configure_input="Generated automatically from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:4360: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo $srcdir/$f else # /dev/null tree { { echo "$as_me:4373: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } EOF cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then mv $tmp/out $ac_file else cat $tmp/out rm -f $tmp/out fi done EOF cat >>$CONFIG_STATUS <<\EOF # # CONFIG_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac test x"$ac_file" != x- && { echo "$as_me:4434: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:4445: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo $srcdir/$f else # /dev/null tree { { echo "$as_me:4458: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >$tmp/in EOF # Transform confdefs.h into two sed scripts, `conftest.defines' and # `conftest.undefs', that substitutes the proper values into # config.h.in to produce config.h. The first handles `#define' # templates, and the second `#undef' templates. # And first: Protect against being on the right side of a sed subst in # config.status. Protect against being in an unquoted here document # in config.status. rm -f conftest.defines conftest.undefs # Using a here document instead of a string reduces the quoting nightmare. # Putting comments in sed scripts is not portable. # # `end' is used to avoid that the second main sed command (meant for # 0-ary CPP macros) applies to n-ary macro definitions. # See the Autoconf documentation for `clear'. cat >confdef2sed.sed <<\EOF s/[\\&,]/\\&/g s,[\\$`],\\&,g t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\(\([^ (][^ (]*\)([^)]*)\)[ ]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp t end s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp : end EOF # If some macros were called several times there might be several times # the same #defines, which is useless. Nevertheless, we may not want to # sort them, since we want the *last* AC-DEFINE to be honored. uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >>conftest.undefs <<\EOF s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, EOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS echo ' if egrep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS echo ' :' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.defines >/dev/null do # Write a limited-size here document to $tmp/defines.sed. echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#define' lines. echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/defines.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines echo ' fi # egrep' >>$CONFIG_STATUS echo >>$CONFIG_STATUS # Break up conftest.undefs because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.undefs >/dev/null do # Write a limited-size here document to $tmp/undefs.sed. echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#undef' echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/undefs.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail rm -f conftest.undefs mv conftest.tail conftest.undefs done rm -f conftest.undefs cat >>$CONFIG_STATUS <<\EOF # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated automatically by config.status. */ if test x"$ac_file" = x-; then echo "/* Generated automatically by configure. */" >$tmp/config.h else echo "/* $ac_file. Generated automatically by configure. */" >$tmp/config.h fi cat $tmp/in >>$tmp/config.h rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then { echo "$as_me:4575: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then { case "$ac_dir" in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy="$ac_dir" for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" ;; esac done; } fi rm -f $ac_file mv $tmp/config.h $ac_file fi else cat $tmp/config.h rm -f $tmp/config.h fi done EOF cat >>$CONFIG_STATUS <<\EOF # # CONFIG_COMMANDS section. # for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue ac_dest=`echo "$ac_file" | sed 's,:.*,,'` ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` case $ac_dest in default-1 ) test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h ;; esac done EOF cat >>$CONFIG_STATUS <<\EOF { (exit 0); exit 0; } EOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: exec 5>/dev/null $SHELL $CONFIG_STATUS || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi # end configure.in lightspeed-1.2a/configure.in0000644000175000017500000000703207334275165011655 # configure.in # # Process this file with autoconf to produce a configure script. # AC_INIT(src/lightspeed.c) AC_CONFIG_AUX_DIR(config) AM_CONFIG_HEADER(config.h) LIGHTSPEED_VERSION_MAJOR=1 LIGHTSPEED_VERSION_MINOR=2a LIGHTSPEED_VERSION=$LIGHTSPEED_VERSION_MAJOR.$LIGHTSPEED_VERSION_MINOR AM_INIT_AUTOMAKE(lightspeed, $LIGHTSPEED_VERSION) # Check for programs # AM_SANITY_CHECK AC_PROG_INSTALL AC_PROG_CC AC_PROG_CPP # Check for header files # AC_HEADER_STDC AC_CHECK_HEADERS(getopt.h malloc.h sys/time.h) # Check for typedefs, structures, and compiler characteristics. # AC_C_CONST AC_TYPE_SIZE_T AC_HEADER_TIME # Check for library functions # AC_CHECK_FUNCS(getopt_long gettimeofday strcspn strdup strtod) # Checks for GTK+ libraries. # AM_PATH_GTK(1.0.1, , AC_MSG_ERROR([Cannot find proper GTK+ version])) # # Check for OpenGL libraries # AC_ARG_WITH(GL-prefix, [ --with-GL-prefix=PFX Prefix where OpenGL is installed (optional)]) GL_CFLAGS="" GL_LDOPTS="" if test -n "$with_GL_prefix" ; then GL_CFLAGS="-I$with_GL_prefix/include" GL_LDOPTS="-L$with_GL_prefix/lib" fi AC_CHECK_LIB(GL, glBegin, , AC_MSG_ERROR([OpenGL library not found.]), $GL_LDOPTS) GL_LIBS="$GL_LDOPTS -lGL" # # Check for GtkGLArea widget # AC_ARG_WITH(gtkgl-prefix, [ --with-gtkgl-prefix=PFX Prefix where GtkGLArea is installed (optional)]) GTKGL_CFLAGS="" GTKGL_LDOPTS="" if test -n "$with_gtkgl_prefix" ; then GTKGL_CFLAGS="-I$with_gtkgl_prefix/include" GTKGL_LDOPTS="-L$with_gtkgl_prefix/lib" fi AC_CHECK_LIB(gtkgl, gtk_gl_area_new, , AC_MSG_ERROR([Cannot find GtkGLArea library.]), $GTKGL_LDOPTS $GTK_LIBS $GL_LIBS) GTKGL_LIBS="$GTKGL_LDOPTS -lgtkgl" # # Test for libpng # if test -z "$LIBPNG_LIB"; then AC_CHECK_LIB(png, png_read_info, AC_CHECK_HEADER(png.h, png_ok=yes, png_ok=no), AC_MSG_WARN(*** PNG exporter cannot be built (PNG library not found) ***), -lz -lm) if test "$png_ok" = yes; then AC_MSG_CHECKING([for png_structp in png.h]) AC_TRY_COMPILE([#include ], [png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;], png_ok=yes, png_ok=no) AC_MSG_RESULT($png_ok) if test "$png_ok" = yes; then PNG='png'; LIBPNG_LIB='-lpng -lz' else AC_MSG_WARN(*** PNG exporter cannot be built (PNG library is too old) ***) fi else AC_MSG_WARN(*** PNG exporter cannot be built (PNG header file not found) ***) fi fi # # Test for libtiff # if test -z "$LIBTIFF_LIB"; then AC_CHECK_LIB(tiff, TIFFReadScanline, AC_CHECK_HEADER(tiffio.h, TIFF='tiff'; LIBTIFF_LIB='-ltiff', AC_MSG_WARN(*** TIFF exporter cannot be built (TIFF header files not found) ***)), AC_CHECK_LIB(tiff, TIFFWriteScanline, AC_CHECK_HEADER(tiffio.h, TIFF='tiff'; LIBTIFF_LIB='-ltiff -ljpeg -lz', AC_MSG_WARN(*** TIFF exporter cannot be built (TIFF header files not found) ***)), AC_CHECK_LIB(tiff34, TIFFFlushData, AC_CHECK_HEADER(tiffio.h, TIFF='tiff'; LIBTIFF_LIB='-ltiff34 -ljpeg -lz', AC_MSG_WARN(*** TIFF exporter cannot be built (TIFF header files not found) ***)), AC_MSG_WARN(*** TIFF exporter cannot be built (TIFF library not found) ***), -ljpeg -lz -lm), -ljpeg -lz -lm), -lm) fi if test "$PNG" = png ; then AC_DEFINE(HAVE_LIBPNG) fi if test "$TIFF" = tiff ; then AC_DEFINE(HAVE_LIBTIFF) fi IMG_LIBS="$LIBPNG_LIB $LIBTIFF_LIB" # # That's a wrap! # CFLAGS="$CFLAGS $GTK_CFLAGS $GL_CFLAGS $GTKGL_CFLAGS" LIBS="$LIBS $GTKGL_LIBS $GTK_LIBS $GL_LIBS $IMG_LIBS" AC_OUTPUT(Makefile src/Makefile) # end configure.in lightspeed-1.2a/MATH0000644000175000017500000002362507325200163010010 The Mathematics behind Light Speed! =================================== This file describes the mathematical framework of the relativistic transforms exhibited in the Light Speed! simulator. In particular, the formulae and some details of their implementation are given below. ==== THE LORENTZ CONTRACTION ==== A moving object will appear shorter than it does at rest, due to an oblique alignment in four-dimensional space-time imparted to it by its motion. Specifically, the object will appear compressed along its axis of travel, scaled down by a factor which is exactly the Lorentz factor, also known as gamma: 1 gamma = --------------------- sqrt( 1 - (v/c)^2 ) where v is the velocity of the object, and c is the speed of light. For most everyday values of v, gamma is practically 1. As v approaches the speed of light, however, gamma grows without bound. Assuming that a vehicle's length L is parallel with its axis of travel, its observed length L' at any velocity (below that of light!) is: L' = L / gamma This predicts that an object travelling at the speed of light will appear to have no length (and hence no volume), while retaining its frontal cross-sectional area. If the object were a rocket, for example, it would appear to have become a flying disc. ==== THE DOPPLER RED/BLUE SHIFT and THE HEADLIGHT EFFECT ==== These are transformations upon the color hue and intensity attributes of an object, respectively. Either is based upon the motion of a light source (whether by emission or reflection) with respect to a receiver or observer of its light. If the source is approaching the observer, it will appear blue-shifted (its light higher in frequency) and brighter. If it is moving away, it will appear red-shifted (lower in frequency) and darker. In Light Speed!, there are two instances where these effects are applied: 1. Ambient light striking (illuminating) the object 2. The object reflecting light toward the observer The first takes into account how the object is illuminated. If the object were a space vessel, travelling at relativistic speed, an onboard observer will notice that (for example) stars and planetary bodies ahead of the ship appear brighter and blue-shifted. Because of this, the nose of the ship will be bathed in a relatively bright, bluish light. The light it reflects, then, will also have this character. The second instance handles the color effects as naturally expected from the motion of the object, with respect to the camera. Both effects depend on the relative motion between a source point and a receiving point, one in motion and the other at rest. As such, the formula for either transform contains the term: v --- * cos a c in which: v = forward velocity of the moving point c = speed of light a = (alpha) angle subtended between the motion vector of the moving point and the vector connecting the two points (moving-to-stationary) This value is nothing more than the rate (as a factor of c, between 1.0 and -1.0) at which the two points are approaching or moving away from one another. With that pointed out, the formula describing the Doppler effect is as follows: n' 1 + (v/c)*cos a --- = --------------------- n sqrt( 1 - (v/c)^2 ) The n'/n (nu-prime over nu) is a frequency ratio. Multiplying the frequency of the source lighting by this value will give the frequency as observed by the receiver. (Also, note that the denominator is the reciprocal of the gamma factor. This accounts for the effect of time dilation upon the frequency, which to some extent always increases it). The Doppler shift routines used in Light Speed! were written by Antony Searle, and actually work with the reciprocal of this value, n/n', which is the _wavelength_ ratio between the two states of light. These routines are not trivial, as they accept an RGB-triplet color as input, and produce an RGB-triplet as output. The RGB representation must be converted to a rough spectrum to make the wavelength ratio meaningful, and then sampled into RGB again as this format is required by the graphics system. The resulting colors are only an approximation, with some assumptions made as to the character of light involved, but Mr. Searle's implementation has the important advantage of computational simplicity-- and thereby speed. The formula describing the headlight effect is similar: I' (1 + (v/c)*cos a)^2 --- = --------------------- I sqrt( 1 - (v/c)^2 ) (The only difference to the previous formula is in the squaring of the numerator) I'/I is an intensity ratio, again multiplying that of the source light to produce what is observed by the receiver. RGB colors can be directly manipulated by this value (i.e. multiplying each color component with it), although better intensity transforms may exist. (Some of the intensity-adjustment routines of quality paint programs come to mind). ==== OPTICAL ABERRATION ==== This results from the phenomena of delayed observation; i.e. we do not see things, but the light reflected from things. As light has a finite, albeit very high speed, there is a corresponding delay associated with our observation of events/things. In Light Speed!, the camera observes a moving object, which is comprised of various vertex points (interconnected in some arbitrary geometrical manner, be it triangles, quads, etc.) The position of each of these is known within a fiducial time frame, at the moment that the shutter is snapped. However, the camera perceives by way of light, whose propagation is not instantaneous. Thus it is necessary to translate each vertex of the object backward (w.r.t. the direction of travel) to an earlier position, specifically the position at which the camera is expected to observe the vertex-- at a slightly earlier point in time. There is one condition that this earlier position must satisfy: The time necessary for the vertex to travel from the earlier position to its position in the fiducial frame _must_exactly_equal_ the time necessary for light to travel from the earlier position of the vertex to the observer. (My apologies; this is very difficult to explain in a straightforward manner. Let me try a different approach...) If the object of concern consists of a single vertex, the problem may be illustrated geometrically as follows: A * |\ | \ | \ | \ | \ | \ B * \ | \ | \ | \ | \ |__ \ | | \ C *-------------* O Fig. 1 The object is traveling along the vector AC. At time T=-t (i.e. a short moment before T=0) it is at position A. At this moment, a photon strikes the object and reflects off its surface, beginning travel along the vector AO toward the observer O. The object continues along path AC. At time T=0, the object is at B, and the photon reaches O. The observer, seeing the photon, observes an image of the object at position A. (and, incidentally, has yet to see anything at position B) Whereas the image of the object is at A, the object itself is really at B; with the above thought experiment we have derived where the object will be (B) from the position of its image (A). Implementing a simulator, however, entails finding the image position A from the actual position B, taking into account the velocity v of the object and position O of the observer. The unknown length AB-- the image-to-object delta-- is what has to be calculated. This means calculating t, as AB is simply v*t. (Similarly, AO is c*t). In the geometrical sense, it is finding lengths AB and AO in the ratio v/c, scaled by some factor t which will make ACO a right triangle. For the sake of argument, let us say AC is the x-axis, with B being the origin. (This is close to how it is implemented in Light Speed!) Let: x = x-position of the observer = distance BC; y = y-position of the observer = distance CO; v = velocity of the moving object; c = speed of light. We start off with the right-triangle relationship (a.k.a. the Pythagorean Theorem), stating the square of the hypotenuse is equal to...: (c*t)^2 = (v*t + x)^2 + y^2 and then rearrange it into a quadratic equation of t: (v^2 - c^2)*t^2 + (2*x*v)*t + (x^2 + y^2) = 0 which yields the solution: -2*x*v - sqrt( (2*x*v)^2 - 4*(v^2 - c^2)*(x^2 + y^2) ) t = -------------------------------------------------------- 2*(v^2 - c^2) (The sign on the radical must be negative to give a positive value for t. Note that the denominator is always negative, as v lightspeed-1.2a/lightspeed.spec0000644000175000017500000000237107334276006012344 %define ver 1.2a %define rel 1 %define prefix /usr/X11R6 Summary: Light Speed! - an interactive relativistic simulator Name: lightspeed Version: %ver Release: %rel Copyright: MozPL/GPL Group: X11/Amusements URL: http://lightspeed.sourceforge.net/ Requires: gtk+ >= 1.0.1 BuildRoot: /tmp/lightspeed-%ver-root %description Light Speed! is an OpenGL-based program which illustrates the effects of special relativity on the appearance of moving objects. When an object accelerates past a few million meters per second, these effects begin to grow noticeable, becoming more and more pronounced as the speed of light is approached. These relativistic effects are viewpoint-dependent, and include shifts in length, object hue, brightness and shape. The moving object is, by default, a geometric lattice. 3D Studio and LightWave 3D objects may be imported as well. Best of all, the simulator is completely interactive, rendering the distortions in real-time! %prep %setup %build ./configure --prefix=%{prefix} make CFLAGS="$RPM_OPT_FLAGS" %install rm -rf $RPM_BUILD_ROOT make prefix=$RPM_BUILD_ROOT%{prefix} install-strip %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc AUTHORS CONTROLS COPYING ChangeLog MATH OVERVIEW README TODO %{prefix}/bin/lightspeed lightspeed-1.2a/src/0000777000175000017500000000000007334276241010211 5lightspeed-1.2a/src/Makefile.am0000644000175000017500000000133107325170037012153 ## src/Makefile.am bin_PROGRAMS = lightspeed lightspeed_SOURCES = \ acconfig.h \ compat.h \ lightspeed.h \ lstrings.h \ read3ds.h \ readlwo.h \ settings.h \ trackmem.h \ animation.c \ auxobjects.c \ camera.c \ command.c \ geometry.c \ globals.c \ gtkwidgets.c \ importobjs.c \ infodisp.c \ lattice.c \ lightspeed.c \ lstrings.c \ mainwindow.c \ menu_cbs.c \ misc.c \ ogl.c \ read3ds.c \ readlwo.c \ snapshot.c \ trackmem.c \ warp.c EXTRA_DIST = \ icon.xpm \ title.xpm ## end src/Makefile.am lightspeed-1.2a/src/Makefile.in0000644000175000017500000002273407334276114012201 # Makefile.in generated automatically by automake 1.4-p4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ CPP = @CPP@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_CONFIG = @GTK_CONFIG@ GTK_LIBS = @GTK_LIBS@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ bin_PROGRAMS = lightspeed lightspeed_SOURCES = acconfig.h compat.h lightspeed.h lstrings.h read3ds.h readlwo.h settings.h trackmem.h animation.c auxobjects.c camera.c command.c geometry.c globals.c gtkwidgets.c importobjs.c infodisp.c lattice.c lightspeed.c lstrings.c mainwindow.c menu_cbs.c misc.c ogl.c read3ds.c readlwo.c snapshot.c trackmem.c warp.c EXTRA_DIST = icon.xpm title.xpm mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ lightspeed_OBJECTS = animation.o auxobjects.o camera.o command.o \ geometry.o globals.o gtkwidgets.o importobjs.o infodisp.o lattice.o \ lightspeed.o lstrings.o mainwindow.o menu_cbs.o misc.o ogl.o read3ds.o \ readlwo.o snapshot.o trackmem.o warp.o lightspeed_LDADD = $(LDADD) lightspeed_DEPENDENCIES = lightspeed_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best SOURCES = $(lightspeed_SOURCES) OBJECTS = $(lightspeed_OBJECTS) all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status mostlyclean-binPROGRAMS: clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) distclean-binPROGRAMS: maintainer-clean-binPROGRAMS: install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) list='$(bin_PROGRAMS)'; for p in $$list; do \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done .c.o: $(COMPILE) -c $< .s.o: $(COMPILE) -c $< .S.o: $(COMPILE) -c $< mostlyclean-compile: -rm -f *.o core *.core clean-compile: distclean-compile: -rm -f *.tab.c maintainer-clean-compile: lightspeed: $(lightspeed_OBJECTS) $(lightspeed_DEPENDENCIES) @rm -f lightspeed $(LINK) $(lightspeed_LDFLAGS) $(lightspeed_OBJECTS) $(lightspeed_LDADD) $(LIBS) tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = src distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done animation.o: animation.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h auxobjects.o: auxobjects.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h camera.o: camera.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h command.o: command.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h geometry.o: geometry.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h globals.o: globals.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h gtkwidgets.o: gtkwidgets.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h importobjs.o: importobjs.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h read3ds.h readlwo.h infodisp.o: infodisp.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h lattice.o: lattice.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h lightspeed.o: lightspeed.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h lstrings.o: lstrings.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h mainwindow.o: mainwindow.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h icon.xpm menu_cbs.o: menu_cbs.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h title.xpm misc.o: misc.c lightspeed.h ../config.h settings.h compat.h lstrings.h ogl.o: ogl.c lightspeed.h ../config.h settings.h compat.h lstrings.h read3ds.o: read3ds.c read3ds.h readlwo.o: readlwo.c readlwo.h snapshot.o: snapshot.c lightspeed.h ../config.h settings.h compat.h \ lstrings.h trackmem.o: trackmem.c trackmem.h warp.o: warp.c lightspeed.h ../config.h settings.h compat.h lstrings.h info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-binPROGRAMS install-exec: install-exec-am install-data-am: install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-binPROGRAMS uninstall: uninstall-am all-am: Makefile $(PROGRAMS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-binPROGRAMS clean-compile clean-tags clean-generic \ mostlyclean-am clean: clean-am distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ distclean-generic clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean-compile maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am .PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \ clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ check-am installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ all-redirect all-am all installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: lightspeed-1.2a/src/acconfig.h0000644000175000017500000000022007176115553012043 /* acconfig.h */ #undef HAVE_LIBPNG #undef HAVE_LIBTIFF #undef LIGHTSPEED_VERSION_MAJOR #undef LIGHTSPEED_VERSION_MINOR /* end acconfig.h */ lightspeed-1.2a/src/compat.h0000644000175000017500000000177007176115553011570 /* compat.h */ /* Compatibility hack for GTK+/glib/GtkGLArea 1.0 */ /* I'll spare you the boilerplate just this once :-) */ #ifndef GTK_HAVE_FEATURES_1_1_0 /* ---- GTK+ 1.1 name ---- ---- GTK+ 1.0 name ---- */ #define gtk_container_set_border_width gtk_container_border_width #define gtk_window_set_position gtk_window_position #define gtk_toggle_button_set_active gtk_toggle_button_set_state #define gtk_check_menu_item_set_active gtk_check_menu_item_set_state #define gtk_label_set_text gtk_label_set /* GtkGLArea prior to 1.? uses a slightly different API */ #define gtk_gl_area_make_current gtk_gl_area_begingl #define GTKGL_TEMP_endgl gtk_gl_area_endgl /* Neutralize accelerator code in keybind( ) */ #define GtkAccelGroup int #define gtk_accel_group_new NOP #define gtk_accel_group_attach(a,b) NOP( ) #define gtk_widget_add_accelerator(a,b,c,d,e,f) NOP( ) #else /* not GTK_HAVE_FEATURES_1_1_0 */ #define GTKGL_TEMP_endgl(a) NOP( ) #endif /* not GTK_HAVE_FEATURES_1_1_0 */ /* end compat.h */ lightspeed-1.2a/src/lightspeed.h0000644000175000017500000004034607176115553012437 /* lightspeed.h */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ /**** Includes ***********************************************************/ /* Autoconf stuff */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ /* The usual headers */ #include #include #ifdef HAVE_GETOPT_H #include #endif /* HAVE_GETOPT_H */ #include #include #include /* OpenGL */ #include #include /* GTK+ */ #include #include /* Compile-time settings */ #include "settings.h" /* For GTK+/glib 1.0 compatibility */ #include "compat.h" /* Optional memory allocation tracking */ #ifdef WITH_TRACKMEM #include "trackmem.h" #endif /**** Constants/macros ***************************************************/ /* We need >=1 image library to save snapshots */ #if (HAVE_LIBPNG || HAVE_LIBTIFF) #define CAN_SAVE_SNAPSHOT #else #undef CAN_SAVE_SNAPSHOT #endif /* C = speed of light in meters/sec */ #define C 299792458.0 /* MAX_VELOCITY < C */ #define MAX_VELOCITY (C - 1.0) /* MIN_VELOCITY > 0 */ #define MIN_VELOCITY 1.0 #define PI 3.14159265358979323846264338327 #define MAGIC_NUMBER 1.618033989 /* EM wavelengths (in nanometers) */ #define LAMBDA_UV 340.0 #define LAMBDA_BLUE 460.0 #define LAMBDA_GREEN 520.0 #define LAMBDA_RED 700.0 #define LAMBDA_IR 1000.0 /* Relative perceptual strengths of the RGB components */ #define RED_STRENGTH 0.3 #define GREEN_STRENGTH 0.59 #define BLUE_STRENGTH 0.11 /* Useful */ #define DEG(angleRad) ((angleRad) * 180 / PI) #define RAD(angle360) ((angle360) * PI / 180) #define SQR(x) ((x) * (x)) #define SIGN(x) (((x) >= 0) ? 1.0 : -1.0) #define C2 (C * C) /* a value counterpart to NULL */ #define NIL 0 /* Macro for message passing via pointer */ #define MESG_(m) ((int *)&mesg_vals[m]) /* Message constants: */ enum { /* Objects modes (for global variable "objects_mode") */ MODE_LATTICE, MODE_USER_GEOMETRY, /* transition types (trans_var->type field) */ TRANS_LINEAR, TRANS_QTR_SIN, TRANS_RAMP, TRANS_SIGMOID, TRANS_STOP, /* graphics mode control by menu_Camera_GraphicsMode_select( ) */ OGL_WIREFRAME_MODE, OGL_SHADED_MODE, /* auxiliary object control by aux_objs( ) */ AUXOBJS_DRAW, AUXOBJS_SET_AXES, AUXOBJS_SET_BBOX, AUXOBJS_SET_GRID, /* relativistic distortion control by warp( ) */ WARP_DISTORT, WARP_LORENTZ_CONTRACTION, WARP_OPTICAL_DEFORMATION, WARP_DOPPLER_SHIFT, WARP_HEADLIGHT_EFFECT, /* time and animation control by warp_time( ) */ WARP_UPDATE_TIME_T, WARP_BEGIN_ANIM, WARP_STOP_ANIM, /* performance profiling control by profile( ) */ PROFILE_START_ITERATION, PROFILE_FRAME_BEGIN, PROFILE_FRAME_DONE, PROFILE_FRAMERATE_RESET, PROFILE_WARP_BEGIN, PROFILE_WARP_DONE, PROFILE_OGLDRAW_BEGIN, PROFILE_OGLDRAW_DONE, PROFILE_IDLE, PROFILE_SHOW_STATS, /* info display control by info_display( ) */ INFODISP_DRAW, INFODISP_ACTIVE, INFODISP_SHOW_VELOCITY, INFODISP_SHOW_TIME_T, INFODISP_SHOW_GAMMA, INFODISP_SHOW_FRAMERATE, INFODISP_UPDATE, /* position codes for ogl_draw_string( ) */ POS_TOP_LEFT, POS_TOP_RIGHT, POS_BOTTOM_LEFT, POS_BOTTOM_RIGHT, POS_CENTER, /* dialog control */ DIALOG_OPEN, DIALOG_CLOSE, DIALOG_OK, DIALOG_OK_CONFIRM, /* for camera_calc_xyz( ) */ CAM_POSITION, CAM_TARGET, /* for velocity_input( ) et. al. */ VALUE_COMMITTED, VALUE_CHANGED, UNITS_CHANGED, /* generic OO */ ACTIVATE, DEACTIVATE, ITERATION, INITIALIZE, RESET, QUERY, /* for rotate_xyz( ), etc. */ X_ALIGN, Y_ALIGN, Z_ALIGN, Z_ROTATE_CW, Z_ROTATE_CCW, /* for image handling, esp. save_snapshot( ) */ IMAGE_FORMAT, IMAGE_FORMAT_PNG, IMAGE_FORMAT_TIFF, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_COMMENTS, IMAGE_FILENAME, IMAGE_PIXELROW, IMAGE_COMPLETE }; /**** Data structures ****************************************************/ /* Command-line option description */ struct option_desc { char opt; /* Short option */ char *lopt; /* Equivalent long option (GNU-style) */ char *desc; /* Description string */ }; /* Transitory variable state container * Keeps track of a float or double var as it goes from initial to final value * (see transition_engine( ) for the details) */ typedef struct trans_var_struct trans_var; struct trans_var_struct { void *var; int is_double : 1; int looping : 1; int type; double start_t; double end_t; int cam_id; /* = -1 if transition affects all camera views */ double initial; double final; trans_var *next; /* transition queue is a linked list.... */ }; /* Absolute coordinate extents info */ typedef struct extents_struct extents; struct extents_struct { float xmin; float xmax; float ymin; float ymax; float zmin; float zmax; float avg; /* = ((xmax-xmin)+(ymax-ymin)+(zmax-zmin))/3 */ }; /* RGB color definition */ typedef struct rgb_color_struct rgb_color; struct rgb_color_struct { float r; float g; float b; }; /* 3D point/vector definition */ typedef struct point_struct point; struct point_struct { float x; float y; float z; }; /* OpenGL point (color+normal+location) definition * (for use in interleaved arrays) */ typedef struct ogl_point_struct ogl_point; struct ogl_point_struct { /* RGBA color (C4F) */ float r; float g; float b; float a; /* Normal direction (N3F) */ float nx; float ny; float nz; /* Vertex location (V3F) */ float x; float y; float z; }; /* OpenGL object definition */ typedef struct ogl_object_struct ogl_object; struct ogl_object_struct { int type; int num_vertices; point *vertices0; /* Original, unwarped geometry */ point *normals0; rgb_color color0; ogl_point *iarrays; /* C4F+N3F+V3F interleaved arrays */ int num_indices; unsigned int *indices; int pre_dlist; /* OGL display list executed before... */ int post_dlist; /* ...and after drawing the object */ }; /* Camera state container */ typedef struct camera_struct camera; struct camera_struct { float phi; /* heading (in degres) */ float theta; /* elevation (in degrees) */ float distance; /* distance to target */ point target; point pos; /* Derived from phi/theta/distance/target */ float fov; /* field of view in degrees */ int width, height; /* of associated viewport */ float near_clip; /* Clipping plane distances */ float far_clip; GtkWidget *window_w; /* Associated window widget */ GtkWidget *ogl_w; /* Associated GL widget (viewport) */ int redraw : 1; /* Flag: does viewport want a redraw? */ }; /**** Global variables ***************************************************/ /* These are all in globals.c */ extern const int mesg_vals[]; extern const int num_unit_systems; extern const char *unit_suffixes[]; extern const double unit_conv_factors[]; extern const int unit_num_decimals[]; extern int cur_unit_system; extern const int num_background_colors; extern const rgb_color bkgd_colors[]; extern rgb_color background; extern const int num_font_sizes; extern const char *sys_font_names[]; extern const int sys_font_sizes[]; extern const int micro_glyph; extern const int num_stock_lenses; extern const float stock_lenses[]; extern const char *image_format_exts[]; extern double velocity; extern double cur_time_t; extern float vehicle_real_x; extern int object_mode; extern int lattice_size_x; extern int lattice_size_y; extern int lattice_size_z; extern float framerate; extern ogl_object **vehicle_objs; extern int num_vehicle_objs; extern extents vehicle_extents; extern extents world_extents; extern camera **usr_cams; extern int num_cams; extern int cur_cam; extern camera out_cam; extern int advanced_interface; extern int dgamma_correct; extern float dgamma_lut[]; extern float mouse_sens; /* Language-specific strings */ #include "lstrings.h" /**** Forward declarations ***********************************************/ /* animation.c */ void queue_redraw( int cam_id ); int update( int message ); void profile( int message ); void transition( void *var, int is_double, int trans_type, double duration, double final, int cam_id ); void animate( void *var, int is_double, int trans_type, double duration, double initial, double final, int cam_id ); void break_transition( void *var ); /* auxobjects.c */ void auxiliary_objects( int message1, int message2 ); /* camera.c */ camera *new_camera( void); void kill_camera( int cam_id ); void camera_reset( int cam_id ); int assoc_cam_id( void *widget ); int camera_set_current( GtkWidget *widget, GdkEventFocus *ev_focus, void *nothing ); float camera_calc_fov( float lens_length ); float camera_calc_lens_length( float fov ); void camera_calc_xyz( int point_type, camera *cam ); void camera_make_target( camera *cam ); int camera_move( GtkWidget *widget, GdkEventAny *event, void *nothing ); /* command.c */ int command( const char *input ); /* geometry.c */ ogl_object *alloc_ogl_object( int num_vertices, int num_indices ); int calc_ogl_object_memusage( int num_vertices, int num_indices ); void free_ogl_object( ogl_object *obj ); void clear_all_objects( void); void rotate_all_objects( int direction ); void rotate_xyz( int action, float *x, float *y, float *z, float x0, float y0, float z0 ); point *calc_tri_normal( point *a, point *b, point *c ); point *calc_tri_centroid( point *a, point *b, point *c ); float calc_tri_area( point *a, point *b, point *c ); void show_geometry_stats( void); #ifdef WITH_SRS_EXPORTER int export_srs( const char *filename, int width, int height, int stereo_view, int visible_faces_only ); void write_srs_mesh( FILE *srs, point *cam_pos, int visible_faces_only ); void write_srs_camera( FILE *srs, camera *cam, float t ); void write_srs_sphere( FILE *srs, point *center, float radius ); void write_srs_cylinder( FILE *srs, point *p1, point *p2, float radius ); void write_srs_smooth_triangle( FILE *srs, point **vertices, point **normals ); void write_srs_pigment( FILE *srs, rgb_color *color ); void convert_to_srs_cs( point *p_srs, point *p_ls ); #endif /* WITH_SRS_EXPORTER */ /* gtkwidgets.c */ GtkWidget *add_gl_area( GtkWidget *parent_box_w ); GtkWidget *make_dialog_window( const char *title, void *callback_close ); GtkWidget *message_window( const char *title, const char *message_text ); GtkWidget *confirmation_dialog( const char *title, const char *message_text, void *callback ); GtkWidget *make_filesel_window( const char *title, const char *init_filename, int show_fileops, void *callback_handler ); GtkWidget *add_menu( GtkWidget *parent_menu_w, const char *label ); GtkWidget *add_menu_item( GtkWidget *menu_w, const char *label, void *callback, void *callback_data ); GtkWidget *add_check_menu_item( GtkWidget *menu_w, const char *label, int init_state, void *callback, void *callback_data ); void begin_radio_menu_group( int init_selected ); GtkWidget *add_radio_menu_item( GtkWidget *menu_w, const char *label, void *callback, void *callback_data ); GtkWidget *option_menu_item( const char *label, void *callback, void *callback_data ); GtkWidget *add_option_menu( GtkWidget *widget ); void add_separator( GtkWidget *parent_w ); void keybind( GtkWidget *widget, char *keys ); GtkWidget *add_hbox( GtkWidget *parent_w, int homog, int spacing ); GtkWidget *add_vbox( GtkWidget *parent_w, int homog, int spacing ); GtkWidget *add_frame( GtkWidget *parent_w, const char *title ); GtkWidget *add_hscale( GtkWidget *parent_w, GtkObject *adjustment ); GtkWidget *add_vscale( GtkWidget *parent_w, GtkObject *adjustment ); GtkWidget *add_spin_button( GtkWidget *parent_w, GtkObject *adjustment ); GtkWidget *add_check_button( GtkWidget *parent_w, const char *label, int init_state, void *callback, void *callback_data ); GtkWidget *add_entry( GtkWidget *parent_w, const char *init_str, void *callback, void *callback_data ); void set_entry_width( GtkWidget *entry_w, const char *span_str ); void set_entry_text( GtkWidget *entry_w, const char *entry_text ); char *read_entry( GtkWidget *entry_w ); void highlight_entry( GtkWidget *entry_w ); GtkWidget *add_button( GtkWidget *parent_w, const char *label, void *callback, void *callback_data ); GtkWidget *add_label( GtkWidget *parent_w, const char *label_text ); GtkWidget *add_pixmap( GtkWidget *parent_w, GtkWidget *parent_window_w, char **xpm_data ); void assign_icon( GtkWidget *window_w, char **xpm_data ); /* importobjs.c */ int import_objects( const char *filename ); /* infodisp.c */ void info_display( int message1, int message2 ); /* lattice.c */ void make_lattice( int size_x, int size_y, int size_z, int smoothness ); #ifdef WITH_SRS_EXPORTER void write_srs_lattice( FILE *srs ); #endif /* WITH_SRS_EXPORTER */ /* mainwindow.c */ void main_window( void ); void add_Camera_menu( GtkWidget *menu_bar_w, GtkWidget *window_w ); /* menu_cbs.c */ void velocity_input( GtkWidget *widget, const int *message ); #ifdef VELOCITY_SLIDER void velocity_slider( GtkWidget *widget, const int *message ); #endif /* VELOCITY_SLIDER */ void dialog_File_NewLattice( GtkWidget *widget, const int *message ); #ifdef WITH_OBJECT_IMPORTER void dialog_File_ImportObject( GtkWidget *widget, const int *message ); #endif /* WITH_OBJECT_IMPORTER */ #ifdef CAN_SAVE_SNAPSHOT void dialog_File_SaveSnapshot( GtkWidget *widget, const int *message ); #endif /* CAN_SAVE_SNAPSHOT */ #ifdef WITH_SRS_EXPORTER void dialog_File_ExportSRS( GtkWidget *widget, const int *message ); #endif /* WITH_SRS_EXPORTER */ void menu_Objects_toggles( GtkWidget *widget, const int *message ); void dialog_Objects_Animation( GtkWidget *widget, const int *message ); void menu_Warp_toggles( GtkWidget *widget, const int *message ); void menu_Camera_Lens_select( GtkWidget *widget, const float *new_lens_length ); void dialog_Camera_Lens_Custom( GtkWidget *widget, const int *message ); void dialog_Camera_Position( GtkWidget *widget, const int *message ); void menu_Camera_ResetView( GtkWidget *widget, const int *cam_id ); void menu_Camera_InfoDisplay_toggles( GtkWidget *widget, const int *message ); void menu_Camera_Background_select( GtkWidget *widget, const int *color_id ); void menu_Camera_GraphicsMode_select( GtkWidget *widget, const int *message ); void menu_Camera_Spawn( GtkWidget *widget, void *dummy ); void menu_Camera_Close( GtkWidget *widget_to_kill, void *dummy ); void dialog_Help_Overview( GtkWidget *widget, int *message ); void dialog_Help_Controls( GtkWidget *widget, int *message ); void dialog_Help_About( GtkWidget *widget, int *message ); /* misc.c */ void *xmalloc( size_t size ); void *xrealloc( void *block, size_t size ); char *xstrdup( const char *str ); void xfree( void *block ); int file_exists( const char *filename ); char *file_basename( const char *name, const char *suffix ); char *swap_filename_ext( const char *filename, const char *old_ext, const char *new_ext ); double read_system_clock( void); void set_cursor_glyph( int glyph ); char *velocity_string( double v_ms, int fancy ); char *add_commas( const char *num_str ); char *clean_number( const char *num_str ); char *time_string( void ); void calc_dgamma_lut( float dgamma ); void crash( char *error_mesg ); void ss( void ); int *NOP( void ); /* ogl.c */ void ogl_initialize( GtkWidget *ogl_w, void *nothing ); int ogl_resize( GtkWidget *ogl_w, GdkEventConfigure *ev_config, void *nothing ); int ogl_refresh( GtkWidget *ogl_w, GdkEventExpose *ev_expose, void *nothing ); void ogl_draw( int cam_id ); void ogl_draw_string( const void *data, int message, int size ); void ogl_blank( int cam_id, const char *blank_message ); GtkWidget *ogl_make_widget( void); /* snapshot.c */ int save_snapshot( int width, int height, const char *filename, int format ); /* warp.c */ int warp( int message, void *data ); void warp_point( point *vertex, point *normal, point *cam_pos ); void warp_time( float x0, float x1, double value, int message ); double lorentz_factor( double v ); /* end lightspeed.h */ lightspeed-1.2a/src/lstrings.h0000644000175000017500000001352707176115553012155 /* lstrings.h */ /* Language-specific strings */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ extern const char *STR_Light_Speed; extern const char *STR_copyright_ARG; extern const char *STR_CLI_usage_ARG; extern struct option_desc STRS_CLI_options[]; extern const char *STR_CLI_option_chars; extern const char *STR_MNU_File; extern const char *STR_MNU_Objects; extern const char *STR_MNU_Warp; extern const char *STR_MNU_Camera; extern const char *STR_MNU_Help; extern const char *STR_MNU_New_lattice; extern const char *STR_MNU_Load_object; extern const char *STR_MNU_Save_snapshot; extern const char *STR_MNU_Export_srs; extern const char *STR_MNU_Exit; extern const char *STR_MNU_Coordinate_axes; extern const char *STR_MNU_Floating_grid; extern const char *STR_MNU_Bounding_box; extern const char *STR_MNU_Animation; extern const char *STR_MNU_Lorentz_contraction; extern const char *STR_MNU_Doppler_shift; extern const char *STR_MNU_Headlight_effect; extern const char *STR_MNU_Optical_deformation; extern const char *STR_MNU_Lens; extern const char *STR_MNU_Position; extern const char *STR_MNU_Reset_view; extern const char *STR_MNU_Info_display; extern const char *STR_MNU_Background; extern const char *STR_MNU_Graphics_mode; extern const char *STR_MNU_Spawn_camera; extern const char *STR_MNU_Close; extern const char *STR_MNU_Custom; extern const char *STR_MNU_Active; extern const char *STR_MNU_Velocity; extern const char *STR_MNU_Time_t; extern const char *STR_MNU_Gamma_factor; extern const char *STR_MNU_Framerate; extern const char *STRS_MNU_bkgd_color_names[]; extern const char *STR_MNU_Wireframe; extern const char *STR_MNU_Shaded; extern const char *STR_MNU_Overview; extern const char *STR_MNU_Controls; extern const char *STR_MNU_About; extern const char *STR_INF_time_ARG; extern const char *STR_INF_fps_ARG; extern const char *STR_INF_velocity_ARG; extern const char *STR_INF_gamma_ARG; extern const char *STR_INF_no_contraction; extern const char *STR_INF_no_doppler_shift; extern const char *STR_INF_no_headlight_effect; extern const char *STR_INF_no_deformation; extern const char *STR_INF_no_relativity; extern const char *STR_DLG_Okay_btn; extern const char *STR_DLG_Cancel_btn; extern const char *STR_DLG_Close_btn; extern const char *STR_DLG_New_lattice; extern const char *STR_DLG_Dimensions; extern const char *STR_DLG_Smoothness; extern const char *STR_DLG_Load_Object; extern const char *STR_DLG_Recognized_formats; extern const char *STR_DLG_3d_formats; extern const char *STR_DLG_Save_Snapshot; extern const char *STR_DLG_snapshot_Parameters; extern const char *STR_DLG_snapshot_Size; extern const char *STR_DLG_snapshot_Format; extern const char *STR_DLG_snapshot_basename; extern const char *STR_DLG_Export_srs; extern const char *STR_DLG_srs; extern const char *STR_DLG_srs_Parameters; extern const char *STR_DLG_srs_Size; extern const char *STR_DLG_srs_Stereo_view; extern const char *STR_DLG_srs_Vis_faces_only; extern const char *STR_DLG_srs_basename1; extern const char *STR_DLG_srs_basename2; extern const char *STR_DLG_Animation; extern const char *STR_DLG_Observed_range; extern const char *STR_DLG_Start_X; extern const char *STR_DLG_End_X; extern const char *STR_DLG_Loop_time; extern const char *STR_DLG_seconds; extern const char *STR_DLG_Begin_btn; extern const char *STR_DLG_Stop_btn; extern const char *STR_DLG_Camera_Position; extern const char *STR_DLG_Location; extern const char *STR_DLG_View_target; extern const char *STR_DLG_Direction; extern const char *STR_DLG_Phi_label; extern const char *STR_DLG_Theta_label; extern const char *STR_DLG_Angles_instead; extern const char *STR_DLG_Xyz_instead; extern const char *STR_DLG_Reposition_btn; extern const char *STR_DLG_Custom_Lens; extern const char *STR_DLG_Lens_length; extern const char *STR_DLG_Field_of_view; extern const char *STR_DLG_degree_suffix; extern const char *STR_DLG_Overview; extern const char *STR_DLG_Controls; extern const char *STR_DLG_About; extern const char *STR_DLG_Version_x_y_ARG; extern const char *STR_DLG_authorship_ARG; extern const char *STR_DLG_home_page_url; extern const char *STR_DLG_Camera; extern const char *STR_DLG_Warning; extern const char *STR_DLG_Error; extern const char *STR_DLG_Overview_TEXT; extern const char *STR_DLG_Controls_TEXT; extern const char *STR_MSG_Okay; extern const char *STR_MSG_Invalid; extern const char *STR_MSG_overwrite_warn_ARG; extern const char *STR_MSG_no_object_file_ARG; extern const char *STR_MSG_not_3ds_file; extern const char *STR_MSG_not_prj_file; extern const char *STR_MSG_not_lwo_file; extern const char *STR_MSG_unknown_obj_format; extern const char *STR_MSG_bad_3ds_file; extern const char *STR_MSG_empty_3ds_file; extern const char *STR_MSG_bad_lwo_file; extern const char *STR_MSG_empty_lwo_file; extern const char *STR_MSG_no_ogl_visual; extern const char *STR_MSG_no_render_buf_ARG; extern const char *STR_MSG_no_ogl_context; extern const char *STR_MSG_no_snapshot_output; extern const char *STR_MSG_Generating_lattice; extern const char *STR_MSG_Importing_object; extern const char *STR_MSG_Rendering_snapshot; extern const char *STR_MSG_Saving_snapshot_ARG; /* end lstrings.h */ lightspeed-1.2a/src/read3ds.h0000644000175000017500000001631407176115553011632 /* read3ds.h */ /* Mini-library for loading .3DS files * 3D Studio loading code by Jare/Iguana et. al. (see read3ds.c) * API interface & portability mods by Straker Skunk * * THIS FILE IS IN THE PUBLIC DOMAIN */ #include #include #include typedef unsigned char uint8; /* "byte" == 8 bits */ typedef unsigned short uint16; /* "word" == 16 bits */ typedef unsigned int uint32; /* "double word" == 32 bits */ /**** Defines, macros, enums, etc. ****************************/ #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #ifndef ABS #define ABS(a) (((a) < 0) ? -(a) : (a)) #endif #ifndef CLAMP #define CLAMP(x,low,high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) #endif /* Type conversion macros */ #define R3DS_OBJECT(x) ((r3ds_object *)(x)) #define R3DS_LIGHT(x) ((r3ds_light *)(x)) #define R3DS_CAMERA(x) ((r3ds_camera *)(x)) #define R3DS_TRIMESH(x) ((r3ds_trimesh *)(x)) /* Use to access r3ds_triangle->flags bitfield (each returns TRUE/FALSE) */ #define R3DS_TRI_AB_VIS(tri) (((tri)->flags & 0x04) != 0) #define R3DS_TRI_BC_VIS(tri) (((tri)->flags & 0x02) != 0) #define R3DS_TRI_CA_VIS(tri) (((tri)->flags & 0x01) != 0) #define R3DS_TRI_U_WRAP(tri) (((tri)->flags & 0x08) != 0) #define R3DS_TRI_V_WRAP(tri) (((tri)->flags & 0x10) != 0) /* Use to access r3ds_triangle->smgroups bitfield. Returns TRUE if triangle is * in the smoothing group specified (1-32), FALSE if otherwise. If 0 is passed, * return TRUE if triangle is not in ANY smoothing group, FALSE otherwise */ #define R3DS_TRI_IN_SMGROUP(tri,g) \ (((g) <= 0) ? ((tri)->smgroups == 0) : (((tri)->smgroups & ((uint32)1 << ((g) - 1))) != 0)) /* Messages for the r3ds_build() state machine */ enum { R3DS_INITIALIZE, R3DS_PROJECT_SCALE, R3DS_NEW_OBJECT, R3DS_DEF_LIGHT, R3DS_DEF_CAMERA, R3DS_DEF_TRIMESH, R3DS_NUM_VERTS, R3DS_VERT, R3DS_NUM_VERT_MAPPINGS, R3DS_VERT_MAPPING, R3DS_NUM_TRIS, R3DS_TRI_FACE, R3DS_TRI_MATERIAL_CURRENT, R3DS_TRI_MATERIAL, R3DS_BEGIN_TRI_SMOOTH, R3DS_TRI_SMOOTH, R3DS_ROT_MATRIX, R3DS_TRANS_MATRIX, R3DS_NEW_MATERIAL, R3DS_MAT_AMBIENT_COLOR, R3DS_MAT_DIFFUSE_COLOR, R3DS_MAT_SPECULAR_COLOR, R3DS_MAT_2SIDED, R3DS_COLOR24, R3DS_GET_SCENE }; /* Messages for r3ds_split_trimeshes( ) */ enum { R3DS_SPLIT_BY_MATERIAL, R3DS_SPLIT_BY_SMGROUP }; /* Object types * (for r3ds_object->type field) */ typedef enum { R3DS_OBJ_LIGHT, R3DS_OBJ_CAMERA, R3DS_OBJ_TRIMESH, R3DS_OBJ_UNDEFINED } R3dsObjType; /* Light types * (for r3ds_light->ltype field) */ typedef enum { R3DS_LIGHT_POINT, R3DS_LIGHT_SPOT } R3dsLightType; /* Shading types * (for r3ds_material->shading_type field) */ typedef enum { R3DS_SHADE_FLAT, R3DS_SHADE_GOURAUD, R3DS_SHADE_PHONG, R3DS_SHADE_METAL } R3dsShadeType; /**** Data structures *****************************************/ /** Elements **/ /* 24-bit RGB color */ typedef struct r3ds_color24_struct r3ds_color24; struct r3ds_color24_struct { /* Each component has a range of 0-255 */ int red; int green; int blue; }; /* Floating-point RGB color */ typedef struct r3ds_colorF_struct r3ds_colorF; struct r3ds_colorF_struct { float red; float green; float blue; }; /* Trimesh vertex */ typedef struct r3ds_point_struct r3ds_point; struct r3ds_point_struct { /* Location coords. */ float x; float y; float z; /* Texture mapping coords. */ float u; float v; }; /* Trimesh triangle */ typedef struct r3ds_triangle_struct r3ds_triangle; struct r3ds_triangle_struct { int a, b, c; /* Vertex indices (into r3ds_trimesh->verts) */ uint16 flags; /* Edge visibility & texture wrap flags */ int mat_id; /* Material index (into r3ds_scene->mats) */ uint32 smgroups; /* Bitfield: smoothing group(s) membership */ }; /* Material */ /* INCOMPLETE */ typedef struct r3ds_material_struct r3ds_material; struct r3ds_material_struct { char *name; r3ds_color24 ambient; r3ds_color24 diffuse; r3ds_color24 specular; R3dsShadeType shading; /* Flat, Gouraud, Phong, or Metal */ int two_sided : 1; /* 2-sided material (flag) */ int shine; /* Shininess % */ int shine_st; /* Shininess strength % */ int transp; /* Transparency % */ int transp_fo; /* Transparency falloff % */ int ref_blur; /* Reflection blur % */ int self_illum; /* Self-illumination % */ int wireframe_th; /* Wireframe thickness */ int texmap; /* Texture map % */ char *texmap_file; /* Filename of texture map */ int refmap; /* Reflection map % */ char *refmap_file; /* Filename of reflection map */ }; /** Objects **/ /* Light object */ /* INCOMPLETE */ typedef struct r3ds_light_struct r3ds_light; struct r3ds_light_struct { R3dsObjType type; /* = R3DS_OBJ_LIGHT */ char *name; R3dsLightType ltype; float x; float y; float z; r3ds_colorF color; /* Light color */ float radius1; /* Inner radius */ float radius2; /* Outer radius */ float mult; /* Multiplier */ }; /* Camera object */ typedef struct r3ds_camera_struct r3ds_camera; struct r3ds_camera_struct { R3dsObjType type; /* = R3DS_OBJ_CAMERA */ char *name; float x; float y; /* Position */ float z; float targ_x; float targ_y; /* Target */ float targ_z; float bank; float lens; /* Lens length in mm */ }; /* Triangle mesh object */ typedef struct r3ds_trimesh_struct r3ds_trimesh; struct r3ds_trimesh_struct { R3dsObjType type; /* = R3DS_OBJ_TRIMESH */ char *name; int num_verts; r3ds_point *verts; int num_tris; r3ds_triangle *tris; float rot_matrix[9]; float trans_matrix[3]; }; /* Generalized object */ typedef struct r3ds_object_struct r3ds_object; struct r3ds_object_struct { R3dsObjType type; char *name; }; /** Scene **/ typedef struct r3ds_scene_struct r3ds_scene; struct r3ds_scene_struct { float inches_per_unit; int num_objs; r3ds_object **objs; /* Note: The array above and the 3 below point to the SAME objects */ int num_lites; r3ds_light **lites; int num_cams; r3ds_camera **cams; int num_tmeshes; r3ds_trimesh **tmeshes; int num_mats; r3ds_material *mats; }; /**** Forward declarations ************************************/ /* Wrappers for the system memory management functions */ extern void *xmalloc( size_t size ); extern void *xrealloc( void *block, size_t size ); extern char *xstrdup( const char *str ); extern void xfree( void *ptr ); int r3ds_read_uint32( uint32 *data, int count, FILE *f ); int r3ds_read_uint16( uint16 *data, int count, FILE *f ); int r3ds_read_uint8( uint8 *data, int count, FILE *f ); int r3ds_read_float( float *data, int count, FILE *f ); int r3ds_file_is_3ds( const char *filename ); int r3ds_file_is_prj( const char *filename ); void r3ds_build( int data_id, const void *data ); r3ds_scene *read3ds( const char *filename ); void r3ds_dump_light( r3ds_light *light ); void r3ds_dump_camera( r3ds_camera *cam ); void r3ds_dump_trimesh( r3ds_trimesh *trimesh ); void r3ds_dump_object( r3ds_object *obj ); void r3ds_free_object( r3ds_object *obj ); void r3ds_free_material( r3ds_material *mat ); void r3ds_free_scene( r3ds_scene *scene ); int r3ds_first_smgroup( r3ds_triangle *tri ); void r3ds_rebuild_scene_objs( r3ds_scene *scene ); int r3ds_split_trimesh( r3ds_trimesh ***trimeshes_ptr, int message ); int r3ds_split_scene_trimeshes( r3ds_scene *scene, int message ); void r3ds_ChunkReader( FILE *f, int ind, int p ); /* end read3ds.h */ lightspeed-1.2a/src/readlwo.h0000644000175000017500000000404707176115553011742 /* readlwo.h */ /* * Copyright (C) 1998 Janne Löf * * 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 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * This is a heavily modified version of Janne's LWO reader library, as * included in the GtkGLArea distribution (gtkglarea-1.0/examples/lw.h) */ #include #include #define LW_MAX_NAME_LEN 64 typedef struct { char name[LW_MAX_NAME_LEN]; float r, g, b; } lwMaterial; #ifndef lwPoint typedef struct { float x; float y; float z; } lwPoint; #endif typedef struct { int mat_id; /* material of this face */ int index_cnt; /* number of vertices */ int *indices; /* index to vertex */ float *texcoords; /* u,v texture coordinates (not used) */ } lwFace; typedef struct { int face_cnt; lwFace *faces; int material_cnt; lwMaterial *materials; int vertex_cnt; lwPoint *vertices; } lwObject; /* Wrappers for the system memory management functions */ extern void *xmalloc( size_t size ); extern void *xrealloc( void *block, size_t size ); extern char *xstrdup( const char *str ); extern void xfree( void *ptr ); gint lw_is_lwobject(const char *lw_file); lwObject *lw_object_read(const char *lw_file); void lw_object_free(lwObject *lw_object); void lw_object_show(const lwObject *lw_object); float lw_object_radius(const lwObject *lw_object); void lw_object_scale (lwObject *lw_object, float scale); /* end readlwo.h */ lightspeed-1.2a/src/settings.h0000644000175000017500000000700707176115553012144 /* settings.h */ /* Compile-time settings */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ /**** Feature switches ***************************************************/ /** Comment any of these out and they will not be compiled in **/ /* Allows importing of 3D Studio and Lightwave objects */ #define WITH_OBJECT_IMPORTER /* Allows exporting to the SRS (Special Relativity Scene) format used * by Antony Searle's BACKLIGHT relativistic raytracer */ #define WITH_SRS_EXPORTER /**** Completely arbitrary defaults **************************************/ /* Set advanced interface as default */ #define DEF_ADVANCED_INTERFACE TRUE /* Initial lattice dimensions and smoothness factor */ #define DEF_LATTICE_X 1 #define DEF_LATTICE_Y 1 #define DEF_LATTICE_Z 1 #define DEF_LATTICE_SMOOTH 6 /* 0 == decimal of c, 1 == meters/sec, 2 == kilometers/hour */ #define DEF_VELOCITY_UNITS 1 /* Initial/resetted camera view. Angles are in degrees */ #define DEF_CAMERA_PHI 195.0 #define DEF_CAMERA_THETA -10.0 #define DEF_CAMERA_FOV 60.0 /* Initial info display configuration */ #define DEF_INFODISP_ACTIVE TRUE #define DEF_INFODISP_SHOW_VELOCITY TRUE #define DEF_INFODISP_SHOW_TIME_T TRUE #define DEF_INFODISP_SHOW_GAMMA FALSE #define DEF_INFODISP_SHOW_FRAMERATE FALSE /* Display gamma correction (1.0 == none) * e.g. 1.5 for a dark monitor, 0.5 for a bright one */ #define DEF_DGAMMA_CORRECT 1.0 /* Mouse sensitivity (mostly a trial & error constant) */ #define DEF_MOUSE_SENS 0.5 /**** Less arbitrary defaults ********************************************/ /* Velocity slider position * 0 == no slider, 1 == at left of viewport, 2 == at right * NOTE: Text for Overview dialog will need updating if this is not 2 ! */ #define VELOCITY_SLIDER 2 /* Look-up tables speed up the warp( ) engine at the expense of a small * margin of precision */ #define USE_LOOKUP_TABLES TRUE /* Table resolution (each will have LUT_RES+1 entries) */ #define LUT_RES 1023 /* Lattice geometry (in meters) */ #define LATTICE_UNIT_SIZE 1.0 #define BALL_RADIUS 0.125 #define STICK_RADIUS (0.125 / SQR(MAGIC_NUMBER)) /* Lattice colors (RGB) */ #define BALL_R 0.01 #define BALL_G 0.125 #define BALL_B 0.5 #define STICK_R 0.5 #define STICK_G 0.5 #define STICK_B 0.5 /* Info display text colors (RGB) */ #define INFODISP_TEXT_FRONT_R 0.0 #define INFODISP_TEXT_FRONT_G 0.75 #define INFODISP_TEXT_FRONT_B 0.0 #define INFODISP_TEXT_BACK_R 0.0 #define INFODISP_TEXT_BACK_G 0.25 #define INFODISP_TEXT_BACK_B 0.0 /* Eye spacing for stereographic SRS output (in meters) */ #define EYE_SPACING 0.064 /* Framerate is a rolling average calculated over roughly this many seconds * (minimum n, maximum n+1 seconds) */ #define FRAMERATE_AVERAGE_TIME 4 /* end settings.h */ lightspeed-1.2a/src/trackmem.h0000644000175000017500000000403707176115553012107 /* trackmem.h */ /* Memory allocation accounting utility */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include #include #include enum { TRACKMEM_MALLOC, TRACKMEM_MALLOC_EQUIV, TRACKMEM_REALLOC, TRACKMEM_STRDUP, TRACKMEM_FREE, TRACKMEM_SHOW_STATS, TRACKMEM_SHOW_BLOCKS, TRACKMEM_QUIT }; #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif /* Some systems don't support malloc() hooks */ #ifdef MALLOC_HOOKS static void *(*prev_malloc_hook)( size_t size ); static void *(*prev_realloc_hook)( void *block, size_t size ); static void (*prev_free_hook)( void *block ); static void *trackmem_malloc_hook( size_t size ); static void *trackmem_realloc_hook( void *block, size_t size ); static void trackmem_free_hook( void *block ); #endif void trackmem_init( void ); void trackmem_stop( void ); void trackmem_show_stats( void ); void trackmem_show_blocks( void ); void trackmem( int message, void *block, void *block2, size_t size ); int trackmem_search_for_block( void *block, void **allblocks, int num_blocks ); void trackmem_malloc( void *block, size_t size ); void trackmem_realloc( void *block, void *block2, size_t size ); void trackmem_strdup( char *string ); void trackmem_free( void *block ); /* end trackmem.h */ lightspeed-1.2a/src/animation.c0000644000175000017500000003061607176115553012260 /* animation.c */ /* Main update loop + transition/animation handlers */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Forward declarations */ static int idle_loop( void ); static int transition_engine( trans_var *new_tvar ); /* Queue a redraw, i.e. flag a camera [viewport] as needing a redraw * Pass a value of -1 to redraw everything */ void queue_redraw( int cam_id ) { int i; if (cam_id < 0) { for (i = 0; i < num_cams; i++) usr_cams[i]->redraw = TRUE; } else usr_cams[cam_id]->redraw = TRUE; /* Idle loop will bring about the actual redraws */ update( ACTIVATE ); } /* This function keeps everything moving and up-to-date */ int update( int message ) { static int active = FALSE; int state_change; int redraw_occurred = FALSE; int redraw_deferred = FALSE; int i; switch( message ) { case ITERATION: /* we're being called from idle_loop( ) */ break; case ACTIVATE: if (active) return FALSE; /* already running */ active = TRUE; /* Hook our idle loop in */ gtk_idle_add( (GtkFunction)idle_loop, NULL ); return TRUE; default: #ifdef DEBUG crash( "update( ): invalid message" ); #endif return FALSE; } /* Begin timing */ profile( PROFILE_START_ITERATION ); profile( PROFILE_FRAME_BEGIN ); /* Update all variables in transitory status */ state_change = transition_engine( NULL ); /* Do pending redraws (if any) ONLY if event queue is empty */ if (gtk_events_pending( ) == 0) { for (i = 0; i < num_cams; i++) if (usr_cams[i]->redraw) { camera_calc_xyz( CAM_POSITION, usr_cams[i] ); ogl_draw( i ); redraw_occurred = TRUE; } #if VELOCITY_SLIDER /* Update velocity slider */ velocity_slider( NULL, MESG_(RESET) ); #endif } else redraw_deferred = TRUE; /* Semi-BUG: Framerate goes artificially high if only spawned cameras are moved * (remember that moving the primary camera updates *all* views) */ if (redraw_occurred) profile( PROFILE_FRAME_DONE ); if (!state_change && !redraw_deferred) { active = FALSE; /* no state change, no pending redraw */ profile( PROFILE_IDLE ); } return active; } /* "Lackey" idle loop for update( ) * Remember, returning TRUE makes loop run again, returning FALSE stops it... */ static int idle_loop( void ) { return update( ITERATION ); } /* Performance profiler, keeps track of framerate and other timely stats */ void profile( int message ) { static double main_t0; static double iteration_t0 = -1.0; static double active_total_t = 0.0; static double frame_t0; static double *frametimes = NULL; static double sum_frametimes; static double warp_t0; static double warp_total_t = 0.0; static double ogldraw_t0; static double ogldraw_total_t = 0.0; static int num_frametimes; static int frame_num = -1; double delta_t; double cur_t; double p; int i; cur_t = read_system_clock( ); switch (message) { case INITIALIZE: main_t0 = cur_t; break; case PROFILE_START_ITERATION: if (iteration_t0 > 0.0) { delta_t = cur_t - iteration_t0; active_total_t += delta_t; } iteration_t0 = cur_t; break; case PROFILE_IDLE: delta_t = cur_t - iteration_t0; active_total_t += delta_t; iteration_t0 = -1.0; break; case PROFILE_FRAME_BEGIN: frame_t0 = cur_t; break; case PROFILE_FRAME_DONE: delta_t = cur_t - frame_t0; if (frame_num == -1) { /* (Re)initialize frametime buffer */ num_frametimes = (int)((FRAMERATE_AVERAGE_TIME + 0.5) / delta_t); num_frametimes = MAX(4, num_frametimes); frametimes = xrealloc( frametimes, num_frametimes * sizeof(double) ); for (i = 0; i < num_frametimes; i++) frametimes[i] = delta_t; sum_frametimes = (double)num_frametimes * delta_t; frame_num = 0; } /* Calculate framerate */ sum_frametimes -= frametimes[frame_num]; frametimes[frame_num] = delta_t; sum_frametimes += delta_t; framerate = (double)num_frametimes / sum_frametimes; /* Adjust frametime buffer length (if necessary) */ while (sum_frametimes > (FRAMERATE_AVERAGE_TIME + 1.0)) { if (num_frametimes <= 4) break; /* Shrink frametime buffer (animation is slowing down) */ delta_t = sum_frametimes / (double)num_frametimes; --num_frametimes; frametimes = xrealloc( frametimes, num_frametimes * sizeof(double) ); for (i = 0; i < num_frametimes; i++) frametimes[i] = delta_t; sum_frametimes = (double)num_frametimes * delta_t; } while (sum_frametimes < FRAMERATE_AVERAGE_TIME) { /* Expand frametime buffer (animation is speeding up) */ delta_t = sum_frametimes / (double)num_frametimes; ++num_frametimes; frametimes = xrealloc( frametimes, num_frametimes * sizeof(double) ); for (i = 0; i < num_frametimes; i++) frametimes[i] = delta_t; sum_frametimes = (double)num_frametimes * delta_t; } frame_num = (frame_num + 1) % num_frametimes; break; case PROFILE_FRAMERATE_RESET: /* (Re)initialize frametime buffer on next completed frame */ frame_num = -1; break; case PROFILE_WARP_BEGIN: warp_t0 = cur_t; break; case PROFILE_WARP_DONE: delta_t = cur_t - warp_t0; warp_total_t += delta_t; break; case PROFILE_OGLDRAW_BEGIN: ogldraw_t0 = cur_t; break; case PROFILE_OGLDRAW_DONE: delta_t = cur_t - ogldraw_t0; ogldraw_total_t += delta_t; break; case PROFILE_SHOW_STATS: printf( "==== Light Speed! profiler stats ====\n" ); delta_t = cur_t - main_t0; printf( "Idle time..: %.3f sec\n", delta_t - active_total_t ); printf( "Active time: %.3f sec (100%%)\n", active_total_t ); p = 100.0 * warp_total_t / active_total_t; printf( "Warp engine: %.3f sec (%.2f%%)\n", warp_total_t, p ); p = 100.0 * ogldraw_total_t / active_total_t; printf( "OpenGL draw: %.3f sec (%.2f%%)\n", ogldraw_total_t, p ); printf( "Framerate..: %.3f fps\n", framerate ); printf( "=====================================\n" ); fflush( stdout ); break; default: #ifdef DEBUG crash( "profile( ): invalid message" ); #endif return; } } /* Convenience function to initiate a variable transition */ void transition( void *var, int is_double, int trans_type, double duration, double final, int cam_id ) { trans_var *tvar; double t; t = read_system_clock( ); tvar = xmalloc( sizeof(trans_var) ); tvar->var = var; tvar->is_double = is_double; tvar->looping = FALSE; tvar->type = trans_type; tvar->start_t = t; tvar->end_t = t + duration; tvar->cam_id = cam_id; if (is_double) tvar->initial = *((double *)var); else tvar->initial = *((float *)var); tvar->final = final; transition_engine( tvar ); } /* Same as earlier, only this starts a looping variable transition * (i.e. continuous, run-until-you-tell-it-to-stop animation) */ void animate( void *var, int is_double, int trans_type, double duration, double initial, double final, int cam_id ) { trans_var *tvar; double t, val; t = read_system_clock( ); tvar = xmalloc( sizeof(trans_var) ); tvar->var = var; tvar->is_double = is_double; tvar->looping = TRUE; tvar->type = trans_type; /* Define starting time so animation debuts at current value (*var) */ if (is_double) val = *((double *)var); else val = *((float *)var); tvar->start_t = t - duration * (val - initial) / (final - initial); tvar->end_t = tvar->start_t + duration; tvar->cam_id = cam_id; tvar->initial = initial; tvar->final = final; transition_engine( tvar ); } /* Stops an ongoing transition/animation * (does nothing if the specified variable isn't being transitioned) */ void break_transition( void *var ) { trans_var stop_tvar; stop_tvar.var = var; stop_tvar.type = TRANS_STOP; transition_engine( &stop_tvar ); } /* This function is what makes dynamic variable transitioning happen! * Return status indicates whether any state change occurred or not */ static int transition_engine( trans_var *new_tvar ) { static trans_var *trans_queue = NULL; trans_var *prev_tvar; trans_var *u; trans_var *next_tvar; double cur_t; double delta_t; double val; double percent; int redraw_all = FALSE; int i; if (new_tvar != NULL) { /* New transition variable is entering the queue */ /* Check to see if it's already in there */ prev_tvar = NULL; u = trans_queue; while (u != NULL) { if (new_tvar->var == u->var) { /* Whoa! This variable is already in transition * Change existing transition record */ if (new_tvar->type == TRANS_STOP) { /* Remove variable from queue */ next_tvar = u->next; if (prev_tvar == NULL) /* i.e. u is 1st in queue */ trans_queue = next_tvar; else prev_tvar->next = next_tvar; break; } /* Alter the existing transition */ u->type = new_tvar->type; u->start_t = new_tvar->start_t; u->end_t = new_tvar->end_t; if (u->is_double) u->initial = *((double *)u->var); else u->initial = *((float *)u->var); u->final = new_tvar->final; u->looping = new_tvar->looping; xfree( new_tvar ); /* Won't need this again */ break; } prev_tvar = u; u = u->next; /* cdr down the list */ } /* (u is NULL if no match occurred) */ if ((u == NULL) && (new_tvar->type != TRANS_STOP)) { /* All clear, add new_tvar to head of transition queue */ new_tvar->next = trans_queue; /* and fire up the idle loop if it's the first one */ if (trans_queue == NULL) update( ACTIVATE ); trans_queue = new_tvar; } /* Done for now, don't do actual state change in this iteration */ return FALSE; } /* Double-check that the inbox isn't empty */ if (trans_queue == NULL) return FALSE; cur_t = read_system_clock( ); /* Perform incremental update of all variables in the queue */ prev_tvar = NULL; u = trans_queue; while (u != NULL) { /* First, set camera update flag(s) as appropriate * (don't use queue_redraw( ) here! bad!) */ if (u->cam_id >= 0) usr_cams[u->cam_id]->redraw = TRUE; else redraw_all = TRUE; /* affects all views */ if (cur_t >= u->end_t) { if (u->looping) { /* start over */ delta_t = u->end_t - u->start_t; u->start_t += delta_t; u->end_t += delta_t; } else { /* Transition complete, remove tvar from queue */ if (u->is_double) *((double *)u->var) = u->final; else *((float *)u->var) = u->final; next_tvar = u->next; if (prev_tvar == NULL) /* i.e. u is 1st in queue */ trans_queue = next_tvar; else prev_tvar->next = next_tvar; xfree( u ); u = next_tvar; continue; } } /* Update variable value as per appropriate transition function */ percent = ((cur_t - u->start_t) / (u->end_t - u->start_t)); switch( u->type ) { case TRANS_LINEAR: /* No remapping */ break; case TRANS_QTR_SIN: /* 1/4 sine: starts fast, finishes slow */ percent = sin( PI * percent / 2 ); break; case TRANS_RAMP: /* Ramp: starts slow, finishes fast */ percent = 1 - cos( PI * percent / 2 ); break; case TRANS_SIGMOID: /* Sigmoidal (S-like) remapping */ percent = (1 - cos( PI * percent )) / 2; break; default: #ifdef DEBUG crash( "transition_engine( ): invalid transition type" ); #endif break; } val = u->initial + percent * (u->final - u->initial); if (u->is_double) *((double *)u->var) = val; else *((float *)u->var) = val; prev_tvar = u; u = u->next; } /* Don't use queue_redraw( ) here either */ if (redraw_all) { for (i = 0; i < num_cams; i++) usr_cams[i]->redraw = TRUE; } return TRUE; } /* Thoughts: The above system could be extended to allow chained transitions * (i.e. when a transition ends, another is automatically started). This * can be implemented by adding a "trans_var *chain_queue" field to the * trans_var structure, and amending the code that terminates transitions. * This would also allow for a somewhat clever way of specifying looping * animations-- have chain_queue point to the very structure it is in }:) */ /* end animation.c */ lightspeed-1.2a/src/auxobjects.c0000644000175000017500000002576407176115553012460 /* auxobjects.c */ /* Auxiliary objects / reference geometry drawing routines */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Forward declarations */ static void draw_coord_axes( float percent, point *cam_pos ); static void draw_floating_grid( float percent ); static void draw_floating_grid_AUX( float unit_size, int i_min, int i_max, int j_min, int j_max, float vis, float side ); static void draw_bounding_box( float percent ); /* Auxiliary objects control */ void auxiliary_objects( int message1, int message2 ) { static float percent_axes = 0.0; static float percent_grid = 1.0; static float percent_bbox = 0.0; static int axes_active = FALSE; static int grid_active = TRUE; static int bbox_active = FALSE; camera *cam; switch (message1) { case AUXOBJS_DRAW: cam = usr_cams[message2]; break; case AUXOBJS_SET_AXES: axes_active = message2; if (axes_active) transition( &percent_axes, FALSE, TRANS_RAMP, 2, 1.0, -1 ); else transition( &percent_axes, FALSE, TRANS_QTR_SIN, 1, 0.0, -1 ); return; case AUXOBJS_SET_BBOX: bbox_active = message2; if (bbox_active) transition( &percent_bbox, FALSE, TRANS_RAMP, 2, 1.0, -1 ); else transition( &percent_bbox, FALSE, TRANS_QTR_SIN, 1, 0.0, -1 ); return; case AUXOBJS_SET_GRID: grid_active = message2; if (grid_active) transition( &percent_grid, FALSE, TRANS_QTR_SIN, 2, 1.0, -1 ); else { percent_grid = -1.0; transition( &percent_grid, FALSE, TRANS_RAMP, 1, 0.0, -1 ); } return; default: #ifdef DEBUG crash( "aux_objects( ): invalid message" ); #endif return; } glDisable( GL_LIGHTING ); if (percent_axes != 0.0) draw_coord_axes( percent_axes, &cam->pos ); if (percent_bbox != 0.0) draw_bounding_box( percent_bbox ); if (percent_grid != 0.0) draw_floating_grid( percent_grid ); glEnable( GL_LIGHTING ); } static void draw_coord_axes( float percent, point *cam_pos ) { float space, scale; float x_dist; float neg_x0, neg_y0, neg_z0; float neg_x1, neg_y1, neg_z1; float pos_x0, pos_y0, pos_z0; float pos_x1, pos_y1, pos_z1; float rot_x, rot_y, rot_z; float arrow1, arrow2; float label1, label2; float label2_x; /* These will be used to draw the axis arrowheads */ arrow1 = vehicle_extents.avg * percent / 8; arrow2 = arrow1 * SQR(MAGIC_NUMBER); /* These will be used to draw the X, Y and Z labels */ label1 = vehicle_extents.avg * percent / 8; label2 = label1 * MAGIC_NUMBER; if (percent > 0.01) space = vehicle_extents.avg / 4 / SQR(percent); else space = vehicle_extents.avg * 1000; scale = 1.0 + SQR(percent); x_dist = vehicle_extents.xmax + space; pos_x0 = x_dist; pos_x1 = x_dist * scale; x_dist = vehicle_extents.xmin - space; neg_x0 = x_dist; neg_x1 = x_dist * scale - arrow2 / 2.0; pos_y0 = vehicle_extents.ymax + space; pos_y1 = pos_y0 * scale; neg_y0 = vehicle_extents.ymin - space; neg_y1 = MIN(neg_y0 * scale, - pos_y1) - arrow2 / 2.0; pos_z0 = vehicle_extents.zmax + space; pos_z1 = pos_z0 * scale; neg_z0 = vehicle_extents.zmin - space; neg_z1 = MIN(neg_z0 * scale, - pos_z1) - arrow2 / 2.0; /* These will keep the arrowheads and labels facing the camera */ rot_x = DEG(atan2( cam_pos->z, cam_pos->y )); rot_y = DEG(atan2( cam_pos->z, cam_pos->x )); rot_z = DEG(atan2( cam_pos->y, cam_pos->x )); /* label2_x is used to flip the Y if x-pos. of camera is negative */ if (cam_pos->x < 0.0) label2_x = - label2; else label2_x = label2; /* Draw the terminating dots */ glPointSize( 8 ); glBegin( GL_POINTS ); glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( neg_x0, 0, 0 ); glVertex3f( pos_x0, 0, 0 ); glColor3f( 1.0, 1.0, 0.0 ); glVertex3f( 0, neg_y0, 0 ); glVertex3f( 0, pos_y0, 0 ); glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( 0, 0, neg_z0 ); glVertex3f( 0, 0, pos_z0 ); glEnd( ); /* Draw the axes */ glLineWidth( 5 ); glBegin( GL_LINES ); glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( neg_x0, 0, 0 ); glVertex3f( neg_x1, 0, 0 ); glVertex3f( pos_x0, 0, 0 ); glVertex3f( pos_x1, 0, 0 ); glColor3f( 1.0, 1.0, 0.0 ); glVertex3f( 0, neg_y0, 0 ); glVertex3f( 0, neg_y1, 0 ); glVertex3f( 0, pos_y0, 0 ); glVertex3f( 0, pos_y1, 0 ); glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( 0, 0, neg_z0 ); glVertex3f( 0, 0, neg_z1 ); glVertex3f( 0, 0, pos_z0 ); glVertex3f( 0, 0, pos_z1 ); glEnd( ); glPushMatrix( ); glRotatef( rot_x, 1.0, 0.0, 0.0 ); /* Draw the x-axis arrowhead */ glBegin( GL_TRIANGLE_FAN ); glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( pos_x1, 0, 0 ); glVertex3f( pos_x1 - arrow1, 0, arrow1 / 2 ); glVertex3f( pos_x1 + arrow2, 0, 0 ); /* tip */ glVertex3f( pos_x1 - arrow1, 0, - arrow1 / 2 ); glEnd( ); /* Draw the X */ glBegin( GL_LINES ); glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( neg_x1 - label2 - label1, 0, label2 ); /* top left */ glVertex3f( neg_x1 - label2 + label1, 0, - label2 ); /* bottom right */ glVertex3f( neg_x1 - label2 - label1, 0, - label2 ); /* bottom left */ glVertex3f( neg_x1 - label2 + label1, 0, label2 ); /* top right */ glEnd( ); glPopMatrix( ); glPushMatrix( ); glRotatef( rot_y, 0.0, -1.0, 0.0 ); /* Draw the y-axis arrowhead */ glBegin( GL_TRIANGLE_FAN ); glColor3f( 1.0, 1.0, 0.0 ); glVertex3f( 0, pos_y1, 0 ); glVertex3f( 0, pos_y1 - arrow1, - arrow1 / 2 ); glVertex3f( 0, pos_y1 + arrow2, 0 ); /* tip */ glVertex3f( 0, pos_y1 - arrow1, arrow1 / 2 ); glEnd( ); /* Draw the Y */ glBegin( GL_LINES ); glColor3f( 1.0, 1.0, 0.0 ); glVertex3f( 0, neg_y1 - label2 - label1, label2_x ); /* top left */ glVertex3f( 0, neg_y1 - label2, 0 ); /* middle */ glVertex3f( 0, neg_y1 - label2 + label1, label2_x ); /* top right */ glVertex3f( 0, neg_y1 - label2, 0 ); /* middle */ glVertex3f( 0, neg_y1 - label2, 0 ); /* middle */ glVertex3f( 0, neg_y1 - label2, - label2_x ); /* bottom */ glEnd( ); glPopMatrix( ); glPushMatrix( ); glRotatef( rot_z, 0.0, 0.0, 1.0 ); /* Draw the z-axis arrowhead */ glBegin( GL_TRIANGLE_FAN ); glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( 0, 0, pos_z1 ); glVertex3f( 0, arrow1 / 2, pos_z1 - arrow1 ); glVertex3f( 0, 0, pos_z1 + arrow2 ); /* tip */ glVertex3f( 0, - arrow1 / 2, pos_z1 - arrow1 ); glEnd( ); /* Draw the Z */ glBegin( GL_LINE_STRIP ); glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( 0, - label1, neg_z1 - label2 ); /* top left */ glVertex3f( 0, label1, neg_z1 - label2 ); glVertex3f( 0, - label1, neg_z1 - 3 * label2 ); glVertex3f( 0, label1, neg_z1 - 3 * label2 ); /* bottom right */ glEnd( ); glPopMatrix( ); } static void draw_floating_grid( float percent ) { float angle; float vis; float unit_size; float x_length, y_length; float y_dist; int i_min, j_min; int i_max, j_max; /* Deployment rotation */ angle = 180.0 * (percent - 1.0); /* Deployment visibility */ if (percent > 0.0) vis = percent; else vis = sqrt( - percent ); /* Determine unit_size suited to vehicle dimensions */ unit_size = pow( 10, floor( log10( vehicle_extents.avg ) ) ); /* and grid extents */ x_length = vehicle_extents.xmax - vehicle_extents.xmin; y_length = vehicle_extents.ymax - vehicle_extents.ymin; y_dist = MAX(vehicle_extents.ymax, - vehicle_extents.ymin); y_dist += y_length / 4; i_max = (int)(ceil( 4 * x_length / unit_size )) / 2; i_min = - i_max; j_max = (int)(ceil( 4 * y_dist / unit_size )); j_min = (int)(ceil( y_dist / unit_size )); glPushMatrix( ); glRotatef( angle, 0.0, 1.0, 0.0 ); glEnable( GL_BLEND ); /* for fadein/fadeout */ draw_floating_grid_AUX( unit_size, i_min, i_max, j_min, j_max, vis, 1.0 ); glPopMatrix( ); glPushMatrix( ); glRotatef( - angle, 0.0, 1.0, 0.0 ); draw_floating_grid_AUX( unit_size, i_min, i_max, j_min, j_max, vis, -1.0 ); glDisable( GL_BLEND ); glPopMatrix( ); } /* ThisIsAHelperFunction */ static void draw_floating_grid_AUX( float unit_size, int i_min, int i_max, int j_min, int j_max, float vis, float side ) { float x0, y0; float x1, y1; float x, y; int i, j; x0 = unit_size * (float)i_min; x1 = unit_size * (float)i_max; y0 = unit_size * (float)j_min; y1 = unit_size * (float)j_max; glLineWidth( 1 ); glBegin( GL_LINES ); glColor4f( 0.5, 0.5, 0.5, vis ); /* x grid lines */ for (j = j_min; j < j_max; j++) { y = unit_size * (float)j; glVertex3f( x0, side * y, 0 ); glVertex3f( x1, side * y, 0 ); } /* y grid lines */ for (i = i_min + 1; i < i_max; i++) { x = unit_size * (float)i; glVertex3f( x, side * y0, 0 ); glVertex3f( x, side * y1, 0 ); } glEnd( ); glLineWidth( 3 ); /* Outer boundaries */ glBegin( GL_LINE_STRIP ); glColor4f( 0.75, 0.75, 0.75, vis ); glVertex3f( x0, side * y0, 0 ); glVertex3f( x0, side * y1, 0 ); glVertex3f( x1, side * y1, 0 ); glVertex3f( x1, side * y0, 0 ); glEnd( ); /* Floating grid determines world extents */ world_extents.xmin = x0; world_extents.xmax = x1; } static void draw_bounding_box( float percent ) { static int b[] = { 1, -1, -1, 2 }; /* Elements 0 and 3 are important */ extents *exts; float bar_percent; float gamma; float xbar, ybar, zbar; /* Length of x, y, z bars */ float bb_x[4], bb_y[4], bb_z[4]; /* x, y, z coords. of box/bars */ int i, j, k; if (percent < 0.01) return; bar_percent = (0.25 / MAGIC_NUMBER) * percent; gamma = lorentz_factor( velocity ); exts = &vehicle_extents; /* abbreviation */ xbar = (exts->xmax - exts->xmin) * bar_percent; bb_x[0] = (exts->xmin / gamma + vehicle_real_x) / percent; bb_x[1] = ((exts->xmin + xbar) / gamma + vehicle_real_x) / percent; bb_x[2] = ((exts->xmax - xbar) / gamma + vehicle_real_x) / percent; bb_x[3] = (exts->xmax / gamma + vehicle_real_x) / percent; ybar = (exts->ymax - exts->ymin) * bar_percent; bb_y[0] = exts->ymin / percent; bb_y[1] = (exts->ymin + ybar) / percent; bb_y[2] = (exts->ymax - ybar) / percent; bb_y[3] = exts->ymax / percent; zbar = (exts->zmax - exts->zmin) * bar_percent; bb_z[0] = exts->zmin / percent; bb_z[1] = (exts->zmin + zbar) / percent; bb_z[2] = (exts->zmax - zbar) / percent; bb_z[3] = exts->zmax / percent; glLineWidth( 5 ); glBegin( GL_LINES ); glColor3f( 1.0, 1.0, 1.0 ); for (i = 0; i <= 3; i += 3) { for (j = 0; j <= 3; j += 3) { for (k = 0; k <= 3; k += 3) { glVertex3f( bb_x[i], bb_y[j], bb_z[k] ); glVertex3f( bb_x[b[i]], bb_y[j], bb_z[k] ); glVertex3f( bb_x[i], bb_y[j], bb_z[k] ); glVertex3f( bb_x[i], bb_y[b[j]], bb_z[k] ); glVertex3f( bb_x[i], bb_y[j], bb_z[k] ); glVertex3f( bb_x[i], bb_y[j], bb_z[b[k]] ); } } } glEnd( ); } /* end auxobjects.c */ lightspeed-1.2a/src/camera.c0000644000175000017500000002302107176115553011521 /* camera.c */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" camera * new_camera( void ) { int new_cam_id; new_cam_id = num_cams; ++num_cams; usr_cams = xrealloc( usr_cams, num_cams * sizeof(camera *) ); usr_cams[new_cam_id] = xmalloc( sizeof(camera) ); cur_cam = new_cam_id; if (new_cam_id > 0) { /* Initialize camera with primary's state */ memcpy( usr_cams[new_cam_id], usr_cams[0], sizeof(camera) ); } else { /* This IS the primary */ camera_reset( 0 ); } /* Widget pointers will be assigned elsewhere * (in main_window( ) for primary, in menu_Camera_Spawn( ) for others) */ usr_cams[new_cam_id]->window_w = NULL; usr_cams[new_cam_id]->ogl_w = NULL; return usr_cams[new_cam_id]; } /* Gets rid of a camera, along with accompanying window and GL widgets */ void kill_camera( int cam_id ) { gtk_widget_destroy( usr_cams[cam_id]->ogl_w ); gtk_widget_destroy( usr_cams[cam_id]->window_w ); xfree( usr_cams[cam_id] ); --num_cams; if (cam_id != num_cams) /* Not last camera? */ memmove( &usr_cams[cam_id], &usr_cams[cam_id + 1], (num_cams - cam_id) * sizeof(camera *) ); usr_cams = xrealloc( usr_cams, num_cams * sizeof(camera *) ); cur_cam = 0; #ifdef DEBUG printf( "Killed camera %d\n", cam_id ); #endif } /* Initialize camera with default initial settings */ void camera_reset( int cam_id ) { camera *cam; cam = usr_cams[cam_id]; /* Convert user phi/theta to struct camera phi/theta values */ cam->phi = fmod( DEF_CAMERA_PHI + 180.0, 360.0) ; cam->theta = - DEF_CAMERA_THETA; cam->distance = 3 * vehicle_extents.avg; cam->target.x = 0; cam->target.y = 0; cam->target.z = 0; cam->fov = DEF_CAMERA_FOV; cam->near_clip = vehicle_extents.avg / 20; cam->far_clip = vehicle_extents.avg * 50; camera_calc_xyz( CAM_POSITION, cam ); /* Update Camera Position dialog if it is active */ dialog_Camera_Position( NULL, MESG_(RESET) ); queue_redraw( cam_id ); } /* This function returns the ID number of the camera associated * with the specified window or GL widget */ int assoc_cam_id( void *widget ) { camera *cam; int i; for (i = 0; i < num_cams; i++) { cam = usr_cams[i]; if ((widget == cam->window_w) || (widget == cam->ogl_w)) return i; } return -1; /* No camera associated with this widget */ } /* Focusing a window updates cur_cam */ int camera_set_current( GtkWidget *widget, GdkEventFocus *ev_focus, void *nothing ) { if (num_cams > 1) { cur_cam = assoc_cam_id( widget ); #ifdef DEBUG printf( "Current camera: %d\n", cur_cam ); fflush( stdout ); #endif } return FALSE; } /* Obtain a field of view (in degrees) from a lens length (in mm) */ float camera_calc_fov( float lens_length ) { return DEG(2 * atan( 21.6663 / (float)lens_length )); } /* Obtain a lens length (in mm) from a field of view (in degrees) */ float camera_calc_lens_length( float fov ) { return 21.6663 / tan( RAD(fov) / 2 ); } /* Calculates a camera's XYZ position or target, given that the other point * (target or position) and phi + theta + distance are defined */ void camera_calc_xyz( int point_type, camera *cam ) { float sin_phi, cos_phi, sin_theta, cos_theta; float dx, dy, dz; sin_phi = sin( RAD(cam->phi) ); cos_phi = cos( RAD(cam->phi) ); sin_theta = sin( RAD(cam->theta) ); cos_theta = cos( RAD(cam->theta) ); dx = cam->distance * cos_theta * cos_phi; dy = cam->distance * cos_theta * sin_phi; dz = cam->distance * sin_theta; switch (point_type) { case CAM_POSITION: cam->pos.x = cam->target.x + dx; cam->pos.y = cam->target.y + dy; cam->pos.z = cam->target.z + dz; break; case CAM_TARGET: cam->target.x = cam->pos.x - dx; cam->target.y = cam->pos.y - dy; cam->target.z = cam->pos.z - dz; break; default: #ifdef DEBUG crash( "camera_calc_xyz( ): invalid type" ); #endif return; } } /* Calculate a target/distance for a camera which only has a location and a * phi/theta direction. The target point should be chosen such that it lies on * the camera's view ray, and is as close to the origin as possible */ void camera_make_target( camera *cam ) { float sin_phi, sin_theta; float cos_phi, cos_theta; float ux, uy, uz; float dist; sin_phi = sin( RAD(cam->phi) ); cos_phi = cos( RAD(cam->phi) ); sin_theta = sin( RAD(cam->theta) ); cos_theta = cos( RAD(cam->theta) ); /* Calculate unit vector in direction of camera view */ ux = cos_phi * cos_theta; uy = sin_phi * cos_theta; uz = sin_theta; /* Calculate distance to point on ray nearest the origin */ dist = cam->pos.x * ux + cam->pos.y * uy + cam->pos.z * uz; /* If dist is negative, desired target is behind camera -- doh! */ cam->distance = MAX(dist, vehicle_extents.avg / 8.0); camera_calc_xyz( CAM_TARGET, cam ); } /* Read mouse input and move camera around accordingly */ /* Will be connected to mouse button & motion events */ int camera_move( GtkWidget *widget, GdkEventAny *event, void *nothing ) { static camera *cam; static float mouse_prev_x; static float mouse_prev_y; static int cam_id; static int over_foreign = FALSE; GdkEventButton *ev_button; GdkEventMotion *ev_motion; float mouse_x, mouse_y; float mouse_dx, mouse_dy; float sin_phi, cos_phi, sin_theta, cos_theta; float k; int mouse_btn1 = FALSE, mouse_btn2 = FALSE, mouse_btn3 = FALSE; int shift_key = FALSE; switch (event->type) { case GDK_BUTTON_PRESS: cam_id = assoc_cam_id( widget ); cam = usr_cams[cam_id]; cur_cam = cam_id; ev_button = (GdkEventButton *)event; /* Note click coordinates (for dragging) */ mouse_prev_x = ev_button->x; mouse_prev_y = ev_button->y; /* Change cursor appropriately */ if (ev_button->button == 1) { if (ev_button->state & GDK_SHIFT_MASK) set_cursor_glyph( GDK_CIRCLE ); else set_cursor_glyph( GDK_FLEUR ); } if (ev_button->button == 2) set_cursor_glyph( GDK_FLEUR ); if (ev_button->button == 3) set_cursor_glyph( GDK_DOUBLE_ARROW ); /* Finally, clear out any stale text in velocity entry */ velocity_input( NULL, MESG_(RESET) ); return FALSE; /* Double-click -- where are these events coming from? */ case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: return FALSE; case GDK_BUTTON_RELEASE: set_cursor_glyph( GDK_LEFT_PTR ); over_foreign = FALSE; return FALSE; case GDK_MOTION_NOTIFY: ev_motion = (GdkEventMotion *)event; mouse_x = ev_motion->x; mouse_y = ev_motion->y; if ((cam_id != assoc_cam_id( widget )) != over_foreign) { /* Fix for when pointer is dragged over another GL widget * (x/y coords. jump to something else completely) */ mouse_prev_x = mouse_x; mouse_prev_y = mouse_y; over_foreign = !over_foreign; } mouse_dx = mouse_sens * ( mouse_x - mouse_prev_x ); mouse_dy = mouse_sens * ( mouse_y - mouse_prev_y ); mouse_prev_x = mouse_x; mouse_prev_y = mouse_y; /* Get status of Shift key and buttons */ shift_key = ev_motion->state & GDK_SHIFT_MASK; mouse_btn1 = ev_motion->state & GDK_BUTTON1_MASK; mouse_btn2 = ev_motion->state & GDK_BUTTON2_MASK; mouse_btn3 = ev_motion->state & GDK_BUTTON3_MASK; break; default: #ifdef DEBUG crash( "camera_move( ): invalid message" ); #endif return FALSE; } /* Make sure cam->pos is not stale (for Shift + LeftClick) */ camera_calc_xyz( CAM_POSITION, cam ); /* Button 1: Revolve view around target or camera (Shift for latter) */ if (mouse_btn1) { /* phi = heading, theta = elevation */ cam->phi -= mouse_dx; cam->theta += mouse_dy; /* Keep angles within proper bounds */ if (cam->phi < 0.0) cam->phi += 360.0; if (cam->phi > 360.0) cam->phi -= 360.0; if (cam->theta < -90.0) cam->theta = -90.0; if (cam->theta > 90.0) cam->theta = 90.0; } /* If Shift was pressed, need to update camera target */ if (shift_key) camera_calc_xyz( CAM_TARGET, cam ); sin_phi = sin( RAD(cam->phi) ); cos_phi = cos( RAD(cam->phi) ); sin_theta = sin( RAD(cam->theta) ); cos_theta = cos( RAD(cam->theta) ); /* Button 2: Dolly camera (up/down/left/right) */ if (mouse_btn2) { k = cam->distance / 128; /* Isn't trig fun? */ cam->target.x += k * ( mouse_dx * sin_phi - mouse_dy * sin_theta * cos_phi ); cam->target.y -= k * ( mouse_dx * cos_phi + mouse_dy * sin_theta * sin_phi ); cam->target.z += k * mouse_dy * cos_theta; } /* Button 3: Dolly camera (forward/backward) */ if (mouse_btn3) { cam->distance -= (mouse_dy * vehicle_extents.avg / 48); cam->distance = MAX(cam->distance, vehicle_extents.avg / 8.0); } /* Now recalculate camera's xyz-position */ camera_calc_xyz( CAM_POSITION, cam ); /* Real quick, update Camera Position dialog if it is active */ dialog_Camera_Position( NULL, MESG_(RESET) ); /* Finally, ask for a redraw. NOTE: primary camera motion causes all * cameras to be redrawn, as time t can vary with its position */ if (cam_id != 0) queue_redraw( cam_id ); else queue_redraw( -1 ); return FALSE; } /* end camera.c */ lightspeed-1.2a/src/command.c0000644000175000017500000000473507176115553011722 /* command.c */ /* Type-in command handlers */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" int command( const char *input ) { static char *cmd_strs[] = { "ZROT_CCW", "ZROT_CW", "PERFSTATS", "GEOMSTATS", "MEMSTATS", "MEMBLOCKS", "DGAMMA=", "STRAKER", "SKUNK" }; const int num_cmd_strs = sizeof(cmd_strs) / sizeof(char *); const char *arg = NULL; float f; int cmd; int i; for (cmd = 0; cmd < num_cmd_strs; cmd++) { i = strlen( cmd_strs[cmd] ); if (!strncasecmp( input, cmd_strs[cmd], i )) { arg = &input[strlen( cmd_strs[cmd] )]; break; } } switch (cmd) { case 0: /* ZROT_CCW */ rotate_all_objects( Z_ROTATE_CCW ); return 0; case 1: /* ZROT_CW */ rotate_all_objects( Z_ROTATE_CW ); return 0; case 2: /* PERFSTATS */ profile( PROFILE_SHOW_STATS ); return 0; case 3: /* GEOMSTATS */ show_geometry_stats( ); return 0; case 4: /* MEMSTATS */ #ifdef WITH_TRACKMEM trackmem_show_stats( ); return 0; #else /* TRACKMEM was not compiled in */ return -1; #endif case 5: /* MEMBLOCKS */ #ifdef WITH_TRACKMEM trackmem_show_blocks( ); return 0; #else /* TRACKMEM was not compiled in */ return -1; #endif case 6: /* DGAMMA= */ /* Adjust display gamma correction */ if (!strcasecmp( arg, "OFF" )) { dgamma_correct = FALSE; queue_redraw( -1 ); return 0; } f = strtod( arg, NULL ); if ((f < 0.1) || (f > 8.0)) return -1; if (f == 1.0) dgamma_correct = FALSE; else { dgamma_correct = TRUE; calc_dgamma_lut( f ); } queue_redraw( -1 ); return 0; case 7: /* STRAKER */ case 8: /* SKUNK */ ss( ); /* // */ return 0; default: return -1; } } /* end command.c */ lightspeed-1.2a/src/geometry.c0000644000175000017500000004134107176115553012131 /* geometry.c */ /* Various geometrical and geometry-related routines */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Allocates an ogl_object */ ogl_object * alloc_ogl_object( int num_vertices, int num_indices ) { ogl_object *new_obj; int i; new_obj = xmalloc( sizeof(ogl_object) ); new_obj->num_vertices = num_vertices; new_obj->vertices0 = xmalloc( num_vertices * sizeof(point) ); new_obj->normals0 = xmalloc( num_vertices * sizeof(point) ); new_obj->iarrays = xmalloc( num_vertices * sizeof(ogl_point) ); /* Initialize "a" fields in iarrays, since we don't really use them */ for (i = 0; i < num_vertices; i++) new_obj->iarrays[i].a = 1.0; new_obj->num_indices = num_indices; new_obj->indices = xmalloc( num_indices * sizeof(unsigned int) ); new_obj->pre_dlist = 0; /* null display list */ new_obj->post_dlist = 0; /* ditto */ return new_obj; } /* Returns the size in memory (bytes) used by an ogl_object having * so many vertices and so many indices */ int calc_ogl_object_memusage( int num_vertices, int num_indices ) { int num_bytes; /* The vertices0 and normals0 arrays */ num_bytes = 2 * num_vertices * sizeof(point); /* The C4F+N3F+V3F superarray */ num_bytes += num_vertices * sizeof(ogl_point); /* The indices array */ num_bytes += num_indices * sizeof(unsigned int); /* The ogl_object structure itself */ num_bytes += sizeof(ogl_object); return num_bytes; } /* Deallocates an ogl_object */ void free_ogl_object( ogl_object *obj ) { xfree( obj->vertices0 ); xfree( obj->normals0 ); xfree( obj->iarrays ); xfree( obj->indices ); if (obj->pre_dlist != 0) glDeleteLists( obj->pre_dlist, 1 ); if (obj->post_dlist != 0) glDeleteLists( obj->post_dlist, 1 ); xfree( obj ); } /* Gets rid of all current objects */ void clear_all_objects( void ) { int i; for (i = 0; i < num_vehicle_objs; i++) free_ogl_object( vehicle_objs[i] ); xfree( vehicle_objs ); num_vehicle_objs = 0; } void rotate_all_objects( int direction ) { ogl_object *obj; float x0,y0,z0; float x,y,z; float xmax = -1E6, ymax = -1E6, zmax = -1E6; float xmin = 1E6, ymin = 1E6, zmin = 1E6; int o, v; for (o = 0; o < num_vehicle_objs; o++) { obj = vehicle_objs[o]; for (v = 0; v < obj->num_vertices; v++) { /* Rotate vertex */ x0 = obj->vertices0[v].x; y0 = obj->vertices0[v].y; z0 = obj->vertices0[v].z; rotate_xyz( direction, &x, &y, &z, x0, y0, z0 ); obj->vertices0[v].x = x; obj->vertices0[v].y = y; obj->vertices0[v].z = z; /* Update vehicle extents */ xmin = MIN(x, xmin); xmax = MAX(x, xmax); ymin = MIN(y, ymin); ymax = MAX(y, ymax); zmin = MIN(z, zmin); zmax = MAX(z, zmax); /* Rotate normal too */ x0 = obj->normals0[v].x; y0 = obj->normals0[v].y; z0 = obj->normals0[v].z; rotate_xyz( direction, &x, &y, &z, x0, y0, z0 ); obj->normals0[v].x = x; obj->normals0[v].y = y; obj->normals0[v].z = z; } } /* Reset vehicle_extents */ vehicle_extents.xmin = xmin; vehicle_extents.xmax = xmax; vehicle_extents.ymin = ymin; vehicle_extents.ymax = ymax; vehicle_extents.zmin = zmin; vehicle_extents.zmax = zmax; vehicle_extents.avg = ((xmax - xmin) + (ymax - ymin) + (zmax - zmin)) / 3; queue_redraw( -1 ); } /* Rotates an XYZ triplet whichever way specified * The ?_ALIGN actions realign a point from the x-axis to the indicated axis */ void rotate_xyz( int action, float *x, float *y, float *z, float x0, float y0, float z0 ) { switch (action) { case X_ALIGN: *x = x0; *y = y0; *z = z0; break; case Y_ALIGN: *x = - y0; *y = x0; *z = z0; break; case Z_ALIGN: *x = - z0; *y = y0; *z = x0; break; case Z_ROTATE_CW: *x = y0; *y = - x0; *z = z0; break; case Z_ROTATE_CCW: *x = - y0; *y = x0; *z = z0; break; default: #ifdef DEBUG crash( "rotate_xyz( ): invalid action" ); #endif return; } } /* Calculate unit normal vector for a given triangle */ point * calc_tri_normal( point *a, point *b, point *c ) { static point normal; point vec_ab; point vec_ac; float d; /* Obtain A->B vector */ vec_ab.x = b->x - a->x; vec_ab.y = b->y - a->y; vec_ab.z = b->z - a->z; /* Obtain A->C vector */ vec_ac.x = c->x - a->x; vec_ac.y = c->y - a->y; vec_ac.z = c->z - a->z; /* Obtain cross product (A->B x A->C) to get normal vector */ normal.x = vec_ab.y * vec_ac.z - vec_ab.z * vec_ac.y; normal.y = vec_ab.z * vec_ac.x - vec_ab.x * vec_ac.z; normal.z = vec_ab.x * vec_ac.y - vec_ab.y * vec_ac.x; /* Scale it by own length to get unit normal vector */ d = sqrt( SQR(normal.x) + SQR(normal.y) + SQR(normal.z) ); if (d < 1E-6) d = 1.0; normal.x /= d; normal.y /= d; normal.z /= d; return &normal; } /* Calculate the centroid of a given triangle */ point * calc_tri_centroid( point *a, point *b, point *c ) { static point centroid; centroid.x = (a->x + b->x + c->x) / 3.0; centroid.y = (a->y + b->y + c->y) / 3.0; centroid.z = (a->z + b->z + c->z) / 3.0; return ¢roid; } /* Calculate area of a given triangle */ float calc_tri_area( point *a, point *b, point *c ) { point vec_ab, vec_ac; point xprod; /* Obtain A->B vector */ vec_ab.x = b->x - a->x; vec_ab.y = b->y - a->y; vec_ab.z = b->z - a->z; /* Obtain A->C vector */ vec_ac.x = c->x - a->x; vec_ac.y = c->y - a->y; vec_ac.z = c->z - a->z; /* Magnitude of cross product == 2 * area of ascribed triangle */ xprod.x = vec_ab.y * vec_ac.z - vec_ab.z * vec_ac.y; xprod.y = vec_ab.z * vec_ac.x - vec_ab.x * vec_ac.z; xprod.z = vec_ab.x * vec_ac.y - vec_ab.y * vec_ac.x; return sqrt( SQR(xprod.x) + SQR(xprod.y) + SQR(xprod.z) ) / 2.0; } void show_geometry_stats( void ) { ogl_object *obj; float r,g,b; float ex,ey,ez; int vnum, inum; int vnum_total = 0, inum_total = 0; int i; printf( "=========== Light Speed! geometry stats ===========\n" ); printf( "Object Vertices Indices RGB base color\n" ); printf( "------ -------- ------- ------------------\n" ); for (i = 0; i < num_vehicle_objs; i++) { obj = vehicle_objs[i]; vnum = obj->num_vertices; vnum_total += vnum; inum = obj->num_indices; inum_total += inum; r = obj->color0.r; g = obj->color0.g; b = obj->color0.b; printf( "%6d%12d%11d (%.2f, %.2f, %.2f)\n", i, vnum, inum, r, g, b ); } printf( "------ -------- ------- ------------------\n" ); printf( "Object Vertices Indices RGB base color\n" ); printf( "------ -------- -------\n" ); printf( " Total%12d%11d\n", vnum_total, inum_total ); ex = vehicle_extents.xmax - vehicle_extents.xmin; ey = vehicle_extents.ymax - vehicle_extents.ymin; ez = vehicle_extents.zmax - vehicle_extents.zmin; printf( " Size: %.3f x %.3f x %.3f\n", ex, ey, ez ); printf( "===================================================\n" ); fflush( stdout ); } #ifdef WITH_SRS_EXPORTER /* Write out an .srs (Special Relativity Scene) file, for use with the * BACKLIGHT relativistic raytracer */ int export_srs( const char *filename, int width, int height, int stereo_view, int visible_faces_only ) { FILE *srs; camera eye_cam; point p; rgb_color *bg; float dx,dy; float eye_dx, eye_dy; float t; int flag, i; srs = fopen( filename, "w" ); /* Initialize output camera */ memcpy( &out_cam, usr_cams[0], sizeof(camera) ); out_cam.width = width; out_cam.height = height; /* Header and global settings */ fprintf( srs, "// %s\n", file_basename( filename, NULL ) ); fprintf( srs, "// File generated by the Light Speed! SRS exporter\n" ); fprintf( srs, "// for use with the BACKLIGHT relativistic raytracer\n\n" ); fprintf( srs, "Width = %d\n", width ); fprintf( srs, "Height = %d\n\n", height ); fprintf( srs, "Antialias = 1\n" ); /* Doppler shift switch */ flag = warp( QUERY, MESG_(WARP_DOPPLER_SHIFT) ); i = flag ? 1 : 0; fprintf( srs, "Doppler = %d\n", i ); /* Headlight effect (intensity) switch */ flag = warp( QUERY, MESG_(WARP_HEADLIGHT_EFFECT) ); i = flag ? 1 : 0; fprintf( srs, "Intensity = %d\n\n", i ); fprintf( srs, "Output_File_Name = \"%s\"\n\n", file_basename( filename, ".srs" ) ); /* Background color */ fprintf( srs, "background { colour rgb " ); bg = &background; fprintf( srs, "< %.2f, %.2f, %.2f > }\n\n", bg->r, bg->g, bg->b ); /* Stationary (observer) frame */ fprintf( srs, "frame {\n" ); fprintf( srs, "\t// Observer frame (stationary)\n" ); /* Camera(s) */ t = C * cur_time_t; if (stereo_view) { /* Stereoscopic view */ dx = out_cam.target.x - out_cam.pos.x; dy = out_cam.target.y - out_cam.pos.y; eye_dx = (EYE_SPACING / 2.0) * dy / sqrt( SQR(dx) + SQR(dy) ); eye_dy = - (EYE_SPACING / 2.0) * dx / sqrt( SQR(dx) + SQR(dy) ); fprintf( srs, "\t// Left eye view\n" ); memcpy( &eye_cam, &out_cam, sizeof(camera) ); eye_cam.pos.x -= eye_dx; eye_cam.pos.y -= eye_dy; write_srs_camera( srs, &eye_cam, t ); fprintf( srs, "\t// Right eye view\n" ); memcpy( &eye_cam, &out_cam, sizeof(camera) ); eye_cam.pos.x += eye_dx; eye_cam.pos.y += eye_dy; write_srs_camera( srs, &eye_cam, t ); } else { /* Normal view */ write_srs_camera( srs, &out_cam, t ); } /* Light source */ fprintf( srs, "\tlight_source {\n" ); convert_to_srs_cs( &p, &out_cam.pos ); fprintf( srs, "\t\t< %.3f, %.3f, %.3f >\n", p.x, p.y, p.z ); fprintf( srs, "\t\tcolour rgb " ); fprintf( srs, "< 1, 1, 1 >\n" ); fprintf( srs, "\t}\n" ); fprintf( srs, "}\n\n" ); /* Moving (object) frame */ fprintf( srs, "frame {\n" ); fprintf( srs, "\t// Object frame (moving)\n" ); fprintf( srs, "\t// v = %s\n", velocity_string( velocity, TRUE ) ); fprintf( srs, "\tvelocity " ); fprintf( srs, "< %.6f, 0, 0 >\n", velocity / C ); /* Export lattice or arbitrary mesh geometry */ fprintf( srs, "\n" ); if (object_mode == MODE_LATTICE) write_srs_lattice( srs ); else write_srs_mesh( srs, &out_cam.pos, visible_faces_only ); fprintf( srs, "\n" ); fprintf( srs, "}\n" ); fclose( srs ); return 0; } void write_srs_mesh( FILE *srs, point *cam_pos, int visible_faces_only ) { ogl_object *obj; point *face_verts[4]; point *face_norms[4]; point *vert_a, *vert_b; point tri_verts[3]; point *norm, *cent; float dx,dy,dz; float fdir; int checks[6][2] = { {0,1}, {1,2}, {2,0}, {0,3}, {1,3}, {2,3} }; int face_size; int num_faces; int num_checks; int *face_flags; int base, ind, ind_a, ind_b; int bad_face, at_least_one_good_face; int o, f, i, a, b; fprintf( srs, "\t// **** Begin mesh definition ****\n" ); for (o = 0; o < num_vehicle_objs; o++) { obj = vehicle_objs[o]; switch (obj->type) { case GL_TRIANGLES: face_size = 3; num_checks = 3; break; case GL_QUADS: face_size = 4; num_checks = 6; break; default: #ifdef DEBUG crash( "write_srs_mesh( ): invalid object type" ); #endif return; } num_faces = obj->num_indices / face_size; face_flags = xmalloc( num_faces * sizeof(int) ); /* First, check for good faces in this object * (good = no coincident vertices, no zero normals) */ at_least_one_good_face = FALSE; for (f = 0; f < num_faces; f++) { base = f * face_size; bad_face = FALSE; /* benefit of the doubt */ for (i = 0; i < num_checks; i++) { /* Check between vertex pair */ a = checks[i][0]; b = checks[i][1]; ind_a = obj->indices[base + a]; ind_b = obj->indices[base + b]; vert_a = &obj->vertices0[ind_a]; vert_b = &obj->vertices0[ind_b]; dx = ABS(vert_a->x - vert_b->x); dy = ABS(vert_a->y - vert_b->y); dz = ABS(vert_a->z - vert_b->z); if ((dx < 1E-4) && (dy < 1E-4) && (dz < 1E-4)) bad_face = TRUE; } /* Check face normals */ for (i = 0; i < face_size; i++) { ind = obj->indices[base + i]; norm = &obj->normals0[ind]; dx = ABS(norm->x); dy = ABS(norm->y); dz = ABS(norm->z); if ((dx < 1E-2) && (dy < 1E-2) && (dz < 1E-2)) bad_face = TRUE; } /* If only visible faces are desired, check if face * is facing the camera (dropping it if not) */ if (visible_faces_only && !bad_face) { for (i = 0; i < 3; i++) { ind = obj->indices[base + i]; memcpy( &tri_verts[i], &obj->vertices0[ind], sizeof(point) ); warp_point( &tri_verts[i], NULL, cam_pos ); } /* Calculate (warped) flat triangle normal * (for quads: 4th vertex is coplanar anyway) */ norm = calc_tri_normal( &tri_verts[0], &tri_verts[1], &tri_verts[2] ); /* Calculate (warped) centroid and then the * triangle-to-camera (reverse view) vector */ cent = calc_tri_centroid( &tri_verts[0], &tri_verts[1], &tri_verts[2] ); dx = cam_pos->x - cent->x; dy = cam_pos->y - cent->y; dz = cam_pos->z - cent->z; /* Get dot product of normal and rview vectors */ fdir = (norm->x * dx) + (norm->y * dy) + (norm->z * dz); if (fdir < 0) bad_face = TRUE; /* not facing camera */ } if (bad_face) face_flags[f] = FALSE; else { face_flags[f] = TRUE; at_least_one_good_face = TRUE; } } if (!at_least_one_good_face) { xfree( face_flags ); continue; } /* Write out the good faces */ fprintf( srs, "\tunion {\n" ); for (f = 0; f < num_faces; f++) { if (!face_flags[f]) continue; /* skip bad face */ base = f * face_size; for (i = 0; i < face_size; i++) { ind = obj->indices[base + i]; face_verts[i] = &obj->vertices0[ind]; face_norms[i] = &obj->normals0[ind]; } write_srs_smooth_triangle( srs, face_verts, face_norms ); if (face_size == 4) { /* Output a 2nd triangle to make a quad * Shift 3rd and 4th vertices down */ face_verts[1] = face_verts[2]; face_norms[1] = face_norms[2]; face_verts[2] = face_verts[3]; face_norms[2] = face_norms[3]; write_srs_smooth_triangle( srs, face_verts, face_norms ); } } xfree( face_flags ); /* Write out face group color */ write_srs_pigment( srs, &obj->color0 ); fprintf( srs, "\t}\n" ); } fprintf( srs, "\t// **** End mesh definition ****\n" ); } void write_srs_camera( FILE *srs, camera *cam, float t ) { point p; float aspect_ratio; aspect_ratio = (float)cam->width / (float)cam->height; fprintf( srs, "\tcamera {\n" ); fprintf( srs, "\t\tlocation " ); convert_to_srs_cs( &p, &cam->pos ); fprintf( srs, "< %.3f, %.3f, %.3f >, %.3f\n", p.x, p.y, p.z, t ); fprintf( srs, "\t\tup < 0, 1, 0 >\n" ); fprintf( srs, "\t\tright " ); fprintf( srs, "< %.3f, 0, 0 >\n", - aspect_ratio ); fprintf( srs, "\t\tangle %.2f\n", cam->fov ); fprintf( srs, "\t\tlook_at " ); convert_to_srs_cs( &p, &cam->target ); fprintf( srs, "< %.3f, %.3f, %.3f >\n", p.x, p.y, p.z ); fprintf( srs, "\t}\n" ); } void write_srs_sphere( FILE *srs, point *center, float radius ) { fprintf( srs, "\t\tsphere {\n" ); fprintf( srs, "\t\t\t< %.3f, %.3f, %.3f >,\n", center->x, center->y, center->z ); fprintf( srs, "\t\t\t%.3f\n", radius ); fprintf( srs, "\t\t}\n" ); } void write_srs_cylinder( FILE *srs, point *p1, point *p2, float radius ) { fprintf( srs, "\t\tcylinder {\n" ); fprintf( srs, "\t\t\t< %.3f, %.3f, %.3f >,\n", p1->x, p1->y, p1->z ); fprintf( srs, "\t\t\t< %.3f, %.3f, %.3f >,\n", p2->x, p2->y, p2->z ); fprintf( srs, "\t\t\t%.3f\n", radius ); fprintf( srs, "\t\t}\n" ); } void write_srs_smooth_triangle( FILE *srs, point **vertices, point **normals ) { point vert_srs, norm_srs; int i; fprintf( srs, "\t\tsmooth_triangle {\n" ); for (i = 0; i < 3; i++) { convert_to_srs_cs( &vert_srs, vertices[i] ); fprintf( srs, "\t\t\t< %.4f, %.4f, %.4f >,\n", vert_srs.x, vert_srs.y, vert_srs.z ); convert_to_srs_cs( &norm_srs, normals[i] ); fprintf( srs, "\t\t\t < %.4f, %.4f, %.4f >", norm_srs.x, norm_srs.y, norm_srs.z ); if (i < 2) fprintf( srs, ",\n" ); else fprintf( srs, "\n" ); } fprintf( srs, "\t\t}\n" ); } void write_srs_pigment( FILE *srs, rgb_color *color ) { float r,g,b; fprintf( srs, "\t\tpigment {\n" ); fprintf( srs, "\t\t\tcolour rgb " ); r = color->r; g = color->g; b = color->b; fprintf( srs, "< %.3f, %.3f, %.3f >\n", r, g, b ); fprintf( srs, "\t\t}\n" ); } /* Converts a point from our coordinate system (right-handed, z-axis up) to the * BACKLIGHT/SRS coordinate system (right-handed, y-axis up) */ void convert_to_srs_cs( point *p_srs, point *p_ls ) { p_srs->x = p_ls->x; p_srs->y = p_ls->z; p_srs->z = - p_ls->y; } #endif /* WITH_SRS_EXPORTER */ /* end geometry.c */ lightspeed-1.2a/src/globals.c0000644000175000017500000000756207176115553011730 /* globals.c */ /* Global variables */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Message value array (used in conjunction with the MESG_ macro) */ const int mesg_vals[] = { 0, 1, 2, 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,28,29,30,31,32,33,34,35,36,37,38,39, 40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59, 60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 }; /* Unit definitions */ const int num_unit_systems = 3; const char *unit_suffixes[] = { "c", "m/s", "Km/h" }; const double unit_conv_factors[] = { C, 1.0, (5.0/18.0) }; const int unit_num_decimals[] = { 6, 0, 0 }; int cur_unit_system = DEF_VELOCITY_UNITS; /* Background colors */ const int num_background_colors = 4; /* Background color names are defined in lstrings.c */ const rgb_color bkgd_colors[] = { { 0.0, 0.0, 0.0 }, { 0.25, 0.25, 0.25 }, { 0.85, 0.85, 0.85 }, { 1.0, 1.0, 1.0 } }; rgb_color background = { 0.0, 0.0, 0.0 }; /* Fonts for info display */ const int num_font_sizes = 4; const char *sys_font_names[] = { "-adobe-helvetica-bold-o-normal--*-120-*-*-*-*-*-*", "-adobe-helvetica-bold-o-normal--*-140-*-*-*-*-*-*", "-adobe-helvetica-bold-o-normal--*-180-*-*-*-*-*-*", "-adobe-helvetica-bold-o-normal--*-240-*-*-*-*-*-*" }; const int sys_font_sizes[] = { 120, 140, 180, 240 }; /* Character code for the "micro-" prefix glyph (looks similar to a u) * NOTE: revise ogl_draw_string( ) if >= 192 */ const int micro_glyph = 181; /* Stock camera lenses (specified in mm) */ const int num_stock_lenses = 6; const float stock_lenses[ ] = { 28, 35, 50, 85, 135, 200 }; /* Image format extensions * Order must match that of the IMAGE_FORMAT_??? symbols in lightspeed.h */ const char *image_format_exts[] = { ".png", ".tif" }; /* Vehicle velocity */ double velocity = 1.0; /* Current time t * (of simulation-- NOT system clock */ double cur_time_t; /* This is the "real" x-position of the vehicle */ float vehicle_real_x; /* Type of object(s) currently in the viewer */ int object_mode = MODE_LATTICE; /* Current lattice dimensions (in lattice units) */ int lattice_size_x = DEF_LATTICE_X; int lattice_size_y = DEF_LATTICE_Y; int lattice_size_z = DEF_LATTICE_Z; /* Graphical framerate (fps) * (don't worry, it gets better :-) */ float framerate = 0.0; /* Vehicle (moving) object(s) */ ogl_object **vehicle_objs; int num_vehicle_objs; extents vehicle_extents; /* World extents * Only xmin/xmax fields are significant, for now * (and are determined by size of floating grid) */ extents world_extents = { -10.0, 10.0, NIL, NIL, NIL, NIL, NIL }; /* Camera array. *usr_cam[0] is primary */ camera **usr_cams = NULL; int num_cams = 0; int cur_cam; /* Output camera (for snapshots and SRS scenes) */ camera out_cam; /* Advanced interface flag (controls presence of extra features) */ int advanced_interface = DEF_ADVANCED_INTERFACE; /* Gamma correction flag & lookup table * NOTE: This is display gamma, not Lorentz factor gamma! */ int dgamma_correct; float dgamma_lut[LUT_RES + 1]; /* Mouse sensitivity setting */ float mouse_sens = DEF_MOUSE_SENS; /* end globals.c */ lightspeed-1.2a/src/gtkwidgets.c0000644000175000017500000005137707176115553012464 /* gtkwidgets.c */ /* GTK+ UI-building semi-abstractions * (Most of the drudge code is in here) */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Creates and installs an OpenGL widget into specified box */ GtkWidget * add_gl_area( GtkWidget *parent_box_w ) { GtkWidget *ogl_w; ogl_w = ogl_make_widget( ); gtk_box_pack_start( GTK_BOX(parent_box_w), ogl_w, TRUE, TRUE, 0 ); gtk_widget_show( ogl_w ); gtk_widget_set_events( GTK_WIDGET(ogl_w), GDK_EXPOSURE_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK ); /* Attach the signal handlers */ gtk_signal_connect( GTK_OBJECT(ogl_w), "realize", GTK_SIGNAL_FUNC(ogl_initialize), NULL ); gtk_signal_connect( GTK_OBJECT(ogl_w), "expose_event", GTK_SIGNAL_FUNC(ogl_refresh), NULL ); gtk_signal_connect( GTK_OBJECT(ogl_w), "configure_event", GTK_SIGNAL_FUNC(ogl_resize), NULL ); gtk_signal_connect( GTK_OBJECT(ogl_w), "button_press_event", GTK_SIGNAL_FUNC(camera_move), NULL ); gtk_signal_connect( GTK_OBJECT(ogl_w), "button_release_event", GTK_SIGNAL_FUNC(camera_move), NULL ); gtk_signal_connect( GTK_OBJECT(ogl_w), "motion_notify_event", GTK_SIGNAL_FUNC(camera_move), NULL ); return ogl_w; } /* Creates a base dialog window */ GtkWidget * make_dialog_window( const char *title, void *callback_close ) { GtkWidget *dialog_window_w; dialog_window_w = gtk_window_new( GTK_WINDOW_DIALOG ); gtk_window_set_title( GTK_WINDOW(dialog_window_w), title ); gtk_container_set_border_width( GTK_CONTAINER(dialog_window_w), 0 ); if (callback_close != NULL) { gtk_signal_connect( GTK_OBJECT(dialog_window_w), "destroy", GTK_SIGNAL_FUNC(callback_close), MESG_(DIALOG_CLOSE) ); } /* Note, no gtk_widget_show( ) */ return dialog_window_w; } /* Creates a simple, click-away message dialog */ GtkWidget * message_window( const char *title, const char *message_text ) { GtkWidget *message_window_w; GtkWidget *vbox_w; GtkWidget *hbox_w; GtkWidget *frame_w; GtkWidget *button_w; message_window_w = make_dialog_window( title, NULL ); gtk_window_set_position( GTK_WINDOW(message_window_w), GTK_WIN_POS_MOUSE ); gtk_signal_connect( GTK_OBJECT(message_window_w), "delete_event", GTK_SIGNAL_FUNC(gtk_widget_destroy), NULL ); vbox_w = add_vbox( message_window_w, FALSE, 10 ); frame_w = add_frame( vbox_w, NULL ); hbox_w = add_hbox( frame_w, FALSE, 10 ); add_label( hbox_w, message_text ); /* OK button */ button_w = gtk_button_new( ); add_label( button_w, "OK" ); gtk_box_pack_start( GTK_BOX(vbox_w), button_w, TRUE, TRUE, 0 ); gtk_signal_connect_object( GTK_OBJECT(button_w), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(message_window_w) ); gtk_widget_show( button_w ); gtk_widget_show( message_window_w ); return message_window_w; } /* Confirmation dialog */ GtkWidget * confirmation_dialog( const char *title, const char *message_text, void *callback ) { GtkWidget *confirm_window_w; GtkWidget *main_vbox_w; GtkWidget *hbox_w; GtkWidget *frame_w; GtkWidget *button_w; confirm_window_w = make_dialog_window( title, callback ); gtk_window_set_position( GTK_WINDOW(confirm_window_w), GTK_WIN_POS_MOUSE ); gtk_signal_connect( GTK_OBJECT(confirm_window_w), "delete_event", GTK_SIGNAL_FUNC(gtk_widget_destroy), NULL ); main_vbox_w = add_vbox( confirm_window_w, FALSE, 10 ); frame_w = add_frame( main_vbox_w, NULL ); hbox_w = add_hbox( frame_w, FALSE, 10 ); add_label( hbox_w, message_text ); hbox_w = add_hbox( main_vbox_w, TRUE, 0 ); /* OK button */ button_w = gtk_button_new( ); add_label( button_w, "OK" ); gtk_box_pack_start( GTK_BOX(hbox_w), button_w, TRUE, TRUE, 0 ); gtk_signal_connect_object( GTK_OBJECT(button_w), "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(confirm_window_w) ); gtk_signal_connect( GTK_OBJECT(button_w), "clicked", GTK_SIGNAL_FUNC(callback), MESG_(DIALOG_OK_CONFIRM) ); gtk_signal_connect_object( GTK_OBJECT(button_w), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(confirm_window_w) ); gtk_widget_show( button_w ); add_hbox( hbox_w, TRUE, 0 ); /* spacer */ /* Cancel button */ button_w = gtk_button_new( ); add_label( button_w, "Cancel" ); gtk_box_pack_start( GTK_BOX(hbox_w), button_w, TRUE, TRUE, 0 ); gtk_signal_connect_object( GTK_OBJECT(button_w), "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(confirm_window_w) ); gtk_signal_connect( GTK_OBJECT(button_w), "clicked", GTK_SIGNAL_FUNC(callback), MESG_(DIALOG_CLOSE) ); gtk_signal_connect_object( GTK_OBJECT(button_w), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(confirm_window_w) ); gtk_widget_show( button_w ); gtk_widget_show( confirm_window_w ); return confirm_window_w; } /* Creates a file selection dialog */ GtkWidget * make_filesel_window( const char *title, const char *init_filename, int show_fileops, void *callback_handler ) { GtkWidget *filesel_w; filesel_w = gtk_file_selection_new( title ); if (!show_fileops) gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION(filesel_w) ); if (init_filename != NULL) gtk_file_selection_set_filename( GTK_FILE_SELECTION(filesel_w), init_filename ); gtk_signal_connect( GTK_OBJECT(filesel_w), "destroy", GTK_SIGNAL_FUNC(callback_handler), MESG_(DIALOG_CLOSE) ); gtk_signal_connect( GTK_OBJECT(GTK_FILE_SELECTION(filesel_w)->cancel_button), "clicked", GTK_SIGNAL_FUNC(callback_handler), MESG_(DIALOG_CLOSE) ); gtk_signal_connect( GTK_OBJECT(GTK_FILE_SELECTION(filesel_w)->ok_button), "clicked", GTK_SIGNAL_FUNC(callback_handler), MESG_(DIALOG_OK) ); return filesel_w; } /* Add a menu to a menu bar (or a submenu to a menu) */ GtkWidget * add_menu( GtkWidget *parent_menu_w, const char *label ) { GtkWidget *menu_item_w; GtkWidget *menu_w; menu_item_w = gtk_menu_item_new_with_label( label ); /* parent_menu can be a menu bar or a regular menu */ if (GTK_IS_MENU_BAR(parent_menu_w)) gtk_menu_bar_append( GTK_MENU_BAR(parent_menu_w), menu_item_w ); else gtk_menu_append( GTK_MENU(parent_menu_w), menu_item_w ); gtk_widget_show( menu_item_w ); menu_w = gtk_menu_new( ); gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu_item_w), menu_w ); return menu_w; } /* Add a menu item to a menu */ GtkWidget * add_menu_item( GtkWidget *menu_w, const char *label, void *callback, void *callback_data ) { GtkWidget *menu_item_w; menu_item_w = gtk_menu_item_new_with_label( label ); gtk_menu_append( GTK_MENU(menu_w), menu_item_w ); if (callback != NULL) { gtk_signal_connect( GTK_OBJECT(menu_item_w), "activate", GTK_SIGNAL_FUNC(callback), callback_data ); } gtk_widget_show( menu_item_w ); return menu_item_w; } /* Add a check-button menu item to a menu */ GtkWidget * add_check_menu_item( GtkWidget *menu_w, const char *label, int init_state, void *callback, void *callback_data ) { GtkWidget *chkmenu_item_w; chkmenu_item_w = gtk_check_menu_item_new_with_label( label ); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(chkmenu_item_w), init_state ); gtk_check_menu_item_set_show_toggle( GTK_CHECK_MENU_ITEM(chkmenu_item_w), TRUE ); gtk_menu_append( GTK_MENU(menu_w), chkmenu_item_w ); gtk_signal_connect( GTK_OBJECT(chkmenu_item_w), "toggled", GTK_SIGNAL_FUNC(callback), callback_data ); gtk_widget_show( chkmenu_item_w ); return chkmenu_item_w; } /* Initiates the definition of a radio menu item group, having a specified * initially selected item (0 == first, 1 == second, etc.) */ void begin_radio_menu_group( int init_selected ) { add_radio_menu_item( NULL, (char *)&init_selected, NULL, NULL ); } /* Add a radio-button menu item to a menu * NOTE: Call begin_radio_menu_group( ) before defining the group! */ GtkWidget * add_radio_menu_item( GtkWidget *menu_w, const char *label, void *callback, void *callback_data ) { static GSList *radio_group; static int radmenu_item_num; static int init_selected; GtkWidget *radmenu_item_w = NULL; if (menu_w != NULL) { radmenu_item_w = gtk_radio_menu_item_new_with_label( radio_group, label ); radio_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM(radmenu_item_w) ); gtk_menu_append( GTK_MENU(menu_w), radmenu_item_w ); if (radmenu_item_num == init_selected) gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(radmenu_item_w), TRUE ); gtk_signal_connect( GTK_OBJECT(radmenu_item_w), "toggled", GTK_SIGNAL_FUNC(callback), callback_data ); gtk_widget_show( radmenu_item_w ); ++radmenu_item_num; } else { /* we're being called from begin_radio_menu_group( ) */ radio_group = NULL; radmenu_item_num = 0; init_selected = *((int *)label); } return radmenu_item_w; } /* Option menu definiton * Call this however many times necessary, and then call add_option_menu( ) * to stick in the finished widget */ GtkWidget * option_menu_item( const char *label, void *callback, void *callback_data ) { GtkWidget *menu_item_w; menu_item_w = gtk_menu_item_new_with_label( label ); if (callback != NULL) { gtk_signal_connect( GTK_OBJECT(menu_item_w), "activate", GTK_SIGNAL_FUNC(callback), callback_data ); } add_option_menu( menu_item_w ); return menu_item_w; } /* Add the finished option menu into the specified box widget * (widget can only be a menu item when called from option_menu_item( )) */ GtkWidget * add_option_menu( GtkWidget *widget ) { static GtkWidget *menu_w = NULL; GtkWidget *optmenu_w; if (GTK_IS_MENU_ITEM(widget)) { if (menu_w == NULL) menu_w = gtk_menu_new( ); gtk_menu_append( GTK_MENU(menu_w), widget ); gtk_widget_show( widget ); return NULL; } /* widget is a Gtk?box */ optmenu_w = gtk_option_menu_new( ); gtk_option_menu_set_menu( GTK_OPTION_MENU(optmenu_w), menu_w ); gtk_box_pack_start( GTK_BOX(widget), optmenu_w, FALSE, FALSE, 0 ); gtk_widget_show( optmenu_w ); menu_w = NULL; return optmenu_w; } /* The ever-ubiquitous separator */ void add_separator( GtkWidget *parent_w ) { GtkWidget *separator_w; if (GTK_IS_MENU(parent_w)) { separator_w = gtk_menu_item_new( ); gtk_menu_append( GTK_MENU(parent_w), separator_w ); } else { separator_w = gtk_hseparator_new( ); gtk_box_pack_start( GTK_BOX(parent_w), separator_w, TRUE, TRUE, 0 ); } gtk_widget_show( separator_w ); } /* Sets up keybindings (accelerators) * Call first with widget == NULL, then with any number of widget/keystroke * pairs, and finally with the parent window. */ void keybind( GtkWidget *widget, char *keys ) { static GtkAccelGroup *accel_group; int mods; char k; if (widget == NULL) { accel_group = gtk_accel_group_new( ); return; } if (GTK_IS_WINDOW(widget)) { gtk_accel_group_attach( accel_group, GTK_OBJECT(widget) ); return; } /* Parse keystroke string */ switch (keys[0]) { case '^': /* Ctrl- keystroke specified */ mods = GDK_CONTROL_MASK; k = keys[1]; break; default: /* Simple keypress */ mods = 0; k = keys[0]; break; } if (GTK_IS_MENU_ITEM(widget)) { gtk_widget_add_accelerator( widget, "activate", accel_group, k, mods, GTK_ACCEL_VISIBLE ); return; } if (GTK_IS_BUTTON(widget)) { gtk_widget_add_accelerator( widget, "clicked", accel_group, k, mods, GTK_ACCEL_VISIBLE ); return; } /* Default: make widget grab focus */ gtk_widget_add_accelerator( widget, "grab_focus", accel_group, k, mods, GTK_ACCEL_VISIBLE ); } /* The horizontal box widget */ GtkWidget * add_hbox( GtkWidget *parent_w, int homog, int spacing ) { GtkWidget *hbox_w; hbox_w = gtk_hbox_new( homog, spacing ); gtk_container_set_border_width( GTK_CONTAINER(hbox_w), spacing ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), hbox_w, FALSE, FALSE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), hbox_w ); gtk_widget_show( hbox_w ); return hbox_w; } /* The vertical box widget */ GtkWidget * add_vbox( GtkWidget *parent_w, int homog, int spacing ) { GtkWidget *vbox_w; vbox_w = gtk_vbox_new( homog, spacing ); gtk_container_set_border_width( GTK_CONTAINER(vbox_w), spacing ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), vbox_w, FALSE, FALSE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), vbox_w ); gtk_widget_show( vbox_w ); return vbox_w; } /* Frame widget */ GtkWidget * add_frame( GtkWidget *parent_w, const char *title ) { GtkWidget *frame_w; frame_w = gtk_frame_new( title ); if (parent_w != NULL) { if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), frame_w, FALSE, FALSE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), frame_w ); gtk_widget_show( frame_w ); } return frame_w; } /* The horizontal value slider widget */ GtkWidget * add_hscale( GtkWidget *parent_w, GtkObject *adjustment ) { GtkWidget *hscale_w; hscale_w = gtk_hscale_new( GTK_ADJUSTMENT(adjustment) ); gtk_scale_set_digits( GTK_SCALE(hscale_w), 0 ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), hscale_w, TRUE, TRUE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), hscale_w ); gtk_widget_show( hscale_w ); return hscale_w; } /* The vertical value slider widget */ GtkWidget * add_vscale( GtkWidget *parent_w, GtkObject *adjustment ) { GtkWidget *vscale_w; vscale_w = gtk_vscale_new( GTK_ADJUSTMENT(adjustment) ); gtk_scale_set_value_pos( GTK_SCALE(vscale_w), GTK_POS_RIGHT ); gtk_scale_set_digits( GTK_SCALE(vscale_w), 0 ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), vscale_w, TRUE, TRUE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), vscale_w ); gtk_widget_show( vscale_w ); return vscale_w; } /* The spin button widget */ GtkWidget * add_spin_button( GtkWidget *parent_w, GtkObject *adjustment ) { GtkWidget *spin_button_w; spin_button_w = gtk_spin_button_new( GTK_ADJUSTMENT(adjustment), 0.0, 0 ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), spin_button_w, TRUE, FALSE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), spin_button_w ); gtk_widget_show( spin_button_w ); return spin_button_w; } /* The check button widget */ GtkWidget * add_check_button( GtkWidget *parent_w, const char *label, int init_state, void *callback, void *callback_data ) { GtkWidget *chkbutton_w; chkbutton_w = gtk_check_button_new_with_label( label ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(chkbutton_w), init_state ); gtk_toggle_button_set_mode( GTK_TOGGLE_BUTTON(chkbutton_w), TRUE ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), chkbutton_w, TRUE, TRUE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), chkbutton_w ); if (callback != NULL) { gtk_signal_connect( GTK_OBJECT(chkbutton_w), "toggled", GTK_SIGNAL_FUNC(callback), callback_data ); } gtk_widget_show( chkbutton_w ); return chkbutton_w; } /* Text/data/number entry */ GtkWidget * add_entry( GtkWidget *parent_w, const char *init_str, void *callback, void *callback_data ) { GtkWidget *entry_w; entry_w = gtk_entry_new_with_max_length( 16 ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), entry_w, FALSE, FALSE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), entry_w ); gtk_entry_set_text( GTK_ENTRY(entry_w), init_str ); if (callback != NULL ) gtk_signal_connect( GTK_OBJECT(entry_w), "activate", GTK_SIGNAL_FUNC(callback), callback_data ); gtk_widget_show( entry_w ); return entry_w; } /* Sets an entry to the width of a specified string */ void set_entry_width( GtkWidget *entry_w, const char *span_str ) { GtkStyle *style; int width; style = gtk_widget_get_style( entry_w ); width = gdk_string_width( style->font, span_str ); gtk_widget_set_usize( entry_w, width, 0 ); } /* Resets the text in an entry to specified string */ void set_entry_text( GtkWidget *entry_w, const char *entry_text ) { gtk_entry_set_text( GTK_ENTRY(entry_w), entry_text ); } /* Returns the text in an entry */ char * read_entry( GtkWidget *entry_w ) { return gtk_entry_get_text( GTK_ENTRY(entry_w) ); } /* Highlights the text in an entry */ void highlight_entry( GtkWidget *entry_w ) { gtk_entry_select_region( GTK_ENTRY(entry_w), 0, GTK_ENTRY(entry_w)->text_length ); } GtkWidget * add_button( GtkWidget *parent_w, const char *label, void *callback, void *callback_data ) { GtkWidget *button_w; button_w = gtk_button_new( ); if (label != NULL) add_label( button_w, label ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), button_w, TRUE, TRUE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), button_w ); gtk_signal_connect( GTK_OBJECT(button_w), "clicked", GTK_SIGNAL_FUNC(callback), callback_data ); gtk_widget_show( button_w ); return button_w; } GtkWidget * add_label( GtkWidget *parent_w, const char *label_text ) { GtkWidget *label_w; GtkWidget *hbox_w; label_w = gtk_label_new( label_text ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), label_w, FALSE, FALSE, 0 ); else if (GTK_IS_BUTTON(parent_w)) { /* Labels are often too snug inside buttons */ hbox_w = add_hbox( parent_w, FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), label_w, TRUE, FALSE, 5 ); } else gtk_container_add( GTK_CONTAINER(parent_w), label_w ); gtk_widget_show( label_w ); return label_w; } /* Scrollable (but non-editing) text window * (I call it a "text area," as just "text" is ambiguous */ GtkWidget * add_text_area( GtkWidget *parent_w, const char *content ) { GtkWidget *text_w; GtkWidget *hbox_w; GtkWidget *vscrollbar_w; /* Horizontal box for text area + vertical scrollbar */ hbox_w = gtk_hbox_new( FALSE, 0 ); if (GTK_IS_BOX(parent_w)) gtk_box_pack_start( GTK_BOX(parent_w), hbox_w, TRUE, TRUE, 0 ); else gtk_container_add( GTK_CONTAINER(parent_w), hbox_w ); gtk_widget_show( hbox_w ); /* Text [area] widget */ text_w = gtk_text_new( NULL, NULL ); /* Set properties suited for a text viewer */ gtk_text_set_editable( GTK_TEXT(text_w), FALSE ); gtk_text_set_word_wrap( GTK_TEXT(text_w), TRUE ); gtk_box_pack_start( GTK_BOX(hbox_w), text_w, TRUE, TRUE, 0 ); gtk_widget_show( text_w ); /* Vertical scroll bar */ vscrollbar_w = gtk_vscrollbar_new( GTK_TEXT(text_w)->vadj ); gtk_box_pack_start( GTK_BOX(hbox_w), vscrollbar_w, FALSE, FALSE, 0 ); gtk_widget_show( vscrollbar_w ); /* Bring in the text */ gtk_widget_realize( text_w ); gtk_text_insert( GTK_TEXT(text_w), NULL, NULL, NULL, content, -1 ); return text_w; } void add_tooltip( GtkWidget *ambiguous_widget, const char *tip_text ) { static GtkTooltips *tooltips = NULL; if (tooltips == NULL) { tooltips = gtk_tooltips_new( ); gtk_tooltips_set_delay( tooltips, 2000 ); } gtk_tooltips_set_tip( tooltips, ambiguous_widget, tip_text, NULL ); } /* Adds an XPM */ GtkWidget * add_pixmap( GtkWidget *parent_w, GtkWidget *parent_window_w, char **xpm_data ) { GtkWidget *pixmap_w; GtkStyle *style; GdkPixmap *pixmap; GdkBitmap *mask; /* Realize the window to prevent a "NULL window" error */ gtk_widget_realize( parent_window_w ); style = gtk_widget_get_style( parent_window_w ); pixmap = gdk_pixmap_create_from_xpm_d( parent_window_w->window, &mask, &style->bg[GTK_STATE_NORMAL], xpm_data ); pixmap_w = gtk_pixmap_new( pixmap, mask ); gdk_pixmap_unref( pixmap ); gdk_bitmap_unref( mask ); gtk_box_pack_start( GTK_BOX(parent_w), pixmap_w, FALSE, FALSE, 0 ); gtk_widget_show( pixmap_w ); return pixmap_w; } /* Associates an XPM icon to a window */ void assign_icon( GtkWidget *window_w, char **xpm_data ) { GtkStyle *style; GdkPixmap *icon_pixmap; GdkBitmap *mask; gtk_widget_realize( window_w ); style = gtk_widget_get_style( window_w ); icon_pixmap = gdk_pixmap_create_from_xpm_d( window_w->window, &mask, &style->bg[GTK_STATE_NORMAL], xpm_data ); gdk_window_set_icon( window_w->window, NULL, icon_pixmap, mask ); } /* end gtkwidgets.c */ lightspeed-1.2a/src/importobjs.c0000644000175000017500000006515007176115553012472 /* importobjs.c */ /* Imports 3DS/LWO objects to our native format */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* 3D Studio reader routines */ #include "read3ds.h" /* LightWave reader routines */ #define lwPoint point #include "readlwo.h" /* Used by tessellate_object( ) */ struct face_info { int adj_faces[3]; int adj_face_edges[3]; int edgewise : 1; }; /* Forward declarations */ static int import_3ds_file( const char *filename ); static int import_3ds( r3ds_scene *scene ); static int import_lwo_file( const char *filename ); static void generate_normals( ogl_object *obj, int face_type ); static void tessellate_object( ogl_object *obj, int tess ); static unsigned int tessellate_face( ogl_object *obj, struct face_info **facei_list_ptr, int f, int e, unsigned int ind_mid ); static void triangulate_polygon( r3ds_triangle *out_tris, int num_edges, int *indices, point *vertices ); int import_objects( const char *filename ) { int rs = -1; int len; char *file_ext; char *error_str; /* Confirm that the file exists */ if (!file_exists( filename )) { len = strlen( STR_MSG_no_object_file_ARG ) + strlen( filename ) + 16; error_str = xmalloc( len * sizeof(char) ); sprintf( error_str, STR_MSG_no_object_file_ARG, filename ); message_window( STR_DLG_Error, error_str ); xfree( error_str ); return -1; } file_ext = strrchr( filename, '.' ); if (file_ext == NULL) file_ext = ""; /* Dispatch a file loader, based on the file's extension */ if (!strcasecmp( file_ext, ".3DS" )) { if (r3ds_file_is_3ds( filename )) rs = import_3ds_file( filename ); else { message_window( STR_DLG_Error, STR_MSG_not_3ds_file ); return -1; } } else if (!strcasecmp( file_ext, ".PRJ" )) { if (r3ds_file_is_prj( filename )) rs = import_3ds_file( filename ); else { message_window( STR_DLG_Error, STR_MSG_not_prj_file ); return -1; } } else if (!strcasecmp( file_ext, ".LWO" )) { if (lw_is_lwobject( filename )) rs = import_lwo_file( filename ); else { message_window( STR_DLG_Error, STR_MSG_not_lwo_file ); return -1; } } else { /* Looks like we don't have an extension to help us * Try file magic numbers */ if (r3ds_file_is_3ds( filename )) rs = import_3ds_file( filename ); else if (r3ds_file_is_prj( filename )) rs = import_3ds_file( filename ); else if (lw_is_lwobject( filename )) rs = import_lwo_file( filename ); else { /* Whatever it is, we can't read it */ message_window( STR_DLG_Error, STR_MSG_unknown_obj_format ); return -1; } } return rs; } static int import_3ds_file( const char *filename ) { r3ds_scene *scene; /* Load .3DS */ scene = read3ds( filename ); if (scene == NULL) { message_window( STR_DLG_Error, STR_MSG_bad_3ds_file ); return -1; } return import_3ds( scene ); } static int import_3ds( r3ds_scene *scene ) { r3ds_trimesh **trimeshes; r3ds_trimesh *tmesh; ogl_object *obj; point *vert_a, *vert_b, *vert_c; point *tri_cent; point centroid = { 0.0, 0.0, 0.0 }; r3ds_color24 *mat_color24; rgb_color color; float scale_factor; float x0,y0,z0; float x,y,z; float tri_area; float tris_total_area = 0.0; float xmax = -1E6, ymax = -1E6, zmax = -1E6; float xmin = 1E6, ymin = 1E6, zmin = 1E6; int num_trimeshes; int num_bad_trimeshes = 0; int num_vertices; int num_indices; int num_bad_tris; int cur_index; int a,b,c; int o, v, i, t; /* Mike, you have a call */ /* Break objects apart by material * (each ogl_object ultimately has one base color) */ r3ds_split_scene_trimeshes( scene, R3DS_SPLIT_BY_MATERIAL ); /* We can't really handle objects with >1 smoothing group, * so break those apart as necessary */ r3ds_split_scene_trimeshes( scene, R3DS_SPLIT_BY_SMGROUP ); trimeshes = scene->tmeshes; num_trimeshes = scene->num_tmeshes; vehicle_objs = xmalloc( num_trimeshes * sizeof(ogl_object *) ); /* Make model metric (from inches) */ scale_factor = scene->inches_per_unit * 0.0254; /* Now, convert each [good] r3ds_trimesh into an ogl_object */ for (o = 0; o < num_trimeshes; o++) { tmesh = trimeshes[o]; if ((tmesh->num_verts < 3) || (tmesh->num_tris < 1)) { ++num_bad_trimeshes; continue; } /* Material of 1st triangle == material of entire object */ i = tmesh->tris[0].mat_id; if (i >= 0) { mat_color24 = &scene->mats[i].diffuse; color.r = (float)(mat_color24->red) / 255.0; color.g = (float)(mat_color24->green) / 255.0; color.b = (float)(mat_color24->blue) / 255.0; } else { color.r = 0.5; color.g = 0.5; color.b = 0.5; } num_vertices = tmesh->num_verts; num_indices = 3 * tmesh->num_tris; obj = alloc_ogl_object( num_vertices, num_indices ); obj->type = GL_TRIANGLES; obj->color0.r = color.r; obj->color0.g = color.g; obj->color0.b = color.b; for (v = 0; v < num_vertices; v++) { x0 = tmesh->verts[v].x; y0 = tmesh->verts[v].y; z0 = tmesh->verts[v].z; /* Scale object, and rotate to x-axial alignment */ x = - y0 * scale_factor; y = x0 * scale_factor; z = z0 * scale_factor; obj->vertices0[v].x = x; obj->vertices0[v].y = y; obj->vertices0[v].z = z; /* Normals will be taken care of shortly... */ } /* Copy triangles, and at the same time sum up the weighed * triangle centroids to get an overall centroid later on */ cur_index = 0; num_bad_tris = 0; for (t = 0; t < tmesh->num_tris; t++) { a = tmesh->tris[t].a; b = tmesh->tris[t].b; c = tmesh->tris[t].c; vert_a = &obj->vertices0[a]; vert_b = &obj->vertices0[b]; vert_c = &obj->vertices0[c]; tri_cent = calc_tri_centroid( vert_a, vert_b, vert_c ); tri_area = calc_tri_area( vert_a, vert_b, vert_c ); centroid.x += tri_cent->x * tri_area; centroid.y += tri_cent->y * tri_area; centroid.z += tri_cent->z * tri_area; tris_total_area += tri_area; if (tri_area > 1E-8) { obj->indices[cur_index++] = a; obj->indices[cur_index++] = b; obj->indices[cur_index++] = c; } else ++num_bad_tris; /* very VERY tiny triangle */ } if (num_bad_tris > 0) { /* Readjust index array size */ obj->num_indices -= 3 * num_bad_tris; obj->indices = xrealloc( obj->indices, obj->num_indices * sizeof(int) ); } /* No longer need the trimesh * Partially free the big arrays to economize on memory * r3ds_free_scene( ) will finish off the rest, shortly */ tmesh->verts = xrealloc( tmesh->verts, sizeof(r3ds_point) ); if (tmesh->num_tris > 1) tmesh->tris = xrealloc( tmesh->tris, sizeof(r3ds_triangle) ); generate_normals( obj, GL_TRIANGLES ); /* This ogl_object is ready */ vehicle_objs[o - num_bad_trimeshes] = obj; } /* Deallocate scene */ r3ds_free_scene( scene ); num_vehicle_objs = num_trimeshes - num_bad_trimeshes; if (num_vehicle_objs == 0) { message_window( STR_DLG_Error, STR_MSG_empty_3ds_file ); return -1; } /* Calculate centroid */ centroid.x /= tris_total_area; centroid.y /= tris_total_area; centroid.z /= tris_total_area; /* Center the model (make world origin and centroid coincide) */ for (o = 0; o < num_vehicle_objs; o++) { obj = vehicle_objs[o]; for (v = 0; v < obj->num_vertices; v++) { obj->vertices0[v].x -= centroid.x; obj->vertices0[v].y -= centroid.y; obj->vertices0[v].z -= centroid.z; /* Update xyz extents */ x = obj->vertices0[v].x; y = obj->vertices0[v].y; z = obj->vertices0[v].z; xmin = MIN(x, xmin); xmax = MAX(x, xmax); ymin = MIN(y, ymin); ymax = MAX(y, ymax); zmin = MIN(z, zmin); zmax = MAX(z, zmax); } } vehicle_extents.xmin = xmin; vehicle_extents.xmax = xmax; vehicle_extents.ymin = ymin; vehicle_extents.ymax = ymax; vehicle_extents.zmin = zmin; vehicle_extents.zmax = zmax; vehicle_extents.avg = ((xmax - xmin) + (ymax - ymin) + (zmax - zmin)) / 3; /* Finally, tessellate the objects so that they deform nicely */ for (o = 0; o < num_vehicle_objs; o++) tessellate_object( vehicle_objs[o], 8 ); return 0; } /* This next importer basically converts a LightWave object into 3DS data using * the same r3ds_build( ) of read3ds. The only additional thing it needs is * a polygon triangulator, as LW objects can have arbitrary n-sided faces */ static int import_lwo_file( const char *filename ) { r3ds_scene *scene; lwObject *lwo; lwFace *face; r3ds_triangle poly_tris_buffer[256]; r3ds_triangle *poly_tris; r3ds_triangle *tri; int abcf[4]; int rgb[3]; float xyz[3]; int num_tris; int num_poly_tris; int mat_id = -1; int i, j; /* Read LWO file */ lwo = lw_object_read( filename ); if (lwo == NULL) { message_window( STR_DLG_Error, STR_MSG_bad_lwo_file ); return -1; } /* Initialize read3ds scene builder */ r3ds_build( R3DS_INITIALIZE, NULL ); /* Input materials */ for (i = 0; i < lwo->material_cnt; i++) { r3ds_build( R3DS_NEW_MATERIAL, lwo->materials[i].name ); r3ds_build( R3DS_MAT_DIFFUSE_COLOR, NULL ); rgb[0] = (int)(lwo->materials[i].r * 255.0); rgb[1] = (int)(lwo->materials[i].g * 255.0); rgb[2] = (int)(lwo->materials[i].b * 255.0); r3ds_build( R3DS_COLOR24, rgb ); } /* Input object mesh */ r3ds_build( R3DS_NEW_OBJECT, filename ); r3ds_build( R3DS_DEF_TRIMESH, NULL ); /* Input vertices */ r3ds_build( R3DS_NUM_VERTS, &lwo->vertex_cnt ); for (i = 0; i < lwo->vertex_cnt; i++) { /* Rotate coordinate system to 3DS standard */ xyz[0] = lwo->vertices[i].x; xyz[1] = - lwo->vertices[i].z; xyz[2] = lwo->vertices[i].y; r3ds_build( R3DS_VERT, xyz ); } /* Count how many triangles there will be */ num_tris = 0; for (i = 0; i < lwo->face_cnt; i++) { face = &lwo->faces[i]; /* (Quickly double-check that the indices are within bounds) */ for (j = 0; j < face->index_cnt; j++) if (face->indices[j] >= lwo->vertex_cnt) face->indices[j] = 0; /* Faces with <3 sides are not faces */ if (face->index_cnt < 3) continue; /* Otherwise, an n-sided polygon will become (n-2) triangles */ num_tris += (face->index_cnt - 2); } r3ds_build( R3DS_NUM_TRIS, &num_tris ); /* Process faces and input triangles */ num_tris = 0; for (i = 0; i < lwo->face_cnt; i++) { face = &lwo->faces[i]; if (face->index_cnt < 3) continue; if (mat_id != face->mat_id) { mat_id = face->mat_id; r3ds_build( R3DS_TRI_MATERIAL_CURRENT, lwo->materials[mat_id].name ); } if (face->index_cnt == 3) { abcf[0] = face->indices[0]; abcf[1] = face->indices[1]; abcf[2] = face->indices[2]; abcf[3] = 0x07; /* Flags: all edges visible */ r3ds_build( R3DS_TRI_FACE, abcf ); r3ds_build( R3DS_TRI_MATERIAL, &num_tris ); ++num_tris; } else { num_poly_tris = face->index_cnt - 2; /* Avoid small malloc()'s at all costs (well, almost) */ if (num_poly_tris <= 256) poly_tris = poly_tris_buffer; else poly_tris = xmalloc( num_poly_tris * sizeof(r3ds_triangle) ); triangulate_polygon( poly_tris, face->index_cnt, face->indices, lwo->vertices ); for (j = 0; j < num_poly_tris; j++) { tri = &poly_tris[j]; abcf[0] = tri->a; abcf[1] = tri->b; abcf[2] = tri->c; abcf[3] = 0x07; r3ds_build( R3DS_TRI_FACE, abcf ); r3ds_build( R3DS_TRI_MATERIAL, &num_tris ); ++num_tris; } if (poly_tris != poly_tris_buffer) xfree( poly_tris ); } } lw_object_free( lwo ); scene = xmalloc( sizeof(r3ds_scene) ); r3ds_build( R3DS_GET_SCENE, scene ); import_3ds( scene ); return 0; } /* Produce normals for an arbitrary triangle or quad mesh * (either is referred to as a generalized "face") */ static void generate_normals( ogl_object *obj, int face_type ) { struct obj_vertex { int num_faces; /* # of faces using this vertex */ point normal_sum; /* Vector sum of normals of said faces */ } *overtices, *overtex; point *plane[3]; point *normal; float x, y, z; float d; int face_size; int num_faces; int num_vertices; int base; int f, v, i; switch (face_type) { case GL_TRIANGLES: face_size = 3; break; case GL_QUADS: face_size = 4; break; default: #ifdef DEBUG crash( "generate_normals( ): invalid face type" ); #endif return; } num_faces = obj->num_indices / face_size; num_vertices = obj->num_vertices; overtices = xmalloc( num_vertices * sizeof(struct obj_vertex) ); /* Initialize vertex records */ for (v = 0; v < num_vertices; v++) { overtex = &overtices[v]; overtex->num_faces = 0; overtex->normal_sum.x = 0.0; overtex->normal_sum.y = 0.0; overtex->normal_sum.z = 0.0; } /* Step 1: Get vector sum of [face] normals for each vertex */ for (f = 0; f < num_faces; f++) { base = f * face_size; /* # of first index describing face */ /* Calculate face normal (need only 3 points for this) */ for (v = 0; v < 3; v++) { i = obj->indices[base + v]; plane[v] = &obj->vertices0[i]; } normal = calc_tri_normal( plane[0], plane[1], plane[2] ); /* Update the 3 or 4 involved vertices */ for (v = 0; v < face_size; v++) { i = obj->indices[base + v]; overtex = &overtices[i]; ++overtex->num_faces; overtex->normal_sum.x += normal->x; overtex->normal_sum.y += normal->y; overtex->normal_sum.z += normal->z; } } /* Step 2: Vertex normal = normalized sum of associated face normals */ for (v = 0; v < num_vertices; v++) { overtex = &overtices[v]; x = overtex->normal_sum.x; y = overtex->normal_sum.y; z = overtex->normal_sum.z; d = sqrt( SQR(x) + SQR(y) + SQR(z) ); if (d < 1E-6) d = 1.0; obj->normals0[v].x = x / d; obj->normals0[v].y = y / d; obj->normals0[v].z = z / d; } xfree( overtices ); } /* This reduces the face edge size (in the yz-plane) of a GL_TRIANGLES object * to below a certain threshold specified by tess (1/tess times the y- and * z-extents), with the exception that any edges shared between faces mostly * edgewise to the yz-plane are not split. This is what keeps, for example, * the tops and sides of a cube from being as heavily tessellated as the front * and back * NOTE: tess must be a power of 2 */ static void tessellate_object( ogl_object *obj, int tess ) { struct edge_info { /* Offset into edgei_list == ind_a */ unsigned int ind_b; int face; int edge; struct edge_info *next; } **edgei_list, *prev_edgei, *edgei; struct face_info *facei_list; struct face_info *facei, *facei_adj, *facei_new, *facei_adj_new; point *vert_a, *vert_b; point *p[3], *norm; float max_ylen, max_zlen; float long_ylen = 0.0, long_zlen = 0.0; float yzlen2, long_yzlen2; float dy, dz; unsigned int ind_a, ind_b, ind_c, ind_d, ind_mid; unsigned int a, b, i; int num_faces_orig; int num_faces; int tess_level; int base, base_adj; int f, f_adj, f_new, f_adj_new; int e, e_adj, e_long; int v; #ifdef DEBUG printf( "Tessellating object..." ); fflush( stdout ); #endif num_faces_orig = obj->num_indices / 3; num_faces = num_faces_orig; /* Initialize face info list */ facei_list = xmalloc( num_faces * sizeof(struct face_info) ); for (f = 0; f < num_faces; f++) { facei = &facei_list[f]; /* No adjacent faces (yet) */ for (e = 0; e < 3; e++) { facei->adj_faces[e] = -1; facei->adj_face_edges[e] = -1; } /* Check x-component of face normal to see if face is * edgewise to the yz-plane or not */ base = 3 * f; for (v = 0; v < 3; v++) { i = obj->indices[base + v]; p[v] = &obj->vertices0[i]; } norm = calc_tri_normal( p[0], p[1], p[2] ); if (ABS(norm->x) < 0.125) facei->edgewise = TRUE; /* Edgewise */ else facei->edgewise = FALSE; /* Not edgewise */ } /* Initialize edge info list */ edgei_list = xmalloc( obj->num_vertices * sizeof(struct edge_info *) ); for (e = 0; e < obj->num_vertices; e++) edgei_list[e] = NULL; /* Find all face adjacencies by searching for coincident edges */ for (f = 0; f < num_faces; f++) { base = 3 * f; for (e = 0; e < 3; e++) { a = obj->indices[base + e]; b = obj->indices[base + ((e + 1) % 3)]; ind_a = MIN(a, b); ind_b = MAX(a, b); /* Search for matching edge */ prev_edgei = NULL; edgei = edgei_list[ind_a]; while (edgei != NULL) { if (edgei->ind_b == ind_b) break; /* found */ else { prev_edgei = edgei; edgei = edgei->next; /* check next one */ } } if (edgei != NULL) { /* Coincident edge found; update adjacency info */ f_adj = edgei->face; e_adj = edgei->edge; /* First face */ facei = &facei_list[f]; facei->adj_faces[e] = f_adj; facei->adj_face_edges[e] = e_adj; /* Second face */ facei_adj = &facei_list[f_adj]; facei_adj->adj_faces[e_adj] = f; facei_adj->adj_face_edges[e_adj] = e; /* and free edge record * (b/c at most two faces can share an edge) * (barring bad geometry, anyway) */ if (prev_edgei != NULL) prev_edgei->next = edgei->next; else edgei_list[ind_a] = edgei->next; xfree( edgei ); } else { /* Add new edge record */ edgei = xmalloc( sizeof(struct edge_info) ); edgei->ind_b = ind_b; edgei->face = f; edgei->edge = e; edgei->next = NULL; if (prev_edgei != NULL) prev_edgei->next = edgei; else edgei_list[ind_a] = edgei; } } } /* Free the edge info list, no longer need it */ for (v = 0; v < obj->num_vertices; v++) { edgei = edgei_list[v]; while (edgei != NULL) { prev_edgei = edgei; edgei = edgei->next; xfree( prev_edgei ); } } xfree( edgei_list ); /* Perform tessellation incrementally, reducing threshold size * one step at a time (else we get non-clean results) */ for (tess_level = 2; tess_level <= tess; tess_level *= 2) { max_ylen = 1.01 * (vehicle_extents.ymax - vehicle_extents.ymin) / (float)tess_level; max_zlen = 1.01 * (vehicle_extents.zmax - vehicle_extents.zmin) / (float)tess_level; for (f = 0; f < num_faces; f++) { /* Find which edge is most eligible to be split. This * is the longest one, as measured in the yz-plane, * that is not shared between two edgewise faces */ facei = &facei_list[f]; base = 3 * f; e_long = -1; long_yzlen2 = -1.0; for (e = 0; e < 3; e++) { /* First, check for exception case */ f_adj = facei->adj_faces[e]; if (f_adj >= 0) { facei_adj = &facei_list[f_adj]; if (facei->edgewise && facei_adj->edgewise) { /* Both faces are edgewise * This edge must not be split */ continue; } } a = obj->indices[base + e]; b = obj->indices[base + ((e + 1) % 3)]; ind_a = MIN(a, b); ind_b = MAX(a, b); vert_a = &obj->vertices0[ind_a]; vert_b = &obj->vertices0[ind_b]; dy = ABS(vert_a->y - vert_b->y); dz = ABS(vert_a->z - vert_b->z); yzlen2 = SQR(dy) + SQR(dz); if (yzlen2 > long_yzlen2) { e_long = e; long_ylen = dy; long_zlen = dz; long_yzlen2 = yzlen2; } } if (e_long == -1) continue; /* Can't split this face */ /* See if long edge doesn't exceed split threshold */ if ((long_ylen <= max_ylen) && (long_zlen <= max_zlen)) continue; /* Tessellate the face and update face info */ ind_mid = tessellate_face( obj, &facei_list, f, e_long, 0 ); facei = &facei_list[f]; /* facei_list might have moved! */ f_new = num_faces; ++num_faces; /* If another face is sharing the same [long] edge, * tessellate it too */ f_adj = facei->adj_faces[e_long]; if (f_adj >= 0) { base_adj = 3 * f_adj; e_adj = facei->adj_face_edges[e_long]; tessellate_face( obj, &facei_list, f_adj, e_adj, ind_mid ); facei = &facei_list[f]; f_adj_new = num_faces; ++num_faces; /* Check for crossed adjacencies */ a = obj->indices[base + e_long]; b = obj->indices[base + ((e_long + 1) % 3)]; ind_a = MIN(a, b); ind_b = MAX(a, b); a = obj->indices[base_adj + e_adj]; b = obj->indices[base_adj + ((e_adj + 1) % 3)]; ind_c = MIN(a, b); ind_d = MAX(a, b); if ((ind_a == ind_c) && (ind_b == ind_d)) { /* The old faces are adjacent-- * this shouldn't happen! * (means the normals disagree, often * the case with sloppy geometry) */ facei_new = &facei_list[f_new]; facei_adj_new = &facei_list[f_adj_new]; /* Correct adjacencies of the new faces */ facei_new->adj_faces[e_long] = f_adj_new; facei_adj_new->adj_faces[e_adj] = f_new; } else { /* The old and new faces are staggered * (as they should be) */ facei_adj = &facei_list[f_adj]; /* Correct adjacencies of the old faces */ facei->adj_faces[e_long] = f_adj_new; facei_adj->adj_faces[e_adj] = f_new; } } /* Might have to split current face again */ --f; } } xfree( facei_list ); #ifdef DEBUG printf( "done. (%d face splits)\n", num_faces - num_faces_orig ); fflush( stdout ); #endif } /* Turns a specified face (f) in an object into two, bisecting the specified * edge (e), using the specified midpoint vertex (ind_mid) if it is >0 * Note: edges are numbered 0-2, *not* on basis of opposite vertex but in * same order as vertex enumeration */ static unsigned int tessellate_face( ogl_object *obj, struct face_info **facei_list_ptr, int f, int e, unsigned int ind_mid ) { struct face_info *facei, *facei_new; struct face_info *facei_other; point *vert_a, *vert_b; point *norm_a, *norm_b; point *vert_mid, *norm_mid; unsigned int ind_a, ind_b; unsigned int ind_split, ind_move; int num_faces0; int base, base_new; int v_split, v_move, v_third; int f_other, e_other; int n; num_faces0 = obj->num_indices / 3; /* this value will not be incremented */ base = 3 * f; /* A value of 0 for index_mid means no midpoint vertex exists * Thus we create it here */ if (ind_mid == 0) { /* Indices of endpoints and new midpoint vertex */ ind_a = obj->indices[base + e]; ind_b = obj->indices[base + ((e + 1) % 3)]; ind_mid = obj->num_vertices; /* Add new vertex and normal */ ++obj->num_vertices; n = obj->num_vertices; obj->vertices0 = xrealloc( obj->vertices0, n * sizeof(point) ); obj->normals0 = xrealloc( obj->normals0, n * sizeof(point) ); obj->iarrays = xrealloc( obj->iarrays, n * sizeof(ogl_point) ); /* New vertex location (midpoint of long edge) */ vert_a = &obj->vertices0[ind_a]; vert_b = &obj->vertices0[ind_b]; vert_mid = &obj->vertices0[ind_mid]; vert_mid->x = (vert_a->x + vert_b->x) / 2.0; vert_mid->y = (vert_a->y + vert_b->y) / 2.0; vert_mid->z = (vert_a->z + vert_b->z) / 2.0; /* New vertex normal (average of endpoint normals) */ norm_a = &obj->normals0[ind_a]; norm_b = &obj->normals0[ind_b]; norm_mid = &obj->normals0[ind_mid]; norm_mid->x = (norm_a->x + norm_b->x) / 2.0; norm_mid->y = (norm_a->y + norm_b->y) / 2.0; norm_mid->z = (norm_a->z + norm_b->z) / 2.0; } /* # and index of vertex from which split begins * (i.e. the vertex opposite the bisected edge) */ v_split = (e + 2) % 3; ind_split = obj->indices[base + v_split]; /* # and index of vertex to move to midpoint of long edge */ v_move = e; ind_move = obj->indices[base + v_move]; /* # of the other (third) vertex */ v_third = (e + 1) % 3; /* First triangle half (modify original face) */ obj->indices[base + v_move] = ind_mid; /* Second triangle half (create new face) */ base_new = obj->num_indices; obj->num_indices += 3; obj->indices = xrealloc( obj->indices, obj->num_indices * sizeof(unsigned int) ); obj->indices[base_new + v_split] = ind_split; obj->indices[base_new + v_move] = ind_move; obj->indices[base_new + v_third] = ind_mid; /* Make new entry in the face info list, and update the adjacencies */ *facei_list_ptr = xrealloc( *facei_list_ptr, (num_faces0 + 1) * sizeof(struct face_info) ); facei = &(*facei_list_ptr)[f]; facei_new = &(*facei_list_ptr)[num_faces0]; memcpy( facei_new, facei, sizeof(struct face_info) ); /* The old face is next to the new face... */ facei->adj_faces[v_split] = num_faces0; facei->adj_face_edges[v_split] = v_third; /* ...and the new face is next to the old face */ facei_new->adj_faces[v_third] = f; facei_new->adj_face_edges[v_third] = v_split; /* If the new face has a neighbor (that isn't sharing the splitted edge), * it will need updating too */ f_other = facei_new->adj_faces[v_split]; if (f_other >= 0) { e_other = facei_new->adj_face_edges[v_split]; facei_other = &(*facei_list_ptr)[f_other]; facei_other->adj_faces[e_other] = num_faces0; /* facei_other->adj_face_edges[e_other] = v_split; */ /* (last line unnecessary, by splitting convention used) */ } return ind_mid; } /* Simple polygon triangulator, should be able to handle anything save for * self-intersecting faces (garbage_in == garbage_out) */ /* TODO: Still buggy, FIX THIS!!! */ static void triangulate_polygon( r3ds_triangle *out_tris, int num_edges, int *indices, point *vertices ) { r3ds_triangle *tri; extents ext = { 1E6, -1E6, 1E6, -1E6, 1E6, -1E6, NIL }; float x, y, z; int indices2_buffer[256]; int *indices2; int index_xmax_num = 0, index_ymax_num = 0, index_zmax_num = 0; int ind, index_num; int i, j; /* Find face extents, and indices of extrema */ for (i = 0; i < num_edges; i++) { ind = indices[i]; x = vertices[ind].x; y = vertices[ind].y; z = vertices[ind].z; if (x < ext.xmin) ext.xmin = x; if (x > ext.xmax) { ext.xmax = x; index_xmax_num = i; } if (y < ext.ymin) ext.ymin = y; if (y > ext.ymax) { ext.ymax = y; index_ymax_num = i; } if (z < ext.zmin) ext.zmin = z; if (z > ext.zmax) { ext.zmax = z; index_zmax_num = i; } } /* Determine first vertex of triangle based on pricipal face alignment */ x = ext.xmax - ext.xmin; y = ext.ymax - ext.ymin; z = ext.zmax - ext.zmin; index_num = index_xmax_num; if (y > x) index_num = index_ymax_num; if ((z > x) && (z > y)) index_num = index_zmax_num; /* Create one output triangle, now knowing that index_num references * a convex vertex of the polygon */ tri = &out_tris[0]; tri->a = indices[index_num]; tri->b = indices[(index_num + 1) % num_edges]; tri->c = indices[(index_num - 1 + num_edges) % num_edges]; /* and recurse if there are more to do */ if (num_edges > 3) { if (num_edges <= 256) indices2 = indices2_buffer; else indices2 = xmalloc( (num_edges - 1) * sizeof(int) ); j = 0; for (i = 0; i < num_edges; i++) if (i != index_num) indices2[j++] = indices[i]; triangulate_polygon( &out_tris[1], num_edges - 1, indices2, vertices ); if (indices2 != indices2_buffer) xfree( indices2 ); } } /* end importobjs.c */ lightspeed-1.2a/src/infodisp.c0000644000175000017500000000700007176115553012103 /* infodisp.c */ /* Graphical text information display ("HUD") */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Info display control */ void info_display( int message1, int message2 ) { static int disp_anything = DEF_INFODISP_ACTIVE; static int disp_velocity = DEF_INFODISP_SHOW_VELOCITY; static int disp_time_t = DEF_INFODISP_SHOW_TIME_T; static int disp_gamma = DEF_INFODISP_SHOW_GAMMA; static int disp_framerate = DEF_INFODISP_SHOW_FRAMERATE; int no_contract; int no_deform; int no_headlight; int no_doppler; char disp_str[64]; switch (message1) { case INFODISP_DRAW: if (disp_anything) break; else return; case INFODISP_ACTIVE: disp_anything = message2; queue_redraw( 0 ); return; case INFODISP_SHOW_VELOCITY: disp_velocity = message2; goto dd_redraw; case INFODISP_SHOW_TIME_T: disp_time_t = message2; goto dd_redraw; case INFODISP_SHOW_GAMMA: disp_gamma = message2; goto dd_redraw; case INFODISP_SHOW_FRAMERATE: disp_framerate = message2; goto dd_redraw; case RESET: dd_redraw: if (disp_anything) { /* Info in display has changed in some way */ queue_redraw( 0 ); } return; default: #ifdef DEBUG crash( "info_display( ): invalid message" ); #endif return; } /* Z-buffer no good for 2D drawing, lighting likewise */ glDisable( GL_DEPTH_TEST ); glDisable( GL_LIGHTING ); if (disp_velocity) { sprintf( disp_str, STR_INF_velocity_ARG, velocity_string( velocity, TRUE ) ); ogl_draw_string( disp_str, POS_BOTTOM_LEFT, 2 ); } if (disp_time_t) { sprintf( disp_str, STR_INF_time_ARG, time_string( ) ); ogl_draw_string( disp_str, POS_TOP_LEFT, 2 ); } if (disp_gamma) { sprintf( disp_str, STR_INF_gamma_ARG, lorentz_factor( velocity ) ); ogl_draw_string( disp_str, POS_BOTTOM_RIGHT, 1 ); } /* Get status of each of the warp transforms */ no_contract = !warp( QUERY, MESG_(WARP_LORENTZ_CONTRACTION) ); no_deform = !warp( QUERY, MESG_(WARP_OPTICAL_DEFORMATION) ); no_headlight = !warp( QUERY, MESG_(WARP_HEADLIGHT_EFFECT) ); no_doppler = !warp( QUERY, MESG_(WARP_DOPPLER_SHIFT) ); if (no_contract && no_doppler && no_headlight && no_deform) ogl_draw_string( STR_INF_no_relativity, POS_TOP_RIGHT, 1 ); else { if (no_contract) ogl_draw_string( STR_INF_no_contraction, POS_TOP_RIGHT, 0 ); if (no_doppler) ogl_draw_string( STR_INF_no_doppler_shift, POS_TOP_RIGHT, 0 ); if (no_headlight) ogl_draw_string( STR_INF_no_headlight_effect, POS_TOP_RIGHT, 0 ); if (no_deform) ogl_draw_string( STR_INF_no_deformation, POS_TOP_RIGHT, 0 ); } if (disp_framerate) { sprintf( disp_str, STR_INF_fps_ARG, framerate ); ogl_draw_string( disp_str, POS_TOP_RIGHT, 0 ); } glEnable( GL_LIGHTING ); glEnable( GL_DEPTH_TEST ); } /* end infodisp.c */ lightspeed-1.2a/src/lattice.c0000644000175000017500000003667407176115553011740 /* lattice.c */ /* Lattice generator */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Forward declarations */ static void add_ball( ogl_object *parent_obj, float x0, float y0, float z0, int smoothness ); static void add_stick( ogl_object *parent_obj, float arg1, float arg2, float arg3, float arg4, int num_segs, int smoothness, int alignment ); static int add_point( ogl_object *obj, float x, float y, float z, float normal_x, float normal_y, float normal_z ); static void add_index( ogl_object *obj, int index ); /* Creates a 3D lattice of specified size, with sticks properly segmented * in the y and z directions for our purposes (i.e. these will be bent) */ void make_lattice( int size_x, int size_y, int size_z, int smoothness ) { ogl_object *lattice_balls; ogl_object *lattice_sticks; ogl_object dummy; float xc, yc, zc; float x, y, z; float sign = 1.0; int nodes_x, nodes_y, nodes_z; int num_balls, num_sticks; int segs_x, segs_y, segs_z; int num_vertices, num_indices; int i, j, k; int i_inc, j_inc, k_inc; #ifdef DEBUG printf( "Building %dx%dx%d/%d lattice...", size_x, size_y, size_z, smoothness ); fflush( stdout ); #endif nodes_x = size_x + 1; nodes_y = size_y + 1; nodes_z = size_z + 1; /* Half the size of each lattice dimension * (disregarding radii of sticks/balls) */ xc = LATTICE_UNIT_SIZE * (float)size_x / 2; yc = LATTICE_UNIT_SIZE * (float)size_y / 2; zc = LATTICE_UNIT_SIZE * (float)size_z / 2; /* NODE BALLS */ /* Determine how many vertices/indices the balls will need */ dummy.type = -1; dummy.num_vertices = 0; dummy.num_indices = 0; add_ball( &dummy, 0, 0, 0, smoothness ); num_balls = nodes_x * nodes_y * nodes_z; num_vertices = num_balls * dummy.num_vertices; num_indices = num_balls * dummy.num_indices; lattice_balls = alloc_ogl_object( num_vertices, num_indices ); lattice_balls->type = GL_QUAD_STRIP; lattice_balls->color0.r = BALL_R; lattice_balls->color0.g = BALL_G; lattice_balls->color0.b = BALL_B; lattice_balls->num_vertices = 0; lattice_balls->num_indices = 0; /* Make the balls */ /* j and k are in "ping-pong" loops */ j = 0; k = 0; j_inc = 1; k_inc = 1; for (i = 0; i < nodes_x; i++) { for (; (j < nodes_y) && (j >= 0); j += j_inc) { for (; (k < nodes_z) && (k >= 0); k += k_inc) { x = LATTICE_UNIT_SIZE * (float)i - xc; y = LATTICE_UNIT_SIZE * (float)j - yc; z = LATTICE_UNIT_SIZE * (float)k - zc; add_ball( lattice_balls, x, y, z, smoothness ); } k -= k_inc; k_inc = - k_inc; } j -= j_inc; j_inc = - j_inc; } #ifdef DEBUG if (lattice_balls->num_vertices != num_vertices) printf( "ERROR: Lattice balls vertices: %d expected, %d actual\n", num_vertices, lattice_balls->num_vertices ); if (lattice_balls->num_indices != num_indices) printf( "ERROR: Lattice balls indices: %d expected, %d actual\n", num_indices, lattice_balls->num_indices ); fflush( stdout ); #endif /* INTERCONNECTING STICKS */ /* Number of segments along segmented y- & z-axis-aligned sticks */ segs_x = size_x * 2; segs_y = size_y * smoothness; segs_z = size_z * smoothness; /* Determine how many vertices/indices the sticks will need */ num_vertices = 0; num_indices = 0; dummy.type = -1; /* x-aligned sticks */ dummy.num_vertices = 0; dummy.num_indices = 0; add_stick( &dummy, 0, 0, 0, 0, segs_x, smoothness, X_ALIGN ); num_sticks = nodes_y * nodes_z; num_vertices += num_sticks * dummy.num_vertices; num_indices += num_sticks * dummy.num_indices; /* y-aligned sticks */ dummy.num_vertices = 0; dummy.num_indices = 0; add_stick( &dummy, 0, 0, 0, 0, segs_y, smoothness, Y_ALIGN ); num_sticks = nodes_z * nodes_x; num_vertices += num_sticks * dummy.num_vertices; num_indices += num_sticks * dummy.num_indices; /* z-aligned sticks */ dummy.num_vertices = 0; dummy.num_indices = 0; add_stick( &dummy, 0, 0, 0, 0, segs_z, smoothness, Z_ALIGN ); num_sticks = nodes_x * nodes_y; num_vertices += num_sticks * dummy.num_vertices; num_indices += num_sticks * dummy.num_indices; lattice_sticks = alloc_ogl_object( num_vertices, num_indices ); lattice_sticks->type = GL_QUAD_STRIP; lattice_sticks->color0.r = STICK_R; lattice_sticks->color0.g = STICK_G; lattice_sticks->color0.b = STICK_B; lattice_sticks->num_vertices = 0; lattice_sticks->num_indices = 0; /* Make the sticks */ /* Make the x-aligned sticks */ k = 0; k_inc = 1; for (j = 0; j < nodes_y; j++) { y = LATTICE_UNIT_SIZE * (float)j - yc; for (; (k < nodes_z) && (k >= 0); k += k_inc) { z = LATTICE_UNIT_SIZE * (float)k - zc; add_stick( lattice_sticks, - sign * xc, sign * xc, y, z, segs_x, smoothness, X_ALIGN ); sign = - sign; } k -= k_inc; k_inc = - k_inc; } /* Make the y-aligned sticks */ if (sign < 0) { i = 0; i_inc = 1; } else { i = nodes_x - 1; i_inc = -1; } sign = -1.0; /* as j_inc == 1 */ for (; (k < nodes_z) && (k >= 0); k += k_inc) { z = LATTICE_UNIT_SIZE * (float)k - zc; for (; (i < nodes_x) && (i >= 0); i += i_inc) { x = LATTICE_UNIT_SIZE * (float)i - xc; add_stick( lattice_sticks, x, - sign * yc, sign * yc, z, segs_y, smoothness, Y_ALIGN ); sign = - sign; } i -= i_inc; i_inc = - i_inc; } /* Make the z-aligned sticks */ if (sign > 0) { j = 0; j_inc = 1; } else { j = nodes_y - 1; j_inc = -1; } sign = (float)k_inc; for (; (i < nodes_x) && (i >= 0); i += i_inc) { x = LATTICE_UNIT_SIZE * (float)i - xc; for (; (j < nodes_y) && (j >= 0); j += j_inc) { y = LATTICE_UNIT_SIZE * (float)j - yc; add_stick( lattice_sticks, x, y, - sign * zc, sign * zc, segs_z, smoothness, Z_ALIGN ); sign = - sign; } j -= j_inc; j_inc = - j_inc; } #ifdef DEBUG if (lattice_sticks->num_vertices != num_vertices) printf( "ERROR: Lattice sticks vertices: %d expected, %d actual\n", num_vertices, lattice_sticks->num_vertices ); if (lattice_sticks->num_indices != num_indices) printf( "ERROR: Lattice sticks indices: %d expected, %d actual\n", num_indices, lattice_sticks->num_indices ); fflush( stdout ); #endif vehicle_objs = xmalloc( 2 * sizeof(ogl_object *) ); vehicle_objs[0] = lattice_balls; vehicle_objs[1] = lattice_sticks; num_vehicle_objs = 2; /* Define dimensional extents */ xc += BALL_RADIUS; yc += BALL_RADIUS; zc += BALL_RADIUS; vehicle_extents.xmin = - xc; vehicle_extents.xmax = xc; vehicle_extents.ymin = - yc; vehicle_extents.ymax = yc; vehicle_extents.zmin = - zc; vehicle_extents.zmax = zc; vehicle_extents.avg = 2 * (xc + yc + zc) / 3; #ifdef DEBUG printf( "done (%db+%ds vertices, %db+%ds indices).\n", lattice_balls->num_vertices, lattice_sticks->num_vertices, lattice_balls->num_indices, lattice_sticks->num_indices ); fflush( stdout ); #endif } static void add_ball( ogl_object *parent_obj, float x0, float y0, float z0, int smoothness ) { float theta; float phi; float x, y, z; int p, t; int range_t, range_p; int center_v, pole_v, begin_v = 0; int obj_v; range_t = smoothness; range_p = 2 * smoothness; /* Center vertex */ center_v = add_point( parent_obj, x0, y0, z0, 0.0, 0.0, -1.0 ); add_index( parent_obj, center_v ); add_index( parent_obj, center_v ); /* Front of ball (North Pole to Arctic Circle) */ /* Pole vertex */ pole_v = add_point( parent_obj, x0 + BALL_RADIUS, y0, z0, 1.0, 0.0, 0.0 ); theta = RAD(90.0 - 180.0 / (float)range_t); x = BALL_RADIUS * sin( theta ); for (p = 0; p < range_p; p++) { phi = RAD(360.0 * (float)p / (float)range_p); y = BALL_RADIUS * cos( theta ) * cos( phi ); z = BALL_RADIUS * cos( theta ) * sin( phi ); obj_v = add_point( parent_obj, x0 + x, y0 + y, z0 + z, x, y, z ); add_index( parent_obj, pole_v ); add_index( parent_obj, obj_v ); if (p == 0) begin_v = obj_v; } /* Complete the circle */ add_index( parent_obj, pole_v ); add_index( parent_obj, begin_v ); /* Midsection of ball (Arctic Circle to Antarctic Circle) */ for (t = 2; t < range_t; t++) { theta = RAD(90.0 - 180.0 * (float)t / (float)range_t); x = BALL_RADIUS * sin( theta ); for (p = 0; p < range_p; p++) { phi = RAD(360.0 * (float)p / (float)range_p); y = BALL_RADIUS * cos( theta ) * cos( phi ); z = BALL_RADIUS * cos( theta ) * sin( phi ); obj_v = add_point( parent_obj, x0 + x, y0 + y, z0 + z, x, y, z ); add_index( parent_obj, obj_v - range_p ); add_index( parent_obj, obj_v ); if (p == 0) begin_v = obj_v; } /* Complete the circle */ add_index( parent_obj, begin_v - range_p ); add_index( parent_obj, begin_v ); } /* Back of ball (Antarctic Circle to South Pole) */ /* Pole vertex */ pole_v = add_point( parent_obj, x0 - BALL_RADIUS, y0, z0, -1.0, 0.0, 0.0 ); theta = RAD(180.0 / (float)range_t - 90.0); x = BALL_RADIUS * sin( theta ); for (p = 0; p < range_p; p++) { phi = RAD(360.0 * (float)p / (float)range_p); y = BALL_RADIUS * cos( theta ) * cos( phi ); z = BALL_RADIUS * cos( theta ) * sin( phi ); obj_v = add_point( parent_obj, x0 + x, y0 + y, z0 + z, x, y, z ); add_index( parent_obj, obj_v ); add_index( parent_obj, pole_v ); if (p == 0) begin_v = obj_v; } /* Once more, complete the circle */ add_index( parent_obj, begin_v ); add_index( parent_obj, pole_v ); /* and tie quad strip back to center */ add_index( parent_obj, center_v ); add_index( parent_obj, center_v ); } static void add_stick( ogl_object *parent_obj, float arg1, float arg2, float arg3, float arg4, int num_segs, int smoothness, int alignment ) { float phi; float a0, a1, b0, c0; float a, b, c; float x0, y0, z0; float xn, yn, zn; float x, y, z; int s, p; int range_p; int reverse = FALSE; int end_v, begin_v = 0; int obj_v; /* Interpret args differently depending on alignment */ switch (alignment) { case X_ALIGN: a0 = arg1; a1 = arg2; b0 = arg3; c0 = arg4; break; case Y_ALIGN: b0 = arg1; a0 = - arg2; a1 = - arg3; c0 = arg4; break; case Z_ALIGN: c0 = arg1; b0 = arg2; a0 = - arg3; a1 = - arg4; break; default: #ifdef DEBUG crash( "add_stick( ): invalid alignment" ); #endif return; } range_p = 2 * smoothness; if (a0 > a1) reverse = TRUE; /* to keep the normals right */ /* Endcap vertex (tie point) */ rotate_xyz( alignment, &x0, &y0, &z0, a0, b0, c0 ); end_v = add_point( parent_obj, x0, y0, z0, 0.0, 0.0, -1.0 ); add_index( parent_obj, end_v ); add_index( parent_obj, end_v ); for (s = 0; s <= num_segs; s++) { a = (a1 - a0) * (float)s / (float)num_segs; for (p = 0; p < range_p; p++) { phi = RAD(360.0 * (float)p / (float)range_p); b = STICK_RADIUS * cos( phi ); c = STICK_RADIUS * sin( phi ); rotate_xyz( alignment, &x, &y, &z, a, b, c ); rotate_xyz( alignment, &xn, &yn, &zn, 0, b, c ); obj_v = add_point( parent_obj, x0 + x, y0 + y, z0 + z, xn, yn, zn ); if (s > 0) { if (reverse) { add_index( parent_obj, obj_v - range_p ); add_index( parent_obj, obj_v ); } else { add_index( parent_obj, obj_v ); add_index( parent_obj, obj_v - range_p ); } } if (p == 0) begin_v = obj_v; } if (s == 0) continue; /* Complete the circle */ if (reverse) { add_index( parent_obj, begin_v - range_p ); add_index( parent_obj, begin_v ); } else { add_index( parent_obj, begin_v ); add_index( parent_obj, begin_v - range_p ); } } /* The other endcap vertex (tie point) */ rotate_xyz( alignment, &x, &y0, &z0, a1, b0, c0 ); end_v = add_point( parent_obj, x, y0, z0, 0.0, 0.0, -1.0 ); add_index( parent_obj, end_v ); add_index( parent_obj, end_v ); } static int add_point( ogl_object *obj, float x, float y, float z, float norm_x, float norm_y, float norm_z ) { float d; int v; v = obj->num_vertices; if (obj->type != -1) { /* Set vertex location */ obj->vertices0[v].x = x; obj->vertices0[v].y = y; obj->vertices0[v].z = z; /* Normalize and set vertex normal */ d = sqrt( SQR(norm_x) + SQR(norm_y) + SQR(norm_z) ); if (d < 1E-6) d = 1.0; obj->normals0[v].x = norm_x / d; obj->normals0[v].y = norm_y / d; obj->normals0[v].z = norm_z / d; } ++obj->num_vertices; return v; } static void add_index( ogl_object *obj, int index ) { int i; i = obj->num_indices++; if (obj->type != -1) obj->indices[i] = index; } #ifdef WITH_SRS_EXPORTER void write_srs_lattice( FILE *srs ) { point p1, p2; point p1_srs, p2_srs; rgb_color color; float xc,yc,zc; float x0,y0,z0; int i,j,k; /* Centering translation */ xc = (float)lattice_size_x * LATTICE_UNIT_SIZE / 2.0; yc = (float)lattice_size_y * LATTICE_UNIT_SIZE / 2.0; zc = (float)lattice_size_z * LATTICE_UNIT_SIZE / 2.0; i = lattice_size_x; j = lattice_size_y; k = lattice_size_z; fprintf( srs, "\t// **** Begin %dx%dx%d lattice definition ****\n", i, j, k ); fprintf( srs, "\tunion { // ** Balls **\n" ); /* Make the balls */ for (i = 0; i <= lattice_size_x; i++) { x0 = (float)i * LATTICE_UNIT_SIZE - xc; p1.x = x0; for (j = 0; j <= lattice_size_y; j++) { y0 = (float)j * LATTICE_UNIT_SIZE - yc; p1.y = y0; for (k = 0; k <= lattice_size_z; k++) { z0 = (float)k * LATTICE_UNIT_SIZE - zc; p1.z = z0; convert_to_srs_cs( &p1_srs, &p1 ); write_srs_sphere( srs, &p1_srs, BALL_RADIUS ); } } } /* Ball material */ color.r = BALL_R; color.g = BALL_G; color.b = BALL_B; write_srs_pigment( srs, &color ); fprintf( srs, "\t}\n" ); fprintf( srs, "\tunion { // ** Sticks **\n" ); /* Make x-sticks */ for (j = 0; j <= lattice_size_y; j++) { y0 = (float)j * LATTICE_UNIT_SIZE - yc; p1.y = y0; p2.y = y0; for (k = 0; k <= lattice_size_z; k++) { z0 = (float)k * LATTICE_UNIT_SIZE - zc; p1.x = xc; p1.z = z0; convert_to_srs_cs( &p1_srs, &p1 ); p2.x = - xc; p2.z = z0; convert_to_srs_cs( &p2_srs, &p2 ); write_srs_cylinder( srs, &p1_srs, &p2_srs, STICK_RADIUS ); } } /* Make y-sticks */ for (i = 0; i <= lattice_size_x; i++) { x0 = (float)i * LATTICE_UNIT_SIZE - xc; p1.x = x0; p2.x = x0; for (k = 0; k <= lattice_size_z; k++) { z0 = (float)k * LATTICE_UNIT_SIZE - zc; p1.y = yc; p1.z = z0; convert_to_srs_cs( &p1_srs, &p1 ); p2.y = - yc; p2.z = z0; convert_to_srs_cs( &p2_srs, &p2 ); write_srs_cylinder( srs, &p1_srs, &p2_srs, STICK_RADIUS ); } } /* Make z-sticks */ for (i = 0; i <= lattice_size_x; i++) { x0 = (float)i * LATTICE_UNIT_SIZE - xc; p1.x = x0; p2.x = x0; for (j = 0; j <= lattice_size_y; j++) { y0 = (float)j * LATTICE_UNIT_SIZE - yc; p1.y = y0; p1.z = zc; convert_to_srs_cs( &p1_srs, &p1 ); p2.y = y0; p2.z = - zc; convert_to_srs_cs( &p2_srs, &p2 ); write_srs_cylinder( srs, &p1_srs, &p2_srs, STICK_RADIUS ); } } /* Stick material */ color.r = STICK_R; color.g = STICK_G; color.b = STICK_B; write_srs_pigment( srs, &color ); fprintf( srs, "\t}\n" ); fprintf( srs, "\t// **** End lattice definition ****\n" ); } #endif /* WITH_SRS_EXPORTER */ /* end lattice.c */ lightspeed-1.2a/src/lightspeed.c0000644000175000017500000001022307334275213012415 /* lightspeed.c */ /****************************** Light Speed! ****************************** Interactive visualization of relativistic distortion phenomena Written by Daniel Richard G., July 1998 - April 1999 Built on OpenGL, GTK+, and the GtkGLArea widget. **************************************************************************/ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" static void cmdline_help( const char *execname ) { int i; char opt, *lopt, *desc; printf( "\n" ); printf( "%s %s\n", STR_Light_Speed, VERSION ); printf( STR_copyright_ARG, 1999, "Daniel Richard G. " ); printf( "\n\n" ); printf( STR_CLI_usage_ARG, execname ); printf( "\n" ); for (i = 0; i < 4; i++) { opt = STRS_CLI_options[i].opt; lopt = STRS_CLI_options[i].lopt; desc = STRS_CLI_options[i].desc; #ifdef HAVE_GETOPT_LONG if (opt != '\0') printf( " -%c --%-9s %s\n", opt, lopt, desc ); else printf( " %-14s %s\n", lopt, desc ); #else if (opt != '\0') printf( " -%-7c %s\n", opt, desc ); else printf( " %-8s %s\n", lopt, desc ); #endif /* not HAVE_GETOPT_LONG */ } printf( "\n" ); fflush( stdout ); } int main( int argc, char **argv ) { #ifdef HAVE_GETOPT_LONG struct option long_options[4]; #endif int opt, i; char *init_obj_file = NULL; #ifdef HAVE_GETOPT_LONG /* Initialize long-options array */ for (i = 0; i < 3; i++) { long_options[i].name = STRS_CLI_options[i].lopt; long_options[i].has_arg = no_argument; long_options[i].flag = NULL; long_options[i].val = STRS_CLI_options[i].opt; } long_options[3].name = 0; long_options[3].has_arg = 0; long_options[3].flag = 0; long_options[3].val = 0; #endif /* HAVE_GETOPT_LONG */ /* Parse command-line options */ while (TRUE) { #ifdef HAVE_GETOPT_LONG opt = getopt_long( argc, argv, STR_CLI_option_chars, long_options, NULL ); #else opt = getopt( argc, argv, STR_CLI_option_chars ); #endif /* not HAVE_GETOPT_LONG */ if (opt == -1) break; if (opt == STRS_CLI_options[0].opt) { /* -h --help */ cmdline_help( argv[0] ); return 0; } if (opt == STRS_CLI_options[1].opt) { /* -s --simple */ advanced_interface = FALSE; break; } if (opt == STRS_CLI_options[2].opt) { /* -a --advanced */ advanced_interface = TRUE; break; } } if (optind < argc) { /* object */ init_obj_file = argv[optind]; } /* Initialize profiling */ profile( INITIALIZE ); /* Initialize GTK+ */ gtk_init( &argc, &argv ); /* Check for OpenGL support (GLX extension) */ if (gdk_gl_query( ) == FALSE) { fprintf( stderr, "Light Speed! requires OpenGL support to run." ); fflush( stderr ); return -1; } /* Generate/load initial object */ if (init_obj_file == NULL) make_lattice( DEF_LATTICE_X, DEF_LATTICE_Y, DEF_LATTICE_Z, DEF_LATTICE_SMOOTH ); else { i = import_objects( init_obj_file ); if (i < 0) { gtk_timeout_add( 5000, (GtkFunction)gtk_main_quit, NULL ); gtk_main( ); return -1; } } /* Make primary camera */ new_camera( ); /* Construct main window */ main_window( ); /* Fire up the warp engine */ warp( INITIALIZE, NULL ); /* Initialize gamma correction if default says so */ if (DEF_DGAMMA_CORRECT != 1.0) { calc_dgamma_lut( DEF_DGAMMA_CORRECT ); dgamma_correct = TRUE; } else dgamma_correct = FALSE; /* Showtime! */ gtk_main( ); return 0; } /* That's all, folks! */ /* end lightspeed.c */ lightspeed-1.2a/src/lstrings.c0000644000175000017500000002723007334275722012145 /* lstrings.c */ /* Language-specific strings (English) */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* All changes necessary to port Light Speed! to a new language should be * contained within this file. If modifications are necessary elsewhere in * the code, please let me know. There are surely a few odd English-specific * constructs not quite in here yet :-) */ const char *STR_Light_Speed = "Light Speed!"; /* %d = year, %s = author's name or author's name + e-mail address */ const char *STR_copyright_ARG = "Copyright (C) %d by %s"; /**** COMMAND-LINE INTERFACE ****/ /* %s = executable name */ const char *STR_CLI_usage_ARG = "usage: %s [-hsa] [object]"; struct option_desc STRS_CLI_options[] = { { 'h', "help", "Print this help screen" }, #ifdef DEF_ADVANCED_INTERFACE { 's', "simple", "Use simplified interface" }, { 'a', "advanced", "Use advanced interface (default)" }, #else { 's', "simple", "Use simple interface (default)" }, { 'a', "advanced", "Use more advanced interface" }, #endif /* not DEF_ADVANCED_INTERFACE */ { '\0', "object", "3D file to load on startup (.3DS or .LWO)" } }; const char *STR_CLI_option_chars = "hsa"; /**** MENUS ****/ /* Menu bar headings */ const char *STR_MNU_File = "File"; const char *STR_MNU_Objects = "Objects"; const char *STR_MNU_Warp = "Warp"; const char *STR_MNU_Camera = "Camera"; const char *STR_MNU_Help = "Help"; /* File menu */ const char *STR_MNU_New_lattice = "New lattice..."; const char *STR_MNU_Load_object = "Load object..."; const char *STR_MNU_Save_snapshot = "Save snapshot..."; const char *STR_MNU_Export_srs = "Export SRS..."; const char *STR_MNU_Exit = "Exit"; /* Objects menu */ const char *STR_MNU_Coordinate_axes = "Coordinate axes"; const char *STR_MNU_Floating_grid = "Floating grid"; const char *STR_MNU_Bounding_box = "Bounding box"; const char *STR_MNU_Animation = "Animation..."; /* Warp menu */ const char *STR_MNU_Lorentz_contraction = "Lorentz contraction"; const char *STR_MNU_Doppler_shift = "Doppler red/blue shift"; const char *STR_MNU_Headlight_effect = "Headlight effect"; const char *STR_MNU_Optical_deformation = "Optical aberration"; /* Camera menu */ const char *STR_MNU_Lens = "Lens"; const char *STR_MNU_Position = "Position..."; const char *STR_MNU_Reset_view = "Reset view"; const char *STR_MNU_Info_display = "Info display"; const char *STR_MNU_Background = "Background"; const char *STR_MNU_Graphics_mode = "Graphics mode"; const char *STR_MNU_Spawn_camera = "Spawn camera"; const char *STR_MNU_Close = "Close"; /* Camera->Lens submenu */ const char *STR_MNU_Custom = "Custom"; /* Camera->Info_display submenu */ const char *STR_MNU_Active = "Active"; const char *STR_MNU_Velocity = "Velocity"; const char *STR_MNU_Time_t = "Time t"; const char *STR_MNU_Gamma_factor = "Gamma factor"; const char *STR_MNU_Framerate = "Framerate"; /* Camera->Background submenu colors * (corresponding color hues are defined in globals.c) */ const char *STRS_MNU_bkgd_color_names[] = { "Black", "Grey", "White", "Very white" }; /* Camera->Graphics_mode submenu */ const char *STR_MNU_Wireframe = "Wireframe"; const char *STR_MNU_Shaded = "Shaded"; /* Help menu */ const char *STR_MNU_Overview = "Overview"; const char *STR_MNU_Controls = "Controls"; const char *STR_MNU_About = "About"; /**** INFO DISPLAY ****/ /* Time t * %s == time string as returned by time_string( ) */ const char *STR_INF_time_ARG = "t = %ssec"; /* Framerate */ const char *STR_INF_fps_ARG = "%.1f fps"; /* Velocity * %s == velocity strings as returned by velocity_string( ???, TRUE ) */ const char *STR_INF_velocity_ARG = "Velocity: %s"; /* Gamma factor */ const char *STR_INF_gamma_ARG = "gamma = %.3f"; /* Relativistic toggle messages */ const char *STR_INF_no_contraction = "LORENTZ CONTRACTION NOT SHOWN"; const char *STR_INF_no_doppler_shift = "DOPPLER RED/BLUE SHIFT NOT SHOWN"; const char *STR_INF_no_headlight_effect = "HEADLIGHT EFFECT NOT SHOWN"; const char *STR_INF_no_deformation = "OPTICAL ABERRATION NOT SHOWN"; const char *STR_INF_no_relativity = "NO RELATIVISTIC EFFECTS SHOWN!!!"; /**** DIALOGS ****/ const char *STR_DLG_Okay_btn = "OK"; const char *STR_DLG_Cancel_btn = "Cancel"; const char *STR_DLG_Close_btn = "Close"; /* New Lattice dialog */ const char *STR_DLG_New_lattice = "New lattice"; const char *STR_DLG_Dimensions = "Dimensions"; const char *STR_DLG_Smoothness = "Smoothness"; /* Load Object dialog */ const char *STR_DLG_Load_Object = "Load Object"; const char *STR_DLG_Recognized_formats = "Recognized formats"; const char *STR_DLG_3d_formats = "3D Studio: *.3DS or *.PRJ\nLightWave 3D: *.LWO"; /* Save snapshot dialog */ const char *STR_DLG_Save_Snapshot = "Save Snapshot"; const char *STR_DLG_snapshot_Parameters = "Parameters"; const char *STR_DLG_snapshot_Size = "Size"; const char *STR_DLG_snapshot_Format = "Format"; const char *STR_DLG_snapshot_basename = "snapshot"; /* Export SRS dialog */ const char *STR_DLG_Export_srs = "Export SRS"; const char *STR_DLG_srs = "Special Relativity Scene (SRS)"; const char *STR_DLG_srs_Parameters = "Parameters"; const char *STR_DLG_srs_Size = "Rendered size"; const char *STR_DLG_srs_Stereo_view = "Stereoscopic view"; const char *STR_DLG_srs_Vis_faces_only = "Visible faces only"; /* basename1 is for lattices, basename2 is for imported geometry */ const char *STR_DLG_srs_basename1 = "lattice"; const char *STR_DLG_srs_basename2 = "object"; /* Animation dialog */ const char *STR_DLG_Animation = "Animation"; const char *STR_DLG_Observed_range = "Observed range of motion"; const char *STR_DLG_Start_X = "Starting X"; const char *STR_DLG_End_X = "Ending X"; const char *STR_DLG_Loop_time = "Loop time: "; const char *STR_DLG_seconds = " seconds"; const char *STR_DLG_Begin_btn = "Begin"; const char *STR_DLG_Stop_btn = "Stop"; /* Camera Position dialog */ const char *STR_DLG_Camera_Position = "Camera Position"; const char *STR_DLG_Location = "Location"; const char *STR_DLG_View_target = "View target"; const char *STR_DLG_Direction = "Direction"; const char *STR_DLG_Phi_label = "Phi [0, 360)"; const char *STR_DLG_Theta_label = "Theta [-90, 90]"; const char *STR_DLG_Angles_instead = "Specify phi/theta direction instead"; const char *STR_DLG_Xyz_instead = "Specify (x,y,z) view target instead"; const char *STR_DLG_Reposition_btn = "Reposition"; /* Custom Lens dialog */ const char *STR_DLG_Custom_Lens = "Custom Lens"; const char *STR_DLG_Lens_length = "Lens length"; const char *STR_DLG_Field_of_view = "Field of view"; const char *STR_DLG_degree_suffix = "deg"; /* Overview dialog */ const char *STR_DLG_Overview = "Overview"; /* Controls dialog */ const char *STR_DLG_Controls = "Controls"; /* About dialog */ const char *STR_DLG_About = "About"; /* %d == version major, %d == version minor */ const char *STR_DLG_Version_x_y_ARG = "Version %s"; /* %s == author's name */ const char *STR_DLG_authorship_ARG = "A Theory Toy by %s"; const char *STR_DLG_home_page_url = "http://lightspeed.sourceforge.net/"; /* Spawned camera window title */ const char *STR_DLG_Camera = "Camera"; /* Miscellaneous dialog titles */ const char *STR_DLG_Warning = "Warning"; const char *STR_DLG_Error = "Error"; /* Help->Overview text * (from the OVERVIEW file) */ const char *STR_DLG_Overview_TEXT = "\ Light Speed! is a simulator which can illustrate the effects of\n\ special relativity on the appearance of objects travelling at\n\ ultra-high speeds. Depending on the particular speed, and one's\n\ point of view, relativistic effects can cause the object to\n\ appear shorter, longer, brighter, darker, deformed and/or\n\ off-color.\n\ \n\ To adjust the velocity, use the slider along the right edge of\n\ the main window. You can also type in a value, using the entry\n\ at the top right (press once it is in). To change the\n\ units shown, press the button to the right of the entry, and it\n\ will cycle through a small list.\n\ \n\ The object travels in the positive-x direction, which can be\n\ visually checked by activating Objects -> Coordinate axes.\n\ "; /* Help->Controls text * (from the CONTROLS file) */ const char *STR_DLG_Controls_TEXT = "\ Most interactive control is performed with the mouse. By holding\n\ down a particular button, and dragging the pointer around,\n\ various camera motions can be obtained:\n\ \n\ Left button: Revolve camera around view targetg\n\ \n\ Left button + Shift key: Revolve view target around camera\n\ \n\ Middle button: Translate camera left, right, up or down\n\ \n\ Right button: Dolly in or out\n\ \n\ The first and last motions are generally the most useful.\n\ Should the camera become difficult to control at any point, it\n\ may be re-initialized by selecting Camera -> Reset View.\n\ "; /**** MESSAGES ****/ /* For quick-and-dirty command feedback */ const char *STR_MSG_Okay = "OK"; const char *STR_MSG_Invalid = "INVALID"; /* File overwrite warning * %s == filename (basename) of file at risk */ const char *STR_MSG_overwrite_warn_ARG = "The file \"%s\" already exists.\nPress OK to overwrite it."; /* Object importer error messages */ /* %s == (bogus) filename */ const char *STR_MSG_no_object_file_ARG = "The specified object file could not be opened.\n(%s)\nImport operation failed."; const char *STR_MSG_not_3ds_file = "The file lacks a valid 3DS signature.\nImport operation failed."; const char *STR_MSG_not_prj_file = "The file lacks a valid 3D Studio PRJ signature.\nImport operation failed."; const char *STR_MSG_not_lwo_file = "The file lacks a valid LWOB signature.\nImport operation failed."; const char *STR_MSG_unknown_obj_format = "The object must be in 3D Studio (3DS)\nor LightWave 3D (LWO) file format.\nImport operation failed."; const char *STR_MSG_bad_3ds_file = "The 3D Studio file could not be properly read.\nImport operation failed."; const char *STR_MSG_empty_3ds_file = "The 3D Studio file has no valid geometry.\nImport operation failed."; const char *STR_MSG_bad_lwo_file = "The LightWave file could not be properly read.\nImport operation failed."; const char *STR_MSG_empty_lwo_file = "The LightWave file has no valid geometry.\nImport operation failed."; /* Snapshot exporter error messages */ const char *STR_MSG_no_ogl_visual = "The system could not provide the required visual.\nSave operation failed."; /* %d == width, %d == height */ const char *STR_MSG_no_render_buf_ARG = "A %dx%d render buffer could not be allocated.\nSave operation failed."; const char *STR_MSG_no_ogl_context = "The required OpenGL context was not available.\nSave operation failed."; const char *STR_MSG_no_snapshot_output = "An error occurred in creating the output file.\nSave operation failed."; /* Viewport-centered messages */ const char *STR_MSG_Generating_lattice = "GENERATING LATTICE . . ."; const char *STR_MSG_Importing_object = "LOADING OBJECT . . ."; const char *STR_MSG_Rendering_snapshot = "RENDERING . . ."; /* %d == percent of snapshot written */ const char *STR_MSG_Saving_snapshot_ARG = "SAVING SNAPSHOT . . .\n(%d%%)"; /* end lstrings.c */ lightspeed-1.2a/src/mainwindow.c0000644000175000017500000002261507176115553012455 /* mainwindow.c */ /* Constructs main window * (and menu of spawned windows) */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Icon for the main Light Speed! window */ #include "icon.xpm" /* Construct main window */ void main_window( void ) { GtkWidget *main_window_w; GtkWidget *main_vbox_w; GtkWidget *hbox_w; GtkWidget *menu_bar_w; GtkWidget *menu_w; GtkWidget *menu_item_w; /* Main window widget */ main_window_w = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_title( GTK_WINDOW(main_window_w), STR_Light_Speed ); gtk_widget_set_usize( main_window_w, 600, 450 ); gtk_container_set_border_width( GTK_CONTAINER(main_window_w), 0 ); gtk_signal_connect( GTK_OBJECT(main_window_w), "focus_in_event", GTK_SIGNAL_FUNC(camera_set_current), NULL ); /* Need to set this so assoc_cam_id( ) will work */ usr_cams[0]->window_w = main_window_w; usr_cams[0]->ogl_w = NULL; /* for ogl_make_widget( ) */ /* (and its obligatory kill buttons) */ gtk_signal_connect( GTK_OBJECT(main_window_w), "delete_event", GTK_SIGNAL_FUNC(gtk_main_quit), NULL ); /* Destroy window before exiting */ gtk_quit_add_destroy( 1, GTK_OBJECT(main_window_w) ); /* Main vertical box widget */ main_vbox_w = add_vbox( main_window_w, FALSE, 0 ); /* Horizontal box for menu bar + velocity entry */ hbox_w = add_hbox( main_vbox_w, FALSE, 0 ); /* Initialize keybinding */ keybind( NULL, NULL ); /* Build menu bar */ /* Root menu bar widget */ menu_bar_w = gtk_menu_bar_new( ); gtk_box_pack_start( GTK_BOX(hbox_w), menu_bar_w, TRUE, TRUE, 0 ); gtk_widget_show( menu_bar_w ); /* File menu */ menu_w = add_menu( menu_bar_w, STR_MNU_File ); /* File menu items */ menu_item_w = add_menu_item( menu_w, STR_MNU_New_lattice, dialog_File_NewLattice, MESG_(DIALOG_OPEN) ); keybind( menu_item_w, "^N" ); #ifdef WITH_OBJECT_IMPORTER menu_item_w = add_menu_item( menu_w, STR_MNU_Load_object, dialog_File_ImportObject, MESG_(DIALOG_OPEN) ); keybind( menu_item_w, "^O" ); #endif #ifdef CAN_SAVE_SNAPSHOT menu_item_w = add_menu_item( menu_w, STR_MNU_Save_snapshot, dialog_File_SaveSnapshot, MESG_(DIALOG_OPEN) ); keybind( menu_item_w, "^S" ); #endif #ifdef WITH_SRS_EXPORTER add_menu_item( menu_w, STR_MNU_Export_srs, dialog_File_ExportSRS, MESG_(DIALOG_OPEN) ); #endif add_separator( menu_w ); menu_item_w = add_menu_item( menu_w, STR_MNU_Exit, gtk_main_quit, NULL ); keybind( menu_item_w, "^Q" ); /* Objects menu */ menu_w = add_menu( menu_bar_w, STR_MNU_Objects ); /* Objects menu items */ menu_item_w = add_check_menu_item( menu_w, STR_MNU_Coordinate_axes, FALSE, menu_Objects_toggles, MESG_(AUXOBJS_SET_AXES) ); keybind( menu_item_w, "C" ); menu_item_w = add_check_menu_item( menu_w, STR_MNU_Floating_grid, TRUE, menu_Objects_toggles, MESG_(AUXOBJS_SET_GRID) ); keybind( menu_item_w, "G" ); menu_item_w = add_check_menu_item( menu_w, STR_MNU_Bounding_box, FALSE, menu_Objects_toggles, MESG_(AUXOBJS_SET_BBOX) ); keybind( menu_item_w, "B" ); add_separator( menu_w ); menu_item_w = add_menu_item( menu_w, STR_MNU_Animation, dialog_Objects_Animation, MESG_(DIALOG_OPEN) ); keybind( menu_item_w, "A" ); /* Warp menu */ menu_w = add_menu( menu_bar_w, STR_MNU_Warp ); /* Warp menu items */ menu_item_w = add_check_menu_item( menu_w, STR_MNU_Lorentz_contraction, TRUE, menu_Warp_toggles, MESG_(WARP_LORENTZ_CONTRACTION) ); keybind( menu_item_w, "L" ); menu_item_w = add_check_menu_item( menu_w, STR_MNU_Doppler_shift, TRUE, menu_Warp_toggles, MESG_(WARP_DOPPLER_SHIFT) ); keybind( menu_item_w, "D" ); menu_item_w = add_check_menu_item( menu_w, STR_MNU_Headlight_effect, TRUE, menu_Warp_toggles, MESG_(WARP_HEADLIGHT_EFFECT) ); keybind( menu_item_w, "H" ); menu_item_w = add_check_menu_item( menu_w, STR_MNU_Optical_deformation, TRUE, menu_Warp_toggles, MESG_(WARP_OPTICAL_DEFORMATION) ); keybind( menu_item_w, "O" ); /* Camera menu defined elsewhere */ add_Camera_menu( menu_bar_w, main_window_w ); /* Help menu */ menu_w = add_menu( menu_bar_w, STR_MNU_Help ); /* Help menu items */ add_menu_item( menu_w, STR_MNU_Overview, dialog_Help_Overview, MESG_(DIALOG_OPEN) ); add_menu_item( menu_w, STR_MNU_Controls, dialog_Help_Controls, MESG_(DIALOG_OPEN) ); add_separator( menu_w ); add_menu_item( menu_w, STR_MNU_About, dialog_Help_About, MESG_(DIALOG_OPEN) ); /* Done with the menu bar */ /* Velocity entry/units select button */ velocity_input( hbox_w, MESG_(INITIALIZE) ); /* Horizontal box for viewport and velocity slider */ hbox_w = gtk_hbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(main_vbox_w), hbox_w, TRUE, TRUE, 0 ); gtk_widget_show( hbox_w ); #if (VELOCITY_SLIDER == 1) velocity_slider( hbox_w, MESG_(INITIALIZE) ); #endif /* OpenGL area widget */ usr_cams[0]->ogl_w = add_gl_area( hbox_w ); #if (VELOCITY_SLIDER == 2) velocity_slider( hbox_w, MESG_(INITIALIZE) ); #endif /* Attach keybindings */ keybind( main_window_w, NULL ); /* Give window a nifty icon */ assign_icon( main_window_w, lightspeed_icon_xpm ); gtk_widget_show( main_window_w ); } /* Camera menu is common to main and spawned windows, thus defined separately */ void add_Camera_menu( GtkWidget *menu_bar_w, GtkWidget *window_w ) { GtkWidget *menu_w; GtkWidget *menu_item_w; GtkWidget *submenu_w; char lens_name[16]; int cam_id; int spawned_camera = FALSE; int i; cam_id = assoc_cam_id( window_w ); if (cam_id > 0) spawned_camera = TRUE; /* Camera menu */ menu_w = add_menu( menu_bar_w, STR_MNU_Camera ); /* Lens submenu */ submenu_w = add_menu( menu_w, STR_MNU_Lens ); /* Lens submenu items */ begin_radio_menu_group( num_stock_lenses ); /* custom lens is default */ for (i = 0; i < num_stock_lenses; i++) { sprintf( lens_name, "%.0fmm", stock_lenses[i] ); add_radio_menu_item( submenu_w, lens_name, menu_Camera_Lens_select, (float *)(&stock_lenses[i]) ); } add_separator( submenu_w ); menu_item_w = add_radio_menu_item( submenu_w, STR_MNU_Custom, dialog_Camera_Lens_Custom, MESG_(DIALOG_OPEN) ); gtk_signal_connect( GTK_OBJECT(menu_item_w), "activate", GTK_SIGNAL_FUNC(dialog_Camera_Lens_Custom), MESG_(DIALOG_OPEN) ); /* Lens submenu finished */ if (advanced_interface) add_menu_item( menu_w, STR_MNU_Position, dialog_Camera_Position, MESG_(DIALOG_OPEN) ); menu_item_w = add_menu_item( menu_w, STR_MNU_Reset_view, menu_Camera_ResetView, MESG_(cam_id) ); keybind( menu_item_w, "R" ); add_separator( menu_w ); if (!spawned_camera) { /* For primary camera only */ /* Info display submenu */ submenu_w = add_menu( menu_w, STR_MNU_Info_display ); /* Info display submenu items */ menu_item_w = add_check_menu_item( submenu_w, STR_MNU_Active, DEF_INFODISP_ACTIVE, menu_Camera_InfoDisplay_toggles, MESG_(INFODISP_ACTIVE) ); keybind( menu_item_w, "I" ); add_separator( submenu_w ); add_check_menu_item( submenu_w, STR_MNU_Velocity, DEF_INFODISP_SHOW_VELOCITY, menu_Camera_InfoDisplay_toggles, MESG_(INFODISP_SHOW_VELOCITY) ); add_check_menu_item( submenu_w, STR_MNU_Time_t, DEF_INFODISP_SHOW_TIME_T, menu_Camera_InfoDisplay_toggles, MESG_(INFODISP_SHOW_TIME_T) ); add_check_menu_item( submenu_w, STR_MNU_Gamma_factor, DEF_INFODISP_SHOW_GAMMA, menu_Camera_InfoDisplay_toggles, MESG_(INFODISP_SHOW_GAMMA) ); add_check_menu_item( submenu_w, STR_MNU_Framerate, DEF_INFODISP_SHOW_FRAMERATE, menu_Camera_InfoDisplay_toggles, MESG_(INFODISP_SHOW_FRAMERATE) ); /* Info display submenu finished */ /* Background submenu */ submenu_w = add_menu( menu_w, STR_MNU_Background ); /* Background submenu items */ begin_radio_menu_group( 0 ); /* first one (black) is default */ for (i = 0; i < num_background_colors; i++) add_radio_menu_item( submenu_w, STRS_MNU_bkgd_color_names[i], menu_Camera_Background_select, MESG_(i) ); /* Background submenu finished */ if (advanced_interface) { /* Graphics mode submenu */ submenu_w = add_menu( menu_w, STR_MNU_Graphics_mode ); /* Graphics mode submenu items */ begin_radio_menu_group( 1 ); /* Shaded mode is default */ add_radio_menu_item( submenu_w, STR_MNU_Wireframe, menu_Camera_GraphicsMode_select, MESG_(OGL_WIREFRAME_MODE) ); add_radio_menu_item( submenu_w, STR_MNU_Shaded, menu_Camera_GraphicsMode_select, MESG_(OGL_SHADED_MODE) ); /* Graphics mode submenu finished */ add_separator( menu_w ); menu_item_w = add_menu_item( menu_w, STR_MNU_Spawn_camera, menu_Camera_Spawn, NULL ); keybind( menu_item_w, "S" ); } } else { /* For spawned cameras */ menu_item_w = add_menu_item( menu_w, STR_MNU_Close, NULL, GTK_OBJECT(window_w) ); gtk_signal_connect_object( GTK_OBJECT(menu_item_w), "activate", GTK_SIGNAL_FUNC(menu_Camera_Close), GTK_OBJECT(window_w) ); keybind( menu_item_w, "^X" ); } } /* end mainwindow.c */ lightspeed-1.2a/src/menu_cbs.c0000644000175000017500000013363507334275635012105 /* menu_cbs.c */ /* Callbacks for menus, dialogs */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Light Speed! title graphic for Help->About */ #include "title.xpm" /* This services the entry and units button on the menu bar */ void velocity_input( GtkWidget *widget, const int *message ) { static GtkWidget *velocity_entry_w = NULL; static GtkWidget *unit_label_w; static double prev_input_val = 1.0; static int blocking_changed = FALSE; GtkWidget *vbox_w; GtkWidget *button_w; double input_val; char *init_str; char *input_str; char *fixed_str; int i; switch (*message) { case RESET: blocking_changed = TRUE; /* Clear out any stale text in entry */ init_str = add_commas( velocity_string( prev_input_val, FALSE ) ); set_entry_text( velocity_entry_w, init_str ); blocking_changed = FALSE; return; case VALUE_COMMITTED: /* keystroke received */ blocking_changed = TRUE; input_str = read_entry( velocity_entry_w ); if (input_str[0] == '>') { /* Command entered */ i = command( &input_str[1] ); if (i == 0) set_entry_text( velocity_entry_w, STR_MSG_Okay ); else set_entry_text( velocity_entry_w, STR_MSG_Invalid ); blocking_changed = FALSE; return; } /* Clean out junk from input string */ input_str = clean_number( input_str ); input_val = strtod( input_str, NULL ) * unit_conv_factors[cur_unit_system]; input_val = CLAMP(input_val, MIN_VELOCITY, MAX_VELOCITY); /* Start hitting the gas (or the brakes!) */ transition( &velocity, TRUE, TRANS_SIGMOID, 5.0, input_val, -1 ); init_str = add_commas( velocity_string( input_val, FALSE ) ); set_entry_text( velocity_entry_w, init_str ); /* TODO: Find out why the highlight_entry( ) here DOES NOT WORK */ highlight_entry( velocity_entry_w ); prev_input_val = input_val; blocking_changed = FALSE; return; case VALUE_CHANGED: /* Avoid infinite recursion on "changed" signal */ if (blocking_changed) return; blocking_changed = TRUE; input_str = read_entry( velocity_entry_w ); if (input_str[0] == '>') return; /* command escape */ /* Clean up numerical input and add commas for clarity */ fixed_str = add_commas( clean_number( input_str ) ); /* TODO: Find out why gtk_entry_set_position() here doesn't work */ /* set_entry_text( widget, fixed_str ); gtk_entry_set_position( GTK_ENTRY(widget), strlen( fixed_str ) ); */ blocking_changed = FALSE; return; case UNITS_CHANGED: blocking_changed = TRUE; cur_unit_system = (cur_unit_system + 1) % num_unit_systems; gtk_label_set_text( GTK_LABEL(unit_label_w), unit_suffixes[cur_unit_system] ); velocity_input( NULL, MESG_(RESET) ); /* Update info display if it is active */ info_display( RESET, NIL ); blocking_changed = FALSE; return; case INITIALIZE: if (velocity_entry_w != NULL) { prev_input_val = velocity; velocity_input( NULL, MESG_(RESET) ); return; } init_str = velocity_string( velocity, FALSE ); velocity_entry_w = add_entry( widget, init_str, velocity_input, MESG_(VALUE_COMMITTED) ); set_entry_width( velocity_entry_w, "000,000,000,000" ); gtk_signal_connect( GTK_OBJECT(velocity_entry_w), "changed", GTK_SIGNAL_FUNC(velocity_input), MESG_(VALUE_CHANGED) ); keybind( velocity_entry_w, "^V" ); vbox_w = add_vbox( widget, FALSE, 3 ); button_w = add_button( vbox_w, NULL, velocity_input, MESG_(UNITS_CHANGED) ); unit_label_w = add_label( button_w, unit_suffixes[cur_unit_system] ); keybind( button_w, "U" ); return; default: #ifdef DEBUG crash( "velocity_input( ): invalid_message" ); #endif return; } } /* Services the slider to the side of the viewport */ #if VELOCITY_SLIDER void velocity_slider( GtkWidget *widget, const int *message ) { static GtkObject *velocity_adj; static GtkWidget *velocity_vscale_w; static int blocking_changed = FALSE; GtkWidget *frame_w; double input_val; float adj_value; switch (*message) { case VALUE_CHANGED: if (blocking_changed) return; adj_value = GTK_ADJUSTMENT(velocity_adj)->value; input_val = C * (1.0 - adj_value / 65536.0); /* Halt any ongoing velocity transition */ break_transition( &velocity ); velocity = CLAMP(input_val, MIN_VELOCITY, MAX_VELOCITY); /* Update velocity entry */ velocity_input( NULL, MESG_(INITIALIZE) ); queue_redraw( -1 ); return; case RESET: /* Update slider if its value isn't up-to-date */ blocking_changed = TRUE; adj_value = rint( 65536.0 * (1.0 - velocity / C) ); if (GTK_ADJUSTMENT(velocity_adj)->value != adj_value) gtk_adjustment_set_value( GTK_ADJUSTMENT(velocity_adj), adj_value ); blocking_changed = FALSE; return; case INITIALIZE: /* Frame for slider (purely for aesthetics) */ frame_w = add_frame( widget, NULL ); /* Velocity adjustment and scale widget */ velocity_adj = gtk_adjustment_new( 65536.0, 0.0, 65536.0, 1.0, 2048.0, 0.0 ); gtk_signal_connect( GTK_OBJECT(velocity_adj), "value_changed", GTK_SIGNAL_FUNC(velocity_slider), MESG_(VALUE_CHANGED) ); velocity_vscale_w = gtk_vscale_new( GTK_ADJUSTMENT(velocity_adj) ); gtk_scale_set_draw_value( GTK_SCALE(velocity_vscale_w), FALSE ); /* gtk_box_pack_start( GTK_BOX(hbox_w), velocity_scale_w, FALSE, FALSE, 0 ); */ gtk_container_add( GTK_CONTAINER(frame_w), velocity_vscale_w ); keybind( velocity_vscale_w, "V" ); gtk_widget_show( velocity_vscale_w ); return; default: #ifdef DEBUG crash( "velocity_slider( ): invalid message" ); #endif return; } } #endif /* VELOCITY_SLIDER */ void dialog_File_NewLattice( GtkWidget *widget, const int *message ) { static int active = FALSE; static GtkWidget *dialog_window_w; static GtkObject *size_x_adj, *size_y_adj, *size_z_adj; static GtkObject *smoothness_adj; static int prev_smoothness = DEF_LATTICE_SMOOTH; static float dummy; GtkWidget *main_vbox_w; GtkWidget *frame_w; GtkWidget *hbox_w; GtkWidget *vbox_w; int input_size_x, input_size_y, input_size_z; int input_smoothness; int i; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_OK: gtk_widget_hide( dialog_window_w ); /* TODO: Find out why window widget doesn't actually hide until too late */ input_size_x = (int)(GTK_ADJUSTMENT(size_x_adj)->value); input_size_y = (int)(GTK_ADJUSTMENT(size_y_adj)->value); input_size_z = (int)(GTK_ADJUSTMENT(size_z_adj)->value); if (advanced_interface) input_smoothness = (int)(GTK_ADJUSTMENT(smoothness_adj)->value); else input_smoothness = prev_smoothness; /* Redraw or blank the viewports first (do redraw(s) if it * won't take too long AND a lattice is already up) */ if ((framerate > ((float)num_cams * 5.0)) && (object_mode == MODE_LATTICE)) { for (i = 0; i < num_cams; i++) ogl_draw( i ); } else { for (i = 0; i < num_cams; i++) ogl_blank( i, STR_MSG_Generating_lattice ); } clear_all_objects( ); make_lattice( input_size_x, input_size_y, input_size_z, input_smoothness ); /* Reset camera(s) if user geometry had been loaded */ if (object_mode == MODE_USER_GEOMETRY) { for (i = 0; i < num_cams; i++) camera_reset( i ); /* and HIT THE BRAKES! */ velocity = 1.0; velocity_input( NULL, MESG_(INITIALIZE) ); } object_mode = MODE_LATTICE; /* Now have to recalibrate framerate */ profile( PROFILE_FRAMERATE_RESET ); /* (the transition will take care of redraw(s), too) */ dummy = 1.0; transition( &dummy, FALSE, TRANS_LINEAR, 1.0, 0.0, -1 ); lattice_size_x = input_size_x; lattice_size_y = input_size_y; lattice_size_z = input_size_z; prev_smoothness = input_smoothness; /* no break/return here */ case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( dialog_window_w ); return; default: #ifdef DEBUG crash( "dialog_File_NewLattice( ): invalid message" ); #endif return; } /* Dialog window widget */ dialog_window_w = make_dialog_window( STR_DLG_New_lattice, dialog_File_NewLattice ); gtk_window_set_position( GTK_WINDOW(dialog_window_w), GTK_WIN_POS_MOUSE ); /* Main vertical box widget */ main_vbox_w = add_vbox( dialog_window_w, FALSE, 10 ); /* Dimensions title frame */ frame_w = add_frame( main_vbox_w, STR_DLG_Dimensions ); hbox_w = add_hbox( frame_w, FALSE, 10 ); /* X spinbutton */ vbox_w = add_vbox( hbox_w, FALSE, 0 ); add_label( vbox_w, "X" ); size_x_adj = gtk_adjustment_new( (float)lattice_size_x, 1.0, 16.0, 1.0, 1.0, 0.0 ); add_spin_button( vbox_w, size_x_adj ); /* Y spinbutton */ vbox_w = add_vbox( hbox_w, FALSE, 0 ); add_label( vbox_w, "Y" ); size_y_adj = gtk_adjustment_new( (float)lattice_size_y, 1.0, 16.0, 1.0, 1.0, 0.0 ); add_spin_button( vbox_w, size_y_adj ); /* Z spinbutton */ vbox_w = add_vbox( hbox_w, FALSE, 0 ); add_label( vbox_w, "Z" ); size_z_adj = gtk_adjustment_new( (float)lattice_size_z, 1.0, 16.0, 1.0, 1.0, 0.0 ); add_spin_button( vbox_w, size_z_adj ); if (advanced_interface) { /* Smoothness title frame */ frame_w = add_frame( main_vbox_w, STR_DLG_Smoothness ); hbox_w = add_hbox( frame_w, TRUE, 10 ); /* Smoothness slider */ smoothness_adj = gtk_adjustment_new( (float)prev_smoothness, 3.0, 16.0, 1.0, 1.0, 0.0 ); add_hscale( hbox_w, smoothness_adj ); } hbox_w = add_hbox( main_vbox_w, TRUE, 0 ); add_button( hbox_w, STR_DLG_Okay_btn, dialog_File_NewLattice, MESG_(DIALOG_OK) ); add_button( hbox_w, STR_DLG_Cancel_btn, dialog_File_NewLattice, MESG_(DIALOG_CLOSE) ); gtk_widget_show( dialog_window_w ); } #ifdef WITH_OBJECT_IMPORTER void dialog_File_ImportObject( GtkWidget *widget, const int *message ) { static int active = FALSE; static GtkWidget *filesel_w; static char *prev_filename = NULL; static float dummy; GtkWidget *frame_w; GtkWidget *hbox_w; GtkWidget *label_w; int i; char *filename; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_OK: filename = gtk_file_selection_get_filename( GTK_FILE_SELECTION(filesel_w) ); if (prev_filename != NULL) xfree( prev_filename ); prev_filename = xstrdup( filename ); gtk_widget_hide( filesel_w ); /* Blank the viewports for loading */ for (i = 0; i < num_cams; i++) ogl_blank( i, STR_MSG_Importing_object ); /* Out with the existing objects... */ clear_all_objects( ); /* ...and in with the new ones */ i = import_objects( prev_filename ); if (i < 0) /* Error! */ make_lattice( 1, 1, 1, 3 ); /* A full view reset is (almost) certainly necessary */ for (i = 0; i < num_cams; i++) camera_reset( i ); /* Reset velocity too */ velocity = 1.0; velocity_input( NULL, MESG_(INITIALIZE) ); object_mode = MODE_USER_GEOMETRY; /* Reset and recalibrate framerate */ profile( PROFILE_FRAMERATE_RESET ); dummy = 1.0; transition( &dummy, FALSE, TRANS_LINEAR, 1.0, 0.0, -1 ); /* no break/return here */ case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( filesel_w ); return; default: #ifdef DEBUG crash( "dialog_File_ImportObject( ): invalid message" ); #endif return; } filesel_w = make_filesel_window( STR_DLG_Load_Object, prev_filename, FALSE, dialog_File_ImportObject ); frame_w = add_frame( GTK_FILE_SELECTION(filesel_w)->main_vbox, STR_DLG_Recognized_formats ); hbox_w = add_hbox( frame_w, FALSE, 10 ); label_w = add_label( hbox_w, STR_DLG_3d_formats ); gtk_label_set_justify( GTK_LABEL(label_w), GTK_JUSTIFY_LEFT ); gtk_widget_show( filesel_w ); } #endif /* WITH_OBJECT_IMPORTER */ #ifdef CAN_SAVE_SNAPSHOT void dialog_File_SaveSnapshot( GtkWidget *widget, const int *message ) { static int active = FALSE; static GtkWidget *filesel_w; static GtkWidget *size_entry_w; static int format = -1; static int width, height; static char *prev_filename = NULL; GtkWidget *frame_w; GtkWidget *hbox_w; GtkWidget *vbox_w; int f, f1, f2; char *filename; char *input_str; char init_str[256]; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_OK: /* Grab and save the specified filename */ filename = gtk_file_selection_get_filename( GTK_FILE_SELECTION(filesel_w) ); xfree( prev_filename ); prev_filename = xstrdup( filename ); /* Get snapshot dimensions */ input_str = read_entry( size_entry_w ); width = (int)strtod( input_str, NULL ); /* next part (height) */ input_str = strpbrk( input_str, "xX* " ); if (input_str != NULL) input_str = strpbrk( input_str, "0123456789" ); if (input_str != NULL) height = (int)strtod( input_str, NULL ); else height = (3 * width) / 4; if ((width < 100) || (height < 75)) { /* Dimensions are too small (or negative??) */ width = MAX(100, width); height = MAX(75, height); sprintf( init_str, "%d x %d", width, height ); set_entry_text( size_entry_w, init_str ); return; } gtk_widget_hide( filesel_w ); case DIALOG_OK_CONFIRM: if (file_exists( prev_filename ) && (*message != DIALOG_OK_CONFIRM)) { filename = file_basename( prev_filename, NULL ); sprintf( init_str, STR_MSG_overwrite_warn_ARG, filename ); confirmation_dialog( STR_DLG_Warning, init_str, dialog_File_SaveSnapshot ); return; } else { ogl_blank( 0, NULL ); save_snapshot( width, height, prev_filename, format ); ogl_draw( 0 ); } /* no break/return here */ case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( filesel_w ); return; case IMAGE_FORMAT_PNG: case IMAGE_FORMAT_TIFF: /* Note newly selected format and update filename extension * (the latter only if it matches previously selected format) */ f1 = format - IMAGE_FORMAT - 1; format = *message; f2 = format - IMAGE_FORMAT - 1; filename = gtk_file_selection_get_filename( GTK_FILE_SELECTION(filesel_w) ); filename = swap_filename_ext( filename, image_format_exts[f1], image_format_exts[f2] ); gtk_file_selection_set_filename( GTK_FILE_SELECTION(filesel_w), filename ); return; default: #ifdef DEBUG crash( "dialog_File_SaveSnapshot( ): invalid message" ); #endif return; } #ifdef HAVE_LIBPNG if (format == -1) format = IMAGE_FORMAT_PNG; #endif #ifdef HAVE_LIBTIFF if (format == -1) format = IMAGE_FORMAT_TIFF; #endif /* Set defaults */ if (prev_filename == NULL) { width = usr_cams[0]->ogl_w->allocation.width; height = usr_cams[0]->ogl_w->allocation.height; f = format - IMAGE_FORMAT - 1; sprintf( init_str, "%s%s", STR_DLG_snapshot_basename, image_format_exts[f] ); prev_filename = xstrdup( init_str ); } filesel_w = make_filesel_window( STR_DLG_Save_Snapshot, prev_filename, TRUE, dialog_File_SaveSnapshot ); /* Frame for image parameters */ frame_w = add_frame( GTK_FILE_SELECTION(filesel_w)->main_vbox, STR_DLG_snapshot_Parameters ); /* hbox for image size/format inputs */ hbox_w = add_hbox( frame_w, FALSE, 10 ); /* Snapshot size label & entry */ vbox_w = gtk_vbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), vbox_w, TRUE, FALSE, 0 ); gtk_widget_show( vbox_w ); add_label( vbox_w, STR_DLG_snapshot_Size ); sprintf( init_str, "%d x %d", width, height ); size_entry_w = add_entry( vbox_w, init_str, NULL, NULL ); /* Image format option menu */ vbox_w = gtk_vbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), vbox_w, TRUE, FALSE, 0 ); gtk_widget_show( vbox_w ); add_label( vbox_w, STR_DLG_snapshot_Format ); #ifdef HAVE_LIBPNG option_menu_item( "PNG", dialog_File_SaveSnapshot, MESG_(IMAGE_FORMAT_PNG) ); #endif #ifdef HAVE_LIBTIFF option_menu_item( "TIFF", dialog_File_SaveSnapshot, MESG_(IMAGE_FORMAT_TIFF) ); #endif add_option_menu( vbox_w ); gtk_widget_show( filesel_w ); } #endif /* CAN_SAVE_SNAPSHOT */ #ifdef WITH_SRS_EXPORTER void dialog_File_ExportSRS( GtkWidget *widget, const int *message ) { static int active = FALSE; static GtkWidget *filesel_w; static GtkWidget *size_entry_w; static GtkWidget *stereo_chkbtn_w; static GtkWidget *visfaceonly_chkbtn_w; static int width, height; static int stereo_view = FALSE; static int visible_faces_only = TRUE; static char *prev_filename = NULL; GtkWidget *frame_w; GtkWidget *hbox_w; GtkWidget *vbox_w; char *filename; char *input_str; char init_str[256]; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_OK: /* Grab and save the specified filename */ filename = gtk_file_selection_get_filename( GTK_FILE_SELECTION(filesel_w) ); xfree( prev_filename ); prev_filename = xstrdup( filename ); /* Get rendering dimensions */ input_str = read_entry( size_entry_w ); width = (int)strtod( input_str, NULL ); /* next part (height) */ input_str = strpbrk( input_str, "xX* " ); if (input_str != NULL) input_str = strpbrk( input_str, "0123456789" ); if (input_str != NULL) height = (int)strtod( input_str, NULL ); else height = (3 * width) / 4; if ((width < 100) || (height < 75)) { /* Dimensions are too small (or negative??) */ width = MAX(100, width); height = MAX(75, height); sprintf( init_str, "%d x %d", width, height ); set_entry_text( size_entry_w, init_str ); return; } stereo_view = GTK_TOGGLE_BUTTON(stereo_chkbtn_w)->active; visible_faces_only = GTK_TOGGLE_BUTTON(visfaceonly_chkbtn_w)->active; gtk_widget_hide( filesel_w ); case DIALOG_OK_CONFIRM: if (file_exists( prev_filename ) && (*message != DIALOG_OK_CONFIRM)) { filename = file_basename( prev_filename, NULL ); sprintf( init_str, STR_MSG_overwrite_warn_ARG, filename ); confirmation_dialog( STR_DLG_Warning, init_str, dialog_File_ExportSRS ); return; } else { ogl_blank( 0, NULL ); export_srs( prev_filename, width, height, stereo_view, visible_faces_only ); ogl_draw( 0 ); } /* no break/return here */ case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( filesel_w ); return; default: #ifdef DEBUG crash( "dialog_File_ExportSRS( ): invalid message" ); #endif return; } if (prev_filename == NULL) { /* Set defaults */ width = usr_cams[0]->ogl_w->allocation.width; height = usr_cams[0]->ogl_w->allocation.height; if (object_mode == MODE_LATTICE) sprintf( init_str, "%s.srs", STR_DLG_srs_basename1 ); else sprintf( init_str, "%s.srs", STR_DLG_srs_basename2 ); prev_filename = xstrdup( init_str ); } filesel_w = make_filesel_window( STR_DLG_Export_srs, prev_filename, TRUE, dialog_File_ExportSRS ); /* Label and frame for SRS parameters */ add_label( GTK_FILE_SELECTION(filesel_w)->main_vbox, STR_DLG_srs ); frame_w = add_frame( GTK_FILE_SELECTION(filesel_w)->main_vbox, STR_DLG_srs_Parameters ); /* hbox for image size / misc. parameter input */ hbox_w = add_hbox( frame_w, FALSE, 10 ); /* Rendering size label & entry */ vbox_w = gtk_vbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), vbox_w, TRUE, FALSE, 0 ); gtk_widget_show( vbox_w ); add_label( vbox_w, STR_DLG_srs_Size ); sprintf( init_str, "%d x %d", width, height ); size_entry_w = add_entry( vbox_w, init_str, NULL, NULL ); /* Misc. parameter check buttons */ vbox_w = gtk_vbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), vbox_w, TRUE, FALSE, 0 ); gtk_widget_show( vbox_w ); stereo_chkbtn_w = add_check_button( vbox_w, STR_DLG_srs_Stereo_view, stereo_view, NULL, NULL ); visfaceonly_chkbtn_w = add_check_button( vbox_w, STR_DLG_srs_Vis_faces_only, visible_faces_only, NULL, NULL ); if (object_mode != MODE_USER_GEOMETRY) gtk_widget_hide( visfaceonly_chkbtn_w ); gtk_widget_show( filesel_w ); } #endif /* WITH_SRS_EXPORTER */ void menu_Objects_toggles( GtkWidget *widget, const int *message ) { int flag; flag = GTK_CHECK_MENU_ITEM(widget)->active; auxiliary_objects( *message, flag ); } void dialog_Objects_Animation( GtkWidget *widget, const int *message ) { static int active = FALSE; static GtkWidget *dialog_window_w; static GtkWidget *x0_entry_w; static GtkWidget *x1_entry_w; static GtkWidget *action_label_w; static GtkObject *loop_time_adj; static float prev_recomm_x0 = 999.0; static float prev_recomm_x1 = -999.0; static float prev_x0; static float prev_x1; static float prev_loop_time = 10.0; static int in_motion = FALSE; GtkWidget *main_vbox_w; GtkWidget *frame_w; GtkWidget *hbox_w; GtkWidget *hbox2_w; GtkWidget *vbox_w; GtkWidget *button_w; float recomm_x0; float recomm_x1; float input_x0; float input_x1; float input_loop_time; char *x_span_str = "0000000000"; char *input_str; char init_str[16]; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( dialog_window_w ); return; case DIALOG_OK: in_motion = !in_motion; if (in_motion) { /* Begin animation */ if (advanced_interface) { input_str = read_entry( x0_entry_w ); input_x0 = strtod( input_str, NULL ); input_str = read_entry( x1_entry_w ); input_x1 = strtod( input_str, NULL ); } else { input_x0 = prev_x0; input_x1 = prev_x1; } input_loop_time = GTK_ADJUSTMENT(loop_time_adj)->value; if (input_x0 > input_x1) return; if ((input_x1 - input_x0) < 0.5) return; warp_time( input_x0, input_x1, input_loop_time, WARP_BEGIN_ANIM ); gtk_label_set_text( GTK_LABEL(action_label_w), STR_DLG_Stop_btn ); prev_x0 = input_x0; prev_x1 = input_x1; prev_loop_time = input_loop_time; } else { /* Stop animation */ warp_time( NIL, NIL, NIL, WARP_STOP_ANIM ); gtk_label_set_text( GTK_LABEL(action_label_w), STR_DLG_Begin_btn ); } return; default: #ifdef DEBUG crash( "dialog_Objects_Animation( ): invalid message" ); #endif return; } /* Recommended values for x0 & x1 * All this prev_/recomm_/prev_recomm_ jockeying is to show recommended * values ONLY when they change, otherwise use previous user values */ recomm_x0 = world_extents.xmin - vehicle_extents.xmax; recomm_x1 = world_extents.xmax - vehicle_extents.xmin; if (recomm_x0 != prev_recomm_x0) { prev_x0 = recomm_x0; prev_x1 = recomm_x1; } prev_recomm_x0 = recomm_x0; prev_recomm_x1 = recomm_x1; /* Dialog window widget */ dialog_window_w = make_dialog_window( STR_DLG_Animation, dialog_Objects_Animation ); gtk_window_set_position( GTK_WINDOW(dialog_window_w), GTK_WIN_POS_MOUSE ); /* Main vertical box widget */ main_vbox_w = add_vbox( dialog_window_w, FALSE, 10 ); if (advanced_interface) { /* Title frame widget for range of motion entries */ frame_w = add_frame( main_vbox_w, STR_DLG_Observed_range ); hbox_w = add_hbox( frame_w, FALSE, 10 ); /* x0 entry */ vbox_w = add_vbox( hbox_w, FALSE, 0 ); add_label( vbox_w, STR_DLG_Start_X ); sprintf( init_str, "%.2f", prev_x0 ); x0_entry_w = add_entry( vbox_w, init_str, NULL, NULL ); set_entry_width( x0_entry_w, x_span_str ); /* x1 entry */ vbox_w = add_vbox( hbox_w, FALSE, 0 ); add_label( vbox_w, STR_DLG_End_X ); sprintf( init_str, "%.2f", prev_x1 ); x1_entry_w = add_entry( vbox_w, init_str, NULL, NULL ); set_entry_width( x1_entry_w, x_span_str ); hbox_w = add_hbox( main_vbox_w, FALSE, 0 ); } else { frame_w = add_frame( main_vbox_w, NULL ); hbox_w = add_hbox( frame_w, FALSE, 10 ); } hbox2_w = gtk_hbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), hbox2_w, TRUE, FALSE, 0 ); gtk_widget_show( hbox2_w ); /* Loop time spin button */ add_label( hbox2_w, STR_DLG_Loop_time ); loop_time_adj = gtk_adjustment_new( prev_loop_time, 1, 60, 1, 1, 0.0 ); add_spin_button( hbox2_w, loop_time_adj ); add_label( hbox2_w, STR_DLG_seconds ); /* Begin/Stop and Close buttons */ hbox_w = add_hbox( main_vbox_w, TRUE, 0 ); button_w = add_button( hbox_w, NULL, dialog_Objects_Animation, MESG_(DIALOG_OK) ); action_label_w = add_label( button_w, STR_DLG_Begin_btn ); if (in_motion) gtk_label_set_text( GTK_LABEL(action_label_w), STR_DLG_Stop_btn ); add_button( hbox_w, STR_DLG_Close_btn, dialog_Objects_Animation, MESG_(DIALOG_CLOSE) ); gtk_widget_show( dialog_window_w ); } void menu_Warp_toggles( GtkWidget *widget, const int *message ) { if (GTK_CHECK_MENU_ITEM(widget)->active) warp( *message, MESG_(1) ); else warp( *message, MESG_(0) ); } /* Camera / Lens / (lens length) */ void menu_Camera_Lens_select( GtkWidget *widget, const float *new_lens_length ) { float new_fov; new_fov = camera_calc_fov( *new_lens_length ); if (GTK_CHECK_MENU_ITEM(widget)->active) transition( &usr_cams[cur_cam]->fov, FALSE, TRANS_QTR_SIN, 3.0, new_fov, cur_cam ); } /* Camera / Lens / Custom */ void dialog_Camera_Lens_Custom( GtkWidget *widget, const int *message ) { static int active = FALSE; static GtkWidget *dialog_window_w; static GtkWidget *entry_w; static GtkWidget *frame_w; static GtkWidget *button_label_w; static camera *cam; static int fov_mode = FALSE; GtkWidget *main_vbox_w; GtkWidget *hbox_w; GtkWidget *vbox_w; GtkWidget *button_w; float input_val; float init_val; char *input_str; char init_str[16]; switch (*message) { case DIALOG_OPEN: if (active || !GTK_CHECK_MENU_ITEM(widget)->active) return; active = TRUE; break; case DIALOG_OK: input_str = read_entry( entry_w ); input_val = strtod( input_str, NULL ); if (!fov_mode) input_val = camera_calc_fov( input_val ); if ((input_val < 1.0) || (input_val > 175.0)) { set_entry_text( entry_w, STR_MSG_Invalid ); highlight_entry( entry_w ); return; } else transition( &cam->fov, FALSE, TRANS_SIGMOID, 3.0, input_val, cur_cam ); /* no break/return here */ case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( dialog_window_w ); return; case INITIALIZE: case UNITS_CHANGED: fov_mode = !fov_mode; if (fov_mode) { gtk_frame_set_label( GTK_FRAME(frame_w), STR_DLG_Field_of_view ); gtk_label_set_text( GTK_LABEL(button_label_w), STR_DLG_degree_suffix ); sprintf( init_str, "%.2f", cam->fov ); set_entry_text( entry_w, init_str ); } else { gtk_frame_set_label( GTK_FRAME(frame_w), STR_DLG_Lens_length ); gtk_label_set_text( GTK_LABEL(button_label_w), "mm" ); init_val = camera_calc_lens_length( cam->fov ); sprintf( init_str, "%.2f", init_val ); set_entry_text( entry_w, init_str ); } return; default: #ifdef DEBUG crash( "dialog_Lens_Custom( ): invalid message" ); #endif return; } cam = usr_cams[cur_cam]; /* Dialog window widget */ dialog_window_w = make_dialog_window( STR_DLG_Custom_Lens, dialog_Camera_Lens_Custom ); gtk_window_set_position( GTK_WINDOW(dialog_window_w), GTK_WIN_POS_MOUSE ); /* Main vertical box widget */ main_vbox_w = add_vbox( dialog_window_w, FALSE, 10 ); /* Title frame widget */ frame_w = add_frame( main_vbox_w, "---" ); /* Vertical box for spacing purposes only */ vbox_w = add_vbox( frame_w, FALSE, 10 ); /* Horizontal box for entry widget, units button */ hbox_w = add_hbox( vbox_w, FALSE, 0 ); /* Entry widget for lens length/FOV value */ entry_w = add_entry( hbox_w, "---", dialog_Camera_Lens_Custom, MESG_(DIALOG_OK) ); set_entry_width( entry_w, "00000000" ); /* Vertical box to frane the button */ vbox_w = add_vbox( hbox_w, FALSE, 3 ); /* Units select button */ button_w = add_button( vbox_w, NULL, dialog_Camera_Lens_Custom, MESG_(UNITS_CHANGED) ); /* Label for units select button */ button_label_w = add_label( button_w, "---" ); /* Horizontal box widget for OK/Close */ hbox_w = add_hbox( main_vbox_w, TRUE, 0 ); /* OK button */ add_button( hbox_w, STR_DLG_Okay_btn, dialog_Camera_Lens_Custom, MESG_(DIALOG_OK) ); /* "Cancel" button */ add_button( hbox_w, STR_DLG_Cancel_btn, dialog_Camera_Lens_Custom, MESG_(DIALOG_CLOSE) ); /* Call ourselves to set all the "---"'s to something sensible */ fov_mode = !fov_mode; /* following call will flip this back */ dialog_Camera_Lens_Custom( NULL, MESG_(INITIALIZE) ); gtk_widget_show( dialog_window_w ); } /* Camera / Position dialog * NOTE: phi & theta as seen by the user are NOT those in struct cam! * cam->phi = user_phi + 180, cam->theta = - user_theta */ void dialog_Camera_Position( GtkWidget *widget, const int *message ) { static int active = FALSE; static GtkWidget *dialog_window_w; static GtkWidget *loc_x_entry_w; static GtkWidget *loc_y_entry_w; static GtkWidget *loc_z_entry_w; static GtkWidget *targ_frame_w; static GtkWidget *targ_1_entry_w; static GtkWidget *targ_2_entry_w; static GtkWidget *targ_z_entry_w; static GtkWidget *unit_label_w; static GtkWidget *targ_1_label_w; static GtkWidget *targ_2_label_w; static GtkWidget *targ_z_vbox_w; static GtkWidget *action_label_w; static camera *cam; static int cam_id; static int phi_theta_mode = FALSE; static int input_queued; static int blocking_changed = FALSE; GtkWidget *main_vbox_w; GtkWidget *frame_w; GtkWidget *hbox_w; GtkWidget *vbox_w; GtkWidget *vbox2_w; GtkWidget *button_w; camera input_cam; float dx, dy, dz, dxy; char *xyz_span_str = "0000000000"; char *phi_theta_span_str = "00000000000000"; char init_str[16]; char *input_str; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_OK: /* If user didn't enter new values, don't do anything, just close */ if (!input_queued) goto cam_pos_close; /* Suck in all the input text */ input_str = read_entry( loc_x_entry_w ); input_cam.pos.x = strtod( input_str, NULL ); input_str = read_entry( loc_y_entry_w ); input_cam.pos.y = strtod( input_str, NULL ); input_str = read_entry( loc_z_entry_w ); input_cam.pos.z = strtod( input_str, NULL ); if (phi_theta_mode) { input_str = read_entry( targ_1_entry_w ); input_cam.phi = fmod( strtod( input_str, NULL ) + 180.0, 360.0 ); input_str = read_entry( targ_2_entry_w ); input_cam.theta = - fmod( strtod( input_str, NULL ), 90.0 ); /* Grok a better target and distance */ camera_make_target( &input_cam ); } else { input_str = read_entry( targ_1_entry_w ); input_cam.target.x = strtod( input_str, NULL ); input_str = read_entry( targ_2_entry_w ); input_cam.target.y = strtod( input_str, NULL ); input_str = read_entry( targ_z_entry_w ); input_cam.target.z = strtod( input_str, NULL ); /* Need to get phi+theta+distance from XYZpos/XYZtarget */ dx = input_cam.target.x - input_cam.pos.x; dy = input_cam.target.y - input_cam.pos.y; dz = input_cam.target.z - input_cam.pos.z; dxy = sqrt( SQR(dx) + SQR(dy) ); input_cam.phi = fmod( DEG(atan2( dy, dx )) + 180.0, 360.0 ); input_cam.theta = DEG(atan2( - dz, dxy )); input_cam.distance = sqrt( SQR(dx) + SQR(dy) + SQR(dz) ); if (input_cam.distance < 0.01) /* not good */ return; } if (ABS(input_cam.phi - cam->phi) > 180.0) { /* e.g. don't do a 300deg turn, -60deg will do */ if (cam->phi > input_cam.phi) cam->phi -= 360.0; else cam->phi += 360.0; } /* And finally, get the camera moving! */ transition( &cam->phi, FALSE, TRANS_SIGMOID, 4.0, input_cam.phi, cam_id ); transition( &cam->theta, FALSE, TRANS_SIGMOID, 4.0, input_cam.theta, cam_id ); transition( &cam->distance, FALSE, TRANS_SIGMOID, 4.0, input_cam.distance, cam_id ); transition( &cam->target.x, FALSE, TRANS_SIGMOID, 4.0, input_cam.target.x, cam_id ); transition( &cam->target.y, FALSE, TRANS_SIGMOID, 4.0, input_cam.target.y, cam_id ); transition( &cam->target.z, FALSE, TRANS_SIGMOID, 4.0, input_cam.target.z, cam_id ); /* no break/return here */ case DIALOG_CLOSE: cam_pos_close: if (!active) return; active = FALSE; gtk_widget_destroy( dialog_window_w ); return; case INITIALIZE: input_queued = TRUE; /* will be set FALSE shortly */ case UNITS_CHANGED: /* Switch between XYZ target and phi/theta specifications */ phi_theta_mode = !phi_theta_mode; if (phi_theta_mode) { /* Set the labels for XYZ target mode */ gtk_label_set_text( GTK_LABEL(unit_label_w), STR_DLG_Xyz_instead ); gtk_label_set_text( GTK_LABEL(targ_1_label_w), STR_DLG_Phi_label ); gtk_label_set_text( GTK_LABEL(targ_2_label_w), STR_DLG_Theta_label ); gtk_widget_hide( targ_z_vbox_w ); gtk_frame_set_label( GTK_FRAME(targ_frame_w), STR_DLG_Direction ); } else { /* Set the labels for phi/theta mode */ gtk_label_set_text( GTK_LABEL(unit_label_w), STR_DLG_Angles_instead ); gtk_label_set_text( GTK_LABEL(targ_1_label_w), "X" ); gtk_label_set_text( GTK_LABEL(targ_2_label_w), "Y" ); gtk_widget_show( targ_z_vbox_w ); gtk_frame_set_label( GTK_FRAME(targ_frame_w), STR_DLG_View_target ); } /* no break/return here */ case RESET: if (!active) return; /* Do this because set_entry_text( ) emits "changed" signals */ blocking_changed = TRUE; /* Update stale text in entry widgets */ if (*message != UNITS_CHANGED) { /* Update location entries * (but not on phi/theta mode switch) */ sprintf( init_str, "%.3f", cam->pos.x ); set_entry_text( loc_x_entry_w, init_str ); sprintf( init_str, "%.3f", cam->pos.y ); set_entry_text( loc_y_entry_w, init_str ); sprintf( init_str, "%.3f", cam->pos.z ); set_entry_text( loc_z_entry_w, init_str ); /* Also note: entries do not contain user input (anymore) */ if (input_queued) gtk_label_set_text( GTK_LABEL(action_label_w), STR_DLG_Okay_btn ); input_queued = FALSE; } if (phi_theta_mode) { /* Update phi+theta/target entries */ sprintf( init_str, "%.2f", fmod( cam->phi + 180.0, 360.0 ) ); set_entry_text( targ_1_entry_w, init_str ); set_entry_width( targ_1_entry_w, phi_theta_span_str ); sprintf( init_str, "%.2f", - cam->theta ); set_entry_text( targ_2_entry_w, init_str ); set_entry_width( targ_2_entry_w, phi_theta_span_str ); } else { /* Update XYZ target entries */ sprintf( init_str, "%.3f", cam->target.x ); set_entry_text( targ_1_entry_w, init_str ); set_entry_width( targ_1_entry_w, xyz_span_str ); sprintf( init_str, "%.3f", cam->target.y ); set_entry_text( targ_2_entry_w, init_str ); set_entry_width( targ_2_entry_w, xyz_span_str ); sprintf( init_str, "%.3f", cam->target.z ); set_entry_text( targ_z_entry_w, init_str ); set_entry_width( targ_z_entry_w, xyz_span_str ); } blocking_changed = FALSE; return; case VALUE_CHANGED: /* Don't catch signals from the set_entry_text( )'s above */ if (blocking_changed) return; /* Entries now contain user input */ if (!input_queued) gtk_label_set_text( GTK_LABEL(action_label_w), STR_DLG_Reposition_btn ); input_queued = TRUE; return; default: #ifdef DEBUG crash( "dialog_Camera_Position( ): invalid message" ); #endif return; } cam_id = cur_cam; cam = usr_cams[cam_id]; /* New dialog window */ dialog_window_w = make_dialog_window( STR_DLG_Camera_Position, dialog_Camera_Position ); gtk_window_set_position( GTK_WINDOW(dialog_window_w), GTK_WIN_POS_MOUSE ); /* Main vertical box widget */ main_vbox_w = add_vbox( dialog_window_w, FALSE, 10 ); /* Title frame for location entries */ frame_w = add_frame( main_vbox_w, STR_DLG_Location ); /* Horizontal box widget for location entries */ hbox_w = add_hbox( frame_w, TRUE, 10 ); /* The XYZ location entries */ vbox_w = add_vbox( hbox_w, FALSE, 0 ); add_label( vbox_w, "X" ); loc_x_entry_w = add_entry( vbox_w, "---", NULL, NULL ); set_entry_width( loc_x_entry_w, xyz_span_str ); gtk_signal_connect( GTK_OBJECT(loc_x_entry_w), "changed", GTK_SIGNAL_FUNC(dialog_Camera_Position), MESG_(VALUE_CHANGED) ); vbox_w = add_vbox( hbox_w, FALSE, 0 ); add_label( vbox_w, "Y" ); loc_y_entry_w = add_entry( vbox_w, "---", NULL, NULL ); set_entry_width( loc_y_entry_w, xyz_span_str ); gtk_signal_connect( GTK_OBJECT(loc_y_entry_w), "changed", GTK_SIGNAL_FUNC(dialog_Camera_Position), MESG_(VALUE_CHANGED) ); vbox_w = add_vbox( hbox_w, FALSE, 0 ); add_label( vbox_w, "Z" ); loc_z_entry_w = add_entry( vbox_w, "---", NULL, NULL ); set_entry_width( loc_z_entry_w, xyz_span_str ); gtk_signal_connect( GTK_OBJECT(loc_z_entry_w), "changed", GTK_SIGNAL_FUNC(dialog_Camera_Position), MESG_(VALUE_CHANGED) ); /* Title frame for target entries */ targ_frame_w = add_frame( main_vbox_w, "---" ); /* Vertical box widget for target entries + entry mode button */ vbox_w = add_vbox( targ_frame_w, FALSE, 10 ); /* Horizontal box widget for target entries (custom) */ hbox_w = add_hbox( vbox_w, TRUE, 0 ); /* The XYZ-target/phi+theta-heading entries */ /* X or phi */ vbox2_w = gtk_vbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), vbox2_w, TRUE, FALSE, 0 ); gtk_widget_show( vbox2_w ); targ_1_label_w = add_label( vbox2_w, "---" ); targ_1_entry_w = add_entry( vbox2_w, "---", NULL, NULL ); gtk_signal_connect( GTK_OBJECT(targ_1_entry_w), "changed", GTK_SIGNAL_FUNC(dialog_Camera_Position), MESG_(VALUE_CHANGED) ); /* Y or theta */ vbox2_w = gtk_vbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), vbox2_w, TRUE, FALSE, 0 ); gtk_widget_show( vbox2_w ); targ_2_label_w = add_label( vbox2_w, "---" ); targ_2_entry_w = add_entry( vbox2_w, "---", NULL, NULL ); gtk_signal_connect( GTK_OBJECT(targ_2_entry_w), "changed", GTK_SIGNAL_FUNC(dialog_Camera_Position), MESG_(VALUE_CHANGED) ); /* Z */ targ_z_vbox_w = gtk_vbox_new( FALSE, 0 ); gtk_box_pack_start( GTK_BOX(hbox_w), targ_z_vbox_w, TRUE, FALSE, 0 ); gtk_widget_show( targ_z_vbox_w ); add_label( targ_z_vbox_w, "Z" ); targ_z_entry_w = add_entry( targ_z_vbox_w, "---", NULL, NULL ); gtk_signal_connect( GTK_OBJECT(targ_z_entry_w), "changed", GTK_SIGNAL_FUNC(dialog_Camera_Position), MESG_(VALUE_CHANGED) ); /* Entry mode button */ button_w = add_button( vbox_w, NULL, dialog_Camera_Position, MESG_(UNITS_CHANGED) ); unit_label_w = add_label( button_w, "---" ); /* Horizontal box widget for OK/Cancel */ hbox_w = add_hbox( main_vbox_w, TRUE, 0 ); /* OK/Cancel buttons */ button_w = add_button( hbox_w, NULL, dialog_Camera_Position, MESG_(DIALOG_OK) ); action_label_w = add_label( button_w, "---" ); add_button( hbox_w, STR_DLG_Cancel_btn, dialog_Camera_Position, MESG_(DIALOG_CLOSE) ); /* Call ourselves to set all the "---"'s to something sensible */ phi_theta_mode = !phi_theta_mode; /* the next call will flip it back */ dialog_Camera_Position( NULL, MESG_(INITIALIZE) ); gtk_widget_show( dialog_window_w ); } void menu_Camera_ResetView( GtkWidget *widget, const int *cam_id ) { camera_reset( *cam_id ); } void menu_Camera_InfoDisplay_toggles( GtkWidget *widget, const int *message ) { int flag; flag = GTK_CHECK_MENU_ITEM(widget)->active; info_display( *message, flag ); } /* Set a new background color */ void menu_Camera_Background_select( GtkWidget *widget, const int *color_id ) { float new_r, new_g, new_b; if (!GTK_CHECK_MENU_ITEM(widget)->active) return; #ifdef DEBUG if (*color_id >= num_background_colors) crash( "menu_Camera_Background_select( ): invalid color" ); #endif new_r = bkgd_colors[*color_id].r; new_g = bkgd_colors[*color_id].g; new_b = bkgd_colors[*color_id].b; transition( &background.r, FALSE, TRANS_QTR_SIN, 2.0, new_r, -1 ); transition( &background.g, FALSE, TRANS_QTR_SIN, 2.0, new_g, -1 ); transition( &background.b, FALSE, TRANS_QTR_SIN, 2.0, new_b, -1 ); } /* Camera / Graphics mode * Switches between OpenGL's shaded and wireframe modes */ void menu_Camera_GraphicsMode_select( GtkWidget *widget, const int *message ) { int i; /* "toggled" signal also catches "toggle off" */ if (!GTK_CHECK_MENU_ITEM(widget)->active) return; for (i = 0; i < num_cams; i++) { gtk_gl_area_make_current( GTK_GL_AREA(usr_cams[i]->ogl_w) ); switch (*message) { case OGL_WIREFRAME_MODE: glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); break; case OGL_SHADED_MODE: glPolygonMode( GL_FRONT, GL_FILL ); break; default: #ifdef DEBUG crash( "menu_Camera_GraphicsMode( ): invalid message" ); #endif break; } GTKGL_TEMP_endgl( GTK_GL_AREA(usr_cams[i]->ogl_w) ); } /* Redraw everything */ queue_redraw( -1 ); } /* Camera / Spawn camera * Creates a new window, with a new, autonomous camera view */ void menu_Camera_Spawn( GtkWidget *widget, void *dummy ) { GtkWidget *cam_window_w; GtkWidget *main_vbox_w; GtkWidget *menu_bar_w; camera *new_cam; /* Create the camera */ new_cam = new_camera( ); /* New window widget */ cam_window_w = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_title( GTK_WINDOW(cam_window_w), STR_DLG_Camera ); gtk_widget_set_usize( cam_window_w, 400, 300 ); gtk_container_set_border_width( GTK_CONTAINER(cam_window_w), 0 ); gtk_signal_connect( GTK_OBJECT(cam_window_w), "focus_in_event", GTK_SIGNAL_FUNC(camera_set_current), NULL ); gtk_signal_connect( GTK_OBJECT(cam_window_w), "delete_event", GTK_SIGNAL_FUNC(menu_Camera_Close), NULL ); /* Destroy window before exiting */ gtk_quit_add_destroy( 1, GTK_OBJECT(cam_window_w) ); /* Main vertical box widget */ main_vbox_w = gtk_vbox_new( FALSE, 0 ); gtk_container_set_border_width( GTK_CONTAINER(main_vbox_w), 0 ); gtk_container_add( GTK_CONTAINER(cam_window_w), main_vbox_w ); gtk_widget_show( main_vbox_w ); /* Initialize keybinding */ keybind( NULL, NULL ); /* Build minimal menu bar */ menu_bar_w = gtk_menu_bar_new( ); gtk_box_pack_start( GTK_BOX(main_vbox_w), menu_bar_w, FALSE, FALSE, 0 ); gtk_widget_show( menu_bar_w ); /* NOTE: add_Camera_menu( ) uses assoc_cam_id( ) */ new_cam->window_w = cam_window_w; /* Add a stripped-down Camera menu */ add_Camera_menu( menu_bar_w, cam_window_w ); /* Add viewport */ new_cam->ogl_w = add_gl_area( main_vbox_w ); /* Attach keybindings */ keybind( cam_window_w, NULL ); gtk_widget_show( cam_window_w ); /* Ready for action! */ } /* Camera / Close (appears only in spawned windows) * Gets rid of a spawned camera */ void menu_Camera_Close( GtkWidget *widget_to_kill, void *dummy ) { int cam_id; cam_id = assoc_cam_id( widget_to_kill ); kill_camera( cam_id ); } /* Help / Overview * Tell the user what's going on */ void dialog_Help_Overview( GtkWidget *widget, int *message ) { static int active = FALSE; static GtkWidget *help_window_w; GtkWidget *main_vbox_w; GtkWidget *frame_w; GtkWidget *help_label_w; GtkWidget *hbox_w; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( help_window_w ); return; default: #ifdef DEBUG crash( "dialog_Help_Overview( ): invalid message" ); #endif return; } help_window_w = make_dialog_window( STR_DLG_Overview, dialog_Help_Overview ); gtk_window_set_position( GTK_WINDOW(help_window_w), GTK_WIN_POS_CENTER ); main_vbox_w = add_vbox( help_window_w, FALSE, 10 ); frame_w = add_frame( main_vbox_w, NULL ); hbox_w = add_hbox( frame_w, FALSE, 10 ); help_label_w = add_label( hbox_w, STR_DLG_Overview_TEXT ); gtk_label_set_justify( GTK_LABEL(help_label_w), GTK_JUSTIFY_LEFT ); /* OK button (hbox_w is to keep button from growing heightwise) */ hbox_w = add_hbox( main_vbox_w, FALSE, 0 ); add_button( hbox_w, STR_DLG_Okay_btn, dialog_Help_Overview, MESG_(DIALOG_CLOSE) ); gtk_widget_show( help_window_w ); } /* Help / Controls * Give a summary of mouse input syntax */ void dialog_Help_Controls( GtkWidget *widget, int *message ) { static int active = FALSE; static GtkWidget *help_window_w; GtkWidget *main_vbox_w; GtkWidget *frame_w; GtkWidget *help_label_w; GtkWidget *hbox_w; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( help_window_w ); return; default: #ifdef DEBUG crash( "dialog_Help_Controls( ): invalid message" ); #endif return; } help_window_w = make_dialog_window( STR_DLG_Controls, dialog_Help_Controls ); gtk_window_set_position( GTK_WINDOW(help_window_w), GTK_WIN_POS_CENTER ); main_vbox_w = add_vbox( help_window_w, FALSE, 10 ); frame_w = add_frame( main_vbox_w, NULL ); hbox_w = add_hbox( frame_w, FALSE, 10 ); help_label_w = add_label( hbox_w, STR_DLG_Controls_TEXT ); gtk_label_set_justify( GTK_LABEL(help_label_w), GTK_JUSTIFY_LEFT ); /* OK button (hbox_w is to keep button from growing heightwise) */ hbox_w = add_hbox( main_vbox_w, FALSE, 0 ); add_button( hbox_w, STR_DLG_Okay_btn, dialog_Help_Controls, MESG_(DIALOG_CLOSE) ); gtk_widget_show( help_window_w ); } /* Help / About * Tell a little about ourselves */ void dialog_Help_About( GtkWidget *widget, int *message ) { static int active = FALSE; static GtkWidget *about_window_w; GtkWidget *main_vbox_w; GtkWidget *frame_w; GtkWidget *vbox_w; GtkWidget *entry_w; char info_str[256]; switch (*message) { case DIALOG_OPEN: if (active) return; active = TRUE; break; case DIALOG_CLOSE: if (!active) return; active = FALSE; gtk_widget_destroy( about_window_w ); return; default: #ifdef DEBUG crash( "dialog_Help_About( ): invalid message" ); #endif return; } about_window_w = make_dialog_window( STR_DLG_About, dialog_Help_About ); gtk_window_set_position( GTK_WINDOW(about_window_w), GTK_WIN_POS_CENTER ); main_vbox_w = add_vbox( about_window_w, FALSE, 10 ); frame_w = add_frame( main_vbox_w, NULL ); vbox_w = add_vbox( frame_w, FALSE, 15 ); /* Get the Light Speed! title up */ add_pixmap( vbox_w, about_window_w, lightspeed_title_xpm ); sprintf( info_str, STR_DLG_Version_x_y_ARG, VERSION ); add_label( vbox_w, info_str ); sprintf( info_str, STR_DLG_authorship_ARG, "Daniel Richard G." ); strcat( info_str, "\nskunk@mit.edu" ); add_label( vbox_w, info_str ); sprintf( info_str, STR_copyright_ARG, 1999, "DRG" ); add_label( vbox_w, info_str ); /* To allow easy cut-and-paste :-) */ entry_w = gtk_entry_new( ); gtk_entry_set_editable( GTK_ENTRY(entry_w), FALSE ); sprintf( info_str, "XXX%sXXX", STR_DLG_home_page_url ); set_entry_width( entry_w, info_str ); set_entry_text( entry_w, STR_DLG_home_page_url ); gtk_box_pack_start( GTK_BOX(vbox_w), entry_w, FALSE, FALSE, 0 ); gtk_widget_show( entry_w ); add_button( main_vbox_w, STR_DLG_Okay_btn, dialog_Help_About, MESG_(DIALOG_CLOSE) ); gtk_widget_show( about_window_w ); } /* end menu_cbs.c */ lightspeed-1.2a/src/misc.c0000644000175000017500000002266407176115553011240 /* misc.c */ /* Random stuff */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* A kinder, gentler malloc( ) */ void * xmalloc( size_t size ) { void *block; #ifdef DEBUG int i; #endif block = malloc( size ); if (block == NULL) crash( "Insufficient memory" ); #ifdef WITH_TRACKMEM trackmem_malloc( block, size ); #endif #ifdef DEBUG /* Fill memory block with random junk */ for (i = 0; i < size; i++) ((unsigned char *)block)[i] = (unsigned char)(rand( ) % 256); #endif return block; } /* ditto for realloc( ) */ void * xrealloc( void *block, size_t size ) { void *block2; block2 = realloc( block, size ); if (block2 == NULL) crash( "Insufficient memory" ); #ifdef WITH_TRACKMEM trackmem_realloc( block, block2, size ); #endif return block2; } char * xstrdup( const char *str ) { char *new_str; new_str = strdup( str ); if (new_str == NULL) crash( "Insufficient memory" ); #ifdef WITH_TRACKMEM trackmem_strdup( new_str ); #endif return new_str; } void xfree( void *block ) { #ifdef WITH_TRACKMEM trackmem_free( block ); #endif free( block ); } /* Checks if a file already exists */ int file_exists( const char *filename ) { FILE *fp; fp = fopen( filename, "r" ); if (fp == NULL) return FALSE; fclose( fp ); return TRUE; } /* This is a functional equivalent of the UNIX "basename" command */ char * file_basename( const char *name, const char *suffix ) { static char basename_buf[256]; int blen, slen; char *base; base = strrchr( name, '/' ); if (base == NULL) base = (char *)name; else base = &base[1]; strcpy( basename_buf, base ); if (suffix != NULL) { blen = strlen( basename_buf ); slen = strlen( suffix ); if (!strcasecmp( &basename_buf[blen - slen], suffix )) basename_buf[blen - slen] = '\0'; } return basename_buf; } /* Swaps the extension of a filename to new_ext if it already ends in old_ext * (a NULL for old_exts means any period-demarcated extension) */ char * swap_filename_ext( const char *filename, const char *old_ext, const char *new_ext ) { static char filename_buf[256]; char *ext_begin; int i; strcpy( filename_buf, filename ); if (old_ext != NULL) { i = strlen( filename_buf ) - strlen( old_ext ); ext_begin = &filename_buf[i]; if (!strcasecmp( ext_begin, old_ext )) strcpy( ext_begin, new_ext ); } else { ext_begin = strrchr( filename_buf, '.' ); if (ext_begin != NULL) strcpy( ext_begin, new_ext ); } return filename_buf; } /* Wrapper for gettimeofday( ) */ double read_system_clock( void ) { struct timeval tv; double t; gettimeofday( &tv, NULL ); t = (double)tv.tv_sec; t += (double)tv.tv_usec / 1E6; return t; } /* Change cursor appearance */ void set_cursor_glyph( int glyph ) { static GdkCursor *cursor; static int prev_glyph = -1; if (prev_glyph != -1) gdk_cursor_destroy( cursor ); cursor = gdk_cursor_new( glyph ); gdk_window_set_cursor( usr_cams[cur_cam]->ogl_w->window, cursor ); prev_glyph = glyph; } /* Returns the specified velocity (in m/s) formatted to current unit system * "fancy" parameter adds commas and units suffix when TRUE */ char * velocity_string( double v_ms, int fancy ) { static char v_str[32]; const char *suffix; double v_conv; int num_decimals; char num_str[32]; v_conv = v_ms / unit_conv_factors[cur_unit_system]; num_decimals = unit_num_decimals[cur_unit_system]; suffix = unit_suffixes[cur_unit_system]; if (fancy) { sprintf( num_str, "%.*f", num_decimals, v_conv ); sprintf( v_str, "%s %s", add_commas( num_str ), suffix ); } else sprintf( v_str, "%.*f", num_decimals, v_conv ); return v_str; } /* Adds commas to a number string */ char * add_commas( const char *num_str ) { static char new_str[64]; int len; int decimal_reached = FALSE; int group_digits = 0; int n = 64; int i; char c; if (strchr( num_str, '.' ) == NULL) decimal_reached = TRUE; /* no decimal point */ len = strlen( num_str ); new_str[--n] = '\0'; for (i = len - 1; i >= 0; i--) { c = num_str[i]; if (group_digits == 3) { new_str[--n] = ','; group_digits = 0; } new_str[--n] = c; if (decimal_reached) ++group_digits; if (c == '.') decimal_reached = TRUE; } return &new_str[n]; } /* Removes commas and other junk from a number string */ char * clean_number( const char *num_str ) { static char new_str[64]; int start, len; int n = 64; int decimal_reached = FALSE; int i; char c; start = strcspn( num_str, "123456789." ); len = strlen( num_str ); new_str[--n] = '\0'; for (i = len - 1; i >= start; i--) { c = num_str[i]; if (c == '.') { /* Allow only one occurrence of decimal point */ if (decimal_reached) continue; else decimal_reached = TRUE; } else if ((c < '0') || (c > '9')) continue; new_str[--n] = c; } return &new_str[n]; } /* Returns current time, formatted nicely and to an appropriate precision */ char * time_string( void ) { static char t_str[64]; float abs_t, t_usec; abs_t = ABS(cur_time_t); if (abs_t >= 1E-2) sprintf( t_str, "%+.3f ", cur_time_t ); else if (abs_t >= 1E-4) sprintf( t_str, "%+.5f ", cur_time_t ); else { t_usec = 1E6 * cur_time_t; /* microseconds */ sprintf( t_str, "%+.3f %c", t_usec, micro_glyph ); } return t_str; } /* Generates display gamma correction color component lookup table */ void calc_dgamma_lut( float dgamma ) { float k, x; int i; k = 1.0 / dgamma; for (i = 0; i <= LUT_RES; i++) { x = (float)i / LUT_RES; dgamma_lut[i] = pow( x, k ); } } /* Hopefully this never gets called */ void crash( char *error_mesg ) { fprintf( stderr, "CRASH: %s\n", error_mesg ); fflush( stderr ); exit( -1 ); } /* ^_^ */ void ss( void ) { const float r1 = 0.0375749; const float r2 = 0.112725; const float r3 = 0.187875; const float r4 = 0.42485; const float r5 = 0.5; const float r6 = 0.518787; const float a1 = 20.7181; const float a2 = 25.7579; const float a3 = 26.8014; const float a4 = 45.0353; const float xd = 0.1161; const float yd = 0.1127; camera *cam; float x, y; float a; int i; cam = usr_cams[0]; gtk_gl_area_make_current( GTK_GL_AREA(cam->ogl_w) ); glClearColor( 0.0, 0.0, 0.0, 0.0 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glDisable( GL_DEPTH_TEST ); glDisable( GL_LIGHTING ); glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); x = (float)cam->width; y = (float)cam->height; if ((x / y) > 1.0 ) { x = 0.6 * x / y; y = 0.6; } else { y = 0.6 * y / x; x = 0.6; } glOrtho( - x, x, - y, y, -1.0, 1.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); glBegin( GL_QUAD_STRIP ); glColor3f( 1.0, 1.0, 1.0 ); glVertex2f( - xd, yd + r1 ); glVertex2f( - xd, yd + r2 ); for (i = 0; i <= 32; i++) { a = RAD(90.0 + 180.0 * (float)i / 32.0); x = cos(a); y = sin(a); glVertex2f( - xd + r1 * x, yd + r1 * y ); glVertex2f( - xd + r2 * x, yd + r2 * y ); } for (i = 0; i <= 64; i++) { a = RAD(90.0 - 180.0 * (float)i / 64.0); x = cos(a); y = sin(a); glVertex2f( xd + r3 * x, - yd + r3 * y ); glVertex2f( xd + r2 * x, - yd + r2 * y ); } for (i = 0; i <= 128; i++) { a = RAD(180.0 + a4 + (a1 - a4 + 180.0) * (float)i / 128.0); glVertex2f( r4 * cos(a), r4 * sin(a) ); a = RAD(180.0 + a2 + 180.0 * (float)i / 128.0); glVertex2f( r6 * cos(a), r6 * sin(a) ); } glVertex2f( - xd, yd + r1 ); glVertex2f( - xd, yd + r2 ); glEnd( ); glBegin( GL_QUAD_STRIP ); glColor3f( 1.0, 1.0, 1.0 ); for (i = 0; i <= 128; i++) { a = RAD( a3 + 180.0 * (float)i / 128.0 ); glVertex2f( r5 * cos(a), r5 * sin(a) ); a = RAD( a2 + 180.0 * (float)i / 128.0 ); glVertex2f( r6 * cos(a), r6 * sin(a) ); } glEnd( ); glBegin( GL_TRIANGLE_FAN ); glColor3f( 1.0, 1.0, 1.0 ); glVertex2f( - xd, yd + r3 ); for (i = 0; i <= 32; i ++) { a = RAD( a4 + (90.0 - a4) * (float)i / 32.0 ); glVertex2f( r4 * cos(a), r4 * sin(a) ); } glEnd( ); glBegin( GL_QUAD_STRIP ); glColor3f( 1.0, 1.0, 1.0 ); for (i = 0; i <= 128; i++) { a = RAD( 90.0 + 180.0 * (float)i / 128.0 ); glVertex2f( - xd + r3 * cos(a), yd + r3 * sin(a) ); a = RAD( 90.0 + (a1 + 90.0) * (float)i / 128.0 ); glVertex2f( r4 * cos(a), r4 * sin(a) ); } glVertex2f( xd, - yd + r1 ); glVertex2f( xd, - yd - r1 ); glEnd( ); glBegin( GL_TRIANGLE_FAN ); glColor3f( 1.0, 1.0, 1.0 ); for (i = 0; i <= 16; i++) { a = RAD( -90.0 + 180.0 * (float)i / 16.0 ); glVertex2f( xd + r1 * cos(a), - yd + r1 * sin(a) ); } glEnd( ); glHint( GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE ); glEnable( GL_LIGHTING ); glEnable( GL_DEPTH_TEST ); GTKGL_TEMP_endgl( GTK_GL_AREA(cam->ogl_w) ); gtk_gl_area_swapbuffers( GTK_GL_AREA(cam->ogl_w) ); } /* NOP is referenced in compat.h * When no one in the world is using GTK 1.0, I'll get rid of this */ int *NOP( void ) { while (FALSE); return NULL; } /* end misc.c */ lightspeed-1.2a/src/ogl.c0000644000175000017500000003424707176115553011066 /* ogl.c */ /* Main OpenGL routines */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Initialize OpenGL state * (will be connected to the GL widget's "realize" signal) */ void ogl_initialize( GtkWidget *ogl_w, void *nothing ) { float light0_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; float light0_diffuse[] = { 0.625, 0.625, 0.625, 1.0 }; float light0_specular[] = { 1.0, 1.0, 1.0, 1.0 }; float light_model_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; float light_pos[] = { 0.0, 0.0, 0.0, 1.0 }; int on_screen = TRUE; if (ogl_w == NULL) on_screen = FALSE; if (on_screen) gtk_gl_area_make_current( GTK_GL_AREA(ogl_w) ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glLightfv( GL_LIGHT0, GL_AMBIENT, light0_ambient ); glLightfv( GL_LIGHT0, GL_DIFFUSE, light0_diffuse ); glLightfv( GL_LIGHT0, GL_SPECULAR, light0_specular ); glRotatef( -90.0, 1.0, 0.0, 0.0 ); glRotatef( -90.0, 0.0, 0.0, 1.0 ); glLightfv( GL_LIGHT0, GL_POSITION, light_pos ); glLightModelfv( GL_LIGHT_MODEL_AMBIENT, light_model_ambient ); glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE ); glEnable( GL_COLOR_MATERIAL ); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LESS ); glEnable( GL_CULL_FACE ); glCullFace( GL_BACK ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glShadeModel( GL_SMOOTH ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); /* Initialize ogl_draw_string for primary viewport and pixmap buffers * (other viewports will get this via shared context) */ if ((assoc_cam_id( ogl_w ) == 0) || !on_screen) ogl_draw_string( NULL, INITIALIZE, NIL ); if (on_screen) { GTKGL_TEMP_endgl( GTK_GL_AREA(ogl_w) ); /* Call ogl_resize( ) to finish viewport initialization */ ogl_resize( ogl_w, NULL, NULL ); } #ifdef DEBUG if (on_screen) printf( "Initialized viewport %d\n", assoc_cam_id( ogl_w ) ); else printf( "Initialized off-screen pixmap buffer\n" ); fflush( stdout ); #endif } /* Change viewport size (after whatever window size adjustment) * Will be connected to the "configure_event" signal * Note: For some reason, this gets called once before ogl_initialize( )... */ int ogl_resize( GtkWidget *ogl_w, GdkEventConfigure *ev_config, void *nothing ) { static float dummy; int width, height; int i; width = ogl_w->allocation.width; height = ogl_w->allocation.height; gtk_gl_area_make_current( GTK_GL_AREA(ogl_w) ); glViewport( 0, 0, width, height ); GTKGL_TEMP_endgl( GTK_GL_AREA(ogl_w) ); /* Update dimensions in camera struct */ i = assoc_cam_id( ogl_w ); usr_cams[i]->width = width; usr_cams[i]->height = height; /* Recalibrate framerate */ profile( PROFILE_FRAMERATE_RESET ); dummy = 1.0; transition( &dummy, FALSE, TRANS_LINEAR, 1.0, 0.0, -1 ); #ifdef DEBUG printf( "Resized camera %d to %dx%d\n", i, width, height ); fflush( stdout ); #endif return FALSE; } /* Refresh a viewport (static redraw) * Will be connected to the "expose_event" signal */ int ogl_refresh( GtkWidget *ogl_w, GdkEventExpose *ev_expose, void *nothing ) { int i; i = assoc_cam_id( ogl_w ); queue_redraw( i ); #ifdef SUPER_DEBUG printf( "Refresh camera %d\n", i ); fflush( stdout ); #endif return FALSE; } /* Redraws the viewport of the camera indicated by cam_id * A cam_id of -1 means we're drawing the primary view into a pixmap buffer */ void ogl_draw( int cam_id ) { camera *cam; ogl_object *obj; float r,g,b; float fr_x, fr_y; int drawing_to_screen = TRUE; int o, i, v; i = 0; /* Avoid pesky "unused variable..." warnings */ v = 0; /* (if they come up-- see the #ifdef's) */ #ifdef SUPER_DEBUG if (cam_id >= 0) printf( "Drawing camera %d...", cam_id ); else printf( "Drawing into off-screen pixmap..." ); fflush( stdout ); #endif if (cam_id < 0) { drawing_to_screen = FALSE; cam = &out_cam; cam_id = 0; } else cam = usr_cams[cam_id]; /* Apply relativistic distortions for this view */ if (drawing_to_screen) { profile( PROFILE_WARP_BEGIN ); warp( WARP_DISTORT, &cam->pos ); profile( PROFILE_WARP_DONE ); profile( PROFILE_OGLDRAW_BEGIN ); gtk_gl_area_make_current( GTK_GL_AREA(cam->ogl_w) ); } else warp( WARP_DISTORT, &cam->pos ); r = background.r; g = background.g; b = background.b; if (dgamma_correct) { r = dgamma_lut[(int)(r * LUT_RES)]; g = dgamma_lut[(int)(g * LUT_RES)]; b = dgamma_lut[(int)(b * LUT_RES)]; } glClearColor( r, g, b, 0.0 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); /* Set view frustum (a.k.a. field of view) */ glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); fr_x = cam->near_clip * tan( RAD(cam->fov) / 2 ); fr_y = fr_x / ((float)cam->width / (float)cam->height); glFrustum( - fr_x, fr_x, - fr_y, fr_y, cam->near_clip, cam->far_clip ); /* (Re)initialize transformation matrix */ glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); /* Initialize the coordinate system to correct alignment */ glRotatef( -90.0, 1.0, 0.0, 0.0 ); glRotatef( -90.0, 0.0, 0.0, 1.0 ); /* Perform world transformations */ glTranslatef( - cam->distance, 0.0, 0.0 ); glRotatef( cam->theta, 0.0, 1.0, 0.0 ); glRotatef( - cam->phi, 0.0, 0.0, 1.0 ); glTranslatef( - cam->target.x, - cam->target.y, - cam->target.z ); /* For wireframe mode, if active */ glLineWidth( 2 ); /* Draw all vehicle objects */ for (o = 0; o < num_vehicle_objs; o++) { obj = vehicle_objs[o]; /* Execute "before" display list, if there is one */ if (obj->pre_dlist != 0) glCallList( obj->pre_dlist ); #ifdef GL_VERSION_1_1 glInterleavedArrays( GL_C4F_N3F_V3F, sizeof(ogl_point), obj->iarrays ); #ifdef GL_VERSION_1_2 glDrawRangeElements( obj->type, 0, obj->num_vertices - 1, obj->num_indices, GL_UNSIGNED_INT, obj->indices ); #else glDrawElements( obj->type, obj->num_indices, GL_UNSIGNED_INT, obj->indices ); #endif /* else GL_VERSION_1_2 */ #else /* Fine, we'll do this the old-fashioned way */ glBegin( obj->type ); for (i = 0; i < obj->num_indices; i++) { v = obj->indices[i]; glColor4fv( &obj->iarrays[v].r ); glNormal3fv( &obj->iarrays[v].nx ); glVertex3fv( &obj->iarrays[v].x ); } glEnd( ); #endif /* else GL_VERSION_1_1 */ /* Execute "after" display list if there is one */ if (obj->post_dlist != 0) glCallList( obj->post_dlist ); } /* Draw all active auxiliary objects */ auxiliary_objects( AUXOBJS_DRAW, cam_id ); #if 0 /* Draw normal lines (a.k.a. "hedgehogification") * (for debugging purposes) */ if (FALSE) { glLineWidth( 1 ); glBegin( GL_LINES ); for (o = 0; o < num_vehicle_objs; o++) { obj = vehicle_objs[o]; for (v = 0; v < obj->num_vertices; v++) { float x, y, z; x = obj->vertices[v].x; y = obj->vertices[v].y; z = obj->vertices[v].z; glVertex3f( x, y, z ); x += obj->normals[v].x; y += obj->normals[v].y; z += obj->normals[v].z; glVertex3f( x, y, z ); } } glEnd( ); } #endif /* 0 */ /* Initialize string drawer (i.e. inform of viewport dimensions) */ ogl_draw_string( cam, RESET, NIL ); /* Finally, draw info display (nothing if it's turned off) * Only the primary camera or an off-screen image gets this */ if ((cam_id == 0) || !drawing_to_screen) info_display( INFODISP_DRAW, NIL ); if (drawing_to_screen) { GTKGL_TEMP_endgl( GTK_GL_AREA(cam->ogl_w) ); gtk_gl_area_swapbuffers( GTK_GL_AREA(cam->ogl_w) ); profile( PROFILE_OGLDRAW_DONE ); cam->redraw = FALSE; } #ifdef SUPER_DEBUG printf( "done.\n" ); fflush( stdout ); #endif } /* Draws a string in the viewport * Meaning of args can vary, see initial switch statement * "size" specifies size of text: 0 (small), 1 (medium) or 2 (large) * NOTE: This function requires some pre-existing state; namely, the target * GL context must already be made current as well as properly initialized * (see ogl_blank( ) or info_display( ) to see what I mean) */ void ogl_draw_string( const void *data, int message, int size ) { static GdkFont **fonts; static unsigned int *font_dlist_bases; static int *font_heights; static int width, height; static int fn_big; static int num_tl_lines, num_tr_lines, num_bl_lines, num_br_lines; static int num_cen_lines; const char *test_str = "XXXX XXXX XXXX XXXX"; camera *cam; int pos_code; int edge_dx = 1, edge_dy = 1; int x = 0, y = 0; int fn; int i; char str_buf[256]; char *disp_str; char *next_disp_str; switch (message) { case INITIALIZE: /* First-time initialization */ fonts = xmalloc( num_font_sizes * sizeof(GdkFont *) ); font_dlist_bases = xmalloc( num_font_sizes * sizeof(unsigned int *) ); font_heights = xmalloc( num_font_sizes * sizeof(int *) ); for (i = 0; i < num_font_sizes; i++) { fonts[i] = gdk_font_load( sys_font_names[i] ); if (fonts[i] == NULL) { printf( "ERROR: Cannot load font: %s\n", sys_font_names[i] ); fflush( stdout ); continue; } font_heights[i] = fonts[i]->ascent + fonts[i]->descent; font_dlist_bases[i] = glGenLists( 192 ); gdk_gl_use_gdk_font( fonts[i], 0, 192, font_dlist_bases[i] ); } return; case RESET: /* Once-per-GL-redraw initialization */ cam = (camera *)data; /* Get GL widget dimensions */ width = cam->width; height = cam->height; /* Reset line counters */ num_tl_lines = 0; num_tr_lines = 0; num_bl_lines = 0; num_br_lines = 0; num_cen_lines = 0; /* Determine upper limit on the font sizes we should use */ for (i = 0; i < num_font_sizes; i++) { fn_big = i; /* font number of "big" (size 2) font */ /* Test string should be minimally 1/3 viewport width */ if (gdk_string_width( fonts[i], test_str ) > (width / 3)) break; } return; default: pos_code = message; disp_str = (char *)data; break; } /* Check string for newlines, and queue if necessary */ i = strcspn( disp_str, "\n" ); if (i < strlen( disp_str )) { strcpy( str_buf, disp_str ); str_buf[i] = '\0'; disp_str = str_buf; next_disp_str = &str_buf[i + 1]; } else next_disp_str = NULL; /* Determine which (proportional) font size to use */ fn = MIN(fn_big, MAX(0, fn_big - 2 + size)); /* 0 <= fn <= fn_big */ /* x coord. of base point */ switch (pos_code) { case POS_TOP_LEFT: case POS_BOTTOM_LEFT: x = width / 100; edge_dx = 1; break; case POS_TOP_RIGHT: case POS_BOTTOM_RIGHT: x = (width * 99) / 100; x -= gdk_string_width( fonts[fn], disp_str ); edge_dx = -1; break; case POS_CENTER: x = width / 2; x -= gdk_string_width( fonts[fn], disp_str ) / 2; edge_dx = 0; break; default: #ifdef DEBUG crash( "ogl_draw_string( ): invalid position code" ); #endif return; } /* y coord. of base point */ switch (pos_code) { case POS_BOTTOM_LEFT: case POS_BOTTOM_RIGHT: y = height / 100; edge_dy = 1; break; case POS_TOP_LEFT: case POS_TOP_RIGHT: y = (99 * height) / 100; y -= font_heights[fn]; edge_dy = -1; break; case POS_CENTER: y = height / 2; y -= font_heights[fn] / 2; edge_dy = -1; break; } /* This makes multi-line readouts possible */ switch (pos_code) { case POS_TOP_LEFT: y -= num_tl_lines * font_heights[fn]; ++num_tl_lines; break; case POS_TOP_RIGHT: y -= num_tr_lines * font_heights[fn]; ++num_tr_lines; break; case POS_BOTTOM_LEFT: y += num_bl_lines * font_heights[fn]; ++num_bl_lines; break; case POS_BOTTOM_RIGHT: y += num_br_lines * font_heights[fn]; ++num_br_lines; break; case POS_CENTER: y -= num_cen_lines * font_heights[fn]; ++num_cen_lines; break; } glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); glOrtho( 0.0, (double)width, 0.0, (double)height, -1.0, 1.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); /* Draw text backing */ glColor3f( INFODISP_TEXT_BACK_R, INFODISP_TEXT_BACK_G, INFODISP_TEXT_BACK_B ); glRasterPos2i( x + edge_dx, y + edge_dy ); glListBase( font_dlist_bases[fn] ); glCallLists( strlen(disp_str), GL_UNSIGNED_BYTE, disp_str ); /* Draw text face */ glColor3f( INFODISP_TEXT_FRONT_R, INFODISP_TEXT_FRONT_G, INFODISP_TEXT_FRONT_B ); glRasterPos2i( x, y ); glCallLists( strlen(disp_str), GL_UNSIGNED_BYTE, disp_str ); /* Finally, do next line if disp_str had newlines */ if (next_disp_str != NULL) ogl_draw_string( next_disp_str, pos_code, size ); } /* Blanks out a viewport, optionally displaying a [centered] message */ void ogl_blank( int cam_id, const char *blank_message ) { camera *cam; cam = usr_cams[cam_id]; gtk_gl_area_make_current( GTK_GL_AREA(cam->ogl_w) ); glClearColor( background.r, background.g, background.b, 0.0 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); if (blank_message != NULL) { /* Tell ogl_draw_string( ) about GL widget dimensions */ ogl_draw_string( cam, RESET, NIL ); glDisable( GL_DEPTH_TEST ); glDisable( GL_LIGHTING ); ogl_draw_string( blank_message, POS_CENTER, 2 ); glEnable( GL_LIGHTING ); glEnable( GL_DEPTH_TEST ); } GTKGL_TEMP_endgl( GTK_GL_AREA(cam->ogl_w) ); gtk_gl_area_swapbuffers( GTK_GL_AREA(cam->ogl_w) ); } /* The GL widget begins life here * If the primary GL widget (camera 0) has already been defined, create a * new one with shared context, to let ogl_draw_string( ) also work in the * new window, and simplify display list management a good bit */ GtkWidget * ogl_make_widget( void ) { GtkWidget *primary_ogl_w; int gl_area_attributes[] = { GDK_GL_RGBA, GDK_GL_RED_SIZE, 1, GDK_GL_GREEN_SIZE, 1, GDK_GL_BLUE_SIZE, 1, GDK_GL_DEPTH_SIZE, 1, GDK_GL_DOUBLEBUFFER, GDK_GL_NONE }; primary_ogl_w = usr_cams[0]->ogl_w; if (primary_ogl_w == NULL) return gtk_gl_area_new( gl_area_attributes ); else return gtk_gl_area_share_new( gl_area_attributes, GTK_GL_AREA(primary_ogl_w) ); } /* end ogl.c */ lightspeed-1.2a/src/read3ds.c0000644000175000017500000017047707176115553011640 /* read3ds.c */ /* Mini-library for loading .3DS files * 3D Studio loading code by Jare/Iguana et. al. (see further down for details) * API interface & portability mods by Straker Skunk * * I wrote this interface only as far as I needed it. Much is lacking; in * particular, material property loading and light definitions. * Anyone want a go at it? * * NOTE: This code is in NO WAY connected to AutoDesk Inc. or Kinetix Inc. * Jare expressed concern that he might have violated AutoDesk's * intellectual property in releasing this 3DS interpreter; however, he * reverse-engineered the format in perfectly legal manner, and made use * of equally legitimate documentation written by others on the Internet. * This library contains ABSOLUTELY NO CODE from AutoDesk's own 3DS File * Toolkit, which I believe was even released subsequent to the authoring * of this interpreter. * * THIS FILE IS IN THE PUBLIC DOMAIN */ #include "read3ds.h" int r3ds_read_uint8( uint8 *data, int count, FILE *f ) { int n; n = fread( data, sizeof(uint8), count, f ); if (n != count) return FALSE; /* failure */ return TRUE; /* success */ } int r3ds_read_uint16( uint16 *data, int count, FILE *f ) { uint8 bytes[2]; int i, rs = TRUE; /* rs == return status */ for (i = 0; i < count; i++) { rs = rs && r3ds_read_uint8( bytes, 2, f ); data[i] = ((uint16)bytes[1] << 8) | (uint16)bytes[0]; } return rs; } int r3ds_read_uint32( uint32 *data, int count, FILE *f ) { uint8 bytes[4]; int i, rs = TRUE; for (i = 0; i < count; i++) { rs = rs && r3ds_read_uint8( bytes, 4, f ); data[i] = ((uint32)bytes[3] << 24) | ((uint32)bytes[2] << 16) | ((uint32)bytes[1] << 8) | (uint32)bytes[0]; } return rs; } int r3ds_read_float( float *data, int count, FILE *f ) { uint32 fpdata; int i, rs = TRUE; for (i = 0; i < count; i++) { rs = rs && r3ds_read_uint32( &fpdata, 1, f ); data[i] = *((float *)&fpdata); } return rs; } int r3ds_file_is_3ds( const char *filename ) { FILE *file_3ds; int filesize; uint16 chunk_id; uint32 chunk_len; file_3ds = fopen( filename, "rb" ); if (file_3ds == NULL) return 0; /* Get file size */ fseek( file_3ds, 0, SEEK_END ); filesize = ftell( file_3ds ); fseek( file_3ds, 0, SEEK_SET ); /* Read in main chunk header */ r3ds_read_uint16( &chunk_id, 1, file_3ds ); r3ds_read_uint32( &chunk_len, 1, file_3ds ); fclose( file_3ds ); if (chunk_id != 0x4D4D) return 0; /* Check that file size is *around* what it should be */ if (ABS(filesize - (int)chunk_len) > 16) return 0; /* Yes, this *does* appear to be a valid 3D Studio file */ return 1; } int r3ds_file_is_prj( const char *filename ) { FILE *file_prj; int filesize; uint16 chunk_id; uint32 chunk_len; file_prj = fopen( filename, "rb" ); if (file_prj == NULL) return 0; /* Get file size */ fseek( file_prj, 0, SEEK_END ); filesize = ftell( file_prj ); fseek( file_prj, 0, SEEK_SET ); /* Read in main chunk header */ r3ds_read_uint16( &chunk_id, 1, file_prj ); r3ds_read_uint32( &chunk_len, 1, file_prj ); fclose( file_prj ); if (chunk_id != 0xC23D) return 0; /* Check that file size is *around* what it should be */ if (ABS(filesize - (int)chunk_len) > 16) return 0; /* Yes, this does appear to be a valid 3D Studio project file */ return 1; } void r3ds_build( int data_id, const void *data ) { static r3ds_object **objects; static r3ds_light **lights; static r3ds_camera **cameras; static r3ds_trimesh **trimeshes; static r3ds_material *materials; static r3ds_object *obj; static r3ds_light *lite; /* A better abbreviation, anyone? */ static r3ds_camera *cam; static r3ds_trimesh *tmesh; static r3ds_material *mat; static r3ds_color24 *color24; static r3ds_color24 default_color24 = { 128, 128, 128 }; static float inches_per_unit; static int num_objects; static int num_lights; static int num_cameras; static int num_trimeshes; static int num_materials; static int vert_alloc = 0; static int tri_alloc = 0; static int cur_vert = 0; static int cur_tri = 0; static int cur_mat; r3ds_scene *scene; r3ds_triangle *tri; r3ds_point *vert; uint32 *dwordp; float *floatp; int *intp; int i; char *name; switch (data_id) { case R3DS_INITIALIZE: inches_per_unit = 1.0; objects = NULL; lights = NULL; cameras = NULL; trimeshes = NULL; materials = NULL; color24 = NULL; num_objects = 0; num_lights = 0; num_cameras = 0; num_trimeshes = 0; num_materials = 0; break; case R3DS_PROJECT_SCALE: floatp = (float *)data; inches_per_unit = *floatp; break; /* Object definition input * (to be followed by light/camera/trimesh def. input */ case R3DS_NEW_OBJECT: name = (char *)data; ++num_objects; objects = xrealloc( objects, num_objects * sizeof(r3ds_object *) ); obj = xmalloc( sizeof(r3ds_object) ); obj->type = R3DS_OBJ_UNDEFINED; obj->name = xstrdup( name ); objects[num_objects - 1] = obj; #ifdef R3DS_VERBOSE printf( "\n\nNew object: \"%s\"\n", name ); #endif break; /* Light definition input */ /* INCOMPLETE */ case R3DS_DEF_LIGHT: ++num_lights; lights = xrealloc( lights, num_lights * sizeof(r3ds_light *) ); lite = xrealloc( obj, sizeof(r3ds_light) ); lite->type = R3DS_OBJ_LIGHT; objects[num_objects - 1] = R3DS_OBJECT(lite); lights[num_lights - 1] = lite; #ifdef R3DS_VERBOSE printf( "Light\n" ); #endif break; /* Camera definiton input */ case R3DS_DEF_CAMERA: floatp = (float *)data; ++num_cameras; cameras = xrealloc( cameras, num_cameras * sizeof(r3ds_camera *) ); cam = xrealloc( obj, sizeof(r3ds_camera) ); cam->type = R3DS_OBJ_CAMERA; cam->x = floatp[0]; cam->y = floatp[1]; cam->z = floatp[2]; cam->targ_x = floatp[3]; cam->targ_y = floatp[4]; cam->targ_z = floatp[5]; cam->bank = floatp[6]; cam->lens = floatp[7]; objects[num_objects - 1] = R3DS_OBJECT(cam); cameras[num_cameras - 1] = cam; #ifdef R3DS_VERBOSE printf( "Camera\n" ); #endif break; /* Triangle mesh definition input */ case R3DS_DEF_TRIMESH: ++num_trimeshes; trimeshes = xrealloc( trimeshes, num_trimeshes * sizeof(r3ds_trimesh *) ); tmesh = xrealloc( obj, sizeof(r3ds_trimesh) ); tmesh->type = R3DS_OBJ_TRIMESH; tmesh->num_verts = 0; tmesh->num_tris = 0; objects[num_objects - 1] = R3DS_OBJECT(tmesh); trimeshes[num_trimeshes - 1] = tmesh; vert_alloc = 0; cur_vert = 0; tri_alloc = 0; cur_tri = 0; cur_mat = -1; #ifdef R3DS_VERBOSE printf( "Triangle mesh\n" ); #endif break; case R3DS_NUM_VERTS: i = *((int *)data); vert_alloc = i; tmesh->num_verts = i; if (i > 0) tmesh->verts = xmalloc( i * sizeof(r3ds_point) ); for (i = 0; i < tmesh->num_verts; i++) { vert = &tmesh->verts[i]; vert->x = 0.0; vert->y = 0.0; vert->z = 0.0; vert->u = 0.0; vert->v = 0.0; } #ifdef R3DS_VERBOSE printf( "\tBegin %d vertices\n", tmesh->num_verts ); #endif break; case R3DS_VERT: floatp = (float *)data; if (cur_vert >= vert_alloc) break; vert = &tmesh->verts[cur_vert]; vert->x = floatp[0]; vert->y = floatp[1]; vert->z = floatp[2]; #ifdef R3DS_VERBOSE printf( "\t\tVertex %d: (%.2f, %.2f, %.2f)\n", cur_vert, floatp[0], floatp[1], floatp[2] ); #endif ++cur_vert; break; case R3DS_NUM_VERT_MAPPINGS: cur_vert = 0; #ifdef R3DS_VERBOSE printf( "\n" ); #endif break; case R3DS_VERT_MAPPING: floatp = (float *)data; if (cur_vert >= vert_alloc) break; vert = &tmesh->verts[cur_vert]; vert->u = floatp[0]; vert->v = floatp[1]; #ifdef R3DS_VERBOSE printf( "\t\tMapping %d: (%.2f, %.2f)\n", cur_vert, floatp[0], floatp[1] ); #endif ++cur_vert; break; case R3DS_NUM_TRIS: i = *((int *)data); tri_alloc = i; tmesh->num_tris = i; if (i > 0) tmesh->tris = xmalloc( i * sizeof(r3ds_triangle) ); for (i = 0; i < tmesh->num_tris; i++) { tri = &tmesh->tris[i]; tri->a = 0.0; tri->b = 0.0; tri->c = 0.0; tri->flags = 0; tri->mat_id = -1; tri->smgroups = 0; } #ifdef R3DS_VERBOSE printf( "\tBegin %d triangles\n", tmesh->num_tris ); #endif break; case R3DS_TRI_FACE: intp = (int *)data; if (cur_tri >= tri_alloc) break; tri = &tmesh->tris[cur_tri]; tri->a = CLAMP(intp[0], 0, vert_alloc - 1); tri->b = CLAMP(intp[1], 0, vert_alloc - 1); tri->c = CLAMP(intp[2], 0, vert_alloc - 1); tri->flags = (uint16)intp[3]; #ifdef R3DS_VERBOSE printf( "\t\tTriangle %d: %d--%d--%d Flags=0x%X\n", cur_tri, wordp[0], wordp[1], wordp[2], wordp[3] ); #endif ++cur_tri; break; case R3DS_TRI_MATERIAL_CURRENT: name = (char *)data; cur_mat = -1; /* default material */ /* Find material index */ for (i = 0; i < num_materials; i++) if (!strcmp( name, materials[i].name )) { cur_mat = i; break; } #ifdef R3DS_VERBOSE printf( "\tBegin triangles with material: \"%s\" (%d)\n", name, cur_mat ); #endif break; case R3DS_TRI_MATERIAL: i = *((int *)data); if ((i < 0) || (i >= tri_alloc)) break; tmesh->tris[i].mat_id = cur_mat; #ifdef R3DS_VERBOSE printf( "\t\tTriangle %d\n", i ); #endif break; case R3DS_BEGIN_TRI_SMOOTH: cur_tri = 0; #ifdef R3DS_VERBOSE printf( "\tBegin smoothing group definitions\n" ); #endif break; case R3DS_TRI_SMOOTH: dwordp = (uint32 *)data; if (cur_tri >= tri_alloc) break; tmesh->tris[cur_tri].smgroups = *dwordp; #ifdef R3DS_VERBOSE printf( "\t\tTriangle %d:", cur_tri ); if (R3DS_TRI_IN_SMGROUP(&tmesh->tris[cur_tri],0)) printf( " none" ); else for (i = 1; i <= 32; i++) if (R3DS_TRI_IN_SMGROUP(&tmesh->tris[cur_tri],i)) printf( " %d", i ); printf( "\n" ); #endif ++cur_tri; break; case R3DS_ROT_MATRIX: floatp = (float *)data; for (i = 0; i < 9; i++) tmesh->rot_matrix[i] = floatp[i]; break; case R3DS_TRANS_MATRIX: floatp = (float *)data; for (i = 0; i < 3; i++) tmesh->trans_matrix[i] = floatp[i]; break; /* Material definition input */ case R3DS_NEW_MATERIAL: name = (char *)data; ++num_materials; materials = xrealloc( materials, num_materials * sizeof(r3ds_material) ); mat = &materials[num_materials - 1]; mat->name = xstrdup( name ); memcpy( &mat->ambient, &default_color24, sizeof(r3ds_color24) ); memcpy( &mat->diffuse, &default_color24, sizeof(r3ds_color24) ); memcpy( &mat->specular, &default_color24, sizeof(r3ds_color24) ); mat->two_sided = 0; mat->texmap_file = NULL; mat->refmap_file = NULL; #ifdef R3DS_VERBOSE printf( "\nNew material: \"%s\" (%d)\n", name, num_materials - 1 ); #endif break; case R3DS_MAT_AMBIENT_COLOR: color24 = &mat->ambient; #ifdef R3DS_VERBOSE printf( "\tAmbient color: " ); #endif break; case R3DS_MAT_DIFFUSE_COLOR: color24 = &mat->diffuse; #ifdef R3DS_VERBOSE printf( "\tDiffuse color: " ); #endif break; case R3DS_MAT_SPECULAR_COLOR: color24 = &mat->specular; #ifdef R3DS_VERBOSE printf( "\tSpecular color: " ); #endif break; case R3DS_MAT_2SIDED: mat->two_sided = 1; #ifdef R3DS_VERBOSE printf( "\tMaterial is 2-sided\n" ); #endif break; case R3DS_COLOR24: intp = (int *)data; if (color24 != NULL) { color24->red = CLAMP(intp[0], 0, 255); color24->green = CLAMP(intp[1], 0, 255); color24->blue = CLAMP(intp[2], 0, 255); #ifdef R3DS_VERBOSE printf( "(%d, %d, %d)\n", color24->red, color24->green, color24->blue ); #endif } color24 = NULL; break; /* Output */ case R3DS_GET_SCENE: scene = (r3ds_scene *)data; scene->inches_per_unit = inches_per_unit; scene->num_objs = num_objects; scene->objs = objects; scene->num_lites = num_lights; scene->lites = lights; scene->num_cams = num_cameras; scene->cams = cameras; scene->num_tmeshes = num_trimeshes; scene->tmeshes = trimeshes; scene->num_mats = num_materials; scene->mats = materials; break; } #ifdef R3DS_VERBOSE fflush( stdout ); #endif } r3ds_scene * read3ds( const char *filename ) { r3ds_scene *scene; FILE *file_3ds; int filesize; file_3ds = fopen( filename, "rb" ); if (file_3ds == NULL) return NULL; /* Get file size */ fseek( file_3ds, 0, SEEK_END ); filesize = ftell( file_3ds ); fseek( file_3ds, 0, SEEK_SET ); /* Read file */ r3ds_build( R3DS_INITIALIZE, NULL ); r3ds_ChunkReader( file_3ds, 0, filesize ); fclose( file_3ds ); scene = xmalloc( sizeof(r3ds_scene) ); r3ds_build( R3DS_GET_SCENE, scene ); return scene; } /* Verbosely describe a light */ void r3ds_dump_light( r3ds_light *light ) { printf( "Light \"%s\"\n", light->name ); } /* Verbosely describe a camera */ void r3ds_dump_camera( r3ds_camera *cam ) { printf( "Camera \"%s\"\n", cam->name ); printf( " Location: (%.3f, %.3f, %.3f)\n", cam->x, cam->y, cam->z ); printf( " Target: (%.3f, %.3f, %.3f)\n", cam->targ_x, cam->targ_y, cam->targ_z ); printf( " Bank: %.2f Lens: %.2f\n", cam->bank, cam->lens ); } /* Verbosely describe a triangle mesh */ void r3ds_dump_trimesh( r3ds_trimesh *trimesh ) { r3ds_point *vert; r3ds_triangle *tri; int i, g; printf( "Triangle mesh \"%s\"\n", trimesh->name ); /* Vertices */ printf( " %d vertices\n", trimesh->num_verts ); for (i = 0; i < trimesh->num_verts; i++) { vert = &trimesh->verts[i]; printf( "\tVert #%d: XYZ=(%.3f, %.3f, %.3f)", i, vert->x, vert->y, vert->z ); printf( " UV=(%.3f, %.3f)\n", vert->u, vert->v ); } /* Triangles */ printf( " %d triangles\n", trimesh->num_tris ); for (i = 0; i < trimesh->num_tris; i++) { tri = &trimesh->tris[i]; printf( "\tTri #%d: %d ", i, tri->a ); if (R3DS_TRI_AB_VIS(tri)) printf( "+" ); else printf( "-" ); printf( " %d ", tri->b ); if (R3DS_TRI_BC_VIS(tri)) printf( "+" ); else printf( "-" ); printf( " %d ", tri->c ); if (R3DS_TRI_CA_VIS(tri)) printf( "+" ); else printf( "-" ); if (R3DS_TRI_U_WRAP(tri)) printf( " Uwrap" ); if (R3DS_TRI_V_WRAP(tri)) printf( " Vwrap" ); /* Smoothing groups */ printf( " SmGrps:" ); if (R3DS_TRI_IN_SMGROUP(tri,0)) printf( " none" ); else { for (g = 1; g <= 32; g++) if (R3DS_TRI_IN_SMGROUP(tri,g)) printf( " %d", g ); } printf( "\n" ); } /* Rotation matrix */ printf( " Coordinate system alignment" ); for (i = 0; i < 9; i++) { if ((i % 3) == 0) printf( "\n\t" ); printf( "% .6f ", trimesh->rot_matrix[i] ); } /* Translation matrix */ printf( "\n Coordinate system origin\n\t" ); for (i = 0; i < 3; i++) printf( "% .6f ", trimesh->trans_matrix[i] ); printf( "\n" ); fflush( stdout ); } /* Verbosely describe an object, whatever it may be */ void r3ds_dump_object( r3ds_object *obj ) { printf( "\n" ); switch (obj->type) { case R3DS_OBJ_LIGHT: r3ds_dump_light( R3DS_LIGHT(obj) ); break; case R3DS_OBJ_CAMERA: r3ds_dump_camera( R3DS_CAMERA(obj) ); break; case R3DS_OBJ_TRIMESH: r3ds_dump_trimesh( R3DS_TRIMESH(obj) ); break; case R3DS_OBJ_UNDEFINED: printf( "Object \"%s\" - undefined\n", obj->name ); break; default: printf( "Error: invalid r3ds_object\n" ); break; } } /* Deallocates an object */ void r3ds_free_object( r3ds_object *obj ) { r3ds_light *light; r3ds_camera *cam; r3ds_trimesh *tmesh; switch (obj->type) { case R3DS_OBJ_LIGHT: light = R3DS_LIGHT(obj); xfree( light->name ); xfree( light ); break; case R3DS_OBJ_CAMERA: cam = R3DS_CAMERA(obj); xfree( cam->name ); xfree( cam ); break; case R3DS_OBJ_TRIMESH: tmesh = R3DS_TRIMESH(obj); xfree( tmesh->name ); if (tmesh->num_verts > 0) xfree( tmesh->verts ); if (tmesh->num_tris > 0) xfree( tmesh->tris ); xfree( tmesh ); break; case R3DS_OBJ_UNDEFINED: xfree( obj->name ); xfree( obj ); break; #ifdef R3DS_DEBUG default: printf( "ERROR: attempted to free invalid r3ds_object\n" ); fflush( stdout ); break; #endif } } /* Deallocates a material */ void r3ds_free_material( r3ds_material *mat ) { xfree( mat->name ); if (mat->texmap_file != NULL) xfree( mat->texmap_file ); if (mat->refmap_file != NULL) xfree( mat->refmap_file ); } /* Deallocates an entire scene-- i.e. EVERYTHING */ void r3ds_free_scene( r3ds_scene *scene ) { int i; /* Free scene objects */ for (i = 0; i < scene->num_objs; i++) r3ds_free_object( scene->objs[i] ); /* Free scene materials */ for (i = 0; i < scene->num_mats; i++) r3ds_free_material( &scene->mats[i] ); /* Free pointer arrays */ if (scene->num_objs > 0) xfree( scene->objs ); if (scene->num_lites > 0) xfree( scene->lites ); if (scene->num_cams > 0) xfree( scene->cams ); if (scene->num_tmeshes > 0) xfree( scene->tmeshes ); if (scene->num_mats > 0) xfree( scene->mats ); /* Free scene itself */ xfree( scene ); } /* Pass this a triangle, and it will return the number of the FIRST smoothing * group that triangle is in (0 if not in any group) */ int r3ds_first_smgroup( r3ds_triangle *tri ) { int g; for (g = 1; g <= 32; g++) if (R3DS_TRI_IN_SMGROUP(tri,g)) return g; return 0; } /* Internal function-- rebuilds the r3ds_scene->objs array from the * separate ->lites, ->cams and ->tmeshes arrays */ void r3ds_rebuild_scene_objs( r3ds_scene *scene ) { int n,o; n = scene->num_lites + scene->num_cams + scene->num_tmeshes; scene->num_objs = n; scene->objs = xrealloc( scene->objs, n * sizeof(r3ds_object *) ); n = 0; for (o = 0; o < scene->num_lites; o++) scene->objs[n++] = R3DS_OBJECT(scene->lites[o]); for (o = 0; o < scene->num_cams; o++) scene->objs[n++] = R3DS_OBJECT(scene->cams[o]); for (o = 0; o < scene->num_tmeshes; o++) scene->objs[n++] = R3DS_OBJECT(scene->tmeshes[o]); } /* This function is mostly meant for use by r3ds_split_trimeshes( ); it takes a * pointer to an array of one trimesh, splits up the trimesh by smoothing groups * (message == -1) or materials (message == num_mats), places all the new * trimeshes into the array and returns the quantity created (or -1 on error) * Note: original trimesh always gets freed */ int r3ds_split_trimesh( r3ds_trimesh ***trimeshes_ptr, int message ) { r3ds_trimesh **group_tmeshes; r3ds_trimesh *orig_tmesh, *tmesh; r3ds_triangle *orig_tri, *tri; int num_groups; int num_new_tmeshes = 0; int *tri_counts; int *index_remap; int *vertex_remap; char name_suffix[16]; int len; int g, t, v, n; /* Create group array, triangle counters */ if (message == -1) /* R3DS_SPLIT_BY_SMGROUP */ num_groups = 33; /* Null group + smoothing groups 1-32 */ else num_groups = message + 1; /* # of materials + default finish */ group_tmeshes = xmalloc( num_groups * sizeof(r3ds_trimesh *) ); tri_counts = xmalloc( num_groups * sizeof(int) ); orig_tmesh = *trimeshes_ptr[0]; /* See how many triangles are in each potential sub-trimesh group */ for (g = 0; g < num_groups; g++) tri_counts[g] = 0; /* initialize counters first */ for (t = 0; t < orig_tmesh->num_tris; t++) { orig_tri = &orig_tmesh->tris[t]; if (message == -1) /* R3DS_SPLIT_BY_SMGROUP */ g = r3ds_first_smgroup( orig_tri ); else { g = orig_tri->mat_id; if (g == -1) /* default material */ g += num_groups; } ++tri_counts[g]; } /* For each non-empty group, create a new sub-trimesh */ for (g = 0; g < num_groups; g++) { n = tri_counts[g]; if (n == 0) { group_tmeshes[g] = NULL; continue; } ++num_new_tmeshes; /* tmesh = new sub-trimesh */ tmesh = xmalloc( sizeof(r3ds_trimesh) ); if (message == -1) /* R3DS_SPLIT_BY_SMGROUP */ sprintf( name_suffix, " (smgrp %d)", g ); else { if (g < (num_groups - 1)) sprintf( name_suffix, " (mat=%d)", g ); else sprintf( name_suffix, " (mat=default)" ); } len = strlen( orig_tmesh->name ) + strlen( name_suffix ) + 1; tmesh->name = xmalloc( len * sizeof(char) ); strcpy( tmesh->name, orig_tmesh->name ); strcat( tmesh->name, name_suffix ); tmesh->type = R3DS_OBJ_TRIMESH; tmesh->num_tris = n; tmesh->tris = xmalloc( n * sizeof(r3ds_triangle) ); group_tmeshes[g] = tmesh; } /* Re-init triangle counters, need them for something else now */ for (g = 0; g < num_groups; g++) tri_counts[g] = 0; /* Copy each triangle into the appropriate sub-trimesh */ for (t = 0; t < orig_tmesh->num_tris; t++) { orig_tri = &orig_tmesh->tris[t]; if (message == -1) /* R3DS_SPLIT_BY_SMGROUP */ g = r3ds_first_smgroup( orig_tri ); else { g = orig_tri->mat_id; if (g == -1) /* default material */ g += num_groups; } tmesh = group_tmeshes[g]; n = tri_counts[g]++; tri = &tmesh->tris[n]; memcpy( tri, orig_tri, sizeof(r3ds_triangle) ); if (message == -1) { /* R3DS_SPLIT_BY_SMGROUP */ /* Set new smoothing groups property */ if (g == 0) tri->smgroups = 0; else tri->smgroups = (uint32)1 << (g - 1); } } /* Done with triangle counters */ xfree( tri_counts ); /* Allocate vertex/index remapping tables (pseudo-functions, * each the inverse of the other) */ n = orig_tmesh->num_verts; if (n > 0) { vertex_remap = xmalloc( n * sizeof(int) ); index_remap = xmalloc( n * sizeof(int) ); } else { vertex_remap = NULL; index_remap = NULL; } /* Get vertices and remapped indices into each sub-trimesh */ for (g = 0; g < num_groups; g++) { tmesh = group_tmeshes[g]; if (tmesh == NULL) continue; /* Initialize index remap table for this object * (vertex_remap doesn't need this) */ for (v = 0; v < orig_tmesh->num_verts; v++) index_remap[v] = -1; /* Build tables */ v = 0; for (t = 0; t < tmesh->num_tris; t++) { tri = &tmesh->tris[t]; if (index_remap[tri->a] == -1) { vertex_remap[v] = tri->a; index_remap[tri->a] = v++; } if (index_remap[tri->b] == -1) { vertex_remap[v] = tri->b; index_remap[tri->b] = v++; } if (index_remap[tri->c] == -1) { vertex_remap[v] = tri->c; index_remap[tri->c] = v++; } } tmesh->num_verts = v; if (v > 0) tmesh->verts = xmalloc( v * sizeof(r3ds_point) ); /* Copy the vertices needed */ for (v = 0; v < tmesh->num_verts; v++) { n = vertex_remap[v]; memcpy( &tmesh->verts[v], &orig_tmesh->verts[n], sizeof(r3ds_point) ); } /* And lastly, remap the indices */ for (t = 0; t < tmesh->num_tris; t++) { tri = &tmesh->tris[t]; tri->a = index_remap[tri->a]; tri->b = index_remap[tri->b]; tri->c = index_remap[tri->c]; } } /* Done with these */ if (vertex_remap != NULL) { xfree( vertex_remap ); xfree( index_remap ); } r3ds_free_object( R3DS_OBJECT(orig_tmesh) ); /* Place the new sub-trimeshes in the original array */ n = num_new_tmeshes; if (n > 1) *trimeshes_ptr = xrealloc( *trimeshes_ptr, n * sizeof(r3ds_trimesh *) ); if (n == 0) xfree( *trimeshes_ptr ); /* orig_tmesh was a dud :( */ n = 0; for (g = 0; g < num_groups; g++) { tmesh = group_tmeshes[g]; if (tmesh != NULL) { (*trimeshes_ptr)[n++] = tmesh; } } xfree( group_tmeshes ); return num_new_tmeshes; } /* This runs through all the r3ds_trimeshes in the given scene and breaks each * down into smaller trimeshes, either on the basis of material (message == * R3DS_SPLIT_BY_MATERIAL) or lowest-numbered smoothing group (message == * R3DS_SPLIT_BY_SMGROUP) * Useful if you want to import 3DS geometry into a property-per-vertex 3D * system like OpenGL (which is exactly the reason I wrote this :) */ int r3ds_split_scene_trimeshes( r3ds_scene *scene, int message ) { r3ds_trimesh **new_tmeshes = NULL; r3ds_trimesh **tmeshes; int num_new_tmeshes = 0; int n, o; for (o = 0; o < scene->num_tmeshes; o++) { tmeshes = xmalloc( sizeof(r3ds_trimesh *) ); tmeshes[0] = scene->tmeshes[o]; switch (message) { case R3DS_SPLIT_BY_MATERIAL: n = r3ds_split_trimesh( &tmeshes, scene->num_mats ); break; case R3DS_SPLIT_BY_SMGROUP: n = r3ds_split_trimesh( &tmeshes, -1 ); break; default: return -1; } num_new_tmeshes += n; if (n > 0) { new_tmeshes = xrealloc( new_tmeshes, num_new_tmeshes * sizeof(r3ds_trimesh *) ); memcpy( &new_tmeshes[num_new_tmeshes - n], tmeshes, n * sizeof(r3ds_trimesh *) ); xfree( tmeshes ); } } xfree( scene->tmeshes ); scene->num_tmeshes = num_new_tmeshes; scene->tmeshes = new_tmeshes; r3ds_rebuild_scene_objs( scene ); return num_new_tmeshes; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This next part is what does the down and dirty file reading. It is a modified * version of the 3DS reader by Jare/Iguana et. al. (see below for details). * * Main changes: * * 1) Replaced all the fread()'s with read_uintXX()/read_float() calls, to * allow explicit little-endian byte ordering. Meaning that file I/O is now * pretty much endian-agnostic. * * 2) Got rid of the #pragma pack directive, and changed the code to read in * the chunk header fields separately instead of the whole thing at once * (the unaligned double word TChunkHeader->len was giving bus errors when * accessed on MIPS hardware) * * 3) Added hooks for the r3ds_build() state machine all over the place. * This required adding a few extra XXXXXXReader() routines to generate some * additional control signals, but no big deal. * * 4) Enclosed all the printf()'s with #ifdef's, so they can be compiled out. * However, they can just as easily be compiled in, and their output compared * to that of the original reference code. As far as I've seen, the outputs * from both the modified and unmodified readers are identical. (yes!) * * 5) Formatting: Changed all the C++ //-style comments to slash-star C kind * (cc complains about the former) and ran the code through astyle as the * 4-space indents were getting on my nerves :-) * * 6) Oh, and added the all-important project scale chunk (CHUNK_SCALE). * * The code below has been successfully tested on SGI MIPS, Sun Sparc, * and Intel x86 hardware. (Alpha anyone?) * * Any further potential portability issues should be resolvable in the * uintXX typedefs, I think. BTW, if you're using libtiff, you'll have to get * rid of said declarations, else namespaces will collide. * * Because Jare and company have generously donated their code to the public * domain, so do I, in the hope that it will be useful to others. (Disclaimer: * There is no warranty, I assume no liability, use at your own risk, etc.) * Other than that, enjoy, and happy parsing! * * * --Straker * * * */ /* --------------------------- 3DSRDR.C ------------------------------- .3DS file format exerciser v1.4 by Bezzegh D‚nes, aka. DiVeR e-mail: diver@inf.bme.hu http://www.inf.bme.hu/~diver If you are not interested in materials, then there is not much new for you. :-( Changes since v1.3: - Fixed SmooListReader's bug when group>15. - New data-chunk type: WORD /CHUNK_WRD/ - New Material chunks: CHUNK_REFMAP CHUNK_REFMASK CHUNK_SHININESS CHUNK_SPECULARMAP CHUNK_SPECULARMASK CHUNK_SHSTRENGTH CHUNK_OPACITYMAP CHUNK_OPACITYMASK CHUNK_TRANSP CHUNK_TEXTURE2 CHUNK_TEXTURE2MASK CHUNK_TRFALLOFF CHUNK_SHININESSMAP CHUNK_SHININESSMASK CHUNK_REFLECTBL CHUNK_SELFILLUMMAP CHUNK_SELFILLUMMASK CHUNK_SELFILLUM CHUNK_TEXTUREMASK CHUNK_BLUR CHUNK_SHADETYPE CHUNK_BUMPMASK CHUNK_TROTATION CHUNK_FLAG2SIDE CHUNK_USCALE CHUNK_VSCALE CHUNK_TFLAGS CHUNK_UOFFSET CHUNK_VOFFSET CHUNK_BLACKTINT CHUNK_WHITETINT CHUNK_RTINT CHUNK_GTINT CHUNK_BTINT - New "not so useful" Material chunks: CHUNK_FACEMAP CHUNK_WIREFRAME CHUNK_WIRETHICK CHUNK_SOFTEN CHUNK_FLAGIN CHUNK_FLAGUNIT CHUNK_FLAGADD - New Light chunks: CHUNK_LIGHTR1 CHUNK_LIGHTR2 CHUNK_LIGHTMUL - Added CHUNK_SHP and CHUNK_LFT. Why not? - That's all! Did I leave something from material out? ------------------------------ v1.3 -------------------------------- .3DS file format exerciser v1.3. by Mats Byggmastar, aka. MRI/Doomsday e-mail: mri@penti.sit.fi All credits goes to Jare/Iguana as this is just a modified version of v1.2 he released. You can use the following method to dig up new data: - Make a simple .3ds file and convert it with this reader using -dump mode. - Go back into 3D Studio and add that little feature to the scene and convert the .3ds file again using -dump mode. - Compare the output from both conversions and you'll find the chunk where the data was modified or added. "The Unofficial 3dStudio 3DS File Format v1.0" by Jeff Lewis is also a great help. I found that file at: www.viewpoint.com/avalon/format_specs.html .Mats Byggmastar 15.2.1997 Jakobstad, Finland --------------------------- 3DSRDR.C ------------------------------- .3DS file format exerciser v1.2. Written by Javier Arevalo, AKA Jare/Iguana. I compile this with Watcom/32, but I guess it should work with any compiler and OS combination for which the typedefs are valid i.e. any that I know for PCs... Try it and see. Oh, and also check the #pragma pack() thing. - DISCLAIMER - I hope I have not broken any patents or trade secrets by releasing this info. This is purely a mind exercise to break into a file format that is quite useful to know. As far as I have been told a file format is not subject to anything such as copyright or patent, so I have done this because I believe I'm allowed to. I PLACE THIS FILE IN THE PUBLIC DOMAIN, SO EVERYTHING CONTAINED HERE IS TOTALLY FREE FOR YOU TO EXPLORE AND USE. I DISCLAIM ANY AND ALL EVENTS COMING OUT OF ANY POSSIBLE USE (OR LACK OF USE) OR EXISTANCE OF THIS FILE. I WON'T BE LIABLE FOR ANYTHING RELATED TO THIS FILE, OR ANY PRIOR OR FUTURE VERSION OF IT. All trademarks mentioned are property of their respective holders. - Merits - Heavily based on info on the file 3DS_08.TXT by Jim Pitts (jp5@ukc.ac.uk) Basic material-related stuff digged up by Jare. Track info stuff too. Thanks to the Egerter brothers of WGT fame and to Walken/Impact studios for extra info, Rex Deathstar for support. And definitely to Xanthome/Darkzone for you know why. And of course, respect to Avatar/Legend Design for being here before all of us. For a cool example of actual reading of 3DS files, look no further than 3DSCO20.ZIP by Mats Byggmastar aka. MRI. I personally prefer using a table-driven modification of this code, but both approaches are quite ok and his is much faster to write and follow. Now only lack is someone to explain how to make use of all this stuff i.e. how exactly is data stored, how spline interpolations are performed, what are those things called quaternions, etc. And also, maybe, dig the rest of the chunks until we are actually able to write 3DS files instead of just being bored reading. There's lots to do. If you decide to work on this further, please make your findings public like we have already done, ok? Upload it to x2ftp.oulu.fi, THE place for programming info, and/or to ftp.cdrom.com. But please PUBLISH it! - Change log - V 1.2: - Added change log to have some idea what's going on. - Added pivot point reading inside tracks stuff. - Info about spline flags on keyframes. - Added face edge visibility info. - Finally!! Those flags that mark when the texture is wrapping around inside a face. This happens when you apply spherical or cylindrical coordinates, the faces along the 0§ axis don't get proper mapping coords. Someone describe how to fix this? - Added -quiet parm, only displays minimal chunk info. - Object parent number is stored in CHUNK_TRACKOBJNAME. This makes reference to the node number in CHUNK_OBJNUMBER. - Object number changed to unsigned. Parent 65535 means none. - Added CHUNK_PRJ and CHUNK_MLI to allow inspecting .PRJ and .MLI files (they're basically the same chunks as .3DS). - Added banner to identify myself, and disclaimer for "just in case" possibilities. - Corrected possible bug when chunklen == 0 (it was not a chunk). - Added several name descriptions of chunks. Use diff to find all the new chunks. */ #ifndef PI #define PI 3.14159265358979323846264338327 #endif typedef struct { uint16 id; uint32 len; } TChunkHeader; enum { CHUNK_RGBF = 0x0010, CHUNK_RGBB = 0x0011, /* CHUNK_RBGB2 = 0x0012, ?? NOT HLS */ CHUNK_WRD = 0x0030, CHUNK_PRJ = 0xC23D, CHUNK_MLI = 0x3DAA, CHUNK_SHP = 0x2D2D, CHUNK_LFT = 0x2D3D, CHUNK_MAIN = 0x4D4D, CHUNK_SCALE = 0xC420, CHUNK_OBJMESH = 0x3D3D, CHUNK_BKGCOLOR = 0x1200, CHUNK_AMBCOLOR = 0x2100, CHUNK_OBJBLOCK = 0x4000, CHUNK_TRIMESH = 0x4100, CHUNK_VERTLIST = 0x4110, CHUNK_VERTFLAGS = 0x4111, CHUNK_FACELIST = 0x4120, CHUNK_FACEMAT = 0x4130, CHUNK_MAPLIST = 0x4140, CHUNK_SMOOLIST = 0x4150, CHUNK_TRMATRIX = 0x4160, CHUNK_MESHCOLOR = 0x4165, CHUNK_TXTINFO = 0x4170, CHUNK_LIGHT = 0x4600, CHUNK_LIGHTR1 = 0x4659, CHUNK_LIGHTR2 = 0x465A, CHUNK_LIGHTMUL = 0x465B, CHUNK_SPOTLIGHT = 0x4610, CHUNK_CAMERA = 0x4700, CHUNK_HIERARCHY = 0x4F00, CHUNK_VIEWPORT = 0x7001, CHUNK_MATERIAL = 0xAFFF, CHUNK_MATNAME = 0xA000, CHUNK_AMBIENT = 0xA010, CHUNK_DIFFUSE = 0xA020, CHUNK_SPECULAR = 0xA030, CHUNK_SHININESS = 0xA040, CHUNK_SHSTRENGTH = 0xA041, CHUNK_TRANSP = 0xA050, CHUNK_TRFALLOFF = 0xA052, CHUNK_REFLECTBL = 0xA053, CHUNK_FLAG2SIDE = 0xA081, CHUNK_FLAGADD = 0xA083, CHUNK_SELFILLUM = 0xA084, CHUNK_WIREFRAME = 0xA085, /* Flag */ CHUNK_WIRETHICK = 0xA087, /* Float */ CHUNK_FACEMAP = 0xA088, /* Flag */ CHUNK_FLAGIN = 0xA08A, CHUNK_SOFTEN = 0xA08C, /* Flag */ CHUNK_FLAGUNIT = 0xA08E, /* Very useless */ CHUNK_SHADETYPE = 0xA100, CHUNK_TEXTURE = 0xA200, CHUNK_TEXTUREMASK = 0xA33E, CHUNK_TEXTURE2 = 0xA33A, CHUNK_TEXTUREMASK2 = 0xA340, CHUNK_REFMAP = 0xA220, CHUNK_REFMASK = 0xA34C, CHUNK_OPACITYMAP = 0xA210, CHUNK_OPACITYMASK = 0xA342, CHUNK_SPECULARMAP = 0xA204, CHUNK_SPECULARMASK = 0xA348, CHUNK_SHININESSMAP = 0xA33C, CHUNK_SHININESSMASK= 0xA346, CHUNK_SELFILLUMMAP = 0xA33D, CHUNK_SELFILLUMMASK= 0xA34A, CHUNK_BUMPMAP = 0xA230, CHUNK_BUMPMASK = 0xA344, CHUNK_MAPFILE = 0xA300, CHUNK_TFLAGS = 0xA351, /* Flags */ CHUNK_BLUR = 0xA353, /* Float */ CHUNK_USCALE = 0xA354, /* Float */ CHUNK_VSCALE = 0xA356, /* Float */ CHUNK_UOFFSET = 0xA358, /* Float */ CHUNK_VOFFSET = 0xA35A, /* Float */ CHUNK_TROTATION = 0xA35C, /* Float */ CHUNK_BLACKTINT = 0xA360, /* Float */ CHUNK_WHITETINT = 0xA362, /* Float */ CHUNK_RTINT = 0xA364, /* Float */ CHUNK_GTINT = 0xA366, /* Float */ CHUNK_BTINT = 0xA368, /* Float */ CHUNK_KEYFRAMER = 0xB000, CHUNK_AMBIENTKEY = 0xB001, CHUNK_TRACKINFO = 0xB002, CHUNK_TRACKOBJNAME = 0xB010, CHUNK_TRACKPIVOT = 0xB013, CHUNK_TRACKPOS = 0xB020, CHUNK_TRACKROTATE = 0xB021, CHUNK_TRACKSCALE = 0xB022, CHUNK_TRACKMORPH = 0xB026, CHUNK_TRACKHIDE = 0xB029, CHUNK_OBJNUMBER = 0xB030, CHUNK_TRACKCAMERA = 0xB003, CHUNK_TRACKFOV = 0xB023, CHUNK_TRACKROLL = 0xB024, CHUNK_TRACKCAMTGT = 0xB004, CHUNK_TRACKLIGHT = 0xB005, CHUNK_TRACKLIGTGT = 0xB006, CHUNK_TRACKSPOTL = 0xB007, CHUNK_FRAMES = 0xB008 }; /* ------------------------------------ */ static void SkipReader( FILE *f, int ind, int p ) { /* Do nothing! */ } static void RGBFReader (FILE *f, int ind, int p) { float c[3]; if (!r3ds_read_float( c, 3, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Red: %f, Green: %f, Blue: %f\n", ind, "", c[0], c[1], c[2]); #endif } static void RGBBReader (FILE *f, int ind, int p) { uint8 c[3]; int rgb[3]; int i; if (!r3ds_read_uint8( c, 3, f )) return; for (i = 0; i < 3; i++) rgb[i] = c[i]; r3ds_build( R3DS_COLOR24, rgb ); #ifdef R3DS_ORIG_CODE printf("%*s Red: %d, Green: %d, Blue: %d\n", ind, "", c[0], c[1], c[2]); #endif } static void WRDReader (FILE *f, int ind, int p) { uint16 value; if (!r3ds_read_uint16( &value, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Value: %d\n", ind, "", value); #endif } static void FloatReader (FILE *f, int ind, int p) { float value; if (!r3ds_read_float( &value, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Value: %f\n", ind, "", value); #endif } static void TextFlagReader (FILE *f, int ind, int p) { uint8 flag1, flag2; #ifdef R3DS_ORIG_CODE printf("%*s ", ind, ""); #endif if (!r3ds_read_uint8( &flag1, 1, f )) return; if (!r3ds_read_uint8( &flag2, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("Source:"); if ((flag1 & 0xc0)==0x80) printf("RGB luma tint\n"); else { if ((flag1 & 0xc0)==0xc0) printf("Alpha tint\n"); else { if ((flag2 & 0x02)==0x02) printf("RGB tint\n"); else printf("RGB\n"); } } printf("%*s ", ind, ""); printf("Filtering:"); if (flag1 & 0x40) printf("Summed arial\n"); else printf("Pyramidal\n"); printf("%*s ", ind, ""); printf("Other parameters:"); switch (flag1 & 0x11) { case 0x11: printf("Decal"); break; case 0x00: printf("Tile"); break; case 0x10: case 0x01: printf("Tile & Decal"); } if (flag2 & 1) printf(" - Ignoge map alpha"); if (flag1 & 8) printf(" - Negative"); if (flag1 & 2) printf(" - Mirror"); printf("\n%*s ", ind, ""); printf("%02X ", flag1); printf("%02X ", flag2); printf("\n"); #endif } static void SHTReader (FILE *f, int ind, int p) { uint16 value; if (!r3ds_read_uint16( &value, 1, f )) return; #ifdef R3DS_ORIG_CODE switch (value) { case 1: printf("%*s Flat\n", ind, ""); break; case 2: printf("%*s Gouraud\n", ind, ""); break; case 3: printf("%*s Phong\n", ind, ""); break; case 4: printf("%*s Metal\n", ind, ""); break; } #endif } static char *ASCIIZReader (FILE *f, int ind, int p) { static char inbuf[256]; int c; int i = 0; /* Read ASCIIZ name */ while (((c = fgetc(f)) != EOF) && (c != '\0')) { if (i < 255) inbuf[i++] = c; #ifdef R3DS_ORIG_CODE putchar(c); #endif } #ifdef R3DS_ORIG_CODE printf("\"\n"); #endif inbuf[i] = '\0'; return inbuf; } static void ProjScaleReader( FILE *f, int ind, int p ) { float unit_size; float inches_per_unit; uint16 unknown; if (!r3ds_read_float( &unit_size, 1, f )) return; if (!r3ds_read_float( &inches_per_unit, 1, f )) return; r3ds_build( R3DS_PROJECT_SCALE, &inches_per_unit ); if (!r3ds_read_uint16( &unknown, 1, f )) return; #if 0 printf( "%*sProject scale: 1 unit == %.3f real units (unknown)\n", ind, "", unit_size ); printf( "%*s == %.3f inches\n", ind, "", inches_per_unit ); #endif } static void ObjBlockReader (FILE *f, int ind, int p) { char *name; /* Read ASCIIZ object name */ #ifdef R3DS_ORIG_CODE printf("%*sObject name \"", ind, ""); #endif name = ASCIIZReader(f, ind, p); r3ds_build( R3DS_NEW_OBJECT, name ); /* Read rest of chunks inside this one */ r3ds_ChunkReader(f, ind, p); } static void TriMeshReader( FILE *f, int ind, int p) { r3ds_build( R3DS_DEF_TRIMESH, NULL ); r3ds_ChunkReader( f, ind, p ); } static void VertListReader (FILE *f, int ind, int p) { uint16 nv; float c[3]; int num_verts; if (!r3ds_read_uint16( &nv, 1, f )) return; num_verts = nv; r3ds_build( R3DS_NUM_VERTS, &num_verts ); #ifdef R3DS_ORIG_CODE printf("%*sVertices: %d\n", ind, "", nv); #endif while (nv-- > 0) { if (!r3ds_read_float( c, 3, f )) return; r3ds_build( R3DS_VERT, c ); #ifdef R3DS_ORIG_CODE printf("%*s X: %f, Y: %f, Z: %f\n", ind, "", c[0], c[1], c[2]); #endif } } static void FaceListReader (FILE *f, int ind, int p) { uint16 nv; uint16 c[3]; uint16 flags; int tri_def[4]; int num_tris; int i; if (!r3ds_read_uint16( &nv, 1, f )) return; num_tris = nv; r3ds_build( R3DS_NUM_TRIS, &num_tris ); #ifdef R3DS_ORIG_CODE printf("%*sFaces: %d\n", ind, "", nv); #endif while (nv-- > 0) { if (!r3ds_read_uint16( c, 3, f )) return; if (!r3ds_read_uint16( &flags, 1, f )) return; for (i = 0; i < 3; i++) tri_def[i] = c[i]; tri_def[3] = flags; r3ds_build( R3DS_TRI_FACE, tri_def ); #ifdef R3DS_ORIG_CODE printf("%*s A %d, B %d, C %d, 0x%X:", ind, "", c[0], c[1], c[2], flags); printf(" AB %d BC %d CA %d UWrap %d VWrap %d\n", (flags & 0x04) != 0, (flags & 0x02) != 0, (flags & 0x01) != 0, (flags & 0x08) != 0, (flags & 0x10) != 0); #endif } /* Read rest of chunks inside this one */ r3ds_ChunkReader(f, ind, p); } static void FaceMatReader (FILE *f, int ind, int p) { uint16 n, nf; int tri_num; char *mat_name; /* Read ASCIIZ material name */ #ifdef R3DS_ORIG_CODE printf("%*sMaterial name for faces: \"", ind, ""); #endif mat_name = ASCIIZReader(f, ind, p); r3ds_build( R3DS_TRI_MATERIAL_CURRENT, mat_name ); if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sFaces with this material: %d\n", ind, "", n); #endif while (n-- > 0) { if (!r3ds_read_uint16( &nf, 1, f )) return; tri_num = nf; r3ds_build( R3DS_TRI_MATERIAL, &tri_num ); #ifdef R3DS_ORIG_CODE printf("%*s Face %d\n", ind, "", nf); #endif } } static void MapListReader (FILE *f, int ind, int p) { uint16 nv; float c[2]; if (!r3ds_read_uint16( &nv, 1, f )) return; r3ds_build( R3DS_NUM_VERT_MAPPINGS, &nv ); #ifdef R3DS_ORIG_CODE printf("%*sVertices: %d\n", ind, "", nv); #endif while (nv-- > 0) { if (!r3ds_read_float( c, 2, f )) return; r3ds_build( R3DS_VERT_MAPPING, c ); #ifdef R3DS_ORIG_CODE printf("%*s U: %f, V: %f\n", ind, "", c[0], c[1]); #endif } } static void SmooListReader (FILE *f, int ind, int p) { uint32 s; int i; r3ds_build( R3DS_BEGIN_TRI_SMOOTH, NULL ); while (ftell(f) < p) { if (!r3ds_read_uint32( &s, 1, f )) return; r3ds_build( R3DS_TRI_SMOOTH, &s ); #ifdef R3DS_ORIG_CODE printf("%*sSmoothing groups: ", ind, ""); #endif for (i = 0; i < 32; i++) if (s & ((uint32)1 << i)) { #ifdef R3DS_ORIG_CODE printf("%d, ", i + 1); #endif } #ifdef R3DS_ORIG_CODE printf("\n"); #endif } } static void TrMatrixReader(FILE *f, int ind, int p) { float rot[9]; float trans[3]; if (!r3ds_read_float( rot, 9, f )) return; r3ds_build( R3DS_ROT_MATRIX, rot ); #ifdef R3DS_ORIG_CODE printf("%*sRotation matrix:\n", ind, ""); printf("%*s %f, %f, %f\n", ind, "", rot[0], rot[1], rot[2]); printf("%*s %f, %f, %f\n", ind, "", rot[3], rot[4], rot[5]); printf("%*s %f, %f, %f\n", ind, "", rot[6], rot[7], rot[8]); #endif if (!r3ds_read_float( trans, 3, f )) return; r3ds_build( R3DS_TRANS_MATRIX, trans ); #ifdef R3DS_ORIG_CODE printf("%*sTranslation matrix: %f, %f, %f\n", ind, "", trans[0], trans[1], trans[2]); #endif } static void LightReader(FILE *f, int ind, int p) { float c[3]; if (!r3ds_read_float( c, 3, f )) return; r3ds_build( R3DS_DEF_LIGHT, c ); #ifdef R3DS_ORIG_CODE printf("%*s X: %f, Y: %f, Z: %f\n", ind, "", c[0], c[1], c[2]); #endif /* Read rest of chunks inside this one */ r3ds_ChunkReader(f, ind, p); } static void SpotLightReader(FILE *f, int ind, int p) { float c[5]; if (!r3ds_read_float( c, 5, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Target X: %f, Y: %f, Z: %f; Hotspot %f, Falloff %f\n", ind, "", c[0], c[1], c[2], c[3], c[4]); #endif } static void CameraReader(FILE *f, int ind, int p) { float c[8]; if (!r3ds_read_float( c, 8, f )) return; r3ds_build( R3DS_DEF_CAMERA, c ); #ifdef R3DS_ORIG_CODE printf("%*s Position: X: %f, Y: %f, Z: %f\n", ind, "", c[0], c[1], c[2]); printf("%*s Target: X: %f, Y: %f, Z: %f\n", ind, "", c[3], c[4], c[5]); printf("%*s Bank: %f, Lens: %f\n", ind, "", c[6], c[7]); #endif } static void MatNameReader (FILE *f, int ind, int p) { char *matname; /* Read ASCIIZ object name */ #ifdef R3DS_ORIG_CODE printf("%*sMaterial name \"", ind, ""); #endif matname = ASCIIZReader(f, ind, p); r3ds_build( R3DS_NEW_MATERIAL, matname ); } static void MatAmbColorReader( FILE *f, int ind, int p ) { r3ds_build( R3DS_MAT_AMBIENT_COLOR, NULL ); r3ds_ChunkReader( f, ind, p ); } static void MatDiffColorReader( FILE *f, int ind, int p ) { r3ds_build( R3DS_MAT_DIFFUSE_COLOR, NULL ); r3ds_ChunkReader( f, ind, p ); } static void MatSpecColorReader( FILE *f, int ind, int p ) { r3ds_build( R3DS_MAT_SPECULAR_COLOR, NULL ); r3ds_ChunkReader( f, ind, p ); } static void TwoSidedFlagReader( FILE *f, int ind, int p ) { r3ds_build( R3DS_MAT_2SIDED, NULL ); } static void MapFileReader(FILE *f, int ind, int p) { /* Read ASCIIZ filename */ #ifdef R3DS_ORIG_CODE printf("%*sMap filename \"", ind, ""); #endif ASCIIZReader(f, ind, p); } static void FramesReader(FILE *f, int ind, int p) { uint32 c[2]; if (!r3ds_read_uint32( c, 2, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Start: %d, End: %d\n", ind, "", c[0], c[1]); #endif } static void TrackObjNameReader(FILE *f, int ind, int p) { uint16 w[2]; uint16 parent; /* Read ASCIIZ name */ #ifdef R3DS_ORIG_CODE printf("%*sTrack object name \"", ind, ""); #endif ASCIIZReader(f, ind, p); if (!r3ds_read_uint16( w, 2, f )) return; if (!r3ds_read_uint16( &parent, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sObject name data: Flags 0x%X, 0x%X, Parent %d\n", ind, "", w[0], w[1], parent); #endif } static void PivotPointReader(FILE *f, int ind, int p) { float pos[3]; if (!r3ds_read_float( pos, 3, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Pivot at X: %f, Y: %f, Z: %f\n", ind, "", pos[0], pos[1], pos[2]); #endif } /* Key info flags for position, rotation and scaling: Until I know the meaning of each bit in flags I assume all mean a following float data. */ /* NOTE THIS IS NOT A CHUNK, but A PART OF SEVERAL CHUNKS */ static void SplineFlagsReader(FILE *f, int ind, uint16 flags) { int i; float dat; #ifdef R3DS_ORIG_CODE static const char *flagnames[] = { "Tension", "Continuity", "Bias", "Ease To", "Ease From", }; #endif for (i = 0; i < 16; i++) { if (flags & (1 << i)) { if (!r3ds_read_float( &dat, 1, f )) return; #ifdef R3DS_ORIG_CODE if (i < sizeof(flagnames)/sizeof(*flagnames)) { printf("%*s %-15s = %f\n", ind, "", flagnames[i], dat); } else { printf("%*s %-15s = %f\n", ind, "", "Unknown", dat); } #endif } } } static void TrackPosReader(FILE *f, int ind, int p) { uint16 n, nf; float pos[3]; uint16 unkown; uint16 flags; int i; for(i=0; i<5; i++) { if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown #%d: 0x%x\n", ind, "", i, unkown); #endif } if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sPosition keys: %d\n", ind, "", n); #endif if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown: 0x%x\n", ind, "", unkown); #endif while (n-- > 0) { if (!r3ds_read_uint16( &nf, 1, f )) return; if (!r3ds_read_uint16( &unkown, 1, f )) return; if (!r3ds_read_uint16( &flags, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Frame %3d: Flags 0x%X\n", ind, "", nf, flags); #endif SplineFlagsReader(f, ind, flags); if (!r3ds_read_float( pos, 3, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s X: %f, Y: %f, Z: %f\n", ind, "", pos[0], pos[1], pos[2]); #endif } } static void TrackRotReader(FILE *f, int ind, int p) { uint16 n, nf; float pos[4]; uint16 unkown; uint16 flags; int i; for(i=0; i<5; i++) { if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown #%d: 0x%x\n", ind, "", i, unkown); #endif } if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sRotation keys: %d\n", ind, "", n); #endif if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown: 0x%x\n", ind, "", unkown); #endif while (n-- > 0) { if (!r3ds_read_uint16( &nf, 1, f )) return; if (!r3ds_read_uint16( &unkown, 1, f )) return; if (!r3ds_read_uint16( &flags, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Frame %3d: Flags 0x%X\n", ind, "", nf, flags); #endif SplineFlagsReader(f, ind, flags); if (!r3ds_read_float( pos, 4, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Angle: %f§, X: %f, Y: %f, Z: %f\n", ind, "", pos[0]*180.0/PI, pos[1], pos[2], pos[3]); #endif } } static void TrackScaleReader(FILE *f, int ind, int p) { uint16 n, nf; float pos[3]; uint16 unkown; uint16 flags; int i; for(i=0; i<5; i++) { if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown #%d: 0x%x\n", ind, "", i, unkown); #endif } if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sScale keys: %d\n", ind, "", n); #endif if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown: 0x%x\n", ind, "", unkown); #endif while (n-- > 0) { if (!r3ds_read_uint16( &nf, 1, f )) return; if (!r3ds_read_uint16( &unkown, 1, f )) return; if (!r3ds_read_uint16( &flags, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Frame %3d: Flags 0x%X\n", ind, "", nf, flags); #endif SplineFlagsReader(f, ind, flags); if (!r3ds_read_float( pos, 3, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s X: %f, Y: %f, Z: %f\n", ind, "", pos[0], pos[1], pos[2]); #endif } } static void TrackFovReader(FILE *f, int ind, int p) { uint16 n, nf; float fov; uint16 unkown; uint16 flags; int i; for(i=0; i<5; i++) { if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown #%d: 0x%x\n", ind, "", i, unkown); #endif } if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sFOV keys: %d\n", ind, "", n); #endif if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown: 0x%x\n", ind, "", unkown); #endif while (n-- > 0) { if (!r3ds_read_uint16( &nf, 1, f )) return; if (!r3ds_read_uint16( &unkown, 1, f )) return; if (!r3ds_read_uint16( &flags, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Frame %3d: Flags 0x%X\n", ind, "", nf, flags); #endif SplineFlagsReader(f, ind, flags); if (!r3ds_read_float( &fov, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s FOV: %f\n", ind, "", fov); #endif } } static void TrackRollReader(FILE *f, int ind, int p) { uint16 n, nf; float roll; uint16 unkown; uint16 flags; int i; for(i=0; i<5; i++) { if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown #%d: 0x%x\n", ind, "", i, unkown); #endif } if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sRoll keys: %d\n", ind, "", n); #endif if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown: 0x%x\n", ind, "", unkown); #endif while (n-- > 0) { if (!r3ds_read_uint16( &nf, 1, f )) return; if (!r3ds_read_uint16( &unkown, 1, f )) return; if (!r3ds_read_uint16( &flags, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Frame %3d: Flags 0x%X\n", ind, "", nf, flags); #endif SplineFlagsReader(f, ind, flags); if (!r3ds_read_float( &roll, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Roll: %f\n", ind, "", roll); #endif } } static void TrackMorphReader(FILE *f, int ind, int p) { uint16 n, nf; uint16 unkown; uint16 flags; int i; for(i=0; i<5; i++) { if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown #%d: 0x%x\n", ind, "", i, unkown); #endif } if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sMorph keys: %d\n", ind, "", n); #endif if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown: 0x%x\n", ind, "", unkown); #endif while (n-- > 0) { if (!r3ds_read_uint16( &nf, 1, f )) return; if (!r3ds_read_uint16( &unkown, 1, f )) return; if (!r3ds_read_uint16( &flags, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Frame %3d: Flags 0x%X\n", ind, "", nf, flags); #endif SplineFlagsReader(f, ind, flags); #ifdef R3DS_ORIG_CODE printf("%*s Object name: \"", ind, ""); #endif ASCIIZReader(f, ind, p); } } static void TrackHideReader(FILE *f, int ind, int p) { uint16 n; uint16 frame; uint16 unkown; int i; for(i=0; i<5; i++) { if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown #%d: 0x%x\n", ind, "", i, unkown); #endif } if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sHide keys: %d\n", ind, "", n); #endif if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sUnknown: 0x%x\n", ind, "", unkown); #endif ind += 2; while (n-- > 0) { if (!r3ds_read_uint16( &frame, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sFrame: %d\n", ind, "", (uint32) frame); #endif for(i=0; i<2; i++) { if (!r3ds_read_uint16( &unkown, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*s Unknown #%d: 0x%x\n", ind, "", i, unkown); #endif } } } static void ObjNumberReader(FILE *f, int ind, int p) { uint16 n; if (!r3ds_read_uint16( &n, 1, f )) return; #ifdef R3DS_ORIG_CODE printf("%*sObject number: %d\n", ind, "", n); #endif } /* ------------------------------------ */ struct { uint16 id; const char *name; void (*func)(FILE *f, int ind, int p); } ChunkNames[] = { {CHUNK_RGBF, "RGB float", RGBFReader}, {CHUNK_RGBB, "RGB byte", RGBBReader}, {CHUNK_WRD, "WORD", WRDReader}, {CHUNK_PRJ, "Project", NULL}, {CHUNK_MLI, "Material Library", NULL}, {CHUNK_SHP, "Shape file", NULL}, {CHUNK_LFT, "Loft file", NULL}, {CHUNK_MAIN, "Main", NULL}, {CHUNK_SCALE, "Project scale", ProjScaleReader}, {CHUNK_OBJMESH, "Object Mesh", NULL}, {CHUNK_BKGCOLOR, "Background color", NULL}, {CHUNK_AMBCOLOR, "Ambient color", NULL}, {CHUNK_OBJBLOCK, "Object Block", ObjBlockReader}, {CHUNK_TRIMESH, "Tri-Mesh", TriMeshReader}, {CHUNK_VERTLIST, "Vertex list", VertListReader}, {CHUNK_VERTFLAGS, "Vertex flag list", SkipReader}, {CHUNK_FACELIST, "Face list", FaceListReader}, {CHUNK_MESHCOLOR, "Mesh color", SkipReader}, {CHUNK_FACEMAT, "Face material", FaceMatReader}, {CHUNK_MAPLIST, "Mappings list", MapListReader}, {CHUNK_TXTINFO, "Texture info", SkipReader}, {CHUNK_SMOOLIST, "Smoothings", SmooListReader}, {CHUNK_TRMATRIX, "Matrix", TrMatrixReader}, {CHUNK_LIGHT, "Light", LightReader}, {CHUNK_LIGHTR1, "Light Range radius1", FloatReader}, {CHUNK_LIGHTR2, "Light Range radius2", FloatReader}, {CHUNK_LIGHTMUL, "Light Multyplity", FloatReader}, {CHUNK_SPOTLIGHT, "Spotlight", SpotLightReader}, {CHUNK_CAMERA, "Camera", CameraReader}, {CHUNK_HIERARCHY, "Hierarchy", NULL}, {CHUNK_VIEWPORT, "Viewport info", SkipReader}, {CHUNK_MATERIAL, "Material", NULL}, {CHUNK_MATNAME, "Material name", MatNameReader}, {CHUNK_AMBIENT, "Ambient color", MatAmbColorReader}, {CHUNK_DIFFUSE, "Diffuse color", MatDiffColorReader}, {CHUNK_SPECULAR, "Specular color", MatSpecColorReader}, {CHUNK_SHININESS, "Shininess", NULL}, {CHUNK_SHSTRENGTH, "Shininess strength", NULL}, {CHUNK_TRANSP, "Transparency", NULL}, {CHUNK_TRFALLOFF, "Transparency falloff", NULL}, {CHUNK_REFLECTBL, "Reflection blur", NULL}, {CHUNK_SELFILLUM, "Self Illumination", NULL}, {CHUNK_FLAG2SIDE, "2Side: ON /flag/", TwoSidedFlagReader}, {CHUNK_FLAGADD, "Transparency: Add /flag/", SkipReader}, {CHUNK_WIREFRAME, "WireFrame: ON /flag/", SkipReader}, {CHUNK_WIRETHICK, "WireFrame thickness", FloatReader}, {CHUNK_FLAGIN, "Transparency falloff: In /flag/", SkipReader}, {CHUNK_FLAGUNIT, "WireFrame thickness: Unit /flag/", SkipReader}, {CHUNK_FACEMAP, "Self Illumination: FaceMap /flag/", SkipReader}, {CHUNK_SOFTEN, "Shininess: Soften /flag/", SkipReader}, {CHUNK_SHADETYPE, "Shadeing type", SHTReader}, {CHUNK_TEXTURE, "Texture map", NULL}, {CHUNK_SPECULARMAP, "Specular map", NULL}, {CHUNK_OPACITYMAP, "Opacity map", NULL}, {CHUNK_TEXTURE2, "Texture map 2", NULL}, {CHUNK_SHININESSMAP, "Shininess map", NULL}, {CHUNK_SELFILLUMMAP, "Self Illumination map", NULL}, {CHUNK_REFMAP, "Reflection map", NULL}, {CHUNK_BUMPMAP, "Bump map", NULL}, {CHUNK_TEXTUREMASK, "Texture mask", NULL}, {CHUNK_SPECULARMASK, "Specular mask", NULL}, {CHUNK_OPACITYMASK, "Opacity mask", NULL}, {CHUNK_TEXTUREMASK2, "Texture2 mask", NULL}, {CHUNK_SHININESSMASK,"Shininess mask", NULL}, {CHUNK_SELFILLUMMASK,"Self Illumination mask", NULL}, {CHUNK_REFMASK, "Reflection mask", NULL}, {CHUNK_BUMPMASK, "Bump mask", NULL}, {CHUNK_TFLAGS, "Texture flags", TextFlagReader}, {CHUNK_BLUR, "Texture Blur", FloatReader}, {CHUNK_USCALE, "U scale (1/x)", FloatReader}, {CHUNK_VSCALE, "V scale (1/x)", FloatReader}, {CHUNK_UOFFSET, "U offset", FloatReader}, {CHUNK_VOFFSET, "V offset", FloatReader}, {CHUNK_TROTATION, "Texture Rotation angle", FloatReader}, {CHUNK_BLACKTINT, "Black Tint", RGBBReader}, {CHUNK_WHITETINT, "White Tint", RGBBReader}, {CHUNK_RTINT, "Red Tint", RGBBReader}, {CHUNK_GTINT, "Green Tint", RGBBReader}, {CHUNK_BTINT, "Blue Tint", RGBBReader}, {CHUNK_MAPFILE, "Map filename", MapFileReader}, {CHUNK_KEYFRAMER, "Keyframer data", NULL}, {CHUNK_AMBIENTKEY, "Ambient key", NULL}, {CHUNK_TRACKINFO, "Track info", NULL}, {CHUNK_FRAMES, "Frames", FramesReader}, {CHUNK_TRACKOBJNAME,"Track Obj. Name", TrackObjNameReader}, {CHUNK_TRACKPIVOT, "Pivot point", PivotPointReader}, {CHUNK_TRACKPOS, "Position keys", TrackPosReader}, {CHUNK_TRACKROTATE, "Rotation keys", TrackRotReader}, {CHUNK_TRACKSCALE, "Scale keys", TrackScaleReader}, {CHUNK_TRACKMORPH, "Morph keys", TrackMorphReader}, {CHUNK_TRACKHIDE, "Hide keys", TrackHideReader}, {CHUNK_OBJNUMBER, "Object number", ObjNumberReader}, {CHUNK_TRACKCAMERA, "Camera track", NULL}, {CHUNK_TRACKCAMTGT, "Camera target track", NULL}, {CHUNK_TRACKLIGHT, "Pointlight track", NULL}, {CHUNK_TRACKLIGTGT, "Pointlight target track", NULL}, {CHUNK_TRACKSPOTL, "Spotlight track", NULL}, {CHUNK_TRACKFOV, "FOV track", TrackFovReader}, {CHUNK_TRACKROLL, "Roll track", TrackRollReader}, }; static int FindChunk(uint16 id) { int i; for (i = 0; i < sizeof(ChunkNames)/sizeof(ChunkNames[0]); i++) if (id == ChunkNames[i].id) return i; return -1; } /* ------------------------------------ */ #ifdef R3DS_ORIG_CODE int Verbose = 1; int Quiet = 0; int Dump = 1; #endif void r3ds_ChunkReader(FILE *f, int ind, int p) { TChunkHeader h; int n; #ifdef R3DS_ORIG_CODE int i; uint8 d; #endif int pc; while (ftell(f) < p) { pc = ftell(f); if (!r3ds_read_uint16( &h.id, 1, f )) return; if (!r3ds_read_uint32( &h.len, 1, f )) return; if (h.len == 0) return; n = FindChunk(h.id); if (n < 0) { #ifdef R3DS_ORIG_CODE if (Verbose) { printf("%*sUnknown chunk: 0x%04X, offset 0x%X, size: %d bytes.", ind, "", h.id, pc, h.len); if (!Dump) printf("\n"); } if (Dump) { fseek(f, pc + 6, SEEK_SET); for (i=0; i 2 && strcmp(argv[2], "-quiet") == 0) Quiet = 1; if (argc > 2 && strcmp(argv[2], "-verbose") == 0) Verbose = 1; if (argc > 2 && strcmp(argv[2], "-dump") == 0) { Verbose = 1; Dump = 1; } if (!Quiet) Banner(); /* Find file size */ fseek(f, 0, SEEK_END); p = ftell(f); fseek(f, 0, SEEK_SET); /* Go! */ r3ds_ChunkReader(f, 0, p); return 0; } #endif /* 0 */ /* end read3ds.c */ lightspeed-1.2a/src/readlwo.c0000644000175000017500000002302407176115553011731 /* readlwo.c */ /* * Copyright (C) 1998 Janne Löf * * 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 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * This is a heavily modified version of Janne's LWO reader library, as * included in the GtkGLArea distribution (gtkglarea-1.0/examples/lw.c) */ #include #include #include "readlwo.h" #define MK_ID(a,b,c,d) ((((guint32)(a))<<24)| \ (((guint32)(b))<<16)| \ (((guint32)(c))<< 8)| \ (((guint32)(d)) )) #define ID_FORM MK_ID('F','O','R','M') #define ID_LWOB MK_ID('L','W','O','B') #define ID_PNTS MK_ID('P','N','T','S') #define ID_SRFS MK_ID('S','R','F','S') #define ID_SURF MK_ID('S','U','R','F') #define ID_POLS MK_ID('P','O','L','S') #define ID_COLR MK_ID('C','O','L','R') static gint32 read_char(FILE *f) { gint32 c; c = fgetc(f); g_return_val_if_fail(c != EOF, 0); return c; } static gint32 read_short(FILE *f) { guint8 bytes[2]; bytes[0] = read_char(f); bytes[1] = read_char(f); return (bytes[0] << 8) | bytes[1]; } static gint32 read_long(FILE *f) { guint8 bytes[4]; bytes[0] = read_char(f); bytes[1] = read_char(f); bytes[2] = read_char(f); bytes[3] = read_char(f); return (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; } static float read_float(FILE *f) { gint32 x; x = read_long(f); return *(float *)&x; } static gint read_string(FILE *f, char *str) { gint c; gint cnt = 0; do { c = read_char(f); if (cnt < LW_MAX_NAME_LEN) str[cnt] = c; else str[LW_MAX_NAME_LEN - 1] = 0; cnt++; } while (c != 0); /* if length of string (including \0) is odd skip another byte */ if (cnt % 2) { read_char(f); cnt++; } return cnt; } static void read_srfs(FILE *f, gint nbytes, lwObject *lwo) { int guess_cnt = lwo->material_cnt; while (nbytes > 0) { lwMaterial *material; /* allocate more memory for materials if needed */ if (guess_cnt <= lwo->material_cnt) { guess_cnt += guess_cnt / 2 + 4; lwo->materials = xrealloc(lwo->materials, sizeof(lwMaterial) * guess_cnt); } material = lwo->materials + lwo->material_cnt++; /* read name */ nbytes -= read_string(f, material->name); /* defaults */ material->r = 0.5; material->g = 0.5; material->b = 0.5; } lwo->materials = xrealloc(lwo->materials, sizeof(lwMaterial) * lwo->material_cnt); } static void read_surf(FILE *f, gint nbytes, lwObject *lwo) { int i; char name[LW_MAX_NAME_LEN]; lwMaterial *material = NULL; /* read surface name */ nbytes -= read_string(f, name); /* find material */ for (i = 0; i < lwo->material_cnt; i++) { if (strcmp(lwo->materials[i].name, name) == 0) { material = &lwo->materials[i]; break; } } g_return_if_fail(material != NULL); /* read values */ while (nbytes > 0) { gint id = read_long(f); gint len = read_short(f); nbytes -= 6 + len + (len % 2); switch (id) { case ID_COLR: material->r = read_char(f) / 255.0; material->g = read_char(f) / 255.0; material->b = read_char(f) / 255.0; read_char(f); /* dummy */ break; default: fseek(f, len + (len % 2), SEEK_CUR); } } } static void read_pols(FILE *f, int nbytes, lwObject *lwo) { int guess_cnt = lwo->face_cnt; size_t n; while (nbytes > 0) { lwFace *face; int i; /* allocate more memory for polygons if necessary */ if (guess_cnt <= lwo->face_cnt) { guess_cnt += guess_cnt + 4; lwo->faces = xrealloc(lwo->faces, sizeof(lwFace) * guess_cnt); } face = lwo->faces + lwo->face_cnt++; /* number of points in this face */ face->index_cnt = read_short(f); nbytes -= 2; /* allocate space for points */ n = sizeof(int) * face->index_cnt; face->indices = xmalloc(n); /* read points in */ for (i = 0; i < face->index_cnt; i++) { face->indices[i] = read_short(f); nbytes -= 2; } /* read surface material */ face->mat_id = read_short(f); nbytes -= 2; /* skip over detail polygons */ if (face->mat_id < 0) { int det_cnt; face->mat_id = - face->mat_id; det_cnt = read_short(f); nbytes -= 2; while (det_cnt-- > 0) { int cnt = read_short(f); fseek(f, cnt * 2 + 2, SEEK_CUR); nbytes -= cnt * 2 + 2; } } face->mat_id -= 1; } /* readjust to true size */ lwo->faces = xrealloc(lwo->faces, sizeof(lwFace) * lwo->face_cnt); } static void read_pnts(FILE *f, gint nbytes, lwObject *lwo) { int i; lwo->vertex_cnt = nbytes / 12; lwo->vertices = xmalloc( lwo->vertex_cnt * sizeof(lwPoint) ); for (i = 0; i < lwo->vertex_cnt; i++) { lwo->vertices[i].x = read_float(f); lwo->vertices[i].y = read_float(f); lwo->vertices[i].z = read_float(f); } } gint lw_is_lwobject(const char *lw_file) { FILE *f = fopen(lw_file, "rb"); if (f) { gint32 form = read_long(f); gint32 nlen = read_long(f); gint32 lwob = read_long(f); fclose(f); if ((form == ID_FORM) && (nlen != 0) && (lwob == ID_LWOB)) return TRUE; } return FALSE; } lwObject * lw_object_read(const char *lw_file) { FILE *f = NULL; lwObject *lw_object = NULL; size_t n; gint32 form_bytes = 0; gint32 read_bytes = 0; /* open file */ f = fopen(lw_file, "rb"); if (f == NULL) { /* g_warning("can't open file %s", lw_file); */ return NULL; } /* check for headers */ if (read_long(f) != ID_FORM) { /* g_warning("file %s is not an IFF file", lw_file); */ fclose(f); return NULL; } form_bytes = read_long(f); read_bytes += 4; if (read_long(f) != ID_LWOB) { /* g_warning("file %s is not a LWOB file", lw_file); */ fclose(f); return NULL; } /* create new lwObject */ n = sizeof(lwObject); lw_object = xmalloc(n); memset(lw_object, 0, n); /* read chunks */ while (read_bytes < form_bytes) { gint32 id = read_long(f); gint32 nbytes = read_long(f); read_bytes += 8 + nbytes + (nbytes % 2); switch (id) { case ID_PNTS: read_pnts(f, nbytes, lw_object); break; case ID_POLS: read_pols(f, nbytes, lw_object); break; case ID_SRFS: read_srfs(f, nbytes, lw_object); break; case ID_SURF: read_surf(f, nbytes, lw_object); break; default: fseek(f, nbytes + (nbytes % 2), SEEK_CUR); } } fclose(f); return lw_object; } void lw_object_free(lwObject *lw_object) { g_return_if_fail(lw_object != NULL); if (lw_object->faces != NULL) { int i; for (i = 0; i < lw_object->face_cnt; i++) xfree(lw_object->faces[i].indices); xfree(lw_object->faces); } xfree(lw_object->materials); xfree(lw_object->vertices); xfree(lw_object); } #if 0 /* don't need this next bit */ #define PX(i) (lw_object->vertices[face->indices[i]].x) #define PY(i) (lw_object->vertices[face->indices[i]].y) #define PZ(i) (lw_object->vertices[face->indices[i]].z) void lw_object_show(const lwObject *lw_object) { int i, j; int prev_index_cnt = -1; int prev_material = -1; float prev_nx = 0; float prev_ny = 0; float prev_nz = 0; g_return_if_fail(lw_object != NULL); for (i = 0; i < lw_object->face_cnt; i++) { float ax, ay, az, bx, by, bz, nx, ny, nz, r; const lwFace *face = lw_object->faces + i; /* ignore faces with less than 3 points */ if (face->index_cnt < 3) continue; /* calculate normal */ ax = PX(1) - PX(0); ay = PY(1) - PY(0); az = PZ(1) - PZ(0); bx = PX(face->index_cnt - 1) - PX(0); by = PY(face->index_cnt - 1) - PY(0); bz = PZ(face->index_cnt - 1) - PZ(0); nx = ay * bz - az * by; ny = az * bx - ax * bz; nz = ax * by - ay * bx; r = sqrt(nx * nx + ny * ny + nz * nz); if (r < 0.000001) /* avoid division by zero */ continue; nx /= r; ny /= r; nz /= r; /* glBegin/glEnd */ if (prev_index_cnt != face->index_cnt || prev_index_cnt > 4) { if (prev_index_cnt > 0) glEnd(); prev_index_cnt = face->index_cnt; switch (face->index_cnt) { case 3: glBegin(GL_TRIANGLES); break; case 4: glBegin(GL_QUADS); break; default: glBegin(GL_POLYGON); } } /* update material if necessary */ if (prev_material != face->mat_id) { prev_material = face->mat_id; glColor3f(lw_object->materials[face->mat_id].r, lw_object->materials[face->mat_id].g, lw_object->materials[face->mat_id].b); } /* update normal if necessary */ if (nx != prev_nx || ny != prev_ny || nz != prev_nz) { prev_nx = nx; prev_ny = ny; prev_nz = nz; glNormal3f(nx, ny, nz); } /* draw polygon/triangle/quad */ for (j = 0; j < face->index_cnt; j++) glVertex3f(PX(j), PY(j), PZ(j)); } /* if glBegin was called call glEnd */ if (prev_index_cnt > 0) glEnd(); } float lw_object_radius(const lwObject *lwo) { int i; double max_radius = 0.0; g_return_val_if_fail(lwo != NULL, 0.0); for (i = 0; i < lwo->vertex_cnt; i++) { point *v = &lwo->vertices[i]; double r = (v->x * v->x) + (v->y * v->y) + (v->z * v->z); if (r > max_radius) max_radius = r; } return sqrt(max_radius); } void lw_object_scale(lwObject *lwo, float scale) { int i; g_return_if_fail(lwo != NULL); for (i = 0; i < lwo->vertex_cnt; i++) { lwo->vertices[i].x *= scale; lwo->vertices[i].y *= scale; lwo->vertices[i].z *= scale; } } #endif /* 0 */ /* end readlwo.c */ lightspeed-1.2a/src/snapshot.c0000644000175000017500000002313207176115553012133 /* snapshot.c */ /* Image exporter */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" #ifdef HAVE_LIBPNG #include static int write_png( int message, const void *data ); #endif #ifdef HAVE_LIBTIFF #include static int write_tiff( int message, const void *data ); #endif /* [Other] forward declarations */ static int write_image( int format, int message, const void *data ); int save_snapshot( int width, int height, const char *filename, int format ) { GdkGLContext *context; GdkGLPixmap *glpixmap; GdkVisual *visual; GdkPixmap *pixmap; GLubyte *scanline; float x,y,z; int visual_attributes[] = { GDK_GL_RGBA, GDK_GL_RED_SIZE, 8, GDK_GL_GREEN_SIZE, 8, GDK_GL_BLUE_SIZE, 8, GDK_GL_DEPTH_SIZE, 1, GDK_GL_NONE }; int ogl_y; int err; int percent, prev_percent = -1; char comments[1024]; char one_line[256]; /* Initialize output camera */ memcpy( &out_cam, usr_cams[0], sizeof(camera) ); out_cam.width = width; out_cam.height = height; /* Create off-screen rendering buffer (i.e. pixmap) */ visual = gdk_gl_choose_visual( visual_attributes ); if (visual == NULL) { message_window( STR_DLG_Error, STR_MSG_no_ogl_visual ); return -1; } pixmap = gdk_pixmap_new( NULL, width, height, visual->depth ); if (pixmap == NULL) { sprintf( one_line, STR_MSG_no_render_buf_ARG, width, height ); message_window( STR_DLG_Error, one_line ); return -1; } glpixmap = gdk_gl_pixmap_new( visual, pixmap ); context = gdk_gl_context_new( visual ); err = !gdk_gl_pixmap_make_current( glpixmap, context ); if (err) { message_window( STR_DLG_Error, STR_MSG_no_ogl_context ); gdk_gl_context_unref( context ); gdk_gl_pixmap_unref( glpixmap ); gdk_pixmap_unref( pixmap ); return -1; } /* Basic setup */ ogl_initialize( NULL, NULL ); /* For extra-high quality output */ glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); glHint( GL_POINT_SMOOTH_HINT, GL_NICEST ); glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); /* GL_LINE_SMOOTH looks crummy */ /* glEnable( GL_LINE_SMOOTH ); */ /* Produce image description (comments) */ if (object_mode == MODE_LATTICE) { sprintf( comments, "%dx%dx%d lattice, travelling at %s", lattice_size_x, lattice_size_y, lattice_size_z, velocity_string( velocity, TRUE ) ); } else sprintf( comments, "Object travelling at %s", velocity_string( velocity, TRUE ) ); sprintf( one_line, " in the +x direction.\n\n" ); strcat( comments, one_line ); x = out_cam.pos.x; y = out_cam.pos.y; z = out_cam.pos.z; sprintf( one_line, "Camera position: (%.3f, %.3f, %.3f)\n", x, y, z ); strcat( comments, one_line ); x = out_cam.target.x; y = out_cam.target.y; z = out_cam.target.z; sprintf( one_line, "Camera target..: (%.3f, %.3f, %.3f)\n", x, y, z ); strcat( comments, one_line ); sprintf( one_line, "Camera FOV.....: %.2f degrees", out_cam.fov ); strcat( comments, one_line ); if (width != height) sprintf( one_line, " horizontally\n\n" ); else sprintf( one_line, "\n\n" ); strcat( comments, one_line ); sprintf( one_line, "Observed object is centered at the origin.\n" ); strcat( comments, one_line ); sprintf( one_line, "Coordinate system is right-handed with +z up.\n" ); strcat( comments, one_line ); sprintf( one_line, "Above units are in meters, where unspecified.\n\n" ); strcat( comments, one_line ); sprintf( one_line, "This image was produced by the Light Speed! relativistic simulator.\n" ); strcat( comments, one_line ); /* TODO: Fix description...? it's inaccurate if an animation is ongoing, or * if any of the relativistic transforms are switched off */ /* Initialize output file */ err = FALSE; err = err || write_image( format, IMAGE_WIDTH, &width ); err = err || write_image( format, IMAGE_HEIGHT, &height ); err = err || write_image( format, IMAGE_COMMENTS, comments ); err = err || write_image( format, IMAGE_FILENAME, filename ); if (err) { message_window( STR_DLG_Error, STR_MSG_no_snapshot_output ); return -1; } ogl_blank( 0, STR_MSG_Rendering_snapshot ); gdk_gl_pixmap_make_current( glpixmap, context ); /* switch back */ /* Draw! */ ogl_draw( -1 ); /* Read and export rows of pixels, one by one */ scanline = xmalloc( width * 3 * sizeof(GLubyte) ); glPixelStorei( GL_PACK_ALIGNMENT, 4 ); for (ogl_y = height - 1; ogl_y >= 0; ogl_y--) { glReadPixels( 0, ogl_y, width, 1, GL_RGB, GL_UNSIGNED_BYTE, scanline ); err = write_image( format, IMAGE_PIXELROW, scanline ); if (err) break; percent = (100 * (height - ogl_y)) / height; if (percent != prev_percent) { sprintf( one_line, STR_MSG_Saving_snapshot_ARG, percent ); ogl_blank( 0, one_line ); /* switch back to pixmap GL context */ gdk_gl_pixmap_make_current( glpixmap, context ); prev_percent = percent; } } xfree( scanline ); /* Close up output file */ write_image( format, IMAGE_COMPLETE, NULL ); gdk_gl_context_unref( context ); gdk_gl_pixmap_unref( glpixmap ); gdk_pixmap_unref( pixmap ); return err; } /* Dispatcher for the various file format handlers */ static int write_image( int format, int message, const void *data ) { switch (format) { #ifdef HAVE_LIBPNG case IMAGE_FORMAT_PNG: return write_png( message, data ); #endif #ifdef HAVE_LIBTIFF case IMAGE_FORMAT_TIFF: return write_tiff( message, data ); #endif default: break; } return -1; } /* PNG output */ #ifdef HAVE_LIBPNG static int write_png( int message, const void *data ) { static FILE *png_fp; static png_structp png_write_s; static png_infop png_info_s; static png_text comments[2]; static int width, height; GLubyte *pixelrow; char *filename; char *text; switch (message) { case IMAGE_WIDTH: width = *((int *)data); break; case IMAGE_HEIGHT: height = *((int *)data); break; case IMAGE_COMMENTS: text = (char *)data; comments[0].key = "Title"; comments[0].text = "Light Speed! snapshot"; comments[0].compression = PNG_TEXT_COMPRESSION_NONE; comments[1].key = "Description"; comments[1].text = text; comments[1].compression = PNG_TEXT_COMPRESSION_NONE; break; case IMAGE_FILENAME: filename = (char *)data; png_fp = fopen( filename, "wb" ); if (png_fp == NULL) return -1; png_write_s = png_create_write_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL ); png_info_s = png_create_info_struct( png_write_s ); if (setjmp( png_write_s->jmpbuf )) { /* Error writing file */ png_destroy_write_struct( &png_write_s, &png_info_s ); fclose( png_fp ); return -1; } png_init_io( png_write_s, png_fp ); png_set_IHDR( png_write_s, png_info_s, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT ); /* png_set_gAMA( png_write_s, png_info_s, dgamma ); */ png_set_compression_level( png_write_s, Z_BEST_COMPRESSION ); png_set_text( png_write_s, png_info_s, comments, 2 ); png_write_info( png_write_s, png_info_s ); break; case IMAGE_PIXELROW: pixelrow = (GLubyte *)data; png_write_row( png_write_s, pixelrow ); break; case IMAGE_COMPLETE: png_write_end( png_write_s, NULL ); png_destroy_write_struct( &png_write_s, &png_info_s ); fclose( png_fp ); break; } return 0; } #endif /* HAVE_LIBPNG */ /* TIFF output */ #ifdef HAVE_LIBTIFF static int write_tiff( int message, const void *data ) { static TIFF *tiff; static FILE *tiff_fp; static int width, height; static char *text = NULL; static int img_y = 0; GLubyte *scanline; int rows_per_strip; int rv; char *filename; switch (message) { case IMAGE_WIDTH: width = *((int *)data); break; case IMAGE_HEIGHT: height = *((int *)data); break; case IMAGE_COMMENTS: text = (char *)data; break; case IMAGE_FILENAME: filename = (char *)data; tiff_fp = fopen( filename, "w" ); if (tiff_fp == NULL) return -1; tiff = TIFFFdOpen( fileno( tiff_fp ), "output file", "w" ); if (tiff == NULL) return -1; TIFFSetField( tiff, TIFFTAG_IMAGEWIDTH, width ); TIFFSetField( tiff, TIFFTAG_IMAGELENGTH, height ); TIFFSetField( tiff, TIFFTAG_BITSPERSAMPLE, 8 ); TIFFSetField( tiff, TIFFTAG_COMPRESSION, COMPRESSION_LZW ); TIFFSetField( tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB ); TIFFSetField( tiff, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB ); TIFFSetField( tiff, TIFFTAG_DOCUMENTNAME, "Light Speed! snapshot" ); TIFFSetField( tiff, TIFFTAG_IMAGEDESCRIPTION, text ); TIFFSetField( tiff, TIFFTAG_SAMPLESPERPIXEL, 3 ); rows_per_strip = MAX(1, 8192 / (3 * width)); TIFFSetField( tiff, TIFFTAG_ROWSPERSTRIP, rows_per_strip ); TIFFSetField( tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG ); break; case IMAGE_PIXELROW: scanline = (GLubyte *)data; rv = TIFFWriteScanline( tiff, scanline, img_y++, 0 ); if (rv < 0) return -1; break; case IMAGE_COMPLETE: TIFFFlushData( tiff ); TIFFClose( tiff ); fclose( tiff_fp ); break; } return 0; } #endif /* HAVE_LIBTIFF */ /* end snapshot.c */ lightspeed-1.2a/src/trackmem.c0000644000175000017500000001564407176115553012110 /* trackmem.h */ /* Memory allocation accounting utilities * This is what I used to nail down memory leaks :) */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "trackmem.h" #ifdef TRACKMEM_VERBOSE static int trackmem_verbose = TRUE; #else static int trackmem_verbose = FALSE; #endif #ifdef MALLOC_HOOKS /* Use this if you want to track memory use via malloc() hooks * (you might not want to have TRACKMEM_VERBOSE set... it gets awful spammy) */ void trackmem_init( void ) { fprintf( stderr, "trackmem_init() says hello\n" ); prev_malloc_hook = __malloc_hook; __malloc_hook = trackmem_malloc_hook; prev_realloc_hook = __realloc_hook; __realloc_hook = trackmem_realloc_hook; prev_free_hook = __free_hook; __free_hook = trackmem_free_hook; fprintf( stderr, "malloc() hooks are in place\n" ); fflush( stderr ); } static void * trackmem_malloc_hook( size_t size ) { void *block; __malloc_hook = prev_malloc_hook; __realloc_hook = prev_realloc_hook; __free_hook = prev_free_hook; block = malloc( size ); trackmem( TRACKMEM_MALLOC, block, NULL, size ); __free_hook = trackmem_free_hook; __realloc_hook = trackmem_realloc_hook; __malloc_hook = trackmem_malloc_hook; return block; } static void * trackmem_realloc_hook( void *block, size_t size ) { void *block2; __malloc_hook = prev_malloc_hook; __realloc_hook = prev_realloc_hook; __free_hook = prev_free_hook; block2 = realloc( block, size ); trackmem( TRACKMEM_REALLOC, block, block2, size ); __free_hook = trackmem_free_hook; __realloc_hook = trackmem_realloc_hook; __malloc_hook = trackmem_malloc_hook; return block; } static void trackmem_free_hook( void *block ) { __malloc_hook = prev_malloc_hook; __realloc_hook = prev_realloc_hook; __free_hook = prev_free_hook; trackmem( TRACKMEM_FREE, block, NULL, 0 ); free( block ); __free_hook = trackmem_free_hook; __realloc_hook = trackmem_realloc_hook; __malloc_hook = trackmem_malloc_hook; } void trackmem_stop( void ) { __malloc_hook = prev_malloc_hook; __realloc_hook = prev_realloc_hook; __free_hook = prev_free_hook; trackmem( TRACKMEM_QUIT, NULL, NULL, 0 ); } #endif /* MALLOC_HOOKS */ void trackmem_show_stats( void ) { trackmem( TRACKMEM_SHOW_STATS, NULL, NULL, 0 ); } void trackmem_show_blocks( void ) { trackmem( TRACKMEM_SHOW_BLOCKS, NULL, NULL, 0 ); } void trackmem( int message, void *block, void *block2, size_t size ) { static void **allblocks = NULL; static int *allsizes = NULL; static int num_blocks = 0; static int total_size = 0; int verbose = trackmem_verbose; int block_id; switch (message) { case TRACKMEM_MALLOC: if (verbose) fprintf( stderr, "%p ALLOC: +%d ", block, size ); case TRACKMEM_MALLOC_EQUIV: if (size == 0) fprintf( stderr, "[BUG! Allocating zero-size block]" ); ++num_blocks; allblocks = realloc( allblocks, num_blocks * sizeof(void *) ); allblocks[num_blocks - 1] = block; allsizes = realloc( allsizes, num_blocks * sizeof(int) ); allsizes[num_blocks - 1] = (int)size; total_size += (int)size; if (message == TRACKMEM_MALLOC_EQUIV) return; break; case TRACKMEM_REALLOC: if (verbose) fprintf( stderr, "%p REALLOC: ", block2 ); if (block == NULL) { if (verbose) fprintf( stderr, "+%d (from NULL)", size ); trackmem( TRACKMEM_MALLOC_EQUIV, block2, NULL, size ); } else { block_id = trackmem_search_for_block( block, allblocks, num_blocks ); if (block_id == -1) { fprintf( stderr, "+%d [BUG! Reallocating unknown block]\n", size ); fflush( stderr ); return; } else { if (verbose) fprintf( stderr, "%+d (from %p)", size - allsizes[block_id], block ); allblocks[block_id] = block2; total_size += (size - allsizes[block_id]); allsizes[block_id] = (int)size; } } break; case TRACKMEM_STRDUP: size = strlen( (char *)block ) + 1; if (verbose) fprintf( stderr, "%p STRDUP: +%d", block, size ); trackmem( TRACKMEM_MALLOC_EQUIV, block, NULL, size ); break; case TRACKMEM_FREE: if (verbose) fprintf( stderr, "%p FREE: ", block ); block_id = trackmem_search_for_block( block, allblocks, num_blocks ); if (block == NULL) { fprintf( stderr, "[BUG! Attempting to free null block]\n" ); fflush( stderr ); return; } else if (block_id == -1) { fprintf( stderr, "[BUG! Attempting to free unknown block]\n" ); fflush( stderr ); return; } else { total_size -= allsizes[block_id]; if (verbose) fprintf( stderr, "-%d", allsizes[block_id] ); --num_blocks; if (block_id != num_blocks) { memmove( &allblocks[block_id], &allblocks[block_id + 1], (num_blocks - block_id) * sizeof(void *) ); memmove( &allsizes[block_id], &allsizes[block_id + 1], (num_blocks - block_id) * sizeof(int) ); } allblocks = realloc( allblocks, num_blocks * sizeof(void *) ); allsizes = realloc( allsizes, num_blocks * sizeof(int) ); } break; case TRACKMEM_SHOW_STATS: fprintf( stderr, "Total: %d blocks (%d bytes)\n", num_blocks, total_size ); fflush( stdout ); return; case TRACKMEM_SHOW_BLOCKS: fprintf( stderr, "==== Current TRACKMEM database ====\n" ); for (block_id = 0; block_id < num_blocks; block_id++) fprintf( stderr, " %p: %d bytes\n", allblocks[block_id], allsizes[block_id] ); trackmem( TRACKMEM_SHOW_STATS, NULL, NULL, 0 ); fprintf( stderr, "===================================\n" ); fflush( stdout ); return; case TRACKMEM_QUIT: free( allblocks ); free( allsizes ); num_blocks = 0; total_size = 0; return; } if (verbose) { fprintf( stderr, " " ); trackmem( TRACKMEM_SHOW_STATS, NULL, NULL, 0 ); } } int trackmem_search_for_block( void *block, void **allblocks, int num_blocks ) { int i; for (i = 0; i < num_blocks; i++) if (block == allblocks[i]) return i; return -1; } /* Alternate interface-- use inside malloc()/realloc()/etc. wrappers */ void trackmem_malloc( void *block, size_t size ) { trackmem( TRACKMEM_MALLOC, block, NULL, size ); } void trackmem_realloc( void *block, void *block2, size_t size ) { trackmem( TRACKMEM_REALLOC, block, block2, size ); } void trackmem_strdup( char *string ) { trackmem( TRACKMEM_STRDUP, (void *)string, NULL, 0 ); } void trackmem_free( void *block ) { trackmem( TRACKMEM_FREE, block, NULL, 0 ); } /* end trackmem.h */ lightspeed-1.2a/src/warp.c0000644000175000017500000004531707176115553011256 /* warp.c */ /* Relativistic distortion engine */ /* * ``The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the "Light Speed!" relativistic simulator. * * The Initial Developer of the Original Code is Daniel Richard G. * Portions created by the Initial Developer are Copyright (C) 1999 * Daniel Richard G. All Rights Reserved. * * Contributor(s): ______________________________________.'' */ #include "lightspeed.h" /* Forward declarations */ static void doppler_shift( rgb_color *color, float freq_ratio ); static void doppler_shift_ref( rgb_color *color, float freq_ratio ); /* This is where it all happens! */ int warp( int message, void *data ) { static int do_lorentz_contraction = TRUE; static int do_optical_deformation = TRUE; static int do_headlight_effect = TRUE; static int do_doppler_shift = TRUE; static float percent_contraction = 1.0; static float percent_deformation = 1.0; static float percent_dopplershift = 1.0; static float percent_headlight = 1.0; #if USE_LOOKUP_TABLES static float sqrt01_lut[LUT_RES + 1]; static float normal_interp_lut1[LUT_RES + 1]; static float normal_interp_lut2[LUT_RES + 1]; #endif ogl_object *obj; ogl_point *pnt; point *cam_pos; point vertex; point normal; rgb_color color; rgb_color in_ray; double LC_gamma; double OD_v, OD_v2, OD_v2_min_C2; double DS_v_over_C, DS_gamma; double HE_v_over_C, HE_gamma; double d_vertex_x; double dx,dy,dz; double dyz2, dist2; double t; float cos_alpha_n, cos_alpha_c; float freq_ratio; float inten_ratio; float intensity; float len2, len; float k; int message2 = 0; int o, vn, i; if ((message != WARP_DISTORT) && (message != INITIALIZE)) message2 = *((int *)data); /* several methods use this value */ switch (message) { case WARP_DISTORT: cam_pos = (point *)data; break; case WARP_LORENTZ_CONTRACTION: do_lorentz_contraction = message2; if (do_lorentz_contraction) transition( &percent_contraction, FALSE, TRANS_SIGMOID, 4.0, 1.0, -1 ); else transition( &percent_contraction, FALSE, TRANS_SIGMOID, 4.0, 0.0, -1 ); return 0; case WARP_OPTICAL_DEFORMATION: do_optical_deformation = message2; if (do_optical_deformation) transition( &percent_deformation, FALSE, TRANS_SIGMOID, 4.0, 1.0, -1 ); else transition( &percent_deformation, FALSE, TRANS_SIGMOID, 4.0, 0.0, -1 ); return 0; case WARP_HEADLIGHT_EFFECT: do_headlight_effect = message2; if (do_headlight_effect) transition( &percent_headlight, FALSE, TRANS_SIGMOID, 4.0, 1.0, -1 ); else transition( &percent_headlight, FALSE, TRANS_SIGMOID, 4.0, 0.0, -1 ); return 0; case WARP_DOPPLER_SHIFT: do_doppler_shift = message2; if (do_doppler_shift) transition( &percent_dopplershift, FALSE, TRANS_SIGMOID, 4.0, 1.0, -1 ); else transition( &percent_dopplershift, FALSE, TRANS_SIGMOID, 4.0, 0.0, -1 ); return 0; case QUERY: switch (message2) { case WARP_LORENTZ_CONTRACTION: return do_lorentz_contraction; case WARP_OPTICAL_DEFORMATION: return do_optical_deformation; case WARP_HEADLIGHT_EFFECT: return do_headlight_effect; case WARP_DOPPLER_SHIFT: return do_doppler_shift; } return 0; case INITIALIZE: #if USE_LOOKUP_TABLES /* Initialize look-up tables */ for (i = 0; i <= LUT_RES; i++) { /* Normal interpolation factor tables * Table 1 handles [0, 1] input range */ normal_interp_lut1[i] = DEG(atan( (double)i / LUT_RES )) / 90.0; /* Table 2 handles (1, inf.) (via reciprocal) */ if (i > 0) normal_interp_lut2[i] = DEG(atan( LUT_RES / (double)i )) / 90.0; /* Square root table for [0, 1] range */ sqrt01_lut[i] = sqrt( (double)i / LUT_RES ); } normal_interp_lut2[0] = 1.0; #endif /* USE_LOOKUP_TABLES */ return 0; default: #ifdef DEBUG crash( "warp( ): invalid message" ); #endif return 0; } /* Variables for Lorentz contraction */ LC_gamma = lorentz_factor( velocity * percent_contraction ); /* Variables for optical deformation */ OD_v = MAX(1.0, velocity * percent_deformation); OD_v2 = SQR(OD_v); OD_v2_min_C2 = OD_v2 - C2; /* Simulation time (and x-location) depend on effective velocity * used for optical deformation */ warp_time( NIL, NIL, OD_v, WARP_UPDATE_TIME_T ); vehicle_real_x = OD_v * cur_time_t; /* Variables for Doppler shift */ DS_v_over_C = velocity * percent_dopplershift / C; DS_gamma = lorentz_factor( velocity * percent_dopplershift ); /* Variables for headlight effect */ HE_v_over_C = velocity * percent_headlight / C; HE_gamma = lorentz_factor( velocity * percent_headlight ); for (o = 0; o < num_vehicle_objs; o++) { obj = vehicle_objs[o]; /* "vn" is the counter instead of "v", to avoid * possible confusion with velocity variables */ for (vn = 0; vn < obj->num_vertices; vn++) { /* Load vertex location */ vertex.x = obj->vertices0[vn].x; vertex.y = obj->vertices0[vn].y; vertex.z = obj->vertices0[vn].z; /* Load vertex normal direction */ normal.x = obj->normals0[vn].x; normal.y = obj->normals0[vn].y; normal.z = obj->normals0[vn].z; /* (Re)load base RGB color */ color.r = obj->color0.r; color.g = obj->color0.g; color.b = obj->color0.b; /**** RELATIVISTIC GEOMETRY TRANSFORMS ****/ /* Do x-coordinate work in double precision */ d_vertex_x = vertex.x; /** Lorentz contraction **/ d_vertex_x /= LC_gamma; /* Adjust normal accordingly */ dx = normal.x; dy = normal.y / LC_gamma; dz = normal.z / LC_gamma; /* Renormalize the normal */ len2 = SQR(dx) + SQR(dy) + SQR(dz); #if USE_LOOKUP_TABLES #ifdef DEBUG if (len2 > 1.001) { printf( "ERROR: warp( ): normal length > 1.0 !!!\n" ); fflush( stdout ); len2 = 1.0; } #endif /* DEBUG */ len = sqrt01_lut[(int)(len2 * LUT_RES)]; #else len = sqrt( len2 ); #endif /* not USE_LOOKUP_TABLES */ if (len < 1E-6) len = 1.0; normal.x = dx / len; normal.y = dy / len; normal.z = dz / len; /* Move object to its "real" x-position */ d_vertex_x += vehicle_real_x; /** Optical deformation **/ /* Obtain xyz deltas (camera to vertex) */ dx = d_vertex_x - cam_pos->x; dy = vertex.y - cam_pos->y; dz = vertex.z - cam_pos->z; /* square, add */ dyz2 = SQR(dy) + SQR(dz); /* lump y & z together */ dist2 = SQR(dx) + dyz2; /* Calculate t and adjust vertex accordingly */ t = (dx*OD_v - sqrt( C2*dist2 - dyz2*OD_v2 )) / OD_v2_min_C2; d_vertex_x -= OD_v * t; /* done with double-precision math */ vertex.x = d_vertex_x; /* Note: dx and dist2 do NOT get updated! * alpha_c below is calculated w.r.t. the * vertex's "actual" position */ /* Need two angles for the color transforms: * alpha_n = angle between direction of * travel and vertex normal; * alpha_c = angle between direction of * travel and vertex-to-camera vector */ cos_alpha_n = normal.x; if (dist2 > 1E-6) cos_alpha_c = - dx / sqrt( dist2 ); else cos_alpha_c = 0.0; /**** RELATIVISTIC COLOR/INTENSITY TRANSFORMS ****/ /* Incoming light ray */ /* in_ray.r = 1.0; */ /* in_ray.g = 1.0; */ /* in_ray.b = 1.0; */ /** Doppler frequency shift (incoming light) **/ k = 1.0 + (HE_v_over_C * cos_alpha_n); inten_ratio = SQR(k) * HE_gamma; /* in_ray.r *= inten_ratio; */ /* in_ray.g *= inten_ratio; */ /* in_ray.b *= inten_ratio; */ in_ray.r = inten_ratio; in_ray.g = inten_ratio; in_ray.b = inten_ratio; /** Headlight effect (incoming light) **/ freq_ratio = (1.0 + (DS_v_over_C * cos_alpha_n)) * DS_gamma; doppler_shift( &in_ray, freq_ratio ); /* Illuminative color interaction */ color.r *= SQR(in_ray.r); color.g *= SQR(in_ray.g); color.b *= SQR(in_ray.b); /** Doppler frequency shift (outgoing light) **/ freq_ratio = (1.0 + (DS_v_over_C * cos_alpha_c)) * DS_gamma; doppler_shift_ref( &color, freq_ratio ); /** Headlight effect (outgoing light) **/ k = 1.0 + (HE_v_over_C * cos_alpha_c); inten_ratio = SQR(k) * HE_gamma; color.r *= inten_ratio; color.g *= inten_ratio; color.b *= inten_ratio; /* If intensity exceeds I(1,1,1), * rotate normal toward camera */ intensity = (color.r * RED_STRENGTH) + (color.g * GREEN_STRENGTH) + (color.b * BLUE_STRENGTH); if (intensity > 1.0) { /* Normal interpolation factor, range [0, 1) * 0 == unchanged, 1 == pointing toward camera */ #if USE_LOOKUP_TABLES if (intensity <= 2.0) { i = (int)((intensity - 1.0) * LUT_RES); k = normal_interp_lut1[i]; } else { i = (int)(LUT_RES / (intensity - 1.0)); k = normal_interp_lut2[i]; } #else k = DEG(atan( intensity - 1.0 )) / 90.0; #endif /* not USE_LOOKUP_TABLES */ /* Interpolate between normal vector and * vertex-to-camera vector */ normal.x -= k * (dx + normal.x); normal.y -= k * (dy + normal.y); normal.z -= k * (dz + normal.z); /* Renormalize */ len = sqrt( SQR(normal.x) + SQR(normal.y) + SQR(normal.z) ); if (len < 1E-6) len = 1.0; normal.x /= len; normal.y /= len; normal.z /= len; } /* Done with relativistic transforms */ /* Clamp color components to legal range */ color.r = MIN(1.0, color.r); color.g = MIN(1.0, color.g); color.b = MIN(1.0, color.b); /* Lastly, perform display gamma correction if needed */ if (dgamma_correct) { color.r = dgamma_lut[(int)(color.r * LUT_RES)]; color.g = dgamma_lut[(int)(color.g * LUT_RES)]; color.b = dgamma_lut[(int)(color.b * LUT_RES)]; } pnt = &obj->iarrays[vn]; /* Store processed vertex location */ pnt->x = vertex.x; pnt->y = vertex.y; pnt->z = vertex.z; /* Store processed vertex normal */ pnt->nx = normal.x; pnt->ny = normal.y; pnt->nz = normal.z; /* Store processed vertex color */ pnt->r = color.r; pnt->g = color.g; pnt->b = color.b; } } return 0; } /* This performs the relativistic geometrical transform, but for a single point, * with the camera at the specified location */ void warp_point( point *vertex, point *normal, point *cam_pos ) { double gamma; double d_vertex_x; double dx,dy,dz; double len; double dyz2, dist2; double v, v2, t; gamma = lorentz_factor( velocity ); /* Perform calculations in double precision */ d_vertex_x = vertex->x; /** Lorentz contraction **/ d_vertex_x /= gamma; /* Adjust normal, if we have a normal to adjust */ if (normal != NULL) { dx = normal->x; dy = normal->y / gamma; dz = normal->z / gamma; /* Renormalize */ len = sqrt( SQR(dx) + SQR(dy) + SQR(dz) ); if (len < 1E-6) len = 1.0; normal->x = dx / len; normal->y = dy / len; normal->z = dz / len; } /* Move object to its "real" x-position */ d_vertex_x += velocity * cur_time_t; dx = d_vertex_x - cam_pos->x; dy = vertex->y - cam_pos->y; dz = vertex->z - cam_pos->z; dyz2 = SQR(dy) + SQR(dz); dist2 = SQR(dx) + SQR(dy) + SQR(dz); v = velocity; v2 = SQR(velocity); /* Calculate t and adjust vertex accordingly */ t = (dx*v - sqrt( C2*dist2 - dyz2*v2 )) / (v2 - C2); d_vertex_x -= velocity * t; vertex->x = d_vertex_x; } /* Doppler frequency shift color transform * My deepest appreciation to Antony Searle for letting me use his code :-) */ static void doppler_shift( rgb_color *color, float freq_ratio ) { float r0,g0,b0; float k; r0 = color->r; g0 = color->g; b0 = color->b; /* Convert frequency ratio into wavelength ratio */ k = 1.0 / freq_ratio; /* Calculate red component */ if (LAMBDA_RED < (k * LAMBDA_UV)) color->r = LAMBDA_RED * ((0.5 * b0) + (0.25 * g0) + (0.125 * r0))/ (k * LAMBDA_UV); else if (LAMBDA_RED < (k * LAMBDA_BLUE)) color->r = ((0.5 * b0) + (0.25 * g0) + (0.125 * r0)) + ((LAMBDA_RED - (k * LAMBDA_UV)) / ((k * LAMBDA_BLUE) - (k * LAMBDA_UV))) * ((0.5 * b0) - (0.25 * g0) - (0.125 * r0)); else if (LAMBDA_RED < (k * LAMBDA_GREEN)) color->r = b0 + ((LAMBDA_RED - (k * LAMBDA_BLUE)) / ((k * LAMBDA_GREEN) - (k * LAMBDA_BLUE))) * (- b0 + g0); else if (LAMBDA_RED < (k * LAMBDA_RED)) color->r = g0 + ((LAMBDA_RED - (k * LAMBDA_GREEN)) / ((k * LAMBDA_RED) - (k * LAMBDA_GREEN))) * (- g0 + r0); else if (LAMBDA_RED < (k * LAMBDA_IR)) color->r = r0 + ((LAMBDA_RED - (k * LAMBDA_RED)) / ((k * LAMBDA_IR) - (k * LAMBDA_RED))) * ((0.125 * b0) + (0.25 * g0) - (0.5 * r0)); else color->r = ((0.125 * b0) + (0.25 * g0) + (0.5 * r0)) * ((k * LAMBDA_IR) / LAMBDA_RED); /* Calculate green component */ if (LAMBDA_GREEN < (k * LAMBDA_UV)) color->g = LAMBDA_GREEN * ((0.5 * b0) + (0.25 * g0) + (0.125 * r0))/ (k * LAMBDA_UV); else if (LAMBDA_GREEN < (k * LAMBDA_BLUE)) color->g = ((0.5 * b0) + (0.25 * g0) + (0.125 * r0)) + ((LAMBDA_GREEN - (k * LAMBDA_UV)) / ((k * LAMBDA_BLUE) - (k * LAMBDA_UV))) * ((0.5 * b0) - (0.25 * g0) - (0.125 * r0)); else if (LAMBDA_GREEN < (k * LAMBDA_GREEN)) color->g = b0 + ((LAMBDA_GREEN - (k * LAMBDA_BLUE)) / ((k * LAMBDA_GREEN) - (k * LAMBDA_BLUE))) * (- b0 + g0); else if (LAMBDA_GREEN < (k * LAMBDA_RED)) color->g = g0 + ((LAMBDA_GREEN - (k * LAMBDA_GREEN)) / ((k * LAMBDA_RED) - (k * LAMBDA_GREEN))) * (- g0 + r0); else if (LAMBDA_GREEN < (k * LAMBDA_IR)) color->g = r0 + ((LAMBDA_GREEN - (k * LAMBDA_RED)) / ((k * LAMBDA_IR) - (k * LAMBDA_RED))) * ((0.125 * b0) + (0.25 * g0) - (0.5 * r0)); else color->g = ((0.125 * b0) + (0.25 * g0) + (0.5 * r0)) * ((k * LAMBDA_IR) / LAMBDA_GREEN); /* Calculate blue component */ if (LAMBDA_BLUE < (k * LAMBDA_UV)) color->b = LAMBDA_BLUE * ((0.5 * b0) + (0.25 * g0) + (0.125 * r0))/ (k * LAMBDA_UV); else if (LAMBDA_BLUE < (k * LAMBDA_BLUE)) color->b = ((0.5 * b0) + (0.25 * g0) + (0.125 * r0)) + ((LAMBDA_BLUE - (k * LAMBDA_UV)) / ((k * LAMBDA_BLUE) - (k * LAMBDA_UV))) * ((0.5 * b0) - (0.25 * g0) - (0.125 * r0)); else if (LAMBDA_BLUE < (k * LAMBDA_GREEN)) color->b = b0 + ((LAMBDA_BLUE - (k * LAMBDA_BLUE)) / ((k * LAMBDA_GREEN) - (k * LAMBDA_BLUE))) * (- b0 + g0); else if (LAMBDA_BLUE < (k * LAMBDA_RED)) color->b = g0 + ((LAMBDA_BLUE - (k * LAMBDA_GREEN)) / ((k * LAMBDA_RED) - (k * LAMBDA_GREEN))) * (- g0 + r0); else if (LAMBDA_BLUE < (k * LAMBDA_IR)) color->b = r0 + ((LAMBDA_BLUE - (k * LAMBDA_RED)) / ((k * LAMBDA_IR) - (k * LAMBDA_RED))) * ((0.125 * b0) + (0.25 * g0) - (0.5 * r0)); else color->b = ((0.125 * b0) + (0.25 * g0) + (0.5 * r0)) * ((k * LAMBDA_IR) / LAMBDA_BLUE); } /* Doppler frequency shift, for reflected light rays * Again, this is straight from BACKLIGHT */ static void doppler_shift_ref( rgb_color *color, float freq_ratio ) { float r0,g0,b0; float k; r0 = color->r; g0 = color->g; b0 = color->b; /* Convert frequency ratio into wavelength ratio */ k = 1.0 / freq_ratio; /* Calculate red component */ if (LAMBDA_RED < (k * LAMBDA_BLUE)) color->r = b0; else if (LAMBDA_RED < (k * LAMBDA_GREEN)) color->r = b0 + ((LAMBDA_RED - (k * LAMBDA_BLUE)) / ((k * LAMBDA_GREEN) - (k * LAMBDA_BLUE))) * (- b0 + g0); else if (LAMBDA_RED < (k * LAMBDA_RED)) color->r = g0 + ((LAMBDA_RED - (k * LAMBDA_GREEN)) / ((k * LAMBDA_RED) - (k * LAMBDA_GREEN))) * (- g0 + r0); else color->r = r0; /* Calculate green component */ if (LAMBDA_GREEN < (k * LAMBDA_BLUE)) color->g = b0; else if (LAMBDA_GREEN < (k * LAMBDA_GREEN)) color->g = b0 + ((LAMBDA_GREEN - (k * LAMBDA_BLUE)) / ((k * LAMBDA_GREEN) - (k * LAMBDA_BLUE))) * (- b0 + g0); else if (LAMBDA_GREEN < (k * LAMBDA_RED)) color->g = g0 + ((LAMBDA_GREEN - (k * LAMBDA_GREEN)) / ((k * LAMBDA_RED) - (k * LAMBDA_GREEN))) * (- g0 + r0); else color->g = r0; /* Calculate blue component */ if (LAMBDA_BLUE < (k * LAMBDA_BLUE)) color->b = b0; else if (LAMBDA_BLUE < (k * LAMBDA_GREEN)) color->b = b0 + ((LAMBDA_BLUE - (k * LAMBDA_BLUE)) / ((k * LAMBDA_GREEN) - (k * LAMBDA_BLUE))) * (- b0 + g0); else if (LAMBDA_BLUE < (k * LAMBDA_RED)) color->b = g0 + ((LAMBDA_BLUE - (k * LAMBDA_GREEN)) / ((k * LAMBDA_RED) - (k * LAMBDA_GREEN))) * (- g0 + r0); else color->b = r0; } /* This next function takes care of determining simulation time (cur_time_t). * If the vehicle is not being animated, warp_time( ) sets time t to keep the * image centered on the origin. If animation is active, time t is returned as * a percent between starting times t0 and t1, the times when the image appears * at the starting and ending x-positions x0 and x1, respectively (note that * while x0 and x1 stay constant, t0 and t1 will vary with camera position) */ void warp_time( float x0, float x1, double value, int message ) { static float anim_x0 = 0.0; static float anim_x1 = 0.0; static float anim_percent = 0.0; camera *cam; double dx,dy,dz; double anim_t0; double anim_t1; double v, t; float loop_time = 0.0; /* Preliminary */ if (message == WARP_BEGIN_ANIM) { anim_x0 = x0; anim_x1 = x1; /* Make SURE these two are not still in transition queue * (i.e. if user hits Begin suddenly after Stop) */ break_transition( &anim_x0 ); break_transition( &anim_x1 ); loop_time = value; v = velocity; } else v = value; /* effective velocity for calculations */ /* BUG (sort of): Actual velocity (not effective velocity) is used when * beginning an animation. This means that if the user begins an animation * while optical deformation is disabled, the object will leap back a small * distance before moving forward */ /* Everything is done w.r.t. the primary camera */ cam = usr_cams[0]; /* Recalculate starting time t (image at x=x0) */ dx = cam->pos.x - anim_x0; dy = cam->pos.y; dz = cam->pos.z; t = anim_x0 / v; anim_t0 = t + sqrt( SQR(dx) + SQR(dy) + SQR(dz) ) / C; /* Recalculate ending time t (image at x=x1) */ dx = cam->pos.x - anim_x1; t = anim_x1 / v; anim_t1 = t + sqrt( SQR(dx) + SQR(dy) + SQR(dz) ) / C; switch (message) { case WARP_UPDATE_TIME_T: break; case WARP_BEGIN_ANIM: /* Set anim_percent so object doesn't initially JUMP to x0 */ anim_percent = (cur_time_t - anim_t0) / (anim_t1 - anim_t0); animate( &anim_percent, FALSE, TRANS_LINEAR, loop_time, 0.0, 1.0, -1 ); return; case WARP_STOP_ANIM: /* Move image back to origin */ transition( &anim_x0, FALSE, TRANS_SIGMOID, 2.0, 0.0, -1 ); transition( &anim_x1, FALSE, TRANS_SIGMOID, 2.0, 0.0, -1 ); /* Get anim_percent out of the transition queue */ transition( &anim_percent, FALSE, TRANS_LINEAR, 0.0, anim_percent, -1 ); return; default: #ifdef DEBUG crash( "warp_time( ): invalid message" ); #endif return; } /* Update current time t */ cur_time_t = anim_t0 + anim_percent * (anim_t1 - anim_t0); } /* The Lorentz factor, a.k.a. the gamma factor * Dependent on velocity, with range [1, infinity) */ double lorentz_factor( double v ) { return 1 / sqrt( 1 - SQR(v) / C2 ); } /* end warp.c */ lightspeed-1.2a/src/icon.xpm0000644000175000017500000001143607176115553011612 /* XPM */ static char * lightspeed_icon_xpm[] = { "64 64 32 1", " c None", ". c #020204", "+ c #474B58", "@ c #262627", "# c #2C2C2D", "$ c #101624", "% c #707070", "& c #606062", "* c #021965", "= c #22377B", "- c #2D3C6D", "; c #0F297D", "> c #505051", ", c #3C3C3D", "' c #1A2E70", ") c #0B2064", "! c #0F1012", "~ c #808080", "{ c #181818", "] c #485478", "^ c #32343A", "/ c #434448", "( c #1F2023", "_ c #787878", ": c #68686A", "< c #354370", "[ c #57585D", "} c #02103D", "| c #868685", "1 c #0C1A47", "2 c #022080", "3 c #202C51", "................................................................", "................................................................", "................................................................", "...........................}2*..................................", "..........................(<;;[/,^@(!!...}**....................", "..................*}..(^>::&''&%_~~~~~_%[;;2^#({!..........}}...", ".................*22)&%:[,{}=1...!{(#,+:&&<2_|||~~_%&[+,^(*22*..", "..............{^>:=2:_%%[/,#%,...}**}^[&[,;*$(#,/>&%~~|||:;<;2..", "....}.....!#>:%%%&'2->&%__~~~~_%[)222+[^.{%{..........!(#^+>'*..", "..*22*}#+:___%>^!.)=}....{(^::&%&[]2=~~_%:_>^@{!......}**3>-*...", ".}2222':__:/(.....^|{.......:+/&::+2;[:_~~|||||~~%&>/(2222-~{...", ".}222]%::&,#{!....(|@.}}..!^&:::/();}...!/_,+[%~~||||;;-;2'~....", "..*22-:%%%_%%%:>/##~-*22*3::::,{..:~.....,_.....!(#,>3>[=2'&....", "..}*2*}!(^+&%%_____&*2222):&&/....:~.....+%.........{>[+22:/....", "....[:{......{#/[:%[2222'_%&:[(!..:_.....>&........{>[[=)#|#....", "....[|^...........![*222=~~~~~~_%&%%@!...[[....}}}$>[>%|@/~!....", "....,|>............[<2222^/[%_~~~|~~~__:>:[{..}*22*)>(_~![_.....", "....(~%............+_}*;1...^&@,>:_~~|||||~~_<*2222*1!~_._[.....", "....._~!...........,~.:|,...221...::^/&%_~|||'222222}@|&!~,.....", ".....&|@...........#~!&|/.!/[2%_:>%%....!%>[%*222222*,|/@|(.....", "...../|/...........{~(>|>#:&^'!(^>__~%>,*-)..}222222}>|#,~!.....", ".....(|&...........!~#/|%:^.#%....::(,[&';;[,3*2222*.:~{[%......", ".....!~_...........!:3+|:!..@%....::...#:-)[%~[)**3$.__.%>......", "......:~{..........*22+~:...{_....:[..,:/[!..!#_~%||_~:*';......", "....../|^.........#:=;%~%/@!{_....:[.+:@(~....!_|+!(>~]''2}.....", "......#~>.......(&_[))#~_%~_%%#!..%[>:(.#_....(~~,..,~/[+2......", "......!~:.....!>_:@./%!~_!{^[_~~:*;;'{..^:....#~~#..[~>&/.......", ".......%~!...,%_,...^_._~{..!_(,+';2+>^{,&....,~~{..:~&:>.......", ".......>~(.#:_[{....@~!%~{..!_!.#%+2]~|~_:^{..+~_!.._%&_#.......", ".......3:;3_%#......{~{&~@...&$,%[<3..(,%~||_[&~%..{~:[~{.......", "......}222;^!.......!~([~#..);]%>._+....>+(/:~%~%&)2<'<_........", "......}22;_:+(......._#+~^.(::%&_:_>....[,...!%~:~)222=&........", ".......*22/:__%+(....:,/~,^%%%/.!#___[^!]^...!_~,!)[-2-/........", "........1[#.{/:__%>@.[/^~:%%%^...._/{,:'22@..{_~#./:-):#........", "........{~+....(/%_~%:>3~+-%#....._/...++;_~&>~_{(::+(~!........", ".........%:.......(+%~-2222(......_^..^:$..{,&~_>[:%/^%.........", ".........[_!........}-)222<[#!...._^.(%(...../~%&::~-=<.........", ".........,~(........^]*222&~~_[^!._^{:,......>~&&:&_';2}........", ".........(_,......./_^}}*)+___~~~&%,&>.......&~:%>[_^:2.........", ".........._[.....![%(...&%!#[___~||~%,!......:_::{:&[/..........", "..........&%....!::{....[_!..!^&_<:~||~&^!..!%_:+!_::{..........", "..........,_!..(%&!.....>_{.....!=;'__~||~:1)%_'!{_:>...........", "..........(_#.^_[......./_(.....@_-1,%~__~~)22;2}#_:(...........", "..........!_+^~/........,_@....{%>....{/_~[22222*/_[............", "..........}+=)#.........#_#...!:&........(,*2222*[:#............", "..........*22<^.........(_^...&%!..........}*22**=-}............", "..........}22:~%,!......{_,..>_@............,<1}2;2*............", "...........}}.#&~_>{....!%/.,_,.............&_@.>&2}............", "................([_~&@...%>#_>..............%%{!%+}.............", "..................{+_~:^!:&[:..............!%%!/%{..............", "....................!,_~']+)!..............{%:!%[...............", ".......................#222;(..............@%[/_(...............", "........................*22]~:#............^%>%&................", "........................}**([~|%,!.........,%:_#................", ".............................{>~|~>{.......+%%%.................", "...............................!,_|~&@.....[%%,.................", "..................................^%||%^...::%!.................", "....................................#:||_^):&^..................", "......................................([~<2]+*..................", "........................................!)2222..................", ".........................................}222*..................", "..........................................*2*}..................", "................................................................", "................................................................"}; lightspeed-1.2a/src/title.xpm0000644000175000017500000004454007176115553012005 /* XPM */ static char * lightspeed_title_xpm[] = { "300 60 32 1", " c None", ". c #020204", "+ c #024287", "@ c #022245", "# c #0262C6", "$ c #021225", "% c #0252A6", "& c #023265", "* c #0274E8", "= c #020A15", "- c #024A95", "; c #022A55", "> c #026AD4", ", c #021A35", "' c #025AB7", ") c #023A76", "! c #027AF4", "~ c #02060D", "{ c #02468E", "] c #02264D", "^ c #0266CC", "/ c #02162D", "( c #0256AE", "_ c #02366D", ": c #020E1D", "< c #024E9D", "[ c #022E5E", "} c #026EDC", "| c #021E3D", "1 c #025EBC", "2 c #023E7D", "3 c #027EFC", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "...............................~....................~~..........~~~~~~~~~~~~~~~~~.........~~..............~~~........~~~~~~~~~~~~~~............................~~~~~~~~~~...............~~~~~~~~~~~~~...........~~~~~~~~~~~~~.........~~~~~~~~~~~~~........~~~~~~~~~~~~~~~~.................................", "..........................~~======~~~...........~~======~~~~~~======================~~~=======~~~.....~~=======~~~===================~~...................~~~==============~~.......~~=================~~~~~~~==================~~~==================~~~=====================~~~....~~======~~..............", "........................~~=:$$$$$$::=~~.......~=::$$$$$$$:::::$$$///////////////$$$$::$$$$$$$$::=~~~~==:$$$/$$$$$$$$$$/////////////$$:==~...............~==:$$$//////////$$:==~~.~~=::$$/////////////$$:::==::$$$////////////$$$$$$$$$////////////$$$$$$$$$$///////////////$$::=~~~==:$$$$$$:=~~............", ".......................~=:$/,|||||,/$:~~.....~=:/,||||||,,//,,|||@@@@@@@@@@@@@@@@||,,,,,||||||,/$:==::/,,||@|||,,,,|||@@@@@@@@@@@@||,,$:=~............~~=:$/,||@@@@@@@@@||,,$:==~==:/,,|@@@@@@@@@@@@@||,//$//,,||@@@@@@@@@@@@|||,,,|||@@@@@@@@@@@@|||,,,,|||@@@@@@@@@@@@@@@||,/$:::$$/,||||,/$:=~...........", "......................~=:/|@;;[[[;]@,$:~~..~~:$,|];[[[[;;]]]]];[[[[&&&&&&&&&&&&[[[;;;;;;;[[[[;]@,/$$/,|];[[[[[;;;;;;[[[[&&&&&&&&&[[[;]|/:=~..........~=:$,|@;;[[[&&&&&&[[[;]|/$:::$,|];[[[&&&&&&&&&[[[;]]@@@@];[[[[&&&&&&&&[[[[;;;;;[[[[&&&&&&&&[[[[;;;;;;[[[[&&&&&&&&&&&[[[;]@|,//,|@;;[[;;@|/:=~..........", ".....................~=:/|;[_))))_&;@,$=~.~~=$,@;&_)))))__&&&_))22222222222222222))_____)))))_&;]|,,|];&_))2)))____))22222222222222)_&]|/:~.........~=:/|@;&_))2222222222)_&;@,/$/|@;&_)2222222222222))_&[[[[&_))222222222222)))___)))2222222222222))____))2222222222222222)_&[;@@@];&_))))_[]|/:~..........", ".....................~:/@;_)+{--{+2_[@/:=~~=$,][_2+{--{{{+++++{{------------------{{++{{{---{+2_[;]];[_2+{---{{{++{{{--------------{+)&]|$=~.......~=:/|]&)2+{-----------{+)&;@|,|][_2+{-------------{{+22))2++{--------------{{{+{{{--------------{{{++{{{----------------{{+)_&[[&)2+{{{{+)&],$=~.........", "....................~=$|;&2%##^^##1{&],$===:/@[){1##^^^#1<--<(1^^^^^^^^^^^^^^^^^^^#'<<<1#^^^##1+_&[[&)+'##^^^^#%<<%#^^^^^^^^^^^^^^^##()[@/:~......~=:/|;&)+-(1^^^^^^^^^^^##()&;@@][)+'##^^^^^^^^^^^^^^#'-{{{-(##^^^^^^^^^^^^^^^'<<<#^^^^^^^^^^^^^^^^#%<<(#^^^^^^^^^^^^^^^^^^#1{+2))2+%##^###%);|/=~.........", "....................=:,]&2-*333333*{_;|$:=:/|;_+'3333333>(%(}33333333333333333333331(('3333333*{2)__2+%!333333*(((}33333333333333333312&@/:~......~:/|;&2->333333333333333312_[;;&)+(3333333333333333333*'%%%*33333333333333333#((#33333333333333333*(((*333333333333333333333><-{{-<*3333331)[@/:~.........", "...................~:/|;)+13333333#+_;|$::$,]&2-*33333331''}3333333333333333333333*'''>33333331-+2)2+-^3333333^'''333333333333333333!<2&@/:~.....~=$,]&2<*3333333333333333!<+_&[&_2{}33333333333333333333}((#33333333333333333!'''*33333333333333333^''13333333333333333333333*%%<<%13333333-2[@/:~.........", "...................=:,]&2-*3333333<+&],$::/|;_+(3333333}''^33333333333333333333333^1'1!333333*<-+22+-%!333333!1''>333333333333333333>{)[@/=~.....~:/@[){*33333333333333333^-2_&&_2{%333333333333333333333>''*33333333333333333>11#33333333333333333!111*3333333333333333333333*'((((*333333^{)[|$=~.........", "..................~=/|[){'3333333>-2[@/$::/@[2-}3333333^11*3333333333333333333333!111>3333333^<-+++{<13333333>''1!333333333333333333%+_;,$=~....~=$|;_+1333333333333333333%{)_&&_+-^33333333333333333333!11#333333333333333333111*33333333333333333}11#33333333333333333333333>''''13333333(+_;|$=..........", "..................~:,]&2-}3333333({);|/::$,]_+(3333333*11#33333333333333333333333>111*333333!(<{++{-%*333333!1''>333333333333333333}{)[@/:~.....~:/@[2-*33333333333333333}{2_&[&)+%!33333333333333333333}11}33333333333333333}11#333333333333333333#11}33333333333333333333333111'1}333333}-2&@/:~..........", ".................~=$|;){(3333333*-2&],$::$|;_{^3333333^11>3333333333333333333333!111^3333333}%<{++{-'!333333}(((*333333333333333333(2_]|$=~.....~:,]_+%!33333333333333333(+)&[[&){#333333333333333333333#1#!3333333333333333!#11>33333333333333333*111!3333333333333333333333*11111!333333'{)[|/=~..........", ".................~:/]&2->3333333'{)[@/:::/@[){%('1111111111111111111111111111111''''111111''(%<-{{-<%('''''(%%<%%(''111111''((%%<-{2_;|/:~......=$,;_+'33333333}#11''(%<-+)&;;[&2{%('111111111#*3333333*111111111111111111111111111111111111111111111111111'''''''1^!33333333#1111>333333*-+&],:=...........", "................~=$|;_+%3333333*-+_],$::$,]&2-%''111111111111111111111111111111'''''111111''(%<---<%('''''(%<---<%(''1111''(%<--+2)&;@/:=~......=$|;){#3333333!#111'((<-+)&;]][_+-%('1111111111*3333333^11111111111111111111111111111111111111111111111111''((((((''}3333333*11111!3333331{)[@/:~...........", "................~:/@&2-^3333333#{)[@/$::/|[){<(''111111111111111111111111111111'''''1111111''(%<<<%((''''(%<{++{-<(''111''(%<{+2_&[]|/$=~.......=$|;){#3333333*111''(%-+)&;]];[)+<(''111111111#3333333*11111111111111111111111111111111111111111111111111''((%%%%(''*3333333^1111^333333*<+_],$=............", "................=$,]_+<*333333!%+_;|$::$,]&2-%('1111111111111111111111111111111'''''1111111'''((%%(('''''(%-+222{<%''111''(<-+_&;]@,/:=~........=$|;_{#33333333^11''(<{2_[]@];_2-<('1111111111}3333333^11111111111111111111111111111111111111111111111111''(%<<<<%('3333333!11111*333333^-2&@/:~............", "...............~:/@[){#3333333^-2&@,$:$,@[){('1#####111########1111###########11''############11111#####11<{2))2{-%1#####1'-+_[]|,/$:=~.........~:,]_+(333333333*^1'%<{2&;]];&){%'1#######^#^}3333333!11#^^#^^#^^#^^#######111##################111#######1(<---<%(>3333333>1111^3333333%+_;|$=~............", "...............=$,]&+-*3333333%{_;|/$$/|;_+(3333333*11^3333333*1111!3333333333^111!3333333333333333333333!<{2))2{<13333333^{)&]|/$:=~~..........~:/@&2'<{2_[;;&_+11*33333333333333333>11#33333333333333333!111*33333331<-{-<%(!333333!#1111*333333>-2&]/:~.............", "..............~=/|[){'3333333}-2&],$$$,]&2-}3333333^11*3333333#111>3333333333!111>33333333333333333333333^-+2))2{<*3333333%+_;|/:=~~............~=$|;_+#3333333333333^-+)_&&_2-#33333333333333333333!#1#333333333333333333111}33333333333333333}11#!333333*%<-{-<%#3333333}1111#3333333({);|$=~.............", "..............~:,]&2-}3333333'{)[@/$$/|;_+%!333333*11#3333333*1111!3333333333}111*3333333333333333333333!(-+2)2+-(3333333}-2&@/:=~...............~:/@[){}3333333333333#-+2))+{%!33333333333333333333}11}33333333333333333*11#!33333333333333333#11}3333333#<-{{-<%*333333311111}333333*-2&],:~..............", ".............~=$|;){(3333333*<+_]|/$$,]&2->3333333^11}3333333^111^3333333333!#11^33333333333333333333333><{+22+{<}3333333({);|$=~................~=$|]&){#!33333333333!(-{{{-<#333333333333333333333#1#!33333333333333333#11>33333333333333333*111!333333!%<----%13333333*1'''1!333333'{);|/=~..............", ".............~:/@&2->33333331-2&],$$/|;_+33333333333333333*111!33333333333333333#11>3333333>%<---<%}3333333#''''>333333*-2&],:=...............", "............~=$|;_+%3333333*<{)[@,//|]&2-#3333333>11>3333333>1''#!3333333333#11#33333333333333333333333*<-+22+{<>33333331{)[|/=~..............~~~=:$/|][)+-<(^333333333}(%%%(#3333333333333333333!}111!33333333333333333^11>33333333333333333*111*333333!'%<--<<'3333333*''(''*3333331+_;|$=~...............", "............~:/@[2-^3333333^<{)&]|,|@[_+<*333333!#11!33333331'''1#^33333333*111}3333333>####^^^*33333331-{222+-%!333333*<+_],$=.............~~==:$$/,|][_2{<%(^33333333*''(''*3333333^#11111111111''1^3333333*^^^^^^^^^^111*333333!^^^^^^^^^^#11^3333333}(%<-<<%>3333333#'((((11111'%{)[@/:=................", "............=$,;_+%!333333!'<{2_[]]][_2-13333333}11^3333333}''''''1*3333333^11#3333333*'''''''1!333333*%-+22+{<^3333333#{2[@/:~............~=:$/,,||@];[_2{-%('*3333333*''''#3333333*(%<<-----<<%(''1*3333333#111111111111^3333333*1111111111111*33333331(%<<<%(3333333!'((%(((''(%<{)&],$=~................", "...........~:/@[){13333333>(%-+)_&[&_2{<*3333333#11*3333333#''''''1!333333*111}3333333^(((((''>3333333^<{+22+-%*333333!%+_;|$=~...........~=:/,@]];;[[&_)+{<%('*3333333}1111*33333331%-{+2222++{<%('#3333333*1111111111111*3333333#111111111111#3333333*'((%%%(^3333333>'((%(((''(%-2_;|$:~.................", "...........=$,]_+<*33333331'(<-{2222+{<'3333333*11^3333333*1''''''>3333333>111!3333333(%%%%(('!333333!%-+222{-13333333>-2&@/:~...........~=$,|][&__)))22+{<%('1!3333333>11113333333*%-+)_&&[&&)2{<%(*3333333^111111111111#3333333*1111111111111*3333333#''(((('!333333!1'(((((('((<{)[@/:=..................", "..........~=/|[){'3333333*''((%<-{{--<%}3333333^11*3333333}1'''''1!3333333111>3333333>%<<<<%(^3333333><{+22+-<*3333333%{);|$=~..........~=$,@;&)2++{{{{--<%%('>33333333#111}3333333#-+)&;]@@];[_+-%'3333333*1111111111111}3333333^111111111111#3333333*1''''''>3333333}'''((('''(%-+_;,$=~..................", "..........~:,]&2-*3333333^#111''(((%%(13333333*11#33333333!^####^*3333333}111*3333333'<---<%(*333333!(-{222{-'3333333}-2&],:~...........~:/@;_+<%%((((((''1#>*33333333*1111!333333!%{)[]|,//,@;&2-%>3333333>#########111#!333333!##########111}3333333>##111#>333333331'''''11111'<+&],:~...................", ".........~=$|;){(33333333333333333*'('}3333333^11}33333333333333333333333#11^3333333}%<-{-<%13333333}<{+22+{<}3333333'{)[|$=~..........~=$|;_2'33333333333333333333333#111>3333333^-2&]|/$:$/,]&2-(!3333333333333333!#11}33333333333333333}111!3333333333333333333333*11''1*333333(2&@/:~...................", ".........~:/@&2->33333333333333333}''13333333!11#!3333333333333333333333*111*3333333'<-{{-<%*3333333'-{222{-(3333333*<+_],:=...........~:,]&2{*3333333333333333333333}1111*3333333%{_;|/:===$,]&2-^33333333333333333*111!33333333333333333#11>33333333333333333333333#1111>333333*-2[@/=~...................", ".........=$,;_+3333333>11>33333333333333333333333#11#3333333*%-{{{-<(3333333*<{+22+{<>33333331{)[@/:~..........~=$|;_+(3333333333333333333333*1''1^3333333}-2&],$=~~=$,;_+<*33333333333333333^11>33333333333333333*111*3333333333333333333333*1''11*333333#{);|$=~...................", "........~=/|[){^33333333333333333*111*333333!1''*3333333333333333333333*''1}33333331<{++{-<>33333331-+2)2+-%3333333!<+_],$=~..........~:/@&2-*333333333333333333333*'''''*3333333(+);|$=~~~=$|[){133333333333333333*111*33333333333333333^11^33333333333333333333333#''''^333333!<+_],:=....................", "........~:/@&2<*33333333333333333^''^3333333}'''*3333333333333333333333#''1!333333*<{+22+-%!333333*<{2)))+-#3333333^{)[@/:~...........=:,]_+(333333333333333333333}(%%((#3333333}-2&],:=~~~:/@[)-*33333333333333333>''#33333333333333333!1''*3333333333333333333333>(((('*333333^{)[@/:~....................", "........~:/@&2'33333333333333333*'('*3333333'%%(*33333333333333333333!1(((>3333333#{+)))2{#3333333#{2_&&_2-*333333!<2&],$=~...........=$,]_+}3333333333333333333*1<--<<%}3333333'+_;|$=~..~:/@[)(33333333333333333!'('*33333333333333333>((13333333333333333333333^<<<<%13333333<+_;,$=~....................", "........~:/@[)}!!!!!!!!!!!!!!!!!#%%'!!!!!!!}<<-<1*!!!!!!!!!!!!!!!!!*^(<<<<*!!!!!!*-2_&&_)+*!!!!!!*-2_&[[&)%*!!!!!!^+_;|/:~............=:,]&{*!!!!!!!!!!!!!!!**^'-{++++{<*!!!!!!*+)[@/:~...~:/@[)^!!!!!!!!!!!!!!!!!>%%'!!!!!!!!!!!!!!!!!*(%%>!!!!!!!!!!!!!!!!!!!*>(-{++{-^!!!!!!>+)[@/:~.....................", "........~=/|;_2{-<<<<<<<<<<<<<--------<<<--{++++{{--<<<<<<<<<<<<<<--{++++{{-----{+)_[;;;&)+{----{+)_[]]];&)+{----{2_[@/:=~............~:/@[)+{-<<<<<<<<<<<<<--{+2)_&&_)+{-----{+)[],$=~...~=$|;&2{-<<<<<<<<<<<<<--------<<<<<<<<<<<<<<--------<<<<<<<<<<<<<<<<--{+2)__)2+{----{+_[@,$=~.....................", "........~=$,@[_)2++++++++++++++222222++++22)____))2+++++++++++++++22)_____)2+++2)_&;@||@;[_)2++22_&;@|,|@;&)2+++2)&[@,$=~.............~=$|][_2+++++++++++++++2)_&[;]];[_)2+++2)_[],$=~....~=:,@;_)2++++++++++++++222222+++++++++++++++2222222++++++++++++++++++2)_[[;;[&_)2++2)_[],$=~......................", ".........~:$,@;[&&___________&&&[[[[&&&&&&[;;]]];[&&&____________&&[;;]]];[[&&&&[;@|,//,|@;[&&&&[;]|/$$/,|];[&&&&[]@,$=~..............~=:/|];[&&___________&&[[;@|,,,|@];[&&&&[;@,$:~......~=$,@;[&&___________&&&[[[[&&&____________&&&[[[[&&&______________&&[;]@|||@];[&&&&[;@,$:~.......................", "..........~:$/|@@]]]]]]]]]]]]]]@@@@@@]]]]@@|,,,,|@@]]]]]]]]]]]]]]]@@||,,,||@]]]@@|,$:::$/,|@@]]@@|,/::=:$/,|@]]]@|,/$=~................~=:/,|@]]]]]]]]]]]]]]@@|,//$$$$/,|@]]]@@|/$:~~.......~=$/|@@]]]]]]]]]]]]]]@@@@@@]]]]]]]]]]]]]]]@@@@@@@]]]]]]]]]]]]]]]]]]@|,//$$/,|@@]]@@,/$=~~.......................", "..........~~=:$///,,,,,,,,,,,////$$////,///$$:::$$//,,,,,,,,,,,,,///$$:::$$//////$:==~~==:$//////$:==~~~=:$$/////$$:=~..................~=::$//,,,,,,,,,,,,///$$:=====::$//////$:=~..........~=:$///,,,,,,,,,,,////$$////,,,,,,,,,,,,////$$///,,,,,,,,,,,,,,,///$::===::$//////$:=~.........................", "............~~==::::::::::::::::====::::::===~~===:::::::::::::::::===~~===:::::==~~~..~~===::::===~~...~~==:::::==~~....................~~==::::::::::::::::===~~~..~~===::::==~~............~~==::::::::::::::::====:::::::::::::::::=====:::::::::::::::::::===~~~~~===::::==~~..........................", "..............~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.....~~~~~~~~~~~~~~~~~~~~.....~~~~~~~~........~~~~~~~~.........~~~~~~~..........................~~~~~~~~~~~~~~~~~~~.........~~~~~~~.................~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~........~~~~~~.............................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................", "............................................................................................................................................................................................................................................................................................................"};