This commit is contained in:
Alexander Deynichenko 2013-02-25 07:23:44 +04:00
parent 35ff18a6a1
commit 03b62f3315
809 changed files with 211135 additions and 0 deletions

66
AUTHORS Normal file
View File

@ -0,0 +1,66 @@
PLIB was originally written by Steve Baker as a solo project - but
has subsequently been greatly enhanced and expanded by a 'cast of
thousands'.
Most important of all - the 'official' PLIB developers:
Alex Perry
Curtis Olson
Ben Woodhead
Dave McClurg
Gerard Decatrel
Gil Carter
Giancarlo Niccolai
James Jones
John Fay ("Mr. PUI")
Juergen Marquardt
Mark Vallevand
Marten Stromberg
Nathan Matias
Norman Vine
Per Liedman
Sam Stickland
Sebastian Ude
Steve Baker <--- Hmmm - must sort this list by SECOND name!
Will Lachance
Wolfram Kuss
Then, the non-registered contributors:
(Apologies to anyone I've left
out - please let me know who
you are and I'll add you in.)
Andrew Ross
Christopher St.John
Christian Mayer
Darrell Walisser
Dave Heil
Erik Hofman
Kevin Thompson
Karl Kremer
Negative0 <---- Who? Some kind of 1's complement arithmetic fanatic?
Mark Danks
Michael Kurth
Sean Palmer
Simon Britnell
Themie Gouthas
Tony Knienieder
Trent Gamblin
Special mention must go to:
Daryll Strauss (GLIDE port to Linux)
David Bucciarelli (Mesa -> GLIDE interface)
Brian Paul (Mesa)
Curtis Olson (FlightGear guru and all-round "Mr Nice Guy",
who nagged me into writing most of this stuff!)
Vasily Lewis (Tireless maintainer and sysadmin at Woodsoup
where PLIB was first hosted)
Toru Egashira (Who wrote a program called 'NSPmod' which was
the original basis of the SL 'MOD' player -
although the original code has been almost
entirely rewritten in the process of merging
it with SL.
Everyone at OPENGL-GAMEDEV-L

496
COPYING Normal file
View File

@ -0,0 +1,496 @@
SPECIAL NOTICE:
As a special exception Steve Baker gives permission to link these
libraries with proprietary software and distribute the resulting
executable without including that proprietary code in any distribution
as the LGPL would normally dictate.
This exception is ONLY granted in the case of an embedded system in
which there is no possibility of an end user re-linking or recompiling
against new versions of this library that may appear in the future.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU 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.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

1102
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

218
INSTALL Normal file
View File

@ -0,0 +1,218 @@
Basic Installation
==================
These are generic installation instructions.
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.
OpenGL Configure
================
Configure is not able to find the OpenGL headers and libraries. In this
case please add
./configure --with-GL=PREFIX
Examples
./configure --with-GL=/usr/local
This will look in the /usr/local/include for headers (GL/ is not needed)
and /usr/local/lib for the libraries.
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
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Compiling for Windows with MSVC
===============================
You can easily compile plib with MSVC 6. First, you have to set some paths
in tools\options\directories. In "include" set the plib path itself (and,
if needed the parent). Then, in "library paths" add the plib path itself again
so that packages that use plib will find it. The building process will copy
the finished *.lib files and any header files that are visible to projects
using plib into the plib path.
There is a workspace (*.dsw file) for plib, for examples, for tools
(including only af2rgb) and for each of the demos: exposer, p-guide
and ttt3d. Simply open one of them (starting with plib itself, of course)
in MSVC, choose what you want to compile (build/set active configuration)
and then compile (F7). if you want to compile or even create a project
that uses plib, please note that the plib workspaces have "multi threading"
enabled. Either enable this as well in your project or disable it for
plib. A missmatch leads to errors.
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'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
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.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
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.

25
KNOWN_BUGS Normal file
View File

@ -0,0 +1,25 @@
Known bugs and limitations in PLIB version 1.8.x
More in depth stuff can be found in TODO_AFTER135.
* ssgLOS is really broken.
* ssgStripify and ssgFlatten might well have bugs in them.
A known bug of ssgStripify is that : since it rearranges and
merges leaf nodes, ssgSelectors are messed up
* Sometimes cr*p values appear in 3D files, for example .ac files.
The reason seems to be that sometimes the loader handles colours
differently than the writer.
* Several, general smalish .MDL loader bugs are known; Look in TODO_AFTER135
* Scaling does not work (intentionally). Uniform scaling may be
enabled by uncommenting "radius *= sgLengthVec3(m[0])" in
sgSphere::orthoXform. It is currently disabled because that extra
calculation would degrade performance on non-scaled matrices.
Scaling really makes a mess of SSG bounding sphere tests
* .ssg files should not be used for long term storage. It will probably
change in incompatible ways.

7
Makefile.am Normal file
View File

@ -0,0 +1,7 @@
SUBDIRS = src
EXTRA_DIST = KNOWN_BUGS NOTICE README README.GLUT \
README.win32 README.mac TODO-1.6 TODO-2.0 \
TODO_AFTER135 autogen.sh missing \
plib.dsp plib.dsw transferCvs2WebSite

4
NEWS Normal file
View File

@ -0,0 +1,4 @@
Fri Oct 13 16:54:04 CEST 2006
Moved from SF CVS to SF SVN.
To grab a copy from svn, use this command:
$ svn co https://svn.sf.net/svnroot/plib/trunk plib

23
NOTICE Normal file
View File

@ -0,0 +1,23 @@
NOTICE: The PLIB Portable Interactive Applications Library distribution
contains source code that is released as OpenSource under the GNU
Library Public License. These programs are thus freely distributable
without licensing fees. These programs are provided without guarantee
or warrantee expressed or implied.
If you use PLIB in a commercial or shareware product, it would be nice
if you gave credit where it is due. If you make any neat modifications
or improvements to PLIB, I would greatly appreciate a copy of the
improved code or at least a source patch.
Note that PLIB uses an addition to the LGPL:
As a special exception Steve Baker gives permission to link these
libraries with proprietary software and distribute the resulting
executable without including that proprietary code in any distribution
as the LGPL would normally dictate.
This exception is ONLY granted in the case of an embedded system in
which there is no possibility of an end user re-linking or recompiling
against new versions of this library that may appear in the future."

182
README Normal file
View File

@ -0,0 +1,182 @@
Portability Libraries.
======================
by Steve Baker.
All the documentation and installation instructions
are now online at:
http://plib.sourceforge.net
They are also downloadable - along with example
programs and demos from the same site.
SUPPORT:
Please don't email me (Steve Baker) directly - I
get *WAY* too much mail as it is! Instead, please
sign up to the PLIB user's mailing list. Instructions
can be found here:
http://plib.sourceforge.net
LICENSING:
These libraries are offered as OpenSource freeware
under the provisions of the GNU Library Public
License (LGPL). Those terms and conditions are
detailed in the file 'LICENSE' in this directory.
I have added a short preamble to LGPL that removes
no rights from ordinary users but offers special
dispensation to allow PLIB to be used under certain
commercial conditions (such as Games Consoles) where
the constraints of LGPL are impossible to meet.
| As a special exception Steve Baker gives permission to link these
| libraries with proprietary software and distribute the resulting
| executable without including that proprietary code in any distribution
| as the LGPL would normally dictate.
|
| This exception is ONLY granted in the case of an embedded system in
| which there is no possibility of an end user re-linking or recompiling
| against new versions of this library that may appear in the future.
REQUIREMENTS:
In addition to the libraries that I provide, you
will also need OpenGL (OpenGL 1.1 or later -
Mesa 3.0 or later) and GLUT (The OpenGL utilities
toolkit - version 3.7 or later) and a hardware 3D
graphics accellerator that supports OpenGL.
WHAT DO YOU GET?
The following libraries are provided:
JS -- A Joystick interface.
PUI -- A simple GUI built on top of OpenGL.
SG -- Some Standard Geometry functions (vector and
matrix math, spheres, boxes, frustra, etc)
SL -- A Games-oriented Sound Library.
FNT -- OpenGL texture-mapped font Library.
PW -- A minimalist windowing library.
PSL -- A C-like scripting language.
SSG -- A Simple Scene Graph API built on top of OpenGL.
NET -- Some Networking functions for games.
UTIL-- Utilities - things that your OS would normally
handle - but these functions are portable.
SSGAUX -- Some optional additional high level features for SSG
PUIAUX -- Some optional additional high level features for PUI
DIRECTORY STRUCTURE:
PLIB expects to be installed in one standard place:
/usr/lib
...with header files at:
/usr/include/plib
PORTABILITY and DEPENDANCIES:
Although all these libraries are designed to be easily
portable (and more importantly so that programs using
them can be UTTERLY portable), some of them have not
yet been ported to all operating systems.
JS -- Currently Linux/Windows/BSD only.
UL -- Should be portable to POSIX-compliant
OS's ... and Windows.
SG -- Totally portable, no dependancies.
PUI -- Requires OpenGL also FNT and SG.
PUI also requires some kind of windowing
library - which could be PW - or GLUT,
freeglut, SDL, FLTK - or others.
PSL -- Requires UL.
PW -- Requires UL.
NET -- Should be portable to POSIX-compliant
OS's.
FNT and SSG -- Require OpenGL, SG and UL.
SSGAUX -- Requires SSG - and hence OpenGL, SG and UL.
PUIAUX -- Requires PUI - and hence FNT and SG.
SL -- This has now been ported onto:
Linux
FreeBSD
OpenBSD
M$ Windows (NT,95,98 - so far)
MacOS
SGI IRIX
Sun Solaris
Any operating system that supports OSS (The
Open Sound System).
NOTE: SL has a subsidiary library 'SM' that
can be used to control the audio mixer - but
that is not portable beyond Linux. You might
get it to work under OSS-based sound systems
too. Don't use SM if you want to write portable
code.
No other requirements.
AUX LIBRARIES AND TOOLS:
The 'tools' directory contains a number of useful tools
and utility programs that are either built using PLIB or
which are specifically useful when writing PLIB programs.
COMPILING/LINKING WITH PLIB
In your source code, add any combination of:
#include <plib/ul.h>
#include <plib/js.h>
#include <plib/sg.h>
#include <plib/fnt.h>
#include <plib/pu.h>
#include <plib/ssg.h>
#include <plib/pw.h>
#include <plib/puAux.h>
#include <plib/psl.h>
#include <plib/sl.h>
#include <plib/net.h>
#include <plib/ssgAux.h>
Add any of these to your link line:
-lplibjs -lplibssgaux -lplibssg -lplibsl -lplibpu
-lplibpuaux -lplibpw -lplibpsl -lplibfnt -lplibnet
-lplibsg -lplibul
Under UNIX/Linux, you'll also need:
-lGLU -lGL -L/usr/X11/lib -lX11 -lXext -lXmu -lm
...and perhaps a -l for whatever windowing library
you're using - unless it's the built-in PW library.
Steve Baker.
<sjbaker1@airmail.net>
http://www.sjbaker.org

3
README.GLUT Normal file
View File

@ -0,0 +1,3 @@
PUI no longer depends on GLUT or freeglut.

96
README.JOYSTICKS.FREEBSD Normal file
View File

@ -0,0 +1,96 @@
FreeBSD joystick support
------------------------
FreeBSD supports two flavors of joysticks: analog and USB. By default,
non-root users do not have access to these devices on FreeBSD, and the
required devices may not even be created yet. Please browse the below
notes before writing to the plib mailing list.
Contents of this file:
-----------
Analog joysticks
USB joysticks
Testing the joysticks
Compiling and linking
Analog joysticks
----------------
Plib uses the joy(4) interface to analog joysticks. You will need to
make sure the device files exist:
ls -l /dev/joy*
If they do not yet exist, create them (logged in as root):
cd /dev
sh MAKEDEV joy
By default, they will have permissions that do not allow unprivileged
users access to them:
crw-r----- 1 root operator 51, 0 Aug 30 16:59 joy0
crw-r----- 1 root operator 51, 1 Aug 30 16:59 joy1
You may wish to consider making the devices world read/writable:
chmod a+rw /dev/joy*
Users of xdm(1) or any of its more modern successors may wish to look
into GiveConsole and TakeConsole or its equivalent.
If you do not have a joystick driver compiled into you kernel, you can
load one dynamically with the command
kldload joy
When in doubt, check the FreeBSD handbook about making sure this driver
is loaded every time you reboot.
USB joysticks
-------------
Plib uses the usbhid(3) interface to USB joysticks. Joysticks will show
up as generic USB Human Interface Devices (uhid). Because the USB design
allows an almost unlimited number of USB buses and USB devices, you should
make sure you have enough devices in /dev to deal with your devices.
When in doubt, create a few extra to make sure. If you have insufficient
USB or uhid devices, your joystick may not appear at all, or it may
disappear if you connect your USB devices in a different order.
Fortunately, device nodes are free. For example, you might see this:
ls -al /dev/usb* /dev/uhid*
crw-rw---- 1 root operator 108, 255 Apr 12 01:44 /dev/usb
crw-rw---- 1 root operator 108, 0 Apr 12 01:44 /dev/usb0
crw-rw---- 1 root operator 122, 0 Apr 12 01:44 /dev/uhid0
This shows you have one usb interface (/dev/usb itself doesn't count), and
one uhid device. Make a few extra with
cd /dev
sh MAKEDEV usb0 usb1 usb2 usb3 uhid0 uhid1 uhid2 uhid3
(you can leave out the devices that exist already).
Next, you'll have to think about permissions. Both the /dev/usb0..3
(but not /dev/usb) have to be world readable, as well as the uhid devices.
This command will take care of it:
chmod a+r /dev/usb?* /dev/uhid*
(yes, the "?*" after /dev/usb is intentional).
Obviously, any permission change you make is at your own risk! XDM users
may use the GiveConsole/TakeConsole mechanism as an alternative.
Plib will complain if /dev/uhid* or /dev/usb* exist but are
unreadable with your current privileges.
Testing the joysticks
---------------------
Users of FlightGear can quickly test their joysticks with the js_demo
program.
Compiling and linking
---------------------
Compile plib on FreeBSD with the same compiler options as used for the
other libraries you may use. In particular, if you use pthreads anywhere
in your application, you should compile Plib with
g++ -pthread
Applications linking to recent Plib's -ljs should add -lusbhid to the
link command line in the Makefile.

19
README.mac Normal file
View File

@ -0,0 +1,19 @@
PLIB Project files for CodeWarrior
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NOTE from Steve:
It seems that the CodeWarrior project files for
PLIB are considerably larger than the entire source
distribution (450Kb!)
Hence, since Mac/CodeWarrior users are not exactly
commonplace, I'm not going to include the project
files into the distro and cause everyone else prolonged
download times.
I suggest you contact Darrell Walisser <dwaliss1@purdue.edu>
should you need to build PLIB in this setting.
Sorry!

52
README.win32 Normal file
View File

@ -0,0 +1,52 @@
PLIB for Windoze.
~~~~~~~~~~~~~~~~~
Let me first say that I (Steve Baker) don't own a copy
of Windoze - so I have little or no ability to help
Windoze owners with PLIB problems. It's especially
important therefore that you direct problems and
queries to the PLIB mailing lists. Subscription
information is on the PLIB homepage:
http://plib.sourceforge.net
CygWin:
~~~~~~~
The simplest way to build PLIB for Windoze is to
use the CygWin compiler and toolset. Since that
environment is pretty close to UNIX/Linux, the
./configure
make
make install
...mechanism works perfectly.
MingW32:
~~~~~~~~
A couple of people have asked about doing a MingW32 port - but
as far as I can tell, the "configure/make/make install" approach
*should* work.
Microsoft Visual C++:
~~~~~~~~~~~~~~~~~~~~~
All you need to do is open the workspace "plib.dsw" in MSVC++,
select the "plib" project (using Set Active Project in the Project
menu), and build it (using "Rebuild All" in the Build menu).
In the examples folder, open the workspace "plib_examples.dsw".
Each example has a seperate project in the workspace. Select
the one you want and build it. Then you should be able to hit
the Go icon on the toolbar and try it out.
For your own application, please note that the plib workspace
leaves all the necessary includes (*.h) and libraries (*.lib)
in the plib root directory (same as workspace). The debug
libraries are given a '_d' suffix. Where ever you put those
files, make sure #include <plib/ul.h> works so your code is
more portable.

69
TODO-1.6 Normal file
View File

@ -0,0 +1,69 @@
NEW FEATURES:
Structure section
* SSG needs RTTI to replace the rapidly vanishing SSG_TYPE bits resource.
* I'd like to see the FGFS sky model moved into ssgAux so everyone can use
it. We got part of the way towards that - but it was never finished.
* I'd like to have a ROAM engine built into ssgAux for terrain rendering.
(maybe not *literally* ROAM - but something very like it).
SSG section
* Support for bump maps, cubic environment maps, etc, etc on hardware
that supports it.
* Support for multi-texture.
* Import some kind of Skin & Bones animation into ssgAux (using the
ExPoser code - or something even better).
Loader section
* MORE file readers and writer.
For example, a reader/loader for WWII Fighters would be nice.
* No file writers for about 2/3rds of the file formats we support.
* I want the PPE material editor's file format built into SSG so we can
load and save material lists.
* Model formats
* VRML
* XML version of ssg
* WWII (I think thats the name)
SG section
* function to get the angle between two vectors
* plot points on a vector (walking in a straight line)
* Expand SG with more intersection and distance-measuring tricks.
PUI section
* PUI should also be implemented with RTTI as well.
* Movable widgets
* PUI is still somewhat tied to GLUT...that should go. It'll need a
way to get the window dimensions - and at least one built-in font
before we can do that.
SL section
* Re-implement SL on top of OpenAL.
* Write players for more modern MOD-like music formats.
Examples section
* More example programs - more complete demo games and tools.
* More documentation for all the new features.

28
TODO-2.0 Normal file
View File

@ -0,0 +1,28 @@
[ Put in tasks here that probably won't get done before PLIB 2.0 or change
the API in a way that could break existing applications ]
PUI section
* Remove deprecated puFilePicker widget
* Remove deprecated old label and legend places
* Remove deprecated PUSTYLE_RADIO
* Remove deprecated 'int puValue::getValue ( void )' function
(Application developers: Use 'puValue::getIntegerValue' instead)
* Remove deprecated 'int puObject::getDefaultValue ( void )' function
(Application developers: Use 'puValue::getDefaultIntegerValue' instead)
* Line up widget constructors (explicit size vs. max coordinates issue)
* Change function parameters taking a 0/1 FALSE/TRUE value from 'int'
to 'bool'
* In puDeactivateWidget (), invoke the active widget's down callback
(Can't be realized prior to 2.0 since it could break existing programs
relying on the old behaviour)
* Implement puiAUX for complex widgets [ unclear ]

138
TODO_AFTER135 Normal file
View File

@ -0,0 +1,138 @@
+============+
| TO BE DONE |
+============+
A tasks and bugs are now being tracked by sourceforge. Please
goto: http://sourceforge.net/projects/plib/
* Have a look into known_bugs and fix them.
* Lines in ASCII files are terminated...
With '\n' under UNIX/Linux
With '\r' under MacOS
With BOTH under Windoze.
Hence, UNIX/Linux does no conversions of either '\r' or '\n'.
and MAC swaps '\r' and '\n' on input.
and Windoze dumps '\r' if it follows a '\n'.
This is a mess - so I'm changing all the ASCII I/O code
to allow either or both '\n' or '\r' and I'm reading the
ASCII files in BINARY mode.
* Array deletion requires '[]' after 'delete' on Mac.
* Some of the MSVC-project files for plib_examples seem to be
broken, for example some miss a "winmm.lib".
* Check whether the new ssgStripify works with TuxKart
See Steves post from 11.12.2000 15:12 for a problem description
The abbreviation NIV14 means not in Version 1.4.
Bugs:
=====
- When creating fgfsTux, sometimes .ac, .dxf,
.ase and .obj saved zero objects, although
there were objects. For example, PLIB
created this .ac file:
----------- snip ------------
AC3Db
OBJECT world
kids 0
OBJECT group
kids 0
----------- snip ------------
This seems to happen after ssgFlatten.
- WK: Create a sphere in ppe. Save it as .ASE. See that values like
diffuse colour are cr*p. Try to load it. It crashes. This could be
one or - probably - two bugs. I don't think this is a ppe problem.
The loader complains that number of faces is -2.
The problem seems to be the writer.
*new remark*: About the diffuse values: I think it has to do with
colour material, a loader (.ASE?) loading colours into a colour
list and writing colours from the ssgSimpleState where they are
undefined. I think the same bug is in .AC
- WK: I have a crash in ssgFlatten if I load .ac files with
unused materials (not reproducable?)
- Loading and saving lines in .OBJ doesn't work. Maybe NIV14.
- Sam wrote:
Has anyone here debugged with plib under Windoze 2000 and MSVC++?
I get a whole bunch of
"Free Heap block modifed after it was free"
warnings with the ssgFlatten and ssgStripify.
I'll try and hunt this one down.
...
I think it may be because I'm using MFC which (if I remember
correctly) enables a bunch more memory checks. Also I'm doing
#ifdef _WIN32
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#endif
- Not all loaders use ssgLoaderOptions::begin. Don't all have to?
- Search for todo, fix, fixme, kludge.
Misc:
=====
- Look whether scaling works. [see current discussion]
If not and if we can't/don't want to make it work, for example
because of performance issues we need a warning in the docs and
IMHO PLIB should "write out" a warning if an unallowed matrix is
sent to it.
Update: Scaling does not work (intentionally). Uniform scaling may be
enabled by uncommenting "radius *= sgLengthVec3(m[0])" in
sgSphere::orthoXform. It is currently disabled because that extra
calculation would degrade performance on non-scaled matrices.
- Reduce lint warnings. Lint is an error checking tool that gives warnings
where things *could be* wrong as opposed to the compiler that tells
you where they are wrong.
- It would be great if we had one or even two working native .ssg
file formats. Currently (16.12.2001) the format work most of the time, but not all
entities are implemented.
- We should write the GetWrapU/GetWrapV function, since
loading /writing .ssg files can't work 100% without it.
- When saving, there is often a warning that "ref count doesn't
tally with parent count"
- Go through the mailing list for unfinished business.
- Someone, preferably a native english speaker with ssg-knowledge,
should go through the new ssg-doc and fix any mistakes. It should be
fairly complete by now.
- Add Per's new Formats to the doc?
- For the other parts of plib, people should bring the doc up to
date.
- There is a bug in the 3Dfx driver for Linux (tdfx_dri-4.0.1-1) that
causes the "complex" example program to crash in "fxSetupBlend".
This is fixed in more recent DRI snapshots (requires kernel 2.4.x).
Probably after 1.4.0:
=====================
- In fgfsTux, not a large object, you get a DList overflow
with the standard values for its size. Can we make its
size dynamic?
- Look at handling of normals. For example, loaders,
stripify etc should only recalculate missing normals.
Have *one* function that recalculates normals.
It would be nice if people would volunteer for tasks.

19
autogen.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
OSTYPE=`uname -s`
AMFLAGS="--add-missing"
if test "$OSTYPE" = "IRIX" -o "$OSTYPE" = "IRIX64"; then
AMFLAGS=$AMFLAGS" --include-deps";
fi
echo "Running aclocal"
aclocal
echo "Running automake"
automake $AMFLAGS
echo "Running autoconf"
autoconf
echo "======================================"
echo "Now you are ready to run './configure'"
echo "======================================"

426
configure.in Normal file
View File

@ -0,0 +1,426 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/js/js.h)
# **WARNING**WARNING**WARNING**WARNING**WARNING**WARNING**
#
# When you make a new release, there are TWO places where you
# have to change the version number:
# 1) Right below this comment.
# 2) In 'ul.h' where PLIB_VERSION is created.
#
# **WARNING**WARNING**WARNING**WARNING**WARNING**WARNING**
AM_INIT_AUTOMAKE(plib, 1.8.5)
# This AC_PREFIX_DEFAULT will place the library files
# into /usr/lib - but will put the include files into
# /usr/include - when /usr/include/plib would be less
# polluting to the filename space.
#
# There is probably a better way to do this.
AC_PREFIX_DEFAULT(/usr)
if echo $includedir | egrep "plib$" > /dev/null; then
echo "includedir is" $includedir "libdir is" $libdir
else
includedir="${includedir}/plib"
echo "includedir changed to" $includedir "libdir is" $libdir
fi
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL
AC_PROG_RANLIB
dnl Command line arguments
dnl Don't use AC_HELP_STRING here as old versions of autoconf do not
dnl understand it.
AC_ARG_WITH(GL,
[ --with-GL=DIR set the prefix directory where GL resides],
GL_PREFIX=$withval, GL_PREFIX=auto)
AC_ARG_ENABLE(fnt,
[ --enable-fnt build FNT library (OpenGL needed) default: yes],,
enable_fnt=yes)
AC_ARG_ENABLE(js,
[ --enable-js build JS library default: yes],,
enable_js=yes)
AC_ARG_ENABLE(pw,
[ --enable-pw build PW library default: yes],,
enable_pw=yes)
AC_ARG_ENABLE(net,
[ --enable-net build NET library default: yes],,
enable_net=yes)
AC_ARG_ENABLE(pui,
[ --enable-pui build PUI library (OpenGL needed) default: yes],,
enable_pui=yes)
AC_ARG_ENABLE(sg,
[ --enable-sg build SG library default: yes],,
enable_sg=yes)
AC_ARG_ENABLE(psl,
[ --enable-psl build PSL library default: yes],,
enable_psl=yes)
AC_ARG_ENABLE(sl,
[ --enable-sl build SL library default: yes],,
enable_sl=yes)
AC_ARG_ENABLE(ssg,
[ --enable-ssg build SSG library (OpenGL needed) default: yes],,
enable_ssg=yes)
AC_ARG_ENABLE(puaux,
[ --enable-puaux build puAux library (OpenGL needed) default: yes],,
enable_puaux=yes)
AC_ARG_ENABLE(ssgaux,
[ --enable-ssgaux build ssgAux library (OpenGL needed) default: yes],,
enable_ssgaux=yes)
AC_ARG_ENABLE(ul,
[ --enable-ul build UTIL library default: yes],,
enable_ul=yes)
dnl Dependancy checking
if test "x$enable_fnt" = "xyes"; then
need_opengl=yes
if test "x$enable_sg" = "xno"; then
AC_MSG_WARN([cannot build FNT library without SG library enabled])
dependancy_problem=yes
fi
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build FNT library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_pw" = "xyes"; then
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build PW library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_js" = "xyes"; then
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build JS library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_net" = "xyes"; then
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build NET library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_pui" = "xyes"; then
need_opengl=yes
if test "x$enable_fnt" = "xno"; then
AC_MSG_WARN([cannot build PUI library without FNT library enabled])
dependancy_problem=yes
fi
if test "x$enable_sg" = "xno"; then
AC_MSG_WARN([cannot build PUI library without SG library enabled])
dependancy_problem=yes
fi
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build PUI library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_sg" = "xyes"; then
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build SG library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_psl" = "xyes"; then
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build PSL library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_sl" = "xyes"; then
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build SL library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_ssg" = "xyes"; then
need_opengl=yes
if test "x$enable_sg" = "xno"; then
AC_MSG_WARN([cannot build SSG library without SG library enabled])
dependancy_problem=yes
fi
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build SSG library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_puaux" = "xyes"; then
need_opengl=yes
if test "x$enable_pui" = "xno"; then
AC_MSG_WARN([cannot build puAux library without PUI library enabled])
dependancy_problem=yes
fi
if test "x$enable_sg" = "xno"; then
AC_MSG_WARN([cannot build puAux library without SG library enabled])
dependancy_problem=yes
fi
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build puAux library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$enable_ssgaux" = "xyes"; then
need_opengl=yes
if test "x$enable_ssg" = "xno"; then
AC_MSG_WARN([cannot build ssgAux library without SSG library enabled])
dependancy_problem=yes
fi
if test "x$enable_sg" = "xno"; then
AC_MSG_WARN([cannot build ssgAux library without SG library enabled])
dependancy_problem=yes
fi
if test "x$enable_ul" = "xno"; then
AC_MSG_WARN([cannot build ssgAux library without UL library enabled])
dependancy_problem=yes
fi
fi
if test "x$dependancy_problem" = "xyes"; then
AC_MSG_ERROR([dependancy problems detected])
fi
AM_CONDITIONAL(BUILD_FNT, test "x$enable_fnt" = "xyes")
AM_CONDITIONAL(BUILD_JS, test "x$enable_js" = "xyes")
AM_CONDITIONAL(BUILD_PW, test "x$enable_pw" = "xyes")
AM_CONDITIONAL(BUILD_NET, test "x$enable_net" = "xyes")
AM_CONDITIONAL(BUILD_PUI, test "x$enable_pui" = "xyes")
AM_CONDITIONAL(BUILD_PUAUX, test "x$enable_puaux" = "xyes")
AM_CONDITIONAL(BUILD_SG, test "x$enable_sg" = "xyes")
AM_CONDITIONAL(BUILD_PSL, test "x$enable_psl" = "xyes")
AM_CONDITIONAL(BUILD_SL, test "x$enable_sl" = "xyes")
AM_CONDITIONAL(BUILD_SSG, test "x$enable_ssg" = "xyes")
AM_CONDITIONAL(BUILD_SSGAUX, test "x$enable_ssgaux" = "xyes")
AM_CONDITIONAL(BUILD_UL, test "x$enable_ul" = "xyes")
if test "x$need_opengl" = "xyes" && test "x$GL_PREFIX" != "xauto"; then
LDFLAGS="$LDFLAGS -L$GL_PREFIX/lib"
CPPFLAGS="$CPPFLAGS -I$GL_PREFIX/include"
fi
dnl Checks for library functions.
dnl check for OpenGL related libraries
AC_CANONICAL_HOST
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
dnl Multimedia library
LIBS="$LIBS -lwinmm"
if test "x$need_opengl" = "xyes"; then
dnl OpenGL libraries
LIBS="$LIBS -lopengl32"
fi
;;
*-apple-darwin*)
dnl Mac OS X
if test "x$need_opengl" = "xyes"; then
dnl OpenGL libraries
LIBS="$LIBS -framework OpenGL"
fi
dnl Sound libraries
LIBS="$LIBS -framework Carbon"
;;
*)
if test "x$need_opengl" = "xyes"; then
dnl Check for X11
AC_PATH_XTRA
LDFLAGS="$LDFLAGS $X_LIBS"
LIBS="$LIBS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS -lm"
dnl =========================================================
dnl if test "x$x_includes" != "x"; then
dnl CPPFLAGS="$CPPFLAGS -I$x_includes"
dnl fi
dnl =========================================================
dnl Reasonable stuff non-windoze variants ... :-)
AC_CHECK_LIB(pthread, pthread_create)
AC_CHECK_LIB(GL, glNewList)
if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
dnl if no GL, check for MesaGL
AC_CHECK_LIB(MesaGL, glNewList,,
AC_MSG_ERROR([could not find working GL library]))
fi
fi
AC_CHECK_LIB(dl, dlclose)
dnl Check SGI audio library
AC_CHECK_LIB(audio, ALopenport)
;;
esac
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADER(windows.h, AC_DEFINE(WIN32))
if test "x$need_opengl" = "xyes"; then
dnl Check for OpenGl header files
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
AC_CHECK_HEADER(GL/gl.h,,
AC_MSG_ERROR([OpenGL header file not found]))
;;
*-apple-darwin*)
dnl Mac OS X
AC_CHECK_HEADER(OpenGL/gl.h,,
AC_MSG_ERROR([OpenGL header file not found]))
;;
*)
AC_CHECK_HEADER(GL/gl.h,,
AC_MSG_ERROR([OpenGL header file not found]))
;;
esac
fi
dnl Warning flags
WFLAG="-Wall"
case "$host" in
mips-sgi-irix*)
if test "x$CXX" = "xCC"; then
WFLAG="-fullwarn";
fi
;;
*)
if test "x$CXX" = "xicpc" || test "x$CXX" = "xicc"; then
WFLAG="-w1"
fi
if test "x$GCC" != xyes; then
# if the compiler is not GCC we reset WFLAG to null for safety
WFLAG=""
fi
;;
esac
CFLAGS="$CFLAGS $WFLAG"
CXXFLAGS="$CXXFLAGS $WFLAG"
dnl FreeBSD requires the -pthread switch to enable pthreads. Look for this
dnl weirdness.
save_CXXFLAGS="$CXXFLAGS"
save_CFLAGS="$CFLAGS"
save_LIBS=$LIBS
CXXFLAGS="-pthread $CXXFLAGS"
CFLAGS="-pthread $CFLAGS"
AC_CHECK_LIB(c_r, pthread_exit)
if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
CFLAGS=$save_CFLAGS
CXXFLAGS=$save_CXXFLAGS
fi
LIBS=$save_LIBS
dnl Checks for typedefs, structures, and compiler characteristics.
dnl check for socklen_t (in Unix98)
AC_MSG_CHECKING(for socklen_t)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
socklen_t apa;
],[],[
AC_MSG_RESULT(yes)],[
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
int accept (int, struct sockaddr *, size_t *);
],[],[
AC_MSG_RESULT(size_t)
AC_DEFINE(socklen_t,size_t)], [
AC_MSG_RESULT(int)
AC_DEFINE(socklen_t,int)])])
AC_OUTPUT( \
Makefile \
src/Makefile \
src/js/Makefile \
src/util/Makefile \
src/sg/Makefile \
src/sl/Makefile \
src/psl/Makefile \
src/ssg/Makefile \
src/ssgAux/Makefile \
src/fnt/Makefile \
src/pui/Makefile \
src/puAux/Makefile \
src/pw/Makefile \
src/net/Makefile )
AC_MSG_RESULT(
[PLIB configuration information:
Building FNT library: $enable_fnt
Building JS library: $enable_js
Building NET library: $enable_net
Building PUI library: $enable_pui
Building puAux library: $enable_puaux
Building SG library: $enable_sg
Building PSL library: $enable_psl
Building SL library: $enable_sl
Building SSG library: $enable_ssg
Building ssgAux library: $enable_ssgaux
Building PW library: $enable_pw
Building UTIL library: $enable_ul
])

16
demos/README Normal file
View File

@ -0,0 +1,16 @@
PLIB Demonstration Programs and other Utilities.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The programs released under this directory are
fully complete programs written either as demonstrations
of PLIB or as useful utility programs. Each one
has it's own licensing rules (although all are OpenSourced
in some way) and each has it's own build mechanism and
documentation.
You can build all of the demo's (on UNIX-like OS's)
by running the 'build_all_demos' script.
Enjoy!

22
demos/build_all_demos Executable file
View File

@ -0,0 +1,22 @@
echo "Building ExPoser..."
cd exposer
./autogen.sh
./configure
make
cd ..
echo "Building P-Guide..."
cd p-guide
./autogen.sh
./configure
make
cd ..
echo "Building 3D TicTacToe..."
cd ttt3d
./autogen.sh
./configure
make
cd ..

2
demos/exposer/AUTHORS Normal file
View File

@ -0,0 +1,2 @@
Exposer was written by Steve Baker.

340
demos/exposer/COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
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 Program or any portion
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) 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; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, 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 executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. 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 Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. 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 Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program 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 Program.
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.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program 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.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies 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 Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, 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
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. 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 PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, 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.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

16
demos/exposer/ChangeLog Normal file
View File

@ -0,0 +1,16 @@
ExPoser Change Log.
===================
ExPoser v0.0.1 (July 21st 2001)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Most bugs now removed.
* Can load in 'scenery'
* Better example models.
ExPoser v0.0.0 (June 17th 2001)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* First release.

182
demos/exposer/INSTALL Normal file
View File

@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
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
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
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'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
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.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
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.

View File

@ -0,0 +1,4 @@
SUBDIRS = src data doc
EXTRA_DIST = autogen.sh README exposer.dsw

0
demos/exposer/NEWS Normal file
View File

44
demos/exposer/README Normal file
View File

@ -0,0 +1,44 @@
ExPoser 3D.
~~~~~~~~~~~
by Steve Baker
<sjbaker1@airmail.net>
INSTALLATION:
Installation instructions are pretty basic,
and are covered in the documentation directory 'doc'.
OpenGL (or Mesa)
GLUT (the GL Utility Toolkit)
PLIB (which can be obtained from one of:
http://plib.sourceforge.net
Once that is done, it should be a simple matter of changing
to the directory where all this stuff is unpacked and type:
./configure
make
make install
However, you might want to check the full documentation -
especially if you need to install Mesa/GLIDE/GLUT before
you can start.
All documents are in HTML - so view them with your web browser.
LICENSE:
This software is released under the provisions of
the GNU General Public License (GPL) which can be
found in the file 'COPYING' in the current directory.
DIRECTORY STRUCTURE:
src -- Where the source code lives.
data -- This contains all kinds of miscellaneous data
files to test with.
doc -- Documentation - all in HTML

19
demos/exposer/autogen.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
OSTYPE=`uname -s`
AMFLAGS="--add-missing"
if test "$OSTYPE" = "IRIX" -o "$OSTYPE" = "IRIX64"; then
AMFLAGS=$AMFLAGS" --include-deps";
fi
echo "Running aclocal"
aclocal
echo "Running automake"
automake $AMFLAGS
echo "Running autoconf"
autoconf
echo "======================================"
echo "Now you are ready to run './configure'"
echo "======================================"

167
demos/exposer/configure.in Normal file
View File

@ -0,0 +1,167 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/exposer.cxx)
AM_INIT_AUTOMAKE(exposer, 0.2.0)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL
plib_suffix="-lplibjs -lplibsl -lplibssgaux -lplibssg -lplibpuaux -lplibpu -lplibfnt -lplibsg -lplibul"
AC_LANG_CPLUSPLUS
dnl Command line arguments.
dnl Don't use AC_HELP_STRING here as old versions of autoconf do not
dnl understand it.
AC_ARG_WITH(GL,
[ --with-GL=DIR set the prefix directory where GL resides],
GL_PREFIX=$withval, GL_PREFIX=auto)
if test "x$GL_PREFIX" != "xauto"; then
LDFLAGS="$LDFLAGS -L$GL_PREFIX/lib"
CPPFLAGS="$CPPFLAGS -I$GL_PREFIX/include"
fi
dnl Checks for library functions.
dnl check for OpenGL related libraries
AC_CANONICAL_HOST
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
LIBS="$LIBS -lwinmm -lglut32 -lglu32 -lopengl32 -luser32 -lgdi32"
;;
*-apple-darwin*)
dnl Mac OS X
LIBS="$LIBS -framework GLUT -lobjc -framework OpenGL -framework Carbon"
;;
*)
dnl Check for X11
AC_PATH_XTRA
LDFLAGS="$LDFLAGS $X_LIBS"
LIBS="$LIBS $X_PRE_LIBS -lXi -lXmu -lXext -lX11 $X_EXTRA_LIBS -lm"
dnl =========================================================
dnl if test "x$x_includes" != "x"; then
dnl CPPFLAGS="$CPPFLAGS -I$x_includes"
dnl fi
dnl =========================================================
dnl Reasonable stuff non-windoze variants ... :-)
AC_CHECK_LIB(GL, glNewList)
if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
dnl if no GL, check for MesaGL
AC_CHECK_LIB(MesaGL, glNewList,,
AC_MSG_ERROR([could not find working GL library]))
fi
AC_CHECK_LIB(GLU, gluLookAt)
if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
dnl if no GLU, check for MesaGLU
AC_CHECK_LIB(MesaGLU, gluLookAt,,
AC_MSG_ERROR([could not find working GLU library]))
fi
dnl check for glut...or freeglut
AC_CHECK_LIB(freeglut, glutGetModifiers)
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xno" ; then
dnl if no freeglut, check for Real GLUT
AC_CHECK_LIB(glut, glutGetModifiers,,
AC_MSG_ERROR([could not find working GLUT library]))
fi
AC_CHECK_LIB(dl, dlclose)
dnl Check SGI audio library
AC_CHECK_LIB(audio, ALopenport, SND_LIBS="-laudio")
;;
esac
dnl Check PLIB library
AC_CHECK_LIB(plibul, ulInit, true,
AC_MSG_ERROR([there seems to be a problem with the PLIB libraries]))
LIBS="$plib_suffix $LIBS"
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADER(windows.h, AC_DEFINE(WIN32))
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
AC_CHECK_HEADERS(GL/gl.h GL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
;;
*-apple-darwin*)
dnl Mac OS X
AC_CHECK_HEADERS(OpenGL/gl.h OpenGL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
AC_CHECK_HEADER(GLUT/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
;;
*)
AC_CHECK_HEADERS(GL/gl.h GL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xyes"; then
AC_CHECK_HEADER(GL/freeglut.h, AC_DEFINE(FREEGLUT_IS_PRESENT),
AC_MSG_ERROR([freeglut header file not found]))
else
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
fi
;;
esac
AC_CHECK_HEADER(plib/ul.h,, AC_MSG_ERROR([PLIB header files not found]))
dnl Warning flags
WFLAG="-Wall"
case "$host" in
mips-sgi-irix*)
if test "x$CXX" = "xCC"; then
WFLAG="-fullwarn";
fi
;;
*)
if test "x$CXX" = "xicpc" || test "x$CXX" = "xicc"; then
WFLAG="-w1"
fi
;;
esac
CFLAGS="$CFLAGS $WFLAG"
CXXFLAGS="$CXXFLAGS $WFLAG"
AC_OUTPUT( Makefile \
data/Makefile \
doc/Makefile \
src/Makefile \
)

View File

@ -0,0 +1,7 @@
pkgdatadir = $(datadir)/games/@PACKAGE@/data
pkgdata_DATA = $(wildcard *.rgb *.ac *.bones)
EXTRA_DIST = $(pkgdata_DATA)

1539
demos/exposer/data/dog.ac Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
NUMBONES=24 NUMEVENTS=5 MAXTIME=3.392857 Z_OFFSET=0 SPEED=0
BONE "Tongue" HP.
BONE "WholeDog" H..
BONE "Nose" ...
BONE "Head" HPR
BONE "Body" H..
BONE "Tail" HP.
BONE "LeftEar" ..R
BONE "RightEar" ..R
BONE "FrLfShoulder" ...
BONE "FrRtShoulder" ...
BONE "BkLfHip" ...
BONE "BkRtHip" ...
BONE "FrLfLeg" .P.
BONE "FrLfKnee" .P.
BONE "FrLfFoot" HP.
BONE "FrRtLeg" .P.
BONE "FrRtKnee" .P.
BONE "FrRtFoot" HP.
BONE "BkLfLeg" .P.
BONE "BkLfKnee" .P.
BONE "BkLfFoot" .P.
BONE "BkRtLeg" HPR
BONE "BkRtKnee" .P.
BONE "BkRtFoot" .P.
EVENT 0.000000 24 (0,0,0)
(0,0,0)
(0,0,0)
(-8,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,14,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
EVENT 0.502870 24 (0,0,0)
(0,0,0)
(0,0,0)
(-8,0,0)
(11,-23,0)
(0,0,0)
(-28,-10,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,14,0)
(0,-24,0)
(21,-18,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
EVENT 1.005740 24 (0,0,0)
(0,0,0)
(0,0,0)
(-8,0,0)
(0,-30,0)
(0,0,0)
(-52,-10,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,14,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
EVENT 2.005421 24 (0,0,0)
(0,0,0)
(0,0,0)
(-8,0,0)
(51,0,0)
(0,0,0)
(51,-10,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,14,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
EVENT 3.000000 24 (0,0,0)
(0,0,0)
(0,0,0)
(-8,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,14,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)

1556
demos/exposer/data/human.ac Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
NUMBONES=18 NUMEVENTS=1 MAXTIME=10.000000 Z_OFFSET=-0.002791 SPEED=0.000000
BONE "Human" HPR
BONE "RtShoulder" HPR
BONE "RtArm" HPR
BONE "RtElbow" HPR
BONE "RtWrist" HPR
BONE "LfShoulder" HPR
BONE "LfArm" HPR
BONE "LfElbow" HPR
BONE "LfWrist" HPR
BONE "Neck" HPR
BONE "Head" HPR
BONE "Waist" HPR
BONE "RtHip" .P.
BONE "RtKnee" .P.
BONE "RtAnkle" .P.
BONE "LfHip" .P.
BONE "LfKnee" .P.
BONE "LfAnkle" .P.
EVENT 0.000000 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)

View File

@ -0,0 +1,133 @@
NUMBONES=18 NUMEVENTS=6 MAXTIME=1.474031 Z_OFFSET=-0.002791 SPEED=0.000000
BONE "Human" HPR
BONE "RtShoulder" ...
BONE "RtArm" HPR
BONE "RtElbow" HPR
BONE "RtWrist" HPR
BONE "LfShoulder" ...
BONE "LfArm" HPR
BONE "LfElbow" HPR
BONE "LfWrist" HPR
BONE "Neck" HPR
BONE "Head" HPR
BONE "Waist" HPR
BONE "RtHip" HP.
BONE "RtKnee" .P.
BONE "RtAnkle" .P.
BONE "LfHip" .P.
BONE "LfKnee" .P.
BONE "LfAnkle" .P.
EVENT 0.000000 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,0,71)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,-64)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
EVENT 0.150392 18 (0.000000,-0.462963,0.000000)
(0,-11,0)
(0,0,0)
(0,38,68)
(31,0,-4)
(0,0,0)
(0,0,0)
(0,32,-52)
(0,-2,-57)
(0,0,0)
(0,0,0)
(0,-34,0)
(0,30,0)
(0,18,0)
(0,0,0)
(0,-21,0)
(0,15,0)
(0,0,0)
(0,-17,0)
EVENT 0.299477 18 (0.000000,-0.648148,-0.462963)
(0,41,0)
(0,0,0)
(0,22,28)
(75,0,-4)
(87,0,-3)
(0,0,0)
(0,71,-32)
(0,22,-15)
(0,0,0)
(0,0,0)
(0,20,0)
(0,10,0)
(0,0,0)
(0,0,0)
(0,-21,0)
(0,4,0)
(0,0,0)
(0,-17,0)
EVENT 0.451177 18 (0.000000,-0.787037,-1.157408)
(0,90,0)
(0,0,0)
(40,-43,22)
(135,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,11,0)
(0,-19,0)
(0,-45,0)
(0,4,0)
(0,0,0)
(0,-17,0)
EVENT 0.681740 18 (0.000000,-0.787037,-1.157408)
(0,90,0)
(0,0,0)
(15,-59,22)
(19,-21,0)
(0,0,0)
(0,0,0)
(0,-42,0)
(0,0,0)
(0,-41,0)
(0,0,0)
(30,-20,0)
(0,0,0)
(0,16,0)
(0,-19,0)
(0,-45,0)
(0,8,0)
(0,-4,0)
(0,-17,0)
EVENT 0.994971 18 (0.000000,-0.787037,-1.157408)
(0,90,0)
(0,0,0)
(15,-59,22)
(19,-21,0)
(0,0,0)
(0,0,0)
(0,-42,0)
(0,0,0)
(0,-41,0)
(0,0,0)
(61,-20,0)
(0,0,0)
(25,0,0)
(0,0,0)
(0,-21,0)
(0,0,0)
(0,0,0)
(0,-12,0)

View File

@ -0,0 +1,171 @@
NUMBONES=18 NUMEVENTS=8 MAXTIME=1.402956 Z_OFFSET=-0.002791 SPEED=1.400000
BONE "Human" HPR
BONE "RtShoulder" ...
BONE "RtArm" HPR
BONE "RtElbow" HPR
BONE "RtWrist" HPR
BONE "LfShoulder" ...
BONE "LfArm" HPR
BONE "LfElbow" HPR
BONE "LfWrist" HPR
BONE "Neck" HPR
BONE "Head" HPR
BONE "Waist" HPR
BONE "RtHip" .P.
BONE "RtKnee" .P.
BONE "RtAnkle" .P.
BONE "LfHip" .P.
BONE "LfKnee" .P.
BONE "LfAnkle" .P.
EVENT 0.000000 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,-24,69)
(19,0,0)
(18,0,0)
(0,0,0)
(0,14,-73)
(-21,0,-4)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,-28,0)
(0,0,0)
(0,10,0)
(0,26,0)
(0,-20,0)
(0,0,0)
EVENT 0.195412 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,-11,69)
(19,0,0)
(18,0,0)
(0,0,0)
(0,-11,-73)
(-21,0,-4)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,5,0)
(0,-57,0)
(0,-21,0)
(0,11,0)
(0,0,0)
(0,0,0)
EVENT 0.400845 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,9,69)
(19,0,0)
(18,0,0)
(0,0,0)
(0,-30,-73)
(-21,0,-4)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,29,0)
(0,-60,0)
(0,-4,0)
(0,-4,0)
(0,-9,0)
(0,14,0)
EVENT 0.598762 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,18,69)
(34,-5,0)
(18,0,0)
(0,0,0)
(0,-45,-73)
(-21,0,-4)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,22,0)
(0,0,0)
(0,0,0)
(0,-24,0)
(0,-9,0)
(0,5,0)
EVENT 0.801689 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,9,69)
(23,-5,0)
(21,0,0)
(0,0,0)
(0,-33,-73)
(-21,0,-4)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,10,0)
(0,-9,0)
(0,-45,0)
(0,-16,0)
EVENT 1.004617 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,-8,69)
(23,-5,0)
(21,0,0)
(0,0,0)
(0,-23,-73)
(-21,0,-4)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,-16,0)
(0,0,0)
(0,25,0)
(0,38,0)
(0,-53,0)
(0,18,0)
EVENT 1.200028 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,-12,69)
(0,5,0)
(15,0,0)
(0,0,0)
(0,0,-73)
(-21,0,-4)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,-23,0)
(0,0,0)
(0,9,0)
(0,20,0)
(0,0,0)
(0,-8,0)
EVENT 1.402956 18 (0.000000,0.000000,0.000000)
(0,0,0)
(0,0,0)
(0,-24,69)
(19,0,0)
(18,0,0)
(0,0,0)
(0,15,-73)
(-21,0,-4)
(0,0,0)
(0,0,0)
(0,0,0)
(0,0,0)
(0,-28,0)
(0,0,0)
(0,10,0)
(0,26,0)
(0,-19,0)
(0,0,0)

Binary file not shown.

View File

@ -0,0 +1,7 @@
pkgdatadir = $(datadir)/games/@PACKAGE@/doc
pkgdata_DATA = $(wildcard *.*)
EXTRA_DIST = $(pkgdata_DATA)

BIN
demos/exposer/doc/bone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -0,0 +1,451 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Exposer Home Page</TITLE>
</HEAD>
<BODY text="#B5A642" link="#8FFF8F" vlink="#18A515" alink="#20336B" bgcolor="#005000" background="../../../doc/marble.png">
<TABLE>
<TR>
<TD>
<IMG SRC="exposer_logo.png" ALT="Exposer Logo" width=127 height=39>
<br>
</TD>
<TD>
<center>
<H1>
<FONT SIZE=9>E</FONT><FONT SIZE=5>X</FONT><FONT SIZE=9>P</FONT><FONT SIZE=5>OSER:</FONT>
<FONT SIZE=9>A</FONT>
<FONT SIZE=9>T</FONT><FONT SIZE=5>OOL FOR</FONT>
<FONT SIZE=9>A</FONT><FONT SIZE=5>NIMATING</FONT>
<FONT SIZE=9>PLIB</FONT>
<FONT SIZE=9>C</FONT><FONT SIZE=5>RITTERS.</FONT>
</H1>
</center>
</TD>
<TD>
<ul>
The foot bone's connected to the leg bone,<br>
The leg bone's connected to the knee bone,<br>
The knee bone's connected to the thigh bone,<br>
The thigh bone's connected to the back bone,<br>
The back bone's connected to the neck bone,<br>
The neck bone's connected to the head bone,<br>
Oh, hear the word of the Lord!<br>
<br>
-- Unknown (but incompetent) anatomist.
</ul>
<center>
<A href="http://sourceforge.net">
<IMG src="http://sourceforge.net/sflogo.php?group_id=382&type=1" width="88" height="31" border="0" ALT="Sourceforge Logo"></A>
</center>
</TD>
</TR>
</TABLE>
<H1>Introduction.</H1>
Exposer is a tool to allow you to perform fairly complex animations
of complex creatures with relative ease using the
<A HREF="http://plib.sf.net"> PLIB Scene Graph API</A>. Naturally,
Exposer is written using PLIB and generates output in several forms
that PLIB programs will find useful.
<p>
Exposer is totally unrelated to the Windows program 'poser'. The
name 'exposer' relates to the fact that this program used to be
called 'poser' until I heard of the existance of a Windows program
of the same name. This is therefore the ex-Poser program.
<p>
Exposer has a complex (but very powerful) GUI - you <b>WILL</b> need to
read this manual in order to take advantage of it.
<H2>Licensing.</H2>
Exposer is OpenSource software, issued under the terms of the
GNU Public License (GPL).
<H2>Installing and Running Exposer</H2>
Download ExPoser from the PLIB site:
<A HREF="http://plib.sf.net/dist/exposer-0.0.1.tar.gz">
http://plib.sf.net/dist/exposer-0.0.1.tar.gz</A>
<p>
Next, unpack the tarball containing the Exposer sources:
<pre>
tar xzvf exposer-0.0.1.tar.gz
</pre>
Then run the usual:
<pre>
./configure ; make
</pre>
(And you can optionally run 'make install' if you wish to fully
install the program rather than running it out of the installation
directory).
<p>
Then to run the program (without installing it) you could type
something like:
<pre>
src/exposer
</pre>
The program will prompt you to enter a 3D model file - the
ones in data with the extension '.ac' will do for starters.
<p>
Exposer can read any format that the PLIB library supports
that can contain both line and polygon objects.
<H2>So What Does It Do.</H2>
Well, right now, not a lot. The idea is that you can take an
arbitary polygonal model (typically of a person or animal of
some kind) and with minimal additional modelling effort be able
to animate it in your game or other interactive application.
<p>
The technique that exposer uses is 'skin and bones' animation
where the polygons of the model form the creatures 'skin' and
you model a set of line primitives inside the creature to make
a crude skeleton (the 'bones') much like the armature that a
sculptor would use.
<p>
Exposer therefore separates out the polygons and the lines in the
model you load (because your game will only be using the polygons)
and uses the lines to form a hierarchical structure of matrix
transformations. Exposer then assigns each vertex in the
skin to one of the bones (possibly more than one in the future)
according to distance - and then moves each vertex in accordance
with the matrix of the bone to which it's attached.
<p>
Exposer can optionally display each bone as a coloured cuboid and
provides a Heading/Pitch/Roll dial for each of them - but typically,
you'll only want to view the 'skin' - and that's the default.
By playing
with the coloured dials, you can move the bones in any way you like and
the skin will try to follow that movement as smoothly as possible.
<p>
One important issue is how the lines are assembled into a bone
heirarchy. Firstly, exactly ONE of the lines in the original
model must be painted RED. This bone is special because it's
the root of the bone hierarchy. Typically, this will be a
bone in the spine of a human or other mammal - but you might
choose it to be something else. You can "Make the Tail Wag
the Dog" by making the tailbone be the red one!
<p>
Once the program has found that red 'root' bone, it looks
for other lines that have one or other of their vertices
touching the root bone. Other lines can connect to the
root somewhere other than at the ends of that red line,
but your non-root bones MUST connect to it at their ends.
<p>
The program allows a 1% tolerance on this positioning so
bones don't have to be EXACTLY touching - but they do have
to be VERY close.
<p>
So, now we have the root bone and some other bones connected
to it - and now the program proceeds to expand out the
skeleton by treating all of the newly connected bones as
'root' and proceeding recursively from there.
<p>
In a sense, it's like reading the lines of the song at
the top of this page backwards:
<pre>
The back bone's...the RED bone,
The thigh bone's connected to the back bone,
The knee bone's connected to the thigh bone,
The leg bone's connected to the knee bone,
The foot bone's connected to the leg bone
</pre>
...although if it were me, I'd want a pelvis-bone and for
the sake of graphics, there wouldn't need to be a knee bone.
<p>
So, that's more or less it.
<H2>Controls.</H2>
Having loaded your first model, you'll see something like this:
<br>
<center><IMG SRC="exposer.png" ALT="ExPoser screenshot" width=400 height=300></center>
<br>
The rather nice shade of green is my favorite colour. If
you prefer shock-pink...bad luck - that's what source code
is for! The 3D model sits in the middle of the screen with
the GUI widgets floating in front of it.
<p>
There is an optional black and white chequerboard 'floor'.
<p>
Let's go through the GUI controls piece by piece:
<H3>The Menu Bar.</H3>
In the top-left, there is a pretty standard menu bar,
<br>
<center><IMG SRC="menu.png" ALT="Menu Bar" width=136 height=36></center>
<br>
The 'File' menu allows you to replace the model you are
working on with another, it also allows you to load
and save 'bone' files - which contain everything you
create in Exposer. Generally, these Bone files have
the same filename as the 3D model but with the extension
".bones". Exposer will fill that filename into the
file selector box - so you probably only have to hit "OK"
to load and save.
<p>
The 'View' menu lets you zoom into and out of the 'timeline'
which we'll come to later. The 'Time' menu has other
'timeline' operations.
<H3>The Bone Dials</H3>
To the left of the window are the bone dials - each coloured
row of GUI widgets represents one of the bones in your model.
<br>
<center><IMG SRC="bone.png" ALT="Bone Dials" width=225 height=60></center>
<br>
The button marked 'X' resets all of the angles of the bone
to zero - which will always be how your model was posed when
you created it. The 'H', 'P' and 'R' buttons let you freeze
and hide any of the three dials that you don't want to use
for that particular bone. This is useful for joints like
your elbow that can only flex in one degree of freedom.
<p>
The three dials represent the heading, pitch and roll
angles of the joint at the end of that bone nearest the
top of the bone connection hierarchy.
<p>
The rectangular area above the 'X/H/P/R' buttons can
be used to enter a short text string to identify the
bone. These strings are saved when you write out the
bone data and your application program might want to
read them to help identify what's what.
<p>
If you have more bones than will conveniently fit on the
screen, the scroll-bar to the left of the bone widgets
will allow you to scroll them up and down.
<H3>The Body Translators</H3>
Just below the meny bar, there are three sliders with
text display/entry areas that allow you to bodily
translate your model.
<br>
<center><IMG SRC="translate.png" ALT="Body Translators" width=226 height=74></center>
<br>
You should generally use this
for things like adding 'bounce' to a character's walk
sequence - it's not advisable to try to position your
character within it's world using this feature.
<H3>View Control</H3>
In the bottom-left corner of the screen are some
view controls. These can be used anytime to change
the view you have of the model - but they don't change
any actual data in the model or it's bones.
<br>
<center><IMG SRC="viewer.png" ALT="View Controls" width=198 height=63></center>
<br>
You can also use the 'Zoom' slider to move the model
closer or further away, and there are buttons marked
'Skin', 'Bones' and 'Floor' that let you toggle the display of
each of those things - so you can see just the skin,
just the bones or both (Or neither if you are
particularly perverse!) - with or without the floor
plane. The initial default is to show just the skin.
<p>
The 'Pan' and 'Tilt' dials allow you to move your
eyepoint around the model to view it from all sides
as it animates.
<H3>VCR Controls</H3>
In the bottom-right corner of the screen, there
are some VCR-like controls to play the animation,
pause it, play in reverse and to play at triple-speed
in forward or reverse.
<br>
<center><IMG SRC="vcr.png" ALT="VCR Controls" width=233 height=44></center>
<br>
You cannot adjust any joint angles in the model when
the animation is playing - so be sure to press the
downward arrow (STOP!) when you want to do editing.
<p>
There is a control to make the ground translate
along at a specified speed (in OpenGL-units-per-second).
This is useful if (for example) you want to animate
a running character that's you'll be moving at two
meters per second in your game. You need to move
the legs so that the feet move along at the same
speed as the ground or else it'll look like
'moonwalking'. Set the VCR's ground speed to match
the speed in the game and you'll be able to see if
the animation is going to work.
<H3>The TimeLine</H3>
This is a large rectangle taking up most of the bottom
edge of the screen:
<br>
<center><IMG SRC="timeline.png" ALT="TimeLine" width=130 height=102></center>
<br>
It has a number of functions, it starts up as a view
of a 10 second animation. Seconds are indicated by
the long tickmarks, tenth seconds by the short ones.
You can zoom into or out of the view or reset to seeing
the entire timeline using the 'View' menu in the menubar.
<p>
If you are zoomed into the timeline, a slider will appear
to allow you to scroll it left and right.
<p>
Magenta lines that extend across the full height of
the timeline indicate "events" - each event is a point
in time at which you have set the bone joint angles.
You can add an event by selecting 'Add an Event' in
the 'Time' menu and then clicking somewhere onto the
timeline to position it. One they are positioned, you
can click and drag events up and down the timeline to
change when they happen.
<p>
To change an event, click on it and it'll flash to
indicate that you have it selected. Then you can
adjust it using the bone dials. A common problem
is to try to edit a position without selecting it
first - make sure that the event is flashing on
the timeline.
<p>
Various operations on the 'selected' event are
available from the 'Time' menu.
<p>
You can also select a 'region' by left-clicking
on one end and right-clicking on the other. The
current region is highlighted in yellow. There
are operations that operate on the current region
in the 'Time' menu.
<p>
Wherever you click the left button on the timeline,
the model will move to that position - and the bone
dials will follow. You can drag the mouse up and
down the timeline to replay the animation at whatever
speed you move the mouse. However, to get a 'realistic'
playback speed, use the single arrows on the VCR
menu.
<p>
Remember though that you can only EDIT the position
of the model on a selected event.
<H3>Menu Operations on the Timeline.</H3>
The 'Time' menu allows you to add an event,
delete the selected event, delete ALL the events
in the 'region' that you have highlighted,
or delete the section of time in the 'region' -
compressing up the rest of the timeline to fit.
Finally, you can add more time to the timeline
so that you can create animations that are longer
than the ten seconds initially provided.
<H2>The Exposer ".bones" file format.</H2>
This is a very simple ASCII text file - however
the parser for it is VERY crude at this stage.
<p>
The first line of the file is:
<pre>
NUMBONES=17 NUMEVENTS=7 MAXTIME=10.0000 Z_OFFSET=1.3 SPEED=0.3
</pre>
So there are 17 bones, 7 events - and the
duration of the animation is ten seconds.
<p>
The Z_OFFSET is advice to the application about the
height of the origin of the model above the lowest
point on the model in it's default pose.
<p>
SPEED is the speed set on the VCR 'Ground Speed'
control - which the application can use to tell
at what speed the character should move forwards
in order to make the animation look right.
<p>
Then follows the bones - one per line:
<pre>
BONE "bone-name" HPR
</pre>
The 'bone-name' is the string you entered beside the
bone dials. The 'HPR' part sets which axes are frozen.
(in this case, none of them...the frozen axis letters
are replaced by dots).
<p>
After all the bones come the events. For each event
there is a header line:
<pre>
EVENT 3.0000 17 (0.000,0.000,0.000)
</pre>
The first number is the time (in seconds) at which the
event occurred, the second number is the number of bones
that are affected by this event. Currently this must be
the same as 'NUMBONES'. The coordinate in parentheses is
the body-translation of the model from the origin at this
moment in time.
<p>
After the event header, there is one line per bone
containing the three joint angles in degrees for
that bone at that time:
<pre>
(90,45,37)
</pre>
That's it! However, as I said - the parser is 'brittle'
and very intolerant of errors - edit the file at your
own peril!
<H2>Support Programs.</H2>
In the ExPoser directory, you'll also find a short
program called 'merge_bones' - this takes a number
of '.bones' files (listed in order on the command line)
and concatenates them end-to-end - placing the results
in the file 'out.bones'.
<p>
On stdout, it lists the header from each of the component
files. It is (of course) necessary that the '.bones'
files originated from the same 3D model - merge_bones
checks that things are consistant and warns of errors.
<H2>Some Advice</H2>
Bones don't necessarily have to be placed where the
bones would be in an anatomically correct version of
the critter. In the example 'dog.ac' file, there is
a tongue-bone and two ear-bones - and there are no ribs,
spinal vertibrae, etc.
<p>
You'll also probably need to hop back and forth between
your modeller and exposer to position the bones how you
want them. You'll find on occasions that the algorithm
that causes exposer to attach a skin vertex to the nearest
bone will sometimes result in part of a character's stomach
being attached to their hand or something. If that happens
then you might try adding some lateral bones
in the stomach to ensure that there is always one attached
to the spine that's closer to the skin than the hand is.
<p>
Artists should be encouraged to model the character in
a position with their legs wide apart and their arms
fully outstretched to minimise this kind of problem.
<p>
It is normal to model the character facing down the
positive Y axis - facing away from the camera.
<p>
Using the axis freeze buttons to isolate only those
axes through which a real joint can rotate is very
useful. A human elbow joint can really only
rotate through one axis and turning off the other two is
helpful.
<p>
You can also use Exposer for things other than animals.
You could model plants bending in a heavy wind - or
even flexible things like flags or clothing.
<hr>
<ADDRESS>
<A HREF="http://www.sjbaker.org">
Steve J. Baker.</A>
&lt;<A HREF="mailto:sjbaker1@airmail.net">sjbaker1@airmail.net</A>&gt;
</ADDRESS>
</BODY>
</HTML>

BIN
demos/exposer/doc/menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
demos/exposer/doc/vcr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

29
demos/exposer/exposer.dsw Normal file
View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "exposer"=.\src\exposer.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@ -0,0 +1,22 @@
# src/
bindir=$(prefix)/games
bin_PROGRAMS = exposer merge_tweens
exposer_SOURCES = \
exposer.cxx exposer.h \
floor.cxx floor.h \
vertices.cxx vertices.h \
boneGUI.cxx boneGUI.h \
load_save.cxx load_save.h \
timebox.cxx timebox.h \
bones.cxx bones.h \
event.cxx event.h \
model.cxx model.h
merge_tweens_SOURCES = \
merge_tweens.cxx merge_tweens.h
EXTRA_DIST = exposer.dsp

View File

@ -0,0 +1,305 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: boneGUI.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
#include "exposer.h"
static puSlider *XtranslateSlider ;
static puSlider *YtranslateSlider ;
static puSlider *ZtranslateSlider ;
static puInput *XtranslateInput ;
static puInput *YtranslateInput ;
static puInput *ZtranslateInput ;
static void jointHeadingCB ( puObject *ob )
{
Bone *bone = (Bone *) (ob->getUserData()) ;
float a ; ob -> getValue ( & a ) ;
bone->setAngle ( 0, a * 360.0f - 180.0f ) ;
setShowAngle ( a * 360.0f - 180.0f ) ;
}
static void jointPitchCB ( puObject *ob )
{
Bone *bone = (Bone *) (ob->getUserData()) ;
float a ; ob -> getValue ( & a ) ;
bone->setAngle ( 1, a * 360.0f - 180.0f ) ;
setShowAngle ( a * 360.0f - 180.0f ) ;
}
static void jointRollCB ( puObject *ob )
{
Bone *bone = (Bone *) (ob->getUserData()) ;
float a ; ob -> getValue ( & a ) ;
bone->setAngle ( 2, a * 360.0f - 180.0f ) ;
setShowAngle ( a * 360.0f - 180.0f ) ;
}
void hide_headingCB ( puObject *ob )
{
Bone *bone = (Bone *) (ob->getUserData()) ;
if ( ob -> getValue () )
bone -> sh -> hide () ;
else
bone -> sh -> reveal () ;
}
void hide_pitchCB ( puObject *ob )
{
Bone *bone = (Bone *) (ob->getUserData()) ;
if ( ob -> getValue () )
bone -> sp -> hide () ;
else
bone -> sp -> reveal () ;
}
void hide_rollCB ( puObject *ob )
{
Bone *bone = (Bone *) (ob->getUserData()) ;
if ( ob -> getValue () )
bone -> sr -> hide () ;
else
bone -> sr -> reveal () ;
}
static void resetCB ( puObject *ob )
{
Bone *bone = (Bone *) (ob->getUserData()) ;
bone -> setAngles ( 0, 0, 0 ) ;
}
void syncTranslators ( sgVec3 trans )
{
XtranslateSlider -> setValue ( trans [ 0 ] / 5.0f + 0.5f ) ;
YtranslateSlider -> setValue ( trans [ 1 ] / 5.0f + 0.5f ) ;
ZtranslateSlider -> setValue ( trans [ 2 ] / 5.0f + 0.5f ) ;
if ( ! XtranslateInput -> isAcceptingInput () )
XtranslateInput -> setValue ( trans [ 0 ] ) ;
if ( ! YtranslateInput -> isAcceptingInput () )
YtranslateInput -> setValue ( trans [ 1 ] ) ;
if ( ! ZtranslateInput -> isAcceptingInput () )
ZtranslateInput -> setValue ( trans [ 2 ] ) ;
}
static void currTranslateTxtXCB ( puObject *sl )
{
float v = sl -> getFloatValue () ;
if ( eventList->getCurrentEvent() == NULL ) return ;
sgVec3 xyz ;
eventList->getCurrentEvent() -> getTranslate ( xyz ) ;
xyz [ 0 ] = v ;
eventList->getCurrentEvent() -> setTranslate ( xyz ) ;
syncTranslators ( xyz ) ;
}
static void currTranslateTxtYCB ( puObject *sl )
{
float v = sl -> getFloatValue () ;
if ( eventList->getCurrentEvent() == NULL ) return ;
sgVec3 xyz ;
eventList->getCurrentEvent() -> getTranslate ( xyz ) ;
xyz [ 1 ] = v ;
eventList->getCurrentEvent() -> setTranslate ( xyz ) ;
syncTranslators ( xyz ) ;
}
static void currTranslateTxtZCB ( puObject *sl )
{
float v = sl -> getFloatValue () ;
if ( eventList->getCurrentEvent() == NULL ) return ;
sgVec3 xyz ;
eventList->getCurrentEvent() -> getTranslate ( xyz ) ;
xyz [ 2 ] = v ;
eventList->getCurrentEvent() -> setTranslate ( xyz ) ;
syncTranslators ( xyz ) ;
}
static void currTranslateXCB ( puObject *sl )
{
float v = (((puSlider *)sl) -> getFloatValue () - 0.5f ) * 5.0f ;
if ( eventList->getCurrentEvent() == NULL ) return ;
sgVec3 xyz ;
eventList->getCurrentEvent() -> getTranslate ( xyz ) ;
xyz [ 0 ] = v ;
eventList->getCurrentEvent() -> setTranslate ( xyz ) ;
syncTranslators ( xyz ) ;
}
static void currTranslateYCB ( puObject *sl )
{
float v = (((puSlider *)sl) -> getFloatValue () - 0.5f ) * 5.0f ;
if ( eventList->getCurrentEvent() == NULL ) return ;
sgVec3 xyz ;
eventList->getCurrentEvent() -> getTranslate ( xyz ) ;
xyz [ 1 ] = v ;
eventList->getCurrentEvent() -> setTranslate ( xyz ) ;
syncTranslators ( xyz ) ;
}
static void currTranslateZCB ( puObject *sl )
{
float v = (((puSlider *)sl) -> getFloatValue () - 0.5f ) * 5.0f ;
if ( eventList->getCurrentEvent() == NULL ) return ;
sgVec3 xyz ;
eventList->getCurrentEvent() -> getTranslate ( xyz ) ;
xyz [ 2 ] = v ;
eventList->getCurrentEvent() -> setTranslate ( xyz ) ;
syncTranslators ( xyz ) ;
}
void initBoneGUI ()
{
puText *message ;
ZtranslateInput = new puInput ( 5, 485, 80, 505 ) ;
ZtranslateInput -> setCallback ( currTranslateTxtZCB ) ;
ZtranslateSlider = new puSlider ( 80, 485, 120, FALSE ) ;
ZtranslateSlider -> setCBMode ( PUSLIDER_DELTA ) ;
ZtranslateSlider -> setDelta ( 0.01f ) ;
ZtranslateSlider -> setCallback ( currTranslateZCB ) ;
message = new puText ( 205,485 ) ; message->setLabel ( "Z" ) ;
YtranslateInput = new puInput ( 5, 505, 80, 525 ) ;
YtranslateInput -> setCallback ( currTranslateTxtYCB ) ;
YtranslateSlider = new puSlider ( 80, 505, 120, FALSE ) ;
YtranslateSlider -> setCBMode ( PUSLIDER_DELTA ) ;
YtranslateSlider -> setDelta ( 0.01f ) ;
YtranslateSlider -> setCallback ( currTranslateYCB ) ;
message = new puText ( 205,505 ) ; message->setLabel ( "Y" ) ;
XtranslateInput = new puInput ( 5, 525, 80, 545 ) ;
XtranslateInput -> setCallback ( currTranslateTxtXCB ) ;
XtranslateSlider = new puSlider ( 80, 525, 120, FALSE ) ;
XtranslateSlider -> setCBMode ( PUSLIDER_DELTA ) ;
XtranslateSlider -> setDelta ( 0.01f ) ;
XtranslateSlider -> setCallback ( currTranslateXCB ) ;
message = new puText ( 205,525 ) ; message->setLabel ( "X" ) ;
}
void Bone::createJoint ()
{
widget = new puGroup ( 0, 0 ) ;
rs = new puOneShot ( 0, 0, "x" ) ;
hb = new puButton (20, 0, "H" ) ;
pb = new puButton (40, 0, "P" ) ;
rb = new puButton (60, 0, "R" ) ;
sh = new puDial ( 80, 0, 40 ) ;
sp = new puDial ( 120, 0, 40 ) ;
sr = new puDial ( 160, 0, 40 ) ;
na = new puInput ( 0,20,80,40 ) ;
na->setUserData ( this ) ;
na->setColourScheme ( colour[0], colour[1], colour[2], 0.5f ) ;
rs->setUserData ( this ) ;
rs->setCallback ( resetCB ) ;
rs->setColourScheme ( colour[0], colour[1], colour[2], 0.5f ) ;
hb->setUserData ( this ) ;
hb->setCallback ( hide_headingCB ) ;
hb->setColourScheme ( colour[0], colour[1], colour[2], 0.5f ) ;
pb->setUserData ( this ) ;
pb->setCallback ( hide_pitchCB ) ;
pb->setColourScheme ( colour[0], colour[1], colour[2], 0.5f ) ;
rb->setUserData ( this ) ;
rb->setCallback ( hide_rollCB ) ;
rb->setColourScheme ( colour[0], colour[1], colour[2], 0.5f ) ;
sh->setUserData ( this ) ;
sh->setValue ( 0.5f ) ;
sh->setCallback ( jointHeadingCB ) ;
sh->setColourScheme ( colour[0], colour[1], colour[2], 0.5f ) ;
sp->setUserData ( this ) ;
sp->setValue ( 0.5f ) ;
sp->setCallback ( jointPitchCB ) ;
sp->setColourScheme ( colour[0], colour[1], colour[2], 0.5f ) ;
sr->setUserData ( this ) ;
sr->setValue ( 0.5f ) ;
sr->setCallback ( jointRollCB ) ;
sr->setColourScheme ( colour[0], colour[1], colour[2], 0.5f ) ;
widget -> close () ;
widget -> hide () ;
}

View File

@ -0,0 +1,32 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: boneGUI.h 1425 2002-08-17 23:58:38Z ude $
*/
void hide_headingCB ( puObject *ob ) ;
void hide_pitchCB ( puObject *ob ) ;
void hide_rollCB ( puObject *ob ) ;
void syncTranslators ( sgVec3 trans ) ;
void initBoneGUI () ;

278
demos/exposer/src/bones.cxx Normal file
View File

@ -0,0 +1,278 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: bones.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
#include "exposer.h"
static sgVec3 curr_translate = { 0.0f, 0.0f, 0.0f } ;
static ssgSimpleState *boneState = NULL ;
static Bone *bone = NULL ;
ssgSimpleState *getBoneState () { return boneState ; }
float *getCurrTranslate () { return curr_translate ; }
Bone *getBone ( int i ) { return & ( bone [ i ] ) ; }
void init_bones ()
{
if ( bone == NULL )
bone = new Bone [ 1000 ] ;
sgZeroVec3 ( curr_translate ) ;
}
Bone::Bone ()
{
parent = -1 ;
}
void Bone::read ( FILE *fd )
{
char name [ PUSTRING_MAX ] ;
char shb, spb, srb ;
fscanf ( fd, "BONE \"%s %c%c%c\n",
name, & shb, & spb, & srb ) ;
if ( name[strlen(name)-1] == '\"' )
name[strlen(name)-1] = '\0' ;
na -> setValue ( name ) ;
hb -> setValue ( (shb == 'H') ? 0 : 1 ) ;
pb -> setValue ( (spb == 'P') ? 0 : 1 ) ;
rb -> setValue ( (srb == 'R') ? 0 : 1 ) ;
hide_headingCB ( hb ) ;
hide_pitchCB ( pb ) ;
hide_rollCB ( rb ) ;
}
void Bone::write ( FILE *fd )
{
fprintf ( fd, "BONE \"%s\" %c%c%c\n",
na->getStringValue(),
hb->getValue() ? '.' : 'H',
pb->getValue() ? '.' : 'P',
rb->getValue() ? '.' : 'R' ) ;
}
void Bone::setAngles ( float h, float p, float r )
{
sgVec3 hpr ;
sgSetVec3 ( hpr, h, p, r ) ;
setAngles ( hpr ) ;
}
void Bone::setAngle ( int which, float a )
{
getXForm() -> hpr [ which ] = a ;
setAngles ( getXForm() -> hpr ) ;
}
void Bone::setAngles ( sgVec3 src )
{
sgCopyVec3 ( getXForm() -> hpr, src ) ;
}
float *Bone::getDialAngles ()
{
static sgVec3 dst ;
dst[0] = sh -> getFloatValue () * 360.0f - 180.0f ;
dst[1] = sp -> getFloatValue () * 360.0f - 180.0f ;
dst[2] = sr -> getFloatValue () * 360.0f - 180.0f ;
return dst ;
}
sgCoord *Bone::getXForm ( Event *prev, Event *next, float lerptime )
{
static sgCoord c ;
sgCoord *coord0 = prev->getBoneCoord ( id ) ;
sgCoord *coord1 = next->getBoneCoord ( id ) ;
sgCopyVec3 ( c.xyz, xlate ) ;
sgLerpAnglesVec3 ( c.hpr, coord0->hpr, coord1->hpr, lerptime ) ;
sh -> setValue ( (c.hpr[0] + 180.0f) / 360.0f ) ;
sp -> setValue ( (c.hpr[1] + 180.0f) / 360.0f ) ;
sr -> setValue ( (c.hpr[2] + 180.0f) / 360.0f ) ;
return & c ;
}
sgCoord *Bone::getXForm ()
{
if ( eventList->getCurrentEvent() != NULL )
{
sgCoord *coord = eventList->getCurrentEvent()->getBoneCoord ( id ) ;
sgCopyVec3 ( coord->xyz, xlate ) ;
return coord ;
}
static sgCoord coord ;
sgZeroCoord ( & coord ) ;
sgCopyVec3 ( coord.xyz, xlate ) ;
return &coord ;
}
void Bone::computeTransform ( Event *prev, Event *next, float t )
{
effector -> setTransform ( getXForm( prev, next, t ) ) ;
}
void Bone::transform ( sgVec3 dst, sgVec3 src )
{
sgXformPnt3 ( dst, src, netMatrix ) ;
sgAddVec3 ( dst, curr_translate ) ;
}
void Bone::swapEnds()
{
sgVec3 tmp ;
/* Swap vertices so that vx0 is always the root. */
sgCopyVec3 ( tmp, vx[0] ) ;
sgCopyVec3 ( vx[0], vx[1] ) ;
sgCopyVec3 ( vx[1], tmp ) ;
sgCopyVec3 ( tmp, orig_vx[0] ) ;
sgCopyVec3 ( orig_vx[0], orig_vx[1] ) ;
sgCopyVec3 ( orig_vx[1], tmp ) ;
}
void Bone::init ( ssgLeaf *l, sgMat4 newmat, short vv[2], int ident )
{
parent = -1 ;
sgCopyVec3 ( vx [ 0 ], l -> getVertex ( vv[0] ) ) ;
sgCopyVec3 ( vx [ 1 ], l -> getVertex ( vv[1] ) ) ;
sgXformPnt3 ( vx [ 0 ], newmat ) ;
sgXformPnt3 ( vx [ 1 ], newmat ) ;
sgCopyVec3 ( orig_vx [ 0 ], vx [ 0 ] ) ;
sgCopyVec3 ( orig_vx [ 1 ], vx [ 1 ] ) ;
id = ident ;
if ( sgEqualVec3 ( vx [ 0 ], vx [ 1 ] ) )
fprintf ( stderr, "exposer: Zero length bone found.\n" ) ;
}
void Bone::print ( FILE *fd, int which )
{
fprintf ( fd, "Bone %d: vx (%f,%f,%f) -> (%f,%f,%f) Parent = %d\n",
which,
vx[0][0],vx[0][1],vx[0][2],
vx[1][0],vx[1][1],vx[1][2],
parent ) ;
}
#define NUM_COLOURS 13
static sgVec4 colourTable [] =
{
{ 1, 0, 0, 0.3f }, { 0, 1, 0, 0.3f }, { 0, 0, 1, 0.3f },
{ 1, 1, 0, 0.3f }, { 1, 0, 1, 0.3f }, { 0, 1, 1, 0.3f },
{ 0.5f, 0.5f, 0.5f, 0.3f },
{ 1, 0.5f, 0.5f, 0.3f }, { 0.5f, 1 , 0.5f, 0.3f }, { 0.5f, 0.5f, 1, 0.3f },
{ 1, 1 , 0.5f, 0.3f }, { 1 , 0.5f, 1 , 0.3f }, { 0.5f, 1, 1, 0.3f }
} ;
ssgBranch *Bone::generateGeometry ( int root )
{
static int nextColIndex = 0 ;
ssgTransform *b = new ssgTransform ;
b -> setUserData ( this ) ;
effector = b ;
sgZeroVec3 ( getXForm()->hpr ) ;
sgCopyVec3 ( xlate, vx[0] ) ;
sgZeroVec3 ( vx[0] ) ;
sgSubVec3 ( vx[1], xlate ) ;
sgMat4 mat ;
sgMakeCoordMat4 ( mat, getXForm() ) ;
b -> setTransform ( mat ) ;
offsetChildBones ( root, xlate ) ;
sgCopyVec4 ( colour, colourTable[nextColIndex] ) ;
createJoint () ;
ssgaCube *shape = new ssgaCube () ;
sgVec3 org ; sgCopyVec3 ( org, vx[1] ) ;
sgVec3 siz ; sgCopyVec3 ( siz, vx[1] ) ;
sgScaleVec3 ( org, 0.5 ) ;
siz[0] = (float)fabs ( siz[0] ) ; if ( siz[0] <= 0.1f ) siz [ 0 ] = 0.1f ;
siz[1] = (float)fabs ( siz[1] ) ; if ( siz[1] <= 0.1f ) siz [ 1 ] = 0.1f ;
siz[2] = (float)fabs ( siz[2] ) ; if ( siz[2] <= 0.1f ) siz [ 2 ] = 0.1f ;
if ( boneState == NULL )
{
boneState = new ssgSimpleState () ;
boneState -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ;
boneState -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
boneState -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ;
boneState -> enable ( GL_BLEND ) ;
}
shape -> setCenter ( org ) ;
shape -> setSize ( siz ) ;
shape -> setColour ( colourTable[nextColIndex] ) ;
shape -> setKidState ( boneState ) ;
nextColIndex = ( nextColIndex + 1 ) % NUM_COLOURS ;
b -> addKid ( shape ) ;
for ( int i = 0 ; i < getNumBones() ; i++ )
if ( i != root && getBone(i)->parent == root )
b -> addKid ( getBone(i)->generateGeometry ( i ) ) ;
return b ;
}

84
demos/exposer/src/bones.h Normal file
View File

@ -0,0 +1,84 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: bones.h 1425 2002-08-17 23:58:38Z ude $
*/
#define ROOT_BONE 9999
class Bone : public ssgBase
{
public:
int id ;
int parent ;
ssgTransform *effector ;
sgVec3 xlate ;
sgMat4 netMatrix ;
sgVec3 vx [ 2 ] ; /* Relative to joint */
sgVec3 orig_vx [ 2 ] ; /* Absolute */
puGroup *widget ;
puOneShot *rs ;
puButton *hb ;
puButton *pb ;
puButton *rb ;
puDial *sh ;
puDial *sp ;
puDial *sr ;
puInput *na ;
sgVec4 colour ;
Bone () ;
void read ( FILE *fd ) ;
void write ( FILE *fd ) ;
void createJoint () ;
void computeTransform ( Event *prev, Event *next, float tim ) ;
void setAngle ( int which, float a ) ;
void setAngles ( float h, float p, float r ) ;
void setAngles ( sgVec3 a ) ;
float *getXYZ () { return xlate ; }
float *getDialAngles () ;
sgCoord *getXForm ( Event *prev, Event *next, float tim ) ;
sgCoord *getXForm () ;
void transform ( sgVec3 dst, sgVec3 src ) ;
void swapEnds() ;
void init ( ssgLeaf *l, sgMat4 newmat, short vv[2], int id ) ;
void print ( FILE *fd, int which ) ;
ssgBranch *generateGeometry ( int root ) ;
} ;
void init_bones () ;
void setShowAngle ( float a ) ;
float *getCurrTranslate () ;
Bone *getBone ( int i ) ;
ssgSimpleState *getBoneState () ;

300
demos/exposer/src/event.cxx Normal file
View File

@ -0,0 +1,300 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: event.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
#include "exposer.h"
void EventList::read ( int nevents, FILE *fd )
{
for ( int i = 0 ; i < nevents ; i++ )
{
Event *e = new Event ( getNumBones(), (float) i ) ;
e -> read ( fd ) ;
addEvent ( e ) ;
}
}
void EventList::write ( FILE *fd )
{
for ( int i = 0 ; i < getNumEvents () ; i++ )
getEvent ( i ) -> write ( fd ) ;
}
void EventList::moveEvent ( Event *e, float new_time )
{
removeEvent ( e ) ;
e -> setTime ( new_time ) ;
addEvent ( e ) ;
}
void EventList::newEvent ( float t )
{
if ( getNumBones () <= 0 )
return ;
setCurrentEvent ( new Event ( getNumBones (), t ) ) ;
addEvent ( getCurrentEvent () ) ;
}
void EventList::deleteEvent ( Event *e )
{
if ( e == NULL )
return ;
if ( e == curr_event )
curr_event = NULL ;
removeEvent ( e ) ;
delete e ;
}
void EventList::compressEventsBetween ( float t1, float t2 )
{
deleteEventsBetween ( t1, t2 ) ;
for ( int i = 0 ; i < getNumEvents() ; i++ )
{
Event *ev = getEvent ( i ) ;
float t = ev -> getTime () ;
if ( t > t1 || t > t2 )
ev -> setTime ( t - (float)fabs(t1-t2) ) ;
}
}
int EventList::getNumEventsBetween ( float t1, float t2 )
{
int nevents = 0 ;
for ( int i = 0 ; i < getNumEvents() ; i++ )
{
float t = getEvent ( i ) -> getTime () ;
if ( ( t1 < t2 && t >= t1 && t <= t2 ) ||
( t2 < t1 && t >= t2 && t <= t1 ) )
nevents++ ;
}
return nevents ;
}
int EventList::getEventsBetween ( float t1, float t2, Event ***elist )
{
int nevents = getNumEventsBetween ( t1, t2 ) ;
if ( nevents == 0 )
{
elist = NULL ;
return 0 ;
}
/* Make a list of the events */
*elist = new Event* [ nevents ] ;
nevents = 0 ;
for ( int i = 0 ; i < getNumEvents() ; i++ )
{
Event *ev = getEvent ( i ) ;
float t = ev -> getTime () ;
if ( ( t1 < t2 && t >= t1 && t <= t2 ) ||
( t2 < t1 && t >= t2 && t <= t1 ) )
(*elist) [ nevents++ ] = ev ;
}
return nevents ;
}
void EventList::deleteEventsBetween ( float t1, float t2 )
{
int found_one = FALSE ;
do
{
found_one = FALSE ;
for ( int i = 0 ; i < getNumEvents() && ! found_one ; i++ )
{
Event *ev = getEvent ( i ) ;
float t = ev -> getTime () ;
if ( ( t1 < t2 && t >= t1 && t <= t2 ) ||
( t2 < t1 && t >= t2 && t <= t1 ) )
{
deleteEvent ( ev ) ;
found_one = TRUE ;
}
}
} while ( found_one ) ;
}
void EventList::reverseEventsBetween ( float t1, float t2 )
{
/* Make a list of the events */
Event **elist ;
int nevents = getEventsBetween ( t1, t2, &elist ) ;
if ( nevents == 0 )
return ;
/* Reverse their order */
for ( int i = 0 ; i < nevents ; i++ )
{
Event *ev = elist [ i ] ;
removeEvent ( ev ) ;
float t = ev -> getTime () ;
if ( t1 > t2 )
t = t1 - ( t - t2 ) ;
else
t = t2 - ( t - t1 ) ;
ev -> setTime ( t ) ;
addEvent ( ev ) ;
}
delete [] elist ;
}
void EventList::addEvent ( Event *e )
{
/*
Keep list in time-increasing order.
*/
for ( int i = 0 ; i < getNumEvents() ; i++ )
if ( e -> getTime() < getEvent(i)->getTime() )
{
addEntityBefore ( i, e ) ;
return ;
}
addEntity ( e ) ;
}
Event *EventList::findNearestEvent ( float t, float tolerance )
{
int nearest = -1 ;
float min = FLT_MAX ;
for ( int i = 0 ; i < getNumEvents() ; i++ )
{
float t2 = getEvent(i)->getTime() ;
float diff = (float) fabs ( t - t2 ) ;
if ( diff < min )
{
min = diff ;
nearest = i ;
}
}
return ( nearest >= 0 && min < tolerance ) ? getEvent ( nearest ) : NULL ;
}
void EventList::deleteAll ()
{
while ( getNumEvents() > 0 )
deleteEvent ( getEvent ( 0 ) ) ;
}
EventList::EventList ()
{
curr_event = NULL ;
}
Event::Event ( int n, float t )
{
time = t ;
nbones = n ;
bone_angles = new sgCoord [ n ] ;
sgCopyVec3 ( translate, getCurrTranslate() ) ;
for ( int i = 0 ; i < n ; i++ )
{
sgCopyVec3 ( bone_angles [ i ] . hpr, getBone(i)->getDialAngles() ) ;
sgCopyVec3 ( bone_angles [ i ] . xyz, getBone(i)->getXYZ() ) ;
}
}
void Event::read ( FILE *fd )
{
fscanf ( fd, "EVENT %f %d (%f,%f,%f)\n", &time, &nbones,
&translate[0], &translate[1], &translate[2] ) ;
for ( int i = 0 ; i < nbones ; i++ )
{
int ssh, ssp, ssr ;
fscanf ( fd, " (%d,%d,%d)\n", & ssh, & ssp, & ssr ) ;
sgSetVec3 ( bone_angles [ i ] . hpr, (float)ssh, (float)ssp, (float)ssr ) ;
sgCopyVec3 ( bone_angles [ i ] . xyz, getBone(i)->getXYZ() ) ;
}
}
void Event::write ( FILE *fd )
{
fprintf ( fd, "EVENT %f %d (%f,%f,%f)\n", time, nbones,
translate[0], translate[1], translate[2] ) ;
for ( int i = 0 ; i < nbones ; i++ )
{
fprintf ( fd, " (%d,%d,%d)\n",
(int) bone_angles [ i ] . hpr[0],
(int) bone_angles [ i ] . hpr[1],
(int) bone_angles [ i ] . hpr[2] ) ;
}
}

102
demos/exposer/src/event.h Normal file
View File

@ -0,0 +1,102 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: event.h 1425 2002-08-17 23:58:38Z ude $
*/
class Event
{
float time ;
int nbones ;
sgCoord *bone_angles ;
sgVec3 translate ;
public:
Event ( int n, float t ) ;
~Event () { delete [] bone_angles ; }
void read ( FILE *fd ) ;
void write ( FILE *fd ) ;
void setTranslate ( sgVec3 tra ) { sgCopyVec3 ( translate, tra ) ; }
void getTranslate ( sgVec3 tra ) { sgCopyVec3 ( tra, translate ) ; }
void setBoneAngles ( int n, sgVec3 angles )
{
if ( n < nbones )
sgCopyVec3 ( bone_angles[n].hpr, angles ) ;
}
void getBoneAngles ( int n, sgVec3 angles )
{
if ( n < nbones )
sgCopyVec3 ( angles, bone_angles[n].hpr ) ;
else
sgZeroVec3 ( angles ) ;
}
sgCoord *getBoneCoord ( int n ) { return & ( bone_angles [ n ] ) ; }
void setTime ( float t ) { time = t ; }
float getTime () { return time ; }
} ;
class EventList : public ulList
{
Event *curr_event ;
public:
EventList () ;
int getNumEvents () { return getNumEntities () ; }
void addEvent ( Event *e ) ;
void newEvent ( float t ) ;
Event *findNearestEvent ( float t, float tolerance ) ;
void moveEvent ( Event *e, float new_time ) ;
void removeEvent ( Event *e ) { removeEntity ( e ) ; }
void setCurrentEvent ( Event *ev ) { curr_event = ev ; }
Event *getEvent ( int i ) { return (Event *) getEntity ( i ) ; }
void deleteEvent ( Event *e ) ;
void deleteAll () ;
Event *getCurrentEvent () { return curr_event ; }
void deleteCurrentEvent() { deleteEvent ( curr_event ) ; }
int getNumEventsBetween ( float t1, float t2 ) ;
int getEventsBetween ( float t1, float t2, Event ***elist ) ;
void reverseEventsBetween ( float t1, float t2 ) ;
void deleteEventsBetween ( float t1, float t2 ) ;
void compressEventsBetween( float t1, float t2 ) ;
void write ( FILE *fd ) ;
void read ( int nevents, FILE *fd ) ;
} ;

View File

@ -0,0 +1,480 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: exposer.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
#include "exposer.h"
static int curr_button = 0 ;
static int scroll_controllers = 0 ;
EventList * eventList = NULL ;
TimeBox * timebox = NULL ;
Floor * ground = NULL ;
ssgRoot * skinScene = NULL ;
ssgRoot *tweenScene = NULL ;
ssgRoot * boneScene = NULL ;
ssgRoot *sceneScene = NULL ;
static puText *message ;
static puButton *hideBones ;
static puButton *hideSkin ;
static puButton *hideGround ;
static puButton *hideScene ;
static puSlider *scroller ;
static puMenuBar *menuBar ;
static puSlider *rangeSlider ;
static puDial * panSlider ;
static puDial * tiltSlider ;
static puInput *show_angle ;
static void save_60th_CB ( puObject * ) { setTweenInterval ( 1.0f/60.0f ) ; }
static void save_30th_CB ( puObject * ) { setTweenInterval ( 1.0f/30.0f ) ; }
static void save_20th_CB ( puObject * ) { setTweenInterval ( 1.0f/20.0f ) ; }
static void save_15th_CB ( puObject * ) { setTweenInterval ( 1.0f/15.0f ) ; }
static void save_10th_CB ( puObject * ) { setTweenInterval ( 1.0f/10.0f ) ; }
static void save_8th_CB ( puObject * ) { setTweenInterval ( 1.0f/ 8.0f ) ; }
static void save_4th_CB ( puObject * ) { setTweenInterval ( 1.0f/ 4.0f ) ; }
static void save_2th_CB ( puObject * ) { setTweenInterval ( 1.0f/ 2.0f ) ; }
static void save_1th_CB ( puObject * ) { setTweenInterval ( 1.0f ) ; }
void setShowAngle ( float a )
{
show_angle -> setValue ( a ) ;
show_angle -> rejectInput () ;
}
static void update_eye_motion ()
{
float r ; rangeSlider -> getValue ( & r ) ; r *= 100.0f ; r += 2.0f ;
float h ; panSlider -> getValue ( & h ) ; h *= 360.0f ; h += 180.0f ;
float p ; tiltSlider -> getValue ( & p ) ; p *= 360.0f ; p += 180.0f ;
sgMat4 mat ;
sgVec3 vec ;
sgMakeCoordMat4 ( mat, 0, 0, 0, h, p, 0 ) ;
sgSetVec3 ( vec, 0, r * 20, 0 ) ;
sgXformPnt3 ( vec, mat ) ;
sgNegateVec3 ( vec ) ;
sgCopyVec3 ( mat[3], vec ) ;
ssgSetCamera ( mat ) ;
transformModel ( boneScene, timebox->getCursorTime () ) ;
}
static void reshape ( int w, int h )
{
glViewport ( 0, 0, w, h ) ;
ssgSetFOV ( 60.0f, 60.0f * (float) h / (float) w ) ;
}
static void specialfn ( int key, int, int )
{
puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;
}
static void keyfn ( unsigned char key, int, int )
{
puKeyboard ( key, PU_DOWN ) ;
}
static void passmotionfn ( int x, int y )
{
puMouse ( x, y ) ;
}
static void motionfn ( int x, int y )
{
puMouse ( x, y ) ;
timebox->updateEventQueue ( curr_button, x, y, FALSE ) ;
}
static void mousefn ( int button, int updown, int x, int y )
{
puMouse ( button, updown, x, y ) ;
curr_button = button ;
timebox->updateEventQueue ( curr_button, x, y, updown == PU_DOWN ) ;
}
static void scrollerCB ( puObject *ob )
{
scroll_controllers = (int)(((float)getNumBones()) * ob -> getFloatValue ()) ;
}
static void exitCB ( puObject *ob )
{
if ( ob -> getValue () )
exit ( 1 ) ;
}
/*
CALLBACK FUNCTIONS FOR GUI.
*/
static void deleteEventCB ( puObject * ) { timebox -> deleteEvent () ; }
static void addNewEventCB ( puObject * ) { timebox -> addNewEvent () ; }
static void reverseRegionCB ( puObject * ) { timebox -> reverseRegion () ; }
// static void deleteAllCB ( puObject * ) { timebox -> deleteAll () ; }
static void deleteRegionCB ( puObject * ) { timebox -> deleteRegion () ; }
static void deleteRegionAndCompressCB ( puObject * )
{ timebox -> deleteRegionAndCompress () ; }
static void zoom_nrm_CB ( puObject * ) { timebox -> setZoom ( 1.0f ) ; }
static void zoom_in_CB ( puObject * ) { timebox -> setZoom (
timebox -> getZoom () * 1.5f ) ; }
static void zoom_out_CB ( puObject * ) { float scale = timebox->getZoom() / 1.5f ;
timebox -> setZoom ( ( scale <= 1.0f ) ? 1.0f : scale ) ; }
static void add_1_CB ( puObject * ) {timebox->setMaxTime(timebox->getMaxTime()+1.0f);}
static void add_2_CB ( puObject * ) {timebox->setMaxTime(timebox->getMaxTime()+2.0f);}
static void add_5_CB ( puObject * ) {timebox->setMaxTime(timebox->getMaxTime()+5.0f);}
static void opaqueBones ()
{
if ( getBoneState() != NULL )
getBoneState() -> disable ( GL_BLEND ) ;
}
static void blendBones ()
{
if ( getBoneState() != NULL )
getBoneState() -> enable ( GL_BLEND ) ;
}
/* GLUT callbacks */
static void redraw ()
{
int i ;
timebox->updateVCR () ;
update_eye_motion () ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
glEnable ( GL_DEPTH_TEST ) ;
if ( ! hideScene -> getValue () && sceneScene != NULL )
ssgCullAndDraw ( sceneScene ) ;
if ( ! hideGround -> getValue () )
ground -> draw () ;
if ( ! hideSkin -> getValue () )
{
ssgCullAndDraw ( skinScene ) ;
blendBones () ;
}
else
opaqueBones () ;
if ( ! hideBones -> getValue () )
{
glClear ( GL_DEPTH_BUFFER_BIT ) ;
ssgCullAndDraw ( boneScene ) ;
}
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
glAlphaFunc ( GL_GREATER, 0.1f ) ;
glEnable ( GL_BLEND ) ;
glDisable ( GL_DEPTH_TEST ) ;
for ( i = 0 ; i < getNumBones() ; i++ )
getBone ( i ) -> widget -> hide () ;
for ( i = 0 ; i < 10 && i+scroll_controllers < getNumBones() ; i++ )
{
getBone ( i + scroll_controllers ) -> widget -> setPosition ( 24, 70+i*40);
if ( eventList -> getCurrentEvent() == NULL )
{
getBone ( i + scroll_controllers ) -> widget -> reveal () ;
getBone ( i + scroll_controllers ) -> widget -> greyOut () ;
}
else
{
getBone ( i + scroll_controllers ) -> widget -> reveal () ;
getBone ( i + scroll_controllers ) -> widget -> activate () ;
}
}
puDisplay () ;
timebox -> draw () ;
glutPostRedisplay () ;
glutSwapBuffers () ;
}
/* Menu bar entries: */
static char *file_submenu [] = { "Exit",
"------------",
"Save Tweened Model As...",
"Save Bones As...",
"Load Bones",
"Load Scenery",
"Load Model",
NULL } ;
static puCallback file_submenu_cb [] = { exitCB,
NULL,
twsaveCB,
bnsaveCB,
bnloadCB,
scloadCB,
loadCB,
NULL } ;
static char *view_submenu [] = { "Zoom Timeline In",
"Zoom Timeline Out",
"Zoom Timeline 1:1",
NULL } ;
static puCallback view_submenu_cb [] = { zoom_in_CB,
zoom_out_CB,
zoom_nrm_CB,
NULL } ;
static char *pref_submenu [] = { "1/60th second",
"1/30th second",
"1/20th second",
"1/15th second",
"1/10th second",
"eighth second",
"quarter second",
"half second",
"second",
"Save a tween bank every...",
NULL } ;
static puCallback pref_submenu_cb [] = { save_60th_CB,
save_30th_CB,
save_20th_CB,
save_15th_CB,
save_10th_CB,
save_8th_CB,
save_4th_CB,
save_2th_CB,
save_1th_CB,
NULL,
NULL } ;
static char *time_submenu [] = { "Add 5 seconds",
"Add 2 seconds",
"Add 1 second",
"------------",
"Reverse region",
"Delete region & compress",
"Delete region",
"Delete selected event",
"Add new event",
NULL } ;
static puCallback time_submenu_cb [] = { add_5_CB,
add_2_CB,
add_1_CB,
NULL,
reverseRegionCB,
deleteRegionAndCompressCB,
deleteRegionCB,
deleteEventCB,
addNewEventCB,
NULL } ;
static void init_graphics ()
{
int fake_argc = 1 ;
char *fake_argv[3] ;
fake_argv[0] = "ExPoser" ;
fake_argv[1] = "ExPoser - Skin and Bones animation for PLIB." ;
fake_argv[2] = NULL ;
/* Initialise GLUT */
glutInitWindowPosition ( 0, 0 ) ;
glutInitWindowSize ( 800, 600 ) ;
glutInit ( &fake_argc, fake_argv ) ;
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
glutCreateWindow ( fake_argv[1] ) ;
glutDisplayFunc ( redraw ) ;
glutReshapeFunc ( reshape ) ;
glutKeyboardFunc ( keyfn ) ;
glutSpecialFunc ( specialfn ) ;
glutMouseFunc ( mousefn ) ;
glutMotionFunc ( motionfn ) ;
glutPassiveMotionFunc ( passmotionfn ) ;
/* Initialise SSG & PUI */
ssgInit () ;
puInit () ;
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
puSetDefaultFonts ( PUFONT_HELVETICA_10, PUFONT_HELVETICA_10 ) ;
/* Some basic OpenGL setup */
glClearColor ( 0.2f, 0.5f, 0.2f, 1.0f ) ;
ssgSetFOV ( 60.0f, 0.0f ) ;
ssgSetNearFar ( 0.1f, 700.0f ) ;
/* Set up the Sun. */
sgVec3 sunposn ;
sgSetVec3 ( sunposn, 0.2f, 0.5f, 0.5f ) ;
ssgGetLight ( 0 ) -> setPosition ( sunposn ) ;
/* GUI setup. */
timebox = new TimeBox ( eventList ) ;
ground = new Floor () ;
menuBar = new puMenuBar () ;
{
menuBar -> add_submenu ( "File", file_submenu, file_submenu_cb ) ;
menuBar -> add_submenu ( "View", view_submenu, view_submenu_cb ) ;
menuBar -> add_submenu ( "Time", time_submenu, time_submenu_cb ) ;
menuBar -> add_submenu ( "SavePrefs", pref_submenu, pref_submenu_cb ) ;
}
menuBar -> close () ;
show_angle = new puInput ( 5, 560, 80, 580 ) ;
show_angle -> setValue ( "" ) ;
show_angle -> rejectInput () ;
message = new puText ( 80, 560 ) ;
message -> setLabel ( "Angle" ) ;
scroller = new puSlider ( 5, 70, 400, TRUE ) ;
scroller -> setCBMode ( PUSLIDER_DELTA ) ;
scroller -> setDelta ( 0.01f ) ;
scroller -> setCallback ( scrollerCB ) ;
panSlider = new puDial ( 0, 0, 40 ) ;
panSlider -> setCBMode ( PUSLIDER_DELTA ) ;
panSlider -> setDelta ( 0.01f ) ;
panSlider -> setValue ( 0.5f ) ;
message = new puText ( 0, 40 ) ;
message -> setColour ( PUCOL_LABEL, 0.7f,0.65f,0.26f,1 ) ;
message -> setLabel ( "Pan" ) ;
tiltSlider = new puDial ( 40, 0, 40 ) ;
tiltSlider -> setCBMode ( PUSLIDER_DELTA ) ;
tiltSlider -> setDelta ( 0.01f ) ;
tiltSlider -> setValue ( 0.5f ) ;
message = new puText ( 40, 40 ) ;
message -> setColour ( PUCOL_LABEL, 0.7f,0.65f,0.26f,1 ) ;
message -> setLabel ( "Tilt" ) ;
hideBones = new puButton ( 80, 0, "Bones" ) ;
hideBones -> setValue ( TRUE ) ;
hideSkin = new puButton ( 119, 0, "Skin" ) ;
hideSkin -> setValue ( FALSE ) ;
hideGround = new puButton ( 149, 0, "Floor" ) ;
hideGround -> setValue ( FALSE ) ;
hideScene = new puButton ( 183, 0, "Scene" ) ;
hideScene -> setValue ( FALSE ) ;
rangeSlider = new puSlider ( 80, 20, 141, FALSE ) ;
rangeSlider -> setCBMode ( PUSLIDER_DELTA ) ;
rangeSlider -> setDelta ( 0.01f ) ;
message = new puText ( 80, 40 ) ;
message -> setColour ( PUCOL_LABEL, 0.7f,0.65f,0.26f,1 ) ;
message -> setLabel ( "Zoom" ) ;
}
static void init_database ()
{
skinScene = new ssgRoot ;
boneScene = new ssgRoot ;
}
static void help ()
{
fprintf ( stderr, "\n" ) ;
fprintf ( stderr, "exposer: Interactive Usage -\n" ) ;
fprintf ( stderr, " exposer\n\n" ) ;
fprintf ( stderr, " ...or...\n\n" ) ;
fprintf ( stderr, "exposer: Batch Tweenfile generation Usage -\n" ) ;
fprintf ( stderr, " exposer -f framerate modelfile bonefile tweenfile\n" );
fprintf ( stderr, "\n" ) ;
}
int main ( int argc, char **argv )
{
eventList = new EventList ;
init_graphics () ;
init_database () ;
init_bones () ;
initBoneGUI () ;
/* Interactive? */
if ( argc <= 1 )
{
loadCB ( NULL ) ;
glutPostRedisplay () ;
glutMainLoop () ;
return 0 ;
}
if ( argc != 6 || strcmp ( argv [ 1 ], "-f" ) != 0 ||
atof ( argv [ 2 ] ) > 100.0f || atof ( argv[2] ) < 0.1f )
{
help () ;
return 1 ;
}
setTweenInterval ( 1.0f / (float)atof ( argv [ 2 ] ) ) ;
loadFile ( argv [ 3 ], FALSE ) ;
loadBoneFile ( argv [ 4 ], FALSE ) ;
saveTweenFile ( argv [ 5 ], FALSE ) ;
return 0 ;
}

View File

@ -0,0 +1,156 @@
# Microsoft Developer Studio Project File - Name="exposer" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=exposer - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "exposer.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "exposer.mak" CFG="exposer - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "exposer - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "exposer - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "exposer - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sg.lib ssg.lib ssgAux.lib fnt.lib pui.lib puAux.lib ul.lib opengl32.lib glu32.lib glut32.lib Winmm.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\.."
!ELSEIF "$(CFG)" == "exposer - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sg_d.lib ssg_d.lib ssgAux_d.lib fnt_d.lib pui_d.lib puAux_d.lib ul_d.lib opengl32.lib glu32.lib glut32.lib Winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\.."
!ENDIF
# Begin Target
# Name "exposer - Win32 Release"
# Name "exposer - Win32 Debug"
# Begin Source File
SOURCE=.\boneGUI.cxx
# End Source File
# Begin Source File
SOURCE=.\boneGUI.h
# End Source File
# Begin Source File
SOURCE=.\bones.cxx
# End Source File
# Begin Source File
SOURCE=.\bones.h
# End Source File
# Begin Source File
SOURCE=.\event.cxx
# End Source File
# Begin Source File
SOURCE=.\event.h
# End Source File
# Begin Source File
SOURCE=.\exposer.cxx
# End Source File
# Begin Source File
SOURCE=.\exposer.h
# End Source File
# Begin Source File
SOURCE=.\floor.cxx
# End Source File
# Begin Source File
SOURCE=.\floor.h
# End Source File
# Begin Source File
SOURCE=.\load_save.cxx
# End Source File
# Begin Source File
SOURCE=.\load_save.h
# End Source File
# Begin Source File
SOURCE=.\model.cxx
# End Source File
# Begin Source File
SOURCE=.\model.h
# End Source File
# Begin Source File
SOURCE=.\timebox.cxx
# End Source File
# Begin Source File
SOURCE=.\timebox.h
# End Source File
# Begin Source File
SOURCE=.\vertices.cxx
# End Source File
# Begin Source File
SOURCE=.\vertices.h
# End Source File
# End Target
# End Project

View File

@ -0,0 +1,65 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: exposer.h 1528 2002-09-01 07:10:09Z ude $
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <math.h>
#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
#include <plib/pu.h>
#include <plib/ssgAux.h>
#include "event.h"
#include "model.h"
#include "bones.h"
#include "boneGUI.h"
#include "vertices.h"
#include "timebox.h"
#include "floor.h"
#include "load_save.h"
extern EventList * eventList ;
extern TimeBox * timebox ;
extern Floor * ground ;
extern ssgRoot * skinScene ;
extern ssgRoot *tweenScene ;
extern ssgRoot * boneScene ;
extern ssgRoot *sceneScene ;

108
demos/exposer/src/floor.cxx Normal file
View File

@ -0,0 +1,108 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: floor.cxx 1425 2002-08-17 23:58:38Z ude $
*/
#include "exposer.h"
static unsigned char Texture0 [] =
{
0, 0, 0, 0, 255, 255, 255, 255,
0, 0, 0, 0, 255, 255, 255, 255,
0, 0, 0, 0, 255, 255, 255, 255,
0, 0, 0, 0, 255, 255, 255, 255,
255, 255, 255, 255, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0
} ;
static unsigned char Texture1 [] =
{
0, 0, 255, 255,
0, 0, 255, 255,
255, 255, 0, 0,
255, 255, 0, 0
} ;
static unsigned char Texture2 [] =
{
0, 255,
255, 0
} ;
static unsigned char Texture3 [] =
{
127
} ;
void Floor::draw ()
{
glMatrixMode ( GL_PROJECTION) ; _ssgCurrentContext->loadProjectionMatrix() ;
glMatrixMode ( GL_MODELVIEW ) ; _ssgCurrentContext->loadModelviewMatrix () ;
glDisable ( GL_LIGHTING ) ;
glEnable ( GL_TEXTURE_2D ) ;
glEnable ( GL_CULL_FACE ) ;
glBindTexture ( GL_TEXTURE_2D, texhandle ) ;
glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ) ;
glBegin ( GL_QUADS ) ;
glTexCoord2f ( -30.0f, timebox->getGroundPosition() - 30.0f ) ;
glVertex3f ( -30.0f, -30.0f, z_coord ) ;
glTexCoord2f ( 30.0f, timebox->getGroundPosition() - 30.0f ) ;
glVertex3f ( 30.0f, -30.0f, z_coord ) ;
glTexCoord2f ( 30.0f, timebox->getGroundPosition() + 30.0f ) ;
glVertex3f ( 30.0f, 30.0f, z_coord ) ;
glTexCoord2f ( -30.0f, timebox->getGroundPosition() + 30.0f ) ;
glVertex3f ( -30.0f, 30.0f, z_coord ) ;
glEnd () ;
glDisable ( GL_TEXTURE_2D ) ;
glEnable ( GL_LIGHTING ) ;
}
Floor::Floor ()
{
glGenTextures ( 1, & texhandle ) ;
glBindTexture ( GL_TEXTURE_2D, texhandle ) ;
glTexEnvi ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ) ;
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR ) ;
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ;
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ;
glTexImage2D ( GL_TEXTURE_2D, 0, 1, 8, 8,
FALSE, GL_LUMINANCE, GL_UNSIGNED_BYTE, Texture0 ) ;
glTexImage2D ( GL_TEXTURE_2D, 1, 1, 4, 4,
FALSE, GL_LUMINANCE, GL_UNSIGNED_BYTE, Texture1 ) ;
glTexImage2D ( GL_TEXTURE_2D, 2, 1, 2, 2,
FALSE, GL_LUMINANCE, GL_UNSIGNED_BYTE, Texture2 ) ;
glTexImage2D ( GL_TEXTURE_2D, 3, 1, 1, 1,
FALSE, GL_LUMINANCE, GL_UNSIGNED_BYTE, Texture3 ) ;
glBindTexture ( GL_TEXTURE_2D, 0 ) ;
}

39
demos/exposer/src/floor.h Normal file
View File

@ -0,0 +1,39 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: floor.h 1425 2002-08-17 23:58:38Z ude $
*/
class Floor
{
unsigned int texhandle ;
float z_coord ;
public:
void setZcoord ( float z ) { z_coord = z ; }
float getZcoord () { return z_coord ; }
void draw () ;
Floor () ;
} ;

View File

@ -0,0 +1,621 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: load_save.cxx 2078 2006-04-13 16:22:38Z bram $
*/
#include <plib/puAux.h>
#include "exposer.h"
#define FILE_SELECTOR_ARGS (640-320)/2,(480-270)/2,320,270,1
static float tweeninterval = 1.0f/8.0f ;
void setTweenInterval ( float t ) { tweeninterval = t ; }
float getTweenInterval () { return tweeninterval ; }
static puaFileSelector *file_selector = NULL ;
static char lastModelFilePath [ PUSTRING_MAX ] ;
static char lastModelFileName [ PUSTRING_MAX ] ;
static void dismissDialogCB ( puObject * ) ;
static puButton *dialog_button = NULL ;
static void initDialog ()
{
if ( dialog_button != NULL )
return ;
dialog_button = new puButton ( 250, 240, "" ) ;
dialog_button -> setSize ( 400, 40 ) ;
dialog_button -> setLegendFont ( PUFONT_TIMES_ROMAN_24 ) ;
dialog_button -> setCallback ( dismissDialogCB ) ;
dialog_button -> setColorScheme ( 1, 1, 0, 1 ) ;
dialog_button -> hide () ;
}
static void dismissDialogCB ( puObject * )
{
initDialog () ;
dialog_button -> hide () ;
}
static void dialog ( const char *msg, float r, float g, float b )
{
initDialog () ;
dialog_button -> setLegend ( msg ) ;
dialog_button -> setColorScheme ( r, g, b, 1 ) ;
dialog_button -> reveal () ;
}
static void twsavepickfn ( puObject * )
{
char path [ PUSTRING_MAX ] ;
file_selector -> getValue ( path ) ;
if ( path [ 0 ] == '\0' )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
dialog ( "FAILED TO SAVE TWEENED MODEL!", 1, 0, 0 ) ;
return ;
}
saveTweenFile ( path, TRUE ) ;
}
void saveTweenFile ( char *path, int interactive )
{
char orig_path [ PUSTRING_MAX ] ;
char fname [ PUSTRING_MAX ] ;
char *p = NULL ;
int i ;
strcpy ( orig_path, path ) ;
for ( i = strlen(path) ; i >= 0 ; i-- )
if ( path[i] == '/' || path[i] == '\\' )
{
p = & ( path[i+1] ) ;
path[i] = '\0' ;
break ;
}
if ( p == NULL )
{
ssgModelPath ( "." ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( "." ) ;
strcpy ( fname, path ) ;
}
else
{
ssgModelPath ( path ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( path ) ;
strcpy ( fname, p ) ;
}
/* SAVE THE TWEENED MODEL */
if ( orig_path[0] == '\0' )
{
if ( interactive )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
dialog ( "FAILED TO SAVE TWEENED MODEL!", 1, 0, 0 ) ;
return ;
}
else
{
perror ( "saveTween:" ) ;
exit ( 1 ) ;
}
}
tweenScene = (ssgRoot *) makeTweenCopy ( skinScene ) ;
for ( i = 0 ; i <= (int)( timebox->getMaxTime() / tweeninterval ) ; i++ )
{
if ( i != 0 )
addTweenBank ( tweenScene ) ;
transformModel ( boneScene, (float) i * tweeninterval ) ;
makeTweenCopy ( tweenScene, skinScene ) ;
}
if ( ! ssgSave ( orig_path, tweenScene ) )
{
if ( interactive )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
dialog ( "FAILED TO SAVE TWEENED MODEL!", 1, 0, 0 ) ;
return ;
}
else
{
perror ( "saveTween:" ) ;
exit ( 1 ) ;
}
}
if ( interactive )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
dialog ( "TWEENED MODEL WAS SAVED OK.", 1, 1, 0 ) ;
}
}
static void bnsavepickfn ( puObject * )
{
char path [ PUSTRING_MAX ] ;
char fname [ PUSTRING_MAX ] ;
file_selector -> getValue ( path ) ;
if ( path [ 0 ] == '\0' )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
dialog ( "FAILED TO SAVE BONES!", 1, 0, 0 ) ;
return ;
}
char *p = NULL ;
int i ;
for ( i = strlen(path) ; i >= 0 ; i-- )
if ( path[i] == '/' || path[i] == '\\' )
{
p = & ( path[i+1] ) ;
path[i] = '\0' ;
break ;
}
if ( p == NULL )
{
ssgModelPath ( "." ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( "." ) ;
strcpy ( fname, path ) ;
}
else
{
ssgModelPath ( path ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( path ) ;
strcpy ( fname, p ) ;
}
/* SAVE THE BONES */
if ( file_selector->getStringValue()[0] == '\0' )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
dialog ( "FAILED TO SAVE BONES!", 1, 0, 0 ) ;
return ;
}
FILE *fd = fopen ( file_selector->getStringValue(), "wa" ) ;
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
if ( fd == NULL )
{
dialog ( "FAILED TO SAVE BONES!", 1, 0, 0 ) ;
return ;
}
fprintf ( fd, "NUMBONES=%d NUMEVENTS=%d MAXTIME=%f Z_OFFSET=%f SPEED=%f\n",
getNumBones(), eventList->getNumEvents(), timebox->getMaxTime (),
-ground->getZcoord(), timebox->getGroundSpeed() ) ;
for ( i = 0 ; i < getNumBones () ; i++ )
getBone ( i ) -> write ( fd ) ;
eventList -> write ( fd ) ;
fclose ( fd ) ;
dialog ( "BONES WERE SAVED OK.", 1, 1, 0 ) ;
}
static void bnpickfn ( puObject * )
{
char path [ PUSTRING_MAX ] ;
file_selector -> getValue ( path ) ;
if ( path [ 0 ] == '\0' )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
return ;
}
loadBoneFile ( path, TRUE ) ;
}
void loadBoneFile ( char *path, int interactive )
{
char orig_path [ PUSTRING_MAX ] ;
char fname [ PUSTRING_MAX ] ;
char *p = NULL ;
int i ;
strcpy ( orig_path, path ) ;
for ( i = strlen(path) ; i >= 0 ; i-- )
if ( path[i] == '/' || path[i] == '\\' )
{
p = & ( path[i+1] ) ;
path[i] = '\0' ;
break ;
}
if ( p == NULL )
{
ssgModelPath ( "." ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( "." ) ;
strcpy ( fname, path ) ;
}
else
{
ssgModelPath ( path ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( path ) ;
strcpy ( fname, p ) ;
}
/* LOAD THE BONES */
if ( orig_path[0] == '\0' )
{
if ( interactive )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
return ;
}
else
{
perror ( "loadBones:" ) ;
exit ( 1 ) ;
}
}
FILE *fd = fopen ( orig_path, "ra" ) ;
if ( fd == NULL )
{
if ( interactive )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
return ;
}
else
{
perror ( "loadBones:" ) ;
exit ( 1 ) ;
}
}
timebox->deleteAll () ;
int numbones, numevents ;
float floor_z_coord, maxtime, new_ground_speed ;
fscanf ( fd,
"NUMBONES=%d NUMEVENTS=%d MAXTIME=%f Z_OFFSET=%f SPEED=%f\n",
&numbones, &numevents,
&maxtime, &floor_z_coord, &new_ground_speed ) ;
/* Don't use the floor_z_coord from the file. */
/* ground -> setZcoord ( floor_z_coord ) ; */
timebox->setMaxTime ( maxtime ) ;
timebox->setGroundSpeed ( new_ground_speed ) ;
if ( numbones != getNumBones () )
{
fprintf ( stderr,
"Number of bones in model (%d) doesn't agree with number in bones file (%d)!\n", getNumBones (), numbones ) ;
exit ( 1 ) ;
}
for ( i = 0 ; i < getNumBones () ; i++ )
getBone ( i ) -> read ( fd ) ;
eventList -> read ( numevents, fd ) ;
fclose ( fd ) ;
if ( interactive )
{
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
}
}
static void scpickfn ( puObject * )
{
char path [ PUSTRING_MAX ] ;
char fname [ PUSTRING_MAX ] ;
file_selector -> getValue ( path ) ;
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
if ( path [ 0 ] == '\0' )
return ;
if ( strlen ( path ) >= 6 && strcmp(&path[strlen(path)-6], ".bones" ) == 0 )
{
fprintf ( stderr, "I think you tried to load a BONES file as 3D model.\n");
fprintf ( stderr, "Try again!\n");
scloadCB ( NULL ) ;
return ;
}
char *p = NULL ;
for ( int i = strlen(path) ; i >= 0 ; i-- )
if ( path[i] == '/' || path[i] == '\\' )
{
p = & ( path[i+1] ) ;
path[i] = '\0' ;
break ;
}
if ( p == NULL )
{
ssgModelPath ( "." ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( "." ) ;
strcpy ( fname, path ) ;
}
else
{
ssgModelPath ( path ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( path ) ;
strcpy ( fname, p ) ;
}
delete sceneScene ;
sceneScene = new ssgRoot ;
sceneScene -> addKid ( ssgLoad ( fname, NULL ) ) ;
}
static void pickfn ( puObject * )
{
char path [ PUSTRING_MAX ] ;
file_selector -> getValue ( path ) ;
puDeleteObject ( file_selector ) ;
file_selector = NULL ;
if ( path [ 0 ] == '\0' )
return ;
if ( strlen ( path ) >= 6 && strcmp(&path[strlen(path)-6], ".bones" ) == 0 )
{
fprintf ( stderr, "I think you tried to load a BONES file as 3D model.\n");
fprintf ( stderr, "Try again!\n");
loadCB ( NULL ) ;
return ;
}
loadFile ( path, TRUE ) ;
}
void loadFile ( char *path, int interactive )
{
char fname [ PUSTRING_MAX ] ;
char *p = NULL ;
for ( int i = strlen(path) ; i >= 0 ; i-- )
if ( path[i] == '/' || path[i] == '\\' )
{
p = & ( path[i+1] ) ;
path[i] = '\0' ;
break ;
}
if ( p == NULL )
{
ssgModelPath ( "." ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( "." ) ;
strcpy ( fname, path ) ;
}
else
{
ssgModelPath ( path ) ;
if ( getenv ( "EXPOSER_TEXTURE_PATH" ) != NULL )
ssgTexturePath ( getenv ( "EXPOSER_TEXTURE_PATH" ) ) ;
else
ssgTexturePath ( path ) ;
strcpy ( fname, p ) ;
}
strcpy ( lastModelFilePath, path ) ;
strcpy ( lastModelFileName, fname ) ;
skinScene -> addKid ( ssgLoad ( fname, NULL ) ) ;
ssgFlatten ( skinScene -> getKid ( 0 ) ) ;
ssgStripify ( skinScene -> getKid ( 0 ) ) ;
boneScene -> addKid ( extractBones ( skinScene ) ) ;
extractVertices ( skinScene ) ;
timebox->deleteAll () ;
eventList -> newEvent ( 0.0f ) ;
ground -> setZcoord ( getLowestVertexZ () ) ;
}
void twsaveCB ( puObject * )
{
if ( file_selector == NULL )
{
file_selector = new puaFileSelector ( FILE_SELECTOR_ARGS,
lastModelFilePath, "Save Tweened Model As..." ) ;
file_selector -> setCallback ( twsavepickfn ) ;
char guess_fname [ PUSTRING_MAX ] ;
strcpy ( guess_fname, lastModelFileName ) ;
for ( int i = strlen ( guess_fname ) ; i >= 0 ; i-- )
if ( guess_fname [ i ] == '.' )
{
guess_fname[i] = '\0' ;
break ;
}
strcat ( guess_fname, "_tweened.ssg" ) ;
file_selector -> setInitialValue ( guess_fname ) ;
}
}
void bnsaveCB ( puObject * )
{
if ( file_selector == NULL )
{
file_selector = new puaFileSelector ( FILE_SELECTOR_ARGS,
lastModelFilePath, "Save Bones As..." ) ;
file_selector -> setCallback ( bnsavepickfn ) ;
char guess_fname [ PUSTRING_MAX ] ;
strcpy ( guess_fname, lastModelFileName ) ;
for ( int i = strlen ( guess_fname ) ; i >= 0 ; i-- )
if ( guess_fname [ i ] == '.' )
{
guess_fname[i] = '\0' ;
break ;
}
strcat ( guess_fname, ".bones" ) ;
file_selector -> setInitialValue ( guess_fname ) ;
}
}
void bnloadCB ( puObject * )
{
if ( file_selector == NULL )
{
file_selector = new puaFileSelector ( FILE_SELECTOR_ARGS,
lastModelFilePath, "Load Bones from..." ) ;
file_selector -> setCallback ( bnpickfn ) ;
/* Guess an initial filename from the model filename */
char guess_fname [ PUSTRING_MAX ] ;
strcpy ( guess_fname, lastModelFileName ) ;
for ( int i = strlen ( guess_fname ) ; i >= 0 ; i-- )
if ( guess_fname [ i ] == '.' )
{
guess_fname[i] = '\0' ;
break ;
}
strcat ( guess_fname, ".bones" ) ;
file_selector -> setInitialValue ( guess_fname ) ;
}
}
void scloadCB ( puObject * )
{
if ( file_selector == NULL )
{
file_selector = new puaFileSelector ( FILE_SELECTOR_ARGS,
"", "Load Scenery from..." ) ;
file_selector -> setCallback ( scpickfn ) ;
}
}
void loadCB ( puObject * )
{
if ( file_selector == NULL )
{
file_selector = new puaFileSelector ( FILE_SELECTOR_ARGS,
"", "Load Model from..." ) ;
file_selector -> setCallback ( pickfn ) ;
}
}

View File

@ -0,0 +1,36 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: load_save.h 1425 2002-08-17 23:58:38Z ude $
*/
void loadCB ( puObject * ) ;
void scloadCB ( puObject * ) ;
void bnloadCB ( puObject * ) ;
void bnsaveCB ( puObject * ) ;
void twsaveCB ( puObject * ) ;
void loadFile ( char *fname, int interactive ) ;
void loadBoneFile ( char *fname, int interactive ) ;
void saveTweenFile ( char *fname, int interactive ) ;
void setTweenInterval ( float t ) ;

View File

@ -0,0 +1,179 @@
/*
merge_tweens - Merges multiple '.bones' files written from ExPoser
Copyright (C) 2001 Steve Baker
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 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: merge_tweens.cxx 1425 2002-08-17 23:58:38Z ude $
*/
#include "merge_tweens.h"
static void help ()
{
fprintf ( stderr, "\n\n" ) ;
fprintf ( stderr, "merge_tweens: Usage -\n\n" ) ;
fprintf ( stderr, " merge_tweens file.bones ...\n" ) ;
fprintf ( stderr, "\n" ) ;
fprintf ( stderr, "Merges multiple '.bones' files written from ExPoser\n" ) ;
fprintf ( stderr, "into a single animation sequence (stored in 'out.bones').\n" ) ;
fprintf ( stderr, "\n" ) ;
fprintf ( stderr, "Bones files must be compatible (same number of joints\n" );
fprintf ( stderr, "in same order, etc).\n" ) ;
fprintf ( stderr, "\n" ) ;
}
static int numBones = 0 ;
static int totalEvents = 0 ;
static float totalTime = 0.0f ;
static float floor_z = 0.0f ;
static float ground_speed = 0.0f ;
int main ( int argc, char **argv )
{
if ( argc < 2 )
{
help () ;
exit ( 1 ) ;
}
/*
First Pass - add up times - do error checking.
*/
totalEvents = 0 ;
totalTime = 0.0f ;
int i ;
for ( i = 1 ; i < argc ; i++ )
{
FILE *fd = fopen ( argv[i], "ra" ) ;
int bones, numevents ;
float new_floor_z, maxtime, new_ground_speed ;
fscanf ( fd, "NUMBONES=%d NUMEVENTS=%d MAXTIME=%f Z_OFFSET=%f SPEED=%f\n",
&bones, &numevents, &maxtime, &new_floor_z, &new_ground_speed ) ;
printf (
"%2d) %s: NUMBONES=%d NUMEVENTS=%d MAXTIME=%f Z_OFFSET=%f SPEED=%f\n",
i, argv[i], bones, numevents, maxtime, new_floor_z, new_ground_speed ) ;
totalEvents += numevents ;
totalTime += maxtime ;
if ( i == 1 )
{
numBones = bones ;
floor_z = new_floor_z ;
ground_speed = new_ground_speed ;
}
else
{
if ( numBones != bones )
{
fprintf ( stderr,
"merge_bones: FATAL - Number of bones must be the same across files.\n" ) ;
exit ( 1 ) ;
}
if ( floor_z != new_floor_z )
{
fprintf ( stderr,
"merge_bones: WARNING - Floor Z is not the same across files.\n" ) ;
}
if ( ground_speed != new_ground_speed )
{
fprintf ( stderr,
"merge_bones: WARNING - Ground speed is not the same across files.\n");
}
}
fclose ( fd ) ;
}
/*
Pass TWO : Write out composite file.
*/
FILE *out_fd = fopen ( "out.bones", "wa" ) ;
float nextTime = 0.0f ;
for ( i = 1 ; i < argc ; i++ )
{
FILE *fd = fopen ( argv[i], "ra" ) ;
int bones, numevents ;
float new_floor_z, maxtime, new_ground_speed ;
fscanf ( fd, "NUMBONES=%d NUMEVENTS=%d MAXTIME=%f Z_OFFSET=%f SPEED=%f\n",
&bones, &numevents, &maxtime, &new_floor_z, &new_ground_speed ) ;
if ( i == 1 )
{
fprintf ( out_fd,
"NUMBONES=%d NUMEVENTS=%d MAXTIME=%f Z_OFFSET=%f SPEED=%f\n",
numBones, totalEvents, totalTime, floor_z, ground_speed ) ;
for ( int j = 0 ; j < numBones ; j++ )
{
char s [ 1000 ] ;
fgets ( s, 1000, fd ) ;
fprintf ( out_fd, "%s", s ) ;
}
}
else
{
for ( int j = 0 ; j < numBones ; j++ )
{
char s [ 1000 ] ;
fgets ( s, 1000, fd ) ;
}
}
for ( int j = 0 ; j < numevents ; j++ )
{
float t, x, y, z ;
int nb ;
fscanf ( fd, "EVENT %f %d (%f,%f,%f)\n", &t, &nb, &x, &y, &z ) ;
fprintf ( out_fd, "EVENT %f %d (%f,%f,%f)\n", t+nextTime, nb, x, y, z ) ;
for ( int k = 0 ; k < nb ; k++ )
{
int xx, yy, zz ;
fscanf ( fd, " (%d,%d,%d)\n", &xx, &yy, &zz ) ;
fprintf ( out_fd, " (%d,%d,%d)\n", xx, yy, zz ) ;
}
}
nextTime += maxtime ;
fclose ( fd ) ;
}
fclose ( out_fd ) ;
return 0 ;
}

View File

@ -0,0 +1,92 @@
# Microsoft Developer Studio Project File - Name="merge_tweens" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=merge_tweens - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "merge_tweens.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "merge_tweens.mak" CFG="exposer - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "merge_tweens - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "merge_tweens - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "merge_tweens - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "merge_tweens - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\.."
!ENDIF
# Begin Target
# Name "merge_tweens - Win32 Release"
# Name "merge_tweens - Win32 Debug"
# Begin Source File
SOURCE=.\merge_tweens.cxx
# End Source File
# Begin Source File
SOURCE=.\merge_tweens.h
# End Source File
# Begin Source File
# End Project

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <math.h>

465
demos/exposer/src/model.cxx Normal file
View File

@ -0,0 +1,465 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: model.cxx 1425 2002-08-17 23:58:38Z ude $
*/
#include "exposer.h"
static int rootBone = -1 ;
static int nextBone = 0 ;
int getNumBones () { return nextBone ; }
static void findChildBones ( int root )
{
float *v0 = getBone ( root ) -> vx[0] ;
float *v1 = getBone ( root ) -> vx[1] ;
/*
Compute parametric equation.
*/
sgVec3 vec ;
float len ;
int i ;
sgSubVec3 ( vec, v1, v0 ) ;
len = sgLengthVec3 ( vec ) ;
sgScaleVec3 ( vec, 1.0f/len ) ;
for ( i = 0 ; i < getNumBones() ; i++ )
{
/*******************************
If this bone already has a parent
then we are done.
********************************/
if ( getBone(i)->parent >= 0 )
continue ;
/*******************************
Test vertex zero of the daughter
bone against the parent bone.
********************************/
float *vi0 = getBone(i)-> vx[0] ;
float *vi1 = getBone(i)-> vx[1] ;
sgVec3 vec_i ;
float len_i ;
sgSubVec3 ( vec_i, vi0, v0 ) ;
len_i = sgLengthVec3 ( vec_i ) ;
if ( len_i <= 0.01 ) /* Close to vertex 0 of parent? */
{
getBone(i)-> parent = root ;
continue ;
}
sgScaleVec3 ( vec_i, 1.0f/len_i ) ;
/* Somewhere between vertex 0 and vertex 1 of parent? */
if ( sgDistanceSquaredVec3 ( vec, vec_i ) <= 0.001 && len_i <= len * 1.01 )
{
getBone(i)-> parent = root ;
continue ;
}
/*******************************
Test vertex one of the daughter
bone against the parent bone.
********************************/
sgSubVec3 ( vec_i, vi1, v0 ) ;
len_i = sgLengthVec3 ( vec_i ) ;
if ( len_i <= 0.01 ) /* Close to vertex 0 of parent? */
{
getBone(i)->parent = root ;
getBone(i)->swapEnds () ;
continue ;
}
sgScaleVec3 ( vec_i, 1.0f/len_i ) ;
/* Somewhere between vertex 0 and vertex 1 of parent? */
if ( sgDistanceSquaredVec3 ( vec, vec_i ) <= 0.001 && len_i <= len * 1.01 )
{
getBone(i)->parent = root ;
getBone(i)->swapEnds () ;
continue ;
}
}
/****************************************************
Recursively search any new child nodes we found.
****************************************************/
for ( i = 0 ; i < getNumBones() ; i++ )
if ( i != root && getBone(i)->parent == root ) /* If Parented by this root node */
findChildBones ( i ) ; /* Recurse downwards. */
}
void addTweenBank ( ssgBranch *root )
{
if ( root == NULL )
return ;
for ( int i = 0 ; i < root -> getNumKids () ; i++ )
{
ssgEntity *e = root -> getKid ( i ) ;
if ( e -> isAKindOf ( ssgTypeBranch() ) )
addTweenBank ( (ssgBranch *)e ) ;
else
if ( e -> isAKindOf ( ssgTypeTween() ) )
{
ssgTween *tween = (ssgTween *) e ;
ssgVertexArray *v1 = new ssgVertexArray ;
for ( int ii = 0 ; ii < tween -> getNumVertices () ; ii++ )
v1 -> add ( tween -> getVertex ( ii ) ) ;
tween -> newBank ( v1, NULL, NULL, NULL ) ;
}
}
}
void makeTweenCopy ( ssgBranch *dst, ssgBranch *src )
{
for ( int i = 0 ; i < src -> getNumKids () ; i++ )
{
ssgEntity *s = src -> getKid ( i ) ;
ssgEntity *d = dst -> getKid ( i ) ;
if ( s -> isAKindOf ( ssgTypeBranch() ) )
makeTweenCopy ( (ssgBranch *)d, (ssgBranch *)s ) ;
else
{
ssgLeaf *ls = (ssgLeaf *) s ;
ssgLeaf *ld = (ssgLeaf *) d ;
for ( int ii = 0 ; ii < ls -> getNumVertices () ; ii++ )
sgCopyVec3 ( ld->getVertex(ii), ls->getVertex(ii) ) ;
}
}
}
static void tweenify ( ssgBranch *root )
{
for ( int i = 0 ; i < root -> getNumKids () ; i++ )
{
ssgEntity *e = root -> getKid ( i ) ;
if ( e -> isAKindOf ( ssgTypeBranch() ) )
tweenify ( (ssgBranch *)e ) ;
else
{
ssgLeaf *l = (ssgLeaf *) e ;
ssgVertexArray *v0 = new ssgVertexArray ;
ssgNormalArray *n0 = new ssgNormalArray ;
ssgTexCoordArray *t0 = new ssgTexCoordArray ;
ssgColourArray *c0 = new ssgColourArray ;
for ( int ii = 0 ; ii < l -> getNumVertices () ; ii++ )
{
v0 -> add ( l -> getVertex ( ii ) ) ;
n0 -> add ( l -> getNormal ( ii ) ) ;
t0 -> add ( l -> getTexCoord ( ii ) ) ;
c0 -> add ( l -> getColour ( ii ) ) ;
}
ssgTween *tween = new ssgTween ( l -> getPrimitiveType () ) ;
tween -> setState ( l -> getState () ) ;
tween -> newBank ( v0, n0, t0, c0 ) ;
root -> replaceKid ( l, tween ) ;
}
}
}
ssgEntity *makeTweenCopy ( ssgEntity *root )
{
if ( root == NULL )
return NULL ;
ssgEntity *res = (ssgEntity *) ( root -> clone ( SSG_CLONE_RECURSIVE |
SSG_CLONE_GEOMETRY ) ) ;
tweenify ( (ssgBranch *) res ) ;
return res ;
}
static void walkBones ( ssgBranch *root, sgMat4 mat )
{
if ( root == NULL )
return ;
sgMat4 newmat ;
if ( root -> isAKindOf ( ssgTypeTransform() ) )
{
sgMat4 tmp ;
((ssgTransform *)root)-> getTransform ( tmp ) ;
sgMultMat4 ( newmat, mat, tmp ) ;
}
else
sgCopyMat4 ( newmat, mat ) ;
for ( int i = 0 ; i < root -> getNumKids () ; i++ )
{
ssgEntity *e = root -> getKid ( i ) ;
if ( e -> isAKindOf ( ssgTypeBranch() ) )
walkBones ( (ssgBranch *)e, newmat ) ;
else
{
ssgLeaf *l = (ssgLeaf *) e ;
if ( l -> getPrimitiveType () == GL_LINES ||
l -> getPrimitiveType () == GL_LINE_LOOP ||
l -> getPrimitiveType () == GL_LINE_STRIP )
{
for ( int ll = 0 ; ll < l->getNumLines() ; ll++ )
{
short vv [ 2 ] ;
l -> getLine ( ll, & vv[0], & vv[1] ) ;
getBone ( getNumBones() ) -> init ( l, newmat, vv,
getNumBones() ) ;
/*
Is this line red?
If so, it's the 'root' line.
*/
float *col = l -> getColour ( vv[0] ) ;
if ( l -> getState () != NULL &&
l -> getState () -> isAKindOf ( ssgTypeSimpleState () ) )
{
ssgSimpleState *ss = (ssgSimpleState *)( l -> getState () ) ;
if ( ss -> getColourMaterial () != GL_DIFFUSE &&
ss -> getColourMaterial () != GL_AMBIENT_AND_DIFFUSE )
{
col = ss -> getMaterial ( GL_DIFFUSE ) ;
}
}
if ( col [ 0 ] > 0.75 && col [ 1 ] < 0.25 && col [ 2 ] < 0.25 )
{
if ( rootBone != -1 )
rootBone = -2 ;
else
rootBone = getNumBones() ;
}
nextBone++ ;
}
root -> removeKid ( e ) ;
i-- ;
}
}
}
}
void offsetChildBones ( int root, sgVec3 v )
{
for ( int i = 0 ; i < getNumBones() ; i++ )
if ( getBone(i)->parent == root )
{
sgSubVec3 ( getBone(i)->vx[0], v ) ;
sgSubVec3 ( getBone(i)->vx[1], v ) ;
offsetChildBones ( i, v ) ;
}
}
ssgBranch *extractBones ( ssgBranch *root )
{
sgMat4 mat ;
nextBone = 0 ;
rootBone = -1 ;
sgMakeIdentMat4 ( mat ) ;
walkBones ( root, mat ) ;
if ( rootBone == -1 )
{
fprintf ( stderr, "exposer: ERROR - No 'root' bone found?!?\n" ) ;
fprintf ( stderr, "exposer: (Exactly one 'bone' line should be RED).\n" ) ;
exit ( 1 ) ;
}
if ( rootBone == -2 )
{
fprintf ( stderr, "exposer: ERROR - Multiple 'root' bones found?!?\n" ) ;
fprintf ( stderr, "exposer: (Only one 'bone' line should be RED).\n" ) ;
exit ( 1 ) ;
}
fprintf ( stderr, "exposer: %d bones found, rootBone is number %d.\n",
getNumBones(), rootBone ) ;
getBone(rootBone)->parent = ROOT_BONE ;
findChildBones ( rootBone ) ;
int disconnected = 0 ;
for ( int i = 0 ; i < getNumBones() ; i++ )
if ( getBone(i)->parent < 0 )
disconnected++ ;
if ( disconnected > 0 )
{
fprintf ( stderr,
"exposer: ERROR - %d bones are not connected to the 'root' bone.\n",
disconnected ) ;
fprintf ( stderr,
"exposer: (The root bone line should be RED. All other bones\n" ) ;
fprintf ( stderr,
"exposer: should either touch the root bone - or touch some\n" ) ;
fprintf ( stderr,
"exposer: other bone that is connected to the root bone so that\n");
fprintf ( stderr,
"exposer: all the bones form one continuously connected\n" ) ;
fprintf ( stderr,
"exposer: skeleton.)\n" ) ;
exit ( 1 ) ;
}
ssgBranch *res = getBone ( rootBone ) -> generateGeometry ( rootBone ) ;
return res ;
}
static void walkTransforms ( ssgBranch *root, sgMat4 mat )
{
if ( root == NULL )
return ;
sgMat4 newmat ;
if ( root -> isAKindOf ( ssgTypeTransform() ) )
{
sgMat4 tmp ;
((ssgTransform *)root)-> getTransform ( tmp ) ;
sgMultMat4 ( newmat, mat, tmp ) ;
Bone *bo = (Bone *)(((ssgTransform *)root)-> getUserData ()) ;
sgCopyMat4 ( bo -> netMatrix, newmat ) ;
}
else
sgCopyMat4 ( newmat, mat ) ;
for ( int i = 0 ; i < root -> getNumKids () ; i++ )
{
ssgEntity *e = root -> getKid ( i ) ;
if ( e -> isAKindOf ( ssgTypeBranch () ) )
walkTransforms ( (ssgBranch *) e, newmat ) ;
}
}
void transformModel ( ssgBranch *boneRoot, float tim )
{
if ( eventList->getNumEvents () < 1 )
return ;
Event *prev = eventList->getEvent ( 0 ) ;
Event *next = prev ;
if ( eventList->getCurrentEvent() != NULL )
{
prev = next = eventList->getCurrentEvent() ;
tim = eventList->getCurrentEvent() -> getTime () ;
}
else
{
for ( int i = 1 ; i < eventList->getNumEvents () ; i++ )
{
Event *ev = eventList->getEvent ( i ) ;
float t = ev -> getTime () ;
if ( t < tim )
next = prev = ev ;
else
{
next = ev ;
break ;
}
}
}
float lerptime = 0.0f ;
if ( next->getTime() - prev->getTime() >= 0.01 )
{
lerptime = tim - prev->getTime() ;
lerptime /= (next->getTime() - prev->getTime()) ;
}
sgVec3 ptra ; prev->getTranslate(ptra) ;
sgVec3 ntra ; next->getTranslate(ntra) ;
sgLerpVec3 ( getCurrTranslate(), ptra, ntra, lerptime ) ;
syncTranslators ( getCurrTranslate() ) ;
int i ;
for ( i = 0 ; i < getNumBones () ; i++ )
getBone ( i ) -> computeTransform ( prev, next, lerptime ) ;
sgMat4 mat ;
sgMakeIdentMat4 ( mat ) ;
walkTransforms ( (ssgBranch *) boneRoot, mat ) ;
transformVertices () ;
}

36
demos/exposer/src/model.h Normal file
View File

@ -0,0 +1,36 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: model.h 1425 2002-08-17 23:58:38Z ude $
*/
ssgBranch *extractBones ( ssgBranch *root ) ;
ssgEntity *makeTweenCopy ( ssgEntity *root ) ;
void extractVertices ( ssgBranch *root ) ;
void transformModel ( ssgBranch *boneRoot, float tim ) ;
void makeTweenCopy ( ssgBranch *dest, ssgBranch *src ) ;
void addTweenBank ( ssgBranch *root ) ;
void offsetChildBones ( int root, sgVec3 v ) ;
float getLowestVertexZ () ;
int getNumBones () ;

View File

@ -0,0 +1,386 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: timebox.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
#include "exposer.h"
#define MODE_ADD 0
#define MODE_SELECT 1
#define TIMEBOX_LEFT 230.0f
#define TIMEBOX_RIGHT 790.0f
#define TIMEBOX_TOP 100.0f
#define TIMEBOX_BOTTOM 10.0f
#define TIMEBOX_WIDTH (TIMEBOX_RIGHT-TIMEBOX_LEFT)
#define TIMEBOX_INITIAL_DURATION 10.0f /* Seconds */
/* GUI callback functions. */
static void vcr_fastReverse ( puObject *ob )
{
TimeBox *timebox = (TimeBox *) ob -> getUserData () ;
timebox -> setReplaySpeed (-3.0f);
}
static void vcr_reverse ( puObject *ob )
{
TimeBox *timebox = (TimeBox *) ob -> getUserData () ;
timebox -> setReplaySpeed (-1.0f);
}
static void vcr_stop ( puObject *ob )
{
TimeBox *timebox = (TimeBox *) ob -> getUserData () ;
timebox -> setReplaySpeed ( 0.0f);
}
static void vcr_play ( puObject *ob )
{
TimeBox *timebox = (TimeBox *) ob -> getUserData () ;
timebox -> setReplaySpeed ( 1.0f);
}
static void vcr_fastPlay ( puObject *ob )
{
TimeBox *timebox = (TimeBox *) ob -> getUserData () ;
timebox -> setReplaySpeed ( 3.0f);
}
static void vcr_groundSpeed ( puObject *ob )
{
TimeBox *timebox = (TimeBox *) ob -> getUserData () ;
timebox -> setGroundSpeed ( ob -> getFloatValue () ) ;
}
static void timescrollerCB ( puObject *ob )
{
TimeBox *timebox = (TimeBox *) ob -> getUserData () ;
timebox -> setScroll ( ob -> getFloatValue () *
( timebox -> getMaxTime() -
TIMEBOX_WIDTH / timebox -> second () ) ) ;
}
float TimeBox::second ()
{
return scale * TIMEBOX_WIDTH / maxtime ;
}
void TimeBox::deleteRegionAndCompress ()
{
eventList -> compressEventsBetween ( lcursor, rcursor ) ;
maxtime -= (float)fabs(lcursor-rcursor) ;
if ( lcursor > rcursor )
lcursor = rcursor ;
else
rcursor = lcursor ;
}
void TimeBox::addNewEvent ()
{
if ( getNumBones() <= 0 )
return ;
eventList->setCurrentEvent ( NULL ) ;
event_mode = MODE_ADD ;
}
void TimeBox::updateVCR ()
{
static ulClock timer ;
timer.update () ;
if ( replay_speed != 0.0f )
{
float delta_t = replay_speed * (float)timer.getDeltaTime () ;
lcursor += delta_t ;
if ( lcursor < 0.0f )
lcursor = maxtime ;
if ( lcursor > maxtime )
lcursor = 0.0f ;
}
ground_position = lcursor * ground_speed ;
}
void TimeBox::draw ()
{
int w = puGetWindowWidth () ;
int h = puGetWindowHeight () ;
glPushAttrib ( GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_LIGHTING_BIT ) ;
glDisable ( GL_LIGHTING ) ;
glDisable ( GL_FOG ) ;
glDisable ( GL_TEXTURE_2D ) ;
glDisable ( GL_DEPTH_TEST ) ;
glDisable ( GL_CULL_FACE ) ;
glViewport ( 0, 0, w, h ) ;
glMatrixMode ( GL_PROJECTION ) ;
glPushMatrix () ;
glLoadIdentity () ;
gluOrtho2D ( 0, w, 0, h ) ;
glMatrixMode ( GL_MODELVIEW ) ;
glPushMatrix () ;
glLoadIdentity () ;
glColor4f ( 0.8f, 0.8f, 0.8f, 1.0f ) ;
glBegin ( GL_LINE_LOOP ) ;
glVertex2f ( TIMEBOX_LEFT , TIMEBOX_BOTTOM ) ;
glVertex2f ( TIMEBOX_RIGHT, TIMEBOX_BOTTOM ) ;
glVertex2f ( TIMEBOX_RIGHT, TIMEBOX_TOP ) ;
glVertex2f ( TIMEBOX_LEFT , TIMEBOX_TOP ) ;
glEnd () ;
int nseconds = (int)floor(TIMEBOX_WIDTH / second () ) ;
int ntenthseconds = (int)floor(TIMEBOX_WIDTH*10.0f / second () ) ;
int tenthsecondoffset = (int)( (start*10.0f -
floor(start*10.0f))
* second () / 10.0f ) ;
int secondoffset = (int)( (start -
floor(start))
* second () ) ;
int i ;
glBegin ( GL_LINES ) ;
for ( i = 0 ; i < ntenthseconds ; i++ )
{
float x = TIMEBOX_LEFT + tenthsecondoffset +
(float) i * second () / 10.0f ;
glVertex2f ( x, TIMEBOX_BOTTOM ) ;
glVertex2f ( x, TIMEBOX_TOP/3.0f ) ;
}
for ( i = 0 ; i < nseconds ; i++ )
{
float x = TIMEBOX_LEFT + secondoffset +
(float) i * second () ;
glVertex2f ( x, TIMEBOX_BOTTOM ) ;
glVertex2f ( x, TIMEBOX_TOP/2.0f ) ;
}
glEnd () ;
float tlcursor = ( lcursor - start ) * second () ;
float trcursor = ( rcursor - start ) * second () ;
tlcursor = (tlcursor < 0.0f ) ? 0.0f :
(tlcursor > TIMEBOX_WIDTH) ? TIMEBOX_WIDTH : tlcursor ;
trcursor = (trcursor < 0.0f ) ? 0.0f :
(trcursor > TIMEBOX_WIDTH) ? TIMEBOX_WIDTH : trcursor ;
if ( tlcursor != trcursor )
{
glColor4f ( 1.0f, 1.0f, 0.0f, 0.2f ) ;
glBegin ( GL_QUADS ) ;
glVertex2f ( TIMEBOX_LEFT + tlcursor, TIMEBOX_BOTTOM ) ;
glVertex2f ( TIMEBOX_LEFT + tlcursor, TIMEBOX_TOP ) ;
glVertex2f ( TIMEBOX_LEFT + trcursor, TIMEBOX_TOP ) ;
glVertex2f ( TIMEBOX_LEFT + trcursor, TIMEBOX_BOTTOM ) ;
glEnd () ;
}
glColor4f ( 0.0f, 0.0f, 0.0f, 1.0f ) ;
glBegin ( GL_LINES ) ;
glVertex2f ( TIMEBOX_LEFT + trcursor, TIMEBOX_BOTTOM ) ;
glVertex2f ( TIMEBOX_LEFT + trcursor, TIMEBOX_TOP ) ;
glEnd () ;
glColor4f ( 1.0f, 0.0f, 0.0f, 1.0f ) ;
glBegin ( GL_LINES ) ;
glVertex2f ( TIMEBOX_LEFT + tlcursor, TIMEBOX_BOTTOM ) ;
glVertex2f ( TIMEBOX_LEFT + tlcursor, TIMEBOX_TOP ) ;
glEnd () ;
float t ;
glColor4f ( 1.0f, 0.0f, 1.0f, 1.0f ) ;
glBegin ( GL_LINES ) ;
for ( i = 0 ; i < eventList->getNumEvents() ; i++ )
{
t = eventList->getEvent(i) -> getTime () ;
t = ( t - start ) * second () ;
if ( t >= 0.0f && t <= TIMEBOX_WIDTH )
{
glVertex2f ( TIMEBOX_LEFT + t, TIMEBOX_TOP/3.0f ) ;
glVertex2f ( TIMEBOX_LEFT + t, TIMEBOX_TOP ) ;
}
}
glEnd () ;
if ( eventList->getCurrentEvent() != NULL )
{
t = eventList->getCurrentEvent() -> getTime () ;
t = ( t - start ) * second () ;
if ( t >= 0.0f && t <= TIMEBOX_WIDTH )
{
static ulClock flasher ;
flasher.update () ;
if ( (int)(flasher.getAbsTime()*3.0f) & 1 )
glColor4f ( 1.0f, 0.0f, 1.0f, 1.0f ) ;
else
glColor4f ( 0.0f, 1.0f, 0.0f, 1.0f ) ;
glBegin ( GL_LINES ) ;
glVertex2f ( TIMEBOX_LEFT + t, TIMEBOX_TOP/3.0f ) ;
glVertex2f ( TIMEBOX_LEFT + t, TIMEBOX_TOP ) ;
glEnd () ;
}
}
glMatrixMode ( GL_PROJECTION ) ;
glPopMatrix () ;
glMatrixMode ( GL_MODELVIEW ) ;
glPopMatrix () ;
glPopAttrib () ;
}
void TimeBox::updateEventQueue ( int button, int x, int y, int new_click )
{
y = puGetWindowHeight () - y ;
/*
Allow user to click a little outside the box so
we can make it easier to get the ends exactly.
*/
if ( x > TIMEBOX_LEFT - 20 && x < TIMEBOX_RIGHT + 20 &&
y > TIMEBOX_BOTTOM && y < TIMEBOX_TOP )
{
float c = (float)(x - TIMEBOX_LEFT) ;
if ( c < 0.0f ) c = 0.0f ;
if ( c > TIMEBOX_WIDTH ) c = TIMEBOX_WIDTH ;
c /= second () ;
c += start ;
if ( button == PU_RIGHT_BUTTON )
rcursor = c ;
else
if ( button == PU_LEFT_BUTTON )
{
rcursor = lcursor = c ;
if ( new_click )
{
if ( event_mode == MODE_ADD )
eventList -> newEvent ( lcursor ) ;
else
eventList -> setCurrentEvent (
eventList -> findNearestEvent ( lcursor, 10.0f/second () ) ) ;
event_mode = MODE_SELECT ;
}
else
if ( eventList->getCurrentEvent() != NULL )
eventList->moveEvent ( eventList->getCurrentEvent(), lcursor ) ;
}
}
}
void TimeBox::init ()
{
event_mode = MODE_SELECT ;
maxtime = TIMEBOX_INITIAL_DURATION ;
scale = 1.0f ;
start = 0.0f ;
lcursor = 0.0f ;
rcursor = 0.0f ;
replay_speed = 0.0f ;
ground_speed = 0.0f ;
ground_position = 0.0f ;
timescroller = new puSlider ( (int)TIMEBOX_LEFT, (int)TIMEBOX_TOP+5,
570-(int)TIMEBOX_LEFT, FALSE ) ;
timescroller -> setCBMode ( PUSLIDER_DELTA ) ;
timescroller -> setDelta ( 0.01f ) ;
timescroller -> setCallback ( timescrollerCB ) ;
timescroller -> setUserData ( this ) ;
timescroller -> hide () ;
puText *message ;
puOneShot *oneshot ;
puGroup *vcr = new puGroup ( 579, (int)TIMEBOX_TOP + 5 ) ;
oneshot = new puArrowButton ( 0, 0, 30, 30, PUARROW_FASTLEFT ) ;
oneshot -> setCallback ( vcr_fastReverse ) ;
oneshot -> setUserData ( this ) ;
oneshot = new puArrowButton ( 30, 0, 60, 30, PUARROW_LEFT ) ;
oneshot -> setCallback ( vcr_reverse ) ;
oneshot -> setUserData ( this ) ;
oneshot = new puArrowButton ( 60, 0, 90, 30, PUARROW_DOWN ) ;
oneshot -> setCallback ( vcr_stop ) ;
oneshot -> setUserData ( this ) ;
oneshot = new puArrowButton ( 90, 0,120, 30, PUARROW_RIGHT ) ;
oneshot -> setCallback ( vcr_play ) ;
oneshot -> setUserData ( this ) ;
oneshot = new puArrowButton (120, 0,150, 30, PUARROW_FASTRIGHT ) ;
oneshot -> setCallback ( vcr_fastPlay ) ;
oneshot -> setUserData ( this ) ;
ground_speed_input = new puInput ( 150, 0, 200, 20 ) ;
ground_speed_input -> setCallback ( vcr_groundSpeed ) ;
ground_speed_input -> setValue ( "0.0" ) ;
ground_speed_input -> setUserData ( this ) ;
message = new puText ( 150, 20 ) ;
message -> setColour ( PUCOL_LABEL, 0.7f,0.65f,0.26f,1 ) ;
message -> setLabel ( "GrndSpeed" ) ;
vcr -> close () ;
}

117
demos/exposer/src/timebox.h Normal file
View File

@ -0,0 +1,117 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: timebox.h 1425 2002-08-17 23:58:38Z ude $
*/
class TimeBox
{
int event_mode ;
float maxtime ;
float scale ;
float start ;
float lcursor ;
float rcursor ;
EventList *eventList ;
puSlider *timescroller ;
puInput *ground_speed_input ;
float replay_speed ;
float ground_speed ;
float ground_position ;
void init () ;
public:
void setReplaySpeed ( float spd )
{
replay_speed = spd ;
eventList->setCurrentEvent ( NULL ) ;
}
void draw () ;
void updateEventQueue ( int button, int x, int y, int new_click ) ;
void updateVCR () ;
TimeBox ( EventList *el ) { eventList = el ; init () ; }
float second () ;
float getCursorTime () { return lcursor ; }
void setMaxTime ( float t ) { maxtime = t ; }
float getMaxTime () { return maxtime ; }
void setGroundSpeed ( float t )
{
ground_speed = t ;
ground_speed_input -> setValue ( ground_speed ) ;
}
float getGroundSpeed () { return ground_speed ; }
void setGroundPosition ( float t ) { ground_position = t ; }
float getGroundPosition () { return ground_position ; }
void setScroll ( float z ) { start = z ; }
float getScroll () { return start ; }
void setZoom ( float z )
{
scale = z ;
if ( scale == 1.0f )
timescroller -> hide () ;
else
timescroller -> reveal () ;
}
float getZoom () { return scale ; }
void reverseRegion ()
{
eventList -> reverseEventsBetween ( lcursor, rcursor ) ;
}
void deleteAll ()
{
eventList -> deleteAll () ;
lcursor = rcursor = 0.0f ;
}
void deleteRegion ()
{
eventList -> deleteEventsBetween ( lcursor, rcursor ) ;
}
void deleteEvent ()
{
eventList -> deleteCurrentEvent () ;
}
void deleteRegionAndCompress () ;
void addNewEvent () ;
} ;

View File

@ -0,0 +1,189 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: vertices.cxx 1425 2002-08-17 23:58:38Z ude $
*/
#include "exposer.h"
class Vertex
{
public:
int boneID ;
sgVec3 rel_vx ;
float *vx ;
int getBoneID () { return boneID ; }
} ;
static int nextVertex = 0 ;
#define MAX_VERTICES (64*1024)
static Vertex vertex [ MAX_VERTICES ] ;
static int getNumVertices () { return nextVertex ; }
static void addVertex ( sgVec3 v )
{
vertex [ nextVertex ] . vx = v ;
sgCopyVec3 ( vertex [ nextVertex ] . rel_vx, v ) ;
nextVertex++ ;
}
static void initVertices ()
{
nextVertex = 0 ;
}
static void walkVertices ( ssgBranch *root, sgMat4 mat )
{
if ( root == NULL )
return ;
sgMat4 newmat ;
if ( root -> isAKindOf ( ssgTypeTransform() ) )
{
sgMat4 tmp ;
((ssgTransform *)root)-> getTransform ( tmp ) ;
sgMultMat4 ( newmat, mat, tmp ) ;
sgMakeIdentMat4 ( tmp ) ;
((ssgTransform *)root)-> setTransform ( tmp ) ;
}
else
sgCopyMat4 ( newmat, mat ) ;
for ( int i = 0 ; i < root -> getNumKids () ; i++ )
{
ssgEntity *e = root -> getKid ( i ) ;
if ( e -> isAKindOf ( ssgTypeBranch() ) )
walkVertices ( (ssgBranch *)e, newmat ) ;
else
{
ssgLeaf *l = (ssgLeaf *) e ;
for ( int ll = 0 ; ll < l->getNumVertices() ; ll++ )
{
float *v = l -> getVertex ( ll ) ;
int vv = -1 ;
for ( int j = 0 ; j < getNumVertices() ; j++ )
if ( v == vertex [ j ] . vx )
{
vv = j ;
break ;
}
if ( vv < 0 )
{
sgXformPnt3 ( v, mat ) ;
addVertex ( v ) ;
}
}
}
}
}
void extractVertices ( ssgBranch *root )
{
sgMat4 mat ;
initVertices () ;
/*
Walk the model - making a list of all of the
unique vertices - flattening the model's transforms
as we go.
*/
sgMakeIdentMat4 ( mat ) ;
walkVertices ( root, mat ) ;
/*
Now find the nearest bone to each vertex and
compute it's position relative to the root of
that bone.
*/
for ( int i = 0 ; i < getNumVertices() ; i++ )
{
float min = FLT_MAX ;
for ( int j = 0 ; j < getNumBones() ; j++ )
{
sgLineSegment3 ls ;
sgCopyVec3 ( ls.a, getBone(j)->orig_vx[0] ) ;
sgCopyVec3 ( ls.b, getBone(j)->orig_vx[1] ) ;
float d = sgDistSquaredToLineSegmentVec3 ( ls, vertex[i].vx ) ;
if ( d < min )
{
min = d ;
vertex[i].boneID = j ;
}
}
sgSubVec3 ( vertex[i].rel_vx,
vertex[i].vx,
getBone(vertex[i].boneID)->orig_vx[0] ) ;
}
}
float getLowestVertexZ ()
{
float lowest = FLT_MAX ;
for ( int i = 0 ; i < getNumVertices() ; i++ )
{
float v = vertex[i].vx [ 2 ] ;
if ( v < lowest )
lowest = v ;
}
return lowest ;
}
void transformVertices ()
{
for ( int i = 0 ; i < getNumVertices () ; i++ )
getBone ( vertex[i].getBoneID() ) -> transform ( vertex[i].vx,
vertex[i].rel_vx ) ;
}

View File

@ -0,0 +1,28 @@
/*
This file is part of ExPoser - A Tool for Animating PLIB Critters.
Copyright (C) 2001 Steve Baker
ExPoser 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 of the License, or
(at your option) any later version.
ExPoser 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 ExPoser; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: vertices.h 1425 2002-08-17 23:58:38Z ude $
*/
void extractVertices ( ssgBranch *root ) ;
float getLowestVertexZ () ;
void transformVertices () ;

3
demos/p-guide/AUTHORS Normal file
View File

@ -0,0 +1,3 @@
P-GUIDE was written by John F. Fay.
Significant improvements were made by James 'J.C.' Jones

340
demos/p-guide/COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
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 Program or any portion
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) 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; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, 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 executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. 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 Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. 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 Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program 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 Program.
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.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program 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.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies 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 Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, 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
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. 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 PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, 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.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

1
demos/p-guide/ChangeLog Normal file
View File

@ -0,0 +1 @@
July, 2002 -- P-Guide functionality increased dramatically -- James 'J.C.' Jones

182
demos/p-guide/INSTALL Normal file
View File

@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
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
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
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'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
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.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
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.

View File

@ -0,0 +1,4 @@
SUBDIRS = src
EXTRA_DIRS = autogen.sh README TODO pGuide.dsw

0
demos/p-guide/NEWS Normal file
View File

34
demos/p-guide/README Normal file
View File

@ -0,0 +1,34 @@
PUI-based Graphical User Interface Designer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
by John F. Fay
REQUIREMENTS:
OpenGL (or Mesa)
GLUT (the GL Utility Toolkit)
PLIB
INSTALLATION:
Installation instructions are pretty basic:
./configure
make
make install
LICENSE:
This software is released under the provisions of
the GNU General Public License (GPL) which can be
found in the file 'COPYING' in the current directory.
DIRECTORY STRUCTURE:
src -- Where the source code lives.
doc -- Documentation - in HTML

30
demos/p-guide/TODO Normal file
View File

@ -0,0 +1,30 @@
Planned Bug Fixes or Upgrades to P-GUIDE:
Bug Fixes:
1. When the user has selected CTRL-widget, have the button value set back to zero when the selected_widget_type (or whatever it is) gets deselected or changed (eg when he presses on another widget button in the Widget window or presses another widget anywhere else), not just when he presses Escape.
2. Make the Active widget's black line go all the way around it.
3. puFileSelector needs options
4. puScrollBar needs to be added
5. Menus (Vert and normal) need a method to populate submenus.
Upgrades:
1. Improve layer support.
2. Make widgets added to window the real widgets, rather than Frames.
3. Multiple Window support
4. Makefile building?
5. Font viewing / selecting (a font browser and such)
6. Copy / Cut / Paste
7. Widget class changes

19
demos/p-guide/autogen.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
OSTYPE=`uname -s`
AMFLAGS="--add-missing"
if test "$OSTYPE" = "IRIX" -o "$OSTYPE" = "IRIX64"; then
AMFLAGS=$AMFLAGS" --include-deps";
fi
echo "Running aclocal"
aclocal
echo "Running automake"
automake $AMFLAGS
echo "Running autoconf"
autoconf
echo "======================================"
echo "Now you are ready to run './configure'"
echo "======================================"

162
demos/p-guide/configure.in Normal file
View File

@ -0,0 +1,162 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/pGuide.cxx)
AM_INIT_AUTOMAKE(pguide, 0.0.1)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL
plib_suffix="-lplibpu -lplibfnt -lplibsg -lplibul"
AC_LANG_CPLUSPLUS
dnl Command line arguments.
dnl Don't use AC_HELP_STRING here as old versions of autoconf do not
dnl understand it.
AC_ARG_WITH(GL,
[ --with-GL=DIR set the prefix directory where GL resides],
GL_PREFIX=$withval, GL_PREFIX=auto)
if test "x$GL_PREFIX" != "xauto"; then
LDFLAGS="$LDFLAGS -L$GL_PREFIX/lib"
CPPFLAGS="$CPPFLAGS -I$GL_PREFIX/include"
fi
dnl Checks for library functions.
dnl check for OpenGL related libraries
AC_CANONICAL_HOST
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
dnl OpenGL libraries
LIBS="$LIBS -lwinmm -lglut32 -lglu32 -lopengl32 -luser32 -lgdi32"
;;
*-apple-darwin*)
dnl Mac OS X
LIBS="$LIBS -framework GLUT -lobjc -framework OpenGL"
;;
*)
dnl Check for X11
AC_PATH_XTRA
LDFLAGS="$LDFLAGS $X_LIBS"
LIBS="$LIBS $X_PRE_LIBS -lXi -lXmu -lXext -lX11 $X_EXTRA_LIBS -lm"
dnl =========================================================
dnl if test "x$x_includes" != "x"; then
dnl CPPFLAGS="$CPPFLAGS -I$x_includes"
dnl fi
dnl =========================================================
dnl Reasonable stuff non-windoze variants ... :-)
AC_CHECK_LIB(GL, glNewList)
if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
dnl if no GL, check for MesaGL
AC_CHECK_LIB(MesaGL, glNewList,,
AC_MSG_ERROR([could not find working GL library]))
fi
AC_CHECK_LIB(GLU, gluLookAt)
if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
dnl if no GLU, check for MesaGLU
AC_CHECK_LIB(MesaGLU, gluLookAt,,
AC_MSG_ERROR([could not find working GLU library]))
fi
dnl check for glut...or freeglut
AC_CHECK_LIB(freeglut, glutGetModifiers)
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xno" ; then
dnl if no freeglut, check for Real GLUT
AC_CHECK_LIB(glut, glutGetModifiers,,
AC_MSG_ERROR([could not find working GLUT library]))
fi
AC_CHECK_LIB(dl, dlclose)
;;
esac
dnl Check PLIB library
AC_CHECK_LIB(plibul, ulInit, true,
AC_MSG_ERROR([there seems to be a problem with the PLIB libraries]))
LIBS="$plib_suffix $LIBS"
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADER(windows.h, AC_DEFINE(WIN32))
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
AC_CHECK_HEADERS(GL/gl.h GL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
;;
*-apple-darwin*)
dnl Mac OS X
AC_CHECK_HEADERS(OpenGL/gl.h OpenGL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
AC_CHECK_HEADER(GLUT/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
;;
*)
AC_CHECK_HEADERS(GL/gl.h GL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xyes"; then
AC_CHECK_HEADER(GL/freeglut.h, AC_DEFINE(FREEGLUT_IS_PRESENT),
AC_MSG_ERROR([freeglut header file not found]))
else
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
fi
;;
esac
AC_CHECK_HEADER(plib/ul.h,, AC_MSG_ERROR([PLIB header files not found]))
dnl Warning flags
WFLAG="-Wall"
case "$host" in
mips-sgi-irix*)
if test "x$CXX" = "xCC"; then
WFLAG="-fullwarn";
fi
;;
*)
if test "x$CXX" = "xicpc" || test "x$CXX" = "xicc"; then
WFLAG="-w1"
fi
;;
esac
CFLAGS="$CFLAGS $WFLAG"
CXXFLAGS="$CXXFLAGS $WFLAG"
AC_OUTPUT( Makefile \
src/Makefile \
)

View File

@ -0,0 +1,146 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="John F. Fay">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<title>PUI-Based GUI Designer (P-GUIDE) Documentation</title>
</head>
<body>
<h1>
P-GUIDE Documentation</h1>
<h1>
PUI-Based Graphical User Interface Designer</h1>
P-GUIDE comes up in three OpenGL windows.&nbsp; The first window is the
Main window in which the user arranges the widgets of his graphical user
interface.&nbsp; The second window is the Widget window which contains
one button for each PUI widget class.&nbsp; The third window is the Status
window which allows the user to see and control various widget and window
parameters in the main window.
<br>The basic concept of P-GUIDE is that the user will click on a button
in the Widget window and then click in the Main window to create a widget
for his GUI.&nbsp; He will then use the Status window to modify the settings
of that widget.&nbsp; The Main window reflects the changes he makes in
real time.&nbsp; When the user has created as many widgets as he likes,
he clicks on the "Write Window Code" button in the Status window and P-GUIDE
will write a file of C++ code which implements the GUI using OpenGL, GLUT,
and PUI.
<br>P-GUIDE is offered to the PLIB community under a GNU Public License
(GPL).&nbsp; Users are free to modify the source code as they see fit but
must offer their changes back to the community.
<h2>
GUI Window Control</h2>
The user may size, position, color, and name his window by using the input
box widgets at the top of the Status window.&nbsp; All the changes except
the window position are reflected immediately in the Main window.
<br>The user may also change the size of his window by clicking on an edge
of the window and dragging on it.&nbsp; Any widgets which the user has
already defined and placed in the window will remain stationary while the
window is being resized; this means that if the user drags the left-hand
edge of the window to change its width, the x-coordinates of the widgets
will change.&nbsp; (The user is cautioned against moving his mouse off
one side of the window, dragging it around the outside of the window, and
clicking on the opposite side of the window from the outside.&nbsp; Due
to a limitation in the windowing system this will reposition the widgets
in the window incorrectly.)
<h2>
Placing Widgets</h2>
To place a widget in the GUI, the user clicks on that widget's button in
the Widget window and then clicks in the Main window.&nbsp; The new widget
will be placed in the Main window with its lower left-hand corner at the
mouse position.&nbsp; The widget will have an initial size of 90 pixels
wide by 20 pixels high.
<br>If the user wants to place more than one widget of the same type in
his GUI, he can press the Control key when he clicks on that widget's button
in the Widget window.&nbsp; He will then click in the Main window once
for each widget of the given type that he wants to create.&nbsp; Pressing
the Escape key or clicking on another widget's button in the Widget window
will deactivate the button.
<br>A widget which has just been placed or has just been clicked on by
the mouse is called the Active widget.&nbsp; It is surrounded by a black
line.
<h2>
Widget Settings</h2>
The user can control the following settings of his widget from controls
in the Status window:
<ul>
<li>
Name (the name of the variable which is the pointer to the widget in the
program)</li>
<li>
Position</li>
<li>
Size</li>
<li>
Legend text and position</li>
<li>
Label text and position</li>
<li>
Callbacks</li>
</ul>
The user may also modify the size and position of his widgets directly
in the Main window.&nbsp; To change the size, he clicks inside the widget
within five pixels of the edge and then drags the mouse to extend the widget.&nbsp;
To change the position he clicks inside the widget away from the edges
and drags the mouse.
<br>The user may also move the Active widget one pixel at a time by pressing
the four arrow keys.&nbsp; Holding the Control key while pressing the arrow
keys will move the Active widget ten pixels at a time.
<h2>
Widget Visibility</h2>
There are obviously times when the user will want to draw more than one
widget in the same place in the GUI and only show them one at a time.&nbsp;
To allow this capability the Status window has a button box which controls
whether the widget in the Main window is visible or not.&nbsp; To hide
a widget the user simply clicks on the "Visible" button box.&nbsp; If he
then clicks on the "Visible" button box again the Active widget will reappear.&nbsp;
If the user selects another Active widget, there is no simple and direct
way to make the single hidden widget reappear in the main window.
<br>To allow the user to make widgets reappear, the Status window has a
one-shot button labelled "Reveal All Widgets".&nbsp; This makes all the
widgets in the Main window visible again.&nbsp; The user can then select
the widgets he wishes to hide again and make them invisible.
<br>When the program writes the C++ code to create the GUI, the widgets
which are not visible in the Main window are hidden by default.
<h2>
Widget Layers</h2>
Many times the order in which widgets are drawn is of vital importance.&nbsp;
For example, the user may want to fill a window with a frame widget to
provide a pleasing background for the actual widgets of the GUI.&nbsp;
In order to allow this the program assigns each widget in the Main window
a layer number.&nbsp; These layer numbers start at zero and increase.&nbsp;
When the Main window is being drawn, the widgets in lower-numbered layers
are drawn first and the widgets with larger layer numbers are drawn after
(and therefore on top of) them.&nbsp; When the C++ code to create the GUI
is being written, the widgets in the lower-numbered layers are created
first.
<h2>
Program Controls</h2>
Basic program control is provided by the three buttons at the bottom of
the Status window.&nbsp; Clicking on the "Write Window Code" button will
cause a file selector widget to pop up for the user to enter a file name
into which the code is to be written.&nbsp; An entire file is written which
contains the necessary include, window data, a default font definition,
widget variable definitions, GLUT window callbacks, widget callbacks for
each widget, and a complete main program that creates and manages the GLUT
window, initializes PUI, creates the widgets, and calls the GLUT main loop.&nbsp;
(At the moment the widget definition calls are somewhat lacking and the
user will need to modify them before he can compile the code.)
<br>If the user clicks on the "Clear" button, all the widgets in the Main
window will be erased.&nbsp; If the user has changed the window at all
since the last time he wrote code or cleared the Main window, the program
will pop up a box asking if he is sure.
<br>If the user clicks on the "Quit" button, the program will stop.&nbsp;
Again, if there have been changes since the last code writing or clearing,
the program will ask if he is sure.
</body>
</html>

29
demos/p-guide/pGuide.dsw Normal file
View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "pGuide"=.\src\pGuide.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@ -0,0 +1,756 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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 of the License, or
(at your option) any later version.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: LoadSave.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
#include <stdio.h>
#include "WidgetList.h"
#define TAG_SAVEFILE 0x00000001
#define TAG_WINDOW 0x00000002
#define TAG_OBJECT 0x00000004
#define TAG_WIDGET 0x00000008
#define TAG_SIZE 0x00000010
#define TAG_POSITION 0x00000020
#define TAG_COLOR 0x00000040
#define TAG_LEGEND 0x00000080
#define TAG_LABEL 0x00000100
#define TAG_DATA 0x00000120
#define CALLBACK_UP 0x00000001
#define CALLBACK_ACTIVE 0x00000002
#define CALLBACK_DOWN 0x00000004
#ifdef WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif
// From the Main Window:
extern WidgetList *widgets ;
extern int max_layer ;
extern int main_window_width ;
extern int main_window_height ;
extern char main_window_name [ PUSTRING_MAX ] ;
extern int main_window_x ;
extern int main_window_y ;
extern int widget_number ;
extern bool main_window_changed ;
extern bool currently_loading ; /* Var for the Reshape function to not do its thing */
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern bool autolock ;
extern float main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ;
// From the Status Window
extern void setStatusWidgets ( WidgetList *wid );
extern int status_window ;
extern int main_window ;
extern puaFileSelector *file_selector ;
// Duplication checking
static void chk_dupname ( WidgetList *new_wid ) ;
static puInput *dup_newname = (puInput *)NULL ;
static puDialogBox *dup_dialog = (puDialogBox *)NULL ;
static WidgetList *nextwid ;
// Now our turn
void saveProject ( puObject *ob ) {
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
/* If they didn't give an extension, then tack ".xml" onto the end. */
if(!strstr(filename, "."))
sprintf(filename, "%s.xml", filename);
FILE *out = fopen ( filename, "wt" ) ;
if ( !out )
printf ( "ERROR opening file <%s> for writing\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !out ) return ;
/* Begin writing the XML */
const char *autolock_text;
if ( !autolock )
autolock_text="FALSE";
else
autolock_text="TRUE";
char projectname [] = "Test Project";
fprintf ( out, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE P-Guide>\n<savefile>\n\n" ) ;
fprintf ( out, "<version>VERSION</version>\n") ;
fprintf ( out, "<project>%s</project>\n", projectname) ;
fprintf ( out, "<autolock>%s</autolock>\n", autolock_text) ;
fprintf ( out, "<window>\n\t<name>%s</name>\n", main_window_name) ;
fprintf ( out, "\t<size>\n\t\t<width>%d</width>\n", main_window_width) ;
fprintf ( out, "\t\t<height>%d</height>\n\t</size>\n", main_window_height) ;
fprintf ( out, "\t<position>\n\t\t<x>%d</x>\n", main_window_x) ;
fprintf ( out, "\t\t<y>%d</y>\n\t</position>\n", main_window_y) ;
fprintf ( out, "\t<color>\n\t\t<r>%f</r>\n\t\t<g>%f</g>\n\t\t<b>%f</b>\n", main_window_color_r, main_window_color_g, main_window_color_b) ;
fprintf ( out, "\t\t<a>%f</a>\n\t</color>\n</window>\n\n", main_window_color_a) ;
fprintf ( out, "<objects>\n") ;
/* Now begin spitting out the actual widget data. */
WidgetList *wid = widgets ;
const char *place_name [] = { "PUPLACE_TOP_LEFT", "PUPLACE_TOP_CENTERED", "PUPLACE_TOP_RIGHT",
"PUPLACE_CENTERED_LEFT", "PUPLACE_CENTERED_RIGHT",
"PUPLACE_BOTTOM_LEFT", "PUPLACE_BOTTOM_CENTERED", "PUPLACE_BOTTOM_RIGHT",
"PUPLACE_CENTERED_CENTERED",
"PUPLACE_ABOVE_LEFT", "PUPLACE_ABOVE_RIGHT",
"PUPLACE_BELOW_LEFT", "PUPLACE_BELOW_RIGHT",
"PUPLACE_UPPER_LEFT", "PUPLACE_UPPER_RIGHT",
"PUPLACE_LOWER_LEFT", "PUPLACE_LOWER_RIGHT" } ;
while ( wid )
{
puObject *obj = wid->obj ;
int x, y, w, h ;
const char *hidden ;
const char *locked ;
const char *bool_one ;
const char *bool_two ;
const char *bool_three ;
obj->getPosition ( &x, &y ) ;
obj->getSize ( &w, &h ) ;
fprintf ( out, "\t<widget>\n\t\t<name>%s</name>\n", wid->object_name) ;
if (wid->legend_text != NULL)
fprintf ( out, "\t\t<legend>\n\t\t\t<text>%s</text>\n\t\t\t<pos>%s</pos>\n\t\t</legend>\n", wid->legend_text, place_name [ obj->getLegendPlace () ] ) ;
if (wid->label_text != NULL)
fprintf ( out, "\t\t<label>\n\t\t\t<text>%s</text>\n\t\t\t<pos>%s</pos>\n\t\t</label>\n", wid->label_text, place_name [ obj->getLabelPlace () ] ) ;
fprintf ( out, "\t\t<type>%s</type>\n", wid->object_type_name) ;
if ( !wid->visible )
hidden="FALSE";
else
hidden="TRUE";
if ( !wid->locked )
locked="FALSE";
else
locked="TRUE";
if ( wid->callbacks & CALLBACK_UP ) // Up-callback defined
fprintf ( out, "\t\t<callbacks>Up</callbacks>\n") ;
if ( wid->callbacks & CALLBACK_ACTIVE ) // Active callback defined
fprintf ( out, "\t\t<callbacks>Active</callbacks>\n") ;
if ( wid->callbacks & CALLBACK_DOWN ) // Down-callback defined
fprintf ( out, "\t\t<callbacks>Down</callbacks>\n") ;
if ( wid->callbacks == 0 )
fprintf ( out, "\t\t<callbacks></callbacks>\n") ;
fprintf ( out, "\t\t<layer>%d</layer>\n", wid->layer) ;
fprintf ( out, "\t\t<visible>%s</visible>\n", hidden) ;
fprintf ( out, "\t\t<locked>%s</locked>\n", locked) ;
fprintf ( out, "\t\t<size>\n\t\t\t<width>%d</width>\n\t\t\t<height>%d</height>\n\t\t</size>\n", w, h) ;
fprintf ( out, "\t\t<position>\n\t\t\t<x>%d</x>\n\t\t\t<y>%d</y>\n\t\t</position>\n", x, y) ;
fprintf ( out, "\t\t<data>\n\t\t\t<int1>%d</int1>\n\t\t\t<int2>%d</int2>\n", wid->intval1, wid->intval2) ;
if ( wid->boolval1 )
bool_one = "TRUE";
else
bool_one = "FALSE";
if ( wid->boolval2 )
bool_two = "TRUE";
else
bool_two = "FALSE";
if ( wid->boolval3 )
bool_three = "TRUE";
else
bool_three = "FALSE";
fprintf ( out, "\t\t\t<bool1>%s</bool1>\n\t\t\t<bool2>%s</bool2>\n\t\t\t<bool3>%s</bool3>\n", bool_one, bool_two, bool_three) ;
fprintf ( out, "\t\t\t<float1>%f</float1>\n\t\t\t<float2>%f</float2>\n", wid->floatval1, wid->floatval2) ;
fprintf ( out, "\t\t\t<float3>%f</float3>\n\t\t\t<float4>%f</float4>\n", wid->floatval3, wid->floatval4) ;
fprintf ( out, "\t\t\t<float5>%f</float5>\n\t\t\t<float6>%f</float6>\n", wid->floatval5, wid->floatval6) ;
if (wid->allowed)
fprintf ( out, "\t\t\t<allowed>%s</allowed>\n", wid->allowed) ;
/* Walk through the list of items, and make a seperate <items> entry for each line in the string */
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
while ( cr != '\0' )
{
*cr = '\0';
fprintf ( out, "\t\t\t<item>%s</item>\n", temp_items);
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
if (wid->object_type == PUCLASS_ARROW)
{
fprintf ( out, "\t\t\t<item>%s</item>\n", temp_items);
}
}
fprintf ( out, "\t\t</data>\n\t</widget>\n") ;
wid = wid->next ;
}
fprintf ( out, "</objects>\n</savefile>\n") ; /* XML output done */
fclose (out) ;
}
/*static void gotoNextLine( char* buffer )
{
while (buffer != "\n")
buffer++ ;
}*/
void loadProject ( puObject *ob ) {
extern puInput *window_name ;
extern puInput *window_size_x ;
extern puInput *window_size_y ;
extern puInput *window_position_x ;
extern puInput *window_position_y ;
extern puaSpinBox *window_color_r ;
extern puaSpinBox *window_color_g ;
extern puaSpinBox *window_color_b ;
extern puaSpinBox *window_color_a ;
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
FILE *in = fopen ( filename, "rt" ) ;
if ( !in )
printf ( "ERROR opening file <%s> for reading\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !in ) return ;
char rawbuffer[2048];
// Verify file is XML
float tver = 0.0f ;
char encversion[PUSTRING_MAX];
fgets( rawbuffer, sizeof(rawbuffer), in) ;
sscanf(rawbuffer,"<?xml version=\"%f\" encoding=\"%s\" ?>", &tver, encversion) ;
if (!tver) {
printf ("File does not contain proper XML headings.\n");
return ;
}
// Verify file is P-Guide
char tag[PUSTRING_MAX] ;
char tagvalue[PUSTRING_MAX] ;
fgets( rawbuffer, sizeof(rawbuffer), in) ;
if (!sscanf(rawbuffer,"<!DOCTYPE %s>", tag)) {
printf ("File, though XML, does not contain P-Guide information (or has damaged header information).\n");
return ;
}
// Start reading XML
main_window_changed = true ;
currently_loading = true ;
int groupid = 0 ;
puObject *new_obj = NULL;
WidgetList *new_wid = NULL ;
/* Dandy little variables */
int wid_val_y = 0, wid_val_x = 0, val_object_width = 20, val_object_height = 20, val_label_place = 4, val_legend_place = 8;
int intval1 = 0, intval2 = 0 ;
bool boolval1 = false, boolval2 = false, boolval3 = false ;
float floatval1 = 0.0f, floatval2 = 0.0f, floatval3 = 0.0f, floatval4 = 0.0f, floatval5 = 0.0f, floatval6 = 0.0f;
while(fgets( rawbuffer, sizeof(rawbuffer), in))
{
/**************************************************************/
/* Key for Groups in our XML file located at top of this file */
/**************************************************************/
*tag = '\0';
*tagvalue = '\0';
char *buffer = rawbuffer;
/* From here on we walk, line by line, through the XML and parse any tags we come to. */
while (*buffer == '\t' || *buffer == ' ') /* Ignore the tabs and spaces */
buffer++ ;
sscanf(buffer,"<%[^>]>", tag); /* Get the tag */
while (*buffer !='>') buffer++;
sscanf(buffer,">%[a-zA-Z_!@#$^&*0123456789-+/\\{}()=~`,. ]</", tagvalue) ; /* Get the tag's value. */
/* Classify the tag, so we know where the next will fit. */
if ( strstr(tag,"savefile") ) groupid |= TAG_SAVEFILE ;
if ( strstr(tag,"window") ) groupid |= TAG_WINDOW ;
if ( strstr(tag,"size") ) groupid |= TAG_SIZE ;
if ( strstr(tag,"position") ) groupid |= TAG_POSITION ;
if ( strstr(tag,"color") ) groupid |= TAG_COLOR ;
if ( strstr(tag,"object") ) groupid |= TAG_OBJECT ;
if ( strstr(tag,"widget") ) groupid |= TAG_WIDGET ;
if ( strstr(tag,"legend") ) groupid |= TAG_LEGEND ;
if ( strstr(tag,"label") ) groupid |= TAG_LABEL ;
if ( strstr(tag,"data") ) groupid |= TAG_DATA ;
/* Note: Order here matters, since the strstrs above WILL match closing tags. This */
/* doesn't hurt anything, as long as we remove the bitset when we realize they are */
/* close tags, not open ones. */
/* De-classify the tag, so we know where it doesn't fit. */
if ( strstr(tag,"/savefile") ) groupid ^= TAG_SAVEFILE ;
if ( strstr(tag,"/window") ) groupid ^= TAG_WINDOW ;
if ( strstr(tag,"/size") ) groupid ^= TAG_SIZE ;
if ( strstr(tag,"/position") ) groupid ^= TAG_POSITION ;
if ( strstr(tag,"/color") ) groupid ^= TAG_COLOR ;
if ( strstr(tag,"/object") ) groupid ^= TAG_OBJECT ;
if ( strstr(tag,"/widget") ) groupid ^= TAG_WIDGET ;
if ( strstr(tag,"/legend") ) groupid ^= TAG_LEGEND ;
if ( strstr(tag,"/label") ) groupid ^= TAG_LABEL ;
if ( strstr(tag,"/data") ) groupid ^= TAG_DATA ;
/* Now that the tag's classifcation has been determined, rip the data */
/* viciously from its' hold and throw it onto the memory stack. */
if (groupid & TAG_SAVEFILE )
{
/* NULLCHECK! */
if (tagvalue[0] == '\0') { sprintf(tagvalue, " "); }
if ( strstr(tag,"autolock") )
{
if (strstr(tagvalue, "TRUE"))
autolock = true ;
else
autolock = false ;
}
if (groupid & TAG_WINDOW)
{
if ( strstr(tag,"name") )
{
window_name->setValue(tagvalue) ;
strcpy(main_window_name, tagvalue);
}
if (groupid & TAG_SIZE)
{
if ( strstr(tag,"width") )
window_size_x->setValue(tagvalue) ;
if ( strstr(tag,"height") )
window_size_y->setValue(tagvalue) ;
}
if (groupid & TAG_POSITION)
{
if ( strstr(tag,"x") )
window_position_x->setValue(tagvalue) ;
if ( strstr(tag,"y") )
window_position_y->setValue(tagvalue) ;
}
if (groupid & TAG_COLOR)
{
if ( strstr(tag,"r") )
window_color_r->setValue(tagvalue) ;
if ( strstr(tag,"g") )
window_color_g->setValue(tagvalue) ;
if ( strstr(tag,"b") )
window_color_b->setValue(tagvalue) ;
if ( strstr(tag,"a") )
window_color_a->setValue(tagvalue) ;
}
}
if (groupid & TAG_OBJECT)
{
if ( strstr(tag,"/widget") )
{
extern WidgetList *widgets ;
/* Create a new frame in the viewing window (for manipulation). */
new_obj = new puFrame ( 0, 0, val_object_width, val_object_height ) ;
new_obj->setWindow( main_window ) ;
/* Set the representative widget's position */
new_obj->setPosition ( wid_val_x, wid_val_y ) ;
new_obj->setLegend ( new_wid->object_type_name ) ;
new_obj->setLegendPlace ( val_legend_place ) ;
if (new_wid->label_text)
{
new_obj->setLabel ( new_wid->label_text ) ;
new_obj->setLabelPlace ( val_label_place ) ; /**/
}
new_wid->boolval1 = boolval1;
new_wid->boolval2 = boolval2;
new_wid->boolval3 = boolval3;
new_wid->intval1 = intval1;
new_wid->intval2 = intval2;
new_wid->floatval1 = floatval1;
new_wid->floatval2 = floatval2;
new_wid->floatval3 = floatval3;
new_wid->floatval4 = floatval4;
new_wid->floatval5 = floatval5;
new_wid->floatval6 = floatval6;
intval1 = intval2 = 0 ;
boolval1 = boolval2 = boolval3 = false ;
floatval1 = floatval2 = floatval3 = floatval4 = floatval5 = floatval6 = 0.0f;
new_wid->obj = new_obj ;
new_wid->next = widgets ;
widgets = new_wid ;
} else if ( strstr(tag,"widget") ) {
/* Add the new object to the list of widgets (for the builder itself) */
new_wid = new WidgetList ;
/* Set those dandy variables */
wid_val_y = 0; wid_val_x = 0;
val_object_width = 20; val_object_height = 20;
val_label_place = 4; val_legend_place = 8;
new_wid->callbacks = 0;
new_wid->allowed = (char *)NULL ;
new_wid->items = (char *)NULL ;
new_wid->locked = false;
new_wid->legend_text = NULL ;
new_wid->label_text = NULL ;
}
if (groupid & TAG_WIDGET)
{
if ( strstr(tag,"name") )
{
strcpy(new_wid->object_name, tagvalue) ;
/* As names are copied, look for defaults (widget0..9999), */
/* and if it's higher than the current widget_number, set */
/* widget_number to it. */
int tmp_wid_num = 0;
sscanf(tagvalue, "widget%d", &tmp_wid_num) ;
if (tmp_wid_num >= widget_number) widget_number = tmp_wid_num + 1;
}
if ( strstr(tag,"type") )
{
new_wid->object_type = 0 ;
new_wid->object_type_name = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->object_type_name, tagvalue) ;
/* BEWARE: Popup[menu], BiSlider[WithEnds], and Button[box] want to be each other! Don't let them! */
if ( strstr(new_wid->object_type_name, "puaList")) new_wid->object_type |= PUCLASS_LIST ;
if ( strstr(new_wid->object_type_name, "puaChooser")) new_wid->object_type |= PUCLASS_CHOOSER ;
if ( strstr(new_wid->object_type_name, "puaSliderWithInput")) new_wid->object_type |= PUCLASS_SLIDERWITHINPUT ;
if ( strstr(new_wid->object_type_name, "puaBiSliderWithEnds")) new_wid->object_type |= PUCLASS_BISLIDERWITHENDS ;
else if ( strstr(new_wid->object_type_name, "puaBiSlider")) new_wid->object_type |= PUCLASS_BISLIDER ;
if ( strstr(new_wid->object_type_name, "puaScrollBar")) new_wid->object_type |= PUCLASS_SCROLLBAR ;
if ( strstr(new_wid->object_type_name, "puaSpinBox")) new_wid->object_type |= PUCLASS_SPINBOX ; /**/
if ( strstr(new_wid->object_type_name, "puaSelectBox")) new_wid->object_type |= PUCLASS_SELECTBOX ;
if ( strstr(new_wid->object_type_name, "puaComboBox")) new_wid->object_type |= PUCLASS_COMBOBOX ;
if ( strstr(new_wid->object_type_name, "puaLargeInput")) new_wid->object_type |= PUCLASS_LARGEINPUT ;
if ( strstr(new_wid->object_type_name, "puaVerticalMenu")) new_wid->object_type |= PUCLASS_VERTMENU ;
if ( strstr(new_wid->object_type_name, "puaTriSlider")) new_wid->object_type |= PUCLASS_TRISLIDER ;
if ( strstr(new_wid->object_type_name, "puaFileSelector")) new_wid->object_type |= PUCLASS_FILESELECTOR ;
if ( strstr(new_wid->object_type_name, "puDial")) new_wid->object_type |= PUCLASS_DIAL ;
if ( strstr(new_wid->object_type_name, "puListBox")) new_wid->object_type |= PUCLASS_LISTBOX ;
if ( strstr(new_wid->object_type_name, "puArrowButton")) new_wid->object_type |= PUCLASS_ARROW ;
if ( strstr(new_wid->object_type_name, "puDialogBox")) new_wid->object_type |= PUCLASS_DIALOGBOX ; /**/
if ( strstr(new_wid->object_type_name, "puSlider")) new_wid->object_type |= PUCLASS_SLIDER ;
if ( strstr(new_wid->object_type_name, "puButtonBox")) new_wid->object_type |= PUCLASS_BUTTONBOX ;
else if ( strstr(new_wid->object_type_name, "puButton")) new_wid->object_type |= PUCLASS_BUTTON ; /* See above for why the elses' */
if ( strstr(new_wid->object_type_name, "puInput")) new_wid->object_type |= PUCLASS_INPUT ;
if ( strstr(new_wid->object_type_name, "puMenuBar")) new_wid->object_type |= PUCLASS_MENUBAR ;
if ( strstr(new_wid->object_type_name, "puPopupMenu")) new_wid->object_type |= PUCLASS_POPUPMENU ; /**/
else if ( strstr(new_wid->object_type_name, "puPopup")) new_wid->object_type |= PUCLASS_POPUP ; /**/
if ( strstr(new_wid->object_type_name, "puOneShot")) new_wid->object_type |= PUCLASS_ONESHOT ;
if ( strstr(new_wid->object_type_name, "puText")) new_wid->object_type |= PUCLASS_TEXT ;
if ( strstr(new_wid->object_type_name, "puFrame")) new_wid->object_type |= PUCLASS_FRAME ;
}
if ( strstr(tag,"callbacks") )
{
/* Update callback's bit set */
if (strstr(tagvalue, "Up")) new_wid->callbacks |= CALLBACK_UP ;
if (strstr(tagvalue, "Down")) new_wid->callbacks |= CALLBACK_DOWN ;
if (strstr(tagvalue, "Active")) new_wid->callbacks |= CALLBACK_ACTIVE ;
}
if ( strstr(tag,"layer") )
{
new_wid->layer = atoi(tagvalue) ;
if ( max_layer <= new_wid->layer ) max_layer = new_wid->layer + 1 ;
}
if ( strstr(tag,"visible") )
{
if (strstr(tagvalue, "TRUE"))
new_wid->visible = true ;
else
new_wid->visible = false ;
}
if ( strstr(tag,"locked") )
{
if (strstr(tagvalue, "TRUE"))
new_wid->locked = true ;
else
new_wid->locked = false ;
}
if (groupid & TAG_LEGEND)
{
if ( strstr(tag,"text") )
{
delete new_wid->legend_text;
new_wid->legend_text = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->legend_text, tagvalue) ;
}
if ( strstr(tag,"pos") )
{
if (strstr(tagvalue, "PUPLACE_TOP_LEFT")) val_legend_place = PUPLACE_TOP_LEFT ;
if (strstr(tagvalue, "PUPLACE_TOP_CENTERED")) val_legend_place = PUPLACE_TOP_CENTERED ;
if (strstr(tagvalue, "PUPLACE_TOP_RIGHT")) val_legend_place = PUPLACE_TOP_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_LEFT")) val_legend_place = PUPLACE_CENTERED_LEFT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_RIGHT")) val_legend_place = PUPLACE_CENTERED_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_LEFT")) val_legend_place = PUPLACE_BOTTOM_LEFT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_CENTERED")) val_legend_place = PUPLACE_BOTTOM_CENTERED ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_RIGHT")) val_legend_place = PUPLACE_BOTTOM_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_CENTERED")) val_legend_place = PUPLACE_CENTERED_CENTERED ;
}
}
if (groupid & TAG_LABEL)
{
if ( strstr(tag,"text") )
{
delete new_wid->label_text;
new_wid->label_text = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->label_text, tagvalue) ;
}
if ( strstr(tag,"pos") )
{
if (strstr(tagvalue, "PUPLACE_TOP_LEFT")) val_label_place = PUPLACE_TOP_LEFT ;
if (strstr(tagvalue, "PUPLACE_TOP_CENTERED")) val_label_place = PUPLACE_TOP_CENTERED ;
if (strstr(tagvalue, "PUPLACE_TOP_RIGHT")) val_label_place = PUPLACE_TOP_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_LEFT")) val_label_place = PUPLACE_CENTERED_LEFT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_RIGHT")) val_label_place = PUPLACE_CENTERED_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_LEFT")) val_label_place = PUPLACE_BOTTOM_LEFT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_CENTERED")) val_label_place = PUPLACE_BOTTOM_CENTERED ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_RIGHT")) val_label_place = PUPLACE_BOTTOM_RIGHT ;
if (strstr(tagvalue, "PUPLACE_ABOVE_LEFT")) val_label_place = PUPLACE_ABOVE_LEFT ;
if (strstr(tagvalue, "PUPLACE_ABOVE_RIGHT")) val_label_place = PUPLACE_ABOVE_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BELOW_LEFT")) val_label_place = PUPLACE_BELOW_LEFT ;
if (strstr(tagvalue, "PUPLACE_BELOW_RIGHT")) val_label_place = PUPLACE_BELOW_RIGHT ;
if (strstr(tagvalue, "PUPLACE_UPPER_LEFT")) val_label_place = PUPLACE_UPPER_LEFT ;
if (strstr(tagvalue, "PUPLACE_UPPER_RIGHT")) val_label_place = PUPLACE_UPPER_RIGHT ;
if (strstr(tagvalue, "PUPLACE_LOWER_LEFT")) val_label_place = PUPLACE_LOWER_LEFT ;
if (strstr(tagvalue, "PUPLACE_LOWER_RIGHT")) val_label_place = PUPLACE_LOWER_RIGHT ;
}
}
if (groupid & TAG_SIZE)
{
if ( strstr(tag,"width") )
val_object_width = atoi(tagvalue) ;
if ( strstr(tag,"height") )
val_object_height = atoi(tagvalue) ;
}
if (groupid & TAG_POSITION)
{
if ( strstr(tag,"x") )
wid_val_x = atoi(tagvalue) ;
if ( strstr(tag,"y") )
wid_val_y = atoi(tagvalue) ;
}
if (groupid & TAG_DATA)
{
if ( strstr(tag,"int1") )
intval1 = atoi (tagvalue) ;
if ( strstr(tag,"int2") )
intval2 = atoi (tagvalue) ;
if ( strstr(tag,"bool1") )
{
if (strstr(tagvalue, "TRUE"))
boolval1 = true ;
else
boolval1 = false ;
}
if ( strstr(tag,"bool2") )
{
if (strstr(tagvalue, "TRUE"))
boolval2 = true ;
else
boolval2 = false ;
}
if ( strstr(tag,"bool3") )
{
if (strstr(tagvalue, "TRUE"))
boolval3 = true ;
else
boolval3 = false ;
}
if ( strstr(tag,"float1") )
floatval1 = (float)atof (tagvalue) ;
if ( strstr(tag,"float2") )
floatval2 = (float)atof (tagvalue) ;
if ( strstr(tag,"float3") )
floatval3 = (float)atof (tagvalue) ;
if ( strstr(tag,"float4") )
floatval4 = (float)atof (tagvalue) ;
if ( strstr(tag,"float5") )
floatval5 = (float)atof (tagvalue) ;
if ( strstr(tag,"float6") )
floatval6 = (float)atof (tagvalue) ;
if ( strstr(tag,"allowed") )
{
new_wid->allowed = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->allowed, tagvalue) ;
}
if ( strstr(tag,"item") )
{
strcat(tagvalue, "\n");
if (!new_wid->items)
{
new_wid->items = new char [1024] ;
strcpy(new_wid->items, tagvalue) ;
}
else
strcat(new_wid->items, tagvalue) ;
}
}
}
}
}
if (strstr(tag, "/savefile"))
{
static int mouse_x ;
static int mouse_y ;
setStatusWidgets( new_wid );
glutSetWindow ( main_window ) ;
glutSetWindowTitle ( window_name->getStringValue() ) ;
/* Fake out the Reshape parts that determine whether to move widgets around or not. */
mouse_x = 999 ;
mouse_y = 999 ;
glutReshapeWindow ( window_size_x->getValue(), window_size_y->getValue() ) ;
glutSetWindow ( status_window ) ;
}
buffer[0] = '\0';
}
fclose (in);
WidgetList *wid = widgets;
/* Check name for duplication */
nextwid = wid; /* Note: Yes, this is inelegant, but if we loop here, we end up making many copies of the same dialog box in the same memory space. This is a Bad Thing. */
chk_dupname(nextwid);
/* Done checking name for duplication */
}
static void chk_dupname_ok_cb ( puObject *ob )
{
/* The user's new name from the dialog has already been set to the object_name*/
/* Close dialogbox and update main window ...*/
puDeleteObject ( dup_dialog ) ;
dup_dialog = (puDialogBox *)NULL ;
dup_newname = (puInput *)NULL ;
/*but force a recheck afterwards to ensure it's an okay substitution. */
nextwid = nextwid->next ;
chk_dupname(nextwid);
}
static void chk_dupname ( WidgetList *new_wid )
{
if (!new_wid)
return;
WidgetList *wid = widgets ;
while ( wid )
{
if ( (strcmp(new_wid->object_name,wid->object_name) == 0) && (new_wid != wid) )
{
/* Popup a dialog telling user something's bad! */
dup_dialog = new puDialogBox ( 20, 20 ) ;
new puFrame ( 0, 0, 460, 120 ) ;
puText *text = new puText ( 80, 85 ) ;
text->setLabel ( "ERROR: Name already used." ) ;
text->setLabelFont(PUFONT_TIMES_ROMAN_24);
puText *directions = new puText ( 90, 65 ) ;
directions->setLabel ( "Please type in a new, unique name to continue." ) ;
directions->setLabelFont(PUFONT_HELVETICA_12);
dup_newname = new puInput (20,40,440,60) ;
dup_newname->setValuator(new_wid->object_name);
dup_newname->setValidData("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_012345679");
puOneShot *ok = new puOneShot ( 200, 10, "Accept" ) ;
ok->setCallback ( chk_dupname_ok_cb ) ;
dup_dialog->close () ;
dup_dialog->reveal () ;
break ;
}
wid = wid->next ;
}
}

View File

@ -0,0 +1,9 @@
bin_PROGRAMS = pguide
pguide_SOURCES = pGuide.cxx StatusWindow.cxx WidgetList.h \
WidgetWindow.cxx WriteCode.cxx LoadSave.cxx PropertiesWindow.cxx
pguide_LDADD = -lplibpuaux
EXTRA_DIST = pGuide.dsp

View File

@ -0,0 +1,610 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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 of the License, or
(at your option) any later version.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: PropertiesWindow.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Status Window
#include <plib/pu.h>
#include "WidgetList.h"
// From the Main Window:
extern int max_layer ;
extern WidgetList *active_widget ;
extern puObject *active_object ;
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern bool main_window_changed ;
// Status window parameters
int properties_window = 0 ; // Window handle
extern int main_window ;
// Status window widgets
puGroup *properties_group ;
// Function to set the widgets from the active object
// GLUT Status Window Callbacks
static void properties_window_specialfn ( int key, int, int )
{
puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;
glutPostRedisplay () ;
}
static void properties_window_keyfn ( unsigned char key, int, int )
{
puKeyboard ( key, PU_DOWN ) ;
glutPostRedisplay () ;
}
static void properties_window_motionfn ( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}
static void properties_window_mousefn ( int button, int updown, int x, int y )
{
puMouse ( button, updown, x, y ) ;
glutPostRedisplay () ;
}
static void properties_window_displayfn ( void )
{
glutSetWindow ( properties_window ) ;
/* Clear the screen */
glClearColor ( 0.1f, 0.1f, 0.1f, 1.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
puDisplay () ;
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
// PUI Callback Functions:
static void cb_properties_close (puObject *obj)
{
/* Save the changes ... Needed? */
if ( puActiveWidget() )
puActiveWidget() -> invokeDownCallback () ; /* Just make sure the last widget saves ... */
/* Delete the widgets */
puDeleteObject( properties_group );
/* Destroy the window */
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
// Data setting standard callbacks
static void cb_items (puObject *obj)
{
/*Set the Items*/
if (active_widget)
{
delete active_widget->items;
active_widget->items = new char [strlen(obj->getStringValue())+1] ;
strcpy(active_widget->items, obj->getStringValue());
}
}
static void cb_allowed (puObject *obj)
{
/*Set the Allowed string*/
if (active_widget)
{
delete active_widget->allowed;
active_widget->allowed = new char [strlen(obj->getStringValue())+1] ;
strcpy(active_widget->allowed, obj->getStringValue());
}
}
static void cb_int1 (puObject *obj)
{
/*Set the first integer storage value */
if (active_widget)
active_widget->intval1 = obj->getIntegerValue();
}
static void cb_int2 (puObject *obj)
{
/*Set the second integer storage value */
if (active_widget)
active_widget->intval2 = obj->getIntegerValue();
}
static void cb_bool1 (puObject *obj)
{
/*Set the first boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval1 = true ;
else
active_widget->boolval1 = false ;
}
}
static void cb_bool2 (puObject *obj)
{
/*Set the second boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval2 = true ;
else
active_widget->boolval2 = false ;
}
}
static void cb_bool3 (puObject *obj)
{
/*Set the second boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval3 = true ;
else
active_widget->boolval3 = false ;
}
}
static void cb_float1 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval1 = obj->getFloatValue();
}
static void cb_float2 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval2 = obj->getFloatValue();
}
static void cb_float3 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval3 = obj->getFloatValue();
}
static void cb_float4 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval4 = obj->getFloatValue();
}
static void cb_float5 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval5 = obj->getFloatValue();
}
static void cb_float6 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval6 = obj->getFloatValue();
}
// Function to define the window
int define_properties_window ()
{
properties_window = glutCreateWindow ( "Properties" ) ;
glutPositionWindow ( 400, 200 ) ;
glutReshapeWindow ( 500, 250 ) ;
glutDisplayFunc ( properties_window_displayfn ) ;
glutKeyboardFunc ( properties_window_keyfn ) ;
glutSpecialFunc ( properties_window_specialfn ) ;
glutMotionFunc ( properties_window_motionfn ) ;
glutMouseFunc ( properties_window_mousefn ) ;
// Set up the widgets
properties_group = new puGroup ( 0, 0 ) ;
new puFrame ( 0, 0, 500, 250 ) ;
puText *properties_instructions = new puText ( 250, 230 );
properties_instructions->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_instructions->setLabel("Here are the extended options for your");
puText *properties_typelabel = new puText ( 250, 215 );
properties_typelabel->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_typelabel->setLabel(active_widget->object_type_name);
puOneShot *properties_close = new puOneShot ( 370, 10, 490, 30 ) ;
properties_close->setLegend("Accept");
properties_close->setCallback(cb_properties_close);
/* puStyle stuff here*/
/* Now customize the display based on the widget currently selected */
if (active_widget->object_type == PUCLASS_FRAME)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for a puFrame.");
} if (active_widget->object_type == PUCLASS_TEXT)
{
/* Add in font properties? */
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puText.");
} if (active_widget->object_type == PUCLASS_BUTTON)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puButton.");
} if (active_widget->object_type == PUCLASS_ONESHOT)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puOneShot.");
} if ( (active_widget->object_type == PUCLASS_POPUPMENU) ||
(active_widget->object_type == PUCLASS_MENUBAR) ||
(active_widget->object_type == PUCLASS_VERTMENU) ||
(active_widget->object_type == PUCLASS_LISTBOX) ||
(active_widget->object_type == PUCLASS_COMBOBOX) ||
(active_widget->object_type == PUCLASS_SELECTBOX) ||
(active_widget->object_type == PUCLASS_BUTTONBOX) ||
(active_widget->object_type == PUCLASS_LIST) )
{
/* List */
puaLargeInput *properties_list_items = new puaLargeInput(10,10,300,195,0,5);
properties_list_items->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_items->setLabel("Enter items, each on a new line.");
properties_list_items->setValidData("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_012345679 :;.,\n");
properties_list_items->setCallback(cb_items);
properties_list_items->setDownCallback(cb_items);
properties_list_items->setValue(active_widget->items);
puText *properties_list_note = new puText(400,190);
properties_list_note->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_note->setLabel("Each line will become");
puText *properties_list_note2 = new puText(400,175);
properties_list_note2->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_note2->setLabel("a selection option.");
} if (active_widget->object_type == PUCLASS_POPUPMENU)
{
/* Allow a list of menu items, and remember to point out these are hidden when created, and must be reveal()ed. */
/* NOT CURRENTLY IMPLEMENTED */
puText *properties_popupmenu_warning = new puText(400,150);
properties_popupmenu_warning->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_popupmenu_warning->setLabel("WARNING: Popup Menus are hidden by \
default when created. You must use \
reveal() to make them appear.");
} if (active_widget->object_type == PUCLASS_MENUBAR)
{
/* Allow a list of menu items */
} if (active_widget->object_type == PUCLASS_VERTMENU)
{
/* Allow a list of menu items */
} if (active_widget->object_type == PUCLASS_LISTBOX)
{
/* Allow a list of items */
} if (active_widget->object_type == PUCLASS_COMBOBOX)
{
/* List and a setCurrentItem, and if editable */
puaSpinBox *properties_combobox_currentitem = new puaSpinBox(320,135,480,155);
properties_combobox_currentitem->setLabel("Initial Selection:");
properties_combobox_currentitem->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_combobox_currentitem->setMinValue(0.0f);
properties_combobox_currentitem->setMaxValue(30.0f);
properties_combobox_currentitem->setCallback(cb_int1);
properties_combobox_currentitem->setValue(active_widget->intval1);
static char *properties_combobox_editable_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_combobox_editable = new puButtonBox(320, 50, 480, 120, properties_combobox_editable_callback_entries, TRUE);
properties_combobox_editable->setLabel("Editable?");
properties_combobox_editable->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_combobox_editable->setCallback(cb_bool1);
properties_combobox_editable->setValue(active_widget->boolval1);
} if (active_widget->object_type == PUCLASS_SELECTBOX)
{
/* List and a setCurrentItem */
puaSpinBox *properties_selectbox_currentitem = new puaSpinBox(320,135,480,155);
properties_selectbox_currentitem->setLabel("Initial Selection:");
properties_selectbox_currentitem->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_selectbox_currentitem->setMinValue(0.0f);
properties_selectbox_currentitem->setMaxValue(30.0f);
properties_selectbox_currentitem->setCallback(cb_int1);
properties_selectbox_currentitem->setValue(active_widget->intval1);
} if (active_widget->object_type == PUCLASS_BUTTONBOX)
{
/* Allow a list of menu items, and if multiple can be selected at once */
puText *properties_buttonbox_label = new puText(400,135);
properties_buttonbox_label->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_buttonbox_label->setLabel("Allow multiple");
static char *properties_buttonbox_multiselect_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_buttonbox_multiselect = new puButtonBox(320, 50, 480, 120, properties_buttonbox_multiselect_callback_entries, TRUE);
properties_buttonbox_multiselect->setLabel("selections?");
properties_buttonbox_multiselect->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_buttonbox_multiselect->setCallback(cb_bool1);
properties_buttonbox_multiselect->setValue(active_widget->boolval1);
} if ( (active_widget->object_type == PUCLASS_SLIDER ) ||
(active_widget->object_type == PUCLASS_BISLIDER ) ||
(active_widget->object_type == PUCLASS_TRISLIDER ) ||
(active_widget->object_type == PUCLASS_DIAL ) ||
(active_widget->object_type == PUCLASS_SPINBOX ) ||
(active_widget->object_type == PUCLASS_SCROLLBAR ) ||
(active_widget->object_type == PUCLASS_SLIDERWITHINPUT ) ||
(active_widget->object_type == PUCLASS_BISLIDERWITHENDS ))
{
/* int minx, int miny, int sz, {TRUE|FALSE}, int width */
puaSpinBox *properties_range_setmaxvalue = new puaSpinBox(30,150,110,170);
properties_range_setmaxvalue->setLabel("Maximum Value:");
properties_range_setmaxvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setmaxvalue->setMinValue(-5000.0f);
properties_range_setmaxvalue->setMaxValue(5000.0f);
properties_range_setmaxvalue->setCallback(cb_float1);
properties_range_setmaxvalue->setValue(active_widget->floatval1);
puaSpinBox *properties_range_setminvalue = new puaSpinBox(230,150,310,170);
properties_range_setminvalue->setLabel("Minimum Value:");
properties_range_setminvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setminvalue->setMinValue(-5000.0f);
properties_range_setminvalue->setMaxValue(5000.0f);
properties_range_setminvalue->setCallback(cb_float2);
properties_range_setminvalue->setValue(active_widget->floatval2);
puaSpinBox *properties_range_setstepvalue = new puaSpinBox(400,150,480,170);
properties_range_setstepvalue->setLabel("Step Size:");
properties_range_setstepvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setstepvalue->setMinValue(0.0f);
properties_range_setstepvalue->setMaxValue(5000.0f);
properties_range_setstepvalue->setCallback(cb_float3);
properties_range_setstepvalue->setValue(active_widget->floatval3);
static char *properties_range_cbmode_callback_entries [] = { "On Click", "Always", NULL } ;
puButtonBox *properties_range_cbmode = new puButtonBox(20, 80, 170, 130, properties_range_cbmode_callback_entries, TRUE);
properties_range_cbmode->setLabel("Callback Mode:");
properties_range_cbmode->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_cbmode->setCallback(cb_bool1);
properties_range_cbmode->setValue(active_widget->boolval1);
} if ( (active_widget->object_type == PUCLASS_SLIDER ) ||
(active_widget->object_type == PUCLASS_BISLIDER ) ||
(active_widget->object_type == PUCLASS_TRISLIDER ) ||
(active_widget->object_type == PUCLASS_SCROLLBAR ) )
{
static char *properties_range_vertical_callback_entries [] = { "Horizontal", "Vertical", NULL } ;
puButtonBox *properties_range_vertical = new puButtonBox(20, 10, 170, 60, properties_range_vertical_callback_entries, TRUE);
properties_range_vertical->setLabel("Orientation:");
properties_range_vertical->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_vertical->setValue(active_widget->boolval2);
properties_range_vertical->setCallback(cb_bool2);
} if (active_widget->object_type == PUCLASS_SLIDER)
{
puaSpinBox *properties_slider_value = new puaSpinBox(230,110,310,130);
properties_slider_value->setLabel("Starting Value:");
properties_slider_value->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_slider_value->setMinValue(-5000.0f);
properties_slider_value->setMaxValue(5000.0f);
properties_slider_value->setValue(active_widget->floatval4);
properties_slider_value->setStepSize(0.1f);
properties_slider_value->setCallback(cb_float4);
} if ((active_widget->object_type == PUCLASS_BISLIDER) ||
(active_widget->object_type == PUCLASS_BISLIDERWITHENDS))
{
puaSpinBox *properties_bislider_topvalue = new puaSpinBox(230,110,310,130);
properties_bislider_topvalue->setLabel("Top Slider Value:");
properties_bislider_topvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_bislider_topvalue->setMinValue(-5000.0f);
properties_bislider_topvalue->setMaxValue(5000.0f);
properties_bislider_topvalue->setValue(active_widget->floatval4);
properties_bislider_topvalue->setStepSize(0.1f);
properties_bislider_topvalue->setCallback(cb_float4);
puaSpinBox *properties_bislider_botvalue = new puaSpinBox(230,40,310,60);
properties_bislider_botvalue->setLabel("Bottom Slider Value:");
properties_bislider_botvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_bislider_botvalue->setMinValue(-5000.0f);
properties_bislider_botvalue->setMaxValue(5000.0f);
properties_bislider_botvalue->setValue(active_widget->floatval5);
properties_bislider_botvalue->setStepSize(0.1f);
properties_bislider_botvalue->setCallback(cb_float5);
} if (active_widget->object_type == PUCLASS_TRISLIDER)
{
puaSpinBox *properties_trislider_topvalue = new puaSpinBox(230,110,310,130);
properties_trislider_topvalue->setLabel("Top Slider Value:");
properties_trislider_topvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_topvalue->setMinValue(-5000.0f);
properties_trislider_topvalue->setMaxValue(5000.0f);
properties_trislider_topvalue->setValue(active_widget->floatval4);
properties_trislider_topvalue->setStepSize(0.1f);
properties_trislider_topvalue->setCallback(cb_float4);
puaSpinBox *properties_trislider_centvalue = new puaSpinBox(230,60,310,80);
properties_trislider_centvalue->setLabel("Center Slider Value:");
properties_trislider_centvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_centvalue->setMinValue(-5000.0f);
properties_trislider_centvalue->setMaxValue(5000.0f);
properties_trislider_centvalue->setValue(active_widget->floatval6);
properties_trislider_centvalue->setStepSize(0.1f);
properties_trislider_centvalue->setCallback(cb_float6);
puaSpinBox *properties_trislider_botvalue = new puaSpinBox(230,10,310,30);
properties_trislider_botvalue->setLabel("Bottom Slider Value:");
properties_trislider_botvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_botvalue->setMinValue(-5000.0f);
properties_trislider_botvalue->setMaxValue(5000.0f);
properties_trislider_botvalue->setValue(active_widget->floatval5);
properties_trislider_botvalue->setStepSize(0.1f);
properties_trislider_botvalue->setCallback(cb_float5);
static char *properties_trislider_lock_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_trislider_lock = new puButtonBox(380, 80, 480, 130, properties_trislider_lock_callback_entries, TRUE);
properties_trislider_lock->setLabel("Lock End Sliders:");
properties_trislider_lock->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_lock->setValue(active_widget->boolval3);
properties_trislider_lock->setCallback(cb_bool3);
} if (active_widget->object_type == PUCLASS_DIAL)
{
/* Wrap Mode */
static char *properties_dial_wrap_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_dial_wrap = new puButtonBox(20, 10, 170, 60, properties_dial_wrap_callback_entries, TRUE);
properties_dial_wrap->setLabel("Allow Dial Wrapping:");
properties_dial_wrap->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_dial_wrap->setValue(active_widget->boolval2);
properties_dial_wrap->setCallback(cb_bool2);
} if (active_widget->object_type == PUCLASS_SPINBOX)
{
/* Arrow position and height */
static char *properties_spinbox_arrow_callback_entries [] = { "Left", "Right", NULL } ;
puButtonBox *properties_spinbox_arrow = new puButtonBox(20, 10, 170, 60, properties_spinbox_arrow_callback_entries, TRUE);
properties_spinbox_arrow->setLabel("Arrow Position");
properties_spinbox_arrow->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrow->setValue(active_widget->boolval2);
properties_spinbox_arrow->setCallback(cb_bool2);
puaSpinBox *properties_spinbox_arrowheight = new puaSpinBox(230,110,310,130);
properties_spinbox_arrowheight->setLabel("Arrow Height:");
properties_spinbox_arrowheight->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrowheight->setMinValue(0.0f);
properties_spinbox_arrowheight->setMaxValue(20.0f);
properties_spinbox_arrowheight->setValue(active_widget->floatval4);
properties_spinbox_arrowheight->setStepSize(0.05f);
properties_spinbox_arrowheight->setCallback(cb_float4);
puText *properties_spinbox_arrowextra = new puText ( 310, 90 );
properties_spinbox_arrowextra->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrowextra->setLabel("(as porportion of spinbox height)");
} if (active_widget->object_type == PUCLASS_DIALOGBOX)
{
/* Not yet implemented as a class */
} if (active_widget->object_type == PUCLASS_ARROW)
{
static char *properties_arrow_arrowtype_options [] = { "Up", "Down", "Left", "Right",
"Double-Up", "Double-Down", "Double-Left",
"Double-Right", NULL } ;
puaComboBox *properties_arrow_arrowtype = new puaComboBox ( 120,10,310,30, properties_arrow_arrowtype_options, FALSE ) ;
properties_arrow_arrowtype->setLabel ( "Arrow Type:" ) ;
properties_arrow_arrowtype->setLabelPlace ( PUPLACE_LOWER_LEFT ) ;
properties_arrow_arrowtype->setCallback(cb_items);
int num = 0;
if (active_widget->items)
{
if (strstr(active_widget->items,"Double-Up"))
num = 4;
else if (strstr(active_widget->items,"Double-Down"))
num = 5;
else if (strstr(active_widget->items,"Double-Left"))
num = 6;
else if (strstr(active_widget->items,"Double-Right"))
num = 7;
else if (strstr(active_widget->items,"Up"))
num = 0;
else if (strstr(active_widget->items,"Down"))
num = 1;
else if (strstr(active_widget->items,"Left"))
num = 2;
else if (strstr(active_widget->items,"Right"))
num = 3;
}
properties_arrow_arrowtype->setCurrentItem(num);
} if ( (active_widget->object_type == PUCLASS_INPUT ) ||
(active_widget->object_type == PUCLASS_LARGEINPUT ) )
{
/*int minx, int miny, int maxx, int maxy */
/* Disabled, and Valid Data list */
puInput *properties_input_validdata = new puInput(20, 150, 260, 170);
properties_input_validdata->setLabel("Allowed Characters for Input:");
properties_input_validdata->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_input_validdata->setCallback(cb_allowed);
properties_input_validdata->setDownCallback(cb_allowed);
properties_input_validdata->setValue(active_widget->allowed);
static char *properties_input_enabled_callback_entries [] = { "Yes", NULL } ;
puButtonBox *properties_input_enabled = new puButtonBox(300, 140, 450, 170, properties_input_enabled_callback_entries, FALSE);
properties_input_enabled->setLabel("Input Allowed? (enabled)");
properties_input_enabled->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_input_enabled->setValue(active_widget->boolval1);
properties_input_enabled->setCallback(cb_bool1);
} if ((active_widget->object_type == PUCLASS_LARGEINPUT) ||
(active_widget->object_type == PUCLASS_SCROLLBAR) )
{
/*Arrows*/
static char *properties_largeinput_arrows_callback_entries [] = { "None", "Normal", "Normal and Fast", NULL } ;
puButtonBox *properties_largeinput_arrows = new puButtonBox(20, 10, 200, 130, properties_largeinput_arrows_callback_entries, TRUE);
properties_largeinput_arrows->setLabel("Which Arrow Buttons:");
properties_largeinput_arrows->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_largeinput_arrows->setValue(active_widget->intval1);
properties_largeinput_arrows->setCallback(cb_int1);
} if (active_widget->object_type == PUCLASS_LARGEINPUT)
{
/*Slider Size*/
puaSpinBox *properties_largeinput_sliderwidth = new puaSpinBox(300,90,400,110);
properties_largeinput_sliderwidth->setLabel("Slider Width:");
properties_largeinput_sliderwidth->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_largeinput_sliderwidth->setMinValue(0.0f);
properties_largeinput_sliderwidth->setMaxValue(150.0f);
properties_largeinput_sliderwidth->setValue(active_widget->intval2);
properties_largeinput_sliderwidth->setStepSize(1.0f);
properties_largeinput_sliderwidth->setCallback(cb_int2);
}
/* TODO:
* puaSliderWithInput: is input above or below slider?
* puaList: can we add the transparency field?
*/
properties_group->close () ;
return 0 ;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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 of the License, or
(at your option) any later version.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WidgetList.h 2083 2006-05-01 13:14:50Z bram $
*/
// Data Structure Definition
#ifndef WIDGET_LIST_H
#define WIDGET_LIST_H
#include <plib/pu.h>
#include <plib/puAux.h>
#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
// PUI Widget List for Main Window
struct WidgetList
{
puObject *obj ;
char *object_type_name ;
int object_type ;
char *label_text ;
char *legend_text ;
short callbacks ;
char object_name [ PUSTRING_MAX ] ;
bool visible ;
bool locked ;
int layer ; // GUI layer: 0 - in back, positive nubmers - greater in front of lesser
WidgetList *next ;
/* Additional data for the extended properties of widgets */
char *items ;
char *allowed ;
int intval1 ;
int intval2 ;
bool boolval1 ;
bool boolval2 ;
bool boolval3 ;
float floatval1 ;
float floatval2 ;
float floatval3 ;
float floatval4 ;
float floatval5 ;
float floatval6 ;
} ;
#endif // WIDGET_LIST_H

View File

@ -0,0 +1,460 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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 of the License, or
(at your option) any later version.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WidgetWindow.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Widget Window
#include <stdio.h>
#include <plib/pu.h>
#include <plib/puAux.h>
#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
// Widget Window Data
bool selected_object_sticky = false ;
int selected_object_type ;
char *selected_type_string ;
puButton *active_button = (puButton *)NULL ;
// Widget window parameters
static int widget_window = 0 ; // Window handle
// GLUT Widget Window Callbacks
static void widget_window_specialfn ( int key, int, int )
{
glutPostRedisplay () ;
}
static void widget_window_keyfn ( unsigned char key, int, int )
{
if ( selected_object_type )
{
if ( key == 27 ) // Escape key, deactivate the selected button
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void widget_window_motionfn ( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}
static void widget_window_mousefn ( int button, int updown, int x, int y )
{
if ( ! puMouse ( button, updown, x, y ) )
{
// PUI didn't absorb the mouse click; deactivate the selected object type
if ( selected_object_type )
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void widget_window_displayfn ( void )
{
glutSetWindow ( widget_window ) ;
/* Clear the screen */
glClearColor ( 0.1f, 0.1f, 0.1f, 1.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
puDisplay () ;
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
// PUI Callback Functions:
static void frame_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_FRAME ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void text_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_TEXT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void menu_bar_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_MENUBAR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void vertical_menu_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_VERTMENU ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void spin_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SPINBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void list_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LIST ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_INPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void large_input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LARGEINPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void select_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SELECTBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void file_selector_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_FILESELECTOR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void list_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LISTBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void scroll_bar_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SCROLLBAR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void button_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BUTTON ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void one_shot_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_ONESHOT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void arrow_button_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_ARROW ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void button_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BUTTONBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void combo_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_COMBOBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void chooser_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_CHOOSER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void dial_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_DIAL ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void slider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void bislider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BISLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void trislider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_TRISLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void slider_with_input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SLIDERWITHINPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void bislider_with_ends_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BISLIDERWITHENDS ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
// Function to define the window
// The widgets are arranged in a rectangle:
// Frame Input Button Dial
// Text Large Input One Shot Slider
// Menu Bar Select Box Arrow Button Bi-Slider
// Vertical Menu File Selector Button Box Tri-Slider
// Spin Box List Box Combo Box Slider with Input
// List Scroll Bar Chooser Bi-Slider with Ends
//
// The following widgets are not offered:
// Group Interface Popup Popup Menu
// Dialog Box
int define_widget_window ()
{
widget_window = glutCreateWindow ( "Widget List" ) ;
int ln = 120 ; // Button length
int ht = 20 ; // Button height
int sp = 10 ; // Button spacing
int total_screen_width = glutGet( GLUT_SCREEN_WIDTH ) ;
glutReshapeWindow ( 4 * ln + 5 * sp, 6 * ht + 7 * sp ) ;
glutPositionWindow ( total_screen_width - (4 * ln + 5 * sp) - 20, 20 ) ;
glutDisplayFunc ( widget_window_displayfn ) ;
glutKeyboardFunc ( widget_window_keyfn ) ;
glutSpecialFunc ( widget_window_specialfn ) ;
glutMotionFunc ( widget_window_motionfn ) ;
glutMouseFunc ( widget_window_mousefn ) ;
// Global variable initialization (type string)
selected_type_string = new char [ PUSTRING_MAX ] ;
// Set up the widgets
puGroup *widget_group = new puGroup ( 0, 0 ) ;
new puFrame ( 0, 0, 4 * ln + 5 * sp, 6 * ht + 7 * sp ) ;
puButton *button = (puButton *)NULL ;
button = new puButton ( sp, 6*sp+5*ht, sp+ln, 6*sp+6*ht ) ;
button->setLegend ( "puFrame" ) ;
button->setCallback ( frame_cb ) ;
button = new puButton ( sp, 5*sp+4*ht, sp+ln, 5*sp+5*ht ) ;
button->setLegend ( "puText" ) ;
button->setCallback ( text_cb ) ;
button = new puButton ( sp, 4*sp+3*ht, sp+ln, 4*sp+4*ht ) ;
button->setLegend ( "puMenuBar" ) ;
button->setCallback ( menu_bar_cb ) ;
button = new puButton ( sp, 3*sp+2*ht, sp+ln, 3*sp+3*ht ) ;
button->setLegend ( "puaVerticalMenu" ) ;
button->setCallback ( vertical_menu_cb ) ;
button = new puButton ( sp, 2*sp+ht, sp+ln, 2*sp+2*ht ) ;
button->setLegend ( "puaSpinBox" ) ;
button->setCallback ( spin_box_cb ) ;
button = new puButton ( sp, sp, sp+ln, sp+ht ) ;
button->setLegend ( "puaList" ) ;
button->setCallback ( list_cb ) ;
button = new puButton ( 2*sp+ln, 6*sp+5*ht, 2*sp+2*ln, 6*sp+6*ht ) ;
button->setLegend ( "puInput" ) ;
button->setCallback ( input_cb ) ;
button = new puButton ( 2*sp+ln, 5*sp+4*ht, 2*sp+2*ln, 5*sp+5*ht ) ;
button->setLegend ( "puaLargeInput" ) ;
button->setCallback ( large_input_cb ) ;
button = new puButton ( 2*sp+ln, 4*sp+3*ht, 2*sp+2*ln, 4*sp+4*ht ) ;
button->setLegend ( "puaSelectBox" ) ;
button->setCallback ( select_box_cb ) ;
button = new puButton ( 2*sp+ln, 3*sp+2*ht, 2*sp+2*ln, 3*sp+3*ht ) ;
button->setLegend ( "puaFileSelector" ) ;
button->setCallback ( file_selector_cb ) ;
button = new puButton ( 2*sp+ln, 2*sp+ht, 2*sp+2*ln, 2*sp+2*ht ) ;
button->setLegend ( "puListBox" ) ;
button->setCallback ( list_box_cb ) ;
button = new puButton ( 2*sp+ln, sp, 2*sp+2*ln, sp+ht ) ;
button->setLegend ( "puaScrollBar" ) ;
button->setCallback ( scroll_bar_cb ) ;
button = new puButton ( 3*sp+2*ln, 6*sp+5*ht, 3*sp+3*ln, 6*sp+6*ht ) ;
button->setLegend ( "puButton" ) ;
button->setCallback ( button_cb ) ;
button = new puButton ( 3*sp+2*ln, 5*sp+4*ht, 3*sp+3*ln, 5*sp+5*ht ) ;
button->setLegend ( "puOneShot" ) ;
button->setCallback ( one_shot_cb ) ;
button = new puButton ( 3*sp+2*ln, 4*sp+3*ht, 3*sp+3*ln, 4*sp+4*ht ) ;
button->setLegend ( "puArrowButton" ) ;
button->setCallback ( arrow_button_cb ) ;
button = new puButton ( 3*sp+2*ln, 3*sp+2*ht, 3*sp+3*ln, 3*sp+3*ht ) ;
button->setLegend ( "puButtonBox" ) ;
button->setCallback ( button_box_cb ) ;
button = new puButton ( 3*sp+2*ln, 2*sp+ht, 3*sp+3*ln, 2*sp+2*ht ) ;
button->setLegend ( "puaComboBox" ) ;
button->setCallback ( combo_box_cb ) ;
button = new puButton ( 3*sp+2*ln, sp, 3*sp+3*ln, sp+ht ) ;
button->setLegend ( "puaChooser" ) ;
button->setCallback ( chooser_cb ) ;
// TODO: It appears that the "puaChooser" file is not in the puAux library yet.
button->hide ();
button = new puButton ( 4*sp+3*ln, 6*sp+5*ht, 4*sp+4*ln, 6*sp+6*ht ) ;
button->setLegend ( "puDial" ) ;
button->setCallback ( dial_cb ) ;
button = new puButton ( 4*sp+3*ln, 5*sp+4*ht, 4*sp+4*ln, 5*sp+5*ht ) ;
button->setLegend ( "puSlider" ) ;
button->setCallback ( slider_cb ) ;
button = new puButton ( 4*sp+3*ln, 4*sp+3*ht, 4*sp+4*ln, 4*sp+4*ht ) ;
button->setLegend ( "puaBiSlider" ) ;
button->setCallback ( bislider_cb ) ;
button = new puButton ( 4*sp+3*ln, 3*sp+2*ht, 4*sp+4*ln, 3*sp+3*ht ) ;
button->setLegend ( "puaTriSlider" ) ;
button->setCallback ( trislider_cb ) ;
button = new puButton ( 4*sp+3*ln, 2*sp+ht, 4*sp+4*ln, 2*sp+2*ht ) ;
button->setLegend ( "puaSliderWithInput" ) ;
button->setCallback ( slider_with_input_cb ) ;
button = new puButton ( 4*sp+3*ln, sp, 4*sp+4*ln, sp+ht ) ;
button->setLegend ( "puaBiSliderWithEnds" ) ;
button->setCallback ( bislider_with_ends_cb ) ;
widget_group->close () ;
return 0 ;
}

View File

@ -0,0 +1,616 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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 of the License, or
(at your option) any later version.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WriteCode.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Function to write the actual code
#include <stdio.h>
#include "WidgetList.h"
#ifdef WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif
// From the Main Window:
extern WidgetList *widgets ;
extern int max_layer ;
extern int main_window_width ;
extern int main_window_height ;
extern char main_window_name [ PUSTRING_MAX ] ;
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern int main_window_x ;
extern int main_window_y ;
extern bool main_window_changed ;
extern float main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ;
// From the Status Window
extern int status_window ;
extern puaFileSelector *file_selector ;
const char* trueOrFalse(bool tf)
{
if (tf) return "TRUE";
else return "FALSE";
}
// The function itself
void write_code ( puObject *ob )
{
// Get the file name and open the file
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
/* If they didn't give an extension, then tack ".cxx" onto the end. */
if(!strstr(filename, "."))
sprintf(filename, "%s.cxx", filename);
FILE *out = fopen ( filename, "wt" ) ;
if ( !out )
printf ( "ERROR opening file <%s> for writing\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !out ) return ;
// Start writing code:
fprintf ( out, "// TODO: Initial documentation\n" ) ;
fprintf ( out, "// TODO: Configuration Management system flags\n\n" ) ;
fprintf ( out, "// TODO: Any additional includes you may need\n\n" ) ;
fprintf ( out, "#include <GL/freeglut.h>\n\n" ) ;
fprintf ( out, "#include <plib/pu.h>\n\n" ) ;
fprintf ( out, "#include <plib/puAux.h> // TODO: Decide if you really need this\n\n" ) ;
fprintf ( out, "// GLUT Window Handle\n" ) ;
fprintf ( out, "int window_handle ;\n\n" ) ;
WidgetList *wid = widgets ;
fprintf ( out, "// PUI Widget Handles:\n" ) ;
while ( wid )
{
fprintf ( out, "%s *%s = (%s *)NULL ;\n", wid->object_type_name, wid->object_name,
wid->object_type_name ) ;
wid = wid->next ;
}
fprintf ( out, "\n" ) ;
// GLUT Callbacks:
fprintf ( out, "// GLUT Callbacks:\n" ) ;
fprintf ( out, "static void specialfn ( int key, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own special-key functionality in here\n" ) ;
fprintf ( out, " puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void keyfn ( unsigned char key, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own keyboard functionality in here\n" ) ;
fprintf ( out, " puKeyboard ( key, PU_DOWN ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void motionfn ( int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own mouse motion functionality in here\n" ) ;
fprintf ( out, " puMouse ( x, y ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void mousefn ( int button, int updown, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own mouse click functionality in here\n" ) ;
fprintf ( out, " puMouse ( button, updown, x, y ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void displayfn ( void )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // Clear the screen\n\n" ) ;
fprintf ( out, " glClearColor ( %f, %f, %f, %f ) ;\n", main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ) ;
fprintf ( out, " glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;\n\n" ) ;
fprintf ( out, " // TODO: Put any of your own window display in here\n\n" ) ;
fprintf ( out, " // Make PUI display\n" ) ;
fprintf ( out, " puDisplay () ;\n\n" ) ;
fprintf ( out, " glutSwapBuffers () ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "// TODO: Put any of your own additional GLUT callbacks in here\n\n" ) ;
// PUI Callbacks
fprintf ( out, "// PUI Callbacks:\n\n" ) ;
wid = widgets ;
while ( wid )
{
if ( wid->callbacks & 0x01 ) // Up-callback defined
{
fprintf ( out, "void %s_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your up-callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
if ( wid->callbacks & 0x02 ) // Active callback defined
{
fprintf ( out, "void %s_active_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your active callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
if ( wid->callbacks & 0x04 ) // Down-callback defined
{
fprintf ( out, "void %s_down_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your down-callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
wid = wid->next ;
}
fprintf ( out, "\n\n" ) ;
// The Main Program
fprintf ( out, "//**********************************************************\n" ) ;
fprintf ( out, "//* The Main Program *\n" ) ;
fprintf ( out, "//**********************************************************\n\n" ) ;
fprintf ( out, "int main ( int argc, char *argv[] )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Add any non-GLUT functionality you want to\n\n" ) ;
fprintf ( out, " // Create the GLUT window:\n" ) ;
fprintf ( out, " glutInitWindowPosition( %d, %d ) ;\n", main_window_x, main_window_y ) ;
fprintf ( out, " glutInitWindowSize ( %d, %d ) ;\n", main_window_width, main_window_height ) ;
fprintf ( out, " glutInit ( &argc, argv ) ;\n" ) ;
fprintf ( out, " glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;\n" ) ;
fprintf ( out, " window_handle = glutCreateWindow ( \"%s\" ) ;\n\n", main_window_name ) ;
fprintf ( out, " // GLUT Windowing Callbacks:\n" ) ;
fprintf ( out, " glutDisplayFunc ( displayfn ) ;\n" ) ;
fprintf ( out, " glutKeyboardFunc ( keyfn ) ;\n" ) ;
fprintf ( out, " glutSpecialFunc ( specialfn ) ;\n" ) ;
fprintf ( out, " glutMouseFunc ( mousefn ) ;\n" ) ;
fprintf ( out, " glutMotionFunc ( motionfn ) ;\n" ) ;
fprintf ( out, " glutPassiveMotionFunc ( motionfn ) ;\n" ) ;
fprintf ( out, " glutIdleFunc ( displayfn ) ;\n" ) ;
fprintf ( out, " // TODO: Add any additional GLUT callbacks that you defined earlier\n\n" ) ;
fprintf ( out, " // Initialize PUI:\n" ) ;
fprintf ( out, " puInit () ;\n\n" ) ;
// TO DO: Allow the user to select his own default fonts, style, and colour scheme
fprintf ( out, " // PUI Default Style, and Colors:\n" ) ;
fprintf ( out, " puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;\n" ) ;
fprintf ( out, " puSetDefaultColourScheme ( 0.3f, 0.4f, 0.6f, 1.0f ) ;\n" ) ;
fprintf ( out, " // TODO: Customize this as you like\n\n" ) ;
fprintf ( out, " // Define the widgets:\n\n" ) ;
fprintf ( out, " puGroup *window_group = new puGroup ( 0, 0 ) ;\n\n" ) ;
int layer ;
for ( layer = 0; layer < max_layer; layer++ )
{
wid = widgets ;
while ( wid )
{
if ( layer == wid->layer )
{
puObject *ob = wid->obj ;
int x, y, w, h ;
ob->getPosition ( &x, &y ) ;
ob->getSize ( &w, &h ) ;
/* Customize widget's constructor and extra details */
/* fprintf ( out, " %s = new %s ( %d, %d, %d, %d ) ;\n", wid->object_name,
wid->object_type_name, x, y, x+w, y+h ) ; */
/* General minx, miny, maxx, maxy constructor */
if ( (wid->object_type == PUCLASS_FRAME ) ||
(wid->object_type == PUCLASS_BUTTON ) ||
(wid->object_type == PUCLASS_INPUT ) ||
(wid->object_type == PUCLASS_BISLIDERWITHENDS))
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
/* General minx, miny constructor */
if (wid->object_type == PUCLASS_TEXT)
{
/* Add in font properties? */
fprintf ( out, " %s = new %s (%d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y) ;
}
if (wid->object_type == PUCLASS_ONESHOT)
{
/*
Add support for both constructors!
puButton::puButton ( int minx, int miny, const char *legend ) ;
puButton::puButton ( int minx, int miny, int maxx, int maxy ) ;
*/
fprintf ( out, " %s = new %s (%d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if ( (wid->object_type == PUCLASS_MENUBAR) ||
(wid->object_type == PUCLASS_VERTMENU) ) {
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
while ( cr != '\0' )
{
char *spc = strchr ( temp_items, ' ' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ' ' ) ;
}
spc = strchr ( temp_items, ':' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ':' ) ;
}
spc = strchr ( temp_items, ';' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ';' ) ;
}
spc = strchr ( temp_items, ',' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ',' ) ;
}
spc = strchr ( temp_items, '.' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, '.' ) ;
}
*cr = '\0';
fprintf ( out, " static char *%s_%s_submenu [] = { \"Filler\", NULL } ;\n", wid->object_name, temp_items) ;
fprintf ( out, " /* TODO: You need to create your own callbacks here, such as { \"exit_cb\",\"delete_cb\",NULL } */ \n") ;
fprintf ( out, " puCallback %s_%s_submenu_cb [] = { NULL, NULL } ;\n\n", wid->object_name, temp_items) ;
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
}
if (wid->object_type == PUCLASS_MENUBAR) {
/* TODO: add in "height" support */
fprintf ( out, " %s = new %s ( ) ;\n", wid->object_name, wid->object_type_name) ;
}
if (wid->object_type == PUCLASS_VERTMENU) {
/* TODO: add in "lock to corner" support */
fprintf ( out, " %s = new %s (%d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y) ;
}
if (wid->items)
{
char *temp_items = wid->items ;
char unspaced_items[PUSTRING_MAX];
char *cr = strchr(temp_items, '\n');
fprintf ( out, " {\n") ;
while ( cr != '\0' )
{
*cr = '\0';
strcpy(unspaced_items, temp_items);
/* Put back the space */
char *spc = strchr ( temp_items, '_' ) ;
while ( spc )
{
*spc = ' ' ;
spc = strchr ( temp_items, '_' ) ;
}
/* Now "unspaced_items" writes "I_have_no_spaces" while temp_items writes "I have no spaces" (AND LIES!) */
fprintf ( out, " %s->add_submenu (\"%s\", %s_%s_submenu, %s_%s_submenu_cb ) ;\n", wid->object_name, temp_items, wid->object_name, unspaced_items, wid->object_name, unspaced_items ) ;
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
fprintf ( out, " }\n") ;
}
fprintf ( out, " %s->close() ;\n", wid->object_name) ;
}
if ( (wid->object_type == PUCLASS_LISTBOX) ||
(wid->object_type == PUCLASS_COMBOBOX) ||
(wid->object_type == PUCLASS_SELECTBOX) ||
(wid->object_type == PUCLASS_BUTTONBOX) ||
(wid->object_type == PUCLASS_LIST))
{
char data[1024];
char onedata[PUSTRING_MAX];
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
sprintf ( data, " ");
while ( cr != '\0' )
{
*cr = '\0';
sprintf ( onedata, "\"%s\",", temp_items);
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
strcat(data, onedata);
}
}
fprintf ( out, " static char *%s_entries [] = { %s NULL } ;\n", wid->object_name, data) ;
if ( (wid->object_type == PUCLASS_LISTBOX) ||
(wid->object_type == PUCLASS_LIST) )
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name) ;
if (wid->object_type == PUCLASS_BUTTONBOX)
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name, trueOrFalse(wid->boolval1)) ;
if (wid->object_type == PUCLASS_COMBOBOX)
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name, trueOrFalse(wid->boolval1)) ;
fprintf ( out, " %s->setCurrentItem(%d) ;\n", wid->object_name, wid->intval1) ;
}
if (wid->object_type == PUCLASS_SELECTBOX)
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name) ;
fprintf ( out, " %s->setCurrentItem(%d) ;\n", wid->object_name, wid->intval1) ;
}
}
if (wid->object_type == PUCLASS_POPUPMENU)
{
/* Allow a list of menu items, and remember to point out these are hidden when created, and must be reveal()ed. */
/* NOT CURRENTLY IMPLEMENTED */
}
/* puRange */
if ( (wid->object_type == PUCLASS_SLIDER ) ||
(wid->object_type == PUCLASS_BISLIDER ) ||
(wid->object_type == PUCLASS_TRISLIDER ) ||
(wid->object_type == PUCLASS_DIAL ) ||
(wid->object_type == PUCLASS_SPINBOX ) ||
(wid->object_type == PUCLASS_SCROLLBAR ) )
{
/* Constructors */
if ( (wid->object_type == PUCLASS_SLIDER ) ||
(wid->object_type == PUCLASS_BISLIDER ) ||
(wid->object_type == PUCLASS_TRISLIDER ))
{
/* Sliders */
fprintf ( out, " %s = new %s (%d, %d, %d, %s, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, (wid->boolval2==1)?h:w, trueOrFalse(wid->boolval2), (wid->boolval2==1)?w:h) ;
/* Slider value options */
if (wid->object_type == PUCLASS_SLIDER )
fprintf ( out, " %s->setValue(%ff) ;\n", wid->object_name, wid->floatval4) ;
if ( (wid->object_type == PUCLASS_BISLIDER ) || (wid->object_type == PUCLASS_TRISLIDER ) )
{
fprintf ( out, " %s->setCurrentMax(%ff) ;\n", wid->object_name, wid->floatval4) ;
fprintf ( out, " %s->setCurrentMin(%ff) ;\n", wid->object_name, wid->floatval5) ;
if (wid->object_type == PUCLASS_TRISLIDER )
{
if (!wid->boolval3)
fprintf ( out, " %s->setFreezeEnds(FALSE) ;\n", wid->object_name ) ;
fprintf ( out, " %s->setValue(%ff) ;\n", wid->object_name, wid->floatval6) ;
fprintf ( out, " %s->setSliderFraction(0.1f) ;\n", wid->object_name) ;
/*Allow setting the slider fraction?*/
}
}
} else if (wid->object_type == PUCLASS_DIAL )
{
fprintf ( out, " %s = new %s (%d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, (h+w)/2) ;
fprintf ( out, " %s->setWrap(%s) ;\n", wid->object_name, trueOrFalse(wid->boolval2)) ;
} else if (wid->object_type == PUCLASS_SPINBOX )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, trueOrFalse(wid->boolval2) ) ;
fprintf ( out, " %s->setArrowHeight(%ff) ;\n", wid->object_name, wid->floatval4 ) ;
} else if (wid->object_type == PUCLASS_SCROLLBAR )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %d, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->intval1, trueOrFalse(wid->boolval2) ) ;
fprintf ( out, " %s->setArrowHeight(%ff) ;\n", wid->object_name, wid->floatval4 ) ;
}
/* All puRange options */
fprintf ( out, " %s->setMaxValue (%ff) ;\n", wid->object_name, wid->floatval1 ) ;
fprintf ( out, " %s->setMinValue (%ff) ;\n", wid->object_name, wid->floatval2 ) ;
fprintf ( out, " %s->setStepSize (%ff) ;\n", wid->object_name, wid->floatval3 ) ;
char cbmodetext[20] = "PUSLIDER_ALWAYS";
if (wid->boolval1)
strcpy(cbmodetext,"PUSLIDER_ALWAYS");
else
strcpy(cbmodetext,"PUSLIDER_CLICK");
fprintf ( out, " %s->setCBMode (%s) ;\n", wid->object_name, cbmodetext) ;
}
if (wid->object_type == PUCLASS_DIALOGBOX)
{
/* Not yet implemented as a class */
}
if (wid->object_type == PUCLASS_ARROW)
{
char arr_name[20] = "PUARROW_UP";
if (wid->items)
{
if (strstr(wid->items,"Double-Up"))
strcpy(arr_name, "PUARROW_FASTUP");
else if (strstr(wid->items,"Double-Down"))
strcpy(arr_name, "PUARROW_FASTDOWN");
else if (strstr(wid->items,"Double-Left"))
strcpy(arr_name, "PUARROW_FASTLEFT");
else if (strstr(wid->items,"Double-Right"))
strcpy(arr_name, "PUARROW_FASTRIGHT");
else if (strstr(wid->items,"Up"))
strcpy(arr_name, "PUARROW_UP");
else if (strstr(wid->items,"Down"))
strcpy(arr_name, "PUARROW_DOWN");
else if (strstr(wid->items,"Left"))
strcpy(arr_name, "PUARROW_LEFT");
else if (strstr(wid->items,"Right"))
strcpy(arr_name, "PUARROW_RIGHT");
}
fprintf ( out, " %s = new puArrowButton (%d, %d, %d, %d, %s ) ;\n", wid->object_name, x, y, x+w, y+h, arr_name) ;
}
if (wid->object_type == PUCLASS_CHOOSER)
{
// Just give it a dummy legend; set the legend later on
fprintf ( out, " %s = new %s (%d, %d, %d, %d, "" ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if (wid->object_type == PUCLASS_SLIDERWITHINPUT)
{
// Extra argument for input box being on the bottom of the slider
fprintf ( out, " %s = new %s (%d, %d, %d, %d, 0 ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if (wid->object_type == PUCLASS_INPUT )
{
/*Already had its constructor defined by the general -- look up*/
if (wid->boolval1 == false)
fprintf ( out, " %s->rejectInput() ;\n", wid->object_name ) ;
if ( wid->allowed)
fprintf ( out, " %s->setValidData(\"%s\") ;\n", wid->object_name, wid->allowed ) ;
}
if ( wid->object_type == PUCLASS_LARGEINPUT )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, w, h, wid->intval1, wid->intval2 ) ;
if (wid->boolval1 == false)
fprintf ( out, " %s->rejectInput() ;\n", wid->object_name ) ;
if ( wid->allowed)
fprintf ( out, " %s->setValidData(\"%s\") ;\n", wid->object_name, wid->allowed ) ;
}
/* Done custom constructor and extra details */
if ( wid->callbacks & 0x01 ) // Up-callback defined
fprintf ( out, " %s->setCallback ( %s_cb ) ;\n", wid->object_name, wid->object_name ) ;
if ( wid->callbacks & 0x02 ) // Active callback defined
fprintf ( out, " %s->setActiveCallback ( %s_active_cb ) ;\n", wid->object_name, wid->object_name ) ;
if ( wid->callbacks & 0x04 ) // Down-callback defined
fprintf ( out, " %s->setDownCallback ( %s_down_cb ) ;\n", wid->object_name, wid->object_name ) ;
// TO DO: Allow the user to customize colour and style
const char *place_name [] = { "PUPLACE_TOP_LEFT", "PUPLACE_TOP_CENTERED", "PUPLACE_TOP_RIGHT",
"PUPLACE_CENTERED_LEFT", "PUPLACE_CENTERED_RIGHT",
"PUPLACE_BOTTOM_LEFT", "PUPLACE_BOTTOM_CENTERED", "PUPLACE_BOTTOM_RIGHT",
"PUPLACE_CENTERED_CENTERED",
"PUPLACE_ABOVE_LEFT", "PUPLACE_ABOVE_RIGHT",
"PUPLACE_BELOW_LEFT", "PUPLACE_BELOW_RIGHT",
"PUPLACE_UPPER_LEFT", "PUPLACE_UPPER_RIGHT",
"PUPLACE_LOWER_LEFT", "PUPLACE_LOWER_RIGHT" } ;
if ( wid->label_text )
{
fprintf ( out, " %s->setLabel ( \"%s\" ) ;\n", wid->object_name, wid->label_text ) ;
fprintf ( out, " %s->setLabelPlace ( %s ) ;\n", wid->object_name, place_name [ ob->getLabelPlace () ] ) ;
// TO DO: Check for label font and print it
}
if ( wid->legend_text )
{
fprintf ( out, " %s->setLegend ( \"%s\" ) ;\n", wid->object_name, wid->legend_text ) ;
fprintf ( out, " %s->setLegendPlace ( %s ) ;\n", wid->object_name, place_name [ ob->getLegendPlace () ] ) ;
// TO DO: Check for legend font and print it
}
if( !wid->visible )
fprintf ( out, " %s->hide () ;\n", wid->object_name ) ;
fprintf ( out, " \n" ) ;
}
wid = wid->next ;
}
}
fprintf ( out, "\n\n" ) ;
fprintf ( out, " window_group->close () ;\n\n\n" ) ;
fprintf ( out, " // GLUT Main Loop\n" ) ;
fprintf ( out, " glutMainLoop () ;\n" ) ;
fprintf ( out, " return 0;\n" ) ;
fprintf ( out, "}\n\n" ) ;
// Close up shop
fclose ( out ) ;
main_window_changed = false ;
}

View File

@ -0,0 +1,504 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE P-Guide>
<savefile>
<version>VERSION</version>
<project>Test Project</project>
<autolock>TRUE</autolock>
<window>
<name>Sample P-Guide File</name>
<size>
<width>600</width>
<height>400</height>
</size>
<position>
<x>0</x>
<y>0</y>
</position>
<color>
<r>0.750000</r>
<g>0.550000</g>
<b>0.650000</b>
<a>1.000000</a>
</color>
</window>
<objects>
<widget>
<name>left_arrow</name>
<type>puArrowButton</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>24</width>
<height>101</height>
</size>
<position>
<x>93</x>
<y>96</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Double-Left</item>
</data>
</widget>
<widget>
<name>right_arrow</name>
<type>puArrowButton</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>25</width>
<height>101</height>
</size>
<position>
<x>127</x>
<y>96</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Double-Right</item>
</data>
</widget>
<widget>
<name>combo</name>
<type>puComboBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>166</width>
<height>70</height>
</size>
<position>
<x>89</x>
<y>20</y>
</position>
<data>
<int1>2</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Option 1</item>
<item>Option 2</item>
<item>Option 3</item>
<item>Final</item>
</data>
</widget>
<widget>
<name>oneshot3</name>
<legend>
<text>Run Away</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>127</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>oneshot2</name>
<legend>
<text>Shoot</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>152</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>oneshot1</name>
<legend>
<text>Execute</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>177</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>dizzy</name>
<type>puSpinBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>166</width>
<height>40</height>
</size>
<position>
<x>89</x>
<y>205</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>20.000000</float1>
<float2>0.000000</float2>
<float3>1.000000</float3>
<float4>0.500000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>libris</name>
<label>
<text>Input</text>
<pos>PUPLACE_TOP_LEFT</pos>
</label>
<type>puLargeInput</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>334</width>
<height>232</height>
</size>
<position>
<x>258</x>
<y>13</y>
</position>
<data>
<int1>2</int1>
<int2>5</int2>
<bool1>TRUE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<allowed> </allowed>
</data>
</widget>
<widget>
<name>dial2</name>
<type>puDial</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>50</width>
<height>50</height>
</size>
<position>
<x>88</x>
<y>255</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>5.000000</float1>
<float2>0.000000</float2>
<float3>1.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>dial1</name>
<type>puDial</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>FALSE</locked>
<size>
<width>50</width>
<height>50</height>
</size>
<position>
<x>87</x>
<y>309</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>1.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>slider</name>
<type>puSlider</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>35</width>
<height>356</height>
</size>
<position>
<x>50</x>
<y>7</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>10.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.500000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>trislider</name>
<type>puTriSlider</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>FALSE</locked>
<size>
<width>47</width>
<height>356</height>
</size>
<position>
<x>1</x>
<y>7</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>17.000000</float1>
<float2>-5.000000</float2>
<float3>2.000000</float3>
<float4>16.000000</float4>
<float5>-0.500000</float5>
<float6>0.500000</float6>
</data>
</widget>
<widget>
<name>menu_bar</name>
<type>puMenuBar</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>120</width>
<height>30</height>
</size>
<position>
<x>0</x>
<y>367</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>File</item>
<item>Edit</item>
<item>View</item>
<item>Project</item>
<item>Build</item>
<item>Debug</item>
<item>Tools</item>
<item>Options</item>
<item>Window</item>
<item>Bookmarks</item>
<item>Help</item>
</data>
</widget>
<widget>
<name>buttonbox</name>
<type>puButtonBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>163</width>
<height>134</height>
</size>
<position>
<x>428</x>
<y>249</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>On</item>
<item>Off</item>
<item>Automatic</item>
</data>
</widget>
<widget>
<name>widget1</name>
<label>
<text>This is a test application</text>
<pos>PUPLACE_LOWER_RIGHT</pos>
</label>
<type>puText</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>5</width>
<height>20</height>
</size>
<position>
<x>173</x>
<y>360</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
</objects>
</savefile>

View File

@ -0,0 +1,916 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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 of the License, or
(at your option) any later version.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: pGuide.cxx 2083 2006-05-01 13:14:50Z bram $
*/
#ifdef VERSION
#undef VERSION
#endif
#define VERSION = "0.1a"
// Program to allow the user to build a PUI Graphical User Interface
#include "WidgetList.h"
WidgetList *widgets = (WidgetList *)NULL ;
int max_layer = 1 ;
puObject *active_object = (puObject *)NULL ;
WidgetList *active_widget = (WidgetList *)NULL ;
static short activity_flag = 0 ; // 0 - inactive; 1 - moving; 2 - resizing xmin, 3 - resizing ymin, 4 - resizing xmax, 5 - resizing ymax
static int resize_symmetric = 1 ;
static int resize_corner = 0 ;
static int mouse_x_position_in_object = 0 ;
static int mouse_y_position_in_object = 0 ;
static int pguide_last_buttons = 0 ; // Because puMouse isn't called, we have to do our own last_buttons checking
// Main window parameters
int main_window = 0 ; // Main window handle
int main_window_width = 600 ;
int main_window_height = 600 ;
char main_window_name [ PUSTRING_MAX ] ;
int main_window_x = 0, main_window_y = 0 ;
float main_window_color_r = 1.0, main_window_color_g = 1.0,
main_window_color_b = 1.0, main_window_color_a = 1.0 ;
bool main_window_changed = false ;
static bool done_first_setup = false ;
bool currently_loading = false ;
static int ctrl_key_down = 0 ;
static int mouse_x = 0 ;
static int mouse_y = 0 ;
char pguide_current_directory [ PUSTRING_MAX ] ;
// Widget count
int widget_number = 0 ;
// Upon creation of new widgets, should they automatically be made "locked"?
bool autolock = false ;
// Properties popup
static puPopupMenu *context_menu;
// From the status window:
extern void setStatusWidgets ( WidgetList *wid ) ;
// From the properties window:
extern int properties_window;
// Definitions
#define RESIZING_BORDER_WIDTH 5
#define RESIZING_CORNER_BORDER_WIDTH 4
/** 4 seems to be the best number for this define... this makes sure *
* that the default widget size allows you to still resize along the *
* X axis without difficulty - 23 Jan 03 JCJ **/
// Properties Callback
static void cb_edit_properties ( puObject *ob )
{
if (properties_window)
{
extern puGroup *properties_group;
/* Delete the widgets */
puDeleteObject( properties_group );
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
extern int define_properties_window () ;
// Open the properties menu
define_properties_window();
}
static void cb_lock_toggle ( puObject *ob )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->obj == active_object )
{
if (wid->locked == false)
wid->locked = true ;
else
wid->locked = false ;
}
wid = wid->next ;
}
}
static void cb_popup_delete ( puObject *ob )
{
WidgetList *wid = widgets ;
WidgetList *prv = (WidgetList *)NULL ;
while ( wid )
{
if ( wid->obj == active_object )
{
if ( prv ) // Remove the widget from the linked list
prv->next = wid->next ;
else
widgets = wid->next ;
delete wid->object_type_name ; // Delete the widget
delete wid->legend_text ;
delete wid->label_text ;
delete wid->obj ;
delete wid->allowed ;
delete wid->items ;
delete wid ;
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
wid = (WidgetList *)NULL ;
if (properties_window)
{
extern puGroup *properties_group;
/* Delete the widgets */
puDeleteObject( properties_group );
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
}
else
{
prv = wid ;
wid = wid->next ;
}
}
}
// GLUT Main Window Callbacks
static void process_key ( int key )
{
extern int selected_object_type ;
extern puButton *active_button ;
ctrl_key_down = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ;
#define NUDGE_DISTANCE 1
#define LARGE_NUDGE_DISTANCE 10
if ( active_object ) // Active object; check the keys
{
main_window_changed = true ;
int xo, yo ;
active_object->getPosition ( &xo, &yo ) ;
int dist = ctrl_key_down ? LARGE_NUDGE_DISTANCE : NUDGE_DISTANCE ;
if ( key == GLUT_KEY_LEFT )
active_object->setPosition ( xo-dist, yo ) ;
else if ( key == GLUT_KEY_RIGHT )
active_object->setPosition ( xo+dist, yo ) ;
else if ( key == GLUT_KEY_UP )
active_object->setPosition ( xo, yo+dist ) ;
else if ( key == GLUT_KEY_DOWN )
active_object->setPosition ( xo, yo-dist ) ;
else if ( ( key == 127 ) || ( key == 8 ) ) // Delete or Backspace
{
WidgetList *wid = widgets ;
WidgetList *prv = (WidgetList *)NULL ;
while ( wid )
{
if ( wid->obj == active_object )
{
if ( prv ) // Remove the widget from the linked list
prv->next = wid->next ;
else
widgets = wid->next ;
delete wid->object_type_name ; // Delete the widget
delete wid->legend_text ;
delete wid->label_text ;
delete wid->obj ;
delete wid->allowed ;
delete wid->items ;
delete wid ;
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
wid = (WidgetList *)NULL ;
}
else
{
prv = wid ;
wid = wid->next ;
}
}
}
else if ( key == 27 ) // Escape key, deactivate the object
{
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
}
setStatusWidgets ( active_widget ) ;
}
if ( selected_object_type )
{
if ( key == 27 ) // Escape key, deactivate the selected button
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void main_window_specialfn ( int key, int, int )
{
process_key ( key ) ;
}
static void main_window_keyfn ( unsigned char key, int, int )
{
process_key ( key ) ;
}
static void main_window_motionfn ( int x, int yy )
{
int y = main_window_height - yy ;
mouse_x = x ;
mouse_y = y ;
// Dragging the mouse: If there is an active object, slide it around
if ( ( active_object ) && ( pguide_last_buttons != 4 ) )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->obj == active_object )
{
if (wid->locked == false)
{
extern puInput *object_position_x ;
extern puInput *object_position_y ;
extern puInput *object_size_x ;
extern puInput *object_size_y ;
main_window_changed = true ;
int dist ;
int xo, yo ;
active_object->getPosition ( &xo, &yo ) ;
int w, h ;
active_object->getSize ( &w, &h ) ;
if (resize_corner == 1)
{
switch ( activity_flag )
{
case 2 : // Resize top-right
case 3 :
activity_flag = 6;
break ;
case 4 : // Resize bottom_left
case 5 :
activity_flag = 7;
break ;
}
}
switch ( activity_flag )
{
case 1 : // Moving the object
active_object->setPosition ( x - mouse_x_position_in_object,
y - mouse_y_position_in_object ) ;
break ;
case 2 : // Resizing on x-min
dist = x - xo ;
if (w - dist < 5) break ;
if ( resize_symmetric * dist > w ) dist = w / resize_symmetric - 1 ;
active_object->setPosition ( x, yo ) ;
active_object->setSize ( w - resize_symmetric * dist, h ) ;
break ;
case 3 : // Resizing on y-min
dist = y - yo ;
if (h - dist < 5) break ;
if ( resize_symmetric * dist > h ) dist = h / resize_symmetric - 1 ;
active_object->setPosition ( xo, y ) ;
active_object->setSize ( w, h - resize_symmetric * dist ) ;
break ;
case 4 : // Resizing on x-max
dist = x - xo - w ;
if (w + dist < 5) break ;
if ( resize_symmetric * dist < -w ) dist = 1 - w / resize_symmetric ;
active_object->setSize ( w + resize_symmetric * dist, h ) ;
if ( resize_symmetric == 2 ) active_object->setPosition ( xo - dist, yo ) ;
break ;
case 5 : // Resizing on y-max
dist = y - yo - h ;
if (h + dist < 5) break ;
if ( resize_symmetric * dist < -h ) dist = 1 - h / resize_symmetric ;
active_object->setSize ( w, h + resize_symmetric * dist ) ;
if ( resize_symmetric == 2 ) active_object->setPosition ( xo, yo - dist ) ;
break ;
case 6 : // Resizing bottom-left
if ( yo - y > xo - x )
dist = yo - y;
else
dist = xo - x;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo - dist, yo - dist ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 7 : // Resizing top-right
if (y-yo-h>x-xo-w)
dist = y - yo - h ;
else
dist = x - xo - w ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 8 : // Resizing top-left
if (y-yo-h>x-xo-w)
dist = y - yo - h ;
else
dist = xo - x ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo - dist, yo ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 9 : // Resizing bottom-right
if (y-yo-h>x-xo-w)
dist = yo - y ;
else
dist = x - xo - w ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo , yo - dist ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
}
int a, b ;
active_object->getPosition ( &a, &b ) ;
object_position_x->setValue ( a ) ;
object_position_y->setValue ( b ) ;
active_object->getSize ( &a, &b ) ;
object_size_x->setValue ( a ) ;
object_size_y->setValue ( b ) ;
}
}
wid = wid->next ;
}
}
glutPostRedisplay () ;
}
static void main_window_passivefn ( int x, int yy )
{
int y = main_window_height - yy ;
// Dragging the mouse without a button down: save the mouse coordinates
mouse_x = x ;
mouse_y = y ;
/*if (context_menu->isVisible() == 1)
{
puBox *cont_box = context_menu->getABox();
if ( ( x >= cont_box->min[0] ) && ( x <= cont_box->max[0] ) &&
( y >= cont_box->min[1] ) && ( y <= cont_box->max[1] ) )
{
context_menu->checkHit(-1, 0, mouse_x, mouse_y);
}
}*/
}
static void main_window_mousefn ( int button, int updown, int x, int yy )
{
int y = main_window_height - yy ;
mouse_x = x ;
mouse_y = y ;
if ( updown == PU_DOWN )
pguide_last_buttons |= ( 1 << button ) ;
else
pguide_last_buttons &= ~( 1 << button ) ;
if ( button == PU_RIGHT_BUTTON )
{
/* Pressed the right mouse button -- popup the manipulation window. */
WidgetList *wid = widgets ;
while ( wid )
{
puBox *box = wid->obj->getABox () ;
if ( wid->visible && ( x >= box->min[0] ) && ( x <= box->max[0] ) &&
( y >= box->min[1] ) && ( y <= box->max[1] ) )
{
active_widget = wid ;
active_object = wid->obj ;
/* We can modify mouse_x and mouse_y, because theyre not used again if we're in the right mouse function */
/* If we're real close to the right of the screen, modify the X position ...*/
if (mouse_x > main_window_width - 110 ) mouse_x = main_window_width - 110 ;
/* If we're real close to the top of the screen, modify the Y position...*/
if (mouse_y > main_window_height - 140) mouse_y = main_window_height - 140 ;
context_menu->setPosition(mouse_x, mouse_y) ;
context_menu->reveal() ;
//puSetActiveWidget(context_menu, mouse_x, mouse_y) ;
break ;
}
wid = wid->next ;
}
} else {
if ( puActiveWidget() && ( active_object != puActiveWidget() ) )
{
puActiveWidget() -> invokeDownCallback () ;
puDeactivateWidget () ;
}
ctrl_key_down = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ;
if ( ( context_menu->isVisible() == 1) && ( active_widget ) )
{
puBox *cont_box = context_menu->getABox();
if ( ( x >= cont_box->min[0] ) && ( x <= cont_box->max[0] ) &&
( y >= cont_box->min[1] ) && ( y <= cont_box->max[1] ) )
{
context_menu->checkHit(button, updown, mouse_x, mouse_y);
} else {
context_menu->hide();
}
} else /*if ( context_menu->isVisible() == 1) { context_menu->hide(); } * The user did something funny, so hide the menu since they've been naughty */
{
// Downclick: Place a new widget, activate an existing widget, deactivate widget, or select from menu.
if ( updown == GLUT_DOWN )
{
// If there is a selected object, create a new one of that type.
// extern puObject *createWidget ( int type ) ;
extern int selected_object_type ;
if ( selected_object_type )
{
extern bool selected_object_sticky ;
extern char *selected_type_string ;
extern puButton *active_button ;
main_window_changed = true ;
// puObject *new_obj = createWidget ( selected_object->getType () ) ;
puObject *new_obj = new puFrame ( 0, 0, 90, 20 ) ;
char *object_type_name = new char [ PUSTRING_MAX ] ;
strcpy ( object_type_name, selected_type_string ) ;
new_obj->setLegend ( object_type_name ) ;
// Add the new object to the list of widgets
WidgetList *new_wid = new WidgetList ;
new_wid->obj = new_obj ;
new_wid->label_text = (char *)NULL ;
new_wid->legend_text = (char *)NULL ;
new_wid->allowed = (char *)NULL ;
new_wid->items = (char *)NULL ;
new_wid->object_type_name = object_type_name ;
new_wid->object_type = selected_object_type ;
new_wid->callbacks = 1 ; // Default: up callback enabled, others disabled
sprintf ( new_wid->object_name, "widget%d", widget_number++ ) ;
new_wid->visible = true ;
new_wid->locked = autolock ; /* Set it to the autolock var (true or false ) */
new_wid->layer = max_layer - 1 ;
new_wid->next = widgets ;
widgets = new_wid ;
// Set the new widget's position
new_obj->setPosition ( x, y ) ;
mouse_x_position_in_object = 0 ;
mouse_y_position_in_object = 0 ;
/* Set up the widget's default data values */
new_wid->intval1 = 0;
new_wid->intval2 = 0;
new_wid->boolval1 = false;
new_wid->boolval2 = false;
new_wid->boolval3 = false;
new_wid->floatval1 = 0.0f;
new_wid->floatval2 = 0.0f;
new_wid->floatval3 = 0.0f;
new_wid->floatval4 = 0.0f;
new_wid->floatval5 = 0.0f;
new_wid->floatval6 = 0.0f;
if (new_wid->object_type == PUCLASS_TEXT)
{
new_obj->setSize(5,20);
}
if (new_wid->object_type == PUCLASS_COMBOBOX)
{
new_wid->intval1 = 1;
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_SELECTBOX)
{
new_wid->intval1 = 1;
}
if (new_wid->object_type == PUCLASS_BUTTONBOX)
{
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_COMBOBOX)
{
new_wid->intval1 = 1;
new_wid->boolval1 = true;
}
if ( (new_wid->object_type == PUCLASS_SLIDER ) ||
(new_wid->object_type == PUCLASS_BISLIDER ) ||
(new_wid->object_type == PUCLASS_TRISLIDER ) ||
(new_wid->object_type == PUCLASS_DIAL ) ||
(new_wid->object_type == PUCLASS_SPINBOX ) ||
(new_wid->object_type == PUCLASS_SCROLLBAR ) )
{
new_wid->floatval1 = 1.0f;
new_wid->floatval2 = 0.0f;
new_wid->floatval3 = 0.0f;
new_wid->boolval1 = true;
}
if ( (new_wid->object_type == PUCLASS_SLIDER ) ||
(new_wid->object_type == PUCLASS_BISLIDER ) ||
(new_wid->object_type == PUCLASS_TRISLIDER ) )
{
new_wid->boolval2 = true;
}
if (new_wid->object_type == PUCLASS_SLIDER)
{
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_BISLIDER)
{
new_wid->floatval4 = 1.0f;
new_wid->floatval5 = 0.0f;
}
if (new_wid->object_type == PUCLASS_TRISLIDER)
{
new_wid->floatval4 = 1.0f;
new_wid->floatval5 = 0.0f;
new_wid->floatval6 = 0.5f;
new_wid->boolval3 = false;
}
if (new_wid->object_type == PUCLASS_DIAL)
{
new_obj->setSize(50,50);
new_wid->boolval2 = true;
}
if (new_wid->object_type == PUCLASS_SPINBOX)
{
new_wid->boolval2 = true;
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_SCROLLBAR)
{
/* Not Yet Implemented */
}
if (new_wid->object_type == PUCLASS_SPINBOX)
{
new_wid->boolval2 = true;
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_INPUT)
{
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_LARGEINPUT)
{
new_wid->boolval1 = true;
new_wid->intval1 = 1;
new_wid->intval2 = 5;
}
if (new_wid->object_type == PUCLASS_MENUBAR)
{
new_obj->setSize( 120, 30) ;
new_obj->setPosition( 0, puGetWindowHeight()-30) ;
new_wid->locked = true ;
}
if (new_wid->object_type == PUCLASS_VERTMENU)
{
new_obj->setSize( 45, 120) ;
new_obj->setPosition( 0, puGetWindowHeight()-120) ;
new_obj->setLegend("");
new_obj->setLabelPlace(PUPLACE_BOTTOM_LEFT);
new_obj->setLabel("puVerticalMenu");
new_wid->locked = true ;
}
// Make the new widget the active widget
active_object = new_obj ;
active_widget = new_wid ;
// If the "sticky" flag is not set, reset the selected object
if ( !selected_object_sticky )
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
else
{
// Clicking on a widget in the main widget list activates it
WidgetList *wid = widgets ;
while ( wid )
{
puBox *box = wid->obj->getABox () ;
if ( wid->visible && ( x >= box->min[0] ) && ( x <= box->max[0] ) &&
( y >= box->min[1] ) && ( y <= box->max[1] ) )
{
active_widget = wid ;
active_object = wid->obj ;
if ( abs ( x - box->min[0] ) < RESIZING_BORDER_WIDTH )
activity_flag = 2 ; // Resizing on x-min
else if ( abs ( x - box->max[0] ) < RESIZING_BORDER_WIDTH )
activity_flag = 4 ; // Resizing on x-max
else if ( abs ( y - box->min[1] ) < RESIZING_BORDER_WIDTH )
activity_flag = 3 ; // Resizing on y-min
else if ( abs ( y - box->max[1] ) < RESIZING_BORDER_WIDTH )
activity_flag = 5 ; // Resizing on y-max
else
activity_flag = 1 ; // Away from edges, we're moving it
/* Now we check and see if we're clicking on a corner - the sensitivity for
the determiniation of whether we're clicking a corner or not is held by the
definition of "RESIZING_CORNER_BORDER_WIDTH" which is at the top of this file */
int corner_resize_width = RESIZING_CORNER_BORDER_WIDTH + (((box->max[0] - box->min[0]) + (box->max[1] - box->min[1]) / 2 ) / 50 ) * 2 ;
if ( activity_flag != 1 )
{
// Bottom Right Corner
if ( ( abs( y - box->min[1] ) < corner_resize_width ) && (abs ( x - box->max[0] ) < corner_resize_width ) )
activity_flag = 9;
// Bottom Left Corner
if ( ( abs( y - box->min[1] ) < corner_resize_width ) && (abs ( x - box->min[0] ) < corner_resize_width ) )
activity_flag = 6;
// Top Right Corner
if ( ( abs( y - box->max[1] ) < corner_resize_width ) && (abs ( x - box->max[0] ) < corner_resize_width ) )
activity_flag = 7;
// Top Left Corner
if ( ( abs( y - box->max[1] ) < corner_resize_width ) && (abs ( x - box->min[0] ) < corner_resize_width ) )
activity_flag = 8;
}
/* If CTRL is held down, symmetric resize is forced. */
resize_symmetric = ctrl_key_down ? 2 : 1 ;
if (active_widget->object_type == PUCLASS_DIAL)
resize_corner = 1 ;
else
resize_corner = 0;
int object_x, object_y ;
active_object->getPosition ( &object_x, &object_y ) ;
mouse_x_position_in_object = x - object_x ;
mouse_y_position_in_object = y - object_y ;
break ;
}
wid = wid->next ;
}
if ( ( !wid ) && ( context_menu->isVisible()==0 ) ) // Ran through the entire list, deactivate any active widget
{
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
}
}
}
setStatusWidgets ( active_widget ) ;
}
}
glutPostRedisplay () ;
}
static void main_window_reshapefn ( int w, int h )
{
extern puInput *window_size_x ;
extern puInput *window_size_y ;
if (done_first_setup)
main_window_changed = true ;
else
done_first_setup = true ;
if ( ( !currently_loading ) && (
( mouse_x < main_window_width/2 ) || // Grabbed the left edge ...
( mouse_y < main_window_height/2 ) ) ) // or the bottom edge, move the widgets
{
WidgetList *wid = widgets ;
int deltax = 0 ;
int deltay = 0 ;
if ( mouse_x < main_window_width/2 ) deltax = w - main_window_width ;
if ( mouse_y < main_window_height/2 ) deltay = h - main_window_height ;
while ( wid )
{
int x, y ;
wid->obj->getPosition ( &x, &y ) ;
wid->obj->setPosition ( x + deltax, y + deltay ) ;
wid = wid->next ;
}
}
main_window_width = w ;
main_window_height = h ;
window_size_x->setValue ( w ) ;
window_size_y->setValue ( h ) ;
currently_loading = false ;
}
static void main_window_displayfn ( void )
{
/* Clear the screen */
glutSetWindow ( main_window ) ;
glClearColor ( main_window_color_r, main_window_color_g, main_window_color_b, main_window_color_a ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
// Set the OpenGL to draw PUI widgets
int w = puGetWindowWidth () ;
int h = puGetWindowHeight () ;
glPushAttrib ( GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_LIGHTING_BIT ) ;
glDisable ( GL_LIGHTING ) ;
glDisable ( GL_FOG ) ;
glDisable ( GL_TEXTURE_2D ) ;
glDisable ( GL_DEPTH_TEST ) ;
glDisable ( GL_CULL_FACE ) ;
glViewport ( 0, 0, w, h ) ;
glMatrixMode ( GL_PROJECTION ) ;
glPushMatrix () ;
glLoadIdentity () ;
gluOrtho2D ( 0, w, 0, h ) ;
glMatrixMode ( GL_MODELVIEW ) ;
glPushMatrix () ;
glLoadIdentity () ;
// Draw the widgets
int layer ;
for ( layer = 0; layer < max_layer; layer++ )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->visible && ( wid->layer == layer ) ) wid->obj->draw ( 0, 0 ) ;
wid = wid->next ;
}
}
if ( active_object )
{
puBox *box = active_object->getBBox () ;
glColor4f ( 0.0f, 0.0f, 0.0f, 1.0f ) ;
glLineWidth ( 3.0f ) ;
glBegin ( GL_LINES ) ;
glVertex2i ( box->min[0]-1, box->min[1]-1 ) ;
glVertex2i ( box->max[0]+1, box->min[1]-1 ) ;
glVertex2i ( box->max[0]+1, box->max[1]+1 ) ;
glVertex2i ( box->min[0]-1, box->max[1]+1 ) ;
glVertex2i ( box->min[0]-1, box->min[1]-1 ) ;
glEnd () ;
}
context_menu->draw(0,0);
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
int main ( int argc, char **argv )
{
extern int define_widget_window () ;
extern int define_status_window () ;
int i = 0;
strcpy ( main_window_name, "PUI GUI Builder" ) ;
glutInitWindowPosition( 100, 0 ) ;
glutInitWindowSize ( main_window_width, main_window_height ) ;
glutInit ( &argc, argv ) ;
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
main_window = glutCreateWindow ( main_window_name ) ;
glutDisplayFunc ( main_window_displayfn ) ;
glutKeyboardFunc ( main_window_keyfn ) ;
glutSpecialFunc ( main_window_specialfn ) ;
glutMouseFunc ( main_window_mousefn ) ;
glutMotionFunc ( main_window_motionfn ) ;
glutPassiveMotionFunc ( main_window_passivefn ) ;
glutReshapeFunc ( main_window_reshapefn ) ;
glutIdleFunc ( main_window_displayfn ) ;
// If we're using windows, ignore the C: or whatnot
#ifdef WIN32
#define PATH_SEPARATOR '\\'
strcpy (pguide_current_directory, argv[0]+2);
#else
#define PATH_SEPARATOR '/'
strcpy (pguide_current_directory, argv[0]);
#endif
i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0';
puInit () ;
#ifdef VOODOO
puShowCursor () ;
#endif
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
puSetDefaultColourScheme ( 0.8f, 0.8f, 0.8f, 1.0f ) ;
// Add the properties context menu
context_menu = new puPopupMenu( 0, 0 ) ;
context_menu->add_item("Properties", cb_edit_properties) ;
context_menu->add_item("Lock/Unlock", cb_lock_toggle) ;
context_menu->add_item("Delete", cb_popup_delete) ;
context_menu->add_item("Cut", NULL) ;
context_menu->add_item("Copy", NULL) ;
context_menu->add_item("Change Class", NULL) ;
context_menu->close() ;
// Set up the other windows
define_widget_window () ;
define_status_window () ;
glutMainLoop () ;
return 0 ;
}

View File

@ -0,0 +1,128 @@
# Microsoft Developer Studio Project File - Name="pGuide" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=pGuide - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "pGuide.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "pGuide.mak" CFG="pGuide - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "pGuide - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "pGuide - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
F90=df.exe
RSC=rc.exe
!IF "$(CFG)" == "pGuide - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 pui.lib puAux.lib sg.lib fnt.lib ul.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\plib"
!ELSEIF "$(CFG)" == "pGuide - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "pGuide___Win32_Debug"
# PROP BASE Intermediate_Dir "pGuide___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "pGuide___Win32_Debug"
# PROP Intermediate_Dir "pGuide___Win32_Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 pui_d.lib puAux_d.lib sg_d.lib fnt_d.lib ul_d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBCMTD" /pdbtype:sept /libpath:"..\..\..\..\plib"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "pGuide - Win32 Release"
# Name "pGuide - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\LoadSave.cxx
# End Source File
# Begin Source File
SOURCE=.\pGuide.cxx
# End Source File
# Begin Source File
SOURCE=.\PropertiesWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\StatusWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\WidgetWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\WriteCode.cxx
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\WidgetList.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

3
demos/simon/AUTHORS Normal file
View File

@ -0,0 +1,3 @@
SIMON was written by Steve Baker.
AstroPong was written by Oliver Baker.

340
demos/simon/COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
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 Program or any portion
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) 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; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, 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 executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. 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 Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. 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 Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program 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 Program.
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.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program 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.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies 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 Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, 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
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. 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 PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, 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.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

13
demos/simon/Makefile Normal file
View File

@ -0,0 +1,13 @@
all:
(cd src ; make)
install:
(cd src ; make install)
uninstall:
(cd src ; make uninstall)
clean:
(cd src ; make clean)

60
demos/simon/README Normal file
View File

@ -0,0 +1,60 @@
WELCOME TO S.I.M.O.N
====================
Which stands for:
Simple
Interface for
Making
Oliver's programs
Nice.
This is a simple set of functions that hide much of the nastiness
of 3D programming to make it possible for someone with only the
very minimum of programming experience to write simple 3D applications.
INSTALLATION
============
Right now, you build SIMON by running 'make' and install it by
running 'make install' as root. You must already have PLIB installed.
Simon installs into /usr/local/simon/libsimon.a /usr/local/simon/simon.h
and places an executable into /usr/local/bin/simon
RUNNING SIMON
=============
There are two ways to write SIMON programs:
1) Write your code in C++ and link it to libsimon
(the LIBRARY version of SIMON).
2) Write your code in PSL (The PLIB Scripting Language)
and use the 'simon' program to run it.
Documentation for both methods are in the 'doc' directory.
DEMO'S
======
AstroPong is my son's first ever game (his first ever program actually).
It was originally written in C++ using libsimon - but has subsequently
been converted into PSL for use as a demonstration program.
Once you've done a 'make install', you can change directory down into
the 'simon' directory and run:
simon astropong.psl
...move your paddle using the joystick - don't let the herring
escape from the ice cube!

View File

@ -0,0 +1,249 @@
/*
AstroPong - A 3D Pong Game
Copyright (C) 2002 Oliver Baker
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 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information visit http://plib.sourceforge.net
$Id: astropong.psl 1699 2002-09-22 15:22:21Z sjbaker $
*/
#define ARENA_SIZE 8.0 /* meters */
#define ARENA_LENGTH 10.0 /* meters */
#define BALL_SIZE 2.5 /* meters */
#define BOUNCE (ARENA_SIZE/2.0 - BALL_SIZE/2.0)
#define BOUNCEY (ARENA_LENGTH/2.0 - BALL_SIZE/2.0)
#define BAT_SIZE (1.0 + BALL_SIZE/2.0) /* From the center to the sides */
int arena ;
int shadow ;
int difficulty ;
int scoreBoardR ;
int scoreBoardB ;
int ball ;
int bPaddle ;
int rPaddle ;
int camera ;
int scoreR ;
int scoreB ;
float Blue_batspeed = .34;
float scoreSpinR ;
float scoreSpinB ;
float ballSpinH ;
float ballSpinSH ;
float ballSpinP ;
float ballSpinSP ;
float ballSpinR ;
float ballSpinSR ;
float ballX ;
float ballY ;
float ballZ ;
float ballSX ;
float ballSY ;
float ballSZ ;
float bpaddleX ;
float bpaddleZ ;
float rpaddleX ;
float rpaddleZ ;
float userX ;
float userZ ;
int frameno = 0 ;
int main()
{
camera = 0 ;
arena = siLoad ( "arena2.ac") ;
ball = siLoad ( "ball3.ac") ;
bPaddle = siLoad ( "bluepaddle2.ac");
rPaddle = siLoad ( "redpaddle2.ac") ;
scoreBoardR = siLoad ( "Scoreboard.ac") ;
scoreBoardB = siLoad ( "Scoreboard.ac") ;
shadow = siLoad ( "shadow2.ac") ;
scoreSpinR = 0 ;
scoreSpinB = 0 ;
ballSX = 0.166 ;
ballSY = 0.155 ;
ballSZ = 0.016 ;
ballSpinSH = 4 ;
ballSpinSP = 4 ;
ballSpinSR = 4 ;
difficulty = 1 ;
if ( difficulty == 1 ) { Blue_batspeed = .275 ; }
else { Blue_batspeed = .34 ; }
while ( 1 )
{
frameno = frameno + 1 ;
/* Read the joystick */
userX = siJoystickLR();
userZ = siJoystickUD();
/* Move the ball */
ballX += ballSX ;
ballY += ballSY ;
ballZ += ballSZ ;
ballSpinH += ballSpinSH ;
ballSpinP += ballSpinSP ;
ballSpinR += ballSpinSR ;
/* Bounce off the sides? */
if ( ballX > BOUNCE || ballX < -BOUNCE )
{
ballSX = -ballSX ;
}
/* Bounce off the top and bottom? */
if ( ballZ > BOUNCE || ballZ < -BOUNCE )
{
ballSZ = -ballSZ ;
}
/* What happens at the ends? */
if ( ballY > BOUNCEY ) /* Passed the blue paddle? */
{
/* Is the blue bat there? */
if (ballX > bpaddleX - BAT_SIZE && ballX < bpaddleX + BAT_SIZE &&
ballZ > bpaddleZ - BAT_SIZE && ballZ < bpaddleZ + BAT_SIZE )
{
float hitX = ballX - bpaddleX ;
float hitZ = ballZ - bpaddleZ ;
if ( ballSX > 0 )
ballSX = fabs ( hitX / 2.0 ) ;
else
ballSX = -fabs ( hitX / 2.0 ) ;
if ( ballSZ > 0 )
ballSZ = fabs ( hitZ / 2.0 ) ;
else
ballSZ = -fabs ( hitZ / 2.0 ) ;
ballSY = -ballSY ;
}
else
{
scoreR++ ;
print ("The score is Red:", scoreR, " Blue:", scoreB, "\n" ) ;
ballSX = 0.1 ;
ballSY = 0.1 ;
ballSZ = 0.1;
ballSY = -ballSY ;
ballX = 0.0 ;
ballY = 0.0 ;
ballZ = 0.0;
for ( int i = 0 ; i < 60 ; i++ ) pause ;
}
}
if ( ballY < -BOUNCEY ) /* Passed the red paddle? */
{
/* Was the red bat there? */
if (ballX > rpaddleX - BAT_SIZE && ballX < rpaddleX + BAT_SIZE &&
ballZ > rpaddleZ - BAT_SIZE && ballZ < rpaddleZ + BAT_SIZE )
{
float hitX = ballX - rpaddleX ;
float hitZ = ballZ - rpaddleZ ;
if ( ballSX > 0 )
ballSX = fabs ( hitX / 2.0 ) ;
else
ballSX = -fabs ( hitX / 2.0 ) ;
if ( ballSZ > 0 )
ballSZ = fabs ( hitZ / 2.0 ) ;
else
ballSZ = -fabs ( hitZ / 2.0 ) ;
ballSY = -ballSY ;
}
else
{
scoreB++ ;
print ("The score is Red:", scoreR, " Blue:", scoreB, "\n" ) ;
ballSX = .1 ;
ballSY = .1 ;
ballSZ = .1;
ballSY = -ballSY ;
ballX = 0.0 ;
ballY = 0.0 ;
ballZ = 0.0;
for ( int i = 0 ; i < 60 ; i++ ) pause ;
}
}
/* Update the scoreboard */
scoreSpinR = scoreR * -36.0 ;
scoreSpinB = scoreB * -36.0 ;
/* How should the computer move the paddle? */
if ( ballZ > bpaddleZ ) { bpaddleZ += Blue_batspeed ; }
else { bpaddleZ -= Blue_batspeed ; }
if ( ballX > bpaddleX ) { bpaddleX += Blue_batspeed ; }
else { bpaddleX -= Blue_batspeed ; }
/* How did the player move the paddle? */
rpaddleX += userX * -.5;
rpaddleZ += userZ * .5;
/* Did the paddle move off the edge of the screen? */
if ( rpaddleX > BOUNCE ) rpaddleX = BOUNCE ;
if ( rpaddleX < -BOUNCE ) rpaddleX = -BOUNCE ;
if ( rpaddleZ > BOUNCE ) rpaddleZ = BOUNCE ;
if ( rpaddleZ < -BOUNCE ) rpaddleZ = -BOUNCE ;
/* Tell SIMON where to position the paddle, ball and camera */
/* MODEL X, Y, Z, H, P, R */
siPosition ( scoreBoardR, 1, 0, 0, 0, scoreSpinR, 0 ) ;
siPosition ( scoreBoardB, -1, 0, 0, 0, scoreSpinB, 0 ) ;
siPosition ( bPaddle , bpaddleX, 5, bpaddleZ, 0, 0 , 0 ) ;
siPosition ( rPaddle , rpaddleX, -5, rpaddleZ, 0, 0 , 0 ) ;
siPosition ( ball , ballX, ballY, ballZ,
ballSpinH,ballSpinP,ballSpinR);
siPosition ( arena , 0, 0, 0, 0, 0 , 0 ) ;
siPosition ( shadow , ballX, ballY, -4, 0, 0 , 0 ) ;
siPosition ( camera , 0, -10, 0, 0, 0 , 0 ) ;
pause ;
}
}

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More