Remove unneeded files and windows only tools

This commit is contained in:
Yamagi Burmeister 2012-02-02 11:16:31 +00:00
parent 0430f42375
commit a6f4830dd1
70 changed files with 0 additions and 26168 deletions

View file

@ -1,281 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
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

View file

@ -1,31 +0,0 @@
Fri Feb 17 11:10:50 CST 2006
If you are getting this file long after our initial release,
chances are the source is quite outdated. See the release
announcement below.
TTimo
id Software releases GtkRadiant source code under GPL
=====================================================
Following last summer's release of Quake III Arena source code and tools
under the GPL license, id is now placing GtkRadiant and q3map2 under GPL
license. We are also providing in this release a number of Quake II
tools that never made it under GPL when we packaged Quake II source code.
GtkRadiant [1] is the heavily modified version of QERadiant and
Q3Radiant ( id's level editors used during Quake II and Quake III Arena
development ). It runs on Microsoft Windows platforms, GNU/Linux, MacOS
X, and supports level editing for many id technology games [2].
A tarball of the initial release is available from our ftp server [3],
and the development website [4] now holds a subversion repository with
the GPL code. We expect development on the editor to continue as usual,
and hope that many new developers will join us [5] :-)
[1] http://www.qeradiant.com/
[2] http://www.qeradiant.com/?data=sitemap#games
[3] ftp://ftp.idsoftware.com/idstuff/source/GtkRadiant-GPL.zip
[4] http://zerowing.idsoftware.com/
[5] http://www.qeradiant.com/wikifaq/index.php?How%20to%20reach%20the%20developers

View file

@ -1,72 +0,0 @@
# Microsoft Developer Studio Project File - Name="Unpack" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Java Virtual Machine Java Project" 0x0809
CFG=Unpack - Java Virtual Machine 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 "Unpack.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 "Unpack.mak" CFG="Unpack - Java Virtual Machine Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Unpack - Java Virtual Machine Release" (based on\
"Java Virtual Machine Java Project")
!MESSAGE "Unpack - Java Virtual Machine Debug" (based on\
"Java Virtual Machine Java Project")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
JAVA=jvc.exe
!IF "$(CFG)" == "Unpack - Java Virtual Machine Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ""
# PROP BASE Intermediate_Dir ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ""
# PROP Intermediate_Dir ""
# PROP Target_Dir ""
# ADD BASE JAVA /O
# ADD JAVA /O
!ELSEIF "$(CFG)" == "Unpack - Java Virtual Machine Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ""
# PROP BASE Intermediate_Dir ""
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ""
# PROP Intermediate_Dir ""
# PROP Target_Dir ""
# ADD BASE JAVA /g
# ADD JAVA /g
!ENDIF
# Begin Target
# Name "Unpack - Java Virtual Machine Release"
# Name "Unpack - Java Virtual Machine Debug"
# Begin Source File
SOURCE=.\Unpack.java
# End Source File
# End Target
# End Project

View file

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

View file

@ -1,198 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
/*
* Unpack -- a completely non-object oriented utility...
*
*/
import java.io.*;
class Unpack {
static final int IDPAKHEADER = (('K'<<24)+('C'<<16)+('A'<<8)+'P');
static int intSwap(int i) {
int a, b, c, d;
a = i & 255;
b = (i >> 8) & 255;
c = (i >> 16) & 255;
d = (i >> 24) & 255;
return (a << 24) + (b << 16) + (c << 8) + d;
}
static boolean patternMatch (String pattern, String s) {
int index;
int remaining;
if (pattern.equals(s)) {
return true;
}
// fairly lame single wildcard matching
index = pattern.indexOf('*');
if (index == -1) {
return false;
}
if (!pattern.regionMatches(0, s, 0, index)) {
return false;
}
index += 1; // skip the *
remaining = pattern.length() - index;
if (s.length() < remaining) {
return false;
}
if (!pattern.regionMatches(index, s, s.length()-remaining, remaining)) {
return false;
}
return true;
}
static void usage() {
System.out.println ("Usage: unpack <packfile> <match> <basedir>");
System.out.println (" or: unpack -list <packfile>");
System.out.println ("<match> may contain a single * wildcard");
System.exit (1);
}
public static void main (String[] args) {
int ident;
int dirofs;
int dirlen;
int i;
int numLumps;
byte[] name = new byte[56];
String nameString;
int filepos;
int filelen;
RandomAccessFile readLump;
DataInputStream directory;
String pakName;
String pattern;
if (args.length == 2) {
if (!args[0].equals("-list")) {
usage();
}
pakName = args[1];
pattern = null;
} else if (args.length == 3) {
pakName = args[0];
pattern = args[1];
} else {
pakName = null;
pattern = null;
usage ();
}
try {
// one stream to read the directory
directory = new DataInputStream(new FileInputStream(pakName));
// another to read lumps
readLump = new RandomAccessFile(pakName, "r");
// read the header
ident = intSwap(directory.readInt());
dirofs = intSwap(directory.readInt());
dirlen = intSwap(directory.readInt());
if (ident != IDPAKHEADER) {
System.out.println ( pakName + " is not a pakfile.");
System.exit (1);
}
// read the directory
directory.skipBytes (dirofs - 12);
numLumps = dirlen / 64;
System.out.println (numLumps + " lumps in " + pakName);
for (i = 0 ; i < numLumps ; i++) {
directory.readFully(name);
filepos = intSwap(directory.readInt());
filelen = intSwap(directory.readInt());
nameString = new String (name, 0);
// chop to the first 0 byte
nameString = nameString.substring (0, nameString.indexOf(0));
if (pattern == null) {
// listing mode
System.out.println (nameString + " : " + filelen + "bytes");
} else if (patternMatch (pattern, nameString) ) {
File writeFile;
DataOutputStream writeLump;
byte[] buffer = new byte[filelen];
StringBuffer fixedString;
String finalName;
int index;
System.out.println ("Unpaking " + nameString + " " + filelen
+ " bytes");
// load the lump
readLump.seek(filepos);
readLump.readFully(buffer);
// quake uses forward slashes, but java requires
// they only by the host's seperator, which
// varies from win to unix
fixedString = new StringBuffer (args[2] + File.separator + nameString);
for (index = 0 ; index < fixedString.length() ; index++) {
if (fixedString.charAt(index) == '/') {
fixedString.setCharAt(index, File.separatorChar);
}
}
finalName = fixedString.toString ();
index = finalName.lastIndexOf(File.separatorChar);
if (index != -1) {
String finalPath;
File writePath;
finalPath = finalName.substring(0, index);
writePath = new File (finalPath);
writePath.mkdirs();
}
writeFile = new File (finalName);
writeLump = new DataOutputStream ( new FileOutputStream(writeFile) );
writeLump.write(buffer);
writeLump.close();
}
}
readLump.close();
directory.close();
} catch (IOException e) {
System.out.println ( e.toString() );
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,87 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// brush.h
typedef struct
{
int numpoints;
int maxpoints;
float points[8][5]; // variable sized
} winding_t;
// the normals on planes point OUT of the brush
#define MAXPOINTS 16
typedef struct face_s
{
struct face_s *next;
vec3_t planepts[3];
texdef_t texdef;
plane_t plane;
winding_t *face_winding;
vec3_t d_color;
qtexture_t *d_texture;
// int d_numpoints;
// vec3_t *d_points;
} face_t;
#define MAX_FACES 16
typedef struct brush_s
{
struct brush_s *prev, *next; // links in active/selected
struct brush_s *oprev, *onext; // links in entity
struct entity_s *owner;
vec3_t mins, maxs;
face_t *brush_faces;
} brush_t;
void Brush_AddToList (brush_t *b, brush_t *list);
void Brush_Build(brush_t *b);
void Brush_BuildWindings( brush_t *b );
brush_t *Brush_Clone (brush_t *b);
brush_t *Brush_Create (vec3_t mins, vec3_t maxs, texdef_t *texdef);
void Brush_Draw( brush_t *b );
void Brush_DrawXY( brush_t *b );
void Brush_Free (brush_t *b);
void Brush_MakeSided (int sides);
void Brush_Move (brush_t *b, vec3_t move);
brush_t *Brush_Parse (void);
face_t *Brush_Ray (vec3_t origin, vec3_t dir, brush_t *b, float *dist);
void Brush_RemoveFromList (brush_t *b);
void Brush_SelectFaceForDragging (brush_t *b, face_t *f, qboolean shear);
void Brush_SetTexture (brush_t *b, texdef_t *texdef);
void Brush_SideSelect (brush_t *b, vec3_t origin, vec3_t dir, qboolean shear);
void Brush_Write (brush_t *b, FILE *f);
void Brush_RemoveEmptyFaces ( brush_t *b );
int AddPlanept (float *f);
face_t *Face_Clone (face_t *f);
void Face_Draw( face_t *face );
winding_t *MakeFaceWinding (brush_t *b, face_t *face);

View file

@ -1,378 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// upper design bounds
// leaffaces, leafbrushes, planes, and verts are still bounded by
// 16 bit short limits
#define MAX_MAP_MODELS 1024
#define MAX_MAP_BRUSHES 8192
#define MAX_MAP_ENTITIES 2048
#define MAX_MAP_PATHS 2048
#define MAX_MAP_ENTSTRING 0x20000
#define MAX_MAP_TEXTURES 1024
#define MAX_MAP_TEXINFO 8192
#define MAX_MAP_PLANES 65536
#define MAX_MAP_NODES 65536
#define MAX_MAP_BRUSHSIDES 65536
#define MAX_MAP_LEAFS 65536
#define MAX_MAP_VERTS 65536
#define MAX_MAP_FACES 65536
#define MAX_MAP_LEAFFACES 65536
#define MAX_MAP_LEAFBRUSHES 65536
#define MAX_MAP_PORTALS 65536
#define MAX_MAP_EDGES 128000
#define MAX_MAP_SURFEDGES 256000
#define MAX_MAP_MIPTEX 0x200000
#define MAX_MAP_LIGHTING 0x200000
#define MAX_MAP_VISIBILITY 0x100000
// key / value pair sizes
#define MAX_KEY 32
#define MAX_VALUE 1024
//=============================================================================
#define BSPVERSION 34
typedef struct
{
int fileofs, filelen;
} lump_t;
#define LUMP_ENTITIES 0
#define LUMP_PLANES 1
#define LUMP_TEXTURES 2
#define LUMP_VERTEXES 3
#define LUMP_VISIBILITY 4
#define LUMP_NODES 5
#define LUMP_TEXINFO 6
#define LUMP_FACES 7
#define LUMP_LIGHTING 8
#define LUMP_LEAFS 9
#define LUMP_LEAFFACES 10
#define LUMP_LEAFBRUSHES 11
#define LUMP_EDGES 12
#define LUMP_SURFEDGES 13
#define LUMP_MODELS 14
#define LUMP_PATHS 15
#define LUMP_BRUSHES 16
#define LUMP_BRUSHSIDES 17
#define LUMP_POP 18
#define HEADER_LUMPS 18
typedef struct
{
int version;
lump_t lumps[HEADER_LUMPS];
} dheader_t;
typedef struct
{
float mins[3], maxs[3];
float origin[3]; // for sounds or lights
int headnode;
int visleafs; // not including the solid leaf 0
int firstface, numfaces;
} dmodel_t;
typedef struct
{
int nummiptex;
int dataofs[4]; // [nummiptex]
} dmiptexlump_t;
#define MIPLEVELS 4
typedef struct miptex_s
{
char name[16];
unsigned width, height;
unsigned offsets[MIPLEVELS]; // four mip maps stored
int flags;
int value;
} miptex_t;
typedef struct
{
float point[3];
} dvertex_t;
// 0-2 are axial planes
#define PLANE_X 0
#define PLANE_Y 1
#define PLANE_Z 2
// 3-5 are non-axial planes snapped to the nearest
#define PLANE_ANYX 3
#define PLANE_ANYY 4
#define PLANE_ANYZ 5
// planes (x&~1) and (x&~1)+1 are allways opposites
typedef struct
{
float normal[3];
float dist;
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
} dplane_t;
// contents flags are seperate bits
// a given brush can contribute multiple content bits
// multiple brushes can be in a single leaf
// lower bits are stronger, and will eat weaker brushes completely
#define CONTENTS_SOLID 1 // an eye is never valid in a solid
#define CONTENTS_WINDOW 2 // translucent, but not watery
#define CONTENTS_LAVA 8
#define CONTENTS_SLIME 16
#define CONTENTS_WATER 32
#define CONTENTS_THINWATER 64 // translucent faces
#define LAST_VISIBLE_CONTENTS 64
// remaining contents are non-visible, and don't eat brushes
#define CONTENTS_MONSTER 128
#define CONTENTS_PLAYERCLIP 256
#define CONTENTS_MONSTERCLIP 512
// currents can be added to any other contents, and may be mixed
#define CONTENTS_CURRENT_0 1024
#define CONTENTS_CURRENT_90 2048
#define CONTENTS_CURRENT_180 4096
#define CONTENTS_CURRENT_270 8192
#define CONTENTS_CURRENT_UP 16384
#define CONTENTS_CURRENT_DOWN 32768
#define CONTENTS_ORIGIN 65536 // removed before processing
// !!! if this is changed, it must be changed in asm_i386.h too !!!
typedef struct
{
int planenum;
int children[2]; // negative numbers are -(leafs+1), not nodes
short mins[3]; // for frustom culling
short maxs[3];
unsigned short firstface;
unsigned short numfaces; // counting both sides
} dnode_t;
typedef struct texinfo_s
{
float vecs[2][4]; // [s/t][xyz offset]
int miptex;
int flags; // miptex flags + overrides
int value; // light emition, etc
} texinfo_t;
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
#define SURF_LIGHT 2
#define SURF_WATER 4
#define SURF_SLIME 8
#define SURF_LAVA 16
#define SURF_WINDOW 32
#define SURF_SKY 64
#define SURF_MIRROR 128
#define SURF_SLIPPERY 256
// note that edge 0 is never used, because negative edge nums are used for
// counterclockwise use of the edge in a face
typedef struct
{
unsigned short v[2]; // vertex numbers
} dedge_t;
#define MAXLIGHTMAPS 4
typedef struct
{
unsigned short planenum;
short side;
int firstedge; // we must support > 64k edges
short numedges;
short texinfo;
// lighting info
byte styles[MAXLIGHTMAPS];
int lightofs; // start of [numstyles*surfsize] samples
} dface_t;
typedef struct
{
int contents; // OR of all brushes
int visofs; // -1 = no visibility info
short mins[3]; // for frustum culling
short maxs[3];
unsigned short firstleafface;
unsigned short numleaffaces;
unsigned short firstleafbrush;
unsigned short numleafbrushes;
} dleaf_t;
typedef struct
{
unsigned short planenum; // facing out of the leaf
short texinfo;
} dbrushside_t;
typedef struct
{
int firstside;
int numsides;
int contents;
} dbrush_t;
typedef struct
{
float origin[3];
float angles[3];
int next, prev;
int flags;
float speed;
} dpath_t;
//============================================================================
#ifndef QUAKE_GAME
#define ANGLE_UP -1
#define ANGLE_DOWN -2
// the utilities get to be lazy and just use large static arrays
extern int nummodels;
extern dmodel_t dmodels[MAX_MAP_MODELS];
extern int visdatasize;
extern byte dvisdata[MAX_MAP_VISIBILITY];
extern int lightdatasize;
extern byte dlightdata[MAX_MAP_LIGHTING];
extern int texdatasize;
extern byte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
extern int entdatasize;
extern char dentdata[MAX_MAP_ENTSTRING];
extern int numleafs;
extern dleaf_t dleafs[MAX_MAP_LEAFS];
extern int numplanes;
extern dplane_t dplanes[MAX_MAP_PLANES];
extern int numvertexes;
extern dvertex_t dvertexes[MAX_MAP_VERTS];
extern int numnodes;
extern dnode_t dnodes[MAX_MAP_NODES];
extern int numtexinfo;
extern texinfo_t texinfo[MAX_MAP_TEXINFO];
extern int numfaces;
extern dface_t dfaces[MAX_MAP_FACES];
extern int numedges;
extern dedge_t dedges[MAX_MAP_EDGES];
extern int numleaffaces;
extern unsigned short dleaffaces[MAX_MAP_LEAFFACES];
extern int numleafbrushes;
extern unsigned short dleafbrushes[MAX_MAP_LEAFBRUSHES];
extern int numsurfedges;
extern int dsurfedges[MAX_MAP_SURFEDGES];
extern int numpaths;
extern dpath_t dpaths[MAX_MAP_PATHS];
extern int numbrushes;
extern dbrush_t dbrushes[MAX_MAP_BRUSHES];
extern int numbrushsides;
extern dbrushside_t dbrushsides[MAX_MAP_BRUSHSIDES];
void DecompressVis (byte *in, byte *decompressed);
int CompressVis (byte *vis, byte *dest);
void LoadBSPFile (char *filename);
void WriteBSPFile (char *filename);
void PrintBSPFileSizes (void);
//===============
typedef struct epair_s
{
struct epair_s *next;
char *key;
char *value;
} epair_t;
typedef struct
{
vec3_t origin;
int firstbrush;
int numbrushes;
epair_t *epairs;
} entity_t;
extern int num_entities;
extern entity_t entities[MAX_MAP_ENTITIES];
void ParseEntities (void);
void UnparseEntities (void);
void SetKeyValue (entity_t *ent, char *key, char *value);
char *ValueForKey (entity_t *ent, char *key);
// will return "" if not present
vec_t FloatForKey (entity_t *ent, char *key);
void GetVectorForKey (entity_t *ent, char *key, vec3_t vec);
epair_t *ParseEpair (void);
void PrintEntity (entity_t *ent);
extern int r_leaftovis[MAX_MAP_LEAFS];
extern int r_vistoleaf[MAX_MAP_LEAFS];
extern int r_numvisleafs;
#endif

View file

@ -1,594 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
#define PAGEFLIPS 2
void DrawPathLines (void);
camera_t camera;
/*
============
Cam_Init
============
*/
void Cam_Init (void)
{
// camera.draw_mode = cd_texture;
// camera.draw_mode = cd_solid;
// camera.draw_mode = cd_wire;
camera.timing = false;
camera.origin[0] = 0;
camera.origin[1] = 20;
camera.origin[2] = 46;
camera.color[0] = 0.3;
camera.color[1] = 0.3;
camera.color[2] = 0.3;
}
//============================================================================
void Cam_BuildMatrix (void)
{
float xa, ya;
float matrix[4][4];
int i;
xa = camera.angles[0]/180*Q_PI;
ya = camera.angles[1]/180*Q_PI;
// the movement matrix is kept 2d
camera.forward[0] = cos(ya);
camera.forward[1] = sin(ya);
camera.right[0] = camera.forward[1];
camera.right[1] = -camera.forward[0];
glGetFloatv (GL_PROJECTION_MATRIX, &matrix[0][0]);
for (i=0 ; i<3 ; i++)
{
camera.vright[i] = matrix[i][0];
camera.vup[i] = matrix[i][1];
camera.vpn[i] = matrix[i][2];
}
VectorNormalize (camera.vright);
VectorNormalize (camera.vup);
VectorNormalize (camera.vpn);
}
//===============================================
/*
===============
Cam_ChangeFloor
===============
*/
void Cam_ChangeFloor (qboolean up)
{
brush_t *b;
float d, bestd, current;
vec3_t start, dir;
start[0] = camera.origin[0];
start[1] = camera.origin[1];
start[2] = 8192;
dir[0] = dir[1] = 0;
dir[2] = -1;
current = 8192 - (camera.origin[2] - 48);
if (up)
bestd = 0;
else
bestd = 16384;
for (b=active_brushes.next ; b != &active_brushes ; b=b->next)
{
if (!Brush_Ray (start, dir, b, &d))
continue;
if (up && d < current && d > bestd)
bestd = d;
if (!up && d > current && d < bestd)
bestd = d;
}
if (bestd == 0 || bestd == 16384)
return;
camera.origin[2] += current - bestd;
Sys_UpdateWindows (W_CAMERA|W_Z_OVERLAY);
}
//===============================================
int cambuttonstate;
static int buttonx, buttony;
static int cursorx, cursory;
face_t *side_select;
#define ANGLE_SPEED 300
#define MOVE_SPEED 400
/*
================
Cam_PositionDrag
================
*/
void Cam_PositionDrag (void)
{
int x, y;
Sys_GetCursorPos (&x, &y);
if (x != cursorx || y != cursory)
{
x -= cursorx;
VectorMA (camera.origin, x, camera.vright, camera.origin);
y -= cursory;
camera.origin[2] -= y;
Sys_SetCursorPos (cursorx, cursory);
Sys_UpdateWindows (W_CAMERA | W_XY_OVERLAY);
}
}
/*
===============
Cam_MouseControl
===============
*/
void Cam_MouseControl (float dtime)
{
int xl, xh;
int yl, yh;
float xf, yf;
if (cambuttonstate != MK_RBUTTON)
return;
xf = (float)(buttonx - camera.width/2) / (camera.width/2);
yf = (float)(buttony - camera.height/2) / (camera.height/2);
xl = camera.width/3;
xh = xl*2;
yl = camera.height/3;
yh = yl*2;
#if 0
// strafe
if (buttony < yl && (buttonx < xl || buttonx > xh))
VectorMA (camera.origin, xf*dtime*MOVE_SPEED, camera.right, camera.origin);
else
#endif
{
xf *= 1.0 - fabs(yf);
if (xf < 0)
{
xf += 0.1;
if (xf > 0)
xf = 0;
}
else
{
xf -= 0.1;
if (xf < 0)
xf = 0;
}
VectorMA (camera.origin, yf*dtime*MOVE_SPEED, camera.forward, camera.origin);
camera.angles[YAW] += xf*-dtime*ANGLE_SPEED;
}
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
}
/*
==============
Cam_MouseDown
==============
*/
void Cam_MouseDown (int x, int y, int buttons)
{
vec3_t dir;
float f, r, u;
int i;
//
// calc ray direction
//
u = (float)(y - camera.height/2) / (camera.width/2);
r = (float)(x - camera.width/2) / (camera.width/2);
f = 1;
for (i=0 ; i<3 ; i++)
dir[i] = camera.vpn[i] * f + camera.vright[i] * r + camera.vup[i] * u;
VectorNormalize (dir);
Sys_GetCursorPos (&cursorx, &cursory);
cambuttonstate = buttons;
buttonx = x;
buttony = y;
// LBUTTON = manipulate selection
// shift-LBUTTON = select
// middle button = grab texture
// ctrl-middle button = set entire brush to texture
// ctrl-shift-middle button = set single face to texture
if ( (buttons == MK_LBUTTON)
|| (buttons == (MK_LBUTTON | MK_SHIFT))
|| (buttons == (MK_LBUTTON | MK_CONTROL))
|| (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT))
|| (buttons == MK_MBUTTON)
|| (buttons == (MK_MBUTTON|MK_CONTROL))
|| (buttons == (MK_MBUTTON|MK_SHIFT|MK_CONTROL)) )
{
Drag_Begin (x, y, buttons,
camera.vright, camera.vup,
camera.origin, dir);
return;
}
if (buttons == MK_RBUTTON)
{
Cam_MouseControl (0.1);
return;
}
}
/*
==============
Cam_MouseUp
==============
*/
void Cam_MouseUp (int x, int y, int buttons)
{
cambuttonstate = 0;
Drag_MouseUp ();
}
/*
==============
Cam_MouseMoved
==============
*/
void Cam_MouseMoved (int x, int y, int buttons)
{
cambuttonstate = buttons;
if (!buttons)
return;
buttonx = x;
buttony = y;
if (buttons == (MK_RBUTTON|MK_CONTROL) )
{
Cam_PositionDrag ();
Sys_UpdateWindows (W_XY|W_CAMERA|W_Z);
return;
}
Sys_GetCursorPos (&cursorx, &cursory);
if (buttons & (MK_LBUTTON | MK_MBUTTON) )
{
Drag_MouseMoved (x, y, buttons);
Sys_UpdateWindows (W_XY|W_CAMERA|W_Z);
}
}
vec3_t cull1, cull2;
int cullv1[3], cullv2[3];
void InitCull (void)
{
int i;
VectorSubtract (camera.vpn, camera.vright, cull1);
VectorAdd (camera.vpn, camera.vright, cull2);
for (i=0 ; i<3 ; i++)
{
if (cull1[i] > 0)
cullv1[i] = 3+i;
else
cullv1[i] = i;
if (cull2[i] > 0)
cullv2[i] = 3+i;
else
cullv2[i] = i;
}
}
qboolean CullBrush (brush_t *b)
{
int i;
vec3_t point;
float d;
for (i=0 ; i<3 ; i++)
point[i] = b->mins[cullv1[i]] - camera.origin[i];
d = DotProduct (point, cull1);
if (d < -1)
return true;
for (i=0 ; i<3 ; i++)
point[i] = b->mins[cullv2[i]] - camera.origin[i];
d = DotProduct (point, cull2);
if (d < -1)
return true;
return false;
}
/*
==============
Cam_Draw
==============
*/
void Cam_Draw (void)
{
brush_t *brush;
face_t *face;
float screenaspect;
float yfov;
double start, end;
int i;
if (!active_brushes.next)
return; // not valid yet
if (camera.timing)
start = Sys_DoubleTime ();
//
// clear
//
QE_CheckOpenGLForErrors();
glViewport(0, 0, camera.width, camera.height);
glScissor(0, 0, camera.width, camera.height);
glClearColor (
g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][0],
g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][1],
g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][2],
0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//
// set up viewpoint
//
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
screenaspect = (float)camera.width/camera.height;
yfov = 2*atan((float)camera.height/camera.width)*180/Q_PI;
gluPerspective (yfov, screenaspect, 2, 8192);
glRotatef (-90, 1, 0, 0); // put Z going up
glRotatef (90, 0, 0, 1); // put Z going up
glRotatef (camera.angles[0], 0, 1, 0);
glRotatef (-camera.angles[1], 0, 0, 1);
glTranslatef (-camera.origin[0], -camera.origin[1], -camera.origin[2]);
Cam_BuildMatrix ();
InitCull ();
//
// draw stuff
//
switch (camera.draw_mode)
{
case cd_wire:
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glColor3f(1.0, 1.0, 1.0);
// glEnable (GL_LINE_SMOOTH);
break;
case cd_solid:
glCullFace(GL_FRONT);
glEnable(GL_CULL_FACE);
glShadeModel (GL_FLAT);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glDepthFunc (GL_LEQUAL);
break;
case cd_texture:
glCullFace(GL_FRONT);
glEnable(GL_CULL_FACE);
glShadeModel (GL_FLAT);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glDepthFunc (GL_LEQUAL);
#if 0
{
GLfloat fogColor[4] = {0.0, 1.0, 0.0, 0.25};
glFogi (GL_FOG_MODE, GL_LINEAR);
glHint (GL_FOG_HINT, GL_NICEST); /* per pixel */
glFogf (GL_FOG_START, -8192);
glFogf (GL_FOG_END, 65536);
glFogfv (GL_FOG_COLOR, fogColor);
}
#endif
break;
case cd_blend:
glCullFace(GL_FRONT);
glEnable(GL_CULL_FACE);
glShadeModel (GL_FLAT);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable(GL_DEPTH_TEST);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
}
glMatrixMode(GL_TEXTURE);
for (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)
{
if (CullBrush (brush))
continue;
if (FilterBrush (brush))
continue;
Brush_Draw( brush );
}
glMatrixMode(GL_PROJECTION);
//
// now draw selected brushes
//
glTranslatef (g_qeglobals.d_select_translate[0], g_qeglobals.d_select_translate[1], g_qeglobals.d_select_translate[2]);
glMatrixMode(GL_TEXTURE);
// draw normally
for (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)
{
Brush_Draw( brush );
}
// blend on top
glMatrixMode(GL_PROJECTION);
glColor4f(1.0, 0.0, 0.0, 0.3);
glEnable (GL_BLEND);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable (GL_TEXTURE_2D);
for (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)
for (face=brush->brush_faces ; face ; face=face->next)
Face_Draw( face );
if (selected_face)
Face_Draw(selected_face);
// non-zbuffered outline
glDisable (GL_BLEND);
glDisable (GL_DEPTH_TEST);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
glColor3f (1, 1, 1);
for (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)
for (face=brush->brush_faces ; face ; face=face->next)
Face_Draw( face );
// edge / vertex flags
if (g_qeglobals.d_select_mode == sel_vertex)
{
glPointSize (4);
glColor3f (0,1,0);
glBegin (GL_POINTS);
for (i=0 ; i<g_qeglobals.d_numpoints ; i++)
glVertex3fv (g_qeglobals.d_points[i]);
glEnd ();
glPointSize (1);
}
else if (g_qeglobals.d_select_mode == sel_edge)
{
float *v1, *v2;
glPointSize (4);
glColor3f (0,0,1);
glBegin (GL_POINTS);
for (i=0 ; i<g_qeglobals.d_numedges ; i++)
{
v1 = g_qeglobals.d_points[g_qeglobals.d_edges[i].p1];
v2 = g_qeglobals.d_points[g_qeglobals.d_edges[i].p2];
glVertex3f ( (v1[0]+v2[0])*0.5,(v1[1]+v2[1])*0.5,(v1[2]+v2[2])*0.5);
}
glEnd ();
glPointSize (1);
}
//
// draw pointfile
//
glEnable(GL_DEPTH_TEST);
DrawPathLines ();
if (g_qeglobals.d_pointfile_display_list)
{
Pointfile_Draw();
// glCallList (g_qeglobals.d_pointfile_display_list);
}
// bind back to the default texture so that we don't have problems
// elsewhere using/modifying texture maps between contexts
glBindTexture( GL_TEXTURE_2D, 0 );
glFinish();
QE_CheckOpenGLForErrors();
// Sys_EndWait();
if (camera.timing)
{
end = Sys_DoubleTime ();
Sys_Printf ("Camera: %i ms\n", (int)(1000*(end-start)));
}
}

View file

@ -1,63 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// window system independent camera view code
typedef enum
{
cd_wire,
cd_solid,
cd_texture,
cd_blend
} camera_draw_mode;
typedef struct
{
int width, height;
qboolean timing;
vec3_t origin;
vec3_t angles;
camera_draw_mode draw_mode;
vec3_t color; // background
vec3_t forward, right, up; // move matrix
vec3_t vup, vpn, vright; // view matrix
} camera_t;
extern camera_t camera;
void Cam_Init ();
void Cam_KeyDown (int key);
void Cam_MouseDown (int x, int y, int buttons);
void Cam_MouseUp (int x, int y, int buttons);
void Cam_MouseMoved (int x, int y, int buttons);
void Cam_MouseControl (float dtime);
void Cam_Draw ();
void Cam_HomeView ();
void Cam_ChangeFloor (qboolean up);

View file

@ -1,686 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// cmdlib.c
#include "cmdlib.h"
#define PATHSEPERATOR '/'
char com_token[1024];
qboolean com_eof;
/*
================
I_FloatTime
================
*/
double I_FloatTime (void)
{
time_t t;
time (&t);
return t;
#if 0
// more precise, less portable
struct timeval tp;
struct timezone tzp;
static int secbase;
gettimeofday(&tp, &tzp);
if (!secbase)
{
secbase = tp.tv_sec;
return tp.tv_usec/1000000.0;
}
return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
#endif
}
/*
==============
COM_Parse
Parse a token out of a string
==============
*/
char *COM_Parse (char *data)
{
int c;
int len;
len = 0;
com_token[0] = 0;
if (!data)
return NULL;
// skip whitespace
skipwhite:
while ( (c = *data) <= ' ')
{
if (c == 0)
{
com_eof = true;
return NULL; // end of file;
}
data++;
}
// skip // comments
if (c=='/' && data[1] == '/')
{
while (*data && *data != '\n')
data++;
goto skipwhite;
}
// handle quoted strings specially
if (c == '\"')
{
data++;
do
{
c = *data++;
if (c=='\"')
{
com_token[len] = 0;
return data;
}
com_token[len] = c;
len++;
} while (1);
}
// parse single characters
if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
{
com_token[len] = c;
len++;
com_token[len] = 0;
return data+1;
}
// parse a regular word
do
{
com_token[len] = c;
data++;
len++;
c = *data;
if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
break;
} while (c>32);
com_token[len] = 0;
return data;
}
int Q_strncasecmp (char *s1, char *s2, int n)
{
int c1, c2;
while (1)
{
c1 = *s1++;
c2 = *s2++;
if (!n--)
return 0; // strings are equal until end point
if (c1 != c2)
{
if (c1 >= 'a' && c1 <= 'z')
c1 -= ('a' - 'A');
if (c2 >= 'a' && c2 <= 'z')
c2 -= ('a' - 'A');
if (c1 != c2)
return -1; // strings not equal
}
if (!c1)
return 0; // strings are equal
}
return -1;
}
int Q_strcasecmp (char *s1, char *s2)
{
return Q_strncasecmp (s1, s2, 99999);
}
/*
=============================================================================
MISC FUNCTIONS
=============================================================================
*/
int argc;
char *argv[MAX_NUM_ARGVS];
/*
============
ParseCommandLine
============
*/
void ParseCommandLine (char *lpCmdLine)
{
argc = 1;
argv[0] = "programname";
while (*lpCmdLine && (argc < MAX_NUM_ARGVS))
{
while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
lpCmdLine++;
if (*lpCmdLine)
{
argv[argc] = lpCmdLine;
argc++;
while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
lpCmdLine++;
if (*lpCmdLine)
{
*lpCmdLine = 0;
lpCmdLine++;
}
}
}
}
/*
=================
CheckParm
Checks for the given parameter in the program's command line arguments
Returns the argument number (1 to argc-1) or 0 if not present
=================
*/
int CheckParm (char *check)
{
int i;
for (i = 1;i<argc;i++)
{
if ( !Q_strcasecmp(check, argv[i]) )
return i;
}
return 0;
}
/*
================
Q_filelength
================
*/
int Q_filelength (FILE *f)
{
int pos;
int end;
pos = ftell (f);
fseek (f, 0, SEEK_END);
end = ftell (f);
fseek (f, pos, SEEK_SET);
return end;
}
FILE *SafeOpenWrite (char *filename)
{
FILE *f;
f = fopen(filename, "wb");
if (!f)
Error ("Error opening %s: %s",filename,strerror(errno));
return f;
}
FILE *SafeOpenRead (char *filename)
{
FILE *f;
f = fopen(filename, "rb");
if (!f)
Error ("Error opening %s: %s",filename,strerror(errno));
return f;
}
void SafeRead (FILE *f, void *buffer, int count)
{
if ( (int)fread (buffer, 1, count, f) != count)
Error ("File read failure");
}
void SafeWrite (FILE *f, void *buffer, int count)
{
if ( (int)fwrite (buffer, 1, count, f) != count)
Error ("File read failure");
}
/*
==============
LoadFile
==============
*/
int LoadFile (char *filename, void **bufferptr)
{
FILE *f;
int length;
void *buffer;
extern void *qmalloc( size_t size );
f = fopen (filename, "rb");
if (!f)
{
*bufferptr = NULL;
return -1;
}
length = Q_filelength (f);
buffer = qmalloc (length+1);
((char *)buffer)[length] = 0;
SafeRead (f, buffer, length);
fclose (f);
*bufferptr = buffer;
return length;
}
/*
==============
LoadFileNoCrash
returns -1 length if not present
==============
*/
int LoadFileNoCrash (char *filename, void **bufferptr)
{
FILE *f;
int length;
void *buffer;
f = fopen (filename, "rb");
if (!f)
return -1;
length = Q_filelength (f);
buffer = qmalloc (length+1);
((char *)buffer)[length] = 0;
SafeRead (f, buffer, length);
fclose (f);
*bufferptr = buffer;
return length;
}
/*
==============
SaveFile
==============
*/
void SaveFile (char *filename, void *buffer, int count)
{
FILE *f;
f = SafeOpenWrite (filename);
SafeWrite (f, buffer, count);
fclose (f);
}
void DefaultExtension (char *path, char *extension)
{
char *src;
//
// if path doesn't have a .EXT, append extension
// (extension should include the .)
//
src = path + strlen(path) - 1;
while (*src != PATHSEPERATOR && src != path)
{
if (*src == '.')
return; // it has an extension
src--;
}
strcat (path, extension);
}
void DefaultPath (char *path, char *basepath)
{
char temp[128];
if (path[0] == PATHSEPERATOR)
return; // absolute path location
strcpy (temp,path);
strcpy (path,basepath);
strcat (path,temp);
}
void StripFilename (char *path)
{
int length;
length = strlen(path)-1;
while (length > 0 && path[length] != PATHSEPERATOR)
length--;
path[length] = 0;
}
void StripExtension (char *path)
{
int length;
length = strlen(path)-1;
while (length > 0 && path[length] != '.')
{
length--;
if (path[length] == '/')
return; // no extension
}
if (length)
path[length] = 0;
}
/*
====================
Extract file parts
====================
*/
void ExtractFilePath (char *path, char *dest)
{
char *src;
src = path + strlen(path) - 1;
//
// back up until a \ or the start
//
while (src != path && *(src-1) != PATHSEPERATOR)
src--;
memcpy (dest, path, src-path);
dest[src-path] = 0;
}
void ExtractFileName (char *path, char *dest)
{
char *src;
src = path + strlen(path) - 1;
//
// back up until a \ or the start
//
while (src != path && *(src-1) != '/'
&& *(src-1) != '\\' )
src--;
while (*src)
{
*dest++ = *src++;
}
*dest = 0;
}
void ExtractFileBase (char *path, char *dest)
{
char *src;
src = path + strlen(path) - 1;
//
// back up until a \ or the start
//
while (src != path && *(src-1) != '/'
&& *(src-1) != '\\' )
src--;
while (*src && *src != '.')
{
*dest++ = *src++;
}
*dest = 0;
}
void ExtractFileExtension (char *path, char *dest)
{
char *src;
src = path + strlen(path) - 1;
//
// back up until a . or the start
//
while (src != path && *(src-1) != '.')
src--;
if (src == path)
{
*dest = 0; // no extension
return;
}
strcpy (dest,src);
}
/*
==============
ParseNum / ParseHex
==============
*/
int ParseHex (char *hex)
{
char *str;
int num;
num = 0;
str = hex;
while (*str)
{
num <<= 4;
if (*str >= '0' && *str <= '9')
num += *str-'0';
else if (*str >= 'a' && *str <= 'f')
num += 10 + *str-'a';
else if (*str >= 'A' && *str <= 'F')
num += 10 + *str-'A';
else
Error ("Bad hex number: %s",hex);
str++;
}
return num;
}
int ParseNum (char *str)
{
if (str[0] == '$')
return ParseHex (str+1);
if (str[0] == '0' && str[1] == 'x')
return ParseHex (str+2);
return atol (str);
}
/*
============================================================================
BYTE ORDER FUNCTIONS
============================================================================
*/
#ifdef _SGI_SOURCE
#define __BIG_ENDIAN__
#endif
#ifdef __BIG_ENDIAN__
short LittleShort (short l)
{
byte b1,b2;
b1 = l&255;
b2 = (l>>8)&255;
return (b1<<8) + b2;
}
short BigShort (short l)
{
return l;
}
int LittleLong (int l)
{
byte b1,b2,b3,b4;
b1 = l&255;
b2 = (l>>8)&255;
b3 = (l>>16)&255;
b4 = (l>>24)&255;
return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
}
int BigLong (int l)
{
return l;
}
float LittleFloat (float l)
{
union {byte b[4]; float f;} in, out;
in.f = l;
out.b[0] = in.b[3];
out.b[1] = in.b[2];
out.b[2] = in.b[1];
out.b[3] = in.b[0];
return out.f;
}
float BigFloat (float l)
{
return l;
}
#else
short BigShort (short l)
{
byte b1,b2;
b1 = l&255;
b2 = (l>>8)&255;
return (b1<<8) + b2;
}
short LittleShort (short l)
{
return l;
}
int BigLong (int l)
{
byte b1,b2,b3,b4;
b1 = l&255;
b2 = (l>>8)&255;
b3 = (l>>16)&255;
b4 = (l>>24)&255;
return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
}
int LittleLong (int l)
{
return l;
}
float BigFloat (float l)
{
union {byte b[4]; float f;} in, out;
in.f = l;
out.b[0] = in.b[3];
out.b[1] = in.b[2];
out.b[2] = in.b[1];
out.b[3] = in.b[0];
return out.f;
}
float LittleFloat (float l)
{
return l;
}
#endif

View file

@ -1,99 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// cmdlib.h
#ifndef __CMDLIB__
#define __CMDLIB__
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <stdarg.h>
#ifndef __BYTEBOOL__
#define __BYTEBOOL__
typedef enum {false, true} qboolean;
typedef unsigned char byte;
#endif
// the dec offsetof macro doesn't work very well...
#define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
// set these before calling CheckParm
extern int myargc;
extern char **myargv;
int Q_strncasecmp (char *s1, char *s2, int n);
int Q_strcasecmp (char *s1, char *s2);
int Q_filelength (FILE *f);
double I_FloatTime (void);
void Error (char *error, ...);
int CheckParm (char *check);
void ParseCommandLine (char *lpCmdLine);
FILE *SafeOpenWrite (char *filename);
FILE *SafeOpenRead (char *filename);
void SafeRead (FILE *f, void *buffer, int count);
void SafeWrite (FILE *f, void *buffer, int count);
int LoadFile (char *filename, void **bufferptr);
int LoadFileNoCrash (char *filename, void **bufferptr);
void SaveFile (char *filename, void *buffer, int count);
void DefaultExtension (char *path, char *extension);
void DefaultPath (char *path, char *basepath);
void StripFilename (char *path);
void StripExtension (char *path);
void ExtractFilePath (char *path, char *dest);
void ExtractFileName (char *path, char *dest);
void ExtractFileBase (char *path, char *dest);
void ExtractFileExtension (char *path, char *dest);
int ParseNum (char *str);
short BigShort (short l);
short LittleShort (short l);
int BigLong (int l);
int LittleLong (int l);
float BigFloat (float l);
float LittleFloat (float l);
char *COM_Parse (char *data);
extern char com_token[1024];
extern qboolean com_eof;
#define MAX_NUM_ARGVS 32
extern int argc;
extern char *argv[MAX_NUM_ARGVS];
#endif

168
qe4/csg.c
View file

@ -1,168 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
/*
==============
CSG_SplitBrushByFace
The incoming brush is NOT freed.
The incoming face is NOT left referenced.
==============
*/
void CSG_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back)
{
brush_t *b;
face_t *nf;
vec3_t temp;
b = Brush_Clone (in);
nf = Face_Clone (f);
nf->texdef = b->brush_faces->texdef;
nf->next = b->brush_faces;
b->brush_faces = nf;
Brush_Build( b );
Brush_RemoveEmptyFaces ( b );
if ( !b->brush_faces )
{ // completely clipped away
Brush_Free (b);
*back = NULL;
}
else
{
Entity_LinkBrush (in->owner, b);
*back = b;
}
b = Brush_Clone (in);
nf = Face_Clone (f);
// swap the plane winding
VectorCopy (nf->planepts[0], temp);
VectorCopy (nf->planepts[1], nf->planepts[0]);
VectorCopy (temp, nf->planepts[1]);
nf->texdef = b->brush_faces->texdef;
nf->next = b->brush_faces;
b->brush_faces = nf;
Brush_Build( b );
Brush_RemoveEmptyFaces ( b );
if ( !b->brush_faces )
{ // completely clipped away
Brush_Free (b);
*front = NULL;
}
else
{
Entity_LinkBrush (in->owner, b);
*front = b;
}
}
/*
=============
CSG_MakeHollow
=============
*/
void CSG_MakeHollow (void)
{
brush_t *b, *front, *back, *next;
face_t *f;
face_t split;
vec3_t move;
int i;
for (b = selected_brushes.next ; b != &selected_brushes ; b=next)
{
next = b->next;
for (f = b->brush_faces ; f ; f=f->next)
{
split = *f;
VectorScale (f->plane.normal, g_qeglobals.d_gridsize, move);
for (i=0 ; i<3 ; i++)
VectorSubtract (split.planepts[i], move, split.planepts[i]);
CSG_SplitBrushByFace (b, &split, &front, &back);
if (back)
Brush_Free (back);
if (front)
Brush_AddToList (front, &selected_brushes);
}
Brush_Free (b);
}
Sys_UpdateWindows (W_ALL);
}
/*
=============
CSG_Subtract
=============
*/
void CSG_Subtract (void)
{
brush_t *b, *s, *frag, *front, *back, *next, *snext;
face_t *f;
int i;
Sys_Printf ("Subtracting...\n");
for (b = selected_brushes.next ; b != &selected_brushes ; b=next)
{
next = b->next;
if (b->owner->eclass->fixedsize)
continue; // can't use texture from a fixed entity, so don't subtract
for (s=active_brushes.next ; s != &active_brushes ; s=snext)
{
snext = s->next;
if (s->owner->eclass->fixedsize)
continue;
for (i=0 ; i<3 ; i++)
if (b->mins[i] >= s->maxs[i] - ON_EPSILON
|| b->maxs[i] <= s->mins[i] + ON_EPSILON)
break;
if (i != 3)
continue; // definately don't touch
frag = s;
for (f = b->brush_faces ; f && frag ; f=f->next)
{
CSG_SplitBrushByFace (frag, f, &front, &back);
Brush_Free (frag);
frag = back;
if (front)
Brush_AddToList (front, &active_brushes);
}
if (frag)
Brush_Free (frag);
}
}
Sys_Printf ("done.\n");
Sys_UpdateWindows (W_ALL);
}

View file

@ -1,457 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
/*
drag either multiple brushes, or select plane points from
a single brush.
*/
qboolean drag_ok;
vec3_t drag_xvec;
vec3_t drag_yvec;
static int buttonstate;
static int pressx, pressy;
static vec3_t pressdelta;
static int buttonx, buttony;
//int num_move_points;
//float *move_points[1024];
int lastx, lasty;
qboolean drag_first;
void AxializeVector (vec3_t v)
{
vec3_t a;
float o;
int i;
if (!v[0] && !v[1])
return;
if (!v[1] && !v[2])
return;
if (!v[0] && !v[2])
return;
for (i=0 ; i<3 ; i++)
a[i] = fabs(v[i]);
if (a[0] > a[1] && a[0] > a[2])
i = 0;
else if (a[1] > a[0] && a[1] > a[2])
i = 1;
else
i = 2;
o = v[i];
VectorCopy (vec3_origin, v);
if (o<0)
v[i] = -1;
else
v[i] = 1;
}
/*
===========
Drag_Setup
===========
*/
void Drag_Setup (int x, int y, int buttons,
vec3_t xaxis, vec3_t yaxis,
vec3_t origin, vec3_t dir)
{
trace_t t;
face_t *f;
if (selected_brushes.next == &selected_brushes)
{
Sys_Status("No selection to drag\n", 0);
return;
}
drag_first = true;
g_qeglobals.d_num_move_points = 0;
VectorCopy (vec3_origin, pressdelta);
pressx = x;
pressy = y;
VectorCopy (xaxis, drag_xvec);
AxializeVector (drag_xvec);
VectorCopy (yaxis, drag_yvec);
AxializeVector (drag_yvec);
if (g_qeglobals.d_select_mode == sel_vertex)
{
SelectVertexByRay (origin, dir);
if (g_qeglobals.d_num_move_points)
{
drag_ok = true;
return;
}
}
if (g_qeglobals.d_select_mode == sel_edge)
{
SelectEdgeByRay (origin, dir);
if (g_qeglobals.d_num_move_points)
{
drag_ok = true;
return;
}
}
//
// check for direct hit first
//
t = Test_Ray (origin, dir, true);
if (t.selected)
{
drag_ok = true;
if (buttons == (MK_LBUTTON|MK_CONTROL) )
{
Sys_Printf ("Shear dragging face\n");
Brush_SelectFaceForDragging (t.brush, t.face, true);
}
else if (buttons == (MK_LBUTTON|MK_CONTROL|MK_SHIFT) )
{
Sys_Printf ("Sticky dragging brush\n");
for (f=t.brush->brush_faces ; f ; f=f->next)
Brush_SelectFaceForDragging (t.brush, f, false);
}
else
Sys_Printf ("Dragging entire selection\n");
return;
}
if (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_edge)
return;
//
// check for side hit
//
if (selected_brushes.next->next != &selected_brushes)
{
Sys_Printf ("Click isn't inside multiple selection\n");
return;
}
if (selected_brushes.next->owner->eclass->fixedsize)
{
Sys_Printf ("Can't stretch fixed size entities\n");
return;
}
if (buttons & MK_CONTROL)
Brush_SideSelect (selected_brushes.next, origin, dir, true);
else
Brush_SideSelect (selected_brushes.next, origin, dir, false);
Sys_Printf ("Side stretch\n");
drag_ok = true;
}
entity_t *peLink;
void UpdateTarget(vec3_t origin, vec3_t dir)
{
trace_t t;
entity_t *pe;
int i;
char sz[128];
t = Test_Ray (origin, dir, 0);
if (!t.brush)
return;
pe = t.brush->owner;
if (pe == NULL)
return;
// is this the first?
if (peLink != NULL)
{
// Get the target id from out current target
// if there is no id, make one
i = IntForKey(pe, "target");
if (i <= 0)
{
i = GetUniqueTargetId(1);
sprintf(sz, "%d", i);
SetKeyValue(pe, "target", sz);
}
// set the target # into our src
sprintf(sz, "%d", i);
SetKeyValue(peLink, "targetname", sz);
Sys_UpdateWindows(W_ENTITY);
}
// promote the target to the src
peLink = pe;
}
/*
===========
Drag_Begin
===========
*/
void Drag_Begin (int x, int y, int buttons,
vec3_t xaxis, vec3_t yaxis,
vec3_t origin, vec3_t dir)
{
trace_t t;
drag_ok = false;
VectorCopy (vec3_origin, pressdelta);
drag_first = true;
peLink = NULL;
// shift LBUTTON = select entire brush
if (buttons == (MK_LBUTTON | MK_SHIFT))
{
if (!dir[0] && !dir[1])
Select_Ray (origin, dir, SF_ENTITIES_FIRST); // hack for XY
else
Select_Ray (origin, dir, 0);
return;
}
// ctrl-shift LBUTTON = select single face
if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT))
{
Select_Deselect ();
Select_Ray (origin, dir, SF_SINGLEFACE);
return;
}
// LBUTTON + all other modifiers = manipulate selection
if (buttons & MK_LBUTTON)
{
Drag_Setup (x, y, buttons, xaxis, yaxis, origin, dir);
return;
}
// middle button = grab texture
if (buttons == MK_MBUTTON)
{
t = Test_Ray (origin, dir, false);
if (t.face)
{
g_qeglobals.d_new_brush_bottom_z = t.brush->mins[2];
g_qeglobals.d_new_brush_top_z = t.brush->maxs[2];
Texture_SetTexture (&t.face->texdef);
}
else
Sys_Printf ("Did not select a texture\n");
return;
}
// ctrl-middle button = set entire brush to texture
if (buttons == (MK_MBUTTON|MK_CONTROL) )
{
t = Test_Ray (origin, dir, false);
if (t.brush)
{
if (t.brush->brush_faces->texdef.name[0] == '(')
Sys_Printf ("Can't change an entity texture\n");
else
{
Brush_SetTexture (t.brush, &g_qeglobals.d_texturewin.texdef);
Sys_UpdateWindows (W_ALL);
}
}
else
Sys_Printf ("Didn't hit a btrush\n");
return;
}
// ctrl-shift-middle button = set single face to texture
if (buttons == (MK_MBUTTON|MK_SHIFT|MK_CONTROL) )
{
t = Test_Ray (origin, dir, false);
if (t.brush)
{
if (t.brush->brush_faces->texdef.name[0] == '(')
Sys_Printf ("Can't change an entity texture\n");
else
{
t.face->texdef = g_qeglobals.d_texturewin.texdef;
Brush_Build( t.brush );
Sys_UpdateWindows (W_ALL);
}
}
else
Sys_Printf ("Didn't hit a btrush\n");
return;
}
}
/*
===========
MoveSelection
===========
*/
void MoveSelection (vec3_t move)
{
int i;
brush_t *b;
if (!move[0] && !move[1] && !move[2])
return;
Sys_UpdateWindows (W_XY|W_CAMERA);
//
// dragging only a part of the selection
//
if (g_qeglobals.d_num_move_points)
{
for (i=0 ; i<g_qeglobals.d_num_move_points ; i++)
VectorAdd (g_qeglobals.d_move_points[i], move, g_qeglobals.d_move_points[i]);
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
{
Brush_Build( b );
for (i=0 ; i<3 ; i++)
if (b->mins[i] > b->maxs[i]
|| b->maxs[i] - b->mins[i] > 4096)
break; // dragged backwards or fucked up
if (i != 3)
break;
}
// if any of the brushes were crushed out of existance
// calcel the entire move
if (b != &selected_brushes)
{
Sys_Printf ("Brush dragged backwards, move canceled\n");
for (i=0 ; i<g_qeglobals.d_num_move_points ; i++)
VectorSubtract (g_qeglobals.d_move_points[i], move, g_qeglobals.d_move_points[i]);
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
Brush_Build( b );
}
}
else
{
//
// if there are lots of brushes selected, just translate instead
// of rebuilding the brushes
//
if (drag_yvec[2] == 0 && selected_brushes.next->next != &selected_brushes)
{
VectorAdd (g_qeglobals.d_select_translate, move, g_qeglobals.d_select_translate);
}
else
{
Select_Move (move);
}
}
}
/*
===========
Drag_MouseMoved
===========
*/
void Drag_MouseMoved (int x, int y, int buttons)
{
vec3_t move, delta;
int i;
char movestring[128];
if (!buttons)
{
drag_ok = false;
return;
}
if (!drag_ok)
return;
// clear along one axis
if (buttons & MK_SHIFT)
{
drag_first = false;
if (abs(x-pressx) > abs(y-pressy))
y = pressy;
else
x = pressx;
}
for (i=0 ; i<3 ; i++)
{
move[i] = drag_xvec[i]*(x - pressx)
+ drag_yvec[i]*(y - pressy);
move[i] = floor(move[i]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;
}
sprintf (movestring, "drag (%i %i %i)", (int)move[0], (int)move[1], (int)move[2]);
Sys_Status (movestring, 0);
VectorSubtract (move, pressdelta, delta);
MoveSelection (delta);
VectorCopy (move, pressdelta);
}
/*
===========
Drag_MouseUp
===========
*/
void Drag_MouseUp (void)
{
Sys_Status ("drag completed.", 0);
if (g_qeglobals.d_select_translate[0] || g_qeglobals.d_select_translate[1] || g_qeglobals.d_select_translate[2])
{
Select_Move (g_qeglobals.d_select_translate);
VectorCopy (vec3_origin, g_qeglobals.d_select_translate);
Sys_UpdateWindows (W_CAMERA);
}
}

View file

@ -1,281 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
#include "io.h"
eclass_t *eclass;
eclass_t *eclass_bad;
char eclass_directory[1024];
/*
the classname, color triple, and bounding box are parsed out of comments
A ? size means take the exact brush size.
/*QUAKED <classname> (0 0 0) ?
/*QUAKED <classname> (0 0 0) (-8 -8 -8) (8 8 8)
Flag names can follow the size description:
/*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY
*/
char *debugname;
eclass_t *Eclass_InitFromText (char *text)
{
char *t;
int len;
int r, i;
char parms[256], *p;
eclass_t *e;
char color[128];
e = qmalloc(sizeof(*e));
memset (e, 0, sizeof(*e));
text += strlen("/*QUAKED ");
// grab the name
text = COM_Parse (text);
e->name = qmalloc (strlen(com_token)+1);
strcpy (e->name, com_token);
debugname = e->name;
// grab the color, reformat as texture name
r = sscanf (text," (%f %f %f)", &e->color[0], &e->color[1], &e->color[2]);
if (r != 3)
return e;
sprintf (color, "(%f %f %f)", e->color[0], e->color[1], e->color[2]);
strcpy (e->texdef.name, color);
while (*text != ')')
{
if (!*text)
return e;
text++;
}
text++;
// get the size
text = COM_Parse (text);
if (com_token[0] == '(')
{ // parse the size as two vectors
e->fixedsize = true;
r = sscanf (text,"%f %f %f) (%f %f %f)", &e->mins[0], &e->mins[1], &e->mins[2],
&e->maxs[0], &e->maxs[1], &e->maxs[2]);
if (r != 6)
return e;
for (i=0 ; i<2 ; i++)
{
while (*text != ')')
{
if (!*text)
return e;
text++;
}
text++;
}
}
else
{ // use the brushes
}
// get the flags
// copy to the first /n
p = parms;
while (*text && *text != '\n')
*p++ = *text++;
*p = 0;
text++;
// any remaining words are parm flags
p = parms;
for (i=0 ; i<8 ; i++)
{
p = COM_Parse (p);
if (!p)
break;
strcpy (e->flagnames[i], com_token);
}
// find the length until close comment
for (t=text ; t[0] && !(t[0]=='*' && t[1]=='/') ; t++)
;
// copy the comment block out
len = t-text;
e->comments = qmalloc (len+1);
memcpy (e->comments, text, len);
#if 0
for (i=0 ; i<len ; i++)
if (text[i] == '\n')
e->comments[i] = '\r';
else
e->comments[i] = text[i];
#endif
e->comments[len] = 0;
return e;
}
/*
=================
Eclass_InsertAlphabetized
=================
*/
void Eclass_InsertAlphabetized (eclass_t *e)
{
eclass_t *s;
if (!eclass)
{
eclass = e;
return;
}
s = eclass;
if (stricmp (e->name, s->name) < 0)
{
e->next = s;
eclass = e;
return;
}
do
{
if (!s->next || stricmp (e->name, s->next->name) < 0)
{
e->next = s->next;
s->next = e;
return;
}
s=s->next;
} while (1);
}
/*
=================
Eclass_ScanFile
=================
*/
void Eclass_ScanFile (char *filename)
{
int size;
char *data;
eclass_t *e;
int i;
char temp[1024];
QE_ConvertDOSToUnixName( temp, filename );
Sys_Printf ("ScanFile: %s\n", temp);
size = LoadFile (filename, (void *)&data);
for (i=0 ; i<size ; i++)
if (!strncmp(data+i, "/*QUAKED",8))
{
e = Eclass_InitFromText (data+i);
if (e)
Eclass_InsertAlphabetized (e);
else
printf ("Error parsing: %s in %s\n",debugname, filename);
}
free (data);
}
void Eclass_InitForSourceDirectory (char *path)
{
struct _finddata_t fileinfo;
int handle;
char filename[1024];
char filebase[1024];
char temp[1024];
char *s;
QE_ConvertDOSToUnixName( temp, path );
Sys_Printf ("Eclass_InitForSourceDirectory: %s\n", temp );
strcpy (filebase, path);
s = filebase + strlen(filebase)-1;
while (*s != '\\' && *s != '/' && s!=filebase)
s--;
*s = 0;
eclass = NULL;
handle = _findfirst (path, &fileinfo);
if (handle != -1)
{
do
{
sprintf (filename, "%s\\%s", filebase, fileinfo.name);
Eclass_ScanFile (filename);
} while (_findnext( handle, &fileinfo ) != -1);
_findclose (handle);
}
eclass_bad = Eclass_InitFromText ("/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?");
}
eclass_t *Eclass_ForName (char *name, qboolean has_brushes)
{
eclass_t *e;
char init[1024];
if (!name)
return eclass_bad;
for (e=eclass ; e ; e=e->next)
if (!strcmp (name, e->name))
return e;
// create a new class for it
if (has_brushes)
{
sprintf (init, "/*QUAKED %s (0 0.5 0) ?\nNot found in source.\n", name);
e = Eclass_InitFromText (init);
}
else
{
sprintf (init, "/*QUAKED %s (0 0.5 0) (-8 -8 -8) (8 8 8)\nNot found in source.\n", name);
e = Eclass_InitFromText (init);
}
Eclass_InsertAlphabetized (e);
return e;
}

View file

@ -1,538 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
char *ValueForKey (entity_t *ent, char *key)
{
epair_t *ep;
for (ep=ent->epairs ; ep ; ep=ep->next)
if (!strcmp (ep->key, key) )
return ep->value;
return "";
}
void SetKeyValue (entity_t *ent, char *key, char *value)
{
epair_t *ep;
if (ent == NULL)
return;
if (!key || !key[0])
return;
for (ep=ent->epairs ; ep ; ep=ep->next)
if (!strcmp (ep->key, key) )
{
free (ep->value);
ep->value = qmalloc(strlen(value)+1);
strcpy (ep->value, value);
return;
}
ep = qmalloc (sizeof(*ep));
ep->next = ent->epairs;
ent->epairs = ep;
ep->key = qmalloc(strlen(key)+1);
strcpy (ep->key, key);
ep->value = qmalloc(strlen(value)+1);
strcpy (ep->value, value);
}
void DeleteKey (entity_t *ent, char *key)
{
epair_t **ep, *next;
ep = &ent->epairs;
while (*ep)
{
next = *ep;
if ( !strcmp (next->key, key) )
{
*ep = next->next;
free(next->key);
free(next->value);
free(next);
return;
}
ep = &next->next;
}
}
float FloatForKey (entity_t *ent, char *key)
{
char *k;
k = ValueForKey (ent, key);
return atof(k);
}
int IntForKey (entity_t *ent, char *key)
{
char *k;
k = ValueForKey (ent, key);
return atoi(k);
}
void GetVectorForKey (entity_t *ent, char *key, vec3_t vec)
{
char *k;
k = ValueForKey (ent, key);
sscanf (k, "%f %f %f", &vec[0], &vec[1], &vec[2]);
}
/*
===============
Entity_Free
Frees the entity and any brushes is has.
The entity is removed from the global entities list.
===============
*/
void Entity_Free (entity_t *e)
{
epair_t *ep, *next;
while (e->brushes.onext != &e->brushes)
Brush_Free (e->brushes.onext);
if (e->next)
{
e->next->prev = e->prev;
e->prev->next = e->next;
}
for (ep = e->epairs ; ep ; ep=next)
{
next = ep->next;
free (ep);
}
free (e);
}
/*
=================
ParseEpair
=================
*/
epair_t *ParseEpair (void)
{
epair_t *e;
e = qmalloc (sizeof(*e));
e->key = qmalloc(strlen(token)+1);
strcpy (e->key, token);
GetToken (false);
e->value = qmalloc(strlen(token)+1);
strcpy (e->value, token);
return e;
}
/*
================
Entity_Parse
If onlypairs is set, the classname info will not
be looked up, and the entity will not be added
to the global list. Used for parsing the project.
================
*/
entity_t *Entity_Parse (qboolean onlypairs)
{
entity_t *ent;
eclass_t *e;
brush_t *b;
vec3_t mins, maxs;
epair_t *ep;
qboolean has_brushes;
if (!GetToken (true))
return NULL;
if (strcmp (token, "{") )
Error ("ParseEntity: { not found");
ent = qmalloc (sizeof(*ent));
ent->brushes.onext = ent->brushes.oprev = &ent->brushes;
do
{
if (!GetToken (true))
Error ("ParseEntity: EOF without closing brace");
if (!strcmp (token, "}") )
break;
if (!strcmp (token, "{") )
{
b = Brush_Parse ();
b->owner = ent;
// add to the end of the entity chain
b->onext = &ent->brushes;
b->oprev = ent->brushes.oprev;
ent->brushes.oprev->onext = b;
ent->brushes.oprev = b;
}
else
{
ep = ParseEpair ();
ep->next = ent->epairs;
ent->epairs = ep;
}
} while (1);
if (onlypairs)
return ent;
if (ent->brushes.onext == &ent->brushes)
has_brushes = false;
else
has_brushes = true;
GetVectorForKey (ent, "origin", ent->origin);
e = Eclass_ForName (ValueForKey (ent, "classname"), has_brushes);
ent->eclass = e;
if (e->fixedsize)
{ // fixed size entity
if (ent->brushes.onext != &ent->brushes)
{
printf ("Warning: Fixed size entity with brushes\n");
#if 0
while (ent->brushes.onext != &ent->brushes)
{ // FIXME: this will free the entity and crash!
Brush_Free (b);
}
#endif
ent->brushes.next = ent->brushes.prev = &ent->brushes;
}
// create a custom brush
VectorAdd (e->mins, ent->origin, mins);
VectorAdd (e->maxs, ent->origin, maxs);
b = Brush_Create (mins, maxs, &e->texdef);
b->owner = ent;
b->onext = ent->brushes.onext;
b->oprev = &ent->brushes;
ent->brushes.onext->oprev = b;
ent->brushes.onext = b;
}
else
{ // brush entity
if (ent->brushes.next == &ent->brushes)
printf ("Warning: Brush entity with no brushes\n");
}
// add all the brushes to the main list
for (b=ent->brushes.onext ; b != &ent->brushes ; b=b->onext)
{
b->next = active_brushes.next;
active_brushes.next->prev = b;
b->prev = &active_brushes;
active_brushes.next = b;
}
return ent;
}
/*
============
Entity_Write
============
*/
void Entity_Write (entity_t *e, FILE *f, qboolean use_region)
{
epair_t *ep;
brush_t *b;
vec3_t origin;
char text[128];
int count;
// if none of the entities brushes are in the region,
// don't write the entity at all
if (use_region)
{
// in region mode, save the camera position as playerstart
if ( !strcmp(ValueForKey (e, "classname"), "info_player_start") )
{
fprintf (f, "{\n");
fprintf (f, "\"classname\" \"info_player_start\"\n");
fprintf (f, "\"origin\" \"%i %i %i\"\n", (int)camera.origin[0],
(int)camera.origin[1], (int)camera.origin[2]);
fprintf (f, "\"angle\" \"%i\"\n", (int)camera.angles[YAW]);
fprintf (f, "}\n");
return;
}
for (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)
if (!Map_IsBrushFiltered(b))
break; // got one
if (b == &e->brushes)
return; // nothing visible
}
// if fixedsize, calculate a new origin based on the current
// brush position
if (e->eclass->fixedsize)
{
VectorSubtract (e->brushes.onext->mins, e->eclass->mins, origin);
sprintf (text, "%i %i %i", (int)origin[0],
(int)origin[1], (int)origin[2]);
SetKeyValue (e, "origin", text);
}
fprintf (f, "{\n");
for (ep = e->epairs ; ep ; ep=ep->next)
fprintf (f, "\"%s\" \"%s\"\n", ep->key, ep->value);
if (!e->eclass->fixedsize)
{
count = 0;
for (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)
{
if (!use_region || !Map_IsBrushFiltered (b))
{
fprintf (f, "// brush %i\n", count);
count++;
Brush_Write (b, f);
}
}
}
fprintf (f, "}\n");
}
/*
============
Entity_Create
Creates a new entity out of the selected_brushes list.
If the entity class is fixed size, the brushes are only
used to find a midpoint. Otherwise, the brushes have
their ownershi[ transfered to the new entity.
============
*/
entity_t *Entity_Create (eclass_t *c)
{
entity_t *e;
brush_t *b;
vec3_t mins, maxs;
int i;
// check to make sure the brushes are ok
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
if (b->owner != world_entity)
{
Sys_Printf ("Entity NOT created, brushes not all from world\n");
Sys_Beep ();
return NULL;
}
// create it
e = qmalloc(sizeof(*e));
e->brushes.onext = e->brushes.oprev = &e->brushes;
e->eclass = c;
SetKeyValue (e, "classname", c->name);
// add the entity to the entity list
e->next = entities.next;
entities.next = e;
e->next->prev = e;
e->prev = &entities;
if (c->fixedsize)
{
//
// just use the selection for positioning
//
b = selected_brushes.next;
for (i=0 ; i<3 ; i++)
e->origin[i] = b->mins[i] - c->mins[i];
// create a custom brush
VectorAdd (c->mins, e->origin, mins);
VectorAdd (c->maxs, e->origin, maxs);
b = Brush_Create (mins, maxs, &c->texdef);
Entity_LinkBrush (e, b);
// delete the current selection
Select_Delete ();
// select the new brush
b->next = b->prev = &selected_brushes;
selected_brushes.next = selected_brushes.prev = b;
Brush_Build( b );
}
else
{
//
// change the selected brushes over to the new entity
//
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
{
Entity_UnlinkBrush (b);
Entity_LinkBrush (e, b);
Brush_Build( b ); // so the key brush gets a name
}
}
Sys_UpdateWindows (W_ALL);
return e;
}
/*
===========
Entity_LinkBrush
===========
*/
void Entity_LinkBrush (entity_t *e, brush_t *b)
{
if (b->oprev || b->onext)
Error ("Entity_LinkBrush: Allready linked");
b->owner = e;
b->onext = e->brushes.onext;
b->oprev = &e->brushes;
e->brushes.onext->oprev = b;
e->brushes.onext = b;
}
/*
===========
Entity_UnlinkBrush
===========
*/
void Entity_UnlinkBrush (brush_t *b)
{
if (!b->owner || !b->onext || !b->oprev)
Error ("Entity_UnlinkBrush: Not currently linked");
b->onext->oprev = b->oprev;
b->oprev->onext = b->onext;
b->onext = b->oprev = NULL;
b->owner = NULL;
}
/*
===========
Entity_Clone
===========
*/
entity_t *Entity_Clone (entity_t *e)
{
entity_t *n;
epair_t *ep, *np;
n = qmalloc(sizeof(*n));
n->brushes.onext = n->brushes.oprev = &n->brushes;
n->eclass = e->eclass;
// add the entity to the entity list
n->next = entities.next;
entities.next = n;
n->next->prev = n;
n->prev = &entities;
for (ep = e->epairs ; ep ; ep=ep->next)
{
np = qmalloc(sizeof(*np));
np->key = copystring(ep->key);
np->value = copystring(ep->value);
np->next = n->epairs;
n->epairs = np;
}
return n;
}
int GetUniqueTargetId(int iHint)
{
int iMin, iMax, i;
BOOL fFound;
entity_t *pe;
fFound = FALSE;
pe = entities.next;
iMin = 0;
iMax = 0;
for (; pe != NULL && pe != &entities ; pe = pe->next)
{
i = IntForKey(pe, "target");
if (i)
{
iMin = min(i, iMin);
iMax = max(i, iMax);
if (i == iHint)
fFound = TRUE;
}
}
if (fFound)
return iMax + 1;
else
return iHint;
}
entity_t *FindEntity(char *pszKey, char *pszValue)
{
entity_t *pe;
pe = entities.next;
for (; pe != NULL && pe != &entities ; pe = pe->next)
{
if (!strcmp(ValueForKey(pe, pszKey), pszValue))
return pe;
}
return NULL;
}
entity_t *FindEntityInt(char *pszKey, int iValue)
{
entity_t *pe;
pe = entities.next;
for (; pe != NULL && pe != &entities ; pe = pe->next)
{
if (IntForKey(pe, pszKey) == iValue)
return pe;
}
return NULL;
}

View file

@ -1,84 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// entity.h
#define MAX_FLAGS 8
typedef struct eclass_s
{
struct eclass_s *next;
char *name;
qboolean fixedsize;
qboolean unknown; // wasn't found in source
vec3_t mins, maxs;
vec3_t color;
texdef_t texdef;
char *comments;
char flagnames[MAX_FLAGS][32];
} eclass_t;
extern eclass_t *eclass;
void Eclass_InitForSourceDirectory (char *path);
eclass_t *Eclass_ForName (char *name, qboolean has_brushes);
//===================================================
typedef struct epair_s
{
struct epair_s *next;
char *key;
char *value;
} epair_t;
typedef struct entity_s
{
struct entity_s *prev, *next;
brush_t brushes; // head/tail of list
vec3_t origin;
eclass_t *eclass;
epair_t *epairs;
} entity_t;
char *ValueForKey (entity_t *ent, char *key);
void SetKeyValue (entity_t *ent, char *key, char *value);
void DeleteKey (entity_t *ent, char *key);
float FloatForKey (entity_t *ent, char *key);
int IntForKey (entity_t *ent, char *key);
void GetVectorForKey (entity_t *ent, char *key, vec3_t vec);
void Entity_Free (entity_t *e);
entity_t *Entity_Parse (qboolean onlypairs);
void Entity_Write (entity_t *e, FILE *f, qboolean use_region);
entity_t *Entity_Create (eclass_t *c);
entity_t *Entity_Clone (entity_t *e);
void Entity_LinkBrush (entity_t *e, brush_t *b);
void Entity_UnlinkBrush (brush_t *b);
entity_t *FindEntity(char *pszKey, char *pszValue);
entity_t *FindEntityInt(char *pszKey, int iValue);
int GetUniqueTargetId(int iHint);

View file

@ -1,66 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// entity.h
#define DlgXBorder 5
#define DlgYBorder 5
#define EntList 0
#define EntComment 1
#define EntCheck1 2
#define EntCheck2 3
#define EntCheck3 4
#define EntCheck4 5
#define EntCheck5 6
#define EntCheck6 7
#define EntCheck7 8
#define EntCheck8 9
#define EntCheck9 10
#define EntCheck10 11
#define EntCheck11 12
#define EntCheck12 13
#define EntProps 14
#define EntDir0 15
#define EntDir45 16
#define EntDir90 17
#define EntDir135 18
#define EntDir180 19
#define EntDir225 20
#define EntDir270 21
#define EntDir315 22
#define EntDirUp 23
#define EntDirDown 24
#define EntDelProp 25
#define EntKeyLabel 26
#define EntKeyField 27
#define EntValueLabel 28
#define EntValueField 29
#define EntColor 30
#define EntLast 31
extern HWND hwndEnt[EntLast];
extern int rgIds[EntLast];

View file

@ -1,98 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// This .h file contains constants, typedefs, etc. for Intergraph
// extensions to OpenGL. These extensions are:
//
// Multiple Palette Extension
// Texture Object Extension
#define GL_INGR_multiple_palette 1
#define GL_EXT_texture_object 1
// New constants and typedefs for the Multiple Palette Extension
#define GL_PALETTE_INGR 0x80c0
#define GL_MAX_PALETTES_INGR 0x80c1
#define GL_MAX_PALETTE_ENTRIES_INGR 0x80c2
#define GL_CURRENT_PALETTE_INGR 0x80c3
#define GL_PALETTE_WRITEMASK_INGR 0x80c4
#define GL_CURRENT_RASTER_PALETTE_INGR 0x80c5
#define GL_PALETTE_CLEAR_VALUE_INGR 0x80c6
// Function prototypes for the Multiple Palette Extension routines
typedef void (APIENTRY *PALETTEFUNCPTR)(GLuint);
typedef void (APIENTRY *PALETTEMASKFUNCPTR)(GLboolean);
typedef void (APIENTRY *WGLLOADPALETTEFUNCPTR)(GLuint, GLsizei, GLuint *);
typedef void (APIENTRY *CLEARPALETTEFUNCPTR)(GLuint);
// New Constants and typedefs for the Texture Object Extension
#define GL_TEXTURE_PRIORITY_EXT 0x8066
#define GL_TEXTURE_RESIDENT_EXT 0x8067
#define GL_TEXTURE_1D_BINDING_EXT 0x8068
#define GL_TEXTURE_2D_BINDING_EXT 0x8069
// Function prototypes for the Texture Object Extension routines
typedef GLboolean (APIENTRY *ARETEXRESFUNCPTR)(GLsizei, const GLuint *,
const GLboolean *);
typedef void (APIENTRY *BINDTEXFUNCPTR)(GLenum, GLuint);
typedef void (APIENTRY *DELTEXFUNCPTR)(GLsizei, const GLuint *);
typedef void (APIENTRY *GENTEXFUNCPTR)(GLsizei, GLuint *);
typedef GLboolean (APIENTRY *ISTEXFUNCPTR)(GLuint);
typedef void (APIENTRY *PRIORTEXFUNCPTR)(GLsizei, const GLuint *,
const GLclampf *);
/* OpenGL ExtEscape escape function constants */
#ifndef OPENGL_GETINFO
#define OPENGL_GETINFO 4353 /* for OpenGL ExtEscape */
#endif
// OPENGL_GETINFO ExtEscape sub-escape numbers. They are defined by
// Microsoft.
#ifndef OPENGL_GETINFO_DRVNAME
#define OPENGL_GETINFO_DRVNAME 0
// Input structure for OPENGL_GETINFO ExtEscape.
typedef struct _OPENGLGETINFO
{
ULONG ulSubEsc;
} OPENGLGETINFO, *POPENGLGETINFO;
// Output structure for OPENGL_GETINFO_DRVNAME ExtEscape.
typedef struct _GLDRVNAMERET
{
ULONG ulVersion; // must be 1 for this version
ULONG ulDriverVersion; // driver specific version number
WCHAR awch[MAX_PATH+1];
} GLDRVNAMERET, *PGLDRVNAMERET;
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

View file

@ -1,835 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// lbmlib.c
#include "cmdlib.h"
#include "lbmlib.h"
/*
============================================================================
LBM STUFF
============================================================================
*/
typedef unsigned char UBYTE;
//conflicts with windows typedef short WORD;
typedef unsigned short UWORD;
typedef long LONG;
typedef enum
{
ms_none,
ms_mask,
ms_transcolor,
ms_lasso
} mask_t;
typedef enum
{
cm_none,
cm_rle1
} compress_t;
typedef struct
{
UWORD w,h;
short x,y;
UBYTE nPlanes;
UBYTE masking;
UBYTE compression;
UBYTE pad1;
UWORD transparentColor;
UBYTE xAspect,yAspect;
short pageWidth,pageHeight;
} bmhd_t;
extern bmhd_t bmhd; // will be in native byte order
#define FORMID ('F'+('O'<<8)+((int)'R'<<16)+((int)'M'<<24))
#define ILBMID ('I'+('L'<<8)+((int)'B'<<16)+((int)'M'<<24))
#define PBMID ('P'+('B'<<8)+((int)'M'<<16)+((int)' '<<24))
#define BMHDID ('B'+('M'<<8)+((int)'H'<<16)+((int)'D'<<24))
#define BODYID ('B'+('O'<<8)+((int)'D'<<16)+((int)'Y'<<24))
#define CMAPID ('C'+('M'<<8)+((int)'A'<<16)+((int)'P'<<24))
bmhd_t bmhd;
int Align (int l)
{
if (l&1)
return l+1;
return l;
}
/*
================
LBMRLEdecompress
Source must be evenly aligned!
================
*/
byte *LBMRLEDecompress (byte *source,byte *unpacked, int bpwidth)
{
int count;
byte b,rept;
count = 0;
do
{
rept = *source++;
if (rept > 0x80)
{
rept = (rept^0xff)+2;
b = *source++;
memset(unpacked,b,rept);
unpacked += rept;
}
else if (rept < 0x80)
{
rept++;
memcpy(unpacked,source,rept);
unpacked += rept;
source += rept;
}
else
rept = 0; // rept of 0x80 is NOP
count += rept;
} while (count<bpwidth);
if (count>bpwidth)
Error ("Decompression exceeded width!\n");
return source;
}
/*
=================
LoadLBM
=================
*/
void LoadLBM (char *filename, byte **picture, byte **palette)
{
byte *LBMbuffer, *picbuffer, *cmapbuffer;
int y;
byte *LBM_P, *LBMEND_P;
byte *pic_p;
byte *body_p;
int formtype,formlength;
int chunktype,chunklength;
// qiet compiler warnings
picbuffer = NULL;
cmapbuffer = NULL;
//
// load the LBM
//
LoadFile (filename, (void **)&LBMbuffer);
//
// parse the LBM header
//
LBM_P = LBMbuffer;
if ( *(int *)LBMbuffer != LittleLong(FORMID) )
Error ("No FORM ID at start of file!\n");
LBM_P += 4;
formlength = BigLong( *(int *)LBM_P );
LBM_P += 4;
LBMEND_P = LBM_P + Align(formlength);
formtype = LittleLong(*(int *)LBM_P);
if (formtype != ILBMID && formtype != PBMID)
Error ("Unrecognized form type: %c%c%c%c\n", formtype&0xff
,(formtype>>8)&0xff,(formtype>>16)&0xff,(formtype>>24)&0xff);
LBM_P += 4;
//
// parse chunks
//
while (LBM_P < LBMEND_P)
{
chunktype = LBM_P[0] + (LBM_P[1]<<8) + (LBM_P[2]<<16) + (LBM_P[3]<<24);
LBM_P += 4;
chunklength = LBM_P[3] + (LBM_P[2]<<8) + (LBM_P[1]<<16) + (LBM_P[0]<<24);
LBM_P += 4;
switch ( chunktype )
{
case BMHDID:
memcpy (&bmhd,LBM_P,sizeof(bmhd));
bmhd.w = BigShort(bmhd.w);
bmhd.h = BigShort(bmhd.h);
bmhd.x = BigShort(bmhd.x);
bmhd.y = BigShort(bmhd.y);
bmhd.pageWidth = BigShort(bmhd.pageWidth);
bmhd.pageHeight = BigShort(bmhd.pageHeight);
break;
case CMAPID:
cmapbuffer = malloc (768);
memset (cmapbuffer, 0, 768);
memcpy (cmapbuffer, LBM_P, chunklength);
break;
case BODYID:
body_p = LBM_P;
pic_p = picbuffer = malloc (bmhd.w*bmhd.h);
if (formtype == PBMID)
{
//
// unpack PBM
//
for (y=0 ; y<bmhd.h ; y++, pic_p += bmhd.w)
{
if (bmhd.compression == cm_rle1)
body_p = LBMRLEDecompress ((byte *)body_p
, pic_p , bmhd.w);
else if (bmhd.compression == cm_none)
{
memcpy (pic_p,body_p,bmhd.w);
body_p += Align(bmhd.w);
}
}
}
else
{
//
// unpack ILBM
//
Error ("%s is an interlaced LBM, not packed", filename);
}
break;
}
LBM_P += Align(chunklength);
}
free (LBMbuffer);
*picture = picbuffer;
if (palette)
*palette = cmapbuffer;
}
/*
============================================================================
WRITE LBM
============================================================================
*/
/*
==============
WriteLBMfile
==============
*/
void WriteLBMfile (char *filename, byte *data,
int width, int height, byte *palette)
{
byte *lbm, *lbmptr;
int *formlength, *bmhdlength, *cmaplength, *bodylength;
int length;
bmhd_t basebmhd;
lbm = lbmptr = malloc (width*height+1000);
//
// start FORM
//
*lbmptr++ = 'F';
*lbmptr++ = 'O';
*lbmptr++ = 'R';
*lbmptr++ = 'M';
formlength = (int*)lbmptr;
lbmptr+=4; // leave space for length
*lbmptr++ = 'P';
*lbmptr++ = 'B';
*lbmptr++ = 'M';
*lbmptr++ = ' ';
//
// write BMHD
//
*lbmptr++ = 'B';
*lbmptr++ = 'M';
*lbmptr++ = 'H';
*lbmptr++ = 'D';
bmhdlength = (int *)lbmptr;
lbmptr+=4; // leave space for length
memset (&basebmhd,0,sizeof(basebmhd));
basebmhd.w = BigShort((short)width);
basebmhd.h = BigShort((short)height);
basebmhd.nPlanes = 8;
basebmhd.xAspect = 5;
basebmhd.yAspect = 6;
basebmhd.pageWidth = BigShort((short)width);
basebmhd.pageHeight = BigShort((short)height);
memcpy (lbmptr,&basebmhd,sizeof(basebmhd));
lbmptr += sizeof(basebmhd);
length = lbmptr-(byte *)bmhdlength-4;
*bmhdlength = BigLong(length);
if (length&1)
*lbmptr++ = 0; // pad chunk to even offset
//
// write CMAP
//
*lbmptr++ = 'C';
*lbmptr++ = 'M';
*lbmptr++ = 'A';
*lbmptr++ = 'P';
cmaplength = (int *)lbmptr;
lbmptr+=4; // leave space for length
memcpy (lbmptr,palette,768);
lbmptr += 768;
length = lbmptr-(byte *)cmaplength-4;
*cmaplength = BigLong(length);
if (length&1)
*lbmptr++ = 0; // pad chunk to even offset
//
// write BODY
//
*lbmptr++ = 'B';
*lbmptr++ = 'O';
*lbmptr++ = 'D';
*lbmptr++ = 'Y';
bodylength = (int *)lbmptr;
lbmptr+=4; // leave space for length
memcpy (lbmptr,data,width*height);
lbmptr += width*height;
length = lbmptr-(byte *)bodylength-4;
*bodylength = BigLong(length);
if (length&1)
*lbmptr++ = 0; // pad chunk to even offset
//
// done
//
length = lbmptr-(byte *)formlength-4;
*formlength = BigLong(length);
if (length&1)
*lbmptr++ = 0; // pad chunk to even offset
//
// write output file
//
SaveFile (filename, lbm, lbmptr-lbm);
free (lbm);
}
/*
============================================================================
LOAD PCX
============================================================================
*/
typedef struct
{
char manufacturer;
char version;
char encoding;
char bits_per_pixel;
unsigned short xmin,ymin,xmax,ymax;
unsigned short hres,vres;
unsigned char palette[48];
char reserved;
char color_planes;
unsigned short bytes_per_line;
unsigned short palette_type;
char filler[58];
unsigned char data; // unbounded
} pcx_t;
/*
==============
LoadPCX
==============
*/
void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height)
{
byte *raw;
pcx_t *pcx;
int x, y;
int len;
int dataByte, runLength;
byte *out, *pix;
if (pic)
*pic = NULL;
if (palette)
*palette = NULL;
if (width)
*width = 0;
if (height)
*height = 0;
//
// load the file
//
len = LoadFile (filename, (void **)&raw);
if (len == -1)
return;
//
// parse the PCX file
//
pcx = (pcx_t *)raw;
raw = &pcx->data;
pcx->xmin = LittleShort(pcx->xmin);
pcx->ymin = LittleShort(pcx->ymin);
pcx->xmax = LittleShort(pcx->xmax);
pcx->ymax = LittleShort(pcx->ymax);
pcx->hres = LittleShort(pcx->hres);
pcx->vres = LittleShort(pcx->vres);
pcx->bytes_per_line = LittleShort(pcx->bytes_per_line);
pcx->palette_type = LittleShort(pcx->palette_type);
if (pcx->manufacturer != 0x0a
|| pcx->version != 5
|| pcx->encoding != 1
|| pcx->bits_per_pixel != 8
|| pcx->xmax >= 640
|| pcx->ymax >= 480)
Error ("Bad pcx file %s", filename);
if (palette)
{
*palette = malloc(768);
memcpy (*palette, (byte *)pcx + len - 768, 768);
}
if (width)
*width = pcx->xmax+1;
if (height)
*height = pcx->ymax+1;
if (!pic)
return;
out = malloc ( (pcx->ymax+1) * (pcx->xmax+1) );
if (!out)
Error ("Skin_Cache: couldn't allocate");
*pic = out;
pix = out;
for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
{
for (x=0 ; x<=pcx->xmax ; )
{
dataByte = *raw++;
if((dataByte & 0xC0) == 0xC0)
{
runLength = dataByte & 0x3F;
dataByte = *raw++;
}
else
runLength = 1;
while(runLength-- > 0)
pix[x++] = dataByte;
}
}
if ( raw - (byte *)pcx > len)
Error ("PCX file %s was malformed", filename);
free (pcx);
}
/*
==============
WritePCXfile
==============
*/
void WritePCXfile (char *filename, byte *data,
int width, int height, byte *palette)
{
int i, j, length;
pcx_t *pcx;
byte *pack;
pcx = malloc (width*height*2+1000);
memset (pcx, 0, sizeof(*pcx));
pcx->manufacturer = 0x0a; // PCX id
pcx->version = 5; // 256 color
pcx->encoding = 1; // uncompressed
pcx->bits_per_pixel = 8; // 256 color
pcx->xmin = 0;
pcx->ymin = 0;
pcx->xmax = LittleShort((short)(width-1));
pcx->ymax = LittleShort((short)(height-1));
pcx->hres = LittleShort((short)width);
pcx->vres = LittleShort((short)height);
pcx->color_planes = 1; // chunky image
pcx->bytes_per_line = LittleShort((short)width);
pcx->palette_type = LittleShort(2); // not a grey scale
// pack the image
pack = &pcx->data;
for (i=0 ; i<height ; i++)
{
for (j=0 ; j<width ; j++)
{
if ( (*data & 0xc0) != 0xc0)
*pack++ = *data++;
else
{
*pack++ = 0xc1;
*pack++ = *data++;
}
}
}
// write the palette
*pack++ = 0x0c; // palette ID byte
for (i=0 ; i<768 ; i++)
*pack++ = *palette++;
// write output file
length = pack - (byte *)pcx;
SaveFile (filename, pcx, length);
free (pcx);
}
/*
============================================================================
LOAD IMAGE
============================================================================
*/
/*
==============
Load256Image
Will load either an lbm or pcx, depending on extension.
Any of the return pointers can be NULL if you don't want them.
==============
*/
void Load256Image (char *name, byte **pixels, byte **palette,
int *width, int *height)
{
char ext[128];
ExtractFileExtension (name, ext);
if (!Q_strcasecmp (ext, "lbm"))
{
LoadLBM (name, pixels, palette);
if (width)
*width = bmhd.w;
if (height)
*height = bmhd.h;
}
else if (!Q_strcasecmp (ext, "pcx"))
{
LoadPCX (name, pixels, palette, width, height);
}
else
Error ("%s doesn't have a known image extension", name);
}
/*
==============
Save256Image
Will save either an lbm or pcx, depending on extension.
==============
*/
void Save256Image (char *name, byte *pixels, byte *palette,
int width, int height)
{
char ext[128];
ExtractFileExtension (name, ext);
if (!Q_strcasecmp (ext, "lbm"))
{
WriteLBMfile (name, pixels, width, height, palette);
}
else if (!Q_strcasecmp (ext, "pcx"))
{
WritePCXfile (name, pixels, width, height, palette);
}
else
Error ("%s doesn't have a known image extension", name);
}
/*
============================================================================
TARGA IMAGE
============================================================================
*/
typedef struct _TargaHeader {
unsigned char id_length, colormap_type, image_type;
unsigned short colormap_index, colormap_length;
unsigned char colormap_size;
unsigned short x_origin, y_origin, width, height;
unsigned char pixel_size, attributes;
} TargaHeader;
int fgetLittleShort (FILE *f)
{
byte b1, b2;
b1 = fgetc(f);
b2 = fgetc(f);
return (short)(b1 + b2*256);
}
int fgetLittleLong (FILE *f)
{
byte b1, b2, b3, b4;
b1 = fgetc(f);
b2 = fgetc(f);
b3 = fgetc(f);
b4 = fgetc(f);
return b1 + (b2<<8) + (b3<<16) + (b4<<24);
}
/*
=============
LoadTGA
=============
*/
void LoadTGA (char *name, byte **pixels, int *width, int *height)
{
int columns, rows, numPixels;
byte *pixbuf;
int row, column;
FILE *fin;
byte *targa_rgba;
TargaHeader targa_header;
fin = fopen (name, "rb");
if (!fin)
Error ("Couldn't read %s", name);
targa_header.id_length = fgetc(fin);
targa_header.colormap_type = fgetc(fin);
targa_header.image_type = fgetc(fin);
targa_header.colormap_index = fgetLittleShort(fin);
targa_header.colormap_length = fgetLittleShort(fin);
targa_header.colormap_size = fgetc(fin);
targa_header.x_origin = fgetLittleShort(fin);
targa_header.y_origin = fgetLittleShort(fin);
targa_header.width = fgetLittleShort(fin);
targa_header.height = fgetLittleShort(fin);
targa_header.pixel_size = fgetc(fin);
targa_header.attributes = fgetc(fin);
if (targa_header.image_type!=2
&& targa_header.image_type!=10)
Error ("LoadTGA: Only type 2 and 10 targa RGB images supported\n");
if (targa_header.colormap_type !=0
|| (targa_header.pixel_size!=32 && targa_header.pixel_size!=24))
Error ("Texture_LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
columns = targa_header.width;
rows = targa_header.height;
numPixels = columns * rows;
if (width)
*width = columns;
if (height)
*height = rows;
targa_rgba = malloc(numPixels*4);
*pixels = targa_rgba;
if (targa_header.id_length != 0)
fseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
if (targa_header.image_type==2) { // Uncompressed, RGB images
for(row=rows-1; row>=0; row--) {
pixbuf = targa_rgba + row*columns*4;
for(column=0; column<columns; column++) {
unsigned char red,green,blue,alphabyte;
switch (targa_header.pixel_size) {
case 24:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
*pixbuf++ = 255;
break;
case 32:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
alphabyte = getc(fin);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
*pixbuf++ = alphabyte;
break;
}
}
}
}
else if (targa_header.image_type==10) { // Runlength encoded RGB images
unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
for(row=rows-1; row>=0; row--) {
pixbuf = targa_rgba + row*columns*4;
for(column=0; column<columns; ) {
packetHeader=getc(fin);
packetSize = 1 + (packetHeader & 0x7f);
if (packetHeader & 0x80) { // run-length packet
switch (targa_header.pixel_size) {
case 24:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
alphabyte = 255;
break;
case 32:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
alphabyte = getc(fin);
break;
}
for(j=0;j<packetSize;j++) {
*pixbuf++=red;
*pixbuf++=green;
*pixbuf++=blue;
*pixbuf++=alphabyte;
column++;
if (column==columns) { // run spans across rows
column=0;
if (row>0)
row--;
else
goto breakOut;
pixbuf = targa_rgba + row*columns*4;
}
}
}
else { // non run-length packet
for(j=0;j<packetSize;j++) {
switch (targa_header.pixel_size) {
case 24:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
*pixbuf++ = 255;
break;
case 32:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
alphabyte = getc(fin);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
*pixbuf++ = alphabyte;
break;
}
column++;
if (column==columns) { // pixel packet run spans across rows
column=0;
if (row>0)
row--;
else
goto breakOut;
pixbuf = targa_rgba + row*columns*4;
}
}
}
}
breakOut:;
}
}
fclose(fin);
}

View file

@ -1,40 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// piclib.h
void LoadLBM (char *filename, byte **picture, byte **palette);
void WriteLBMfile (char *filename, byte *data, int width, int height
, byte *palette);
void LoadPCX (char *filename, byte **picture, byte **palette, int *width, int *height);
void WritePCXfile (char *filename, byte *data, int width, int height
, byte *palette);
// loads / saves either lbm or pcx, depending on extension
void Load256Image (char *name, byte **pixels, byte **palette,
int *width, int *height);
void Save256Image (char *name, byte *pixels, byte *palette,
int width, int height);
void LoadTGA (char *filename, byte **pixels, int *width, int *height);

View file

@ -1,23 +0,0 @@
TARGETOS=WINNT
!include <ntwin32.mak>
# This line allows NMAKE to work as well
all: gengl.exe
# Update the object file if necessary
gengl.obj: gengl.c gengl.h
$(cc) $(cflags) $(cvars) $(cdebug) $(cf) gengl.c
render.obj: render.c gengl.h
$(cc) $(cflags) $(cvars) $(cdebug) $(cf) render.c
gengl.res: gengl.rc genglrc.h
rc -r gengl.rc
gengl.exe: gengl.obj gengl.res render.obj
$(link) $(linkdebug) /NODEFAULTLIB $(guilflags) -out:gengl.exe \
gengl.obj render.obj gengl.res $(guilibsdll) opengl32.lib glu32.lib

661
qe4/map.c
View file

@ -1,661 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// map.c
#include "qe3.h"
qboolean modified; // for quit confirmation (0 = clean, 1 = unsaved,
// 2 = autosaved, but not regular saved)
char currentmap[1024];
brush_t active_brushes; // brushes currently being displayed
brush_t selected_brushes; // highlighted
face_t *selected_face;
brush_t *selected_face_brush;
brush_t filtered_brushes; // brushes that have been filtered or regioned
entity_t entities; // head/tail of doubly linked list
entity_t *world_entity;
void AddRegionBrushes (void);
void RemoveRegionBrushes (void);
/*
=============================================================
Cross map selection saving
this could fuck up if you have only part of a complex entity selected...
=============================================================
*/
brush_t between_brushes;
entity_t between_entities;
void Map_SaveBetween (void)
{
brush_t *b;
entity_t *e, *e2;
between_brushes.next = selected_brushes.next;
between_brushes.prev = selected_brushes.prev;
between_brushes.next->prev = &between_brushes;
between_brushes.prev->next = &between_brushes;
between_entities.next = between_entities.prev = &between_entities;
selected_brushes.next = selected_brushes.prev = &selected_brushes;
for (b=between_brushes.next ; b != &between_brushes ; b=b->next)
{
e = b->owner;
if (e == world_entity)
b->owner = NULL;
else
{
for (e2=between_entities.next ; e2 != &between_entities ; e2=e2->next)
if (e2 == e)
goto next; // allready got the entity
// move the entity over
e->prev->next = e->next;
e->next->prev = e->prev;
e->next = between_entities.next;
e->prev = &between_entities;
e->next->prev = e;
e->prev->next = e;
}
next: ;
}
}
void Map_RestoreBetween (void)
{
entity_t *head, *tail;
brush_t *b;
if (!between_brushes.next)
return;
for (b=between_brushes.next ; b != &between_brushes ; b=b->next)
{
if (!b->owner)
{
b->owner = world_entity;
b->onext = world_entity->brushes.onext;
b->oprev = &world_entity->brushes;
b->onext->oprev = b;
b->oprev->onext = b;
}
}
selected_brushes.next = between_brushes.next;
selected_brushes.prev = between_brushes.prev;
selected_brushes.next->prev = &selected_brushes;
selected_brushes.prev->next = &selected_brushes;
head = between_entities.next;
tail = between_entities.prev;
if (head != tail)
{
entities.prev->next = head;
head->prev = entities.prev;
tail->next = &entities;
entities.prev = tail;
}
between_brushes.next = NULL;
between_entities.next = NULL;
}
//============================================================================
void Map_BuildBrushData(void)
{
brush_t *b, *next;
if (active_brushes.next == NULL)
return;
Sys_BeginWait (); // this could take a while
for (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=next)
{
next = b->next;
Brush_Build( b );
if (!b->brush_faces)
{
Brush_Free (b);
Sys_Printf ("Removed degenerate brush\n");
}
}
Sys_EndWait();
}
entity_t *Map_FindClass (char *cname)
{
entity_t *ent;
for (ent = entities.next ; ent != &entities ; ent=ent->next)
{
if (!strcmp(cname, ValueForKey (ent, "classname")))
return ent;
}
return NULL;
}
/*
================
Map_Free
================
*/
void Map_Free (void)
{
if (selected_brushes.next &&
(selected_brushes.next != &selected_brushes) )
{
if (MessageBox(g_qeglobals.d_hwndMain, "Copy selection?", "", MB_YESNO) == IDYES)
Map_SaveBetween ();
}
Texture_ClearInuse ();
Pointfile_Clear ();
strcpy (currentmap, "unnamed.map");
Sys_SetTitle (currentmap);
g_qeglobals.d_num_entities = 0;
if (!active_brushes.next)
{ // first map
active_brushes.prev = active_brushes.next = &active_brushes;
selected_brushes.prev = selected_brushes.next = &selected_brushes;
filtered_brushes.prev = filtered_brushes.next = &filtered_brushes;
entities.prev = entities.next = &entities;
}
else
{
while (active_brushes.next != &active_brushes)
Brush_Free (active_brushes.next);
while (selected_brushes.next != &selected_brushes)
Brush_Free (selected_brushes.next);
while (filtered_brushes.next != &filtered_brushes)
Brush_Free (filtered_brushes.next);
while (entities.next != &entities)
Entity_Free (entities.next);
}
world_entity = NULL;
}
/*
================
Map_LoadFile
================
*/
void Map_LoadFile (char *filename)
{
char *buf;
entity_t *ent;
char temp[1024];
Sys_BeginWait ();
SetInspectorMode(W_CONSOLE);
QE_ConvertDOSToUnixName( temp, filename );
Sys_Printf ("Map_LoadFile: %s\n", temp );
Map_Free ();
g_qeglobals.d_parsed_brushes = 0;
strcpy (currentmap, filename);
LoadFile (filename, (void **)&buf);
StartTokenParsing (buf);
g_qeglobals.d_num_entities = 0;
while (1)
{
ent = Entity_Parse (false);
if (!ent)
break;
if (!strcmp(ValueForKey (ent, "classname"), "worldspawn"))
{
if (world_entity)
Sys_Printf ("WARNING: multiple worldspawn\n");
world_entity = ent;
}
else
{
// add the entity to the end of the entity list
ent->next = &entities;
ent->prev = entities.prev;
entities.prev->next = ent;
entities.prev = ent;
g_qeglobals.d_num_entities++;
}
}
free (buf);
if (!world_entity)
{
Sys_Printf ("No worldspawn in map.\n");
Map_New ();
return;
}
Sys_Printf ("--- LoadMapFile ---\n");
Sys_Printf ("%s\n", temp );
Sys_Printf ("%5i brushes\n", g_qeglobals.d_parsed_brushes );
Sys_Printf ("%5i entities\n", g_qeglobals.d_num_entities);
Map_RestoreBetween ();
Sys_Printf ("Map_BuildAllDisplayLists\n");
Map_BuildBrushData();
//
// move the view to a start position
//
ent = Map_FindClass ("info_player_start");
if (!ent)
ent = Map_FindClass ("info_player_deathmatch");
camera.angles[PITCH] = 0;
if (ent)
{
GetVectorForKey (ent, "origin", camera.origin);
GetVectorForKey (ent, "origin", g_qeglobals.d_xy.origin);
camera.angles[YAW] = FloatForKey (ent, "angle");
}
else
{
camera.angles[YAW] = 0;
VectorCopy (vec3_origin, camera.origin);
VectorCopy (vec3_origin, g_qeglobals.d_xy.origin);
}
Sys_UpdateWindows (W_ALL);
Map_RegionOff ();
modified = false;
Sys_SetTitle (temp);
Texture_ShowInuse ();
Sys_EndWait();
}
/*
===========
Map_SaveFile
===========
*/
void Map_SaveFile (char *filename, qboolean use_region )
{
entity_t *e, *next;
FILE *f;
char temp[1024];
int count;
QE_ConvertDOSToUnixName( temp, filename );
if (!use_region)
{
char backup[1024];
// rename current to .bak
strcpy (backup, filename);
StripExtension (backup);
strcat (backup, ".bak");
_unlink (backup);
rename (filename, backup);
}
Sys_Printf ("Map_SaveFile: %s\n", filename);
f = fopen(filename, "w");
if (!f)
{
Sys_Printf ("ERROR!!!! Couldn't open %s\n", filename);
return;
}
if (use_region)
AddRegionBrushes ();
// write world entity first
Entity_Write (world_entity, f, use_region);
// then write all other ents
count = 1;
for (e=entities.next ; e != &entities ; e=next)
{
fprintf (f, "// entity %i\n", count);
count++;
next = e->next;
if (e->brushes.onext == &e->brushes)
Entity_Free (e); // no brushes left, so remove it
else
Entity_Write (e, f, use_region);
}
fclose (f);
if (use_region)
RemoveRegionBrushes ();
Sys_Printf ("Saved.\n");
modified = false;
if ( !strstr( temp, "autosave" ) )
Sys_SetTitle (temp);
if (!use_region)
{
time_t timer;
FILE *f;
time (&timer);
MessageBeep (MB_ICONEXCLAMATION);
f = fopen ("c:/tstamps.log", "a");
if (f)
{
fprintf (f, "%4i : %35s : %s", g_qeglobals.d_workcount, filename, ctime(&timer));
fclose (f);
g_qeglobals.d_workcount = 0;
}
fclose (f);
Sys_Status ("Saved.\n", 0);
}
}
/*
===========
Map_New
===========
*/
void Map_New (void)
{
Sys_Printf ("Map_New\n");
Map_Free ();
world_entity = qmalloc(sizeof(*world_entity));
world_entity->brushes.onext =
world_entity->brushes.oprev = &world_entity->brushes;
SetKeyValue (world_entity, "classname", "worldspawn");
world_entity->eclass = Eclass_ForName ("worldspawn", true);
camera.angles[YAW] = 0;
VectorCopy (vec3_origin, camera.origin);
camera.origin[2] = 48;
VectorCopy (vec3_origin, g_qeglobals.d_xy.origin);
Map_RestoreBetween ();
Sys_UpdateWindows (W_ALL);
modified = false;
}
/*
===========================================================
REGION
===========================================================
*/
qboolean region_active;
vec3_t region_mins = {-4096, -4096, -4096};
vec3_t region_maxs = {4096, 4096, 4096};
brush_t *region_sides[4];
/*
===========
AddRegionBrushes
a regioned map will have temp walls put up at the region boundary
===========
*/
void AddRegionBrushes (void)
{
vec3_t mins, maxs;
int i;
texdef_t td;
if (!region_active)
return;
memset (&td, 0, sizeof(td));
strcpy (td.name, "REGION");
mins[0] = region_mins[0] - 16;
maxs[0] = region_mins[0] + 1;
mins[1] = region_mins[1] - 16;
maxs[1] = region_maxs[1] + 16;
mins[2] = -2048;
maxs[2] = 2048;
region_sides[0] = Brush_Create (mins, maxs, &td);
mins[0] = region_maxs[0] - 1;
maxs[0] = region_maxs[0] + 16;
region_sides[1] = Brush_Create (mins, maxs, &td);
mins[0] = region_mins[0] - 16;
maxs[0] = region_maxs[0] + 16;
mins[1] = region_mins[1] - 16;
maxs[1] = region_mins[1] + 1;
region_sides[2] = Brush_Create (mins, maxs, &td);
mins[1] = region_maxs[1] - 1;
maxs[1] = region_maxs[1] + 16;
region_sides[3] = Brush_Create (mins, maxs, &td);
for (i=0 ; i<4 ; i++)
{
Brush_AddToList (region_sides[i], &selected_brushes);
Entity_LinkBrush (world_entity, region_sides[i]);
Brush_Build( region_sides[i] );
}
}
void RemoveRegionBrushes (void)
{
int i;
if (!region_active)
return;
for (i=0 ; i<4 ; i++)
Brush_Free (region_sides[i]);
}
qboolean Map_IsBrushFiltered (brush_t *b)
{
int i;
for (i=0 ; i<3 ; i++)
{
if (b->mins[i] > region_maxs[i])
return true;
if (b->maxs[i] < region_mins[i])
return true;
}
return false;
}
/*
===========
Map_RegionOff
Other filtering options may still be on
===========
*/
void Map_RegionOff (void)
{
brush_t *b, *next;
int i;
region_active = false;
for (i=0 ; i<3 ; i++)
{
region_maxs[i] = 4096;
region_mins[i] = -4096;
}
for (b=filtered_brushes.next ; b != &filtered_brushes ; b=next)
{
next = b->next;
if (Map_IsBrushFiltered (b))
continue; // still filtered
Brush_RemoveFromList (b);
Brush_AddToList (b, &active_brushes);
}
Sys_UpdateWindows (W_ALL);
}
void Map_ApplyRegion (void)
{
brush_t *b, *next;
region_active = true;
for (b=active_brushes.next ; b != &active_brushes ; b=next)
{
next = b->next;
if (!Map_IsBrushFiltered (b))
continue; // still filtered
Brush_RemoveFromList (b);
Brush_AddToList (b, &filtered_brushes);
}
Sys_UpdateWindows (W_ALL);
}
/*
========================
Map_RegionSelectedBrushes
========================
*/
void Map_RegionSelectedBrushes (void)
{
Map_RegionOff ();
region_active = true;
Select_GetBounds (region_mins, region_maxs);
// move the entire active_brushes list to filtered_brushes
filtered_brushes.next = active_brushes.next;
filtered_brushes.prev = active_brushes.prev;
filtered_brushes.next->prev = &filtered_brushes;
filtered_brushes.prev->next = &filtered_brushes;
// move the entire selected_brushes list to active_brushes
active_brushes.next = selected_brushes.next;
active_brushes.prev = selected_brushes.prev;
active_brushes.next->prev = &active_brushes;
active_brushes.prev->next = &active_brushes;
// clear selected_brushes
selected_brushes.next = selected_brushes.prev = &selected_brushes;
Sys_UpdateWindows (W_ALL);
}
/*
===========
Map_RegionXY
===========
*/
void Map_RegionXY (void)
{
Map_RegionOff ();
region_mins[0] = g_qeglobals.d_xy.origin[0] - 0.5*g_qeglobals.d_xy.width/g_qeglobals.d_xy.scale;
region_maxs[0] = g_qeglobals.d_xy.origin[0] + 0.5*g_qeglobals.d_xy.width/g_qeglobals.d_xy.scale;
region_mins[1] = g_qeglobals.d_xy.origin[1] - 0.5*g_qeglobals.d_xy.height/g_qeglobals.d_xy.scale;
region_maxs[1] = g_qeglobals.d_xy.origin[1] + 0.5*g_qeglobals.d_xy.height/g_qeglobals.d_xy.scale;
region_mins[2] = -4096;
region_maxs[2] = 4096;
Map_ApplyRegion ();
}
/*
===========
Map_RegionTallBrush
===========
*/
void Map_RegionTallBrush (void)
{
brush_t *b;
if (!QE_SingleBrush ())
return;
b = selected_brushes.next;
Map_RegionOff ();
VectorCopy (b->mins, region_mins);
VectorCopy (b->maxs, region_maxs);
region_mins[2] = -4096;
region_maxs[2] = 4096;
Select_Delete ();
Map_ApplyRegion ();
}
/*
===========
Map_RegionBrush
===========
*/
void Map_RegionBrush (void)
{
brush_t *b;
if (!QE_SingleBrush ())
return;
b = selected_brushes.next;
Map_RegionOff ();
VectorCopy (b->mins, region_mins);
VectorCopy (b->maxs, region_maxs);
Select_Delete ();
Map_ApplyRegion ();
}

View file

@ -1,53 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// map.h -- the state of the current world that all views are displaying
extern char currentmap[1024];
// head/tail of doubly linked lists
extern brush_t active_brushes; // brushes currently being displayed
extern brush_t selected_brushes; // highlighted
extern face_t *selected_face;
extern brush_t *selected_face_brush;
extern brush_t filtered_brushes; // brushes that have been filtered or regioned
extern entity_t entities;
extern entity_t *world_entity; // the world entity is NOT included in
// the entities chain
extern qboolean modified; // for quit confirmations
extern vec3_t region_mins, region_maxs;
extern qboolean region_active;
void Map_LoadFile (char *filename);
void Map_SaveFile (char *filename, qboolean use_region);
void Map_New (void);
void Map_BuildBrushData(void);
void Map_RegionOff (void);
void Map_RegionXY (void);
void Map_RegionTallBrush (void);
void Map_RegionBrush (void);
void Map_RegionSelectedBrushes (void);
qboolean Map_IsBrushFiltered (brush_t *b);

View file

@ -1,131 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// mathlib.c -- math primitives
#include "cmdlib.h"
#include "mathlib.h"
vec3_t vec3_origin = {0.0f,0.0f,0.0f};
float VectorLength(vec3_t v)
{
int i;
float length;
length = 0.0f;
for (i=0 ; i< 3 ; i++)
length += v[i]*v[i];
length = (float)sqrt (length);
return length;
}
qboolean VectorCompare (vec3_t v1, vec3_t v2)
{
int i;
for (i=0 ; i<3 ; i++)
if (fabs(v1[i]-v2[i]) > EQUAL_EPSILON)
return false;
return true;
}
vec_t Q_rint (vec_t in)
{
return (float)floor (in + 0.5);
}
void VectorMA (vec3_t va, float scale, vec3_t vb, vec3_t vc)
{
vc[0] = va[0] + scale*vb[0];
vc[1] = va[1] + scale*vb[1];
vc[2] = va[2] + scale*vb[2];
}
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross)
{
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
}
vec_t _DotProduct (vec3_t v1, vec3_t v2)
{
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
}
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out)
{
out[0] = va[0]-vb[0];
out[1] = va[1]-vb[1];
out[2] = va[2]-vb[2];
}
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out)
{
out[0] = va[0]+vb[0];
out[1] = va[1]+vb[1];
out[2] = va[2]+vb[2];
}
void _VectorCopy (vec3_t in, vec3_t out)
{
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
}
vec_t VectorNormalize (vec3_t v)
{
int i;
float length;
length = 0.0f;
for (i=0 ; i< 3 ; i++)
length += v[i]*v[i];
length = (float)sqrt (length);
if (length == 0)
return (vec_t)0;
for (i=0 ; i< 3 ; i++)
v[i] /= length;
return length;
}
void VectorInverse (vec3_t v)
{
v[0] = -v[0];
v[1] = -v[1];
v[2] = -v[2];
}
void VectorScale (vec3_t v, vec_t scale, vec3_t out)
{
out[0] = v[0] * scale;
out[1] = v[1] * scale;
out[2] = v[2] * scale;
}

View file

@ -1,66 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __MATHLIB__
#define __MATHLIB__
// mathlib.h
#include <math.h>
typedef float vec_t;
typedef vec_t vec3_t[3];
#define SIDE_FRONT 0
#define SIDE_ON 2
#define SIDE_BACK 1
#define SIDE_CROSS -2
#define Q_PI 3.14159265358979323846
extern vec3_t vec3_origin;
#define EQUAL_EPSILON 0.001
qboolean VectorCompare (vec3_t v1, vec3_t v2);
#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
vec_t Q_rint (vec_t in);
vec_t _DotProduct (vec3_t v1, vec3_t v2);
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
void _VectorCopy (vec3_t in, vec3_t out);
float VectorLength(vec3_t v);
void VectorMA (vec3_t va, float scale, vec3_t vb, vec3_t vc);
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
vec_t VectorNormalize (vec3_t v);
void VectorInverse (vec3_t v);
void VectorScale (vec3_t v, vec_t scale, vec3_t out);
#endif

671
qe4/mru.c
View file

@ -1,671 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//*************************************************************
// File name: mru.c
//
// Description:
//
// Routines for MRU support
//
// Development Team:
//
// Gilles Vollant (100144.2636@compuserve.com)
//
//*************************************************************
#include <windows.h>
#include <windowsx.h>
#include <string.h>
#include "mru.h"
// CreateMruMenu : MRUMENU constructor
// wNbLruShowInit : nb of item showed in menu
// wNbLruMenuInit : nb of item stored in memory
// wMaxSizeLruItemInit : size max. of filename
//*************************************************************
//
// CreateMruMenu()
//
// Purpose:
//
// Allocate and Initialize an MRU and return a pointer on it
//
//
// Parameters:
//
// WORD wNbLruShowInit - Maximum number of item displayed on menu
// WORD wNbLruMenuInit - Maximum number of item stored in memory
// WORD wMaxSizeLruItemInit - Maximum size of an item (ie size of pathname)
// WORD wIdMruInit - ID of the first item in the menu (default:IDMRU)
//
//
// Return: (LPMRUMENU)
//
// Pointer on a MRUMENU structure, used by other function
//
//
// Comments:
// wNbLruShowInit <= wNbLruMenuInit
//
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
LPMRUMENU CreateMruMenu (WORD wNbLruShowInit,
WORD wNbLruMenuInit,WORD wMaxSizeLruItemInit,WORD wIdMruInit)
{
LPMRUMENU lpMruMenu;
lpMruMenu = (LPMRUMENU)GlobalAllocPtr(GHND,sizeof(MRUMENU));
lpMruMenu->wNbItemFill = 0;
lpMruMenu->wNbLruMenu = wNbLruMenuInit;
lpMruMenu->wNbLruShow = wNbLruShowInit;
lpMruMenu->wIdMru = wIdMruInit;
lpMruMenu->wMaxSizeLruItem = wMaxSizeLruItemInit;
lpMruMenu->lpMRU = (LPSTR)GlobalAllocPtr(GHND,
lpMruMenu->wNbLruMenu*(UINT)lpMruMenu->wMaxSizeLruItem);
if (lpMruMenu->lpMRU == NULL)
{
GlobalFreePtr(lpMruMenu);
lpMruMenu = NULL;
}
return lpMruMenu;
}
//*************************************************************
//
// CreateMruMenuDefault()
//
// Purpose:
//
// Allocate and Initialize an MRU and return a pointer on it
// Use default parameter
//
//
// Parameters:
//
//
// Return: (LPMRUMENU)
//
// Pointer on a MRUMENU structure, used by other function
//
//
// Comments:
//
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
LPMRUMENU CreateMruMenuDefault()
{
return CreateMruMenu (NBMRUMENUSHOW,NBMRUMENU,MAXSIZEMRUITEM,IDMRU);
}
//*************************************************************
//
// DeleteMruMenu()
//
// Purpose:
// Destructor :
// Clean and free a MRUMENU structure
//
// Parameters:
//
// LPMRUMENU lpMruMenu - pointer on MRUMENU, allocated
// by CreateMruMenu() or CreateMruMenuDefault()
//
//
// Return: void
//
//
// Comments:
//
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void DeleteMruMenu(LPMRUMENU lpMruMenu)
{
GlobalFreePtr(lpMruMenu->lpMRU);
GlobalFreePtr(lpMruMenu);
}
//*************************************************************
//
// SetNbLruShow()
//
// Purpose:
// Change the maximum number of item displayed on menu
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// WORD wNbLruShowInit - Maximum number of item displayed on menu
//
//
// Return: void
//
//
// Comments:
//
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void SetNbLruShow (LPMRUMENU lpMruMenu,WORD wNbLruShowInit)
{
lpMruMenu->wNbLruShow = min(wNbLruShowInit,lpMruMenu->wNbLruMenu);
}
//*************************************************************
//
// SetMenuItem()
//
// Purpose:
// Set the filename of an item
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// WORD wItem - Number of Item to set, zero based
// LPSTR lpItem - String, contain the filename of the item
//
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// used when load .INI or reg database
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL SetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,LPSTR lpItem)
{
if (wItem >= NBMRUMENU)
return FALSE;
_fstrncpy((lpMruMenu->lpMRU) +
((lpMruMenu->wMaxSizeLruItem) * (UINT)wItem),
lpItem,lpMruMenu->wMaxSizeLruItem-1);
lpMruMenu->wNbItemFill = max(lpMruMenu->wNbItemFill,wItem+1);
return TRUE;
}
//*************************************************************
//
// GetMenuItem()
//
// Purpose:
// Get the filename of an item
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// WORD wItem - Number of Item to set, zero based
// BOOL fIDMBased - TRUE : wItem is based on ID menu item
// FALSE : wItem is zero-based
// LPSTR lpItem - String where the filename of the item will be
// stored by GetMenuItem()
// UINT uiSize - Size of the lpItem buffer
//
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Used for saving in .INI or reg database, or when user select
// an MRU in File menu
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL GetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,
BOOL fIDMBased,LPSTR lpItem,UINT uiSize)
{
if (fIDMBased)
wItem -= (lpMruMenu->wIdMru + 1);
if (wItem >= lpMruMenu->wNbItemFill)
return FALSE;
_fstrncpy(lpItem,(lpMruMenu->lpMRU) +
((lpMruMenu->wMaxSizeLruItem) * (UINT)(wItem)),uiSize);
*(lpItem+uiSize-1) = '\0';
return TRUE;
}
//*************************************************************
//
// AddNewItem()
//
// Purpose:
// Add an item at the begin of the list
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpItem - String contain the filename to add
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Used when used open a file (using File Open common
// dialog, Drag and drop or MRU)
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void AddNewItem (LPMRUMENU lpMruMenu,LPSTR lpItem)
{
WORD i,j;
for (i=0;i<lpMruMenu->wNbItemFill;i++)
if (lstrcmpi(lpItem,(lpMruMenu->lpMRU) +
((lpMruMenu->wMaxSizeLruItem) * (UINT)i)) == 0)
{
// Shift the other items
for (j=i;j>0;j--)
lstrcpy((lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)j),
(lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)(j-1)));
_fstrncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);
return ;
}
lpMruMenu->wNbItemFill = min(lpMruMenu->wNbItemFill+1,lpMruMenu->wNbLruMenu);
for (i=lpMruMenu->wNbItemFill-1;i>0;i--)
lstrcpy(lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),
lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i-1)));
_fstrncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);
}
//*************************************************************
//
// DelMenuItem()
//
// Purpose:
// Delete an item
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// WORD wItem - Number of Item to set, zero based
// BOOL fIDMBased - TRUE : wItem is based on ID menu item
// FALSE : wItem is zero-based
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Used when used open a file, using MRU, and when an error
// occured (by example, when file was deleted)
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL DelMenuItem(LPMRUMENU lpMruMenu,WORD wItem,BOOL fIDMBased)
{
WORD i;
if (fIDMBased)
wItem -= (lpMruMenu->wIdMru + 1);
if (lpMruMenu->wNbItemFill <= wItem)
return FALSE;
lpMruMenu->wNbItemFill--;
for (i=wItem;i<lpMruMenu->wNbItemFill;i++)
lstrcpy(lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),
lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i+1)));
return TRUE;
}
//*************************************************************
//
// PlaceMenuMRUItem()
//
// Purpose:
// Add MRU at the end of a menu
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// HMENU hMenu - Handle of menu where MRU must be added
// UINT uiItem - Item of menu entry where MRU must be added
//
// Return: void
//
//
// Comments:
// Used MRU is modified, for refresh the File menu
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem)
{
int i;
WORD wNbShow;
if (hMenu == NULL)
return;
// remove old MRU in menu
for (i=0;i<=(int)(lpMruMenu->wNbLruMenu);i++)
RemoveMenu(hMenu,i+lpMruMenu->wIdMru,MF_BYCOMMAND);
if (lpMruMenu->wNbItemFill == 0)
return;
// If they are item, insert a separator before the files
InsertMenu(hMenu,uiItem,MF_SEPARATOR,lpMruMenu->wIdMru,NULL);
wNbShow = min(lpMruMenu->wNbItemFill,lpMruMenu->wNbLruShow);
for (i=(int)wNbShow-1;i>=0;i--)
{
LPSTR lpTxt;
if (lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20))
{
wsprintf(lpTxt,"&%lu %s",
(DWORD)(i+1),lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem*(UINT)i));
InsertMenu(hMenu,(((WORD)i)!=(wNbShow-1)) ? (lpMruMenu->wIdMru+i+2) : lpMruMenu->wIdMru,
MF_STRING,lpMruMenu->wIdMru+i+1,lpTxt);
GlobalFreePtr(lpTxt);
}
}
}
///////////////////////////////////////////
//*************************************************************
//
// SaveMruInIni()
//
// Purpose:
// Save MRU in a private .INI
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszSection - Points to a null-terminated string containing
// the name of the section
// LPSTR lpszFile - Points to a null-terminated string that names
// the initialization file.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// See WritePrivateProfileString API for more info on lpszSection and lpszFile
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL SaveMruInIni(LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile)
{
LPSTR lpTxt;
WORD i;
lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
if (lpTxt == NULL)
return FALSE;
for (i=0;i<lpMruMenu->wNbLruMenu;i++)
{
char szEntry[16];
wsprintf(szEntry,"File%lu",(DWORD)i+1);
if (!GetMenuItem(lpMruMenu,i,FALSE,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))
*lpTxt = '\0';
WritePrivateProfileString(lpszSection,szEntry,lpTxt,lpszFile);
}
GlobalFreePtr(lpTxt);
WritePrivateProfileString(NULL,NULL,NULL,lpszFile); // flush cache
return TRUE;
}
//*************************************************************
//
// LoadMruInIni()
//
// Purpose:
// Load MRU from a private .INI
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszSection - Points to a null-terminated string containing
// the name of the section
// LPSTR lpszFile - Points to a null-terminated string that names
// the initialization file.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// See GetPrivateProfileString API for more info on lpszSection and lpszFile
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL LoadMruInIni(LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile)
{
LPSTR lpTxt;
WORD i;
lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
if (lpTxt == NULL)
return FALSE;
for (i=0;i<lpMruMenu->wNbLruMenu;i++)
{
char szEntry[16];
wsprintf(szEntry,"File%lu",(DWORD)i+1);
GetPrivateProfileString(lpszSection,szEntry,"",lpTxt,
lpMruMenu->wMaxSizeLruItem + 10,lpszFile);
if (*lpTxt == '\0')
break;
SetMenuItem(lpMruMenu,i,lpTxt);
}
GlobalFreePtr(lpTxt);
return TRUE;
}
#ifdef WIN32
BOOL IsWin395OrHigher(void)
{
WORD wVer;
wVer = LOWORD(GetVersion());
wVer = (((WORD)LOBYTE(wVer)) << 8) | (WORD)HIBYTE(wVer);
return (wVer >= 0x035F); // 5F = 95 dec
}
//*************************************************************
//
// SaveMruInReg()
//
// Purpose:
// Save MRU in the registry
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszKey - Points to a null-terminated string
// specifying the name of a key that
// this function opens or creates.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Win32 function designed for Windows NT and Windows 95
// See RegCreateKeyEx API for more info on lpszKey
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL SaveMruInReg(LPMRUMENU lpMruMenu,LPSTR lpszKey)
{
LPSTR lpTxt;
WORD i;
HKEY hCurKey;
DWORD dwDisp;
lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
if (lpTxt == NULL)
return FALSE;
RegCreateKeyEx(HKEY_CURRENT_USER,lpszKey,0,NULL,
REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hCurKey,&dwDisp);
for (i=0;i<lpMruMenu->wNbLruMenu;i++)
{
char szEntry[16];
wsprintf(szEntry,"File%lu",(DWORD)i+1);
if (!GetMenuItem(lpMruMenu,i,FALSE,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))
*lpTxt = '\0';
RegSetValueEx(hCurKey,szEntry,0,REG_SZ,lpTxt,lstrlen(lpTxt));
}
RegCloseKey(hCurKey);
GlobalFreePtr(lpTxt);
return TRUE;
}
//*************************************************************
//
// LoadMruInReg()
//
// Purpose:
// Load MRU from the registry
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszKey - Points to a null-terminated string
// specifying the name of a key that
// this function opens or creates.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Win32 function designed for Windows NT and Windows 95
// See RegOpenKeyEx API for more info on lpszKey
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL LoadMruInReg(LPMRUMENU lpMruMenu,LPSTR lpszKey)
{
LPSTR lpTxt;
WORD i;
HKEY hCurKey;
DWORD dwType;
lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
if (lpTxt == NULL)
return FALSE;
RegOpenKeyEx(HKEY_CURRENT_USER,lpszKey,0,KEY_READ,&hCurKey);
for (i=0;i<lpMruMenu->wNbLruMenu;i++)
{
char szEntry[16];
DWORD dwSizeBuf;
wsprintf(szEntry,"File%lu",(DWORD)i+1);
*lpTxt = '\0';
dwSizeBuf = lpMruMenu->wMaxSizeLruItem + 10;
RegQueryValueEx(hCurKey,szEntry,NULL,&dwType,(LPBYTE)lpTxt,&dwSizeBuf);
*(lpTxt+dwSizeBuf)='\0';
if (*lpTxt == '\0')
break;
SetMenuItem(lpMruMenu,i,lpTxt);
}
RegCloseKey(hCurKey);
GlobalFreePtr(lpTxt);
return TRUE;
}
//*************************************************************
//
// GetWin32Kind()
//
// Purpose:
// Get the Win32 platform
//
// Parameters:
//
// Return: (WIN32KIND)
// WINNT - Run under Windows NT
// WIN32S - Run under Windows 3.1x + Win32s
// WIN95ORGREATHER - Run under Windows 95
//
//
// Comments:
// Win32 function designed for Windows NT and Windows 95
// See RegOpenKeyEx API for more info on lpszKey
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
WIN32KIND GetWin32Kind()
{
BOOL IsWin395OrHigher(void);
WORD wVer;
if ((GetVersion() & 0x80000000) == 0)
return WINNT;
wVer = LOWORD(GetVersion());
wVer = (((WORD)LOBYTE(wVer)) << 8) | (WORD)HIBYTE(wVer);
if (wVer >= 0x035F)
return WIN95ORGREATHER;
else
return WIN32S;
}
#endif

101
qe4/mru.h
View file

@ -1,101 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//*************************************************************
// File name: mru.h
//
// Description:
//
// Header for MRU support
//
// Development Team:
//
// Gilles Vollant (100144.2636@compuserve.com)
//
//*************************************************************
#ifndef __MRU_H__
#define __MRU_H__
#define NBMRUMENUSHOW 6 // Default number of MRU showed in the menu File
#define NBMRUMENU 9 // Default number of MRU stored
#define IDMRU 8000 // Default First ID of MRU
#ifdef OFS_MAXPATHNAME
#define MAXSIZEMRUITEM OFS_MAXPATHNAME
#else
#define MAXSIZEMRUITEM 128 // Default max size of an entry
#endif
typedef struct
{
WORD wNbItemFill;
WORD wNbLruShow;
WORD wNbLruMenu;
WORD wMaxSizeLruItem;
WORD wIdMru;
LPSTR lpMRU;
} MRUMENU;
typedef MRUMENU FAR * LPMRUMENU;
#ifdef __cplusplus
LPMRUMENU CreateMruMenu (WORD wNbLruShowInit=NBMRUMENUSHOW,
WORD wNbLruMenuInit=NBMRUMENU,
WORD wMaxSizeLruItemInit=MAXSIZEMRUITEM,
WORD wIdMruInit=IDMRU);
#else
LPMRUMENU CreateMruMenu (WORD wNbLruShowInit,
WORD wNbLruMenuInit,
WORD wMaxSizeLruItemInit,
WORD wIdMruInit);
#endif
LPMRUMENU CreateMruMenuDefault();
void DeleteMruMenu (LPMRUMENU lpMruMenu);
void SetNbLruShow (LPMRUMENU lpMruMenu,WORD wNbLruShowInit);
BOOL SetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,
LPSTR lpItem);
BOOL GetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,
BOOL fIDMBased,LPSTR lpItem,UINT uiSize);
BOOL DelMenuItem (LPMRUMENU lpMruMenu,WORD wItem,BOOL fIDMBased);
void AddNewItem (LPMRUMENU lpMruMenu,LPSTR lpItem);
void PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem);
BOOL SaveMruInIni (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile);
BOOL LoadMruInIni (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile);
#ifdef WIN32
BOOL SaveMruInReg (LPMRUMENU lpMruMenu,LPSTR lpszKey);
BOOL LoadMruInReg (LPMRUMENU lpMruMenu,LPSTR lpszKey);
typedef enum
{
WIN32S,
WINNT,
WIN95ORGREATHER
} WIN32KIND;
WIN32KIND GetWin32Kind();
#endif
//////////////////////////////////////////////////////////////
#endif

View file

@ -1,141 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
char token[MAXTOKEN];
qboolean unget;
char *script_p;
int scriptline;
void StartTokenParsing (char *data)
{
scriptline = 1;
script_p = data;
unget = false;
}
qboolean GetToken (qboolean crossline)
{
char *token_p;
if (unget) // is a token allready waiting?
return true;
//
// skip space
//
skipspace:
while (*script_p <= 32)
{
if (!*script_p)
{
if (!crossline)
Error ("Line %i is incomplete",scriptline);
return false;
}
if (*script_p++ == '\n')
{
if (!crossline)
Error ("Line %i is incomplete",scriptline);
scriptline++;
}
}
if (script_p[0] == '/' && script_p[1] == '/') // comment field
{
if (!crossline)
Error ("Line %i is incomplete\n",scriptline);
while (*script_p++ != '\n')
if (!*script_p)
{
if (!crossline)
Error ("Line %i is incomplete",scriptline);
return false;
}
goto skipspace;
}
//
// copy token
//
token_p = token;
if (*script_p == '"')
{
script_p++;
while ( *script_p != '"' )
{
if (!*script_p)
Error ("EOF inside quoted token");
*token_p++ = *script_p++;
if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i",scriptline);
}
script_p++;
}
else while ( *script_p > 32 )
{
*token_p++ = *script_p++;
if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i",scriptline);
}
*token_p = 0;
return true;
}
void UngetToken (void)
{
unget = true;
}
/*
==============
TokenAvailable
Returns true if there is another token on the line
==============
*/
qboolean TokenAvailable (void)
{
char *search_p;
search_p = script_p;
while ( *search_p <= 32)
{
if (*search_p == '\n')
return false;
if (*search_p == 0)
return false;
search_p++;
}
if (*search_p == ';')
return false;
return true;
}

View file

@ -1,34 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// parse.h -- text file parsing routines
#define MAXTOKEN 1024
extern char token[MAXTOKEN];
extern int scriptline;
void StartTokenParsing (char *data);
qboolean GetToken (qboolean crossline);
void UngetToken (void);
qboolean TokenAvailable (void);

View file

@ -1,155 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
#define MAX_POINTFILE 8192
static vec3_t s_pointvecs[MAX_POINTFILE];
static int s_num_points, s_check_point;
void Pointfile_Delete (void)
{
char name[1024];
strcpy (name, currentmap);
StripExtension (name);
strcat (name, ".lin");
remove(name);
}
// advance camera to next point
void Pointfile_Next (void)
{
vec3_t dir;
if (s_check_point >= s_num_points-2)
{
Sys_Status ("End of pointfile", 0);
return;
}
s_check_point++;
VectorCopy (s_pointvecs[s_check_point], camera.origin);
VectorCopy (s_pointvecs[s_check_point], g_qeglobals.d_xy.origin);
VectorSubtract (s_pointvecs[s_check_point+1], camera.origin, dir);
VectorNormalize (dir);
camera.angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
camera.angles[0] = asin (dir[2])*180/3.14159;
Sys_UpdateWindows (W_ALL);
}
// advance camera to previous point
void Pointfile_Prev (void)
{
vec3_t dir;
if ( s_check_point == 0)
{
Sys_Status ("Start of pointfile", 0);
return;
}
s_check_point--;
VectorCopy (s_pointvecs[s_check_point], camera.origin);
VectorCopy (s_pointvecs[s_check_point], g_qeglobals.d_xy.origin);
VectorSubtract (s_pointvecs[s_check_point+1], camera.origin, dir);
VectorNormalize (dir);
camera.angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
camera.angles[0] = asin (dir[2])*180/3.14159;
Sys_UpdateWindows (W_ALL);
}
void Pointfile_Check (void)
{
char name[1024];
FILE *f;
vec3_t v;
strcpy (name, currentmap);
StripExtension (name);
strcat (name, ".lin");
f = fopen (name, "r");
if (!f)
return;
Sys_Printf ("Reading pointfile %s\n", name);
if (!g_qeglobals.d_pointfile_display_list)
g_qeglobals.d_pointfile_display_list = glGenLists(1);
s_num_points = 0;
glNewList (g_qeglobals.d_pointfile_display_list, GL_COMPILE);
glColor3f (1, 0, 0);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glLineWidth (4);
glBegin(GL_LINE_STRIP);
do
{
if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
break;
if (s_num_points < MAX_POINTFILE)
{
VectorCopy (v, s_pointvecs[s_num_points]);
s_num_points++;
}
glVertex3fv (v);
} while (1);
glEnd();
glLineWidth (1);
glEndList ();
s_check_point = 0;
fclose (f);
Pointfile_Next ();
}
void Pointfile_Draw( void )
{
int i;
glColor3f( 1.0F, 0.0F, 0.0F );
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glLineWidth (4);
glBegin(GL_LINE_STRIP);
for ( i = 0; i < s_num_points; i++ )
{
glVertex3fv( s_pointvecs[i] );
}
glEnd();
glLineWidth( 1 );
}
void Pointfile_Clear (void)
{
if (!g_qeglobals.d_pointfile_display_list)
return;
glDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
g_qeglobals.d_pointfile_display_list = 0;
Sys_UpdateWindows (W_ALL);
}

BIN
qe4/q.bmp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

451
qe4/qe3.c
View file

@ -1,451 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
QEGlobals_t g_qeglobals;
void QE_CheckOpenGLForErrors(void)
{
int i;
while ( ( i = glGetError() ) != GL_NO_ERROR )
{
char buffer[100];
sprintf( buffer, "OpenGL Error: %s", gluErrorString( i ) );
MessageBox( g_qeglobals.d_hwndMain, buffer , "QuakeEd Error", MB_OK | MB_ICONEXCLAMATION );
exit( 1 );
}
}
char *ExpandReletivePath (char *p)
{
static char temp[1024];
char *base;
if (!p || !p[0])
return NULL;
if (p[0] == '/' || p[0] == '\\')
return p;
base = ValueForKey(g_qeglobals.d_project_entity, "basepath");
sprintf (temp, "%s/%s", base, p);
return temp;
}
void *qmalloc (int size)
{
void *b;
b = malloc(size);
memset (b, 0, size);
return b;
}
char *copystring (char *s)
{
char *b;
b = malloc(strlen(s)+1);
strcpy (b,s);
return b;
}
/*
===============
QE_CheckAutoSave
If five minutes have passed since making a change
and the map hasn't been saved, save it out.
===============
*/
void QE_CheckAutoSave( void )
{
static clock_t s_start;
clock_t now;
now = clock();
if ( modified != 1 || !s_start)
{
s_start = now;
return;
}
if ( now - s_start > ( CLOCKS_PER_SEC * 60 * QE_AUTOSAVE_INTERVAL ) )
{
Sys_Printf ("Autosaving...\n");
Sys_Status ("Autosaving...", 0 );
Map_SaveFile (ValueForKey(g_qeglobals.d_project_entity, "autosave"), false);
Sys_Status ("Autosaving...Saved.", 0 );
modified = 2;
s_start = now;
}
}
/*
===========
QE_LoadProject
===========
*/
qboolean QE_LoadProject (char *projectfile)
{
char *data;
Sys_Printf ("QE_LoadProject (%s)\n", projectfile);
if ( LoadFileNoCrash (projectfile, (void *)&data) == -1)
return false;
StartTokenParsing (data);
g_qeglobals.d_project_entity = Entity_Parse (true);
if (!g_qeglobals.d_project_entity)
Error ("Couldn't parse %s", projectfile);
free (data);
Eclass_InitForSourceDirectory (ValueForKey (g_qeglobals.d_project_entity, "entitypath"));
FillClassList (); // list in entity window
Map_New ();
FillTextureMenu ();
FillBSPMenu ();
return true;
}
/*
===========
QE_KeyDown
===========
*/
#define SPEED_MOVE 32
#define SPEED_TURN 22.5
qboolean QE_KeyDown (int key)
{
switch (key)
{
case 'K':
PostMessage( g_qeglobals.d_hwndMain, WM_COMMAND, ID_MISC_SELECTENTITYCOLOR, 0 );
break;
case VK_UP:
VectorMA (camera.origin, SPEED_MOVE, camera.forward, camera.origin);
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
break;
case VK_DOWN:
VectorMA (camera.origin, -SPEED_MOVE, camera.forward, camera.origin);
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
break;
case VK_LEFT:
camera.angles[1] += SPEED_TURN;
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
break;
case VK_RIGHT:
camera.angles[1] -= SPEED_TURN;
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
break;
case 'D':
camera.origin[2] += SPEED_MOVE;
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY|W_Z_OVERLAY);
break;
case 'C':
camera.origin[2] -= SPEED_MOVE;
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY|W_Z_OVERLAY);
break;
case 'A':
camera.angles[0] += SPEED_TURN;
if (camera.angles[0] > 85)
camera.angles[0] = 85;
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
break;
case 'Z':
camera.angles[0] -= SPEED_TURN;
if (camera.angles[0] < -85)
camera.angles[0] = -85;
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
break;
case VK_COMMA:
VectorMA (camera.origin, -SPEED_MOVE, camera.right, camera.origin);
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
break;
case VK_PERIOD:
VectorMA (camera.origin, SPEED_MOVE, camera.right, camera.origin);
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
break;
case '0':
g_qeglobals.d_showgrid = !g_qeglobals.d_showgrid;
PostMessage( g_qeglobals.d_hwndXY, WM_PAINT, 0, 0 );
break;
case '1':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_GRID_1, 0);
break;
case '2':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_GRID_2, 0);
break;
case '3':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_GRID_4, 0);
break;
case '4':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_GRID_8, 0);
break;
case '5':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_GRID_16, 0);
break;
case '6':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_GRID_32, 0);
break;
case '7':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_GRID_64, 0);
break;
case 'E':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_SELECTION_DRAGEDGES, 0);
break;
case 'V':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_SELECTION_DRAGVERTECIES, 0);
break;
case 'N':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_ENTITY, 0);
break;
case 'O':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_CONSOLE, 0);
break;
case 'T':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_TEXTURE, 0);
break;
case 'S':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_TEXTURES_INSPECTOR, 0);
break;
case ' ':
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_SELECTION_CLONE, 0);
break;
case VK_BACK:
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_SELECTION_DELETE, 0);
break;
case VK_ESCAPE:
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_SELECTION_DESELECT, 0);
break;
case VK_END:
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_CENTER, 0);
break;
case VK_DELETE:
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_ZOOMIN, 0);
break;
case VK_INSERT:
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_ZOOMOUT, 0);
break;
case VK_NEXT:
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_DOWNFLOOR, 0);
break;
case VK_PRIOR:
PostMessage (g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_UPFLOOR, 0);
break;
default:
return false;
}
return true;
}
/*
===============
ConnectEntities
Sets target / targetname on the two entities selected
from the first selected to the secon
===============
*/
void ConnectEntities (void)
{
entity_t *e1, *e2, *e;
char *target, *tn;
int maxtarg, targetnum;
char newtarg[32];
if (g_qeglobals.d_select_count != 2)
{
Sys_Status ("Must have two brushes selected.", 0);
Sys_Beep ();
return;
}
e1 = g_qeglobals.d_select_order[0]->owner;
e2 = g_qeglobals.d_select_order[1]->owner;
if (e1 == world_entity || e2 == world_entity)
{
Sys_Status ("Can't connect to the world.", 0);
Sys_Beep ();
return;
}
if (e1 == e2)
{
Sys_Status ("Brushes are from same entity.", 0);
Sys_Beep ();
return;
}
target = ValueForKey (e1, "target");
if (target && target[0])
strcpy (newtarg, target);
else
{
target = ValueForKey (e2, "targetname");
if (target && target[0])
strcpy (newtarg, target);
else
{
// make a unique target value
maxtarg = 0;
for (e=entities.next ; e != &entities ; e=e->next)
{
tn = ValueForKey (e, "targetname");
if (tn && tn[0])
{
targetnum = atoi(tn+1);
if (targetnum > maxtarg)
maxtarg = targetnum;
}
}
sprintf (newtarg, "t%i", maxtarg+1);
}
}
SetKeyValue (e1, "target", newtarg);
SetKeyValue (e2, "targetname", newtarg);
Sys_UpdateWindows (W_XY | W_CAMERA);
Select_Deselect();
Select_Brush (g_qeglobals.d_select_order[1]);
}
qboolean QE_SingleBrush (void)
{
if ( (selected_brushes.next == &selected_brushes)
|| (selected_brushes.next->next != &selected_brushes) )
{
Sys_Printf ("Error: you must have a single brush selected\n");
return false;
}
if (selected_brushes.next->owner->eclass->fixedsize)
{
Sys_Printf ("Error: you cannot manipulate fixed size entities\n");
return false;
}
return true;
}
void QE_Init (void)
{
/*
** initialize variables
*/
g_qeglobals.d_gridsize = 8;
g_qeglobals.d_showgrid = true;
/*
** other stuff
*/
Texture_Init ();
Cam_Init ();
XY_Init ();
Z_Init ();
}
void QE_ConvertDOSToUnixName( char *dst, const char *src )
{
while ( *src )
{
if ( *src == '\\' )
*dst = '/';
else
*dst = *src;
dst++; src++;
}
*dst = 0;
}
int g_numbrushes, g_numentities;
void QE_CountBrushesAndUpdateStatusBar( void )
{
static int s_lastbrushcount, s_lastentitycount;
static qboolean s_didonce;
entity_t *e;
brush_t *b, *next;
g_numbrushes = 0;
g_numentities = 0;
if ( active_brushes.next != NULL )
{
for ( b = active_brushes.next ; b != NULL && b != &active_brushes ; b=next)
{
next = b->next;
if (b->brush_faces )
{
if ( !b->owner->eclass->fixedsize)
g_numbrushes++;
else
g_numentities++;
}
}
}
if ( entities.next != NULL )
{
for ( e = entities.next ; e != &entities && g_numentities != MAX_MAP_ENTITIES ; e = e->next)
{
g_numentities++;
}
}
if ( ( ( g_numbrushes != s_lastbrushcount ) || ( g_numentities != s_lastentitycount ) ) || ( !s_didonce ) )
{
Sys_UpdateStatusBar();
s_lastbrushcount = g_numbrushes;
s_lastentitycount = g_numentities;
s_didonce = true;
}
}

306
qe4/qe3.h
View file

@ -1,306 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __QE3_H__
#define __QE3_H__
// disable data conversion warnings for gl
#pragma warning(disable : 4244) // MIPS
#pragma warning(disable : 4136) // X86
#pragma warning(disable : 4051) // ALPHA
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
#include "glingr.h"
#include <math.h>
#include <stdlib.h>
#include "cmdlib.h"
#include "mathlib.h"
#include "parse.h"
#include "lbmlib.h"
#include <commctrl.h>
#include "afxres.h"
#include "resource.h"
#include "qedefs.h"
typedef struct
{
vec3_t normal;
double dist;
int type;
} plane_t;
#include "qfiles.h"
#include "textures.h"
#include "brush.h"
#include "entity.h"
#include "map.h"
#include "select.h"
#include "camera.h"
#include "xy.h"
#include "z.h"
#include "mru.h"
typedef struct
{
int p1, p2;
face_t *f1, *f2;
} pedge_t;
typedef struct
{
int iSize;
int iTexMenu; // nearest, linear, etc
float fGamma; // gamma for textures
char szProject[256]; // last project loaded
vec3_t colors[COLOR_LAST];
qboolean show_names,
show_coordinates;
int exclude;
} SavedInfo_t;
//
// system functions
//
void Sys_UpdateStatusBar( void );
void Sys_UpdateWindows (int bits);
void Sys_Beep (void);
void Sys_ClearPrintf (void);
void Sys_Printf (char *text, ...);
double Sys_DoubleTime (void);
void Sys_GetCursorPos (int *x, int *y);
void Sys_SetCursorPos (int x, int y);
void Sys_SetTitle (char *text);
void Sys_BeginWait (void);
void Sys_EndWait (void);
void Sys_Status(const char *psz, int part);
/*
** most of the QE globals are stored in this structure
*/
typedef struct
{
qboolean d_showgrid;
int d_gridsize;
int d_num_entities;
entity_t *d_project_entity;
float d_new_brush_bottom_z,
d_new_brush_top_z;
HINSTANCE d_hInstance;
HGLRC d_hglrcBase;
HDC d_hdcBase;
HWND d_hwndMain;
HWND d_hwndCamera;
HWND d_hwndEdit;
HWND d_hwndEntity;
HWND d_hwndTexture;
HWND d_hwndXY;
HWND d_hwndZ;
HWND d_hwndStatus;
vec3_t d_points[MAX_POINTS];
int d_numpoints;
pedge_t d_edges[MAX_EDGES];
int d_numedges;
int d_num_move_points;
float *d_move_points[1024];
qtexture_t *d_qtextures;
texturewin_t d_texturewin;
int d_pointfile_display_list;
xy_t d_xy;
LPMRUMENU d_lpMruMenu;
SavedInfo_t d_savedinfo;
int d_workcount;
// connect entities uses the last two brushes selected
int d_select_count;
brush_t *d_select_order[2];
vec3_t d_select_translate; // for dragging w/o making new display lists
select_t d_select_mode;
int d_font_list;
int d_parsed_brushes;
qboolean show_blocks;
} QEGlobals_t;
void *qmalloc (int size);
char *copystring (char *s);
char *ExpandReletivePath (char *p);
void Pointfile_Delete (void);
void Pointfile_Check (void);
void Pointfile_Next (void);
void Pointfile_Prev (void);
void Pointfile_Clear (void);
void Pointfile_Draw( void );
void Pointfile_Load( void );
//
// drag.c
//
void Drag_Begin (int x, int y, int buttons,
vec3_t xaxis, vec3_t yaxis,
vec3_t origin, vec3_t dir);
void Drag_MouseMoved (int x, int y, int buttons);
void Drag_MouseUp (void);
//
// csg.c
//
void CSG_MakeHollow (void);
void CSG_Subtract (void);
//
// vertsel.c
//
void SetupVertexSelection (void);
void SelectEdgeByRay (vec3_t org, vec3_t dir);
void SelectVertexByRay (vec3_t org, vec3_t dir);
void ConnectEntities (void);
extern int update_bits;
extern int screen_width;
extern int screen_height;
extern HANDLE bsp_process;
char *TranslateString (char *buf);
void ProjectDialog (void);
void FillTextureMenu (void);
void FillBSPMenu (void);
BOOL CALLBACK Win_Dialog (
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
//
// win_cam.c
//
void WCam_Create (HINSTANCE hInstance);
//
// win_xy.c
//
void WXY_Create (HINSTANCE hInstance);
//
// win_z.c
//
void WZ_Create (HINSTANCE hInstance);
//
// win_ent.c
//
//
// win_main.c
//
void Main_Create (HINSTANCE hInstance);
extern BOOL SaveWindowState(HWND hWnd, const char *pszName);
extern BOOL LoadWindowState(HWND hWnd, const char *pszName);
extern BOOL SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize);
extern BOOL loadRegistryInfo(const char *pszName, void *pvBuf, long *plSize);
//
// entityw.c
//
BOOL CreateEntityWindow(HINSTANCE hInstance);
void FillClassList (void);
BOOL UpdateEntitySel(eclass_t *pec);
void SetInspectorMode(int iType);
int DrawTexControls(HWND hWnd);
void SetSpawnFlags(void);
void GetSpawnFlags(void);
void SetKeyValuePairs(void);
extern void BuildGammaTable(float g);
// win_dlg.c
void DoGamma(void);
void DoFind(void);
void DoRotate(void);
void DoSides(void);
void DoAbout(void);
void DoSurface(void);
/*
** QE function declarations
*/
void QE_CheckAutoSave( void );
void QE_ConvertDOSToUnixName( char *dst, const char *src );
void QE_CountBrushesAndUpdateStatusBar( void );
void QE_CheckOpenGLForErrors(void);
void QE_ExpandBspString (char *bspaction, char *out, char *mapname);
void QE_Init (void);
qboolean QE_KeyDown (int key);
qboolean QE_LoadProject (char *projectfile);
qboolean QE_SingleBrush (void);
/*
** QE Win32 function declarations
*/
int QEW_SetupPixelFormat(HDC hDC, qboolean zbuffer );
void QEW_StopGL( HWND hWnd, HGLRC hGLRC, HDC hDC );
/*
** extern declarations
*/
extern QEGlobals_t g_qeglobals;
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,117 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __QEDEFS_H__
#define __QEDEFS_H__
#define QE_VERSION 0x0401
#define QE3_STYLE (WS_OVERLAPPED| WS_CAPTION | WS_THICKFRAME | \
/* WS_MINIMIZEBOX | */ WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | \
WS_CLIPCHILDREN | WS_CHILD)
#define QE_AUTOSAVE_INTERVAL 5 // number of minutes between autosaves
#define CAMERA_WINDOW_CLASS "QCamera"
#define XY_WINDOW_CLASS "QXY"
#define Z_WINDOW_CLASS "QZ"
#define ENT_WINDOW_CLASS "QENT"
#define ZWIN_WIDTH 40
#define CWIN_SIZE (0.4)
#define MAX_EDGES 256
#define MAX_POINTS 512
#define CMD_TEXTUREWAD 60000
#define CMD_BSPCOMMAND 61000
#define PITCH 0
#define YAW 1
#define ROLL 2
#define QE_TIMER0 1
#define PLANE_X 0
#define PLANE_Y 1
#define PLANE_Z 2
#define PLANE_ANYX 3
#define PLANE_ANYY 4
#define PLANE_ANYZ 5
#define ON_EPSILON 0.01
#define KEY_FORWARD 1
#define KEY_BACK 2
#define KEY_TURNLEFT 4
#define KEY_TURNRIGHT 8
#define KEY_LEFT 16
#define KEY_RIGHT 32
#define KEY_LOOKUP 64
#define KEY_LOOKDOWN 128
#define KEY_UP 256
#define KEY_DOWN 512
// xy.c
#define EXCLUDE_LIGHTS 1
#define EXCLUDE_ENT 2
#define EXCLUDE_PATHS 4
#define EXCLUDE_WATER 8
#define EXCLUDE_WORLD 16
#define EXCLUDE_CLIP 32
#define EXCLUDE_DETAIL 64
//
// menu indexes for modifying menus
//
#define MENU_VIEW 2
#define MENU_BSP 4
#define MENU_TEXTURE 6
// odd things not in windows header...
#define VK_COMMA 188
#define VK_PERIOD 190
/*
** window bits
*/
#define W_CAMERA 0x0001
#define W_XY 0x0002
#define W_XY_OVERLAY 0x0004
#define W_Z 0x0008
#define W_TEXTURE 0x0010
#define W_Z_OVERLAY 0x0020
#define W_CONSOLE 0x0040
#define W_ENTITY 0x0080
#define W_ALL 0xFFFFFFFF
#define COLOR_TEXTUREBACK 0
#define COLOR_GRIDBACK 1
#define COLOR_GRIDMINOR 2
#define COLOR_GRIDMAJOR 3
#define COLOR_CAMERABACK 4
#define COLOR_ENTITY 5
#define COLOR_LAST 6
#endif

View file

@ -1,389 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
// qfiles.h: quake file formats
// This file must be identical in the quake and utils directories
//
/*
========================================================================
.MD2 triangle model file format
========================================================================
*/
#define IDALIASHEADER (('2'<<24)+('P'<<16)+('D'<<8)+'I')
#define ALIAS_VERSION 8
#define MAX_TRIANGLES 4096
#define MAX_VERTS 2048
#define MAX_FRAMES 512
#define MAX_MD2SKINS 32
#define MAX_SKINNAME 64
typedef struct
{
short s;
short t;
} dstvert_t;
typedef struct
{
short index_xyz[3];
short index_st[3];
} dtriangle_t;
typedef struct
{
byte v[3]; // scaled byte to fit in frame mins/maxs
byte lightnormalindex;
} dtrivertx_t;
typedef struct
{
float scale[3]; // multiply byte verts by this
float translate[3]; // then add this
char name[16]; // frame name from grabbing
dtrivertx_t verts[1]; // variable sized
} daliasframe_t;
// the glcmd format:
// a positive integer starts a tristrip command, followed by that many
// vertex structures.
// a negative integer starts a trifan command, followed by -x vertexes
// a zero indicates the end of the command list.
// a vertex consists of a floating point s, a floating point t,
// and an integer vertex index.
typedef struct
{
int ident;
int version;
int skinwidth;
int skinheight;
int framesize; // byte size of each frame
int num_skins;
int num_xyz;
int num_st; // greater than num_xyz for seams
int num_tris;
int num_glcmds; // dwords in strip/fan command list
int num_frames;
int ofs_skins; // each skin is a MAX_SKINNAME string
int ofs_st; // byte offset from start for stverts
int ofs_tris; // offset for dtriangles
int ofs_frames; // offset for first frame
int ofs_glcmds;
int ofs_end; // end of file
} dmdl_t;
/*
========================================================================
.SP2 sprite file format
========================================================================
*/
#define IDSPRITEHEADER (('2'<<24)+('S'<<16)+('D'<<8)+'I')
// little-endian "IDS2"
#define SPRITE_VERSION 2
typedef struct
{
int width, height;
int origin_x, origin_y; // raster coordinates inside pic
char name[MAX_SKINNAME]; // name of pcx file
} dsprframe_t;
typedef struct {
int ident;
int version;
int numframes;
dsprframe_t frames[1]; // variable sized
} dsprite_t;
/*
==============================================================================
.WAL texture file format
==============================================================================
*/
#define MIPLEVELS 4
typedef struct miptex_s
{
char name[32];
unsigned width, height;
unsigned offsets[MIPLEVELS]; // four mip maps stored
char animname[32]; // next frame in animation chain
int flags;
int contents;
int value;
} miptex_t;
/*
==============================================================================
.BSP file format
==============================================================================
*/
#define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I')
// little-endian "IBSP"
#define BSPVERSION 36
// upper design bounds
// leaffaces, leafbrushes, planes, and verts are still bounded by
// 16 bit short limits
#define MAX_MAP_MODELS 1024
#define MAX_MAP_BRUSHES 8192
#define MAX_MAP_ENTITIES 2048
#define MAX_MAP_ENTSTRING 0x20000
#define MAX_MAP_TEXINFO 8192
#define MAX_MAP_PLANES 65536
#define MAX_MAP_NODES 65536
#define MAX_MAP_BRUSHSIDES 65536
#define MAX_MAP_LEAFS 65536
#define MAX_MAP_VERTS 65536
#define MAX_MAP_FACES 65536
#define MAX_MAP_LEAFFACES 65536
#define MAX_MAP_LEAFBRUSHES 65536
#define MAX_MAP_PORTALS 65536
#define MAX_MAP_EDGES 128000
#define MAX_MAP_SURFEDGES 256000
#define MAX_MAP_LIGHTING 0x200000
#define MAX_MAP_VISIBILITY 0x100000
// key / value pair sizes
#define MAX_KEY 32
#define MAX_VALUE 1024
//=============================================================================
typedef struct
{
int fileofs, filelen;
} lump_t;
#define LUMP_ENTITIES 0
#define LUMP_PLANES 1
#define LUMP_VERTEXES 2
#define LUMP_VISIBILITY 3
#define LUMP_NODES 4
#define LUMP_TEXINFO 5
#define LUMP_FACES 6
#define LUMP_LIGHTING 7
#define LUMP_LEAFS 8
#define LUMP_LEAFFACES 9
#define LUMP_LEAFBRUSHES 10
#define LUMP_EDGES 11
#define LUMP_SURFEDGES 12
#define LUMP_MODELS 13
#define LUMP_BRUSHES 14
#define LUMP_BRUSHSIDES 15
#define LUMP_POP 16
#define HEADER_LUMPS 17
typedef struct
{
int ident;
int version;
lump_t lumps[HEADER_LUMPS];
} dheader_t;
typedef struct
{
float mins[3], maxs[3];
float origin[3]; // for sounds or lights
int headnode;
int firstface, numfaces; // submodels just draw faces
// without walking the bsp tree
} dmodel_t;
typedef struct
{
float point[3];
} dvertex_t;
// 0-2 are axial planes
#define PLANE_X 0
#define PLANE_Y 1
#define PLANE_Z 2
// 3-5 are non-axial planes snapped to the nearest
#define PLANE_ANYX 3
#define PLANE_ANYY 4
#define PLANE_ANYZ 5
// planes (x&~1) and (x&~1)+1 are allways opposites
typedef struct
{
float normal[3];
float dist;
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
} dplane_t;
// contents flags are seperate bits
// a given brush can contribute multiple content bits
// multiple brushes can be in a single leaf
// lower bits are stronger, and will eat weaker brushes completely
#define CONTENTS_SOLID 1 // an eye is never valid in a solid
#define CONTENTS_WINDOW 2 // translucent, but not watery
#define CONTENTS_AUX 4
#define CONTENTS_LAVA 8
#define CONTENTS_SLIME 16
#define CONTENTS_WATER 32
#define CONTENTS_MIST 64
#define LAST_VISIBLE_CONTENTS 64
// remaining contents are non-visible, and don't eat brushes
#define CONTENTS_PLAYERCLIP 0x10000
#define CONTENTS_MONSTERCLIP 0x20000
// currents can be added to any other contents, and may be mixed
#define CONTENTS_CURRENT_0 0x40000
#define CONTENTS_CURRENT_90 0x80000
#define CONTENTS_CURRENT_180 0x100000
#define CONTENTS_CURRENT_270 0x200000
#define CONTENTS_CURRENT_UP 0x400000
#define CONTENTS_CURRENT_DOWN 0x800000
#define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
#define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
#define CONTENTS_DEADMONSTER 0x4000000
#define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
#define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
typedef struct
{
int planenum;
int children[2]; // negative numbers are -(leafs+1), not nodes
short mins[3]; // for frustom culling
short maxs[3];
unsigned short firstface;
unsigned short numfaces; // counting both sides
} dnode_t;
typedef struct texinfo_s
{
float vecs[2][4]; // [s/t][xyz offset]
int flags; // miptex flags + overrides
int value; // light emission, etc
char texture[32]; // texture name (textures/*.wal)
int nexttexinfo; // for animations, -1 = end of chain
} texinfo_t;
#define SURF_LIGHT 0x1 // value will hold the light strength
#define SURF_SLICK 0x2 // effects game physics
#define SURF_SKY 0x4 // don't draw, but add to skybox
#define SURF_WARP 0x8 // turbulent water warp
#define SURF_TRANS33 0x10
#define SURF_TRANS66 0x20
#define SURF_FLOWING 0x40 // scroll towards angle
#define SURF_NODRAW 0x80 // don't bother referencing the texture
// note that edge 0 is never used, because negative edge nums are used for
// counterclockwise use of the edge in a face
typedef struct
{
unsigned short v[2]; // vertex numbers
} dedge_t;
#define MAXLIGHTMAPS 4
typedef struct
{
unsigned short planenum;
short side;
int firstedge; // we must support > 64k edges
short numedges;
short texinfo;
// lighting info
byte styles[MAXLIGHTMAPS];
int lightofs; // start of [numstyles*surfsize] samples
} dface_t;
typedef struct
{
int contents; // OR of all brushes (not needed?)
int pvsofs; // -1 = no info
int phsofs; // -1 = no info
short mins[3]; // for frustum culling
short maxs[3];
unsigned short firstleafface;
unsigned short numleaffaces;
unsigned short firstleafbrush;
unsigned short numleafbrushes;
} dleaf_t;
typedef struct
{
unsigned short planenum; // facing out of the leaf
short texinfo;
} dbrushside_t;
typedef struct
{
int firstside;
int numsides;
int contents;
} dbrush_t;
#define ANGLE_UP -1
#define ANGLE_DOWN -2

View file

@ -1,308 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by win_qe3.rc
//
#define IDAPPLY 3
#define IDR_MENU1 101
#define IDR_ACCELERATOR1 104
#define IDD_CREATE_ENTITY 107
#define IDD_EDIT_ENTITY 108
#define IDR_TOOLBAR1 109
#define IDD_FINDTEXTURE 111
#define IDD_ENTITY 115
#define IDR_E_MENU 116
#define IDD_EDITPROP 117
#define IDD_GAMMA 118
#define IDD_FINDBRUSH 119
#define IDI_ICON1 120
#define IDD_ROTATE 121
#define IDD_SIDES 122
#define IDD_ABOUT 123
#define IDB_BITMAP1 127
#define IDD_SURFACE 129
#define IDC_ENTITY_COMMENT 1018
#define IDC_VALUE 1021
#define IDC_KEY 1022
#define IDC_ENTITY_LIST 1023
#define IDC_PAIRS 1024
#define IDC_CHECK1 1026
#define IDC_CHECK2 1027
#define IDC_CHECK3 1028
#define IDC_CHECK4 1029
#define IDC_CHECK5 1030
#define IDC_CHECK6 1031
#define IDC_CHECK7 1032
#define IDC_CHECK8 1033
#define IDC_CHECK9 1034
#define IDC_CHECK10 1035
#define IDC_CHECK11 1036
#define IDC_CHECK12 1037
#define IDC_ANGLE90 1038
#define IDC_CHECK13 1038
#define IDC_ANGLE45 1039
#define IDC_CHECK14 1039
#define IDC_ANGLE135 1040
#define IDC_CHECK15 1040
#define IDC_ANGLE225 1041
#define IDC_CHECK16 1041
#define IDC_ANGLEUP 1042
#define IDC_CHECK17 1042
#define IDC_ANGLE180 1043
#define IDC_CHECK18 1043
#define IDC_ANGLE315 1044
#define IDC_CHECK19 1044
#define IDC_ANGLE0 1045
#define IDC_CHECK20 1045
#define IDC_ANGLE270 1046
#define IDC_CHECK21 1046
#define IDC_ANGLEDOWN 1047
#define IDC_CHECK22 1047
#define IDC_DELETEKEY 1048
#define IDC_ADDPAIR 1048
#define IDC_CHECK23 1048
#define IDC_DELETEPAIR 1049
#define IDC_CHECK24 1049
#define IDC_CHECK25 1050
#define IDC_SPAWN1 1051
#define IDC_CHECK26 1051
#define IDC_SPAWN2 1052
#define IDC_CHECK27 1052
#define IDC_SPAWN3 1053
#define IDC_CHECK28 1053
#define IDC_SPAWN4 1054
#define IDC_CHECK29 1054
#define IDC_SPAWN5 1055
#define IDC_CHECK30 1055
#define IDC_SPAWN6 1056
#define IDC_CHECK31 1056
#define IDC_SPAWN7 1057
#define IDC_CHECK32 1057
#define IDC_SPAWN8 1058
#define IDC_CHECK33 1058
#define IDC_EDIT1 1059
#define IDC_CHECK34 1059
#define IDC_ROTATE_BOX 1060
#define IDC_ROTZ 1060
#define IDC_CHECK35 1060
#define IDC_SCALE_BOX 1061
#define IDC_ROTY 1061
#define IDC_CHECK36 1061
#define IDC_E_VALUE_FIELD 1062
#define IDC_CHECK37 1062
#define IDC_CHECK38 1063
#define IDC_E_LIST 1064
#define IDC_CHECK39 1064
#define IDC_E_COMMENT 1065
#define IDC_CHECK40 1065
#define IDC_CHECK41 1066
#define IDC_E_PROPS 1067
#define IDC_CHECK42 1067
#define IDC_E_135 1068
#define IDC_CHECK43 1068
#define IDC_E_180 1069
#define IDC_CHECK44 1069
#define IDC_E_225 1070
#define IDC_CHECK45 1070
#define IDC_E_270 1071
#define IDC_CHECK46 1071
#define IDC_E_90 1072
#define IDC_CHECK47 1072
#define IDC_E_45 1073
#define IDC_CHECK48 1073
#define IDC_E_0 1074
#define IDC_CHECK49 1074
#define IDC_E_315 1075
#define IDC_CHECK50 1075
#define IDC_E_UP 1076
#define IDC_CHECK51 1076
#define IDC_E_DOWN 1077
#define IDC_CHECK52 1077
#define IDC_CHECK53 1078
#define IDC_CHECK54 1079
#define IDC_E_ADDPROP 1080
#define IDC_CHECK55 1080
#define IDC_E_DELPROP 1081
#define IDC_CHECK56 1081
#define IDC_E_CREATE 1082
#define IDC_CHECK57 1082
#define IDC_E_STATUS 1083
#define IDC_CHECK58 1083
#define IDC_CHECK59 1084
#define IDC_CHECK60 1085
#define IDC_CHECK61 1086
#define IDC_CHECK62 1087
#define IDC_CHECK63 1088
#define IDC_CHECK64 1089
#define IDC_SHIFT_BOX 1090
#define IDC_HSHIFT 1090
#define IDC_VSHIFT 1091
#define IDC_ROTATEV 1092
#define IDC_SCALEV 1093
#define IDC_SCALEH 1094
#define IDC_SHIFTV 1095
#define IDC_HSHIFTA 1095
#define IDC_SHIFTH 1096
#define IDC_VSHIFTA 1097
#define IDC_HSCALE 1098
#define IDC_HSCALEA 1099
#define IDC_VSCALE 1100
#define IDC_VSCALEA 1101
#define IDC_ROTATE 1102
#define IDC_G_EDIT 1103
#define IDC_ROTATEA 1103
#define IDC_STATIC_KEY 1104
#define IDC_FIND_BRUSH 1104
#define IDC_STATIC_VALUE 1105
#define IDC_E_KEY_FIELD 1106
#define IDC_FIND_ENTITY 1107
#define IDC_SIDES 1108
#define IDC_ROTX 1109
#define IDC_E_COLOR 1111
#define IDC_ABOUT_GLVENDOR 1112
#define IDC_ABOUT_GLVERSION 1113
#define IDC_ABOUT_GLRENDERER 1114
#define IDC_TEXTURE 1114
#define IDC_ABOUT_GLEXTENSIONS 1115
#define ID_FILE_EXIT 40002
#define ID_FILE_SAVEAS 40004
#define ID_VIEW_CENTER 40005
#define ID_VIEW_UPFLOOR 40006
#define ID_VIEW_DOWNFLOOR 40007
#define ID_BRUSH_FLIPX 40008
#define ID_BRUSH_FLIPY 40009
#define ID_BRUSH_FLIPZ 40010
#define ID_BRUSH_ROTATEX 40011
#define ID_BRUSH_ROTATEY 40012
#define ID_BRUSH_ROTATEZ 40013
#define ID_BSP_FULLVIS 40016
#define ID_BSP_FASTVIS 40017
#define ID_BSP_NOVIS 40018
#define ID_BSP_RELIGHT 40019
#define ID_BSP_ENTITIES 40020
#define ID_FILE_POINTFILE 40021
#define ID_VIEW_100 40022
#define ID_VIEW_75 40023
#define ID_VIEW_50 40024
#define ID_VIEW_25 40025
#define ID_VIEW_12 40026
#define ID_GRID_1 40028
#define ID_GRID_2 40029
#define ID_GRID_4 40030
#define ID_GRID_8 40031
#define ID_GRID_16 40032
#define ID_TEXTURES_SHOWALL 40033
#define ID_TEXTURES_SHOWINUSE 40034
#define ID_TEXTURES_TOGGLEVIEW 40037
#define ID_SELECTION_CREATEENTITY 40039
#define ID_SELECTION_EDITENTITY 40040
#define ID_MISC_BENCHMARK 40041
#define ID_REGION_OFF 40043
#define ID_REGION_SETXY 40044
#define ID_REGION_SETBRUSH 40045
#define ID_SELECTION_MAKEHOLLOW 40046
#define ID_SELECTION_SELECTPARTIALTALL 40047
#define ID_SELECTION_SELECTCOMPLETETALL 40048
#define ID_SELECTION_CSGSUBTRACT 40049
#define ID_SELECTION_SELECTTOUCHING 40050
#define ID_VIEW_NEAREST 40052
#define ID_VIEW_LINEAR 40053
#define ID_VIEW_BILINEAR 40054
#define ID_VIEW_TRILINEAR 40055
#define ID_VIEW_NEARESTMIPMAP 40056
#define ID_VIEW_BILINEARMIPMAP 40057
#define ID_VIEW_SHOWNAMES 40058
#define ID_VIEW_ZOOMIN 40059
#define ID_VIEW_ZOOMOUT 40060
#define ID_VIEW_SHOWCOORDINATES 40061
#define ID_VIEW_Z100 40062
#define ID_VIEW_ZZOOMIN 40063
#define ID_VIEW_ZZOOMOUT 40064
#define ID_SELECTION_CLONE 40065
#define ID_SELECTION_DESELECT 40066
#define ID_SELECTION_DELETE 40067
#define ID_BUTTON40068 40068
#define ID_TEXTURES_WIREFRAME 40072
#define ID_TEXTURES_FLATSHADE 40073
#define ID_SELECTION_DRAGVERTECIES 40074
#define ID_SELECTION_DRAGEDGES 40075
#define ID_REGION_SETTALLBRUSH 40076
#define ID_SELECTION_SELECTINSIDE 40092
#define ID_PROJECT_RELEAD 40094
#define ID_PROJECT_CHANGE 40095
#define ID_MISC_GAMMA 40097
#define ID_VIEW_SHOWENT 40098
#define ID_VIEW_SHOWPATH 40099
#define ID_VIEW_SHOWLIGHTS 40100
#define ID_VIEW_SHOWCLIP 40101
#define ID_VIEW_SHOWWATER 40102
#define ID_VIEW_SHOWWORLD 40103
#define ID_MISC_TEXTUREBACKGROUN 40104
#define ID_TEXTUREBK 40105
#define ID_COLORS_XYBK 40106
#define ID_FILE_ABOUT 40107
#define ID_VIEW_CONSOLE 40108
#define ID_VIEW_ENTITY 40109
#define ID_VIEW_TEXTURE 40110
#define ID_COLORS_MAJOR 40111
#define ID_COLORS_MINOR 40113
#define ID_SELECTION_CONNECT 40114
#define ID_FILE_LOADPROJECT 40115
#define ID_MISC_FINDBRUSH 40116
#define ID_MISC_NEXTLEAKSPOT 40117
#define ID_MISC_PREVIOUSLEAKSPOT 40118
#define ID_BRUSH_3SIDED 40119
#define ID_BRUSH_4SIDED 40120
#define ID_BRUSH_5SIDED 40121
#define ID_BRUSH_6SIDED 40122
#define ID_BRUSH_7SIDED 40123
#define ID_BRUSH_8SIDED 40124
#define ID_BRUSH_9SIDED 40125
#define ID_SELECTION_ARBITRARYROTATION 40126
#define ID_BRUSH_ARBITRARYSIDED 40127
#define ID_GRID_32 40128
#define ID_GRID_64 40129
#define ID_SELECTION_UNGROUPENTITY 40130
#define ID_MISC_SELECTENTITYCOLOR 40131
#define ID_MISC_PRINTXY 40132
#define ID_HELP_ABOUT 40134
#define ID_EDIT_COPYBRUSH 40135
#define ID_EDIT_PASTEBRUSH 40136
#define ID_TEXTURES_INSPECTOR 40137
#define ID_VIEW_SHOWDETAIL 40138
#define ID_SELECTION_MAKE_DETAIL 40139
#define ID_SELECTION_MAKE_STRUCTURAL 40140
#define ID_REGION_SETSELECTION 40142
#define ID_VIEW_SHOWBLOCKS 40143
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 40144
#define _APS_NEXT_CONTROL_VALUE 1115
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -1,706 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// select.c
#include "qe3.h"
/*
===========
Test_Ray
===========
*/
#define DIST_START 999999
trace_t Test_Ray (vec3_t origin, vec3_t dir, int flags)
{
brush_t *brush;
face_t *face;
float dist;
trace_t t;
memset (&t, 0, sizeof(t));
t.dist = DIST_START;
if (! (flags & SF_SELECTED_ONLY) )
for (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)
{
if ( (flags & SF_ENTITIES_FIRST) && brush->owner == world_entity)
continue;
if (FilterBrush (brush))
continue;
face = Brush_Ray (origin, dir, brush, &dist);
if (dist > 0 && dist < t.dist)
{
t.dist = dist;
t.brush = brush;
t.face = face;
t.selected = false;
}
}
for (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)
{
if ( (flags & SF_ENTITIES_FIRST) && brush->owner == world_entity)
continue;
if (FilterBrush (brush))
continue;
face = Brush_Ray (origin, dir, brush, &dist);
if (dist > 0 && dist < t.dist)
{
t.dist = dist;
t.brush = brush;
t.face = face;
t.selected = true;
}
}
// if entites first, but didn't find any, check regular
if ( (flags & SF_ENTITIES_FIRST) && t.brush == NULL)
return Test_Ray (origin, dir, flags - SF_ENTITIES_FIRST);
return t;
}
/*
============
Select_Brush
============
*/
void Select_Brush (brush_t *brush)
{
brush_t *b;
entity_t *e;
selected_face = NULL;
if (g_qeglobals.d_select_count < 2)
g_qeglobals.d_select_order[g_qeglobals.d_select_count] = brush;
g_qeglobals.d_select_count++;
e = brush->owner;
if (e)
{
// select complete entity on first click
if (e != world_entity)
{
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
if (b->owner == e)
goto singleselect;
for (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)
{
Brush_RemoveFromList (b);
Brush_AddToList (b, &selected_brushes);
}
}
else
{
singleselect:
Brush_RemoveFromList (brush);
Brush_AddToList (brush, &selected_brushes);
}
if (e->eclass)
{
UpdateEntitySel(brush->owner->eclass);
}
}
}
/*
============
Select_Ray
If the origin is inside a brush, that brush will be ignored.
============
*/
void Select_Ray (vec3_t origin, vec3_t dir, int flags)
{
trace_t t;
t = Test_Ray (origin, dir, flags);
if (!t.brush)
return;
if (flags == SF_SINGLEFACE)
{
selected_face = t.face;
selected_face_brush = t.brush;
Sys_UpdateWindows (W_ALL);
g_qeglobals.d_select_mode = sel_brush;
return;
}
// move the brush to the other list
g_qeglobals.d_select_mode = sel_brush;
if (t.selected)
{
Brush_RemoveFromList (t.brush);
Brush_AddToList (t.brush, &active_brushes);
} else
{
Select_Brush (t.brush);
}
Sys_UpdateWindows (W_ALL);
}
void Select_Delete (void)
{
brush_t *brush;
selected_face = NULL;
g_qeglobals.d_select_mode = sel_brush;
g_qeglobals.d_select_count = 0;
g_qeglobals.d_num_move_points = 0;
while (selected_brushes.next != &selected_brushes)
{
brush = selected_brushes.next;
Brush_Free (brush);
}
// FIXME: remove any entities with no brushes
Sys_UpdateWindows (W_ALL);
}
void Select_Deselect (void)
{
brush_t *b;
g_qeglobals.d_workcount++;
g_qeglobals.d_select_count = 0;
g_qeglobals.d_num_move_points = 0;
b = selected_brushes.next;
if (b == &selected_brushes)
{
if (selected_face)
{
selected_face = NULL;
Sys_UpdateWindows (W_ALL);
}
return;
}
selected_face = NULL;
g_qeglobals.d_select_mode = sel_brush;
// grab top / bottom height for new brushes
if (b->mins[2] < b->maxs[2])
{
g_qeglobals.d_new_brush_bottom_z = b->mins[2];
g_qeglobals.d_new_brush_top_z = b->maxs[2];
}
selected_brushes.next->prev = &active_brushes;
selected_brushes.prev->next = active_brushes.next;
active_brushes.next->prev = selected_brushes.prev;
active_brushes.next = selected_brushes.next;
selected_brushes.prev = selected_brushes.next = &selected_brushes;
Sys_UpdateWindows (W_ALL);
}
/*
============
Select_Move
============
*/
void Select_Move (vec3_t delta)
{
brush_t *b;
// actually move the selected brushes
for (b = selected_brushes.next ; b != &selected_brushes ; b=b->next)
Brush_Move (b, delta);
// Sys_UpdateWindows (W_ALL);
}
/*
============
Select_Clone
Creates an exact duplicate of the selection in place, then moves
the selected brushes off of their old positions
============
*/
void Select_Clone (void)
{
brush_t *b, *b2, *n, *next, *next2;
vec3_t delta;
entity_t *e;
g_qeglobals.d_workcount++;
g_qeglobals.d_select_mode = sel_brush;
delta[0] = g_qeglobals.d_gridsize;
delta[1] = g_qeglobals.d_gridsize;
delta[2] = 0;
for (b=selected_brushes.next ; b != &selected_brushes ; b=next)
{
next = b->next;
// if the brush is a world brush, handle simply
if (b->owner == world_entity)
{
n = Brush_Clone (b);
Brush_AddToList (n, &active_brushes);
Entity_LinkBrush (world_entity, n);
Brush_Build( n );
Brush_Move (b, delta);
continue;
}
e = Entity_Clone (b->owner);
// clear the target / targetname
DeleteKey (e, "target");
DeleteKey (e, "targetname");
// if the brush is a fixed size entity, create a new entity
if (b->owner->eclass->fixedsize)
{
n = Brush_Clone (b);
Brush_AddToList (n, &active_brushes);
Entity_LinkBrush (e, n);
Brush_Build( n );
Brush_Move (b, delta);
continue;
}
// brush is a complex entity, grab all the other ones now
next = &selected_brushes;
for ( b2 = b ; b2 != &selected_brushes ; b2=next2)
{
next2 = b2->next;
if (b2->owner != b->owner)
{
if (next == &selected_brushes)
next = b2;
continue;
}
// move b2 to the start of selected_brushes,
// so it won't be hit again
Brush_RemoveFromList (b2);
Brush_AddToList (b2, &selected_brushes);
n = Brush_Clone (b2);
Brush_AddToList (n, &active_brushes);
Entity_LinkBrush (e, n);
Brush_Build( n );
Brush_Move (b2, delta);
}
}
Sys_UpdateWindows (W_ALL);
}
/*
============
Select_SetTexture
============
*/
void Select_SetTexture (texdef_t *texdef)
{
brush_t *b;
if (selected_face)
{
selected_face->texdef = *texdef;
Brush_Build(selected_face_brush);
}
else
{
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
if (!b->owner->eclass->fixedsize)
Brush_SetTexture (b, texdef);
}
Sys_UpdateWindows (W_ALL);
}
/*
================================================================
TRANSFORMATIONS
================================================================
*/
void Select_GetBounds (vec3_t mins, vec3_t maxs)
{
brush_t *b;
int i;
for (i=0 ; i<3 ; i++)
{
mins[i] = 99999;
maxs[i] = -99999;
}
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
for (i=0 ; i<3 ; i++)
{
if (b->mins[i] < mins[i])
mins[i] = b->mins[i];
if (b->maxs[i] > maxs[i])
maxs[i] = b->maxs[i];
}
}
void Select_GetMid (vec3_t mid)
{
vec3_t mins, maxs;
int i;
Select_GetBounds (mins, maxs);
for (i=0 ; i<3 ; i++)
mid[i] = g_qeglobals.d_gridsize*floor ( ( (mins[i] + maxs[i])*0.5 )/g_qeglobals.d_gridsize );
}
vec3_t select_origin;
vec3_t select_matrix[3];
qboolean select_fliporder;
void Select_AplyMatrix (void)
{
brush_t *b;
face_t *f;
int i, j;
vec3_t temp;
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
{
for (f=b->brush_faces ; f ; f=f->next)
{
for (i=0 ; i<3 ; i++)
{
VectorSubtract (f->planepts[i], select_origin, temp);
for (j=0 ; j<3 ; j++)
f->planepts[i][j] = DotProduct(temp, select_matrix[j])
+ select_origin[j];
}
if (select_fliporder)
{
VectorCopy (f->planepts[0], temp);
VectorCopy (f->planepts[2], f->planepts[0]);
VectorCopy (temp, f->planepts[2]);
}
}
Brush_Build( b );
}
Sys_UpdateWindows (W_ALL);
}
void Select_FlipAxis (int axis)
{
int i;
Select_GetMid (select_origin);
for (i=0 ; i<3 ; i++)
{
VectorCopy (vec3_origin, select_matrix[i]);
select_matrix[i][i] = 1;
}
select_matrix[axis][axis] = -1;
select_fliporder = true;
Select_AplyMatrix ();
}
void Select_RotateAxis (int axis, float deg)
{
vec3_t temp;
int i, j;
vec_t c, s;
if (deg == 0)
return;
Select_GetMid (select_origin);
select_fliporder = false;
if (deg == 90)
{
for (i=0 ; i<3 ; i++)
{
VectorCopy (vec3_origin, select_matrix[i]);
select_matrix[i][i] = 1;
}
i = (axis+1)%3;
j = (axis+2)%3;
VectorCopy (select_matrix[i], temp);
VectorCopy (select_matrix[j], select_matrix[i]);
VectorSubtract (vec3_origin, temp, select_matrix[j]);
}
else
{
deg = -deg;
if (deg == -180)
{
c = -1;
s = 0;
}
else if (deg == -270)
{
c = 0;
s = -1;
}
else
{
c = cos(deg/180*3.14159);
s = sin (deg/180*3.14159);
}
for (i=0 ; i<3 ; i++)
{
VectorCopy (vec3_origin, select_matrix[i]);
select_matrix[i][i] = 1;
}
switch (axis)
{
case 0:
select_matrix[1][1] = c;
select_matrix[1][2] = -s;
select_matrix[2][1] = s;
select_matrix[2][2] = c;
break;
case 1:
select_matrix[0][0] = c;
select_matrix[0][2] = s;
select_matrix[2][0] = -s;
select_matrix[2][2] = c;
break;
case 2:
select_matrix[0][0] = c;
select_matrix[0][1] = -s;
select_matrix[1][0] = s;
select_matrix[1][1] = c;
break;
}
}
Select_AplyMatrix ();
}
/*
================================================================
GROUP SELECTIONS
================================================================
*/
void Select_CompleteTall (void)
{
brush_t *b, *next;
int i;
vec3_t mins, maxs;
if (!QE_SingleBrush ())
return;
g_qeglobals.d_select_mode = sel_brush;
VectorCopy (selected_brushes.next->mins, mins);
VectorCopy (selected_brushes.next->maxs, maxs);
Select_Delete ();
for (b=active_brushes.next ; b != &active_brushes ; b=next)
{
next = b->next;
for (i=0 ; i<2 ; i++)
if (b->maxs[i] > maxs[i] || b->mins[i] < mins[i])
break;
if (i == 2)
{
Brush_RemoveFromList (b);
Brush_AddToList (b, &selected_brushes);
}
}
Sys_UpdateWindows (W_ALL);
}
void Select_PartialTall (void)
{
brush_t *b, *next;
int i;
vec3_t mins, maxs;
if (!QE_SingleBrush ())
return;
g_qeglobals.d_select_mode = sel_brush;
VectorCopy (selected_brushes.next->mins, mins);
VectorCopy (selected_brushes.next->maxs, maxs);
Select_Delete ();
for (b=active_brushes.next ; b != &active_brushes ; b=next)
{
next = b->next;
for (i=0 ; i<2 ; i++)
if (b->mins[i] > maxs[i] || b->maxs[i] < mins[i])
break;
if (i == 2)
{
Brush_RemoveFromList (b);
Brush_AddToList (b, &selected_brushes);
}
}
Sys_UpdateWindows (W_ALL);
}
void Select_Touching (void)
{
brush_t *b, *next;
int i;
vec3_t mins, maxs;
if (!QE_SingleBrush ())
return;
g_qeglobals.d_select_mode = sel_brush;
VectorCopy (selected_brushes.next->mins, mins);
VectorCopy (selected_brushes.next->maxs, maxs);
for (b=active_brushes.next ; b != &active_brushes ; b=next)
{
next = b->next;
for (i=0 ; i<3 ; i++)
if (b->mins[i] > maxs[i]+1 || b->maxs[i] < mins[i]-1)
break;
if (i == 3)
{
Brush_RemoveFromList (b);
Brush_AddToList (b, &selected_brushes);
}
}
Sys_UpdateWindows (W_ALL);
}
void Select_Inside (void)
{
brush_t *b, *next;
int i;
vec3_t mins, maxs;
if (!QE_SingleBrush ())
return;
g_qeglobals.d_select_mode = sel_brush;
VectorCopy (selected_brushes.next->mins, mins);
VectorCopy (selected_brushes.next->maxs, maxs);
Select_Delete ();
for (b=active_brushes.next ; b != &active_brushes ; b=next)
{
next = b->next;
for (i=0 ; i<3 ; i++)
if (b->maxs[i] > maxs[i] || b->mins[i] < mins[i])
break;
if (i == 3)
{
Brush_RemoveFromList (b);
Brush_AddToList (b, &selected_brushes);
}
}
Sys_UpdateWindows (W_ALL);
}
/*
=============
Select_Ungroup
Turn the currently selected entity back into normal brushes
=============
*/
void Select_Ungroup (void)
{
entity_t *e;
brush_t *b;
e = selected_brushes.next->owner;
if (!e || e == world_entity || e->eclass->fixedsize)
{
Sys_Status ("Not a grouped entity.", 0);
return;
}
for (b=e->brushes.onext ; b != &e->brushes ; b=e->brushes.onext)
{
Brush_RemoveFromList (b);
Brush_AddToList (b, &active_brushes);
Entity_UnlinkBrush (b);
Entity_LinkBrush (world_entity, b);
Brush_Build( b );
b->owner = world_entity;
}
Entity_Free (e);
Sys_UpdateWindows (W_ALL);
}
/*
====================
Select_MakeStructural
====================
*/
void Select_MakeStructural (void)
{
brush_t *b;
face_t *f;
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
for (f=b->brush_faces ; f ; f=f->next)
f->texdef.contents &= ~CONTENTS_DETAIL;
Select_Deselect ();
Sys_UpdateWindows (W_ALL);
}
void Select_MakeDetail (void)
{
brush_t *b;
face_t *f;
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
for (f=b->brush_faces ; f ; f=f->next)
f->texdef.contents |= CONTENTS_DETAIL;
Select_Deselect ();
Sys_UpdateWindows (W_ALL);
}

View file

@ -1,62 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
typedef enum
{
sel_brush,
// sel_sticky_brush,
// sel_face,
sel_vertex,
sel_edge
} select_t;
typedef struct
{
brush_t *brush;
face_t *face;
float dist;
qboolean selected;
} trace_t;
#define SF_SELECTED_ONLY 1
#define SF_ENTITIES_FIRST 2
#define SF_SINGLEFACE 4
trace_t Test_Ray (vec3_t origin, vec3_t dir, int flags);
void Select_GetBounds (vec3_t mins, vec3_t maxs);
void Select_Brush (brush_t *b);
void Select_Ray (vec3_t origin, vec3_t dir, int flags);
void Select_Delete (void);
void Select_Deselect (void);
void Select_Clone (void);
void Select_Move (vec3_t delta);
void Select_SetTexture (texdef_t *texdef);
void Select_FlipAxis (int axis);
void Select_RotateAxis (int axis, float deg);
void Select_CompleteTall (void);
void Select_PartialTall (void);
void Select_Touching (void);
void Select_Inside (void);
void Select_MakeStructural (void);
void Select_MakeDetail (void);

File diff suppressed because it is too large Load diff

View file

@ -1,70 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
typedef struct
{
char name[32];
float shift[2];
float rotate;
float scale[2];
int contents;
int flags;
int value;
} texdef_t;
typedef struct
{
int width, height;
int originy;
texdef_t texdef;
} texturewin_t;
typedef struct qtexture_s
{
struct qtexture_s *next;
char name[64]; // includes partial directory and extension
int width, height;
int contents;
int flags;
int value;
int texture_number; // gl bind number
vec3_t color; // for flat shade mode
qboolean inuse; // true = is present on the level
} qtexture_t;
// a texturename of the form (0 0 0) will
// create a solid color texture
void Texture_Init (void);
void Texture_Flush (void);
void Texture_ClearInuse (void);
void Texture_ShowInuse (void);
void Texture_ShowDirectory (int menunum);
qtexture_t *Texture_ForName (char *name);
void Texture_Init (void);
void Texture_SetTexture (texdef_t *texdef);
void Texture_SetMode(int iMenu); // GL_TEXTURE_NEAREST, etc..

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -1,245 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
int FindPoint (vec3_t point)
{
int i, j;
for (i=0 ; i<g_qeglobals.d_numpoints ; i++)
{
for (j=0 ; j<3 ; j++)
if (fabs(point[j] - g_qeglobals.d_points[i][j]) > 0.1)
break;
if (j == 3)
return i;
}
VectorCopy (point, g_qeglobals.d_points[g_qeglobals.d_numpoints]);
g_qeglobals.d_numpoints++;
return g_qeglobals.d_numpoints-1;
}
int FindEdge (int p1, int p2, face_t *f)
{
int i;
for (i=0 ; i<g_qeglobals.d_numedges ; i++)
if (g_qeglobals.d_edges[i].p1 == p2 && g_qeglobals.d_edges[i].p2 == p1)
{
g_qeglobals.d_edges[i].f2 = f;
return i;
}
g_qeglobals.d_edges[g_qeglobals.d_numedges].p1 = p1;
g_qeglobals.d_edges[g_qeglobals.d_numedges].p2 = p2;
g_qeglobals.d_edges[g_qeglobals.d_numedges].f1 = f;
g_qeglobals.d_numedges++;
return g_qeglobals.d_numedges-1;
}
void MakeFace (face_t *f)
{
winding_t *w;
int i;
int pnum[128];
w = MakeFaceWinding (selected_brushes.next, f);
if (!w)
return;
for (i=0 ; i<w->numpoints ; i++)
pnum[i] = FindPoint (w->points[i]);
for (i=0 ; i<w->numpoints ; i++)
FindEdge (pnum[i], pnum[(i+1)%w->numpoints], f);
free (w);
}
void SetupVertexSelection (void)
{
face_t *f;
brush_t *b;
g_qeglobals.d_numpoints = 0;
g_qeglobals.d_numedges = 0;
if (!QE_SingleBrush())
return;
b = selected_brushes.next;
for (f=b->brush_faces ; f ; f=f->next)
MakeFace (f);
Sys_UpdateWindows (W_ALL);
}
void SelectFaceEdge (face_t *f, int p1, int p2)
{
winding_t *w;
int i, j, k;
int pnum[128];
w = MakeFaceWinding (selected_brushes.next, f);
if (!w)
return;
for (i=0 ; i<w->numpoints ; i++)
pnum[i] = FindPoint (w->points[i]);
for (i=0 ; i<w->numpoints ; i++)
if (pnum[i] == p1 && pnum[(i+1)%w->numpoints] == p2)
{
VectorCopy (g_qeglobals.d_points[pnum[i]], f->planepts[0]);
VectorCopy (g_qeglobals.d_points[pnum[(i+1)%w->numpoints]], f->planepts[1]);
VectorCopy (g_qeglobals.d_points[pnum[(i+2)%w->numpoints]], f->planepts[2]);
for (j=0 ; j<3 ; j++)
{
for (k=0 ; k<3 ; k++)
{
f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;
}
}
AddPlanept (f->planepts[0]);
AddPlanept (f->planepts[1]);
break;
}
if (i == w->numpoints)
Sys_Printf ("SelectFaceEdge: failed\n");
free (w);
}
void SelectVertex (int p1)
{
brush_t *b;
winding_t *w;
int i, j, k;
face_t *f;
b = selected_brushes.next;
for (f=b->brush_faces ; f ; f=f->next)
{
w = MakeFaceWinding (b, f);
if (!w)
continue;
for (i=0 ; i<w->numpoints ; i++)
{
if (FindPoint (w->points[i]) == p1)
{
VectorCopy (w->points[(i+w->numpoints-1)%w->numpoints], f->planepts[0]);
VectorCopy (w->points[i], f->planepts[1]);
VectorCopy (w->points[(i+1)%w->numpoints], f->planepts[2]);
for (j=0 ; j<3 ; j++)
{
for (k=0 ; k<3 ; k++)
{
f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;
}
}
AddPlanept (f->planepts[1]);
break;
}
}
free (w);
}
}
void SelectEdgeByRay (vec3_t org, vec3_t dir)
{
int i, j, besti;
float d, bestd;
vec3_t mid, temp;
pedge_t *e;
// find the edge closest to the ray
besti = -1;
bestd = 8;
for (i=0 ; i<g_qeglobals.d_numedges ; i++)
{
for (j=0 ; j<3 ; j++)
mid[j] = 0.5*(g_qeglobals.d_points[g_qeglobals.d_edges[i].p1][j] + g_qeglobals.d_points[g_qeglobals.d_edges[i].p2][j]);
VectorSubtract (mid, org, temp);
d = DotProduct (temp, dir);
VectorMA (org, d, dir, temp);
VectorSubtract (mid, temp, temp);
d = VectorLength (temp);
if (d < bestd)
{
bestd = d;
besti = i;
}
}
if (besti == -1)
{
Sys_Printf ("Click didn't hit an edge\n");
return;
}
Sys_Printf ("hit edge\n");
// make the two faces that border the edge use the two edge points
// as primary drag points
g_qeglobals.d_num_move_points = 0;
e = &g_qeglobals.d_edges[besti];
SelectFaceEdge (e->f1, e->p1, e->p2);
SelectFaceEdge (e->f2, e->p2, e->p1);
}
void SelectVertexByRay (vec3_t org, vec3_t dir)
{
int i, besti;
float d, bestd;
vec3_t temp;
// find the point closest to the ray
besti = -1;
bestd = 8;
for (i=0 ; i<g_qeglobals.d_numpoints ; i++)
{
VectorSubtract (g_qeglobals.d_points[i], org, temp);
d = DotProduct (temp, dir);
VectorMA (org, d, dir, temp);
VectorSubtract (g_qeglobals.d_points[i], temp, temp);
d = VectorLength (temp);
if (d < bestd)
{
bestd = d;
besti = i;
}
}
if (besti == -1)
{
Sys_Printf ("Click didn't hit a vertex\n");
return;
}
Sys_Printf ("hit vertex\n");
SelectVertex (besti);
}

View file

@ -1,52 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
typedef struct
{
int x, y;
int w, h;
int redraws; // clear to 0 when need update
vec3_t color;
vec3_t origin;
vec3_t angles;
vec3_t forward, right, up;
int draw_filtered;
int draw_wire;
int draw_solid;
int draw_textured;
int draw_blend;
} vieworg_t;
extern vieworg_t *view_org;
extern int keysdown;
void View_Init (void);
void View_Draw (void);
void View_MouseDown (int x, int y, int buttons);
void View_KeyUp (int key);
void View_KeyDown (int key);
void View_Reshape(int w, int h);

View file

@ -1,273 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// win_cam.c -- windows specific camera view code
#include "qe3.h"
/*
============
CameraWndProc
============
*/
LONG WINAPI WCam_WndProc (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
int fwKeys, xPos, yPos;
RECT rect;
GetClientRect(hWnd, &rect);
switch (uMsg)
{
case WM_CREATE:
{
HFONT hfont;
g_qeglobals.d_hdcBase = GetDC(hWnd);
QEW_SetupPixelFormat(g_qeglobals.d_hdcBase, true);
if ( ( g_qeglobals.d_hglrcBase = wglCreateContext( g_qeglobals.d_hdcBase ) ) == 0 )
Error ("wglCreateContext failed");
if (!wglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase ))
Error ("wglMakeCurrent failed");
Texture_SetMode(g_qeglobals.d_savedinfo.iTexMenu);
//
// create GL font
//
hfont = CreateFont(
10, // logical height of font
7, // logical average character width
0, // angle of escapement
0, // base-line orientation angle
0, // font weight
0, // italic attribute flag
0, // underline attribute flag
0, // strikeout attribute flag
0, // character set identifier
0, // output precision
0, // clipping precision
0, // output quality
0, // pitch and family
0 // pointer to typeface name string
);
if ( !hfont )
Error( "couldn't create font" );
SelectObject (g_qeglobals.d_hdcBase, hfont);
if ( ( g_qeglobals.d_font_list = glGenLists (256) ) == 0 )
Error( "couldn't create font dlists" );
// create the bitmap display lists
// we're making images of glyphs 0 thru 255
if ( !wglUseFontBitmaps (g_qeglobals.d_hdcBase, 1, 255, g_qeglobals.d_font_list) )
Error( "wglUseFontBitmaps faileD" );
// indicate start of glyph display lists
glListBase (g_qeglobals.d_font_list);
// report OpenGL information
Sys_Printf ("GL_VENDOR: %s\n", glGetString (GL_VENDOR));
Sys_Printf ("GL_RENDERER: %s\n", glGetString (GL_RENDERER));
Sys_Printf ("GL_VERSION: %s\n", glGetString (GL_VERSION));
Sys_Printf ("GL_EXTENSIONS: %s\n", glGetString (GL_EXTENSIONS));
}
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
if (!wglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase ))
Error ("wglMakeCurrent failed");
if ( BeginPaint(hWnd, &ps) )
{
QE_CheckOpenGLForErrors();
Cam_Draw ();
QE_CheckOpenGLForErrors();
EndPaint(hWnd, &ps);
SwapBuffers(g_qeglobals.d_hdcBase);
}
}
return 0;
case WM_USER+267: // benchmark
{
PAINTSTRUCT ps;
WINDOWPLACEMENT wp;
double start, end;
int i;
memset( &wp, 0, sizeof( wp ) );
wp.length = sizeof( wp );
GetWindowPlacement( g_qeglobals.d_hwndCamera, &wp );
MoveWindow( g_qeglobals.d_hwndCamera, 30, 30, 400, 400, TRUE );
BeginPaint(hWnd, &ps);
if (!wglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))
Error ("wglMakeCurrent failed");
glDrawBuffer (GL_FRONT);
start = Sys_DoubleTime ();
for (i=0 ; i<100 ; i++)
{
camera.angles[YAW] = i*4;
Cam_Draw ();
}
SwapBuffers(g_qeglobals.d_hdcBase);
glDrawBuffer (GL_BACK);
end = Sys_DoubleTime ();
EndPaint(hWnd, &ps);
Sys_Printf ("%5.2f seconds\n", end-start);
SetWindowPlacement( g_qeglobals.d_hwndCamera, &wp );
}
break;
case WM_KEYDOWN:
if ( QE_KeyDown (wParam) )
return 0;
else
return DefWindowProc( hWnd, uMsg, wParam, lParam );
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
if (GetTopWindow(g_qeglobals.d_hwndMain) != hWnd)
BringWindowToTop(hWnd);
SetFocus (g_qeglobals.d_hwndCamera);
SetCapture (g_qeglobals.d_hwndCamera);
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
Cam_MouseDown (xPos, yPos, fwKeys);
return 0;
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONUP:
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
Cam_MouseUp (xPos, yPos, fwKeys);
if (! (fwKeys & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))
ReleaseCapture ();
return 0;
case WM_MOUSEMOVE:
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
Cam_MouseMoved (xPos, yPos, fwKeys);
return 0;
case WM_SIZE:
camera.width = rect.right;
camera.height = rect.bottom;
InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
return 0;
case WM_KILLFOCUS:
case WM_SETFOCUS:
SendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 );
return 0;
case WM_NCCALCSIZE:// don't let windows copy pixels
DefWindowProc (hWnd, uMsg, wParam, lParam);
return WVR_REDRAW;
case WM_CLOSE:
DestroyWindow (hWnd);
return 0;
case WM_DESTROY:
QEW_StopGL( hWnd, g_qeglobals.d_hglrcBase, g_qeglobals.d_hdcBase );
return 0;
}
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
/*
==============
WCam_Create
==============
*/
void WCam_Create (HINSTANCE hInstance)
{
WNDCLASS wc;
char *title;
/* Register the camera class */
memset (&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WCam_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = 0;
wc.lpszClassName = CAMERA_WINDOW_CLASS;
if (!RegisterClass (&wc) )
Error ("WCam_Register: failed");
if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAIL )
title = "Camera View (DETAIL EXCLUDED)";
else
title = "Camera View";
g_qeglobals.d_hwndCamera = CreateWindow (CAMERA_WINDOW_CLASS ,
title,
QE3_STYLE,
ZWIN_WIDTH,
20,
(int)(screen_width*CWIN_SIZE),
(int)(screen_height*CWIN_SIZE), // size
g_qeglobals.d_hwndMain, // parent window
0, // no menu
hInstance,
0);
if (!g_qeglobals.d_hwndCamera)
Error ("Couldn't create g_qeglobals.d_hwndCamera");
LoadWindowState(g_qeglobals.d_hwndCamera, "camerawindow");
ShowWindow (g_qeglobals.d_hwndCamera, SW_SHOWDEFAULT);
}

View file

@ -1,653 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
BOOL CALLBACK GammaDlgProc (
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
char sz[256];
switch (uMsg)
{
case WM_INITDIALOG:
sprintf(sz, "%1.1f", g_qeglobals.d_savedinfo.fGamma);
SetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
GetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz, 255);
g_qeglobals.d_savedinfo.fGamma = atof(sz);
EndDialog(hwndDlg, 1);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, 0);
return TRUE;
}
}
return FALSE;
}
void DoGamma(void)
{
char *psz, sz[256];
if ( DialogBox(g_qeglobals.d_hInstance, (char *)IDD_GAMMA, g_qeglobals.d_hwndMain, GammaDlgProc))
{
psz = ValueForKey(world_entity, "_wad");
if (psz)
{
strcpy(sz, psz);
Texture_Flush();
Texture_ShowInuse();
}
}
}
//================================================
void SelectBrush (int entitynum, int brushnum)
{
entity_t *e;
brush_t *b;
int i;
if (entitynum == 0)
e = world_entity;
else
{
e = entities.next;
while (--entitynum)
{
e=e->next;
if (e == &entities)
{
Sys_Status ("No such entity.", 0);
return;
}
}
}
b = e->brushes.onext;
if (b == &e->brushes)
{
Sys_Status ("No such brush.", 0);
return;
}
while (brushnum--)
{
b=b->onext;
if (b == &e->brushes)
{
Sys_Status ("No such brush.", 0);
return;
}
}
Brush_RemoveFromList (b);
Brush_AddToList (b, &selected_brushes);
Sys_UpdateWindows (W_ALL);
for (i=0 ; i<3 ; i++)
g_qeglobals.d_xy.origin[i] = (b->mins[i] + b->maxs[i])/2;
Sys_Status ("Selected.", 0);
}
/*
=================
GetSelectionIndex
=================
*/
void GetSelectionIndex (int *ent, int *brush)
{
brush_t *b, *b2;
entity_t *entity;
*ent = *brush = 0;
b = selected_brushes.next;
if (b == &selected_brushes)
return;
// find entity
if (b->owner != world_entity)
{
(*ent)++;
for (entity = entities.next ; entity != &entities
; entity=entity->next, (*ent)++)
;
}
// find brush
for (b2=b->owner->brushes.onext
; b2 != b && b2 != &b->owner->brushes
; b2=b2->onext, (*brush)++)
;
}
BOOL CALLBACK FindBrushDlgProc (
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
char entstr[256];
char brushstr[256];
HWND h;
int ent, brush;
switch (uMsg)
{
case WM_INITDIALOG:
// set entity and brush number
GetSelectionIndex (&ent, &brush);
sprintf (entstr, "%i", ent);
sprintf (brushstr, "%i", brush);
SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr);
SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr);
h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
SetFocus (h);
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr, 255);
GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr, 255);
SelectBrush (atoi(entstr), atoi(brushstr));
EndDialog(hwndDlg, 1);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, 0);
return TRUE;
}
}
return FALSE;
}
void DoFind(void)
{
DialogBox(g_qeglobals.d_hInstance, (char *)IDD_FINDBRUSH, g_qeglobals.d_hwndMain, FindBrushDlgProc);
}
/*
===================================================
ARBITRARY ROTATE
===================================================
*/
BOOL CALLBACK RotateDlgProc (
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
char str[256];
HWND h;
float v;
switch (uMsg)
{
case WM_INITDIALOG:
h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
SetFocus (h);
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
GetWindowText(GetDlgItem(hwndDlg, IDC_ROTX), str, 255);
v = atof(str);
if (v)
Select_RotateAxis (0, v);
GetWindowText(GetDlgItem(hwndDlg, IDC_ROTY), str, 255);
v = atof(str);
if (v)
Select_RotateAxis (1, v);
GetWindowText(GetDlgItem(hwndDlg, IDC_ROTZ), str, 255);
v = atof(str);
if (v)
Select_RotateAxis (2, v);
EndDialog(hwndDlg, 1);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, 0);
return TRUE;
}
}
return FALSE;
}
void DoRotate(void)
{
DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ROTATE, g_qeglobals.d_hwndMain, RotateDlgProc);
}
/*
===================================================
ARBITRARY SIDES
===================================================
*/
BOOL CALLBACK SidesDlgProc (
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
char str[256];
HWND h;
switch (uMsg)
{
case WM_INITDIALOG:
h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
SetFocus (h);
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
GetWindowText(GetDlgItem(hwndDlg, IDC_SIDES), str, 255);
Brush_MakeSided (atoi(str));
EndDialog(hwndDlg, 1);
break;
case IDCANCEL:
EndDialog(hwndDlg, 0);
break;
}
default:
return FALSE;
}
}
void DoSides(void)
{
DialogBox(g_qeglobals.d_hInstance, (char *)IDD_SIDES, g_qeglobals.d_hwndMain, SidesDlgProc);
}
//======================================================================
/*
===================
DoAbout
===================
*/
BOOL CALLBACK AboutDlgProc( HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
{
switch (uMsg)
{
case WM_INITDIALOG:
{
char renderer[1024];
char version[1024];
char vendor[1024];
char extensions[4096];
sprintf( renderer, "Renderer:\t%s", glGetString( GL_RENDERER ) );
sprintf( version, "Version:\t\t%s", glGetString( GL_VERSION ) );
sprintf( vendor, "Vendor:\t\t%s", glGetString( GL_VENDOR ) );
sprintf( extensions, "\n%s", glGetString( GL_EXTENSIONS ) );
SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLRENDERER ), renderer );
SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLVERSION ), version );
SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLVENDOR ), vendor );
SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLEXTENSIONS ), extensions );
}
return TRUE;
case WM_CLOSE:
EndDialog( hwndDlg, 1 );
return TRUE;
case WM_COMMAND:
if ( LOWORD( wParam ) == IDOK )
EndDialog(hwndDlg, 1);
return TRUE;
}
return FALSE;
}
void DoAbout(void)
{
DialogBox( g_qeglobals.d_hInstance, ( char * ) IDD_ABOUT, g_qeglobals.d_hwndMain, AboutDlgProc );
}
/*
===================================================
SURFACE INSPECTOR
===================================================
*/
texdef_t g_old_texdef;
HWND g_surfwin;
qboolean g_changed_surface;
int g_checkboxes[64] = {
IDC_CHECK1, IDC_CHECK2, IDC_CHECK3, IDC_CHECK4,
IDC_CHECK5, IDC_CHECK6, IDC_CHECK7, IDC_CHECK8,
IDC_CHECK9, IDC_CHECK10, IDC_CHECK11, IDC_CHECK12,
IDC_CHECK13, IDC_CHECK14, IDC_CHECK15, IDC_CHECK16,
IDC_CHECK17, IDC_CHECK18, IDC_CHECK19, IDC_CHECK20,
IDC_CHECK21, IDC_CHECK22, IDC_CHECK23, IDC_CHECK24,
IDC_CHECK25, IDC_CHECK26, IDC_CHECK27, IDC_CHECK28,
IDC_CHECK29, IDC_CHECK30, IDC_CHECK31, IDC_CHECK32,
IDC_CHECK33, IDC_CHECK34, IDC_CHECK35, IDC_CHECK36,
IDC_CHECK37, IDC_CHECK38, IDC_CHECK39, IDC_CHECK40,
IDC_CHECK41, IDC_CHECK42, IDC_CHECK43, IDC_CHECK44,
IDC_CHECK45, IDC_CHECK46, IDC_CHECK47, IDC_CHECK48,
IDC_CHECK49, IDC_CHECK50, IDC_CHECK51, IDC_CHECK52,
IDC_CHECK53, IDC_CHECK54, IDC_CHECK55, IDC_CHECK56,
IDC_CHECK57, IDC_CHECK58, IDC_CHECK59, IDC_CHECK60,
IDC_CHECK61, IDC_CHECK62, IDC_CHECK63, IDC_CHECK64
};
/*
==============
SetTexMods
Set the fields to the current texdef
===============
*/
void SetTexMods(void)
{
char sz[128];
texdef_t *pt;
int i;
pt = &g_qeglobals.d_texturewin.texdef;
SendMessage (g_surfwin, WM_SETREDRAW, 0, 0);
SetWindowText(GetDlgItem(g_surfwin, IDC_TEXTURE), pt->name);
sprintf(sz, "%d", (int)pt->shift[0]);
SetWindowText(GetDlgItem(g_surfwin, IDC_HSHIFT), sz);
sprintf(sz, "%d", (int)pt->shift[1]);
SetWindowText(GetDlgItem(g_surfwin, IDC_VSHIFT), sz);
sprintf(sz, "%4.2f", pt->scale[0]);
SetWindowText(GetDlgItem(g_surfwin, IDC_HSCALE), sz);
sprintf(sz, "%4.2f", pt->scale[1]);
SetWindowText(GetDlgItem(g_surfwin, IDC_VSCALE), sz);
sprintf(sz, "%d", (int)pt->rotate);
SetWindowText(GetDlgItem(g_surfwin, IDC_ROTATE), sz);
sprintf(sz, "%d", (int)pt->value);
SetWindowText(GetDlgItem(g_surfwin, IDC_VALUE), sz);
for (i=0 ; i<32 ; i++)
SendMessage(GetDlgItem(g_surfwin, g_checkboxes[i]), BM_SETCHECK, !!(pt->flags&(1<<i)), 0 );
for (i=0 ; i<32 ; i++)
SendMessage(GetDlgItem(g_surfwin, g_checkboxes[32+i]), BM_SETCHECK, !!(pt->contents&(1<<i)), 0 );
SendMessage (g_surfwin, WM_SETREDRAW, 1, 0);
InvalidateRect (g_surfwin, NULL, true);
}
/*
==============
GetTexMods
Reads the fields to get the current texdef
===============
*/
void GetTexMods(void)
{
char sz[128];
texdef_t *pt;
int b;
int i;
pt = &g_qeglobals.d_texturewin.texdef;
GetWindowText (GetDlgItem(g_surfwin, IDC_TEXTURE), sz, 127);
strncpy (pt->name, sz, sizeof(pt->name)-1);
if (pt->name[0] <= ' ')
{
strcpy (pt->name, "none");
SetWindowText(GetDlgItem(g_surfwin, IDC_TEXTURE), pt->name);
}
GetWindowText (GetDlgItem(g_surfwin, IDC_HSHIFT), sz, 127);
pt->shift[0] = atof(sz);
GetWindowText (GetDlgItem(g_surfwin, IDC_VSHIFT), sz, 127);
pt->shift[1] = atof(sz);
GetWindowText(GetDlgItem(g_surfwin, IDC_HSCALE), sz, 127);
pt->scale[0] = atof(sz);
GetWindowText(GetDlgItem(g_surfwin, IDC_VSCALE), sz, 127);
pt->scale[1] = atof(sz);
GetWindowText(GetDlgItem(g_surfwin, IDC_ROTATE), sz, 127);
pt->rotate = atof(sz);
GetWindowText(GetDlgItem(g_surfwin, IDC_VALUE), sz, 127);
pt->value = atof(sz);
pt->flags = 0;
for (i=0 ; i<32 ; i++)
{
b = SendMessage(GetDlgItem(g_surfwin, g_checkboxes[i]), BM_GETCHECK, 0, 0);
if (b != 1 && b != 0)
continue;
pt->flags |= b<<i;
}
pt->contents = 0;
for (i=0 ; i<32 ; i++)
{
b = SendMessage(GetDlgItem(g_surfwin, g_checkboxes[32+i]), BM_GETCHECK, 0, 0);
if (b != 1 && b != 0)
continue;
pt->contents |= b<<i;
}
g_changed_surface = true;
Select_SetTexture(pt);
}
/*
=================
UpdateSpinners
=================
*/
void UpdateSpinners(unsigned uMsg, WPARAM wParam, LPARAM lParam)
{
int nScrollCode;
HWND hwnd;
texdef_t *pt;
pt = &g_qeglobals.d_texturewin.texdef;
nScrollCode = (int) LOWORD(wParam); // scroll bar value
hwnd = (HWND) lParam; // handle of scroll bar
if ((nScrollCode != SB_LINEUP) && (nScrollCode != SB_LINEDOWN))
return;
if (hwnd == GetDlgItem(g_surfwin, IDC_ROTATEA))
{
if (nScrollCode == SB_LINEUP)
pt->rotate += 45;
else
pt->rotate -= 45;
if (pt->rotate < 0)
pt->rotate += 360;
if (pt->rotate >= 360)
pt->rotate -= 360;
}
else if (hwnd == GetDlgItem(g_surfwin, IDC_HSCALEA))
{
if (nScrollCode == SB_LINEDOWN)
pt->scale[0] -= 0.1;
else
pt->scale[0] += 0.1;
}
else if (hwnd == GetDlgItem(g_surfwin, IDC_VSCALEA))
{
if (nScrollCode == SB_LINEUP)
pt->scale[1] += 0.1;
else
pt->scale[1] -= 0.1;
}
else if (hwnd == GetDlgItem(g_surfwin, IDC_HSHIFTA))
{
if (nScrollCode == SB_LINEDOWN)
pt->shift[0] -= 8;
else
pt->shift[0] += 8;
}
else if (hwnd == GetDlgItem(g_surfwin, IDC_VSHIFTA))
{
if (nScrollCode == SB_LINEUP)
pt->shift[1] += 8;
else
pt->shift[1] -= 8;
}
SetTexMods();
g_changed_surface = true;
Select_SetTexture(pt);
}
BOOL CALLBACK SurfaceDlgProc (
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch (uMsg)
{
case WM_INITDIALOG:
g_surfwin = hwndDlg;
SetTexMods ();
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
GetTexMods ();
EndDialog(hwndDlg, 1);
break;
case IDAPPLY:
GetTexMods ();
InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
UpdateWindow (g_qeglobals.d_hwndCamera);
break;
case IDCANCEL:
g_qeglobals.d_texturewin.texdef = g_old_texdef;
if (g_changed_surface)
Select_SetTexture(&g_qeglobals.d_texturewin.texdef);
EndDialog(hwndDlg, 0);
break;
}
break;
case WM_HSCROLL:
case WM_VSCROLL:
UpdateSpinners(uMsg, wParam, lParam);
InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
UpdateWindow (g_qeglobals.d_hwndCamera);
return 0;
default:
return FALSE;
}
}
void DoSurface (void)
{
// save current state for cancel
g_old_texdef = g_qeglobals.d_texturewin.texdef;
g_changed_surface = false;
DialogBox(g_qeglobals.d_hInstance, (char *)IDD_SURFACE, g_qeglobals.d_hwndMain, SurfaceDlgProc);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -1,605 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
#include "mru.h"
int screen_width;
int screen_height;
qboolean have_quit;
int update_bits;
HANDLE bsp_process;
//===========================================
void Sys_SetTitle (char *text)
{
SetWindowText (g_qeglobals.d_hwndMain, text);
}
HCURSOR waitcursor;
void Sys_BeginWait (void)
{
waitcursor = SetCursor (LoadCursor (NULL, IDC_WAIT));
}
void Sys_EndWait (void)
{
if (waitcursor)
{
SetCursor (waitcursor);
waitcursor = NULL;
}
}
void Sys_GetCursorPos (int *x, int *y)
{
POINT lpPoint;
GetCursorPos (&lpPoint);
*x = lpPoint.x;
*y = lpPoint.y;
}
void Sys_SetCursorPos (int x, int y)
{
SetCursorPos (x, y);
}
void Sys_UpdateWindows (int bits)
{
// Sys_Printf("updating 0x%X\n", bits);
update_bits |= bits;
//update_bits = -1;
}
void Sys_Beep (void)
{
MessageBeep (MB_ICONASTERISK);
}
char *TranslateString (char *buf)
{
static char buf2[32768];
int i, l;
char *out;
l = strlen(buf);
out = buf2;
for (i=0 ; i<l ; i++)
{
if (buf[i] == '\n')
{
*out++ = '\r';
*out++ = '\n';
}
else
*out++ = buf[i];
}
*out++ = 0;
return buf2;
}
void Sys_ClearPrintf (void)
{
char text[4];
text[0] = 0;
SendMessage (g_qeglobals.d_hwndEdit,
WM_SETTEXT,
0,
(LPARAM)text);
}
void Sys_Printf (char *text, ...)
{
va_list argptr;
char buf[32768];
char *out;
va_start (argptr,text);
vsprintf (buf, text,argptr);
va_end (argptr);
out = TranslateString (buf);
#ifdef LATER
Sys_Status(out);
#else
SendMessage (g_qeglobals.d_hwndEdit,
EM_REPLACESEL,
0,
(LPARAM)out);
#endif
}
double Sys_DoubleTime (void)
{
return clock()/ 1000.0;
}
void PrintPixels (HDC hDC)
{
int i;
PIXELFORMATDESCRIPTOR p[64];
printf ("### flags color layer\n");
for (i=1 ; i<64 ; i++)
{
if (!DescribePixelFormat ( hDC, i, sizeof(p[0]), &p[i]))
break;
printf ("%3i %5i %5i %5i\n", i,
p[i].dwFlags,
p[i].cColorBits,
p[i].bReserved);
}
printf ("%i modes\n", i-1);
}
//==========================================================================
void QEW_StopGL( HWND hWnd, HGLRC hGLRC, HDC hDC )
{
wglMakeCurrent( NULL, NULL );
wglDeleteContext( hGLRC );
ReleaseDC( hWnd, hDC );
}
int QEW_SetupPixelFormat(HDC hDC, qboolean zbuffer )
{
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
32, // depth bits
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int pixelformat = 0;
zbuffer = true;
if ( !zbuffer )
pfd.cDepthBits = 0;
if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 )
{
printf("%d",GetLastError());
Error ("ChoosePixelFormat failed");
}
if (!SetPixelFormat(hDC, pixelformat, &pfd))
Error ("SetPixelFormat failed");
return pixelformat;
}
/*
=================
Error
For abnormal program terminations
=================
*/
void Error (char *error, ...)
{
va_list argptr;
char text[1024];
char text2[1024];
int err;
err = GetLastError ();
va_start (argptr,error);
vsprintf (text, error,argptr);
va_end (argptr);
sprintf (text2, "%s\nGetLastError() = %i", text, err);
MessageBox(g_qeglobals.d_hwndMain, text2, "Error", 0 /* MB_OK */ );
exit (1);
}
/*
======================================================================
FILE DIALOGS
======================================================================
*/
qboolean ConfirmModified (void)
{
if (!modified)
return true;
if (MessageBox (g_qeglobals.d_hwndMain, "This will lose changes to the map"
, "warning", MB_OKCANCEL) == IDCANCEL)
return false;
return true;
}
static OPENFILENAME ofn; /* common dialog box structure */
static char szDirName[MAX_PATH]; /* directory string */
static char szFile[260]; /* filename string */
static char szFileTitle[260]; /* file title string */
static char szFilter[260] = /* filter string */
"QuakeEd file (*.map)\0*.map\0\0";
static char szProjectFilter[260] = /* filter string */
"QuakeEd project (*.qe4)\0*.qe4\0\0";
static char chReplace; /* string separator for szFilter */
static int i, cbString; /* integer count variables */
static HANDLE hf; /* file handle */
void OpenDialog (void)
{
/*
* Obtain the system directory name and
* store it in szDirName.
*/
strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, "basepath") );
strcat (szDirName, "\\maps");
/* Place the terminating null character in the szFile. */
szFile[0] = '\0';
/* Set the members of the OPENFILENAME structure. */
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = g_qeglobals.d_hwndCamera;
ofn.lpstrFilter = szFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.lpstrInitialDir = szDirName;
ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
OFN_FILEMUSTEXIST;
/* Display the Open dialog box. */
if (!GetOpenFileName(&ofn))
return; // canceled
// Add the file in MRU.
AddNewItem( g_qeglobals.d_lpMruMenu, ofn.lpstrFile);
// Refresh the File menu.
PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0),
ID_FILE_EXIT);
/* Open the file. */
Map_LoadFile (ofn.lpstrFile);
}
void ProjectDialog (void)
{
/*
* Obtain the system directory name and
* store it in szDirName.
*/
strcpy (szDirName, ValueForKey(g_qeglobals.d_project_entity, "basepath") );
strcat (szDirName, "\\scripts");
/* Place the terminating null character in the szFile. */
szFile[0] = '\0';
/* Set the members of the OPENFILENAME structure. */
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = g_qeglobals.d_hwndCamera;
ofn.lpstrFilter = szProjectFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.lpstrInitialDir = szDirName;
ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
OFN_FILEMUSTEXIST;
/* Display the Open dialog box. */
if (!GetOpenFileName(&ofn))
return; // canceled
// Refresh the File menu.
PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0),
ID_FILE_EXIT);
/* Open the file. */
if (!QE_LoadProject(ofn.lpstrFile))
Error ("Couldn't load project file");
}
void SaveAsDialog (void)
{
strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, "basepath") );
strcat (szDirName, "\\maps");
/* Place the terminating null character in the szFile. */
szFile[0] = '\0';
/* Set the members of the OPENFILENAME structure. */
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = g_qeglobals.d_hwndCamera;
ofn.lpstrFilter = szFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.lpstrInitialDir = szDirName;
ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT;
/* Display the Open dialog box. */
if (!GetSaveFileName(&ofn))
return; // canceled
DefaultExtension (ofn.lpstrFile, ".map");
strcpy (currentmap, ofn.lpstrFile);
// Add the file in MRU.
AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile);
// Refresh the File menu.
PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0),
ID_FILE_EXIT);
Map_SaveFile (ofn.lpstrFile, false); // ignore region
}
/*
=======================================================
Menu modifications
=======================================================
*/
/*
==================
FillBSPMenu
==================
*/
char *bsp_commands[256];
void FillBSPMenu (void)
{
HMENU hmenu;
epair_t *ep;
int i;
static int count;
hmenu = GetSubMenu (GetMenu(g_qeglobals.d_hwndMain), MENU_BSP);
for (i=0 ; i<count ; i++)
DeleteMenu (hmenu, CMD_BSPCOMMAND+i, MF_BYCOMMAND);
count = 0;
i = 0;
for (ep = g_qeglobals.d_project_entity->epairs ; ep ; ep=ep->next)
{
if (ep->key[0] == 'b' && ep->key[1] == 's' && ep->key[2] == 'p')
{
bsp_commands[i] = ep->key;
AppendMenu (hmenu, MF_ENABLED|MF_STRING,
CMD_BSPCOMMAND+i, (LPCTSTR)ep->key);
i++;
}
}
count = i;
}
//==============================================
/*
===============
CheckBspProcess
See if the BSP is done yet
===============
*/
void CheckBspProcess (void)
{
char outputpath[1024];
char temppath[512];
DWORD exitcode;
char *out;
BOOL ret;
if (!bsp_process)
return;
ret = GetExitCodeProcess (bsp_process, &exitcode);
if (!ret)
Error ("GetExitCodeProcess failed");
if (exitcode == STILL_ACTIVE)
return;
bsp_process = 0;
GetTempPath(512, temppath);
sprintf (outputpath, "%sjunk.txt", temppath);
LoadFile (outputpath, (void *)&out);
Sys_Printf ("%s", out);
Sys_Printf ("\ncompleted.\n");
free (out);
Sys_Beep ();
Pointfile_Check ();
}
extern int cambuttonstate;
/*
==================
WinMain
==================
*/
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance
,LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
double time, oldtime, delta;
HACCEL accelerators;
g_qeglobals.d_hInstance = hInstance;
InitCommonControls ();
screen_width = GetSystemMetrics (SM_CXFULLSCREEN);
screen_height = GetSystemMetrics (SM_CYFULLSCREEN);
// hack for broken NT 4.0 dual screen
if (screen_width > 2*screen_height)
screen_width /= 2;
accelerators = LoadAccelerators (hInstance
, MAKEINTRESOURCE(IDR_ACCELERATOR1));
if (!accelerators)
Error ("LoadAccelerators failed");
Main_Create (hInstance);
WCam_Create (hInstance);
WXY_Create (hInstance);
WZ_Create (hInstance);
CreateEntityWindow(hInstance);
// the project file can be specified on the command line,
// or implicitly found in the scripts directory
if (lpCmdLine && strlen(lpCmdLine))
{
ParseCommandLine (lpCmdLine);
if (!QE_LoadProject(argv[1]))
Error ("Couldn't load %s project file", argv[1]);
}
else if (!QE_LoadProject("scripts/quake.qe4"))
Error ("Couldn't load scripts/quake.qe4 project file");
QE_Init ();
Sys_Printf ("Entering message loop\n");
oldtime = Sys_DoubleTime ();
while (!have_quit)
{
Sys_EndWait (); // remove wait cursor if active
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
if (!TranslateAccelerator(g_qeglobals.d_hwndMain, accelerators, &msg) )
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
if (msg.message == WM_QUIT)
have_quit = true;
}
CheckBspProcess ();
time = Sys_DoubleTime ();
delta = time - oldtime;
oldtime = time;
if (delta > 0.2)
delta = 0.2;
// run time dependant behavior
Cam_MouseControl (delta);
// update any windows now
if (update_bits & W_CAMERA)
{
InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
UpdateWindow (g_qeglobals.d_hwndCamera);
}
if (update_bits & (W_Z | W_Z_OVERLAY) )
{
InvalidateRect(g_qeglobals.d_hwndZ, NULL, false);
UpdateWindow (g_qeglobals.d_hwndZ);
}
if ( update_bits & W_TEXTURE )
{
InvalidateRect(g_qeglobals.d_hwndTexture, NULL, false);
UpdateWindow (g_qeglobals.d_hwndEntity);
}
if (update_bits & (W_XY | W_XY_OVERLAY))
{
InvalidateRect(g_qeglobals.d_hwndXY, NULL, false);
UpdateWindow (g_qeglobals.d_hwndXY);
}
update_bits = 0;
if (!cambuttonstate && !have_quit)
{ // if not driving in the camera view, block
WaitMessage ();
}
}
/* return success of application */
return TRUE;
}

View file

@ -1,693 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU1 MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", ID_FILE_NEW
MENUITEM "&Open", ID_FILE_OPEN
MENUITEM "&Save", ID_FILE_SAVE
MENUITEM "Save &as...", ID_FILE_SAVEAS
MENUITEM "&Pointfile", ID_FILE_POINTFILE
MENUITEM "Load &project", ID_FILE_LOADPROJECT
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Copy brush", ID_EDIT_COPYBRUSH, GRAYED
MENUITEM "&Paste brush", ID_EDIT_PASTEBRUSH, GRAYED
END
POPUP "&View"
BEGIN
MENUITEM "Texture View\tT", ID_VIEW_TEXTURE
MENUITEM "Console View\tO", ID_VIEW_CONSOLE
MENUITEM "Entity View\tN", ID_VIEW_ENTITY
MENUITEM SEPARATOR
MENUITEM "&Center\tEnd", ID_VIEW_CENTER
MENUITEM "&Up Floor\tPage Up", ID_VIEW_UPFLOOR
MENUITEM "&Down Floor\tPage Down", ID_VIEW_DOWNFLOOR
MENUITEM SEPARATOR
MENUITEM "&XY 100%", ID_VIEW_100
MENUITEM "XY Zoom &In\tDelete", ID_VIEW_ZOOMIN
MENUITEM "XY Zoom &Out\tInsert", ID_VIEW_ZOOMOUT
MENUITEM SEPARATOR
MENUITEM "Show &Names", ID_VIEW_SHOWNAMES, CHECKED
MENUITEM "Show Blocks", ID_VIEW_SHOWBLOCKS
MENUITEM "Show C&oordinates", ID_VIEW_SHOWCOORDINATES
, CHECKED
MENUITEM "Show &Entities", ID_VIEW_SHOWENT, CHECKED
MENUITEM "Show &Path", ID_VIEW_SHOWPATH, CHECKED
MENUITEM "Show &Lights", ID_VIEW_SHOWLIGHTS, CHECKED
MENUITEM "Show &Water", ID_VIEW_SHOWWATER, CHECKED
MENUITEM "Show Clip &Brush", ID_VIEW_SHOWCLIP, CHECKED
MENUITEM "Show Wor&ld", ID_VIEW_SHOWWORLD, CHECKED
MENUITEM "Show Detail\tctrl-D", ID_VIEW_SHOWDETAIL, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Z 100%", ID_VIEW_Z100
MENUITEM "Z Zoo&m In\tctrl-Delete", ID_VIEW_ZZOOMIN
MENUITEM "Z Zoom O&ut\tctrl-Insert", ID_VIEW_ZZOOMOUT
END
POPUP "&Selection"
BEGIN
MENUITEM "Drag &Edges\tE", ID_SELECTION_DRAGEDGES
MENUITEM "Drag &Vertecies\tV", ID_SELECTION_DRAGVERTECIES
MENUITEM "&Clone\tspace", ID_SELECTION_CLONE
MENUITEM "Deselect\tEsc", ID_SELECTION_DESELECT
MENUITEM "&Delete\tBackspace", ID_SELECTION_DELETE
MENUITEM "Flip &X", ID_BRUSH_FLIPX
MENUITEM "Flip &Y", ID_BRUSH_FLIPY
MENUITEM "Flip &Z", ID_BRUSH_FLIPZ
MENUITEM "Rotate X", ID_BRUSH_ROTATEX
MENUITEM "Rotate Y", ID_BRUSH_ROTATEY
MENUITEM "Rotate Z", ID_BRUSH_ROTATEZ
MENUITEM "Arbitrary rotation", ID_SELECTION_ARBITRARYROTATION
MENUITEM "Make &Hollow", ID_SELECTION_MAKEHOLLOW
MENUITEM "CSG &Subtract", ID_SELECTION_CSGSUBTRACT
MENUITEM "Select Complete &Tall", ID_SELECTION_SELECTCOMPLETETALL
MENUITEM "Select T&ouching", ID_SELECTION_SELECTTOUCHING
MENUITEM "Select &Partial Tall", ID_SELECTION_SELECTPARTIALTALL
MENUITEM "Select &Inside", ID_SELECTION_SELECTINSIDE
MENUITEM "Connect entities\tCtrl-k", ID_SELECTION_CONNECT
MENUITEM "Ungroup entity", ID_SELECTION_UNGROUPENTITY
MENUITEM "Make detail\tCtrl-m", ID_SELECTION_MAKE_DETAIL
MENUITEM "Make structural", ID_SELECTION_MAKE_STRUCTURAL
END
POPUP "&Bsp"
BEGIN
MENUITEM SEPARATOR
END
POPUP "&Grid"
BEGIN
MENUITEM "Grid1\t&1", ID_GRID_1
MENUITEM "Grid2\t&2", ID_GRID_2
MENUITEM "Grid4\t&3", ID_GRID_4
MENUITEM "Grid8\t&4", ID_GRID_8, CHECKED
MENUITEM "Grid16\t&5", ID_GRID_16
MENUITEM "Grid32\t&6", ID_GRID_32
MENUITEM "Grid64\t&7", ID_GRID_64
END
POPUP "&Textures"
BEGIN
MENUITEM "Show In &Use\tU", ID_TEXTURES_SHOWINUSE
MENUITEM "&Surface inspector\tS", ID_TEXTURES_INSPECTOR
MENUITEM SEPARATOR
MENUITEM "&Wireframe", ID_TEXTURES_WIREFRAME
MENUITEM "&Flat shade", ID_TEXTURES_FLATSHADE
MENUITEM "&Nearest", ID_VIEW_NEAREST
MENUITEM "Nearest &Mipmap", ID_VIEW_NEARESTMIPMAP
MENUITEM "&Linear", ID_VIEW_LINEAR
MENUITEM "&Bilinear", ID_VIEW_BILINEAR
MENUITEM "B&ilinear Mipmap", ID_VIEW_BILINEARMIPMAP
MENUITEM "T&rilinear", ID_VIEW_TRILINEAR
MENUITEM SEPARATOR
END
POPUP "&Misc"
BEGIN
MENUITEM "&Benchmark", ID_MISC_BENCHMARK
POPUP "&Colors"
BEGIN
MENUITEM "&Texture Background", ID_TEXTUREBK
MENUITEM "Grid Background", ID_COLORS_XYBK
MENUITEM "Grid Major", ID_COLORS_MAJOR
MENUITEM "Grid Minor", ID_COLORS_MINOR
END
MENUITEM "&Gamma", ID_MISC_GAMMA
MENUITEM "Find brush", ID_MISC_FINDBRUSH
MENUITEM "Next leak spot\tctrl-l", ID_MISC_NEXTLEAKSPOT
MENUITEM "Previous leak spot\tctrl-p", ID_MISC_PREVIOUSLEAKSPOT
MENUITEM "&Print XY View", ID_MISC_PRINTXY
MENUITEM "&Select Entity Color\tK", ID_MISC_SELECTENTITYCOLOR
END
POPUP "&Region"
BEGIN
MENUITEM "&Off", ID_REGION_OFF
MENUITEM "&Set XY", ID_REGION_SETXY
MENUITEM "Set &Tall Brush", ID_REGION_SETTALLBRUSH
MENUITEM "Set &Brush", ID_REGION_SETBRUSH
MENUITEM "Set Se&lected Brushes", ID_REGION_SETSELECTION
END
POPUP "&Brush"
BEGIN
MENUITEM "3 sided\tctrl-3", ID_BRUSH_3SIDED
MENUITEM "4 sided\tctrl-4", ID_BRUSH_4SIDED
MENUITEM "5 sided\tctrl-5", ID_BRUSH_5SIDED
MENUITEM "6 sided\tctrl-6", ID_BRUSH_6SIDED
MENUITEM "7 sided\tctrl-7", ID_BRUSH_7SIDED
MENUITEM "8 sided\tctrl-8", ID_BRUSH_8SIDED
MENUITEM "9 sided\tctrl-9", ID_BRUSH_9SIDED
MENUITEM "Arbitrary sided", ID_BRUSH_ARBITRARYSIDED
END
POPUP "&Help"
BEGIN
MENUITEM "&About", ID_HELP_ABOUT
END
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_FINDTEXTURE DIALOG DISCARDABLE 0, 0, 129, 53
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Find Texture"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,10,30,50,14
PUSHBUTTON "Cancel",IDCANCEL,70,30,50,14
EDITTEXT IDC_EDIT1,10,10,110,14,ES_AUTOHSCROLL
END
IDD_ENTITY DIALOGEX 0, 0, 234, 389
STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS |
WS_CAPTION | WS_THICKFRAME
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE
CAPTION "Entity"
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
LISTBOX IDC_E_LIST,5,5,180,99,LBS_SORT | LBS_NOINTEGRALHEIGHT |
LBS_WANTKEYBOARDINPUT | WS_VSCROLL | WS_TABSTOP,
WS_EX_CLIENTEDGE
EDITTEXT IDC_E_COMMENT,5,106,180,50,ES_MULTILINE | ES_READONLY |
WS_VSCROLL,WS_EX_CLIENTEDGE
PUSHBUTTON "135",IDC_E_135,5,290,15,15
PUSHBUTTON "180",IDC_E_180,5,305,15,15
PUSHBUTTON "225",IDC_E_225,5,320,15,15
PUSHBUTTON "270",IDC_E_270,21,320,15,15
PUSHBUTTON "90",IDC_E_90,21,290,15,15
PUSHBUTTON "45",IDC_E_45,35,290,15,15
PUSHBUTTON "0",IDC_E_0,35,305,15,15
PUSHBUTTON "315",IDC_E_315,35,320,15,15
PUSHBUTTON "Up",IDC_E_UP,60,295,15,15
PUSHBUTTON "Dn",IDC_E_DOWN,60,310,15,15
CONTROL "",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,5,160,50,8
CONTROL "",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,5,170,50,8
CONTROL "",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,5,180,50,8
CONTROL "",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,5,190,50,8
CONTROL "",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,65,160,50,8
CONTROL "",IDC_CHECK6,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,65,170,50,8
CONTROL "",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,65,180,50,8
CONTROL "",IDC_CHECK8,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
WS_TABSTOP,65,190,50,8
CONTROL "!Easy",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
125,160,50,8
CONTROL "!Medium",IDC_CHECK10,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,125,170,50,8
CONTROL "!Hard",IDC_CHECK11,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,125,180,50,10
CONTROL "!DeathMatch",IDC_CHECK12,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,125,190,55,10
LISTBOX IDC_E_PROPS,5,205,180,50,LBS_SORT | LBS_USETABSTOPS |
LBS_NOINTEGRALHEIGHT | LBS_WANTKEYBOARDINPUT |
WS_VSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE
PUSHBUTTON "Del Key/Pair",IDC_E_DELPROP,105,295,45,15
EDITTEXT IDC_E_STATUS,83,312,95,30,ES_MULTILINE | ES_AUTOVSCROLL |
ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
LTEXT "Key",IDC_STATIC_KEY,5,260,25,10
LTEXT "Value",IDC_STATIC_VALUE,5,275,25,10
EDITTEXT IDC_E_KEY_FIELD,40,260,135,14,ES_AUTOHSCROLL
EDITTEXT IDC_E_VALUE_FIELD,40,275,135,14,ES_AUTOHSCROLL
END
IDD_GAMMA DIALOGEX 0, 0, 127, 76
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Gamma"
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,10,40,50,14
PUSHBUTTON "Cancel",IDCANCEL,65,40,50,14
EDITTEXT IDC_G_EDIT,30,15,66,13,ES_AUTOHSCROLL,WS_EX_CLIENTEDGE
END
IDD_FINDBRUSH DIALOGEX 0, 0, 127, 76
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Find brush"
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,5,55,50,14
PUSHBUTTON "Cancel",IDCANCEL,65,55,50,14
EDITTEXT IDC_FIND_ENTITY,80,15,46,13,ES_AUTOHSCROLL,
WS_EX_CLIENTEDGE
EDITTEXT IDC_FIND_BRUSH,80,30,46,13,ES_AUTOHSCROLL,
WS_EX_CLIENTEDGE
LTEXT "Entity number",IDC_STATIC,10,15,60,8
LTEXT "Brush number",IDC_STATIC,10,30,65,8
END
IDD_ROTATE DIALOG DISCARDABLE 0, 0, 186, 71
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Arbitrary rotation"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
EDITTEXT IDC_ROTX,30,5,40,14,ES_AUTOHSCROLL
LTEXT "x",IDC_STATIC,5,10,8,8
EDITTEXT IDC_ROTZ,30,45,40,14,ES_AUTOHSCROLL
LTEXT "y",IDC_STATIC,5,25,8,8
EDITTEXT IDC_ROTY,30,25,40,14,ES_AUTOHSCROLL
LTEXT "z",IDC_STATIC,5,45,8,8
END
IDD_SIDES DIALOG DISCARDABLE 0, 0, 186, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Arbitrrary sides"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
EDITTEXT IDC_SIDES,50,15,40,14,ES_AUTOHSCROLL
LTEXT "Sides",IDC_STATIC,15,15,18,8
END
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 274, 212
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About QuakeEd"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,217,7,50,14
CONTROL 127,IDC_STATIC,"Static",SS_BITMAP,7,7,83,58
CONTROL "QuakeEd 4.0(beta)\nCopyright (C) 1997 id Software, Inc.",
IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,100,10,
110,23
GROUPBOX "OpenGL Properties",IDC_STATIC,5,75,265,50
LTEXT "Vendor:\t\tWHOEVER",IDC_ABOUT_GLVENDOR,10,90,125,10
LTEXT "Version:\t\t1.1",IDC_ABOUT_GLVERSION,10,100,125,10
LTEXT "Renderer:\tWHATEVER",IDC_ABOUT_GLRENDERER,10,110,125,10
LTEXT "WHATEVER",IDC_ABOUT_GLEXTENSIONS,10,140,255,60
GROUPBOX "OpenGL Extensions",IDC_STATIC,5,130,265,80
END
IDD_SURFACE DIALOG DISCARDABLE 400, 100, 392, 181
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Surface inspector"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,5,155,40,14
PUSHBUTTON "Cancel",IDCANCEL,105,155,40,14
EDITTEXT IDC_HSHIFT,85,45,35,15,ES_AUTOHSCROLL
SCROLLBAR IDC_HSHIFTA,120,45,10,15,SBS_VERT
LTEXT "Horizontal shift",IDC_STATIC,10,45,65,8
LTEXT "Vertical shift",IDC_STATIC,10,60,65,8
LTEXT "Horizontal stretch",IDC_STATIC,10,75,65,8
LTEXT "Vertical stretch",IDC_STATIC,10,90,65,8
LTEXT "Rotate",IDC_STATIC,10,105,65,8
LTEXT "value",IDC_STATIC,10,120,65,8
EDITTEXT IDC_VSHIFT,85,60,35,15,ES_AUTOHSCROLL
SCROLLBAR IDC_VSHIFTA,120,60,10,15,SBS_VERT
EDITTEXT IDC_HSCALE,85,75,35,15,ES_AUTOHSCROLL
SCROLLBAR IDC_HSCALEA,120,75,10,15,SBS_VERT
EDITTEXT IDC_VSCALE,85,90,35,15,ES_AUTOHSCROLL
SCROLLBAR IDC_VSCALEA,120,90,10,15,SBS_VERT
EDITTEXT IDC_ROTATE,85,105,35,15,ES_AUTOHSCROLL
SCROLLBAR IDC_ROTATEA,120,105,10,15,SBS_VERT
EDITTEXT IDC_VALUE,85,120,35,15,ES_AUTOHSCROLL
EDITTEXT IDC_TEXTURE,50,15,80,14,ES_AUTOHSCROLL
CONTROL "light",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,10,41,8
CONTROL "slick",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,20,41,8
CONTROL "sky",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,30,41,8
CONTROL "warp",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,40,41,8
CONTROL "trans33",IDC_CHECK5,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,160,50,41,8
CONTROL "trans66",IDC_CHECK6,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,160,60,41,8
CONTROL "flowing",IDC_CHECK7,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,160,70,41,8
CONTROL "nodraw",IDC_CHECK8,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,160,80,41,8
CONTROL "100",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,90,41,8
CONTROL "200",IDC_CHECK10,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,100,41,8
CONTROL "400",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,110,41,8
CONTROL "800",IDC_CHECK12,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,120,41,8
CONTROL "1000",IDC_CHECK13,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,130,41,8
CONTROL "2000",IDC_CHECK14,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,140,41,8
CONTROL "4000",IDC_CHECK15,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,150,41,8
CONTROL "8000",IDC_CHECK16,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
160,160,41,8
LTEXT "Texture",IDC_STATIC,10,18,30,8
PUSHBUTTON "Apply",IDAPPLY,55,155,40,14
CONTROL "10000",IDC_CHECK17,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,10,41,8
CONTROL "20000",IDC_CHECK18,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,20,41,8
CONTROL "40000",IDC_CHECK19,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,30,41,8
CONTROL "80000",IDC_CHECK20,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,40,41,8
CONTROL "100000",IDC_CHECK21,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,50,41,8
CONTROL "200000",IDC_CHECK22,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,60,41,8
CONTROL "400000",IDC_CHECK23,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,70,41,8
CONTROL "800000",IDC_CHECK24,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,80,41,8
CONTROL "1000000",IDC_CHECK25,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,90,41,8
CONTROL "2000000",IDC_CHECK26,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,100,41,8
CONTROL "4000000",IDC_CHECK27,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,110,41,8
CONTROL "8000000",IDC_CHECK28,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,120,41,8
CONTROL "10000000",IDC_CHECK29,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,130,40,8
CONTROL "20000000",IDC_CHECK30,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,140,45,8
CONTROL "40000000",IDC_CHECK31,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,150,45,8
CONTROL "80000000",IDC_CHECK32,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,210,160,45,8
CONTROL "solid",IDC_CHECK33,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,280,10,41,8
CONTROL "window",IDC_CHECK34,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,280,20,41,8
CONTROL "aux",IDC_CHECK35,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,31,41,8
CONTROL "lava",IDC_CHECK36,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,41,41,8
CONTROL "slime",IDC_CHECK37,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,280,50,41,8
CONTROL "water",IDC_CHECK38,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,280,60,41,8
CONTROL "mist",IDC_CHECK39,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,71,41,8
CONTROL "80",IDC_CHECK40,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,81,41,8
CONTROL "100",IDC_CHECK41,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,90,41,8
CONTROL "200",IDC_CHECK42,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,100,41,8
CONTROL "400",IDC_CHECK43,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,111,41,8
CONTROL "800",IDC_CHECK44,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,121,41,8
CONTROL "1000",IDC_CHECK45,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,130,41,8
CONTROL "2000",IDC_CHECK46,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,140,41,8
CONTROL "4000",IDC_CHECK47,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,151,41,8
CONTROL "8000",IDC_CHECK48,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
280,161,41,8
CONTROL "playerclip",IDC_CHECK49,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,10,41,8
CONTROL "monsterclip",IDC_CHECK50,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,20,50,8
CONTROL "current_0",IDC_CHECK51,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,31,50,8
CONTROL "current_90",IDC_CHECK52,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,41,50,8
CONTROL "current_180",IDC_CHECK53,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,50,50,8
CONTROL "current_270",IDC_CHECK54,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,60,50,8
CONTROL "current_up",IDC_CHECK55,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,71,50,8
CONTROL "current_dn",IDC_CHECK56,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,81,50,8
CONTROL "origin",IDC_CHECK57,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,90,41,8
CONTROL "monster",IDC_CHECK58,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,100,41,8
CONTROL "corpse",IDC_CHECK59,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,111,41,8
CONTROL "detail",IDC_CHECK60,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,121,41,8
CONTROL "translucent",IDC_CHECK61,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,130,50,8
CONTROL "ladder",IDC_CHECK62,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,140,45,8
CONTROL "40000000",IDC_CHECK63,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,151,45,8
CONTROL "80000000",IDC_CHECK64,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,330,161,45,8
GROUPBOX "Surf flags",IDC_STATIC,150,0,115,175
GROUPBOX "Content flags",IDC_STATIC,270,0,115,175
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Id Software\0"
VALUE "FileDescription", "qe3\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "qe3\0"
VALUE "LegalCopyright", "Copyright © 1996\0"
VALUE "OriginalFilename", "qe3.exe\0"
VALUE "ProductName", "Id Software qe3\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"3", ID_BRUSH_3SIDED, VIRTKEY, CONTROL, NOINVERT
"4", ID_BRUSH_4SIDED, VIRTKEY, CONTROL, NOINVERT
"5", ID_BRUSH_5SIDED, VIRTKEY, CONTROL, NOINVERT
"6", ID_BRUSH_6SIDED, VIRTKEY, CONTROL, NOINVERT
"7", ID_BRUSH_7SIDED, VIRTKEY, CONTROL, NOINVERT
"8", ID_BRUSH_8SIDED, VIRTKEY, CONTROL, NOINVERT
"9", ID_BRUSH_9SIDED, VIRTKEY, CONTROL, NOINVERT
"D", ID_VIEW_SHOWDETAIL, VIRTKEY, CONTROL, NOINVERT
"K", ID_SELECTION_CONNECT, VIRTKEY, CONTROL, NOINVERT
"L", ID_MISC_NEXTLEAKSPOT, VIRTKEY, CONTROL, NOINVERT
"M", ID_SELECTION_MAKE_DETAIL, VIRTKEY, CONTROL, NOINVERT
"O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"P", ID_MISC_PREVIOUSLEAKSPOT, VIRTKEY, CONTROL, NOINVERT
"S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
VK_DELETE, ID_VIEW_ZZOOMIN, VIRTKEY, CONTROL, NOINVERT
VK_INSERT, ID_VIEW_ZZOOMOUT, VIRTKEY, CONTROL, NOINVERT
"X", ID_FILE_EXIT, VIRTKEY, CONTROL, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// Toolbar
//
IDR_TOOLBAR1 TOOLBAR DISCARDABLE 16, 15
BEGIN
BUTTON ID_BRUSH_FLIPX
BUTTON ID_BRUSH_ROTATEX
BUTTON ID_BRUSH_FLIPY
BUTTON ID_BRUSH_ROTATEY
BUTTON ID_BRUSH_FLIPZ
BUTTON ID_BRUSH_ROTATEZ
BUTTON ID_SELECTION_SELECTCOMPLETETALL
BUTTON ID_SELECTION_SELECTTOUCHING
BUTTON ID_SELECTION_SELECTPARTIALTALL
BUTTON ID_SELECTION_SELECTINSIDE
BUTTON ID_SELECTION_CSGSUBTRACT
BUTTON ID_SELECTION_MAKEHOLLOW
BUTTON ID_TEXTURES_WIREFRAME
BUTTON ID_TEXTURES_FLATSHADE
BUTTON ID_VIEW_TRILINEAR
END
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDR_TOOLBAR1 BITMAP DISCARDABLE "toolbar1.bmp"
IDB_BITMAP1 BITMAP DISCARDABLE "q.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ENTITY, DIALOG
BEGIN
RIGHTMARGIN, 227
BOTTOMMARGIN, 387
END
IDD_GAMMA, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 120
TOPMARGIN, 7
BOTTOMMARGIN, 68
END
IDD_FINDBRUSH, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 120
TOPMARGIN, 7
BOTTOMMARGIN, 68
END
IDD_ROTATE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 64
END
IDD_SIDES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
IDD_ABOUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 267
TOPMARGIN, 7
BOTTOMMARGIN, 205
END
IDD_SURFACE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 385
TOPMARGIN, 7
BOTTOMMARGIN, 174
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "icon1.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -1,306 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// win_xy.c -- windows specific xy view code
#include "qe3.h"
static HDC s_hdcXY;
static HGLRC s_hglrcXY;
static unsigned s_stipple[32] =
{
0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,
0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,
0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,
0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,
0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,
0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,
0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,
0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,
};
/*
============
WXY_WndProc
============
*/
LONG WINAPI WXY_WndProc (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
int fwKeys, xPos, yPos;
RECT rect;
GetClientRect(hWnd, &rect);
switch (uMsg)
{
case WM_CREATE:
s_hdcXY = GetDC(hWnd);
QEW_SetupPixelFormat(s_hdcXY, false);
if ( ( s_hglrcXY = wglCreateContext( s_hdcXY ) ) == 0 )
Error( "wglCreateContext in WXY_WndProc failed" );
if (!wglMakeCurrent( s_hdcXY, s_hglrcXY ))
Error ("wglMakeCurrent failed");
if (!wglShareLists( g_qeglobals.d_hglrcBase, s_hglrcXY ) )
Error( "wglShareLists in WXY_WndProc failed" );
glPolygonStipple ((char *)s_stipple);
glLineStipple (3, 0xaaaa);
return 0;
case WM_DESTROY:
QEW_StopGL( hWnd, s_hglrcXY, s_hdcXY );
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
if (!wglMakeCurrent( s_hdcXY, s_hglrcXY ))
Error ("wglMakeCurrent failed");
QE_CheckOpenGLForErrors();
XY_Draw ();
QE_CheckOpenGLForErrors();
SwapBuffers(s_hdcXY);
EndPaint(hWnd, &ps);
}
return 0;
case WM_KEYDOWN:
return QE_KeyDown (wParam);
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
if ( GetTopWindow( g_qeglobals.d_hwndMain ) != hWnd)
BringWindowToTop(hWnd);
SetFocus( g_qeglobals.d_hwndXY );
SetCapture( g_qeglobals.d_hwndXY );
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
XY_MouseDown (xPos, yPos, fwKeys);
return 0;
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONUP:
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
XY_MouseUp (xPos, yPos, fwKeys);
if (! (fwKeys & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))
ReleaseCapture ();
return 0;
case WM_MOUSEMOVE:
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
XY_MouseMoved (xPos, yPos, fwKeys);
return 0;
case WM_SIZE:
g_qeglobals.d_xy.width = rect.right;
g_qeglobals.d_xy.height = rect.bottom;
InvalidateRect( g_qeglobals.d_hwndXY, NULL, false);
return 0;
case WM_NCCALCSIZE:// don't let windows copy pixels
DefWindowProc (hWnd, uMsg, wParam, lParam);
return WVR_REDRAW;
case WM_KILLFOCUS:
case WM_SETFOCUS:
SendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 );
return 0;
case WM_CLOSE:
DestroyWindow (hWnd);
return 0;
}
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
/*
==============
WXY_Create
==============
*/
void WXY_Create (HINSTANCE hInstance)
{
WNDCLASS wc;
/* Register the camera class */
memset (&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WXY_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL; //(HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = XY_WINDOW_CLASS;
if (!RegisterClass (&wc) )
Error ("RegisterClass: failed");
g_qeglobals.d_hwndXY = CreateWindow (XY_WINDOW_CLASS ,
"XY View",
QE3_STYLE ,
ZWIN_WIDTH,
(int)(screen_height*CWIN_SIZE)-20,
screen_width-ZWIN_WIDTH,
(int)(screen_height*(1.0-CWIN_SIZE)-38), // size
g_qeglobals.d_hwndMain, // parent
0, // no menu
hInstance,
NULL);
if (!g_qeglobals.d_hwndXY )
Error ("Couldn't create XY View");
LoadWindowState(g_qeglobals.d_hwndXY, "xywindow");
ShowWindow(g_qeglobals.d_hwndXY, SW_SHOWDEFAULT);
}
static void WXY_InitPixelFormat( PIXELFORMATDESCRIPTOR *pPFD )
{
memset( pPFD, 0, sizeof( *pPFD ) );
pPFD->nSize = sizeof( PIXELFORMATDESCRIPTOR );
pPFD->nVersion = 1;
pPFD->dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
pPFD->iPixelType = PFD_TYPE_RGBA;
pPFD->cColorBits = 24;
pPFD->cDepthBits = 32;
pPFD->iLayerType = PFD_MAIN_PLANE;
}
void WXY_Print( void )
{
DOCINFO di;
PRINTDLG pd;
/*
** initialize the PRINTDLG struct and execute it
*/
memset( &pd, 0, sizeof( pd ) );
pd.lStructSize = sizeof( pd );
pd.hwndOwner = g_qeglobals.d_hwndXY;
pd.Flags = PD_RETURNDC;
pd.hInstance = 0;
if ( !PrintDlg( &pd ) || !pd.hDC )
{
MessageBox( g_qeglobals.d_hwndMain, "Could not PrintDlg()", "QE4 Print Error", MB_OK | MB_ICONERROR );
return;
}
/*
** StartDoc
*/
memset( &di, 0, sizeof( di ) );
di.cbSize = sizeof( di );
di.lpszDocName = "QE4";
if ( StartDoc( pd.hDC, &di ) <= 0 )
{
MessageBox( g_qeglobals.d_hwndMain, "Could not StartDoc()", "QE4 Print Error", MB_OK | MB_ICONERROR );
return;
}
/*
** StartPage
*/
if ( StartPage( pd.hDC ) <= 0 )
{
MessageBox( g_qeglobals.d_hwndMain, "Could not StartPage()", "QE4 Print Error", MB_OK | MB_ICONERROR );
return;
}
/*
** read pixels from the XY window
*/
{
int bmwidth = 320, bmheight = 320;
int pwidth, pheight;
RECT r;
GetWindowRect( g_qeglobals.d_hwndXY, &r );
bmwidth = r.right - r.left;
bmheight = r.bottom - r.top;
pwidth = GetDeviceCaps( pd.hDC, PHYSICALWIDTH ) - GetDeviceCaps( pd.hDC, PHYSICALOFFSETX );
pheight = GetDeviceCaps( pd.hDC, PHYSICALHEIGHT ) - GetDeviceCaps( pd.hDC, PHYSICALOFFSETY );
StretchBlt( pd.hDC,
0, 0,
pwidth, pheight,
s_hdcXY,
0, 0,
bmwidth, bmheight,
SRCCOPY );
}
/*
** EndPage and EndDoc
*/
if ( EndPage( pd.hDC ) <= 0 )
{
MessageBox( g_qeglobals.d_hwndMain, "QE4 Print Error", "Could not EndPage()", MB_OK | MB_ICONERROR );
return;
}
if ( EndDoc( pd.hDC ) <= 0 )
{
MessageBox( g_qeglobals.d_hwndMain, "QE4 Print Error", "Could not EndDoc()", MB_OK | MB_ICONERROR );
return;
}
}

View file

@ -1,195 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// win_cam.c -- windows specific camera view code
#include "qe3.h"
static HDC s_hdcZ;
static HGLRC s_hglrcZ;
/*
============
WZ_WndProc
============
*/
LONG WINAPI WZ_WndProc (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
int fwKeys, xPos, yPos;
RECT rect;
GetClientRect(hWnd, &rect);
switch (uMsg)
{
case WM_DESTROY:
QEW_StopGL( hWnd, s_hglrcZ, s_hdcZ );
return 0;
case WM_CREATE:
s_hdcZ = GetDC(hWnd);
QEW_SetupPixelFormat( s_hdcZ, false);
if ( ( s_hglrcZ = wglCreateContext( s_hdcZ ) ) == 0 )
Error( "wglCreateContext in WZ_WndProc failed" );
if (!wglMakeCurrent( s_hdcZ, s_hglrcZ ))
Error ("wglMakeCurrent in WZ_WndProc failed");
if (!wglShareLists( g_qeglobals.d_hglrcBase, s_hglrcZ ) )
Error( "wglShareLists in WZ_WndProc failed" );
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
if ( !wglMakeCurrent( s_hdcZ, s_hglrcZ ) )
Error ("wglMakeCurrent failed");
QE_CheckOpenGLForErrors();
Z_Draw ();
SwapBuffers(s_hdcZ);
EndPaint(hWnd, &ps);
}
return 0;
case WM_KEYDOWN:
QE_KeyDown (wParam);
return 0;
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
if (GetTopWindow(g_qeglobals.d_hwndMain) != hWnd)
BringWindowToTop(hWnd);
SetFocus( g_qeglobals.d_hwndZ );
SetCapture( g_qeglobals.d_hwndZ );
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
Z_MouseDown (xPos, yPos, fwKeys);
return 0;
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONUP:
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
Z_MouseUp (xPos, yPos, fwKeys);
if (! (fwKeys & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))
ReleaseCapture ();
return 0;
case WM_GETMINMAXINFO:
{
MINMAXINFO *pmmi = (LPMINMAXINFO) lParam;
pmmi->ptMinTrackSize.x = ZWIN_WIDTH;
return 0;
}
case WM_MOUSEMOVE:
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
Z_MouseMoved (xPos, yPos, fwKeys);
return 0;
case WM_SIZE:
z.width = rect.right;
z.height = rect.bottom;
InvalidateRect( g_qeglobals.d_hwndZ, NULL, false);
return 0;
case WM_NCCALCSIZE:// don't let windows copy pixels
DefWindowProc (hWnd, uMsg, wParam, lParam);
return WVR_REDRAW;
case WM_KILLFOCUS:
case WM_SETFOCUS:
SendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 );
return 0;
case WM_CLOSE:
/* call destroy window to cleanup and go away */
DestroyWindow (hWnd);
return 0;
}
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
/*
==============
WZ_Create
==============
*/
void WZ_Create (HINSTANCE hInstance)
{
WNDCLASS wc;
/* Register the camera class */
memset (&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WZ_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = Z_WINDOW_CLASS;
if (!RegisterClass (&wc) )
Error ("WCam_Register: failed");
g_qeglobals.d_hwndZ = CreateWindow (Z_WINDOW_CLASS ,
"Z",
QE3_STYLE,
0,20,ZWIN_WIDTH,screen_height-38, // size
g_qeglobals.d_hwndMain, // parent
0, // no menu
hInstance,
NULL);
if (!g_qeglobals.d_hwndZ)
Error ("Couldn't create zwindow");
LoadWindowState(g_qeglobals.d_hwndZ, "zwindow");
ShowWindow (g_qeglobals.d_hwndZ, SW_SHOWDEFAULT);
}

973
qe4/xy.c
View file

@ -1,973 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
#define PAGEFLIPS 2
/*
============
XY_Init
============
*/
void XY_Init (void)
{
g_qeglobals.d_xy.origin[0] = 0;
g_qeglobals.d_xy.origin[1] = 20;
g_qeglobals.d_xy.origin[2] = 46;
g_qeglobals.d_xy.scale = 1;
}
/*
============================================================================
MOUSE ACTIONS
============================================================================
*/
static int cursorx, cursory;
static int buttonstate;
static int pressx, pressy;
static vec3_t pressdelta;
static qboolean press_selection;
void XY_ToPoint (int x, int y, vec3_t point)
{
point[0] = g_qeglobals.d_xy.origin[0] + (x - g_qeglobals.d_xy.width/2)/g_qeglobals.d_xy.scale;
point[1] = g_qeglobals.d_xy.origin[1] + (y - g_qeglobals.d_xy.height/2)/g_qeglobals.d_xy.scale;
point[2] = 0;
}
void XY_ToGridPoint (int x, int y, vec3_t point)
{
point[0] = g_qeglobals.d_xy.origin[0] + (x - g_qeglobals.d_xy.width/2)/g_qeglobals.d_xy.scale;
point[1] = g_qeglobals.d_xy.origin[1] + (y - g_qeglobals.d_xy.height/2)/g_qeglobals.d_xy.scale;
point[2] = 0;
point[0] = floor(point[0]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;
point[1] = floor(point[1]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;
}
/*
==============
XY_MouseDown
==============
*/
void XY_MouseDown (int x, int y, int buttons)
{
vec3_t point;
vec3_t origin, dir, right, up;
buttonstate = buttons;
pressx = x;
pressy = y;
VectorCopy (vec3_origin, pressdelta);
XY_ToPoint (x, y, point);
VectorCopy (point, origin);
origin[2] = 8192;
dir[0] = 0; dir[1] = 0; dir[2] = -1;
right[0] = 1/g_qeglobals.d_xy.scale; right[1] = 0; right[2] = 0;
up[0] = 0; up[1] = 1/g_qeglobals.d_xy.scale; up[2] = 0;
press_selection = (selected_brushes.next != &selected_brushes);
Sys_GetCursorPos (&cursorx, &cursory);
// lbutton = manipulate selection
// shift-LBUTTON = select
if ( (buttons == MK_LBUTTON)
|| (buttons == (MK_LBUTTON | MK_SHIFT))
|| (buttons == (MK_LBUTTON | MK_CONTROL))
|| (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT)) )
{
Drag_Begin (x, y, buttons,
right, up,
origin, dir);
return;
}
// control mbutton = move camera
if (buttonstate == (MK_CONTROL|MK_MBUTTON) )
{
camera.origin[0] = point[0];
camera.origin[1] = point[1];
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
}
// mbutton = angle camera
if (buttonstate == MK_MBUTTON)
{
VectorSubtract (point, camera.origin, point);
if (point[1] || point[0])
{
camera.angles[YAW] = 180/Q_PI*atan2 (point[1], point[0]);
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
}
}
// shift mbutton = move z checker
if (buttonstate == (MK_SHIFT|MK_MBUTTON) )
{
XY_ToPoint (x, y, point);
z.origin[0] = point[0];
z.origin[1] = point[1];
Sys_UpdateWindows (W_XY_OVERLAY|W_Z);
return;
}
}
/*
==============
XY_MouseUp
==============
*/
void XY_MouseUp (int x, int y, int buttons)
{
Drag_MouseUp ();
if (!press_selection)
Sys_UpdateWindows (W_ALL);
buttonstate = 0;
}
qboolean DragDelta (int x, int y, vec3_t move)
{
vec3_t xvec, yvec, delta;
int i;
xvec[0] = 1/g_qeglobals.d_xy.scale;
xvec[1] = xvec[2] = 0;
yvec[1] = 1/g_qeglobals.d_xy.scale;
yvec[0] = yvec[2] = 0;
for (i=0 ; i<3 ; i++)
{
delta[i] = xvec[i]*(x - pressx) + yvec[i]*(y - pressy);
delta[i] = floor(delta[i]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;
}
VectorSubtract (delta, pressdelta, move);
VectorCopy (delta, pressdelta);
if (move[0] || move[1] || move[2])
return true;
return false;
}
/*
==============
NewBrushDrag
==============
*/
void NewBrushDrag (int x, int y)
{
vec3_t mins, maxs, junk;
int i;
float temp;
brush_t *n;
if (!DragDelta (x,y, junk))
return;
// delete the current selection
if (selected_brushes.next != &selected_brushes)
Brush_Free (selected_brushes.next);
XY_ToGridPoint (pressx, pressy, mins);
mins[2] = g_qeglobals.d_gridsize * ((int)(g_qeglobals.d_new_brush_bottom_z/g_qeglobals.d_gridsize));
XY_ToGridPoint (x, y, maxs);
maxs[2] = g_qeglobals.d_gridsize * ((int)(g_qeglobals.d_new_brush_top_z/g_qeglobals.d_gridsize));
if (maxs[2] <= mins[2])
maxs[2] = mins[2] + g_qeglobals.d_gridsize;
for (i=0 ; i<3 ; i++)
{
if (mins[i] == maxs[i])
return; // don't create a degenerate brush
if (mins[i] > maxs[i])
{
temp = mins[i];
mins[i] = maxs[i];
maxs[i] = temp;
}
}
n = Brush_Create (mins, maxs, &g_qeglobals.d_texturewin.texdef);
if (!n)
return;
Brush_AddToList (n, &selected_brushes);
Entity_LinkBrush (world_entity, n);
Brush_Build( n );
// Sys_UpdateWindows (W_ALL);
Sys_UpdateWindows (W_XY| W_CAMERA);
}
/*
==============
XY_MouseMoved
==============
*/
void XY_MouseMoved (int x, int y, int buttons)
{
vec3_t point;
if (!buttonstate)
return;
// lbutton without selection = drag new brush
if (buttonstate == MK_LBUTTON && !press_selection)
{
NewBrushDrag (x, y);
return;
}
// lbutton (possibly with control and or shift)
// with selection = drag selection
if (buttonstate & MK_LBUTTON)
{
Drag_MouseMoved (x, y, buttons);
Sys_UpdateWindows (W_XY_OVERLAY | W_CAMERA);
return;
}
// control mbutton = move camera
if (buttonstate == (MK_CONTROL|MK_MBUTTON) )
{
XY_ToPoint (x, y, point);
camera.origin[0] = point[0];
camera.origin[1] = point[1];
Sys_UpdateWindows (W_XY_OVERLAY | W_CAMERA);
return;
}
// shift mbutton = move z checker
if (buttonstate == (MK_SHIFT|MK_MBUTTON) )
{
XY_ToPoint (x, y, point);
z.origin[0] = point[0];
z.origin[1] = point[1];
Sys_UpdateWindows (W_XY_OVERLAY|W_Z);
return;
}
// mbutton = angle camera
if (buttonstate == MK_MBUTTON )
{
XY_ToPoint (x, y, point);
VectorSubtract (point, camera.origin, point);
if (point[1] || point[0])
{
camera.angles[YAW] = 180/Q_PI*atan2 (point[1], point[0]);
Sys_UpdateWindows (W_XY_OVERLAY | W_CAMERA);
}
return;
}
// rbutton = drag xy origin
if (buttonstate == MK_RBUTTON)
{
Sys_GetCursorPos (&x, &y);
if (x != cursorx || y != cursory)
{
g_qeglobals.d_xy.origin[0] -= (x-cursorx)/g_qeglobals.d_xy.scale;
g_qeglobals.d_xy.origin[1] += (y-cursory)/g_qeglobals.d_xy.scale;
Sys_SetCursorPos (cursorx, cursory);
Sys_UpdateWindows (W_XY | W_XY_OVERLAY);
}
return;
}
}
/*
============================================================================
DRAWING
============================================================================
*/
/*
==============
XY_DrawGrid
==============
*/
void XY_DrawGrid (void)
{
float x, y, xb, xe, yb, ye;
int w, h;
char text[32];
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
w = g_qeglobals.d_xy.width/2 / g_qeglobals.d_xy.scale;
h = g_qeglobals.d_xy.height/2 / g_qeglobals.d_xy.scale;
xb = g_qeglobals.d_xy.origin[0] - w;
if (xb < region_mins[0])
xb = region_mins[0];
xb = 64 * floor (xb/64);
xe = g_qeglobals.d_xy.origin[0] + w;
if (xe > region_maxs[0])
xe = region_maxs[0];
xe = 64 * ceil (xe/64);
yb = g_qeglobals.d_xy.origin[1] - h;
if (yb < region_mins[1])
yb = region_mins[1];
yb = 64 * floor (yb/64);
ye = g_qeglobals.d_xy.origin[1] + h;
if (ye > region_maxs[1])
ye = region_maxs[1];
ye = 64 * ceil (ye/64);
// draw major blocks
glColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR]);
if ( g_qeglobals.d_showgrid )
{
glBegin (GL_LINES);
for (x=xb ; x<=xe ; x+=64)
{
glVertex2f (x, yb);
glVertex2f (x, ye);
}
for (y=yb ; y<=ye ; y+=64)
{
glVertex2f (xb, y);
glVertex2f (xe, y);
}
glEnd ();
}
// draw minor blocks
if ( g_qeglobals.d_showgrid && g_qeglobals.d_gridsize*g_qeglobals.d_xy.scale >= 4)
{
glColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR]);
glBegin (GL_LINES);
for (x=xb ; x<xe ; x += g_qeglobals.d_gridsize)
{
if ( ! ((int)x & 63) )
continue;
glVertex2f (x, yb);
glVertex2f (x, ye);
}
for (y=yb ; y<ye ; y+=g_qeglobals.d_gridsize)
{
if ( ! ((int)y & 63) )
continue;
glVertex2f (xb, y);
glVertex2f (xe, y);
}
glEnd ();
}
// draw coordinate text if needed
if ( g_qeglobals.d_savedinfo.show_coordinates)
{
glColor4f(0, 0, 0, 0);
for (x=xb ; x<xe ; x+=64)
{
glRasterPos2f (x, g_qeglobals.d_xy.origin[1] + h - 6/g_qeglobals.d_xy.scale);
sprintf (text, "%i",(int)x);
glCallLists (strlen(text), GL_UNSIGNED_BYTE, text);
}
for (y=yb ; y<ye ; y+=64)
{
glRasterPos2f (g_qeglobals.d_xy.origin[0] - w + 1, y);
sprintf (text, "%i",(int)y);
glCallLists (strlen(text), GL_UNSIGNED_BYTE, text);
}
}
}
/*
==============
XY_DrawBlockGrid
==============
*/
void XY_DrawBlockGrid (void)
{
float x, y, xb, xe, yb, ye;
int w, h;
char text[32];
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
w = g_qeglobals.d_xy.width/2 / g_qeglobals.d_xy.scale;
h = g_qeglobals.d_xy.height/2 / g_qeglobals.d_xy.scale;
xb = g_qeglobals.d_xy.origin[0] - w;
if (xb < region_mins[0])
xb = region_mins[0];
xb = 1024 * floor (xb/1024);
xe = g_qeglobals.d_xy.origin[0] + w;
if (xe > region_maxs[0])
xe = region_maxs[0];
xe = 1024 * ceil (xe/1024);
yb = g_qeglobals.d_xy.origin[1] - h;
if (yb < region_mins[1])
yb = region_mins[1];
yb = 1024 * floor (yb/1024);
ye = g_qeglobals.d_xy.origin[1] + h;
if (ye > region_maxs[1])
ye = region_maxs[1];
ye = 1024 * ceil (ye/1024);
// draw major blocks
glColor3f(0,0,1);
glLineWidth (2);
glBegin (GL_LINES);
for (x=xb ; x<=xe ; x+=1024)
{
glVertex2f (x, yb);
glVertex2f (x, ye);
}
for (y=yb ; y<=ye ; y+=1024)
{
glVertex2f (xb, y);
glVertex2f (xe, y);
}
glEnd ();
glLineWidth (1);
// draw coordinate text if needed
for (x=xb ; x<xe ; x+=1024)
for (y=yb ; y<ye ; y+=1024)
{
glRasterPos2f (x+512, y+512);
sprintf (text, "%i,%i",(int)floor(x/1024), (int)floor(y/1024) );
glCallLists (strlen(text), GL_UNSIGNED_BYTE, text);
}
glColor4f(0, 0, 0, 0);
}
void DrawCameraIcon (void)
{
float x, y, a;
x = camera.origin[0];
y = camera.origin[1];
a = camera.angles[YAW]/180*Q_PI;
glColor3f (0.0, 0.0, 1.0);
glBegin(GL_LINE_STRIP);
glVertex3f (x-16,y,0);
glVertex3f (x,y+8,0);
glVertex3f (x+16,y,0);
glVertex3f (x,y-8,0);
glVertex3f (x-16,y,0);
glVertex3f (x+16,y,0);
glEnd ();
glBegin(GL_LINE_STRIP);
glVertex3f (x+48*cos(a+Q_PI/4), y+48*sin(a+Q_PI/4), 0);
glVertex3f (x, y, 0);
glVertex3f (x+48*cos(a-Q_PI/4), y+48*sin(a-Q_PI/4), 0);
glEnd ();
}
void DrawZIcon (void)
{
float x, y;
x = z.origin[0];
y = z.origin[1];
glEnable (GL_BLEND);
glDisable (GL_TEXTURE_2D);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glDisable (GL_CULL_FACE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f (0.0, 0.0, 1.0, 0.25);
glBegin(GL_QUADS);
glVertex3f (x-8,y-8,0);
glVertex3f (x+8,y-8,0);
glVertex3f (x+8,y+8,0);
glVertex3f (x-8,y+8,0);
glEnd ();
glDisable (GL_BLEND);
glColor4f (0.0, 0.0, 1.0, 1);
glBegin(GL_LINE_LOOP);
glVertex3f (x-8,y-8,0);
glVertex3f (x+8,y-8,0);
glVertex3f (x+8,y+8,0);
glVertex3f (x-8,y+8,0);
glEnd ();
glBegin(GL_LINE_STRIP);
glVertex3f (x-4,y+4,0);
glVertex3f (x+4,y+4,0);
glVertex3f (x-4,y-4,0);
glVertex3f (x+4,y-4,0);
glEnd ();
}
/*
==================
FilterBrush
==================
*/
BOOL FilterBrush(brush_t *pb)
{
if (!pb->owner)
return FALSE; // during construction
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLIP)
{
if (!strncmp(pb->brush_faces->texdef.name, "clip", 4))
return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WATER)
{
if (pb->brush_faces->texdef.name[0] == '*')
return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAIL)
{
if (pb->brush_faces->texdef.contents & CONTENTS_DETAIL)
return TRUE;
}
if (pb->owner == world_entity)
{
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD)
return TRUE;
return FALSE;
}
else if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT)
return TRUE;
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTS)
{
if (!strncmp(pb->owner->eclass->name, "light", 5))
return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS)
{
if (!strncmp(pb->owner->eclass->name, "path", 4))
return TRUE;
}
return FALSE;
}
/*
=============================================================
PATH LINES
=============================================================
*/
/*
==================
DrawPathLines
Draws connections between entities.
Needs to consider all entities, not just ones on screen,
because the lines can be visible when neither end is.
Called for both camera view and xy view.
==================
*/
void DrawPathLines (void)
{
int i, j, k;
vec3_t mid, mid1;
entity_t *se, *te;
brush_t *sb, *tb;
char *psz;
vec3_t dir, s1, s2;
vec_t len, f;
int arrows;
int num_entities;
char *ent_target[MAX_MAP_ENTITIES];
entity_t *ent_entity[MAX_MAP_ENTITIES];
num_entities = 0;
for (te = entities.next ; te != &entities && num_entities != MAX_MAP_ENTITIES ; te = te->next)
{
ent_target[num_entities] = ValueForKey (te, "target");
if (ent_target[num_entities][0])
{
ent_entity[num_entities] = te;
num_entities++;
}
}
for (se = entities.next ; se != &entities ; se = se->next)
{
psz = ValueForKey(se, "targetname");
if (psz == NULL || psz[0] == '\0')
continue;
sb = se->brushes.onext;
if (sb == &se->brushes)
continue;
for (k=0 ; k<num_entities ; k++)
{
if (strcmp (ent_target[k], psz))
continue;
te = ent_entity[k];
tb = te->brushes.onext;
if (tb == &te->brushes)
continue;
for (i=0 ; i<3 ; i++)
mid[i] = (sb->mins[i] + sb->maxs[i])*0.5;
for (i=0 ; i<3 ; i++)
mid1[i] = (tb->mins[i] + tb->maxs[i])*0.5;
VectorSubtract (mid1, mid, dir);
len = VectorNormalize (dir);
s1[0] = -dir[1]*8 + dir[0]*8;
s2[0] = dir[1]*8 + dir[0]*8;
s1[1] = dir[0]*8 + dir[1]*8;
s2[1] = -dir[0]*8 + dir[1]*8;
glColor3f (se->eclass->color[0], se->eclass->color[1], se->eclass->color[2]);
glBegin(GL_LINES);
glVertex3fv(mid);
glVertex3fv(mid1);
arrows = (int)(len / 256) + 1;
for (i=0 ; i<arrows ; i++)
{
f = len * (i + 0.5) / arrows;
for (j=0 ; j<3 ; j++)
mid1[j] = mid[j] + f*dir[j];
glVertex3fv (mid1);
glVertex3f (mid1[0] + s1[0], mid1[1] + s1[1], mid1[2]);
glVertex3fv (mid1);
glVertex3f (mid1[0] + s2[0], mid1[1] + s2[1], mid1[2]);
}
glEnd();
}
}
return;
}
//=============================================================
/*
==============
XY_Draw
==============
*/
void XY_Draw (void)
{
brush_t *brush;
float w, h;
entity_t *e;
double start, end;
vec3_t mins, maxs;
int drawn, culled;
int i;
if (!active_brushes.next)
return; // not valid yet
if (g_qeglobals.d_xy.timing)
start = Sys_DoubleTime ();
//
// clear
//
g_qeglobals.d_xy.d_dirty = false;
glViewport(0, 0, g_qeglobals.d_xy.width, g_qeglobals.d_xy.height);
glClearColor (
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][0],
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][1],
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][2],
0);
glClear(GL_COLOR_BUFFER_BIT);
//
// set up viewpoint
//
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
w = g_qeglobals.d_xy.width/2 / g_qeglobals.d_xy.scale;
h = g_qeglobals.d_xy.height/2 / g_qeglobals.d_xy.scale;
mins[0] = g_qeglobals.d_xy.origin[0] - w;
maxs[0] = g_qeglobals.d_xy.origin[0] + w;
mins[1] = g_qeglobals.d_xy.origin[1] - h;
maxs[1] = g_qeglobals.d_xy.origin[1] + h;
glOrtho (mins[0], maxs[0], mins[1], maxs[1], -8000, 8000);
//
// now draw the grid
//
XY_DrawGrid ();
//
// draw stuff
//
glShadeModel (GL_FLAT);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glColor3f(0, 0, 0);
// glEnable (GL_LINE_SMOOTH);
drawn = culled = 0;
e = NULL;
for (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)
{
if (brush->mins[0] > maxs[0]
|| brush->mins[1] > maxs[1]
|| brush->maxs[0] < mins[0]
|| brush->maxs[1] < mins[1] )
{
culled++;
continue; // off screen
}
if (FilterBrush (brush))
continue;
drawn++;
if (brush->owner != e)
{
e = brush->owner;
glColor3fv(e->eclass->color);
}
Brush_DrawXY( brush );
}
DrawPathLines ();
//
// draw pointfile
//
if ( g_qeglobals.d_pointfile_display_list)
glCallList (g_qeglobals.d_pointfile_display_list);
//
// draw block grid
//
if ( g_qeglobals.show_blocks)
XY_DrawBlockGrid ();
//
// now draw selected brushes
//
glTranslatef( g_qeglobals.d_select_translate[0], g_qeglobals.d_select_translate[1], g_qeglobals.d_select_translate[2]);
glColor3f(1.0, 0.0, 0.0);
glEnable (GL_LINE_STIPPLE);
glLineStipple (3, 0xaaaa);
glLineWidth (2);
for (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)
{
drawn++;
Brush_DrawXY( brush );
}
glDisable (GL_LINE_STIPPLE);
glLineWidth (1);
// edge / vertex flags
if (g_qeglobals.d_select_mode == sel_vertex)
{
glPointSize (4);
glColor3f (0,1,0);
glBegin (GL_POINTS);
for (i=0 ; i<g_qeglobals.d_numpoints ; i++)
glVertex3fv (g_qeglobals.d_points[i]);
glEnd ();
glPointSize (1);
}
else if (g_qeglobals.d_select_mode == sel_edge)
{
float *v1, *v2;
glPointSize (4);
glColor3f (0,0,1);
glBegin (GL_POINTS);
for (i=0 ; i<g_qeglobals.d_numedges ; i++)
{
v1 = g_qeglobals.d_points[g_qeglobals.d_edges[i].p1];
v2 = g_qeglobals.d_points[g_qeglobals.d_edges[i].p2];
glVertex3f ( (v1[0]+v2[0])*0.5,(v1[1]+v2[1])*0.5,(v1[2]+v2[2])*0.5);
}
glEnd ();
glPointSize (1);
}
glTranslatef (-g_qeglobals.d_select_translate[0], -g_qeglobals.d_select_translate[1], -g_qeglobals.d_select_translate[2]);
//
// now draw camera point
//
DrawCameraIcon ();
DrawZIcon ();
glFinish();
QE_CheckOpenGLForErrors();
if (g_qeglobals.d_xy.timing)
{
end = Sys_DoubleTime ();
Sys_Printf ("xy: %i ms\n", (int)(1000*(end-start)));
}
}
/*
==============
XY_Overlay
==============
*/
void XY_Overlay (void)
{
int w, h;
int r[4];
static vec3_t lastz;
static vec3_t lastcamera;
glViewport(0, 0, g_qeglobals.d_xy.width, g_qeglobals.d_xy.height);
//
// set up viewpoint
//
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
w = g_qeglobals.d_xy.width/2 / g_qeglobals.d_xy.scale;
h = g_qeglobals.d_xy.height/2 / g_qeglobals.d_xy.scale;
glOrtho (g_qeglobals.d_xy.origin[0] - w, g_qeglobals.d_xy.origin[0] + w
, g_qeglobals.d_xy.origin[1] - h, g_qeglobals.d_xy.origin[1] + h, -8000, 8000);
//
// erase the old camera and z checker positions
// if the entire xy hasn't been redrawn
//
if (g_qeglobals.d_xy.d_dirty)
{
glReadBuffer (GL_BACK);
glDrawBuffer (GL_FRONT);
glRasterPos2f (lastz[0]-9, lastz[1]-9);
glGetIntegerv (GL_CURRENT_RASTER_POSITION,r);
glCopyPixels(r[0], r[1], 18,18, GL_COLOR);
glRasterPos2f (lastcamera[0]-50, lastcamera[1]-50);
glGetIntegerv (GL_CURRENT_RASTER_POSITION,r);
glCopyPixels(r[0], r[1], 100,100, GL_COLOR);
}
g_qeglobals.d_xy.d_dirty = true;
//
// save off underneath where we are about to draw
//
VectorCopy (z.origin, lastz);
VectorCopy (camera.origin, lastcamera);
glReadBuffer (GL_FRONT);
glDrawBuffer (GL_BACK);
glRasterPos2f (lastz[0]-9, lastz[1]-9);
glGetIntegerv (GL_CURRENT_RASTER_POSITION,r);
glCopyPixels(r[0], r[1], 18,18, GL_COLOR);
glRasterPos2f (lastcamera[0]-50, lastcamera[1]-50);
glGetIntegerv (GL_CURRENT_RASTER_POSITION,r);
glCopyPixels(r[0], r[1], 100,100, GL_COLOR);
//
// draw the new icons
//
glDrawBuffer (GL_FRONT);
glShadeModel (GL_FLAT);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glColor3f(0, 0, 0);
DrawCameraIcon ();
DrawZIcon ();
glDrawBuffer (GL_BACK);
glFinish();
}

View file

@ -1,48 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// window system independent camera view code
typedef struct
{
int width, height;
qboolean timing;
vec3_t origin; // at center of window
float scale;
float topclip, bottomclip;
qboolean d_dirty;
} xy_t;
BOOL XYExcludeBrush(brush_t *pb);
void XY_Init (void);
void XY_MouseDown (int x, int y, int buttons);
void XY_MouseUp (int x, int y, int buttons);
void XY_MouseMoved (int x, int y, int buttons);
void XY_Draw (void);
void XY_Overlay (void);
BOOL FilterBrush(brush_t *pb);

426
qe4/z.c
View file

@ -1,426 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qe3.h"
#define PAGEFLIPS 2
z_t z;
/*
============
Z_Init
============
*/
void Z_Init (void)
{
z.origin[0] = 0;
z.origin[1] = 20;
z.origin[2] = 46;
z.scale = 1;
}
/*
============================================================================
MOUSE ACTIONS
============================================================================
*/
static int cursorx, cursory;
/*
==============
Z_MouseDown
==============
*/
void Z_MouseDown (int x, int y, int buttons)
{
vec3_t org, dir, vup, vright;
brush_t *b;
Sys_GetCursorPos (&cursorx, &cursory);
vup[0] = 0; vup[1] = 0; vup[2] = 1/z.scale;
VectorCopy (z.origin, org);
org[2] += (y - (z.height/2))/z.scale;
org[1] = -8192;
b = selected_brushes.next;
if (b != &selected_brushes)
{
org[0] = (b->mins[0] + b->maxs[0])/2;
}
dir[0] = 0; dir[1] = 1; dir[2] = 0;
vright[0] = 0; vright[1] = 0; vright[2] = 0;
// LBUTTON = manipulate selection
// shift-LBUTTON = select
// middle button = grab texture
// ctrl-middle button = set entire brush to texture
// ctrl-shift-middle button = set single face to texture
if ( (buttons == MK_LBUTTON)
|| (buttons == (MK_LBUTTON | MK_SHIFT))
|| (buttons == MK_MBUTTON)
// || (buttons == (MK_MBUTTON|MK_CONTROL))
|| (buttons == (MK_MBUTTON|MK_SHIFT|MK_CONTROL)) )
{
Drag_Begin (x, y, buttons,
vright, vup,
org, dir);
return;
}
// control mbutton = move camera
if ((buttons == (MK_CONTROL|MK_MBUTTON) ) || (buttons == (MK_CONTROL|MK_LBUTTON)))
{
camera.origin[2] = org[2] ;
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY|W_Z);
}
}
/*
==============
Z_MouseUp
==============
*/
void Z_MouseUp (int x, int y, int buttons)
{
Drag_MouseUp ();
}
/*
==============
Z_MouseMoved
==============
*/
void Z_MouseMoved (int x, int y, int buttons)
{
if (!buttons)
return;
if (buttons == MK_LBUTTON)
{
Drag_MouseMoved (x, y, buttons);
Sys_UpdateWindows (W_Z|W_CAMERA);
return;
}
// rbutton = drag z origin
if (buttons == MK_RBUTTON)
{
Sys_GetCursorPos (&x, &y);
if ( y != cursory)
{
z.origin[2] += y-cursory;
Sys_SetCursorPos (cursorx, cursory);
Sys_UpdateWindows (W_Z);
}
return;
}
// control mbutton = move camera
if ((buttons == (MK_CONTROL|MK_MBUTTON) ) || (buttons == (MK_CONTROL|MK_LBUTTON)))
{
camera.origin[2] = (y - (z.height/2))/z.scale;
Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY|W_Z);
}
}
/*
============================================================================
DRAWING
============================================================================
*/
/*
==============
Z_DrawGrid
==============
*/
void Z_DrawGrid (void)
{
float zz, zb, ze;
int w, h;
char text[32];
w = z.width/2 / z.scale;
h = z.height/2 / z.scale;
zb = z.origin[2] - h;
if (zb < region_mins[2])
zb = region_mins[2];
zb = 64 * floor (zb/64);
ze = z.origin[2] + h;
if (ze > region_maxs[2])
ze = region_maxs[2];
ze = 64 * ceil (ze/64);
// draw major blocks
glColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR]);
glBegin (GL_LINES);
glVertex2f (0, zb);
glVertex2f (0, ze);
for (zz=zb ; zz<ze ; zz+=64)
{
glVertex2f (-w, zz);
glVertex2f (w, zz);
}
glEnd ();
// draw minor blocks
if (g_qeglobals.d_showgrid && g_qeglobals.d_gridsize*z.scale >= 4)
{
glColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR]);
glBegin (GL_LINES);
for (zz=zb ; zz<ze ; zz+=g_qeglobals.d_gridsize)
{
if ( ! ((int)zz & 63) )
continue;
glVertex2f (-w, zz);
glVertex2f (w, zz);
}
glEnd ();
}
// draw coordinate text if needed
glColor4f(0, 0, 0, 0);
for (zz=zb ; zz<ze ; zz+=64)
{
glRasterPos2f (-w+1, zz);
sprintf (text, "%i",(int)zz);
glCallLists (strlen(text), GL_UNSIGNED_BYTE, text);
}
}
#define CAM_HEIGHT 48 // height of main part
#define CAM_GIZMO 8 // height of the gizmo
void ZDrawCameraIcon (void)
{
float x, y;
int xCam = z.width/4;
x = 0;
y = camera.origin[2];
glColor3f (0.0, 0.0, 1.0);
glBegin(GL_LINE_STRIP);
glVertex3f (x-xCam,y,0);
glVertex3f (x,y+CAM_GIZMO,0);
glVertex3f (x+xCam,y,0);
glVertex3f (x,y-CAM_GIZMO,0);
glVertex3f (x-xCam,y,0);
glVertex3f (x+xCam,y,0);
glVertex3f (x+xCam,y-CAM_HEIGHT,0);
glVertex3f (x-xCam,y-CAM_HEIGHT,0);
glVertex3f (x-xCam,y,0);
glEnd ();
}
GLbitfield glbitClear = GL_COLOR_BUFFER_BIT; //HACK
/*
==============
Z_Draw
==============
*/
void Z_Draw (void)
{
brush_t *brush;
float w, h;
double start, end;
qtexture_t *q;
float top, bottom;
vec3_t org_top, org_bottom, dir_up, dir_down;
int xCam = z.width/3;
if (!active_brushes.next)
return; // not valid yet
if (z.timing)
start = Sys_DoubleTime ();
//
// clear
//
glViewport(0, 0, z.width, z.height);
glClearColor (
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][0],
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][1],
g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][2],
0);
/* GL Bug */
/* When not using hw acceleration, gl will fault if we clear the depth
buffer bit on the first pass. The hack fix is to set the GL_DEPTH_BUFFER_BIT
only after Z_Draw() has been called once. Yeah, right. */
glClear(glbitClear);
glbitClear |= GL_DEPTH_BUFFER_BIT;
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
w = z.width/2 / z.scale;
h = z.height/2 / z.scale;
glOrtho (-w, w, z.origin[2]-h, z.origin[2]+h, -8, 8);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_1D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
//
// now draw the grid
//
Z_DrawGrid ();
//
// draw stuff
//
glDisable(GL_CULL_FACE);
glShadeModel (GL_FLAT);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
// draw filled interiors and edges
dir_up[0] = 0 ; dir_up[1] = 0; dir_up[2] = 1;
dir_down[0] = 0 ; dir_down[1] = 0; dir_down[2] = -1;
VectorCopy (z.origin, org_top);
org_top[2] = 4096;
VectorCopy (z.origin, org_bottom);
org_bottom[2] = -4096;
for (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)
{
if (brush->mins[0] >= z.origin[0]
|| brush->maxs[0] <= z.origin[0]
|| brush->mins[1] >= z.origin[1]
|| brush->maxs[1] <= z.origin[1])
continue;
if (!Brush_Ray (org_top, dir_down, brush, &top))
continue;
top = org_top[2] - top;
if (!Brush_Ray (org_bottom, dir_up, brush, &bottom))
continue;
bottom = org_bottom[2] + bottom;
q = Texture_ForName (brush->brush_faces->texdef.name);
glColor3f (q->color[0], q->color[1], q->color[2]);
glBegin (GL_QUADS);
glVertex2f (-xCam, bottom);
glVertex2f (xCam, bottom);
glVertex2f (xCam, top);
glVertex2f (-xCam, top);
glEnd ();
glColor3f (1,1,1);
glBegin (GL_LINE_LOOP);
glVertex2f (-xCam, bottom);
glVertex2f (xCam, bottom);
glVertex2f (xCam, top);
glVertex2f (-xCam, top);
glEnd ();
}
//
// now draw selected brushes
//
for (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)
{
if ( !(brush->mins[0] >= z.origin[0]
|| brush->maxs[0] <= z.origin[0]
|| brush->mins[1] >= z.origin[1]
|| brush->maxs[1] <= z.origin[1]) )
{
if (Brush_Ray (org_top, dir_down, brush, &top))
{
top = org_top[2] - top;
if (Brush_Ray (org_bottom, dir_up, brush, &bottom))
{
bottom = org_bottom[2] + bottom;
q = Texture_ForName (brush->brush_faces->texdef.name);
glColor3f (q->color[0], q->color[1], q->color[2]);
glBegin (GL_QUADS);
glVertex2f (-xCam, bottom);
glVertex2f (xCam, bottom);
glVertex2f (xCam, top);
glVertex2f (-xCam, top);
glEnd ();
}
}
}
glColor3f (1,0,0);
glBegin (GL_LINE_LOOP);
glVertex2f (-xCam, brush->mins[2]);
glVertex2f (xCam, brush->mins[2]);
glVertex2f (xCam, brush->maxs[2]);
glVertex2f (-xCam, brush->maxs[2]);
glEnd ();
}
ZDrawCameraIcon ();
glFinish();
QE_CheckOpenGLForErrors();
if (z.timing)
{
end = Sys_DoubleTime ();
Sys_Printf ("z: %i ms\n", (int)(1000*(end-start)));
}
}

42
qe4/z.h
View file

@ -1,42 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// window system independent camera view code
typedef struct
{
int width, height;
qboolean timing;
vec3_t origin; // at center of window
float scale;
} z_t;
extern z_t z;
void Z_Init (void);
void Z_MouseDown (int x, int y, int buttons);
void Z_MouseUp (int x, int y, int buttons);
void Z_MouseMoved (int x, int y, int buttons);
void Z_Draw (void);

View file

@ -1,38 +0,0 @@
Texpaint works with three data types:
Skin textures
Model frames
S/T mappings
Skin textures can be either lbm or pcx files, and they will allways be
saved out the same size as loaded in, even if it is larger than the
active texture area.
Model frames are alias .tri files. Adding support for 3ds would not
be difficult, but it is likely that there would be coordinate problems
unless the entire model was done completely in 3ds.
S/T mappings allow a skin to be mapped onto any model frame. A mapping is
generated from a base frame and a texture size. If a coords.txt file is
not present, texpaint will generate a default mapping that is compatable
with the output of the old texmake. New skin or remap to skin will
generate a new coords.txt file.
Usage
-----
A three button mouse is required.
The left button paints with the current color in either the skin window
or the camera window, or selects colors in the palette view. Ctrl-left
click picks up the color clicked on in any view, making it current.
Right button dragging slides the object or skin around. Ctrl-right drag
to move in or out on the object.
Middle button dragging rotates the object in the camera view. Ctrl-middle
drag to change the roll angle.

View file

@ -1,58 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by texmake.rc
//
#define IDR_MENU1 101
#define IDR_MENU2 102
#define IDR_ACCELERATOR1 104
#define IDD_NEWSKIN 105
#define IDC_WIDTH 1000
#define IDC_HEIGHT 1001
#define ID_FILE_SAVEAS 4003
#define ID_VIEW_MODELLINES 4006
#define ID_VIEW_MODELLIGHTING 4008
#define ID_FILE_OPENSKIN 4009
#define ID_FILE_SAVESKIN 4010
#define ID_FILE_SAVESKINAS 4011
#define ID_FILE_EXIT 4012
#define ID_FILE_OPENMODEL 4013
#define ID_FILE_RELOADSKIN 4014
#define ID_FILE_NEWSKIN 4016
#define ID_FILE_OPENFRAME 4017
#define ID_VIEW_SKINLINES 4018
#define ID_VIEW_MODELINES 4019
#define ID_VIEW_TEXTURELINES 4020
#define ID_FILE_RESAMPLESKIN 4024
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 4025
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Binary file not shown.

View file

@ -1,156 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU2 MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New skin\tCtrl-n", ID_FILE_NEWSKIN
MENUITEM "&Open skin\tCtrl-o", ID_FILE_OPENSKIN
MENUITEM "&Reload skin\tCtrl-r", ID_FILE_RELOADSKIN
MENUITEM "&Save skin\tCtrl-s", ID_FILE_SAVESKIN
MENUITEM "Save skin &as\tCtrl-a", ID_FILE_SAVESKINAS
MENUITEM "Resample skin", ID_FILE_RESAMPLESKIN
MENUITEM SEPARATOR
MENUITEM "Open &frame\tCtrl-f", ID_FILE_OPENFRAME
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Undo\tCtrl-z", ID_EDIT_UNDO
MENUITEM "&Redo\tCtrl-y", ID_EDIT_REDO
END
POPUP "&View"
BEGIN
MENUITEM "&Model lines\tCtrl-m", ID_VIEW_MODELLINES
MENUITEM "&Texture lines\tCtrl-t", ID_VIEW_TEXTURELINES
MENUITEM "Model &lighting\tCtrl-l", ID_VIEW_MODELLIGHTING
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"A", ID_FILE_SAVESKINAS, VIRTKEY, CONTROL, NOINVERT
"F", ID_FILE_OPENFRAME, VIRTKEY, CONTROL, NOINVERT
"L", ID_VIEW_MODELLIGHTING, VIRTKEY, CONTROL, NOINVERT
"M", ID_VIEW_MODELLINES, VIRTKEY, CONTROL, NOINVERT
"N", ID_FILE_NEWSKIN, VIRTKEY, CONTROL, NOINVERT
"O", ID_FILE_OPENSKIN, VIRTKEY, CONTROL, NOINVERT
"R", ID_FILE_RELOADSKIN, VIRTKEY, CONTROL, NOINVERT
"S", ID_FILE_SAVESKIN, VIRTKEY, CONTROL, NOINVERT
"T", ID_VIEW_TEXTURELINES, VIRTKEY, CONTROL, NOINVERT
"Y", ID_EDIT_REDO, VIRTKEY, CONTROL, NOINVERT
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_NEWSKIN DIALOG DISCARDABLE 0, 0, 186, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "New Skin"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
EDITTEXT IDC_WIDTH,51,14,40,14,ES_AUTOHSCROLL
LTEXT "Width",IDC_STATIC,20,17,20,8
EDITTEXT IDC_HEIGHT,51,37,40,14,ES_AUTOHSCROLL
LTEXT "height",IDC_STATIC,19,40,20,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_NEWSKIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 88
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -1,311 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "texpaint.h"
triangle_t *faces;
int numfaces;
int skinwidth, skinheight;
int picwidth, picheight;
int width, height;
int iwidth, iheight;
int width2, height2; // padded to ^2
float tmcoords[10000][3][2];
byte pic[1024*512];
unsigned rgb[1024*512];
float scale;
float s_scale, t_scale;
char filename[1024];
char picfilename[1024];
/*
================
BoundFaces
================
*/
vec3_t mins, maxs;
void BoundFaces (void)
{
int i,j,k;
triangle_t *pol;
float v;
for (i=0 ; i<3 ; i++)
{
mins[i] = 9999;
maxs[i] = -9999;
}
for (i=0 ; i<numfaces ; i++)
{
pol = &faces[i];
for (j=0 ; j<3 ; j++)
for (k=0 ; k<3 ; k++)
{
v = pol->verts[j][k];
if (v<mins[k])
mins[k] = v;
if (v>maxs[k])
maxs[k] = v;
}
}
for (i=0 ; i<3 ; i++)
{
mins[i] = floor(mins[i]);
maxs[i] = ceil(maxs[i]);
}
width = maxs[0] - mins[0];
height = maxs[2] - mins[2];
printf ("width: %i height: %i\n",width, height);
if (!skinwidth)
{ // old way
scale = 8;
if (width*scale >= 150)
scale = 150.0 / width;
if (height*scale >= 190)
scale = 190.0 / height;
s_scale = t_scale = scale;
iwidth = ceil(width*scale) + 4;
iheight = ceil(height*scale) + 4;
}
else
{ // new way
s_scale = (skinwidth/2-4)/(float)width;
t_scale = (skinheight-4)/(float)height;
iwidth = skinwidth/2;
iheight = skinheight;
}
printf ("scale: %f\n",scale);
printf ("iwidth: %i iheight: %i\n",iwidth, iheight);
}
/*
============
AddFace
============
*/
void AddFace (int facenum, triangle_t *f)
{
vec3_t v1, v2, normal;
int basex, basey;
int i, j;
int coords[3][2];
//
// determine which side to map the teture to
//
VectorSubtract (f->verts[0], f->verts[1], v1);
VectorSubtract (f->verts[2], f->verts[1], v2);
CrossProduct (v1, v2, normal);
if (normal[1] > 0)
basex = iwidth + 2;
else
basex = 2;
basey = 2;
for (i=0 ; i<3 ; i++)
{
coords[i][0] = Q_rint((f->verts[i][0] - mins[0])*s_scale + basex);
coords[i][1] = Q_rint( (maxs[2] - f->verts[i][2])*t_scale + basey);
tmcoords[facenum][i][0] = coords[i][0]/(float)width2;
tmcoords[facenum][i][1] = coords[i][1]/(float)height2;
}
}
void CalcTmCoords (void)
{
int j;
BoundFaces ();
for (j=0 ; j<numfaces ; j++)
AddFace (j, &faces[j]);
printf ("numfaces: %i\n",numfaces);
}
//===============================================================================
#define MAX_NUM_ARGVS 32
int argc;
char *argv[MAX_NUM_ARGVS];
/*
============
ParseCommandLine
============
*/
void ParseCommandLine (char *lpCmdLine)
{
argc = 1;
argv[0] = "programname";
while (*lpCmdLine && (argc < MAX_NUM_ARGVS))
{
while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
lpCmdLine++;
if (*lpCmdLine)
{
argv[argc] = lpCmdLine;
argc++;
while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
lpCmdLine++;
if (*lpCmdLine)
{
*lpCmdLine = 0;
lpCmdLine++;
}
}
}
}
/*
=================
LoadTriFile
=================
*/
void LoadTriFile (char *name)
{
strcpy (tri_filename, name);
SetWindowText (camerawindow, tri_filename);
LoadTriangleList (tri_filename, &faces, &numfaces);
InvalidateRect (camerawindow, NULL, false);
}
/*
==================
TimerProc
==================
*/
int CALLBACK TimerProc(
HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time
)
{
static int counter;
char name[1024];
if (!skin_filename[0])
return 0;
if (!modified_past_autosave)
{
counter = 0;
return 0;
}
counter++;
if (counter < 3*5)
return 0; // save every five minutes
strcpy (name, skin_filename);
StripExtension (name);
strcat (name, "_autosave.lbm");
Skin_SaveFile (name);
modified_past_autosave = false;
counter = 0;
return 0;
}
/*
==================
WinMain
==================
*/
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance
,LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
HACCEL accelerators;
main_instance = hInstance;
ParseCommandLine (lpCmdLine);
screen_width = GetSystemMetrics (SM_CXFULLSCREEN);
screen_height = GetSystemMetrics (SM_CYFULLSCREEN);
// hack for broken NT 4.0 dual screen
if (screen_width > 2*screen_height)
screen_width /= 2;
accelerators = LoadAccelerators (hInstance
, MAKEINTRESOURCE(IDR_ACCELERATOR1));
if (!accelerators)
Sys_Error ("LoadAccelerators failed");
Main_Create (hInstance);
WCam_Create (hInstance);
WPal_Create (hInstance);
WSkin_Create (hInstance);
if (argc == 2)
Skin_LoadFile (argv[1]);
SetTimer ( mainwindow, 1, 1000*20, TimerProc );
while (1)
{
if (!GetMessage (&msg, mainwindow, 0, 0))
break;
if (!TranslateAccelerator(mainwindow, accelerators, &msg) )
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
/* return success of application */
return TRUE;
}

View file

@ -1,88 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "cmdlib.h"
#include "mathlib.h"
#include "lbmlib.h"
#include "trilib.h"
#include "l3dslib.h"
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
#include "resource.h"
#include "afxres.h"
extern HINSTANCE main_instance;
extern HGLRC baseRC;
extern HWND mainwindow;
extern HWND camerawindow;
extern HWND palettewindow;
extern HWND skinwindow;
extern int screen_width, screen_height;
#define QE3_STYLE (WS_OVERLAPPED| WS_CAPTION | WS_THICKFRAME | \
/* WS_MINIMIZEBOX | */ WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | \
WS_CLIPCHILDREN | WS_CHILD)
extern byte pic[1024*512];
extern unsigned rgb[1024*512];
extern unsigned index_texture[1024*512];
extern byte palette[768];
extern triangle_t *faces;
extern int numfaces;
extern float tmcoords[10000][3][2];
extern int skinwidth, skinheight;
extern int picwidth, picheight;
extern int width, height;
extern int iwidth, iheight;
extern int width2, height2; // padded to ^2
extern char tri_filename[1024];
extern char skin_filename[1024];
extern int selected_index;
extern unsigned selected_rgb;
extern qboolean model_lines;
extern qboolean skin_lines;
extern qboolean modified;
extern qboolean modified_past_autosave;
#define TEXTURE_SKIN 1
#define TEXTURE_INDEX 2
#define MENU_VIEW 2
#define MODEL_DISPLAYLIST 1
typedef void (APIENTRY *BINDTEXFUNCPTR)(GLenum, GLuint);
extern BINDTEXFUNCPTR BindTextureEXT;

View file

@ -1,468 +0,0 @@
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
!IF "$(CFG)" == ""
CFG=texpaint - Win32 Debug
!MESSAGE No configuration specified. Defaulting to texpaint - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "texpaint - Win32 Release" && "$(CFG)" !=\
"texpaint - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "texpaint.mak" CFG="texpaint - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "texpaint - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "texpaint - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
################################################################################
# Begin Project
# PROP Target_Last_Scanned "texpaint - Win32 Debug"
MTL=mktyplib.exe
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "texpaint - 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 ""
OUTDIR=.\Release
INTDIR=.\Release
ALL : "$(OUTDIR)\texpaint.exe"
CLEAN :
-@erase "$(INTDIR)\cmdlib.obj"
-@erase "$(INTDIR)\l3dslib.obj"
-@erase "$(INTDIR)\lbmlib.obj"
-@erase "$(INTDIR)\mathlib.obj"
-@erase "$(INTDIR)\scriplib.obj"
-@erase "$(INTDIR)\texmake.res"
-@erase "$(INTDIR)\texpaint.obj"
-@erase "$(INTDIR)\trilib.obj"
-@erase "$(INTDIR)\win_cam.obj"
-@erase "$(INTDIR)\win_main.obj"
-@erase "$(INTDIR)\win_pal.obj"
-@erase "$(INTDIR)\win_skin.obj"
-@erase "$(OUTDIR)\texpaint.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /GX /O2 /I "..\common" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
CPP_PROJ=/nologo /ML /GX /O2 /I "..\common" /D "WIN32" /D "NDEBUG" /D\
"_WINDOWS" /Fp"$(INTDIR)/texpaint.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\Release/
CPP_SBRS=.\.
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/texmake.res" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/texpaint.bsc"
BSC32_SBRS= \
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:windows /machine:I386
# ADD LINK32 opengl32.lib glu32.lib glaux.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 /nologo /subsystem:windows /machine:I386
LINK32_FLAGS=opengl32.lib glu32.lib glaux.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 /nologo /subsystem:windows /incremental:no\
/pdb:"$(OUTDIR)/texpaint.pdb" /machine:I386 /out:"$(OUTDIR)/texpaint.exe"
LINK32_OBJS= \
"$(INTDIR)\cmdlib.obj" \
"$(INTDIR)\l3dslib.obj" \
"$(INTDIR)\lbmlib.obj" \
"$(INTDIR)\mathlib.obj" \
"$(INTDIR)\scriplib.obj" \
"$(INTDIR)\texmake.res" \
"$(INTDIR)\texpaint.obj" \
"$(INTDIR)\trilib.obj" \
"$(INTDIR)\win_cam.obj" \
"$(INTDIR)\win_main.obj" \
"$(INTDIR)\win_pal.obj" \
"$(INTDIR)\win_skin.obj"
"$(OUTDIR)\texpaint.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "texpaint - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "texpaint"
# PROP BASE Intermediate_Dir "texpaint"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
OUTDIR=.\Debug
INTDIR=.\Debug
ALL : "$(OUTDIR)\texpaint.exe"
CLEAN :
-@erase "$(INTDIR)\cmdlib.obj"
-@erase "$(INTDIR)\l3dslib.obj"
-@erase "$(INTDIR)\lbmlib.obj"
-@erase "$(INTDIR)\mathlib.obj"
-@erase "$(INTDIR)\scriplib.obj"
-@erase "$(INTDIR)\texmake.res"
-@erase "$(INTDIR)\texpaint.obj"
-@erase "$(INTDIR)\trilib.obj"
-@erase "$(INTDIR)\vc40.idb"
-@erase "$(INTDIR)\vc40.pdb"
-@erase "$(INTDIR)\win_cam.obj"
-@erase "$(INTDIR)\win_main.obj"
-@erase "$(INTDIR)\win_pal.obj"
-@erase "$(INTDIR)\win_skin.obj"
-@erase "$(OUTDIR)\texpaint.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /Gm /GX /Zi /Od /I "..\common" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "WIN_ERROR" /YX /c
CPP_PROJ=/nologo /MLd /Gm /GX /Zi /Od /I "..\common" /D "WIN32" /D "_DEBUG" /D\
"_WINDOWS" /D "WIN_ERROR" /Fp"$(INTDIR)/texpaint.pch" /YX /Fo"$(INTDIR)/"\
/Fd"$(INTDIR)/" /c
CPP_OBJS=.\Debug/
CPP_SBRS=.\.
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/texmake.res" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/texpaint.bsc"
BSC32_SBRS= \
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:windows /debug /machine:I386
# ADD LINK32 opengl32.lib glu32.lib glaux.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 /nologo /subsystem:windows /pdb:none /debug /machine:I386
LINK32_FLAGS=opengl32.lib glu32.lib glaux.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 /nologo /subsystem:windows /pdb:none /debug\
/machine:I386 /out:"$(OUTDIR)/texpaint.exe"
LINK32_OBJS= \
"$(INTDIR)\cmdlib.obj" \
"$(INTDIR)\l3dslib.obj" \
"$(INTDIR)\lbmlib.obj" \
"$(INTDIR)\mathlib.obj" \
"$(INTDIR)\scriplib.obj" \
"$(INTDIR)\texmake.res" \
"$(INTDIR)\texpaint.obj" \
"$(INTDIR)\trilib.obj" \
"$(INTDIR)\win_cam.obj" \
"$(INTDIR)\win_main.obj" \
"$(INTDIR)\win_pal.obj" \
"$(INTDIR)\win_skin.obj"
"$(OUTDIR)\texpaint.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.c{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
################################################################################
# Begin Target
# Name "texpaint - Win32 Release"
# Name "texpaint - Win32 Debug"
!IF "$(CFG)" == "texpaint - Win32 Release"
!ELSEIF "$(CFG)" == "texpaint - Win32 Debug"
!ENDIF
################################################################################
# Begin Source File
SOURCE=.\texpaint.c
DEP_CPP_TEXPA=\
"..\common\cmdlib.h"\
"..\common\l3dslib.h"\
"..\common\lbmlib.h"\
"..\common\mathlib.h"\
"..\common\trilib.h"\
".\texpaint.h"\
{$(INCLUDE)}"\gl\GL.H"\
{$(INCLUDE)}"\gl\GLAUX.H"\
{$(INCLUDE)}"\gl\GLU.H"\
"$(INTDIR)\texpaint.obj" : $(SOURCE) $(DEP_CPP_TEXPA) "$(INTDIR)"
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\mathlib.c
DEP_CPP_MATHL=\
"..\..\..\quake\utils2\common\cmdlib.h"\
"..\..\..\quake\utils2\common\mathlib.h"\
"$(INTDIR)\mathlib.obj" : $(SOURCE) $(DEP_CPP_MATHL) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\l3dslib.c
DEP_CPP_L3DSL=\
"..\..\..\quake\utils2\common\cmdlib.h"\
"..\..\..\quake\utils2\common\l3dslib.h"\
"..\..\..\quake\utils2\common\mathlib.h"\
"..\..\..\quake\utils2\common\trilib.h"\
"$(INTDIR)\l3dslib.obj" : $(SOURCE) $(DEP_CPP_L3DSL) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\lbmlib.c
DEP_CPP_LBMLI=\
"..\..\..\quake\utils2\common\cmdlib.h"\
"..\..\..\quake\utils2\common\lbmlib.h"\
"$(INTDIR)\lbmlib.obj" : $(SOURCE) $(DEP_CPP_LBMLI) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\scriplib.c
DEP_CPP_SCRIP=\
"..\..\..\quake\utils2\common\cmdlib.h"\
"..\..\..\quake\utils2\common\scriplib.h"\
"$(INTDIR)\scriplib.obj" : $(SOURCE) $(DEP_CPP_SCRIP) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\trilib.c
DEP_CPP_TRILI=\
"..\..\..\quake\utils2\common\cmdlib.h"\
"..\..\..\quake\utils2\common\mathlib.h"\
"..\..\..\quake\utils2\common\trilib.h"\
"$(INTDIR)\trilib.obj" : $(SOURCE) $(DEP_CPP_TRILI) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=.\win_skin.c
DEP_CPP_WIN_S=\
"..\common\cmdlib.h"\
"..\common\l3dslib.h"\
"..\common\lbmlib.h"\
"..\common\mathlib.h"\
"..\common\trilib.h"\
".\texpaint.h"\
{$(INCLUDE)}"\gl\GL.H"\
{$(INCLUDE)}"\gl\GLAUX.H"\
{$(INCLUDE)}"\gl\GLU.H"\
"$(INTDIR)\win_skin.obj" : $(SOURCE) $(DEP_CPP_WIN_S) "$(INTDIR)"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\win_main.c
DEP_CPP_WIN_M=\
"..\common\cmdlib.h"\
"..\common\l3dslib.h"\
"..\common\lbmlib.h"\
"..\common\mathlib.h"\
"..\common\trilib.h"\
".\texpaint.h"\
{$(INCLUDE)}"\gl\GL.H"\
{$(INCLUDE)}"\gl\GLAUX.H"\
{$(INCLUDE)}"\gl\GLU.H"\
"$(INTDIR)\win_main.obj" : $(SOURCE) $(DEP_CPP_WIN_M) "$(INTDIR)"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\win_pal.c
DEP_CPP_WIN_P=\
"..\common\cmdlib.h"\
"..\common\l3dslib.h"\
"..\common\lbmlib.h"\
"..\common\mathlib.h"\
"..\common\trilib.h"\
".\texpaint.h"\
{$(INCLUDE)}"\gl\GL.H"\
{$(INCLUDE)}"\gl\GLAUX.H"\
{$(INCLUDE)}"\gl\GLU.H"\
"$(INTDIR)\win_pal.obj" : $(SOURCE) $(DEP_CPP_WIN_P) "$(INTDIR)"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\win_cam.c
DEP_CPP_WIN_C=\
"..\common\cmdlib.h"\
"..\common\l3dslib.h"\
"..\common\lbmlib.h"\
"..\common\mathlib.h"\
"..\common\trilib.h"\
".\texpaint.h"\
{$(INCLUDE)}"\gl\GL.H"\
{$(INCLUDE)}"\gl\GLAUX.H"\
{$(INCLUDE)}"\gl\GLU.H"\
"$(INTDIR)\win_cam.obj" : $(SOURCE) $(DEP_CPP_WIN_C) "$(INTDIR)"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\texmake.rc
"$(INTDIR)\texmake.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=.\texpaint.h
!IF "$(CFG)" == "texpaint - Win32 Release"
!ELSEIF "$(CFG)" == "texpaint - Win32 Debug"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\lbmlib.h
!IF "$(CFG)" == "texpaint - Win32 Release"
!ELSEIF "$(CFG)" == "texpaint - Win32 Debug"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\cmdlib.h
!IF "$(CFG)" == "texpaint - Win32 Release"
!ELSEIF "$(CFG)" == "texpaint - Win32 Debug"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\cmdlib.c
DEP_CPP_CMDLI=\
"..\..\..\quake\utils2\common\cmdlib.h"\
{$(INCLUDE)}"\sys\stat.h"\
{$(INCLUDE)}"\sys\types.h"\
"$(INTDIR)\cmdlib.obj" : $(SOURCE) $(DEP_CPP_CMDLI) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
# End Target
# End Project
################################################################################

View file

@ -1,414 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "texpaint.h"
#define CAMERA_WINDOW_CLASS "TPCamera"
HDC camdc;
HGLRC baseRC;
float pitch, yaw, roll;
qboolean model_lines = false;
float cam_x, cam_y=-64, cam_z=32;
int cam_width, cam_height;
BINDTEXFUNCPTR BindTextureEXT;
void InitIndexTexture (void)
{
int i;
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_INDEX);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
for (i=0 ; i<sizeof(index_texture)/4 ; i++)
index_texture[i] = i+1;
glTexImage2D (GL_TEXTURE_2D, 0, 3, width2, height2, 0, GL_RGBA, GL_UNSIGNED_BYTE, index_texture);
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_SKIN);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
void CreateDisplaylist (void)
{
}
void DrawModel (void)
{
int i, j;
glColor4f (1,1,1,1);
glBegin (GL_TRIANGLES);
for (i=0 ; i<numfaces ; i++)
{
for (j=0 ; j<3 ; j++)
{
glTexCoord2f (tmcoords[i][j][0], tmcoords[i][j][1]);
glVertex3fv (faces[i].verts[j]);
}
}
glEnd ();
}
/*
=============
Cam_Click
=============
*/
int cam_last_index;
void Cam_Click (int x, int y, qboolean shift)
{
int index;
index = 0;
glReadBuffer (GL_BACK);
glReadPixels (x, y, 1,1, GL_RGB, GL_UNSIGNED_BYTE, &index);
index--;
if (index == -1)
return;
if (index >= width2*height2)
return;
if (index == cam_last_index)
return; // in same pixel
cam_last_index = index;
if (shift)
{
Pal_SetIndex (pic[index]);
return;
}
SetSkin (index, selected_rgb);
UpdateWindow (camerawindow);
}
void Cam_DrawSetup (void)
{
glViewport (0,0,cam_width, cam_height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (90, (float)cam_width/cam_height, 2, 1024);
gluLookAt (cam_x, cam_y, cam_z, cam_x, cam_y+1, cam_z, 0, 0, 1);
glRotated (-roll*0.3, 0, 1, 0);
glRotated (-pitch*0.3, 1, 0, 0);
glRotated (yaw*0.3, 0, 0, 1);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glEnable (GL_DEPTH_TEST);
glEnable (GL_CULL_FACE);
glEnable (GL_TEXTURE_2D);
glCullFace (GL_FRONT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
void Cam_Draw (void)
{
if (!cam_width || !cam_height)
return;
glClearColor (0.3,0.3,0.3,1);
Cam_DrawSetup ();
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_SKIN);
DrawModel ();
if (model_lines)
{
glDisable (GL_TEXTURE_2D);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
glDepthFunc (GL_LEQUAL);
glDepthRange (0, 0.999); // nudge depth to avoid dropouts
DrawModel ();
glDepthRange (0, 1);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable (GL_TEXTURE_2D);
}
SwapBuffers(camdc);
// now fill the back buffer with the index texture
glClearColor (0,0,0,0);
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_INDEX);
DrawModel ();
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_SKIN);
}
/*
============
CameraWndProc
============
*/
LONG WINAPI WCam_WndProc (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
LONG lRet = 1;
int fwKeys, xPos, yPos;
RECT rect;
static int oldx, oldy;
POINT pt;
GetClientRect(hWnd, &rect);
cam_width = rect.right-rect.left;
cam_height = rect.bottom-rect.top;
switch (uMsg)
{
case WM_CREATE:
camdc = GetDC(hWnd);
bSetupPixelFormat(camdc);
baseRC = wglCreateContext( camdc );
if (!baseRC)
Sys_Error ("wglCreateContext failed");
if (!wglMakeCurrent( camdc, baseRC ))
Sys_Error ("wglMakeCurrent failed");
BindTextureEXT = (void *)wglGetProcAddress((LPCSTR) "glBindTextureEXT");
if (!BindTextureEXT)
Sys_Error ("GetProcAddress for BindTextureEXT failed");
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
if (!wglMakeCurrent( camdc, baseRC ))
Sys_Error ("wglMakeCurrent failed");
Cam_Draw ();
EndPaint(hWnd, &ps);
}
break;
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
if (GetTopWindow(mainwindow) != hWnd)
BringWindowToTop(hWnd);
SetFocus (camerawindow);
SetCapture (camerawindow);
GetCursorPos (&pt);
xPos = pt.x;
yPos = pt.y;
oldx = xPos;
oldy = yPos;
break;
case WM_LBUTTONDOWN:
cam_last_index = -1;
draw:
if (GetTopWindow(mainwindow) != hWnd)
BringWindowToTop(hWnd);
SetFocus (camerawindow);
SetCapture (camerawindow);
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
if (!wglMakeCurrent( camdc, baseRC ))
Sys_Error ("wglMakeCurrent failed");
Cam_Click (xPos, yPos, !!(wParam&(MK_SHIFT|MK_CONTROL)) );
// Cam_MouseDown (xPos, yPos, fwKeys);
break;
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONUP:
if (! (wParam & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))
ReleaseCapture ();
break;
case WM_MOUSEMOVE:
{
int dx, dy;
if (wParam & MK_LBUTTON)
goto draw;
GetCursorPos (&pt);
xPos = pt.x;
yPos = pt.y;
if (!(wParam & (MK_RBUTTON|MK_MBUTTON)))
{
oldx = xPos;
oldy = yPos;
break;
}
dx = xPos-oldx;
dy = oldy-yPos;
if (!dx && !dy)
break;
SetCursorPos (oldx, oldy);
if (wParam == (MK_RBUTTON|MK_CONTROL) )
{
if (abs(dx) > abs(dy))
cam_y -= 0.1*dx;
else
cam_y -= 0.1*dy;
InvalidateRect (camerawindow, NULL, false);
}
if (wParam == MK_RBUTTON)
{
cam_x -= 0.1*dx;
cam_z -= 0.1*dy;
InvalidateRect (camerawindow, NULL, false);
}
if (wParam == (MK_MBUTTON|MK_CONTROL) )
{
if (abs(dx) > abs(dy))
roll -= dx;
else
roll -= dy;
InvalidateRect (camerawindow, NULL, false);
}
if (wParam == MK_MBUTTON)
{
yaw += dx;
pitch += dy;
InvalidateRect (camerawindow, NULL, false);
}
}
break;
case WM_SIZE:
// camera.width = rect.right;
// camera.height = rect.bottom;
InvalidateRect(camerawindow, NULL, false);
break;
case WM_NCCALCSIZE:// don't let windows copy pixels
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
return WVR_REDRAW;
case WM_CLOSE:
/* call destroy window to cleanup and go away */
DestroyWindow (hWnd);
break;
case WM_DESTROY:
{
HGLRC hRC;
HDC hDC;
/* release and free the device context and rendering context */
hRC = wglGetCurrentContext();
hDC = wglGetCurrentDC();
wglMakeCurrent(NULL, NULL);
if (hRC)
wglDeleteContext(hRC);
if (hDC)
ReleaseDC(hWnd, hDC);
}
break;
default:
/* pass all unhandled messages to DefWindowProc */
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
break;
}
/* return 1 if handled message, 0 if not */
return lRet;
}
/*
==============
WCam_Register
==============
*/
void WCam_Register (HINSTANCE hInstance)
{
WNDCLASS wc;
/* Register the camera class */
memset (&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WCam_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = 0;
wc.lpszClassName = CAMERA_WINDOW_CLASS;
if (!RegisterClass (&wc) )
Sys_Error ("WCam_Register: failed");
}
void WCam_Create (HINSTANCE hInstance)
{
WCam_Register (hInstance);
camerawindow = CreateWindow (CAMERA_WINDOW_CLASS ,
"Camera View",
QE3_STYLE,
0,
0,
(int)(screen_width*0.5),
(int)(screen_height-20), // size
mainwindow, // parent window
0, // no menu
hInstance,
0);
if (!camerawindow)
Sys_Error ("Couldn't create camerawindow");
RestoreWindowState(camerawindow, "camerawindow");
ShowWindow (camerawindow, SW_SHOWDEFAULT);
}

View file

@ -1,496 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "texpaint.h"
HINSTANCE main_instance;
int screen_width, screen_height;
HWND mainwindow;
HWND camerawindow;
HWND palettewindow;
HWND skinwindow;
/*
=================
Sys_Error
For abnormal program terminations
=================
*/
void Sys_Error (char *error, ...)
{
va_list argptr;
char text[1024];
char text2[1024];
int err;
err = GetLastError ();
va_start (argptr,error);
vsprintf (text, error,argptr);
va_end (argptr);
sprintf (text2, "%s\nGetLastError() = %i", text, err);
MessageBox(mainwindow, text2, "Error", 0 /* MB_OK */ );
exit (1);
}
/*
======================================================================
FILE DIALOGS
======================================================================
*/
qboolean modified;
qboolean modified_past_autosave;
qboolean ConfirmModified (void)
{
if (!modified)
return true;
if (MessageBox (mainwindow, "This will lose changes to the skin"
, "warning", MB_OKCANCEL) == IDCANCEL)
return false;
return true;
}
OPENFILENAME ofn; /* common dialog box structure */
char szDirName[MAX_PATH]; /* directory string */
char szFile[260]; /* filename string */
char szFileTitle[260]; /* file title string */
char szSkinFilter[260] = /* filter string */
"Skin texture (*.lbm *.pcx)\0*.lbm;*.pcx\0\0";
char szFrameFilter[260] = /* filter string */
"Model frame (*.tri)\0*.tri\0\0";
char chReplace; /* string separator for szFilter */
int i, cbString; /* integer count variables */
HANDLE hf; /* file handle */
void OpenSkinDialog (void)
{
// strcpy (szDirName, ValueForKey (project_entity, "basepath") );
// strcat (szDirName, "\\maps");
/* Place the terminating null character in the szFile. */
szFile[0] = '\0';
/* Set the members of the OPENFILENAME structure. */
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = mainwindow;
ofn.lpstrFilter = szSkinFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.lpstrInitialDir = szDirName;
ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
OFN_FILEMUSTEXIST;
/* Display the Open dialog box. */
if (!GetOpenFileName(&ofn))
return; // canceled
Skin_LoadFile (ofn.lpstrFile);
}
void OpenFrameDialog (void)
{
// strcpy (szDirName, ValueForKey (project_entity, "basepath") );
// strcat (szDirName, "\\maps");
/* Place the terminating null character in the szFile. */
szFile[0] = '\0';
/* Set the members of the OPENFILENAME structure. */
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = mainwindow;
ofn.lpstrFilter = szFrameFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.lpstrInitialDir = szDirName;
ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
OFN_FILEMUSTEXIST;
/* Display the Open dialog box. */
if (!GetOpenFileName(&ofn))
return; // canceled
LoadTriFile (ofn.lpstrFile);
}
void SaveSkinDialog (void)
{
// strcpy (szDirName, ValueForKey (project_entity, "basepath") );
// strcat (szDirName, "\\maps");
/* Place the terminating null character in the szFile. */
szFile[0] = '\0';
/* Set the members of the OPENFILENAME structure. */
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = mainwindow;
ofn.lpstrFilter = szSkinFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.lpstrInitialDir = szDirName;
ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST |
OFN_FILEMUSTEXIST;
/* Display the Open dialog box. */
if (!GetSaveFileName(&ofn))
return; // canceled
DefaultExtension (ofn.lpstrFile, ".lbm");
Skin_SaveFile (ofn.lpstrFile);
strcpy (skin_filename, ofn.lpstrFile);
}
//==========================================================================
BOOL bSetupPixelFormat(HDC hDC)
{
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
32, // 32-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int pixelformat = 0;
PIXELFORMATDESCRIPTOR newp;
if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 )
{
printf("%d",GetLastError());
Error ("ChoosePixelFormat failed");
}
if (!SetPixelFormat(hDC, pixelformat, &pfd))
Error ("SetPixelFormat failed");
return TRUE;
}
/*
==============================================================================
MENU
==============================================================================
*/
/* handle all WM_COMMAND messages here */
LONG WINAPI CommandHandler (
HWND hWnd,
WPARAM wParam,
LPARAM lParam)
{
unsigned short cmd;
cmd = LOWORD(wParam);
switch (cmd)
{
//
// file menu
//
case ID_FILE_RESAMPLESKIN:
ResampleSkin ();
break;
case ID_FILE_NEWSKIN:
NewSkin ();
break;
case ID_FILE_OPENFRAME:
OpenFrameDialog ();
break;
case ID_FILE_OPENSKIN:
if (!ConfirmModified())
break;
OpenSkinDialog ();
break;
case ID_FILE_RELOADSKIN:
if (!ConfirmModified())
break;
Skin_LoadFile (skin_filename);
break;
case ID_FILE_SAVESKIN:
Skin_SaveFile (skin_filename);
break;
case ID_FILE_SAVESKINAS:
SaveSkinDialog ();
break;
case ID_FILE_EXIT:
if (!ConfirmModified())
break;
PostQuitMessage (0);
break;
//
// edit menu
//
case ID_EDIT_UNDO:
Undo();
break;
case ID_EDIT_REDO:
Redo();
break;
//
// view menu
//
case ID_VIEW_MODELLINES:
model_lines ^= 1;
CheckMenuItem ( GetSubMenu (GetMenu(mainwindow), MENU_VIEW)
, ID_VIEW_MODELLINES
, MF_BYCOMMAND | (model_lines ? MF_CHECKED : MF_UNCHECKED) );
InvalidateRect (camerawindow, NULL, false);
break;
case ID_VIEW_TEXTURELINES:
skin_lines ^= 1;
CheckMenuItem ( GetSubMenu (GetMenu(mainwindow), MENU_VIEW)
, ID_VIEW_TEXTURELINES
, MF_BYCOMMAND | (skin_lines ? MF_CHECKED : MF_UNCHECKED) );
InvalidateRect (skinwindow, NULL, false);
break;
default:
return FALSE;
}
return TRUE;
}
/*
============
WMAIN_WndProc
============
*/
LONG WINAPI WMAIN_WndProc (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
LONG lRet = 1;
RECT rect;
HDC maindc;
GetClientRect(hWnd, &rect);
switch (uMsg)
{
case WM_CREATE:
maindc = GetDC(hWnd);
bSetupPixelFormat(maindc);
break;
case WM_COMMAND:
lRet = CommandHandler (hWnd, wParam, lParam);
break;
case WM_CLOSE:
if (!ConfirmModified())
break;
PostQuitMessage (0);
break;
default:
/* pass all unhandled messages to DefWindowProc */
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
break;
}
/* return 1 if handled message, 0 if not */
return lRet;
}
/*
==============
Main_Create
==============
*/
void Main_Create (HINSTANCE hInstance)
{
WNDCLASS wc;
/* Register the class */
memset (&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WMAIN_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU2);
wc.lpszClassName = "TEXPAINT_MAIN";
if (!RegisterClass (&wc) )
Error ("WCam_Register: failed");
mainwindow = CreateWindow ("TEXPAINT_MAIN" ,
"Texpaint",
WS_OVERLAPPEDWINDOW |
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN,
0,0,screen_width,screen_height, // size
0,
NULL, // no menu
hInstance,
NULL);
if (!mainwindow)
Error ("Couldn't create main window");
// GetWindowInfo("mainwindow", &SavedInfo, NULL);
ShowWindow (mainwindow, SW_SHOWDEFAULT);
}
BOOL SaveWindowInfo(const char *pszName, void *pvBuf, long lSize)
{
LONG lres;
DWORD dwDisp;
HKEY hKeyId;
lres = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\id\\Texpaint", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeyId, &dwDisp);
if (lres != ERROR_SUCCESS)
return FALSE;
lres = RegSetValueEx(hKeyId, pszName, 0, REG_BINARY, pvBuf, lSize);
RegCloseKey(hKeyId);
if (lres != ERROR_SUCCESS)
return FALSE;
return TRUE;
}
BOOL GetWindowInfo(const char *pszName, void *pvBuf, long *plSize)
{
HKEY hKey;
long lres, lType, lSize;
if (plSize == NULL)
plSize = &lSize;
lres = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\id\\Texpaint", 0, KEY_READ, &hKey);
if (lres != ERROR_SUCCESS)
return FALSE;
lres = RegQueryValueEx(hKey, pszName, NULL, &lType, pvBuf, plSize);
RegCloseKey(hKey);
if (lres != ERROR_SUCCESS)
return FALSE;
return TRUE;
}
BOOL SaveWindowState(HWND hWnd, const char *pszName)
{
RECT rc;
GetWindowRect(hWnd, &rc);
MapWindowPoints(NULL, mainwindow, (POINT *)&rc, 2);
return SaveWindowInfo(pszName, &rc, sizeof(rc));
}
BOOL RestoreWindowState(HWND hWnd, const char *pszName)
{
RECT rc;
LONG lSize = sizeof(rc);
if (GetWindowInfo(pszName, &rc, &lSize))
{
if (rc.left < 0)
rc.left = 0;
if (rc.top < 0)
rc.top = 0;
if (rc.right < rc.left + 16)
rc.right = rc.left + 16;
if (rc.bottom < rc.top + 16)
rc.bottom = rc.top + 16;
MoveWindow(hWnd, rc.left, rc.top, rc.right - rc.left,
rc.bottom - rc.top, FALSE);
return TRUE;
}
return FALSE;
}

View file

@ -1,257 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "texpaint.h"
#define PALETTE_WINDOW_CLASS "TPPalette"
HDC paldc;
int pal_width, pal_height;
int blocks_x, blocks_y;
int selected_index;
unsigned selected_rgb;
byte palette[768];
float SnapAspect (float aspect)
{
if (aspect > 128)
return 256;
if (aspect > 32)
return 128;
if (aspect > 8)
return 64;
if (aspect > 2)
return 32;
return 16;
}
void Pal_SetIndex (int index)
{
selected_index = index;
selected_rgb = palette[index*3] + (palette[index*3+1]<<8) + (palette[index*3+2]<<16);
InvalidateRect (palettewindow, NULL, false);
}
void Pal_Draw (void)
{
int x, y;
float aspect;
float xs, ys;
int c;
if (pal_width < 1 || pal_height < 1)
return;
//
// determine the block arrangement
//
if (pal_width > pal_height)
{
aspect = SnapAspect (pal_width / pal_height);
blocks_x = aspect;
blocks_y = 256/blocks_x;
}
else
{
aspect = SnapAspect (pal_height / pal_width);
blocks_y = aspect;
blocks_x = 256/blocks_y;
}
//
// draw it
//
glViewport (0,0,pal_width, pal_height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0,1,0,1,-100,100);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glClear (GL_COLOR_BUFFER_BIT);
glDisable (GL_DEPTH_TEST);
glDisable (GL_CULL_FACE);
glDisable (GL_TEXTURE_2D);
xs = 1.0/blocks_x;
ys = 1.0/blocks_y;
for (x=0 ; x<blocks_x ; x++)
{
for (y=0 ; y<blocks_y ; y++)
{
c = x*blocks_y+(blocks_y-1-y);
glColor3ubv (palette+c*3);
glRectf (x*xs, y*ys, (x+1)*xs, (y+1)*ys);
}
}
// highlight the selected texture
y = selected_index % blocks_y;
x = selected_index / blocks_y;
y = blocks_y-1-y;
glColor3f (0,0,0);
glRectf ( (x+0.4)*xs, (y+0.4)*ys, (x+0.6)*xs, (y+0.6)*ys);
}
void Pal_Click (int x, int y)
{
int index;
x = x*blocks_x/pal_width;
y = y*blocks_y/pal_height;
y = blocks_y-1-y;
index = x*blocks_y + y;
Pal_SetIndex (index);
}
/*
============
Palette_WndProc
============
*/
LONG WINAPI Palette_WndProc (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
LONG lRet = 1;
int fwKeys, xPos, yPos;
RECT rect;
GetClientRect(hWnd, &rect);
pal_width = rect.right-rect.left;
pal_height = rect.bottom-rect.top;
switch (uMsg)
{
case WM_CREATE:
paldc = GetDC(hWnd);
bSetupPixelFormat(paldc);
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
if (!wglMakeCurrent( paldc, baseRC ))
Error ("wglMakeCurrent failed");
Pal_Draw ();
EndPaint(hWnd, &ps);
SwapBuffers(paldc);
}
break;
case WM_MOUSEMOVE:
if (wParam != MK_LBUTTON)
break;
case WM_LBUTTONDOWN:
if (GetTopWindow(mainwindow) != hWnd)
BringWindowToTop(hWnd);
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
Pal_Click (xPos, yPos);
break;
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONUP:
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
ReleaseCapture ();
break;
case WM_SIZE:
InvalidateRect(skinwindow, NULL, false);
break;
case WM_NCCALCSIZE:// don't let windows copy pixels
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
return WVR_REDRAW;
case WM_CLOSE:
/* call destroy window to cleanup and go away */
DestroyWindow (hWnd);
break;
default:
/* pass all unhandled messages to DefWindowProc */
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
break;
}
/* return 1 if handled message, 0 if not */
return lRet;
}
/*
==============
WPal_Create
==============
*/
void WPal_Create (HINSTANCE hInstance)
{
WNDCLASS wc;
/* Register the skin class */
memset (&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)Palette_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = 0;
wc.lpszClassName = PALETTE_WINDOW_CLASS;
if (!RegisterClass (&wc) )
Error ("RegisterClass failed");
palettewindow = CreateWindow (PALETTE_WINDOW_CLASS ,
"Palette View",
QE3_STYLE,
(int)(screen_width*0.5),
0,
(int)(screen_width*0.5),
(int)(screen_height*.2), // size
mainwindow, // parent window
0, // no menu
hInstance,
0);
if (!palettewindow)
Error ("Couldn't create palettewindow");
// RestoreWindowState(palettewindow, "palettewindow");
ShowWindow (palettewindow, SW_SHOWDEFAULT);
}

View file

@ -1,946 +0,0 @@
/*
===========================================================================
Copyright (C) 1997-2006 Id Software, Inc.
This file is part of Quake 2 Tools source code.
Quake 2 Tools source code 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.
Quake 2 Tools source code 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 Quake 2 Tools source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "texpaint.h"
#define SKIN_WINDOW_CLASS "TPSkin"
HDC skindc;
int skinw_width, skinw_height; // size of the window
float skin_x = 128, skin_y = 128, skin_z = 100;
qboolean skin_lines = false;
char tri_filename[1024];
char skin_filename[1024];
int skin_width, skin_height; // size of the .lbm image
unsigned index_texture[1024*512];
void UpdateTexture (int offset)
{
int x, y;
y = offset / width2;
x = offset % width2;
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_SKIN);
// glTexImage2D (GL_TEXTURE_2D, 0, 3, width2, height2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgb);
glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, rgb+offset);
}
/*
===================================================================
TEXEL MODIFICATION
===================================================================
*/
#define MAX_MODIFY 8192
typedef struct
{
int offset;
int oldvalue;
} modify_t;
int modify_index;
int undo_index;
modify_t modify[MAX_MODIFY];
void SetSkinModified (void)
{
char text[1024];
if (modified && modified_past_autosave)
return;
modified = true;
modified_past_autosave = true;
sprintf (text, "%s *", skin_filename);
SetWindowText (skinwindow, text);
}
void SetSkin (int index, int pixel)
{
modify_t *m;
if (!modified)
SetSkinModified ();
// save undo info
m = &modify[undo_index];
m->offset = index;
m->oldvalue = pic[index];
modify_index = (++undo_index)&(MAX_MODIFY-1);
// modify it
rgb[index] = selected_rgb;
pic[index] = selected_index;
UpdateTexture (index);
InvalidateRect (skinwindow, NULL, false);
InvalidateRect (camerawindow, NULL, false);
}
void Undo (void)
{
modify_t *m;
int temp;
if (!undo_index)
return;
if (!--undo_index)
{ // back to unmodified state
modified = false;
SetWindowText (skinwindow, skin_filename);
}
m = &modify[undo_index];
// modify it
temp = pic[m->offset];
pic[m->offset] = m->oldvalue;
rgb[m->offset] = palette[m->oldvalue*3] +
(palette[m->oldvalue*3+1]<<8) + (palette[m->oldvalue*3+2]<<16);
m->oldvalue = temp;
UpdateTexture (m->offset);
InvalidateRect (skinwindow, NULL, false);
InvalidateRect (camerawindow, NULL, false);
}
void Redo (void)
{
modify_t *m;
int temp;
if (undo_index == modify_index)
return;
m = &modify[undo_index];
// modify it
temp = pic[m->offset];
pic[m->offset] = m->oldvalue;
rgb[m->offset] = palette[m->oldvalue*3] +
(palette[m->oldvalue*3+1]<<8) + (palette[m->oldvalue*3+2]<<16);
m->oldvalue = temp;
UpdateTexture (m->offset);
InvalidateRect (skinwindow, NULL, false);
InvalidateRect (camerawindow, NULL, false);
if (!undo_index++)
{ // modified again
char text[1024];
modified = true;
sprintf (text, "%s *", skin_filename);
SetWindowText (skinwindow, text);
}
}
//===================================================================
/*
=============
Skin_SaveFile
Load a skin texture and the base.tri from the same directory
=============
*/
void Skin_SaveFile (char *name)
{
byte *data;
int i, j;
char backup[1024];
// back up the current file if it exists
sprintf (backup, "%s.bak", name);
remove (backup);
rename (name, backup);
modified = false;
modified_past_autosave = false;
modify_index = undo_index = 0;
SetWindowText (skinwindow, skin_filename);
data = malloc(skin_width*skin_height);
for (i=0 ; i<skin_height ; i++)
memcpy (data + i*skin_width, pic + i*width2, skin_width);
Save256Image (name, data, palette, skin_width, skin_height);
free(data);
}
/*
=============
Expand256Texture
=============
*/
void Expand256Texture (void)
{
int i, j;
int p;
memset (rgb, 0, sizeof(rgb));
for (i=0 ; i<skin_height ; i++)
{
for (j=0 ; j<skin_width ; j++)
{
p = pic[i*width2+j];
rgb[i*width2+j] = (palette[p*3+0]<<0) + (palette[p*3+1]<<8) + (palette[p*3+2]<<16);
}
}
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_SKIN);
glTexImage2D (GL_TEXTURE_2D, 0, 3, width2, height2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgb);
}
void SetSizes (int width, int height)
{
int i;
if (width < 32)
width = 16;
if (height < 32)
height = 16;
skin_width = width;
skin_height = height;
if (skin_width > 1024 || skin_height > 512)
Sys_Error ("Skin file is too large");
width2 = 1;
height2 = 1;
for (i=0 ; i<12 ; i++)
{
if (width2 < skin_width)
width2<<=1;
if (height2 < skin_height)
height2<<=1;
}
// compatability shit for auto sizing of old skins
if (skin_width != 320 || skin_height != 200)
{
skinwidth = skin_width;
skinheight = skin_height;
}
else
{
skinwidth = 0;
skinheight = 0;
}
}
/*
=============
Skin_LoadFile
Load a skin texture and the base.tri from the same directory
=============
*/
void Skin_LoadFile (char *name)
{
int i, j, p;
byte *lbmpic;
byte *lbmpal;
char trifile[1024];
int width, height;
modified = false;
modified_past_autosave = false;
modify_index = undo_index = 0;
strcpy (skin_filename, name);
SetWindowText (skinwindow, skin_filename);
//
// read the texture
//
Load256Image (skin_filename, &lbmpic, &lbmpal, &width, &height);
memcpy (palette, lbmpal, sizeof(palette));
free (lbmpal);
SetSizes (width, height);
memset (pic, 0, sizeof(pic));
for (i=0 ; i<skin_height ; i++)
{
for (j=0 ; j<skin_width ; j++)
{
p = lbmpic[i*skin_width + j];
pic[i*width2+j] = p;
}
}
free (lbmpic);
Expand256Texture ();
InitIndexTexture ();
Pal_SetIndex (selected_index);
//
// read the polfile and
// generate the texture coordinates
//
strcpy (trifile, skin_filename);
StripExtension (trifile);
strcat (trifile, ".tri");
if (FileExists (trifile))
{
LoadTriFile (trifile);
CalcTmCoords ();
}
else
{
ExtractFilePath (name, trifile);
strcat (trifile, "base.tri");
if (FileExists (trifile))
{
LoadTriFile (trifile);
CalcTmCoords ();
}
}
InvalidateRect (palettewindow, NULL, false);
InvalidateRect (skinwindow, NULL, false);
InvalidateRect (camerawindow, NULL, false);
}
/*
=============
Skin_Click
=============
*/
int skin_last_index;
void Skin_Click (int x, int y, qboolean shift)
{
int index;
index = 0;
glReadBuffer (GL_BACK);
glReadPixels (x, y, 1,1, GL_RGB, GL_UNSIGNED_BYTE, &index);
index--;
if (index == -1)
return;
if (index >= width2*height2)
return;
if (index == skin_last_index)
return; // in same pixel
skin_last_index = index;
if (shift)
{
Pal_SetIndex (pic[index]);
return;
}
SetSkin (index, selected_index);
UpdateWindow (skinwindow);
}
void DrawModelST (void)
{
int i, j;
glColor4f (1,1,1,1);
glBegin (GL_TRIANGLES);
for (i=0 ; i<numfaces ; i++)
{
for (j=0 ; j<3 ; j++)
{
glVertex2f (tmcoords[i][j][0]*width2, (1-tmcoords[i][j][1])*height2);
}
}
glEnd ();
}
void DrawSkin (void)
{
glBegin (GL_POLYGON);
glTexCoord2f (0,1);
glVertex2f (0,0);
glTexCoord2f (0,0);
glVertex2f (0,height2);
glTexCoord2f (1,0);
glVertex2f (width2,height2);
glTexCoord2f (1,1);
glVertex2f (width2,0);
glEnd ();
}
void Skin_Draw (void)
{
int x, y;
float aspect;
float xs, ys;
int c;
//
// draw it
//
if (skin_z < 20)
skin_z = 20;
glViewport (0,0,skinw_width, skinw_height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (90, (float)skinw_width/skinw_height, 2, 16384);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
gluLookAt (skin_x, skin_y, skin_z, skin_x, skin_y, skin_z-1, 0, 1, 0);
glClearColor (0.3,0.3,0.3,1);
glClear (GL_COLOR_BUFFER_BIT);
glDisable (GL_DEPTH_TEST);
glDisable (GL_CULL_FACE);
glEnable (GL_TEXTURE_2D);
glColor4f (1,1,1,1);
DrawSkin ();
if (skin_lines)
{
glDisable (GL_TEXTURE_2D);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
DrawModelST ();
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable (GL_TEXTURE_2D);
}
SwapBuffers(skindc);
// now fill the back buffer with the index texture
glClearColor (0,0,0,0);
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_INDEX);
DrawSkin ();
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_SKIN);
}
/*
============
Skin_WndProc
============
*/
LONG WINAPI Skin_WndProc (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
LONG lRet = 1;
int fwKeys, xPos, yPos;
RECT rect;
GetClientRect(hWnd, &rect);
skinw_width = rect.right-rect.left;
skinw_height = rect.bottom-rect.top;
switch (uMsg)
{
case WM_CREATE:
skindc = GetDC(hWnd);
bSetupPixelFormat(skindc);
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
if (!wglMakeCurrent( skindc, baseRC ))
Sys_Error ("wglMakeCurrent failed");
Skin_Draw ();
EndPaint(hWnd, &ps);
}
break;
case WM_LBUTTONDOWN:
skin_last_index = -1;
draw:
if (GetTopWindow(mainwindow) != hWnd)
BringWindowToTop(hWnd);
SetFocus (skinwindow);
SetCapture (skinwindow);
fwKeys = wParam; // key flags
xPos = (short)LOWORD(lParam); // horizontal position of cursor
yPos = (short)HIWORD(lParam); // vertical position of cursor
yPos = (int)rect.bottom - 1 - yPos;
if (!wglMakeCurrent( skindc, baseRC ))
Sys_Error ("wglMakeCurrent failed");
Skin_Click (xPos, yPos, !!(wParam&(MK_SHIFT|MK_CONTROL)) );
break;
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONUP:
fwKeys = wParam; // key flags
if (! (fwKeys & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))
ReleaseCapture ();
break;
case WM_MOUSEMOVE:
{
static int oldx, oldy;
int dx, dy;
POINT pt;
if (wParam & MK_LBUTTON)
goto draw;
GetCursorPos (&pt);
xPos = pt.x;
yPos = pt.y;
if (!(wParam & (MK_RBUTTON|MK_MBUTTON)))
{
oldx = xPos;
oldy = yPos;
break;
}
dx = xPos-oldx;
dy = oldy-yPos;
if (!dx && !dy)
break;
SetCursorPos (oldx, oldy);
if (wParam == (MK_RBUTTON|MK_CONTROL) )
{
if (abs(dx) > abs(dy))
skin_z += 0.25*dx;
else
skin_z += 0.25*dy;
InvalidateRect (skinwindow, NULL, false);
}
if (wParam == MK_RBUTTON)
{
skin_x -= 0.25*dx;
skin_y -= 0.25*dy;
InvalidateRect (skinwindow, NULL, false);
}
}
break;
case WM_SIZE:
InvalidateRect(camerawindow, NULL, false);
break;
case WM_NCCALCSIZE:// don't let windows copy pixels
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
return WVR_REDRAW;
case WM_CLOSE:
DestroyWindow (hWnd);
break;
default:
/* pass all unhandled messages to DefWindowProc */
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
break;
}
/* return 1 if handled message, 0 if not */
return lRet;
}
/*
==============
WSkin_Create
==============
*/
void WSkin_Create (HINSTANCE hInstance)
{
WNDCLASS wc;
/* Register the camera class */
memset (&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)Skin_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = 0;
wc.lpszClassName = SKIN_WINDOW_CLASS;
if (!RegisterClass (&wc) )
Sys_Error ("RegisterClass failed");
skinwindow = CreateWindow (SKIN_WINDOW_CLASS ,
"Skin View",
QE3_STYLE,
(int)(screen_width*0.5),
(int)(screen_height*0.2),
(int)(screen_width*0.5),
(int)(screen_height*0.8), // size
mainwindow, // parent window
0, // no menu
hInstance,
0);
if (!skinwindow)
Error ("Couldn't create skinwindow");
// RestoreWindowState(palettewindow, "palettewindow");
ShowWindow (skinwindow, SW_SHOWDEFAULT);
}
/*
===================================================================
SKIN RESAMPLING
===================================================================
*/
HWND resamplewindow;
HDC resampledc;
#define RESAMPLE_WINDOW_CLASS "TPResample"
/*
============
Resample_WndProc
============
*/
LONG WINAPI Resample_WndProc (
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
resampledc = GetDC(hWnd);
bSetupPixelFormat(resampledc);
break;
}
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
/*
==============
ResampleWindow
==============
*/
void ResampleWindow (HINSTANCE hInstance)
{
WNDCLASS wc;
static qboolean registered;
if (!registered)
{
registered = true;
/* Register the camera class */
memset (&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)Resample_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = 0;
wc.lpszClassName = RESAMPLE_WINDOW_CLASS;
if (!RegisterClass (&wc) )
Sys_Error ("RegisterClass failed");
}
resamplewindow = CreateWindow (RESAMPLE_WINDOW_CLASS ,
"ResampleWindow",
WS_OVERLAPPED,
0, 0, width2+32, height2+32, // size
NULL, // parent window
0, // no menu
hInstance,
0);
if (!resamplewindow)
Error ("Couldn't create skinwindow");
ShowWindow (resamplewindow, SW_SHOWDEFAULT);
}
void OutlineTexture (byte *pic)
{
int i, j;
int x, y;
int empty;
byte oldpic[1024*512];
memcpy (oldpic, pic, width2*height2);
empty = oldpic[0];
for (i=0 ; i<height2 ; i++)
{
for (j=0 ; j<width2 ; j++)
{
if (oldpic[i*width2+j] != empty)
continue;
for (x=-1 ; x<=1 ; x++)
{
for (y=-1 ; y<=1 ; y++)
{
if (i+y < 0 || i+y >= height2)
continue;
if (j+x < 0 || j+x >= width2)
continue;
if (oldpic[(i+y)*width2 + j+x] != empty)
{
pic[i*width2+j] = oldpic[(i+y)*width2 + j+x];
goto done;
}
}
}
done: ;
}
}
}
void ResampleSkin (void)
{
int i, j;
static float oldtmcoords[10000][3][2];
static int newindex[1024*512];
static byte oldpic[1024*512];
// open a window of the texture size
ResampleWindow (main_instance);
// get new S/T from current frame
memcpy (oldtmcoords, tmcoords, numfaces*3*2*4);
CalcTmCoords ();
// draw all the triangles with the index texture
if (!wglMakeCurrent( resampledc, baseRC ))
Sys_Error ("wglMakeCurrent failed");
glViewport (0,0,width2, height2);
glClearColor (0,0,0,0);
glClear (GL_COLOR_BUFFER_BIT);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, width2, 0, height2, -100, 100);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glColor4f (1,1,1,1);
glDisable (GL_DEPTH_TEST);
glDisable (GL_CULL_FACE);
BindTextureEXT (GL_TEXTURE_2D, TEXTURE_INDEX);
#if 0
glDisable(GL_TEXTURE_2D);
glBegin (GL_LINE_LOOP);
glVertex3f (1,1,10);
glVertex3f (skin_width-1,0,10);
glVertex3f (skin_width-1,skin_height-1,10);
glVertex3f (1,skin_height-1,10);
glEnd ();
glEnable(GL_TEXTURE_2D);
#endif
glBegin (GL_TRIANGLES);
for (i=0 ; i<numfaces ; i++)
{
for (j=0 ; j<3 ; j++)
{
glTexCoord2f (oldtmcoords[i][j][0], oldtmcoords[i][j][1]);
glVertex3f (tmcoords[i][j][0]*width2, tmcoords[i][j][1]*height2, 10);
}
}
glEnd ();
SwapBuffers (resampledc);
// build the new color texture
memcpy (oldpic, pic, width2*height2);
glReadBuffer (GL_FRONT);
glReadPixels (0,0,width2,height2,GL_RGBA,GL_UNSIGNED_BYTE, &newindex);
for (i=0 ; i<height2 ; i++)
for (j=0 ; j<width2 ; j++)
pic[i*width2+j] = oldpic[newindex[i*width2+j]&0xffffff];
// outline it
OutlineTexture (pic);
Expand256Texture ();
InvalidateRect (skinwindow, NULL, false);
InvalidateRect (camerawindow, NULL, false);
// change name
strcpy (skin_filename, tri_filename);
StripExtension (skin_filename);
strcat (skin_filename, ".lbm");
SetSkinModified ();
wglMakeCurrent (NULL, NULL);
DestroyWindow (resamplewindow);
}
/*
===================================================================
NEW SKIN
===================================================================
*/
BOOL CALLBACK NewSkinDlgProc (
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
char sz[256];
int width, height;
switch (uMsg)
{
case WM_INITDIALOG:
SetWindowText(GetDlgItem(hwndDlg, IDC_WIDTH), "320");
SetWindowText(GetDlgItem(hwndDlg, IDC_HEIGHT), "200");
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
GetWindowText(GetDlgItem(hwndDlg, IDC_WIDTH), sz, 255);
width = atoi(sz);
GetWindowText(GetDlgItem(hwndDlg, IDC_HEIGHT), sz, 255);
height = atoi(sz);
SetSizes (width, height);
EndDialog(hwndDlg, 1);
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, 0);
return TRUE;
}
}
return FALSE;
}
void NewSkin (void)
{
int i, j;
byte *buf;
if (!DialogBox(main_instance, (char *)IDD_NEWSKIN, mainwindow, NewSkinDlgProc))
return;
// open a window of the texture size
ResampleWindow (main_instance);
// get new S/T from current frame
CalcTmCoords ();
// draw all the triangles
if (!wglMakeCurrent( resampledc, baseRC ))
Sys_Error ("wglMakeCurrent failed");
glViewport (0,0,width2, height2);
glClearColor (0,0,0,0);
glClear (GL_COLOR_BUFFER_BIT);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, width2, 0, height2, -100, 100);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glColor4f (1,1,1,1);
glDisable (GL_DEPTH_TEST);
glDisable (GL_CULL_FACE);
glDisable (GL_TEXTURE_2D);
for (i=0 ; i<numfaces ; i++)
{
glColor3f ((i&255)/255.0, (i&255)/255.0, (i&255)/255.0);
glBegin (GL_TRIANGLES);
for (j=0 ; j<3 ; j++)
glVertex3f (tmcoords[i][j][0]*width2, tmcoords[i][j][1]*height2, 10);
glEnd ();
}
SwapBuffers (resampledc);
// build the new color texture
glReadBuffer (GL_FRONT);
buf = malloc(width2*height2*4);
glReadPixels (0,0,width2,height2,GL_RGBA,GL_UNSIGNED_BYTE, buf);
for (i=0 ; i<width2*height2 ; i++)
pic[i] = buf[i*4];
free (buf);
// outline it
OutlineTexture (pic);
Expand256Texture ();
InitIndexTexture ();
InvalidateRect (skinwindow, NULL, false);
InvalidateRect (camerawindow, NULL, false);
// change name
strcpy (skin_filename, tri_filename);
StripExtension (skin_filename);
strcat (skin_filename, ".lbm");
SetSkinModified ();
wglMakeCurrent (NULL, NULL);
DestroyWindow (resamplewindow);
}