The GtkRadiant sources as originally released under the GPL license.

This commit is contained in:
Travis Bradshaw
2012-01-31 15:20:35 -06:00
commit 0991a5ce8b
1590 changed files with 431941 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

View File

@@ -0,0 +1,318 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant 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.
GtkRadiant 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 GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin
//
// Code by reyalP aka Reed Mideke
//
// Based on various other plugins
//
#include "bkgrnd2d.h"
CBackgroundRender render;
CBackgroundImage backgroundXY(XY),backgroundXZ(XZ),backgroundYZ(YZ);
CBackgroundRender::CBackgroundRender()
{
refCount = 1;
}
CBackgroundRender::~CBackgroundRender()
{
}
void CBackgroundRender::Register()
{
g_QglTable.m_pfnHookGL2DWindow( this );
}
void CBackgroundRender::Draw2D( VIEWTYPE vt )
{
switch(vt)
{
case XY:
backgroundXY.Render();
break;
case XZ:
backgroundXZ.Render();
break;
case YZ:
backgroundYZ.Render();
break;
}
}
CBackgroundImage::CBackgroundImage(VIEWTYPE vt)
{
m_tex = NULL;
m_alpha = 0.5;
// TODO, sensible defaults ? Or not show until we have extents ?
m_xmin = m_ymin = 0.0f;
m_xmax = m_ymax = 0.0f;
m_bActive = false;
m_vt = vt;
switch(m_vt)
{
case XY:
m_ix = 0;
m_iy = 1;
break;
case XZ:
m_ix = 0;
m_iy = 2;
break;
case YZ:
m_ix = 1;
m_iy = 2;
break;
}
}
/*
* should cleanup, but I don't think we can be sure it happens before our
* interfaces are gone
CBackgroundImage::~CBackgroundImage()
{
}
*/
void CBackgroundImage::Cleanup()
{
if(m_tex) {
g_QglTable.m_pfn_qglDeleteTextures(1,&m_tex->texture_number);
g_free(m_tex);
m_tex = NULL;
}
}
void CBackgroundImage::Render()
{
if (!m_bActive || !Valid())
return;
g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
g_QglTable.m_pfn_qglEnable(GL_TEXTURE_2D);
g_QglTable.m_pfn_qglEnable(GL_BLEND);
g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
g_QglTable.m_pfn_qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
g_QglTable.m_pfn_qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
g_QglTable.m_pfn_qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
g_QglTable.m_pfn_qglPolygonMode(GL_FRONT,GL_FILL);
// TODO, just so we can tell if we end up going the wrong way
// g_QglTable.m_pfn_qglPolygonMode(GL_BACK,GL_LINE);
// TODO any other state we should not assume ?
g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, m_tex->texture_number);
g_QglTable.m_pfn_qglBegin(GL_QUADS);
g_QglTable.m_pfn_qglColor4f(1.0,1.0,1.0,m_alpha);
g_QglTable.m_pfn_qglTexCoord2f(0.0,1.0);
g_QglTable.m_pfn_qglVertex2f(m_xmin,m_ymin);
g_QglTable.m_pfn_qglTexCoord2f(1.0,1.0);
g_QglTable.m_pfn_qglVertex2f(m_xmax,m_ymin);
g_QglTable.m_pfn_qglTexCoord2f(1.0,0.0);
g_QglTable.m_pfn_qglVertex2f(m_xmax,m_ymax);
g_QglTable.m_pfn_qglTexCoord2f(0.0,0.0);
g_QglTable.m_pfn_qglVertex2f(m_xmin,m_ymax);
g_QglTable.m_pfn_qglEnd();
g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, 0);
g_QglTable.m_pfn_qglPopAttrib();
}
bool CBackgroundImage::Load(const char *filename)
{
qtexture_t *newtex;
unsigned char *image = NULL; // gets allocated with what ? g_malloc
int width = 0, height = 0;
g_FuncTable.m_pfnLoadImage(filename,&image,&width,&height);
if(!image) {
Syn_Printf(MSG_WARN "load %s failed\n",filename);
return false;
}
// just in case we want to build for an old version
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=900
#ifdef BKGRND2D_JPG_WORKAROUND
if ( strlen(filename) > 4 && !strcmp(".jpg",filename + strlen(filename) - 4)) {
Syn_Printf(MSG_PREFIX ".jpg workaround, clearing alpha channel\n");
int size = width*height*4;
int i;
for (i = 3; i < size; i+=4) {
image[i] = 255;
}
}
#endif
//TODO bug for stored texture size
//TODO whose gl context are we in, anyway ?
newtex = g_FuncTable.m_pfnLoadTextureRGBA(image,width,height);
g_free(image);
if(!newtex) {
Syn_Printf(MSG_WARN "image to texture failed\n");
return false;
}
Cleanup();
m_tex = newtex;
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
return true;
}
bool CBackgroundImage::SetExtentsMM()
{
entity_s *worldentity;
const char *val;
int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
worldentity = (entity_s *)g_FuncTable.m_pfnGetEntityHandle(0);
if(!worldentity) {
Syn_Printf(MSG_WARN "SetExtentsMM worldspawn not found\n");
return false;
}
//TODO val is not NULL even if key does not exist
val = g_EntityTable.m_pfnValueForKey(worldentity,"mapcoordsmins");
if(!val || !val[0]) {
Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmins not found\n");
return false;
}
// we could be more robust
// note contortions due to splashs strange idea of min and max
if(sscanf(val, "%d %d",&xmin,&ymax) != 2)
{
Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmins malformed\n");
return false;
}
val = g_EntityTable.m_pfnValueForKey(worldentity,"mapcoordsmaxs");
if(!val || !val[0]) {
Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmaxs not found\n");
return false;
}
if(sscanf(val, "%d %d",&xmax,&ymin) != 2)
{
Syn_Printf(MSG_WARN "SetExtentsMM mapcoordsmaxs malformed\n");
return false;
}
//might do sanity check before we commit
m_xmin = (float)xmin;
m_ymin = (float)ymin;
m_xmax = (float)xmax;
m_ymax = (float)ymax;
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
return true;
}
// TODO, this should just be exported from core
// ripped directly from radiant/select.cpp:Select_GetBounds
//
static bool get_selection_bounds (vec3_t mins, vec3_t maxs)
{
brush_t *b;
int i;
brush_t *selected_brushes = g_DataTable.m_pfnSelectedBrushes();
//TODO should never happen
if(!selected_brushes) {
Sys_Printf (MSG_PREFIX "selected_brushes = NULL\n");
return false;
}
// this should mean no selection
if(selected_brushes == selected_brushes->next) {
Sys_Printf (MSG_PREFIX "nothing selected\n");
return false;
}
for (i=0 ; i<3 ; i++)
{
mins[i] = 99999;
maxs[i] = -99999;
}
for (b=selected_brushes->next ; b != selected_brushes ; b=b->next)
{
if (b->owner->eclass->fixedsize)
{
for (i=0 ; i<3 ; i++)
{
if (b->owner->origin[i] < mins[i])
mins[i] = b->owner->origin[i];
if (b->owner->origin[i] > maxs[i])
maxs[i] = b->owner->origin[i];
}
}
else
{
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];
}
}
}
return true;
}
bool CBackgroundImage::SetExtentsSel()
{
vec3_t mins,maxs;
if(!get_selection_bounds(mins,maxs))
return false;
if(((int)mins[m_ix] == (int)maxs[m_ix]) ||
((int)mins[m_iy] == (int)maxs[m_iy])) {
Syn_Printf(MSG_PREFIX "tiny selection\n");
return false;
}
m_xmin = mins[m_ix];
m_ymin = mins[m_iy];
m_xmax = maxs[m_ix];
m_ymax = maxs[m_iy];
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
return true;
}

View File

@@ -0,0 +1,8 @@
; bkgrnd2d.def : Declares the module parameters for the DLL.
LIBRARY "BKGRND2D"
DESCRIPTION 'BKGRND2D Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
Synapse_EnumerateInterfaces @1

View File

@@ -0,0 +1,133 @@
# Microsoft Developer Studio Project File - Name="bkgrnd2d" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=bkgrnd2d - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "bkgrnd2d.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 "bkgrnd2d.mak" CFG="bkgrnd2d - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bkgrnd2d - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "bkgrnd2d - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "bkgrnd2d - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BKGRND2D_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\shared" /I "..\..\..\libxml2\include" /I "..\..\..\gtk2-win32\include\glib-2.0" /I "..\..\..\gtk2-win32\lib\glib-2.0\include" /I "..\..\..\gtk2-win32\lib\gtk-2.0\include" /I "..\..\..\gtk2-win32\include\gtk-2.0" /I "..\..\..\gtk2-win32\include\gtk-2.0\gdk" /I "..\..\..\gtk2-win32\include\pango-1.0" /I "..\..\..\gtk2-win32\include\atk-1.0" /I "..\..\include" /I "..\common" /I "..\..\libs" /I "..\..\libs\nvtristrip" /I "..\..\..\STLPort\stlport" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BKGRND2D_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib glib-2.0.lib synapse.lib /nologo /dll /machine:I386 /libpath:"..\..\libs\synapse\release" /libpath:"..\..\..\gtk2-win32\lib\\"
!ELSEIF "$(CFG)" == "bkgrnd2d - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BKGRND2D_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\shared" /I "..\..\..\libxml2\include" /I "..\..\..\gtk2-win32\include\glib-2.0" /I "..\..\..\gtk2-win32\lib\glib-2.0\include" /I "..\..\..\gtk2-win32\lib\gtk-2.0\include" /I "..\..\..\gtk2-win32\include\gtk-2.0" /I "..\..\..\gtk2-win32\include\gtk-2.0\gdk" /I "..\..\..\gtk2-win32\include\pango-1.0" /I "..\..\..\gtk2-win32\include\atk-1.0" /I "..\..\include" /I "..\common" /I "..\..\libs" /I "..\..\libs\nvtristrip" /I "..\..\..\STLPort\stlport" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BKGRND2D_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib glib-2.0.lib synapse.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\libs\synapse\debug" /libpath:"..\..\..\gtk2-win32\lib\\"
!ENDIF
# Begin Target
# Name "bkgrnd2d - Win32 Release"
# Name "bkgrnd2d - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\bkgrnd2d.cpp
# End Source File
# Begin Source File
SOURCE=.\bkgrnd2d.def
# End Source File
# Begin Source File
SOURCE=.\dialog.cpp
# End Source File
# Begin Source File
SOURCE=.\plugin.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\bkgrnd2d.h
# End Source File
# Begin Source File
SOURCE=.\dialog.h
# End Source File
# Begin Source File
SOURCE=.\plugin.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,82 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant 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.
GtkRadiant 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 GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin
//
// Code by reyalP aka Reed Mideke
//
// Based on spritemodel source code by hydra
//
#include "plugin.h"
class CBackgroundImage {
private:
qtexture_t *m_tex;
VIEWTYPE m_vt;
// which components of a vec3_t correspond to x and y in the image
unsigned m_ix,m_iy;
public:
CBackgroundImage(VIEWTYPE vt);
// ~CBackgroundImage();
float m_alpha; // vertex alpha
bool m_bActive;
// x and y axis are in relation to the screen, not world, making rendering
// the same for each view type. Whoever sets them is responsible for
// shuffling.
// units are world units.
// TODO should be private
float m_xmin,m_ymin,m_xmax,m_ymax;
// load file, create new tex, cleanup old tex, set new tex
bool Load(const char *filename);
void Cleanup(); // free texture, free tex, set make tex NULL
bool SetExtentsMM(); // set extents by ET mapcoordsmaxs/mapcoordsmins
bool SetExtentsSel(); // set extents by selection
void Render();
bool Valid() { return (m_tex && (m_xmin != m_xmax) && (m_ymin != m_ymax)); }
};
class CBackgroundRender : public IGL2DWindow {
public:
CBackgroundRender();
virtual ~CBackgroundRender();
protected:
int refCount;
public:
// IGL2DWindow IGL3DWindow interface
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
void Draw2D( VIEWTYPE vt );
void Register();
};
extern CBackgroundImage backgroundXY,backgroundXZ,backgroundYZ;
extern CBackgroundRender render;

View File

@@ -0,0 +1,171 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="bkgrnd2d"
ProjectGUID="{356A36AA-1F10-48A0-BF63-227DFB46F208}"
>
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\shared,..\..\..\libxml2\include,..\..\..\gtk2-win32\include\glib-2.0,..\..\..\gtk2-win32\lib\glib-2.0\include,..\..\..\gtk2-win32\lib\gtk-2.0\include,..\..\..\gtk2-win32\include\gtk-2.0,..\..\..\gtk2-win32\include\gtk-2.0\gdk,..\..\..\gtk2-win32\include\pango-1.0,..\..\..\gtk2-win32\include\atk-1.0,..\..\include,..\common,..\..\libs,..\..\libs\nvtristrip,..\..\..\STLPort\stlport"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BKGRND2D_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/bkgrnd2d.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib glib-2.0.lib synapse.lib"
OutputFile=".\Release/bkgrnd2d.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\libs\synapse\release,..\..\..\gtk2-win32\lib\"
ModuleDefinitionFile=".\bkgrnd2d.def"
ProgramDatabaseFile=".\Release/bkgrnd2d.pdb"
ImportLibrary=".\Release/bkgrnd2d.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/bkgrnd2d.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\shared,..\..\..\libxml2\include,..\..\..\gtk2-win32\include\glib-2.0,..\..\..\gtk2-win32\lib\glib-2.0\include,..\..\..\gtk2-win32\lib\gtk-2.0\include,..\..\..\gtk2-win32\include\gtk-2.0,..\..\..\gtk2-win32\include\gtk-2.0\gdk,..\..\..\gtk2-win32\include\pango-1.0,..\..\..\gtk2-win32\include\atk-1.0,..\..\include,..\common,..\..\libs,..\..\libs\nvtristrip,..\..\..\STLPort\stlport"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BKGRND2D_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/bkgrnd2d.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib glib-2.0.lib synapse.lib"
OutputFile=".\Debug/bkgrnd2d.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\libs\synapse\debug,..\..\..\gtk2-win32\lib\"
ModuleDefinitionFile=".\bkgrnd2d.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/bkgrnd2d.pdb"
ImportLibrary=".\Debug/bkgrnd2d.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/bkgrnd2d.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath=".\bkgrnd2d.cpp">
</File>
<File
RelativePath=".\bkgrnd2d.def">
</File>
<File
RelativePath=".\dialog.cpp">
</File>
<File
RelativePath=".\plugin.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath=".\bkgrnd2d.h">
</File>
<File
RelativePath=".\dialog.h">
</File>
<File
RelativePath=".\plugin.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

364
contrib/bkgrnd2d/dialog.cpp Normal file
View File

@@ -0,0 +1,364 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant 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.
GtkRadiant 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 GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin dialog
//
// Code by reyalP aka Reed Mideke
//
// Based on various other plugins
//
#include <gtk/gtk.h>
#include "bkgrnd2d.h"
#include "dialog.h"
// spaces to make label nice and big
#define NO_FILE_MSG " (no file loaded) "
static GtkWidget *pDialogWnd;
static GtkWidget *pNotebook;
static GtkTooltips *pTooltips;
class CBackgroundDialogPage
{
private:
GtkWidget *m_pWidget;
GtkWidget *m_pTabLabel;
GtkWidget *m_pFileLabel;
GtkWidget *m_pPosLabel;
VIEWTYPE m_vt;
bool m_bValidFile;
public:
CBackgroundImage *m_pImage;
CBackgroundDialogPage( VIEWTYPE vt );
void Append(GtkWidget *notebook);
void Browse();
void Reload();
void SetPosLabel();
// ~BackgroundDialogPage();
};
// dialog page callbacks
static void browse_callback( GtkWidget *widget, gpointer data )
{
((CBackgroundDialogPage *)data)->Browse();
}
static void reload_callback( GtkWidget *widget, gpointer data )
{
((CBackgroundDialogPage *)data)->Reload();
}
static void size_sel_callback( GtkWidget *widget, gpointer data )
{
CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
if (pPage->m_pImage->SetExtentsSel())
pPage->SetPosLabel();
}
static void size_mm_callback( GtkWidget *widget, gpointer data )
{
CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
if(pPage->m_pImage->SetExtentsMM())
pPage->SetPosLabel();
}
static void alpha_adjust_callback( GtkWidget *widget, gpointer data )
{
CBackgroundDialogPage *pPage = (CBackgroundDialogPage *)data;
pPage->m_pImage->m_alpha = (float)gtk_range_get_value (GTK_RANGE(widget));
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
}
void CBackgroundDialogPage::Reload()
{
if(m_bValidFile)
m_pImage->Load(gtk_label_get_text(GTK_LABEL(m_pFileLabel)));
}
void CBackgroundDialogPage::Browse()
{
char browsedir[PATH_MAX];
const char *ct;
const char *newfile;
char *t;
//TODO GetMapName saves the map. eeep!
//also with no map, returns unnamed.map, otherwise returns full path
// Syn_Printf(MSG_PREFIX "GetMapName() %s\n",
// g_FuncTable.m_pfnGetMapName());
ct = g_FuncTable.m_pfnReadProjectKey("basepath");
// TODO shouldn't need this stuff
if(!ct || !strlen(ct)) {
Syn_Printf(MSG_PREFIX "basepath = NULL or empty\n");
return;
}
Syn_Printf(MSG_PREFIX "basepath: %s\n",ct);
if(strlen(ct) >= PATH_MAX) {
Syn_Printf(MSG_PREFIX "base game dir too long\n");
return;
}
strcpy(browsedir,ct);
// make sure we have a trailing /
if(browsedir[strlen(browsedir) - 1] != '/')
strcat(browsedir,"/");
//if we dont have a file yet, don't try to use it for default dir
if(m_bValidFile) {
// filename should always be a nice clean unix style relative path
ct = gtk_label_get_text(GTK_LABEL(m_pFileLabel));
strcat(browsedir,ct);
Syn_Printf(MSG_PREFIX "full path: %s\n",browsedir);
// lop off the file part
t = browsedir + strlen(browsedir) - 1;
while (t != browsedir && *t != '/')
t--;
*t = 0;
}
Syn_Printf(MSG_PREFIX "browse directory %s\n",browsedir);
//does NOT need freeing contrary to include/qerplugin.h comments
//TODO bug/patch for comments
//TODO patern gets fucked up sometimes if empty
//http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=915
newfile = g_FuncTable.m_pfnFileDialog(pDialogWnd,TRUE,
"Load Background Image",browsedir,FILETYPE_KEY);
if(!newfile) {
Syn_Printf(MSG_PREFIX "newfile = NULL\n");
return;
}
Syn_Printf(MSG_PREFIX "newfile: %s\n",newfile);
newfile = g_FileSystemTable.m_pfnExtractRelativePath(newfile);
if(!newfile) {
Syn_Printf(MSG_PREFIX "newfile = NULL\n");
return;
}
Syn_Printf(MSG_PREFIX "newfile: %s\n",newfile);
if(m_pImage->Load(newfile)) {
m_bValidFile = true;
gtk_label_set_text(GTK_LABEL(m_pFileLabel),newfile);
}
}
void CBackgroundDialogPage::SetPosLabel()
{
char s[64];
// TODO no snprintf ?
sprintf(s, "Size/Position (%d,%d) (%d,%d)",(int)(m_pImage->m_xmin),
(int)(m_pImage->m_ymin),(int)(m_pImage->m_xmax),(int)(m_pImage->m_ymax));
gtk_label_set_text(GTK_LABEL(m_pPosLabel),s);
}
CBackgroundDialogPage::CBackgroundDialogPage(VIEWTYPE vt )
{
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *w;
m_vt = vt;
m_bValidFile = false;
switch(m_vt)
{
case XY:
m_pTabLabel = gtk_label_new("X/Y");
m_pImage = &backgroundXY;
break;
case XZ:
m_pTabLabel = gtk_label_new("X/Z");
m_pImage = &backgroundXZ;
break;
case YZ:
m_pTabLabel = gtk_label_new("Y/Z");
m_pImage = &backgroundYZ;
break;
}
// A vbox to hold everything
m_pWidget = gtk_vbox_new(FALSE,0);
// Frame for file row
frame = gtk_frame_new("File");
gtk_box_pack_start (GTK_BOX (m_pWidget),frame, FALSE, FALSE, 2);
// hbox for first row
hbox = gtk_hbox_new(FALSE,5);
gtk_container_set_border_width(GTK_CONTAINER (hbox),4);
gtk_container_add (GTK_CONTAINER (frame), hbox);
// label to display filename
m_pFileLabel = gtk_label_new(NO_FILE_MSG);
gtk_label_set_selectable(GTK_LABEL(m_pFileLabel),TRUE);
//TODO set min size ? done with spaces right now
gtk_box_pack_start (GTK_BOX (hbox),m_pFileLabel, TRUE, TRUE, 5);
gtk_widget_show (m_pFileLabel);
w = gtk_button_new_with_label ("Browse...");
g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (browse_callback),
(gpointer)this);
gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);
gtk_tooltips_set_tip (pTooltips, w, "Select a file", NULL);
gtk_widget_show (w);
w = gtk_button_new_with_label ("Reload");
g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (reload_callback),
(gpointer)this);
// TODO disable until we have file
// gtk_widget_set_sensitive(w,FALSE);
gtk_tooltips_set_tip (pTooltips, w, "Reload current file", NULL);
gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);
gtk_widget_show (w);
gtk_widget_show (hbox);
gtk_widget_show (frame);
// second row (rendering options)
frame = gtk_frame_new("Rendering");
gtk_box_pack_start (GTK_BOX (m_pWidget),frame, FALSE, FALSE, 2);
hbox = gtk_hbox_new(FALSE,5);
gtk_container_set_border_width(GTK_CONTAINER (hbox),4);
gtk_container_add (GTK_CONTAINER (frame), hbox);
w = gtk_label_new("Vertex alpha:");
gtk_box_pack_start (GTK_BOX (hbox),w, FALSE, FALSE, 5);
gtk_widget_show (w);
w = gtk_hscale_new_with_range(0.0,1.0,0.01);
gtk_range_set_value(GTK_RANGE(w),0.5);
gtk_scale_set_value_pos(GTK_SCALE(w),GTK_POS_LEFT);
g_signal_connect (G_OBJECT (w), "value-changed",
G_CALLBACK (alpha_adjust_callback), (gpointer)this);
gtk_box_pack_start (GTK_BOX (hbox),w, TRUE, TRUE, 5);
gtk_tooltips_set_tip (pTooltips, w, "Set image transparancy", NULL);
gtk_widget_show (w);
gtk_widget_show (hbox);
gtk_widget_show (frame);
// Third row (size and position)
frame = gtk_frame_new("Size/Position (undefined)");
m_pPosLabel = gtk_frame_get_label_widget (GTK_FRAME(frame));
gtk_box_pack_start ( GTK_BOX (m_pWidget), frame, FALSE, FALSE, 2);
hbox = gtk_hbox_new(FALSE,5);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_container_set_border_width(GTK_CONTAINER (hbox),4);
w = gtk_button_new_with_label ("from selection");
gtk_box_pack_start (GTK_BOX (hbox),w, TRUE, FALSE, 5);
g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (size_sel_callback),
(gpointer)this);
gtk_tooltips_set_tip (pTooltips, w, "Set the size of the image to the bounding rectangle of all selected brushes and entities", NULL);
gtk_widget_show (w);
if(m_vt == XY) {
w = gtk_button_new_with_label ("from map mins/maxs");
gtk_box_pack_start ( GTK_BOX (hbox),w, TRUE, FALSE, 2);
g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (size_mm_callback),
(gpointer)this);
gtk_tooltips_set_tip (pTooltips, w, "Set the size of the image using the mapcoordsmins and mapcoordsmaxs keys of the worldspawn entity", NULL);
gtk_widget_show (w);
}
gtk_widget_show (hbox);
gtk_widget_show (frame);
gtk_widget_show ( m_pWidget );
}
void CBackgroundDialogPage::Append(GtkWidget *notebook)
{
gtk_notebook_append_page( GTK_NOTEBOOK(notebook), m_pWidget, m_pTabLabel);
}
// dialog global callbacks
/*
static gint expose_callback( GtkWidget *widget, gpointer data )
{
return FALSE;
}
*/
static void response_callback( GtkWidget *widget, gint response, gpointer data )
{
if( response == GTK_RESPONSE_CLOSE )
gtk_widget_hide( pDialogWnd );
}
static gint close_callback( GtkWidget *widget, gpointer data )
{
gtk_widget_hide( pDialogWnd );
return TRUE;
}
void InitBackgroundDialog()
{
CBackgroundDialogPage *pPage;
pDialogWnd = gtk_dialog_new_with_buttons ("Background Images",
GTK_WINDOW(g_pMainWidget),
(GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT),
// TODO dialog with no buttons
// GTK_STOCK_CLOSE,
// GTK_RESPONSE_CLOSE,
NULL);
gtk_signal_connect( GTK_OBJECT (pDialogWnd), "delete_event",
GTK_SIGNAL_FUNC( close_callback ), NULL );
gtk_signal_connect( GTK_OBJECT (pDialogWnd), "response",
GTK_SIGNAL_FUNC( response_callback ), NULL );
// gtk_signal_connect( GTK_OBJECT (pDialogWnd), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL );
pTooltips = gtk_tooltips_new();
pNotebook = gtk_notebook_new();
pPage = new CBackgroundDialogPage(XY);
pPage->Append(pNotebook);
pPage = new CBackgroundDialogPage(XZ);
pPage->Append(pNotebook);
pPage = new CBackgroundDialogPage(YZ);
pPage->Append(pNotebook);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(pDialogWnd)->vbox), pNotebook, TRUE, TRUE, 0);
gtk_widget_show ( pNotebook );
gtk_widget_realize( pDialogWnd );
}
void ShowBackgroundDialog()
{
gtk_window_present( GTK_WINDOW(pDialogWnd) );
}
void ShowBackgroundDialogPG(int page)
{
gtk_notebook_set_current_page(GTK_NOTEBOOK(pNotebook),page);
ShowBackgroundDialog();
}

35
contrib/bkgrnd2d/dialog.h Normal file
View File

@@ -0,0 +1,35 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant 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.
GtkRadiant 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 GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin dialog box
//
// Code by reyalP aka Reed Mideke
//
//
#ifndef _BKGRND2D_DIALOG_H_
#define _BKGRND2D_DIALOG_H_
void InitBackgroundDialog();
void ShowBackgroundDialog();
void ShowBackgroundDialogPG(int page);
#endif // _BKGRND2D_DIALOG_H_

319
contrib/bkgrnd2d/plugin.cpp Normal file
View File

@@ -0,0 +1,319 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant 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.
GtkRadiant 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 GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// 2d background Plugin
//
// Code by reyalP aka Reed Mideke
//
// Based on
//
/*
Overview
========
This little plugin allows you to display an image in the background of the
gtkradiant XY window.
Version History
===============
v0.1
- Initial version.
v0.2
- three views, dialog box, toolbar
v0.25
- tooltips, follow gtkradiant coding conventions
Why ?
-----
http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=88
How ?
-----
- textures 'n widgets 'n stuff.
*/
//#include "plugin.h"
//TODO we just poke the objects directly
#include "bkgrnd2d.h"
#include "dialog.h"
#define CMD_SEP "-"
#define CMD_CONFIG "Configure..."
#define CMD_ABOUT "About..."
// =============================================================================
// Globals
// function tables
_QERFuncTable_1 g_FuncTable;
_QERQglTable g_QglTable;
_QERFileSystemTable g_FileSystemTable;
_QEREntityTable g_EntityTable;
_QERAppDataTable g_DataTable;
// for the file load dialog
void *g_pMainWidget;
// =============================================================================
// plugin implementation
static const char *PLUGIN_NAME = "2d window background plugin";
//backwards for some reason
static const char *PLUGIN_COMMANDS = CMD_ABOUT ";"
CMD_SEP ";"
CMD_CONFIG
;
static const char *PLUGIN_ABOUT = "2d window background v0.25\n\n"
"By reyalP (hellsownpuppy@yahoo.com)";
void DoBkgrndToggleXY();
void DoBkgrndToggleXZ();
void DoBkgrndToggleYZ();
#define NUM_TOOLBAR_BUTTONS 4
struct toolbar_button_info_s
{
char *image;
char *text;
char *tip;
void (*func)();
IToolbarButton::EType type;
};
struct toolbar_button_info_s toolbar_buttons[NUM_TOOLBAR_BUTTONS] =
{
{
"bkgrnd2d_xy_toggle.bmp",
"xy background",
"Toggle xy background image",
DoBkgrndToggleXY,
IToolbarButton::eToggleButton
},
{
"bkgrnd2d_xz_toggle.bmp",
"xz background",
"Toggle xz background image",
DoBkgrndToggleXZ,
IToolbarButton::eToggleButton
},
{
"bkgrnd2d_yz_toggle.bmp",
"yz background",
"Toggle yz background image",
DoBkgrndToggleYZ,
IToolbarButton::eToggleButton
},
{
"bkgrnd2d_conf.bmp",
"Configure",
"Configure background images",
ShowBackgroundDialog,
IToolbarButton::eButton
},
};
class Bkgrnd2dButton : public IToolbarButton
{
public:
const toolbar_button_info_s *bi;
virtual const char* getImage() const
{
return bi->image;
}
virtual const char* getText() const
{
return bi->text;
}
virtual const char* getTooltip() const
{
return bi->tip;
}
virtual void activate() const
{
bi->func();
return ;
}
virtual EType getType() const
{
return bi->type;
}
};
Bkgrnd2dButton g_bkgrnd2dbuttons[NUM_TOOLBAR_BUTTONS];
unsigned int ToolbarButtonCount()
{
return NUM_TOOLBAR_BUTTONS;
}
const IToolbarButton* GetToolbarButton(unsigned int index)
{
g_bkgrnd2dbuttons[index].bi = &toolbar_buttons[index];
return &g_bkgrnd2dbuttons[index];
}
extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)
{
g_pMainWidget = pMainWidget;
InitBackgroundDialog();
render.Register();
//TODO is it right ? is it wrong ? it works
//TODO figure out supported image types
GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("all files", "*.*"));
GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("jpeg files", "*.jpg"));
GetFileTypeRegistry()->addType(FILETYPE_KEY, filetype_t("targa files", "*.tga"));
return (char *) PLUGIN_NAME;
}
extern "C" const char* QERPlug_GetName ()
{
return (char *) PLUGIN_NAME;
}
extern "C" const char* QERPlug_GetCommandList ()
{
return (char *) PLUGIN_COMMANDS;
}
extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
{
Sys_Printf (MSG_PREFIX "Command \"%s\"\n",p);
if(!strcmp(p, CMD_ABOUT)) {
g_FuncTable.m_pfnMessageBox(NULL, PLUGIN_ABOUT, "About", MB_OK, NULL);
}
else if(!strcmp(p,CMD_CONFIG)) {
ShowBackgroundDialog();
}
}
//TODO these three suck
void DoBkgrndToggleXY()
{
Sys_Printf (MSG_PREFIX "DoBkgrndToggleXY\n");
// always toggle, since the buttons do
backgroundXY.m_bActive = (backgroundXY.m_bActive) ? false:true;
// if we don't have image or extents, and we activated,
// bring up the dialog with the corresponding page
// would be better to hide or grey out button, but we can't
if(backgroundXY.m_bActive && !backgroundXY.Valid())
ShowBackgroundDialogPG(0);
else
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
}
void DoBkgrndToggleXZ()
{
Sys_Printf (MSG_PREFIX "DoBkgrndToggleXZ\n");
backgroundXZ.m_bActive = (backgroundXZ.m_bActive) ? false:true;
if(backgroundXZ.m_bActive && !backgroundXZ.Valid())
ShowBackgroundDialogPG(1);
else
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
}
void DoBkgrndToggleYZ()
{
Sys_Printf (MSG_PREFIX "DoBkgrndToggleYZ\n");
backgroundYZ.m_bActive = (backgroundYZ.m_bActive) ? false:true;
if(backgroundYZ.m_bActive && !backgroundYZ.Valid())
ShowBackgroundDialogPG(2);
else
g_FuncTable.m_pfnSysUpdateWindows(W_XY);
}
// =============================================================================
// SYNAPSE
CSynapseServer* g_pSynapseServer = NULL;
CSynapseClientBkgrnd2d g_SynapseClient;
extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
{
if (strcmp(version, SYNAPSE_VERSION))
{
Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
return NULL;
}
g_pSynapseServer = pServer;
g_pSynapseServer->IncRef();
Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
g_SynapseClient.AddAPI(TOOLBAR_MAJOR, BKGRND2D_MINOR, sizeof(_QERPlugToolbarTable));
g_SynapseClient.AddAPI(PLUGIN_MAJOR, BKGRND2D_MINOR, sizeof( _QERPluginTable ) );
g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( g_FuncTable ), SYN_REQUIRE, &g_FuncTable );
g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( g_QglTable ), SYN_REQUIRE, &g_QglTable );
// TODO is this the right way to ask for 'whichever VFS we have loaded' ? Seems to work
// for misc filename functions
g_SynapseClient.AddAPI( VFS_MAJOR, "*", sizeof( g_FileSystemTable ), SYN_REQUIRE, &g_FileSystemTable );
// get worldspawn
g_SynapseClient.AddAPI( ENTITY_MAJOR, NULL, sizeof( g_EntityTable ), SYN_REQUIRE, &g_EntityTable );
// selected brushes
g_SynapseClient.AddAPI( DATA_MAJOR, NULL, sizeof( g_DataTable ), SYN_REQUIRE, &g_DataTable );
return &g_SynapseClient;
}
bool CSynapseClientBkgrnd2d::RequestAPI(APIDescriptor_t *pAPI)
{
if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))
{
_QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
pTable->m_pfnQERPlug_Init = QERPlug_Init;
pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
return true;
}
if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR))
{
_QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
pTable->m_pfnGetToolbarButton = &GetToolbarButton;
return true;
}
Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
return false;
}
#include "version.h"
const char* CSynapseClientBkgrnd2d::GetInfo()
{
return "2d Background plugin built " __DATE__ " " RADIANT_VERSION;
}
const char* CSynapseClientBkgrnd2d::GetName()
{
return "bkgrnd2d";
}

79
contrib/bkgrnd2d/plugin.h Normal file
View File

@@ -0,0 +1,79 @@
/*
Copyright (C) 2003 Reed Mideke.
This file is part of GtkRadiant.
GtkRadiant 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.
GtkRadiant 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 GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// bkgrnd2d Plugin
//
// Code by reyalP aka Reed Mideke
//
// Based on spritemodel source code by hydra
//
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
/*!
\todo need general notice about lib purpose etc.
and the external dependencies (such as GLib, STL, mathlib etc.)
*/
#include <stdio.h>
// for CPtrArray for idata.h
#include "missing.h"
#include "synapse.h"
#include "iplugin.h"
#include "itoolbar.h"
#define USE_QERTABLE_DEFINE
#include "qerplugin.h"
#include "igl.h"
#include "ifilesystem.h"
#include "ientity.h"
#include "idata.h"
// verbose messages
#define BKGRND2D_DEBUG
extern _QERFuncTable_1 g_FuncTable;
extern _QERQglTable g_QglTable;
extern _QERFileSystemTable g_FileSystemTable;
extern _QEREntityTable g_EntityTable;
extern _QERAppDataTable g_DataTable;
extern void *g_pMainWidget;
extern CSynapseServer* g_pSynapseServer;
class CSynapseClientBkgrnd2d : public CSynapseClient
{
public:
// CSynapseClient API
bool RequestAPI(APIDescriptor_t *pAPI);
const char* GetInfo();
const char* GetName();
CSynapseClientBkgrnd2d() { }
virtual ~CSynapseClientBkgrnd2d() { }
};
#define MSG_PREFIX "bkgrnd2d: "
#define MSG_WARN "bkgrnd2d WARNING: "
#define BKGRND2D_MINOR "bkgrnd2d"
#define FILETYPE_KEY "bkgrnd2d"
#endif // _PLUGIN_H_

View File

@@ -0,0 +1,131 @@
November 25 2003
bkgrnd2d v 0.25 beta for radiant 1.3.13
by SCDS_reyalP (email hellsownpuppy@yahoo.com)
WARNING:
This is an beta release. It is provided with absolutely NO WARRANTY.
If it turns your data to mush and melts your CPU, don't blame me.
Overview:
This little plugin allows you to display an image in the the gtkradiant 2d
windows. This is useful for layout sketches, maps made from
existing plans, building geometry based on photgraphs, viewing terrain
alphamaps in relation to your terrain, and so on.
Installation:
extract the .dll and bitmaps into your gtkradiant/plugins directory, and
restart radiant. Be sure to use directory names, to ensure the bitmaps go
in your plugins/bitmaps directory.
Uninstallation:
Close radiant, delete the bkgrnd2d.dll from the plugins directory, and
delete the bkgrnd2*.bmp files from the plugins/bitmaps directory.
User Interface:
- The plugin adds 4 buttons to the radiant plugin toolbar. The first 3
toggle the display of a background image in the specified view. The fourth
brings up a configuration dialog. The configuration dialog can also be
opened from the plugins menu.
- If an image has not been loaded, or it's display size and location have
not been set, pushing one of the toggle buttons will bring up the dialog
with the corresponding page selected.
- The configuration dialog is non-modal, meaning that you can leave it open
while you work in radiant. If it gets lost behind another window, clicking
on the configuration button will bring it to the forground.
Usage:
- bring up the configuration dialog.
- Choose the "Browse..." button. This will prompt you for an image file.
The file *MUST* be inside your basegame directory (baseq3, main, etmain or
whatever your chosen game uses). The image must be in a format supported by
the game in use. For q3 based games this is truecolor .jpg, .tga and
sometimes .png. For q2 this is .wal
- Use one of the following methods to set the size (in game units) that the
file is displayed.
1) select 1 or more brushes or entities and choose "from selection"
This will use the total dimensions off all selected brushes and entities
to size the image.
2) For the X/Y view only, choose 'Size to min/max keys' This will look in
the worldspawn entity for the keys mapcoordsmins and mapcoordsmaxs (also
used for ET tracemap generation and command map sizing) and use those
dimensions to size the image.
- Use the toggle buttons to show or hide the loaded images. The buttons will
press or unpress whenever you click them, but an image will only be
displayed once you have successfully loaded a file and set its size/postion.
- Set the opacity of the image using the slider in the configuration dialog.
- If any of these commands do not produce the expected results, there may be
an information in the radiant console. Please include this when reporting
bugs.
Notes and limitations:
- This plugin is compiled for GtkRadiant 1.3.13. It may or may not work with
later versions. It will *NOT* work with version 1.3.12 and below. If you
build from source (see below) you can build it for other versions.
- As mentioned above, the image *MUST* be inside your basegame directory, or
another directory in which radiant looks for game files.
- To prevent the image from being distorted, you should size it to the
original images aspect ratio. mapcoordsmaxs/mapcoordsmins and command maps
should always be square.
- If you want a specific pixel to world unit relationship, you must arrange
that yourself.
- On load, the image is converted to a texture whose dimensions are powers
of 2. If the original image dimensions are not powers of 2, some detail will
be lost due to resampling. If it is too large to fit on a single texture,
resolution is reduced.
- radiants gamma and mipmap options are applied to the image.
- If the image has an alpha channel, it will be included in the blending
process. 0 is transparent, 255 is opaque. .tga images are recommended if
you want to have an alpha channel.
- since the plugin will only use true color files, you cannot use a terrain
indexmap (aka alphamap) or heightmap directly. You can of course, save a
copy of your indexmap in a 32 bit format.
- There is no unload command.
- You put the plugin in a game specific plugin directory, rather than the
radiant plugin directory.
- You cannot set the image size with sub-unit precision.
- Only win32 binaries are included. The source is available from:
http://www.cyberonic.net/~gdevault/rfm/mapstuff/bkgrnd2d-b0.25-src.zip
If you want to use it on another platform you will need a buildable gtkradiant
source tree to build it. For any non-windows platform you will also have to
figure out the compile options. I suggest ripping those off from some other
plugin.
TODO:
- make file selection paterns match supported filetypes
- large images without downsampling
- bitmap and pcx support for indexmaps
- automatic size from indexmapped entities
- render under the grid instead of blending
- mac/*nix support
- remember/save/restore settings
- texture options independant of radiant prefs
- clean up icky code
Changes from 0.1
- all 2d views supported
- new ui
- file selection patterns, default directory improved
Changes from 0.2
- tooltips in dialog
- various code cleanup

View File

@@ -0,0 +1,63 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h" // Added by ClassView
class CBspPoint {
public:
float p[3];
};
class CBspPortal {
public:
CBspPortal();
~CBspPortal();
unsigned point_count;
CBspPoint *point;
bool Build(char *def, unsigned int pointCnt, bool bInverse);
};
class CBspNode {
public:
CBspPortal *portal;
unsigned int portal_count;
bool AddPortal(char* def, unsigned int pointCnt, bool bInverse);
unsigned int portal_next;
CBspNode();
~CBspNode();
};
class CPortals {
public:
CPortals();
~CPortals();
void Load(); // use filename in fn
void Purge();
char fn[NAME_MAX];
CBspNode *node;
unsigned int node_count;
};

View File

@@ -0,0 +1,366 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// BobView.cpp: implementation of the DBobView class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "DBobView.h"
#include "DListener.h"
//#include "misc.h"
#include "funchandlers.h"
#include "gtkr_list.h"
#include "str.h"
#include "misc.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DBobView::DBobView()
{
nPathCount = 0;
refCount = 1;
m_bHooked = FALSE;
path = NULL;
eyes = NULL;
boundingShow = BOUNDS_APEX;
}
DBobView::~DBobView()
{
if(path)
delete[] path;
// oops forgot to remove our eyes, was causing access violation when it tried
// to talk to it's parent
if(eyes)
delete eyes;
if(m_bHooked)
UnRegister();
g_PathView = NULL;
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
void DBobView::Draw2D(VIEWTYPE vt)
{
if(!path)
return;
__QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
__QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglEnable(GL_LINE_SMOOTH);
__QGLTABLENAME.m_pfn_qglPushMatrix();
switch(vt)
{
case XY:
break;
case XZ:
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
break;
case YZ:
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
break;
}
__QGLTABLENAME.m_pfn_qglLineWidth(1.0f);
__QGLTABLENAME.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 1.0f);
int i;
__QGLTABLENAME.m_pfn_qglBegin(GL_LINE_STRIP);
for(i = 0; i < nPathCount; i++)
__QGLTABLENAME.m_pfn_qglVertex3fv(path[i]);
__QGLTABLENAME.m_pfn_qglEnd();
if(m_bShowExtra)
{
// +mars
// for the bounding box stuff
__QGLTABLENAME.m_pfn_qglColor4f(0.25f, 0.75f, 0.75f, 1.0f);
__QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, 16.0f, 28.0f );
__QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
for ( i = 0; i < nPathCount; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
__QGLTABLENAME.m_pfn_qglEnd();
// ---------------
__QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, -16.0f, -28.0f ); // back to where we were
__QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, 16.0f, 28.0f ); // move to new postion
__QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
for ( i = 0; i < nPathCount; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
__QGLTABLENAME.m_pfn_qglEnd();
// --------------
__QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, -16.0f, -28.0f ); // back to where we were
__QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, -16.0f, -28.0f ); // new pos
__QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
for ( i = 0; i < nPathCount; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
__QGLTABLENAME.m_pfn_qglEnd();
// ----------------
__QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, 16.0f, 28.0f ); // back to where we were
/* __QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, -16.0f, -28.0f ); // new pos
__QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
if ( boundingShow == BOUNDS_ALL )
{
for ( i = 0; i < nPathCount; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
}
else if ( boundingShow == BOUNDS_APEX )
{
for ( i = (nPathCount/4); i < (nPathCount/4) * 3; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
}
__QGLTABLENAME.m_pfn_qglEnd();*/ // djbob: er, um doesn't really seem to do anyhting
}
// -mars
__QGLTABLENAME.m_pfn_qglPopMatrix();
__QGLTABLENAME.m_pfn_qglPopAttrib();
}
void DBobView::Draw3D()
{
if(!path)
return;
__QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
__QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglEnable(GL_LINE_SMOOTH);
__QGLTABLENAME.m_pfn_qglLineWidth(1.0f);
__QGLTABLENAME.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 1.0f);
__QGLTABLENAME.m_pfn_qglBegin(GL_LINE_STRIP);
for(int i = 0; i < nPathCount; i++)
__QGLTABLENAME.m_pfn_qglVertex3fv(path[i]);
__QGLTABLENAME.m_pfn_qglEnd();
if(m_bShowExtra)
{
// +mars
// ahhh -- a nice C&P job :)
// for the bounding box stuff
__QGLTABLENAME.m_pfn_qglColor4f(0.25f, 0.75f, 0.75f, 1.0f);
__QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, 16.0f, 28.0f );
__QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
int i;
for ( i = 0; i < nPathCount; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
__QGLTABLENAME.m_pfn_qglEnd();
// ---------------
__QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, -16.0f, -28.0f ); // back to where we were
__QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, 16.0f, 28.0f ); // move to new postion
__QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
for ( i = 0; i < nPathCount; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
__QGLTABLENAME.m_pfn_qglEnd();
// --------------
__QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, -16.0f, -28.0f ); // back to where we were
__QGLTABLENAME.m_pfn_qglTranslatef( 16.0f, -16.0f, -28.0f ); // new pos
__QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
for ( i = 0; i < nPathCount; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
__QGLTABLENAME.m_pfn_qglEnd();
// ----------------
__QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, 16.0f, 28.0f ); // back to where we were
__QGLTABLENAME.m_pfn_qglTranslatef( -16.0f, -16.0f, -28.0f ); // new pos
__QGLTABLENAME.m_pfn_qglBegin( GL_LINE_STRIP );
for ( i = 0; i < nPathCount; i++ )
__QGLTABLENAME.m_pfn_qglVertex3fv( path[i] );
__QGLTABLENAME.m_pfn_qglEnd();
}
// -mars
__QGLTABLENAME.m_pfn_qglPopAttrib();
}
void DBobView::Register()
{
__QGLTABLENAME.m_pfnHookGL2DWindow( this );
__QGLTABLENAME.m_pfnHookGL3DWindow( this );
m_bHooked = TRUE;
}
void DBobView::UnRegister()
{
__QGLTABLENAME.m_pfnUnHookGL2DWindow( this );
__QGLTABLENAME.m_pfnUnHookGL3DWindow( this );
m_bHooked = FALSE;
}
void DBobView::SetPath(vec3_t *pPath)
{
if(path)
delete[] path;
path = pPath;
}
#define LOCAL_GRAVITY -800.0f
bool DBobView::CalculateTrajectory(vec3_t start, vec3_t apex, float multiplier, int points, float varGravity)
{
if(apex[2] <= start[2])
{
SetPath(NULL);
return FALSE;
}
// ----think q3a actually would allow these
//scrub that, coz the plugin wont :]
vec3_t dist, speed;
VectorSubtract(apex, start, dist);
vec_t speed_z = (float)sqrt(-2*LOCAL_GRAVITY*dist[2]);
float flight_time = -speed_z/LOCAL_GRAVITY;
VectorScale(dist, 1/flight_time, speed);
speed[2] = speed_z;
// Sys_Printf("Speed: (%.4f %.4f %.4f)\n", speed[0], speed[1], speed[2]);
vec3_t* pPath = new vec3_t[points];
float interval = multiplier*flight_time/points;
for(int i = 0; i < points; i++)
{
float ltime = interval*i;
VectorScale(speed, ltime, pPath[i]);
VectorAdd(pPath[i], start, pPath[i]);
// could do this all with vectors
// vGrav = {0, 0, -800.0f}
// VectorScale(vGrav, 0.5f*ltime*ltime, vAdd);
// VectorScale(speed, ltime, pPath[i]);
// _VectorAdd(pPath[i], start, pPath[i])
// _VectorAdd(pPath[i], vAdd, pPath[i])
pPath[i][2] = start[2] + (speed_z*ltime) + (varGravity*0.5f*ltime*ltime);
}
SetPath(pPath);
return TRUE;
}
void DBobView::Begin(const char* trigger, const char *target, float multiplier, int points, float varGravity, bool bNoUpdate, bool bShowExtra)
{
strcpy(entTrigger, trigger);
strcpy(entTarget, target);
fMultiplier = multiplier;
fVarGravity = varGravity;
nPathCount = points;
m_bShowExtra = bShowExtra;
Register();
if(UpdatePath())
{
if(!bNoUpdate)
{
eyes = new DListener;
eyes->parent = this;
eyes->Register();
}
}
else
{
Sys_ERROR("Initialization Failure in DBobView::Begin");
delete this;
}
}
bool DBobView::UpdatePath()
{
vec3_t start, apex;
if(GetEntityCentre(entTrigger, start))
{
if(GetEntityCentre(entTarget, apex))
{
CalculateTrajectory(start, apex, fMultiplier, nPathCount, fVarGravity);
return TRUE;
}
}
return FALSE;
}

View File

@@ -0,0 +1,72 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DBobView.h: interface for the DBobView class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_
class DListener;
#define BOUNDS_ALL 0
#define BOUNDS_APEX 1
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class DBobView :
public IGL2DWindow,
public IGL3DWindow
{
public:
DBobView();
virtual ~DBobView();
protected:
vec3_t* path;
int refCount;
public:
bool m_bShowExtra;
int boundingShow;
DListener* eyes;
float fVarGravity;
bool UpdatePath();
char entTarget[256];
char entTrigger[256];
void Begin(const char*, const char*, float, int, float, bool, bool);
bool CalculateTrajectory(vec3_t, vec3_t, float, int, float);
void SetPath(vec3_t* pPath);
void UnRegister();
void Register();
void Draw3D();
void Draw2D(VIEWTYPE vt);
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
float fMultiplier;
bool m_bHooked;
int nPathCount;
};
#endif // !defined(AFX_BOBVIEW_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)

867
contrib/bobtoolz/DBrush.cpp Normal file
View File

@@ -0,0 +1,867 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DBrush.cpp: implementation of the DBrush class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#ifdef WIN32
#pragma warning(disable : 4786)
#endif
#include "StdAfx.h"
#include "gtkr_list.h"
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#include "DEPair.h"
#include "DPatch.h"
#include "DEntity.h"
#include "DWinding.h"
#include "dialogs-gtk.h"
#include "misc.h"
#include "iundo.h"
#include "refcounted_ptr.h"
#include "scenelib.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DBrush::DBrush(int ID)
{
m_nBrushID = ID;
bBoundsBuilt = FALSE;
QER_brush = NULL;
}
DBrush::~DBrush()
{
ClearFaces();
ClearPoints();
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
DPlane* DBrush::AddFace(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData)
{
#ifdef _DEBUG
// Sys_Printf("(%f %f %f) (%f %f %f) (%f %f %f)\n", va[0], va[1], va[2], vb[0], vb[1], vb[2], vc[0], vc[1], vc[2]);
#endif
bBoundsBuilt = FALSE;
DPlane* newFace = new DPlane(va, vb, vc, texData);
faceList.push_back(newFace);
return newFace;
}
int DBrush::BuildPoints()
{
ClearPoints();
if(faceList.size() <= 3) // if less than 3 faces, there can be no points
return 0; // with only 3 faces u can't have a bounded soild
for(list<DPlane *>::const_iterator p1=faceList.begin(); p1!=faceList.end(); p1++)
{
list<DPlane *>::const_iterator p2=p1;
for(p2++; p2!=faceList.end(); p2++)
{
list<DPlane *>::const_iterator p3=p2;
for(p3++; p3!=faceList.end(); p3++)
{
vec3_t pnt;
if((*p1)->PlaneIntersection(*p2, *p3, pnt))
{
int pos = PointPosition(pnt);
if(pos == POINT_IN_BRUSH)
{ // ???? shouldn't happen here
Sys_Printf("ERROR:: Build Brush Points: Point IN brush!!!\n");
}
else if(pos == POINT_ON_BRUSH)
{ // normal point
if(!HasPoint(pnt))
AddPoint(pnt);
/* else
Sys_Printf("Duplicate Point Found, pyramids ahoy!!!!!\n");*/
// point lies on more that 3 planes
}
// otherwise point is removed due to another plane..
// Sys_Printf("(%f, %f, %f)\n", pnt[0], pnt[1], pnt[2]);
}
}
}
}
#ifdef _DEBUG
// Sys_Printf("%i points on brush\n", pointList.size());
#endif
return pointList.size();
}
void DBrush::LoadFromBrush(scene::Node* brush, bool textured)
{
ClearFaces();
ClearPoints();
#if 0
for(int i = g_FuncTable.m_pfnGetFaceCount(brush)-1; i >= 0 ; i--)
{ // running backwards so i dont have to use the count function each time (OPT)
_QERFaceData* faceData = g_FuncTable.m_pfnGetFaceData(brush, i);
if(faceData == NULL)
DoMessageBox("Null pointer returned", "WARNING!", MB_OK);
if(textured)
AddFace(faceData->m_v1, faceData->m_v2, faceData->m_v3, faceData);
else
AddFace(faceData->m_v1, faceData->m_v2, faceData->m_v3, NULL);
}
#endif
QER_brush = brush;
}
int DBrush::PointPosition(vec3_t pnt)
{
int state = POINT_IN_BRUSH; // if nothing happens point is inside brush
for(list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
{
float dist = (*chkPlane)->DistanceToPoint(pnt);
if(dist > MAX_ROUND_ERROR)
return POINT_OUT_BRUSH; // if point is in front of plane, it CANT be in the brush
else if(fabs(dist) < MAX_ROUND_ERROR)
state = POINT_ON_BRUSH; // if point is ON plane point is either ON the brush
// or outside it, it can no longer be in it
}
return state;
}
void DBrush::ClearPoints()
{
for(list<DPoint *>::const_iterator deadPoint=pointList.begin(); deadPoint!=pointList.end(); deadPoint++) {
delete *deadPoint;
}
pointList.clear();
}
void DBrush::ClearFaces()
{
bBoundsBuilt = FALSE;
for(list<DPlane *>::const_iterator deadPlane=faceList.begin(); deadPlane!=faceList.end(); deadPlane++)
{
delete *deadPlane;
}
faceList.clear();
}
void DBrush::AddPoint(vec3_t pnt)
{
DPoint* newPoint = new DPoint;
VectorCopy(pnt, newPoint->_pnt);
pointList.push_back(newPoint);
}
bool DBrush::HasPoint(vec3_t pnt)
{
for(list<DPoint *>::const_iterator chkPoint=pointList.begin(); chkPoint!=pointList.end(); chkPoint++)
{
if(**chkPoint == pnt)
return TRUE;
}
return FALSE;
}
int DBrush::RemoveRedundantPlanes()
{
int cnt = 0;
list<DPlane *>::iterator chkPlane;
// find duplicate planes
list<DPlane *>::iterator p1=faceList.begin();
while( p1!=faceList.end() )
{
list<DPlane *>::iterator p2 = p1;
for(p2++; p2!=faceList.end(); p2++)
{
if(**p1 == **p2)
{
if(!strcmp((*p1)->texInfo.m_texdef.GetName(), "textures/common/caulk"))
{
delete *p1;
p1 = faceList.erase(p1); // duplicate plane
}
else
{
delete *p2;
p2 = faceList.erase(p2); // duplicate plane
}
cnt++;
break;
}
}
if( p2 == faceList.end() )
p1++;
}
//+djbob kill planes with bad normal, they are more of a nuisance than losing a brush
chkPlane=faceList.begin();
while( chkPlane!=faceList.end() )
{
if(VectorLength((*chkPlane)->normal) == 0) // plane has bad normal
{
delete *chkPlane;
chkPlane = faceList.erase(chkPlane);
cnt++;
} else {
chkPlane++;
}
}
//-djbob
if(pointList.size() == 0) // if points may not have been built, build them
/* if(BuildPoints() == 0) // just let the planes die if they are all bad
return cnt;*/
BuildPoints();
chkPlane=faceList.begin();
while(chkPlane != faceList.end())
{
if((*chkPlane)->IsRedundant(pointList)) // checks that plane "0wnz" :), 3 or more points
{
delete *chkPlane;
chkPlane = faceList.erase(chkPlane);
cnt++;
}
else
chkPlane++;
}
return cnt;
}
bool DBrush::GetBounds(vec3_t min, vec3_t max)
{
BuildBounds();
if(!bBoundsBuilt)
return FALSE;
VectorCopy(bbox_min, min);
VectorCopy(bbox_max, max);
return TRUE;
}
bool DBrush::BBoxCollision(DBrush* chkBrush)
{
vec3_t min1, min2;
vec3_t max1, max2;
GetBounds(min1, max1);
chkBrush->GetBounds(min2, max2);
if(min1[0] >= max2[0])
return FALSE;
if(min1[1] >= max2[1])
return FALSE;
if(min1[2] >= max2[2])
return FALSE;
if(max1[0] <= min2[0])
return FALSE;
if(max1[1] <= min2[1])
return FALSE;
if(max1[2] <= min2[2])
return FALSE;
return TRUE;
}
DPlane* DBrush::HasPlane(DPlane* chkPlane)
{
for(list<DPlane *>::const_iterator brushPlane=faceList.begin(); brushPlane!=faceList.end(); brushPlane++)
{
if(**brushPlane == *chkPlane)
return *brushPlane;
}
return NULL;
}
bool DBrush::IsCutByPlane(DPlane *cuttingPlane)
{
bool isInFront;
if(pointList.size() == 0)
if(BuildPoints() == 0)
return FALSE;
list<DPoint *>::const_iterator chkPnt = pointList.begin();
if(chkPnt == pointList.end())
return FALSE;
float dist = cuttingPlane->DistanceToPoint((*chkPnt)->_pnt);
if(dist > MAX_ROUND_ERROR)
isInFront = FALSE;
else if(dist < MAX_ROUND_ERROR)
isInFront = TRUE;
else
return TRUE;
for(chkPnt++=pointList.begin(); chkPnt!=pointList.end(); chkPnt++)
{
dist = cuttingPlane->DistanceToPoint((*chkPnt)->_pnt);
if(dist > MAX_ROUND_ERROR)
{
if(isInFront)
return TRUE;
}
else if(dist < MAX_ROUND_ERROR)
{
if(!isInFront)
return TRUE;
}
else
return TRUE;
}
return FALSE;
}
scene::Node* DBrush::BuildInRadiant(bool allowDestruction, int* changeCnt, scene::Node* entity)
{
if(allowDestruction)
{
bool kill = TRUE;
for(list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
{
if((*chkPlane)->m_bChkOk)
{
kill = FALSE;
break;
}
}
if(kill)
return NULL;
}
//+djbob: fixed bug when brush had no faces "phantom brush" in radiant.
if(faceList.size() < 4)
{
Sys_Printf("Possible Phantom Brush Found, will not rebuild\n");
return NULL;
}
//-djbob
NodePtr node(Brush_AllocNode());
for(list<DPlane *>::const_iterator buildPlane=faceList.begin(); buildPlane!=faceList.end(); buildPlane++) {
if((*buildPlane)->AddToBrush(node->m_brush) && changeCnt) {
(*changeCnt)++;
}
}
if(entity) {
entity->m_traverse->insert(node);
} else {
GetWorldspawn()->m_traverse->insert(node);
}
return node;
}
void DBrush::CutByPlane(DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush2)
{
if(!IsCutByPlane(cutPlane))
{
*newBrush1 = NULL;
*newBrush2 = NULL;
return;
}
DBrush* b1 = new DBrush;
DBrush* b2 = new DBrush;
for(list<DPlane *>::const_iterator parsePlane=faceList.begin(); parsePlane!=faceList.end(); parsePlane++)
{
b1->AddFace((*parsePlane)->points[0], (*parsePlane)->points[1], (*parsePlane)->points[2], NULL);
b2->AddFace((*parsePlane)->points[0], (*parsePlane)->points[1], (*parsePlane)->points[2], NULL);
}
b1->AddFace(cutPlane->points[0], cutPlane->points[1], cutPlane->points[2], NULL);
b2->AddFace(cutPlane->points[2], cutPlane->points[1], cutPlane->points[0], NULL);
b1->RemoveRedundantPlanes();
b2->RemoveRedundantPlanes();
*newBrush1 = b1;
*newBrush2 = b2;
}
bool DBrush::IntersectsWith(DBrush *chkBrush)
{
if(pointList.size() == 0)
if(BuildPoints() == 0)
return FALSE; // invalid brush!!!!
if(chkBrush->pointList.size() == 0)
if(chkBrush->BuildPoints() == 0)
return FALSE; // invalid brush!!!!
if(!BBoxCollision(chkBrush))
return FALSE;
list<DPlane *>::const_iterator iplPlane;
for( iplPlane=faceList.begin(); iplPlane!=faceList.end(); iplPlane++)
{
bool allInFront = TRUE;
for(list<DPoint *>::const_iterator iPoint=chkBrush->pointList.begin(); iPoint!=chkBrush->pointList.end(); iPoint++)
{
if((*iplPlane)->DistanceToPoint((*iPoint)->_pnt) < -MAX_ROUND_ERROR)
{
allInFront = FALSE;
break;
}
}
if(allInFront)
return FALSE;
}
for( iplPlane=chkBrush->faceList.begin(); iplPlane!=chkBrush->faceList.end(); iplPlane++)
{
bool allInFront = TRUE;
for(list<DPoint *>::const_iterator iPoint=pointList.begin(); iPoint!=pointList.end(); iPoint++)
{
if((*iplPlane)->DistanceToPoint((*iPoint)->_pnt) < -MAX_ROUND_ERROR)
{
allInFront = FALSE;
break;
}
}
if(allInFront)
return FALSE;
}
return TRUE;
}
bool DBrush::IntersectsWith(DPlane* p1, DPlane* p2, vec3_t v) {
vec3_t vDown = { 0, 0, -1 };
list<DPlane *>::const_iterator iplPlane;
for( iplPlane = faceList.begin(); iplPlane != faceList.end(); iplPlane++) {
DPlane* p = (*iplPlane);
vec_t d = DotProduct( p->normal, vDown );
if( d >= 0 ) {
continue;
}
if(p->PlaneIntersection(p1, p2, v)) {
if(PointPosition( v ) != POINT_OUT_BRUSH) {
return TRUE;
}
}
}
return FALSE;
}
void DBrush::BuildBounds()
{
if(!bBoundsBuilt)
{
if(pointList.size() == 0) // if points may not have been built, build them
if(BuildPoints() == 0)
return;
list<DPoint *>::const_iterator first = pointList.begin();
VectorCopy((*first)->_pnt, bbox_min);
VectorCopy((*first)->_pnt, bbox_max);
list<DPoint *>::const_iterator point=pointList.begin();
for( point++; point!=pointList.end(); point++)
{
if((*point)->_pnt[0] > bbox_max[0])
bbox_max[0] = (*point)->_pnt[0];
if((*point)->_pnt[1] > bbox_max[1])
bbox_max[1] = (*point)->_pnt[1];
if((*point)->_pnt[2] > bbox_max[2])
bbox_max[2] = (*point)->_pnt[2];
if((*point)->_pnt[0] < bbox_min[0])
bbox_min[0] = (*point)->_pnt[0];
if((*point)->_pnt[1] < bbox_min[1])
bbox_min[1] = (*point)->_pnt[1];
if((*point)->_pnt[2] < bbox_min[2])
bbox_min[2] = (*point)->_pnt[2];
}
bBoundsBuilt = TRUE;
}
}
bool DBrush::BBoxTouch(DBrush *chkBrush)
{
vec3_t min1, min2;
vec3_t max1, max2;
GetBounds(min1, max1);
chkBrush->GetBounds(min2, max2);
if((min1[0] - max2[0]) > MAX_ROUND_ERROR)
return FALSE;
if((min1[1] - max2[1]) > MAX_ROUND_ERROR)
return FALSE;
if((min1[2] - max2[2]) > MAX_ROUND_ERROR)
return FALSE;
if((min2[0] - max1[0]) > MAX_ROUND_ERROR)
return FALSE;
if((min2[1] - max1[1]) > MAX_ROUND_ERROR)
return FALSE;
if((min2[2] - max1[2]) > MAX_ROUND_ERROR)
return FALSE;
int cnt = 0;
if((min2[0] - max1[0]) == 0)
cnt++;
if((min2[1] - max1[1]) == 0)
cnt++;
if((min2[2] - max1[2]) == 0)
cnt++;
if((min1[0] - max2[0]) == 0)
cnt++;
if((min1[1] - max2[1]) == 0)
cnt++;
if((min1[2] - max2[2]) == 0)
cnt++;
if(cnt > 1)
return FALSE;
return TRUE;
}
void DBrush::ResetChecks(list<Str>* exclusionList)
{
for(list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
{
bool set = FALSE;
if(exclusionList)
{
for(list<Str>::iterator eTexture = exclusionList->begin(); eTexture != exclusionList->end(); eTexture++)
{
if(strstr((*resetPlane)->texInfo.m_texdef.GetName(), eTexture->GetBuffer()))
{
set = TRUE;
break;
}
}
}
(*resetPlane)->m_bChkOk = set;
}
}
DPlane* DBrush::HasPlaneInverted(DPlane *chkPlane)
{
for(list<DPlane *>::const_iterator brushPlane=faceList.begin(); brushPlane!=faceList.end(); brushPlane++)
{
if(**brushPlane != *chkPlane)
{
if(fabs((*brushPlane)->_d + chkPlane->_d) < 0.1)
return (*brushPlane);
}
}
return NULL;
}
bool DBrush::HasTexture(const char *textureName)
{
for(list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
{
if(strstr((*chkPlane)->texInfo.m_texdef.GetName(), textureName))
return TRUE;
}
return FALSE;
}
bool DBrush::IsDetail()
{
for(list<DPlane *>::const_iterator chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
{
if((*chkPlane)->texInfo.m_texdef.contents & FACE_DETAIL)
return TRUE;
}
return FALSE;
}
void DBrush::BuildFromWinding(DWinding *w)
{
if(w->numpoints < 3)
{
Sys_ERROR("Winding has invalid number of points");
return;
}
DPlane* wPlane = w->WindingPlane();
DWinding* w2;
w2 = w->CopyWinding();
int i;
for(i = 0; i < w2->numpoints; i++)
VectorAdd(w2->p[i], wPlane->normal, w2->p[i]);
AddFace(w2->p[0], w2->p[1], w2->p[2], NULL);
AddFace(w->p[2], w->p[1], w->p[0], NULL);
for(i = 0; i < w->numpoints-1; i++)
AddFace(w2->p[i], w->p[i], w->p[i+1], NULL);
AddFace(w2->p[w->numpoints-1], w->p[w->numpoints-1], w->p[0], NULL);
delete wPlane;
delete w2;
}
void DBrush::SaveToFile(FILE *pFile)
{
fprintf(pFile, "{\n");
for(list<DPlane *>::const_iterator pp=faceList.begin(); pp!=faceList.end(); pp++)
{
char buffer[512];
sprintf(buffer, "( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) %s %.0f %.0f %f %f %.0f 0 0 0\n",
(*pp)->points[0][0], (*pp)->points[0][1], (*pp)->points[0][2],
(*pp)->points[1][0], (*pp)->points[1][1], (*pp)->points[1][2],
(*pp)->points[2][0], (*pp)->points[2][1], (*pp)->points[2][2],
(*pp)->texInfo.m_texdef.GetName(),
(*pp)->texInfo.m_texdef.shift[0], (*pp)->texInfo.m_texdef.shift[1],
(*pp)->texInfo.m_texdef.scale[0], (*pp)->texInfo.m_texdef.scale[0],
(*pp)->texInfo.m_texdef.rotate);
fprintf(pFile, buffer);
}
fprintf(pFile, "}\n");
}
void DBrush::Rotate(vec3_t vOrigin, vec3_t vRotation)
{
for(list<DPlane *>::const_iterator rotPlane=faceList.begin(); rotPlane!=faceList.end(); rotPlane++)
{
for(int i = 0; i < 3; i++)
VectorRotate((*rotPlane)->points[i], vRotation, vOrigin);
(*rotPlane)->Rebuild();
}
}
void DBrush::RotateAboutCentre(vec3_t vRotation)
{
vec3_t min, max, centre;
GetBounds(min, max);
VectorAdd(min, max, centre);
VectorScale(centre, 0.5f, centre);
Rotate(centre, vRotation);
}
bool DBrush::ResetTextures(const char* textureName, float fScale[2], float fShift[2], int rotation, const char* newTextureName,
int bResetTextureName, int bResetScale[2], int bResetShift[2], int bResetRotation)
{
if(textureName)
{
bool changed = FALSE;
for(list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
{
if(!strcmp((*resetPlane)->texInfo.m_texdef.GetName(), textureName))
{
if(bResetTextureName)
(*resetPlane)->texInfo.m_texdef.SetName(newTextureName);
if(bResetScale[0])
(*resetPlane)->texInfo.m_texdef.scale[0] = fScale[0];
if(bResetScale[1])
(*resetPlane)->texInfo.m_texdef.scale[1] = fScale[1];
if(bResetShift[0])
(*resetPlane)->texInfo.m_texdef.shift[0] = fShift[0];
if(bResetShift[1])
(*resetPlane)->texInfo.m_texdef.shift[1] = fShift[1];
if(bResetRotation)
(*resetPlane)->texInfo.m_texdef.rotate = (float)rotation;
changed = TRUE;
}
}
return changed; // no point rebuilding unless we need to, only slows things down
}
else
{
for(list<DPlane *>::const_iterator resetPlane=faceList.begin(); resetPlane!=faceList.end(); resetPlane++)
{
if(bResetTextureName)
(*resetPlane)->texInfo.m_texdef.SetName(newTextureName);
if(bResetScale[0])
(*resetPlane)->texInfo.m_texdef.scale[0] = fScale[0];
if(bResetScale[1])
(*resetPlane)->texInfo.m_texdef.scale[1] = fScale[1];
if(bResetShift[0])
(*resetPlane)->texInfo.m_texdef.shift[0] = fShift[0];
if(bResetShift[1])
(*resetPlane)->texInfo.m_texdef.shift[1] = fShift[1];
if(bResetRotation)
(*resetPlane)->texInfo.m_texdef.rotate = (float)rotation;
}
return TRUE;
}
}
bool DBrush::operator ==(DBrush* other)
{
list<DPlane *>::const_iterator chkPlane;
for(chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
{
if(!other->HasPlane((*chkPlane)))
return FALSE;
}
for(chkPlane=faceList.begin(); chkPlane!=faceList.end(); chkPlane++)
{
if(!HasPlane((*chkPlane)))
return FALSE;
}
return TRUE;
}
DPlane* DBrush::AddFace(vec3_t va, vec3_t vb, vec3_t vc, const char *textureName, bool bDetail)
{
bBoundsBuilt = FALSE;
DPlane* newFace = new DPlane(va, vb, vc, textureName, bDetail);
faceList.push_back(newFace);
return newFace;
}
DPlane* DBrush::FindPlaneWithClosestNormal( vec_t* normal ) {
vec_t bestDot = -2;
DPlane* bestDotPlane = NULL;
list<DPlane *>::const_iterator chkPlane;
for( chkPlane = faceList.begin(); chkPlane != faceList.end(); chkPlane++ ) {
DPlane* pPlane = (*chkPlane);
vec_t dot = DotProduct( pPlane->normal, normal );
if( dot > bestDot ) {
bestDot = dot;
bestDotPlane = pPlane;
}
}
return bestDotPlane;
}
int DBrush::FindPointsForPlane( DPlane* plane, DPoint** pnts, int maxpnts ) {
int numpnts = 0;
if(!maxpnts) {
return 0;
}
BuildPoints();
for( list<DPoint *>::const_iterator points = pointList.begin(); points != pointList.end(); points++ ) {
DPoint* point = (*points);
if( fabs(plane->DistanceToPoint( point->_pnt )) < MAX_ROUND_ERROR ) {
pnts[numpnts] = point;
numpnts++;
if(numpnts >= maxpnts) {
return numpnts;
}
}
}
return numpnts;
}
void DBrush::RemovePlane( DPlane* plane ) {
bBoundsBuilt = FALSE;
for( list<DPlane *>::const_iterator deadPlane = faceList.begin(); deadPlane != faceList.end(); deadPlane++ ) {
if(*deadPlane == plane) {
delete *deadPlane;
faceList.remove( plane );
}
}
}
void DBrush::RemoveFromRadiant( void ) {
if(QER_brush) {
#if 0
g_FuncTable.m_pfnDeleteBrushHandle(QER_brush);
#endif
}
}

99
contrib/bobtoolz/DBrush.h Normal file
View File

@@ -0,0 +1,99 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DBrush.h: interface for the DBrush class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DBRUSH_H__35B2C522_F0A7_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_DBRUSH_H__35B2C522_F0A7_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define POINT_IN_BRUSH 0
#define POINT_ON_BRUSH 1
#define POINT_OUT_BRUSH 2
class DBrush
{
public:
DPlane* AddFace(vec3_t va, vec3_t vb, vec3_t vc, const char* textureName, bool bDetail);
void SaveToFile(FILE* pFile);
void Rotate(vec3_t vOrigin, vec3_t vRotation);
void RotateAboutCentre(vec3_t vRotation);
DPlane* HasPlaneInverted(DPlane* chkPlane);
DPlane* HasPlane(DPlane* chkPlane);
DPlane* AddFace(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData);
bool ResetTextures(const char* textureName, float fScale[2], float fShift[2], int rotation, const char* newTextureName, int bResetTextureName, int bResetScale[2], int bResetShift[2], int bResetRotation);
bool IsDetail();
bool HasTexture(const char* textureName);
bool IntersectsWith(DBrush *chkBrush);
bool IntersectsWith(DPlane* p1, DPlane* p2, vec3_t v);
bool IsCutByPlane(DPlane* cuttingPlane);
bool GetBounds(vec3_t min, vec3_t max);
bool HasPoint(vec3_t pnt);
bool BBoxCollision(DBrush* chkBrush);
bool BBoxTouch(DBrush* chkBrush);
int BuildPoints();
void BuildBounds();
void BuildFromWinding(DWinding* w);
scene::Node* BuildInRadiant(bool allowDestruction, int* changeCnt, scene::Node* entity = NULL);
void ResetChecks(list<Str>* exclusionList);
void ClearFaces();
void ClearPoints();
int RemoveRedundantPlanes( void );
void RemovePlane( DPlane* plane );
int PointPosition(vec3_t pnt);
void RemoveFromRadiant( void );
void CutByPlane(DPlane* cutPlane, DBrush** newBrush1, DBrush** newBrush2);
void LoadFromBrush(scene::Node* brush, bool textured);
void AddPoint(vec3_t pnt);
DPlane* FindPlaneWithClosestNormal( vec_t* normal );
int FindPointsForPlane( DPlane* plane, DPoint** pnts, int maxpnts );
DBrush(int ID = -1);
virtual ~DBrush();
bool operator== (DBrush* other);
// members
scene::Node* QER_brush;
list<DPlane*> faceList;
list<DPoint*> pointList;
int m_nBrushID;
vec3_t bbox_min, bbox_max;
bool bBoundsBuilt;
};
//typedef CList<DBrush*, DBrush*> DBrushList;
#endif // !defined(AFX_DBRUSH_H__35B2C522_F0A7_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,50 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DEPair.cpp: implementation of the DEPair class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "str.h"
#include "DEPair.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DEPair::DEPair()
{
}
DEPair::~DEPair()
{
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
void DEPair::Build(const char *pKey, const char *pValue)
{
key = pKey;
value = pValue;
}

45
contrib/bobtoolz/DEPair.h Normal file
View File

@@ -0,0 +1,45 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DEPair.h: interface for the DEPair class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DEPAIR_H__35B2C521_F0A7_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_DEPAIR_H__35B2C521_F0A7_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class DEPair
{
public:
DEPair();
virtual ~DEPair();
void Build(const char* pKey, const char* pValue);
Str key;
Str value;
};
//typedef CList<DEPair*, DEPair*> DEPairList;
#endif // !defined(AFX_DEPAIR_H__35B2C521_F0A7_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,667 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DEntity.cpp: implementation of the DEntity class.
//
//////////////////////////////////////////////////////////////////////
#ifdef WIN32
#pragma warning(disable : 4786)
#endif
#include "StdAfx.h"
#include "gtkr_list.h"
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#include "DEPair.h"
#include "DPatch.h"
#include "DEntity.h"
#include "dialogs-gtk.h"
#include "misc.h"
#include "CPortals.h"
#include "iundo.h"
#include "refcounted_ptr.h"
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include "scenelib.h"
const char* brushEntityList[] = {
"worldspawn",
"trigger_always",
"trigger_hurt",
"trigger_multiple",
"trigger_push",
"trigger_teleport",
"func_bobbing",
"func_button",
"func_door",
"func_group",
"func_pendulum",
"func_plat",
"func_rotating",
"func_static",
"func_timer",
"func_train",
0
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DEntity::DEntity(const char *classname, int ID)
{
SetClassname(classname);
m_nID = ID;
QER_Entity = NULL;
}
DEntity::~DEntity()
{
ClearPatches();
ClearBrushes();
ClearEPairs();
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
void DEntity::ClearBrushes()
{
for(list<DBrush *>::const_iterator deadBrush=brushList.begin(); deadBrush!=brushList.end(); deadBrush++)
{
delete *deadBrush;
}
brushList.clear();
}
void DEntity::ClearPatches()
{
for(list<DPatch *>::const_iterator deadPatch=patchList.begin(); deadPatch!=patchList.end(); deadPatch++)
{
delete *deadPatch;
}
patchList.clear();
}
DPatch* DEntity::NewPatch()
{
DPatch* newPatch = new DPatch;
patchList.push_back(newPatch);
return newPatch;
}
DBrush* DEntity::NewBrush(int ID)
{
DBrush* newBrush = new DBrush(ID);
brushList.push_back(newBrush);
return newBrush;
}
char* getNextBracket(char* s)
{
char* p = s;
while(*p)
{
p++;
if(*p == '(')
break;
}
return p;
}
bool DEntity::LoadFromPrt(char *filename)
{
CPortals portals;
strcpy(portals.fn, filename);
portals.Load();
if(portals.node_count == 0)
return FALSE;
ClearBrushes();
ClearEPairs();
bool build = false;
for(unsigned int i = 0; i < portals.node_count; i++)
{
build = false;
DBrush* brush = NewBrush();
for(unsigned int j = 0; j < portals.node[i].portal_count; j++)
{
for(unsigned int k = 0; k < portals.node[i].portal[j].point_count-2; k++)
{
vec3_t v1, v2, normal, n;
VectorSubtract(portals.node[i].portal[j].point[k+2].p, portals.node[i].portal[j].point[k+1].p, v1);
VectorSubtract(portals.node[i].portal[j].point[k].p, portals.node[i].portal[j].point[k+1].p, v2);
CrossProduct(v1, v2, n);
VectorNormalize(n, v2);
if(k == 0)
{
VectorCopy(v2, normal);
}
else
{
VectorSubtract(v2, normal, v1);
if(VectorLength(v1) > 0.01)
{
build = true;
break;
}
}
}
if(!build)
brush->AddFace(portals.node[i].portal[j].point[2].p, portals.node[i].portal[j].point[1].p, portals.node[i].portal[j].point[0].p, "textures/common/caulk", FALSE);
else
brush->AddFace(portals.node[i].portal[j].point[0].p, portals.node[i].portal[j].point[1].p, portals.node[i].portal[j].point[2].p, "textures/common/caulk", FALSE);
}
if(build)
brush->BuildInRadiant(FALSE, NULL);
}
return TRUE;
}
DPlane* DEntity::AddFaceToBrush(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* faceData, int ID)
{
DBrush* buildBrush = GetBrushForID(ID);
return buildBrush->AddFace(va, vb, vc, faceData);
// slow, dont use much
}
DBrush* DEntity::GetBrushForID(int ID)
{
DBrush* buildBrush = NULL;
for(list<DBrush *>::const_iterator chkBrush=brushList.begin(); chkBrush!=brushList.end(); chkBrush++)
{
if((*chkBrush)->m_nBrushID == ID)
{
buildBrush = (*chkBrush);
break;
}
}
if(!buildBrush)
buildBrush = NewBrush(ID);
return buildBrush;
}
void DEntity::LoadSelectedBrushes()
{
ClearBrushes();
ClearEPairs();
#if 0
int count = g_FuncTable.m_pfnAllocateSelectedBrushHandles();
for(int i = 0; i < count; i++) {
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle(i);
if(brush->patchBrush)
continue;
DBrush* loadBrush = NewBrush(i);
loadBrush->LoadFromBrush_t(brush, TRUE);
}
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
#endif
}
void DEntity::LoadSelectedPatches()
{
ClearPatches();
ClearEPairs();
#if 0
int count = g_FuncTable.m_pfnAllocateSelectedPatchHandles();
for(int i = 0; i < count; i++)
{
//$ FIXME: m_pfnGetPatchHandle
patchMesh_t *pmesh = (patchMesh_t*)g_FuncTable.m_pfnGetPatchData(i);
DPatch* loadPatch = NewPatch();
loadPatch->LoadFromBrush_t(pmesh->pSymbiot);
}
g_FuncTable.m_pfnReleasePatchHandles();
#endif
}
bool* DEntity::BuildIntersectList()
{
int max = GetIDMax();
if(max == 0)
return NULL;
bool* pbIntList = new bool[max];
memset(pbIntList, 0, sizeof(bool)*(max));
for(list<DBrush *>::const_iterator pB1=brushList.begin(); pB1!=brushList.end(); pB1++)
{
list<DBrush *>::const_iterator pB2=pB1;
for(pB2++; pB2!=brushList.end(); pB2++)
{
if((*pB1)->IntersectsWith((*pB2)))
{
pbIntList[(*pB1)->m_nBrushID] = TRUE;
pbIntList[(*pB2)->m_nBrushID] = TRUE;
}
}
}
return pbIntList;
}
bool* DEntity::BuildDuplicateList()
{
int max = GetIDMax();
if(max == 0)
return NULL;
bool* pbDupList = new bool[max];
memset(pbDupList, 0, sizeof(bool)*(max));
for(list<DBrush *>::const_iterator pB1=brushList.begin(); pB1!=brushList.end(); pB1++)
{
list<DBrush *>::const_iterator pB2=pB1;
for(pB2++; pB2!=brushList.end(); pB2++)
{
if(**pB1 == *pB2)
{
pbDupList[(*pB1)->m_nBrushID] = TRUE;
pbDupList[(*pB2)->m_nBrushID] = TRUE;
}
}
}
return pbDupList;
}
void DEntity::SelectBrushes(bool *selectList)
{
if(selectList == NULL)
return;
GlobalSelectionSystem().Select(false);
scene::Path path(GlobalSceneGraph().root());
path.push(QER_Entity);
for(std::list<DBrush *>::const_iterator pBrush=brushList.begin(); pBrush!=brushList.end(); pBrush++)
{
if(selectList[(*pBrush)->m_nBrushID])
{
path.push((*pBrush)->QER_brush);
GlobalSceneGraph().find(path)->selectable()->select(true);
path.pop();
}
}
}
bool DEntity::LoadFromEntity(scene::Node* ent, bool bLoadPatches) {
ClearPatches();
ClearBrushes();
ClearEPairs();
QER_Entity = ent;
LoadEPairList(ent->m_entity);
bool keep = FALSE;
int i;
for(i = 0; brushEntityList[i]; i++)
{
if(!stricmp(brushEntityList[i], m_Classname))
{
keep = TRUE;
break;
}
}
if(!keep)
return FALSE;
if(ent->m_traverse)
{
class load_brushes_t : public scene::Traversable::Walker
{
DEntity* m_entity;
int m_count;
public:
load_brushes_t(DEntity* entity)
: m_entity(entity), m_count(0)
{
}
bool pre(scene::Node* node)
{
if(node->m_brush)
{
DPatch* loadPatch = m_entity->NewPatch();
loadPatch->LoadFromBrush(node);
}
else if(node->m_patch)
{
DBrush* loadBrush = m_entity->NewBrush(m_count++);
loadBrush->LoadFromBrush(node, TRUE);
}
return false;
}
void post(scene::Node* node)
{
}
} load_brushes(this);
ent->m_traverse->traverse(load_brushes);
}
return TRUE;
}
void DEntity::RemoveNonCheckBrushes(list<Str>* exclusionList, bool useDetail)
{
list<DBrush *>::iterator chkBrush=brushList.begin();
while( chkBrush!=brushList.end() )
{
if(!useDetail)
{
if((*chkBrush)->IsDetail())
{
delete *chkBrush;
chkBrush = brushList.erase(chkBrush);
continue;
}
}
list<Str>::iterator eTexture;
for( eTexture=exclusionList->begin(); eTexture!=exclusionList->end(); eTexture++ )
{
if((*chkBrush)->HasTexture((*eTexture).GetBuffer()))
{
delete *chkBrush;
chkBrush = brushList.erase(chkBrush);
break;
}
}
if( eTexture == exclusionList->end() )
chkBrush++;
}
}
void DEntity::ResetChecks(list<Str>* exclusionList)
{
for(list<DBrush *>::const_iterator resetBrush=brushList.begin(); resetBrush!=brushList.end(); resetBrush++)
{
(*resetBrush)->ResetChecks(exclusionList);
}
}
int DEntity::FixBrushes()
{
int count = 0;
for(list<DBrush *>::const_iterator fixBrush=brushList.begin(); fixBrush!=brushList.end(); fixBrush++)
{
count += (*fixBrush)->RemoveRedundantPlanes();
}
return count;
}
void DEntity::BuildInRadiant(bool allowDestruction)
{
bool makeEntity = strcmp(m_Classname, "worldspawn") ? true : false;
if(makeEntity)
{
NodePtr node(GlobalEntityCreator().createEntity(m_Classname.GetBuffer()));
for(list<DEPair* >::const_iterator buildEPair=epairList.begin(); buildEPair!=epairList.end(); buildEPair++)
{
node->m_entity->setkeyvalue((*buildEPair)->key, (*buildEPair)->value);
}
GlobalSceneGraph().root()->m_traverse->insert(node);
for(list<DBrush *>::const_iterator buildBrush=brushList.begin(); buildBrush!=brushList.end(); buildBrush++)
(*buildBrush)->BuildInRadiant(allowDestruction, NULL, node);
for(list<DPatch *>::const_iterator buildPatch=patchList.begin(); buildPatch!=patchList.end(); buildPatch++)
(*buildPatch)->BuildInRadiant(node);
QER_Entity = node;
}
else
{
for(list<DBrush *>::const_iterator buildBrush=brushList.begin(); buildBrush!=brushList.end(); buildBrush++)
(*buildBrush)->BuildInRadiant(allowDestruction, NULL);
for(list<DPatch *>::const_iterator buildPatch=patchList.begin(); buildPatch!=patchList.end(); buildPatch++)
(*buildPatch)->BuildInRadiant();
}
}
int DEntity::GetIDMax( void ) {
int max = -1;
for(list<DBrush *>::const_iterator cntBrush=brushList.begin(); cntBrush!=brushList.end(); cntBrush++) {
if((*cntBrush)->m_nBrushID > max)
max = (*cntBrush)->m_nBrushID;
}
return max+1;
}
void DEntity::SetClassname( const char *classname ) {
m_Classname = classname;
}
void DEntity::SaveToFile(FILE *pFile)
{
fprintf(pFile, "{\n");
fprintf(pFile, "\"classname\" \"%s\"\n", (const char *)m_Classname);
for(list<DEPair *>::const_iterator ep=epairList.begin(); ep!=epairList.end(); ep++)
{
fprintf(pFile, "\"%s\" \"%s\"\n", (const char *)(*ep)->key, (const char *)(*ep)->value);
}
for(list<DBrush *>::const_iterator bp=brushList.begin(); bp!=brushList.end(); bp++)
{
(*bp)->SaveToFile(pFile);
}
fprintf(pFile, "}\n");
}
void DEntity::ClearEPairs()
{
for(list<DEPair *>::const_iterator deadEPair=epairList.begin(); deadEPair!=epairList.end(); deadEPair++)
{
delete (*deadEPair);
}
epairList.clear();
}
void DEntity::AddEPair(const char *key, const char *value) {
DEPair* newEPair;
newEPair = FindEPairByKey( key );
if(!newEPair) {
newEPair = new DEPair;
newEPair->Build(key, value);
epairList.push_back(newEPair);
} else {
newEPair->Build(key, value);
}
}
void DEntity::LoadEPairList(Entity *epl)
{
class load_epairs_t : public Entity::Visitor
{
DEntity* m_entity;
public:
load_epairs_t(DEntity* entity)
: m_entity(entity)
{
}
void visit(const char* key, const char* value)
{
if(strcmp(key, "classname") == 0)
m_entity->SetClassname(value);
else
m_entity->AddEPair(key, value);
}
} load_epairs(this);
epl->accept(load_epairs);
}
bool DEntity::ResetTextures(const char* textureName, float fScale[2], float fShift[2], int rotation, const char* newTextureName,
int bResetTextureName, int bResetScale[2], int bResetShift[2], int bResetRotation, bool rebuild)
{
bool reset = FALSE;
for(list<DBrush *>::const_iterator resetBrush=brushList.begin(); resetBrush!=brushList.end(); resetBrush++)
{
bool tmp = (*resetBrush)->ResetTextures(textureName, fScale, fShift, rotation, newTextureName,
bResetTextureName, bResetScale, bResetShift, bResetRotation);
if(tmp)
{
reset = TRUE;
}
}
if(bResetTextureName)
{
for(list<DPatch *>::const_iterator resetPatch=patchList.begin(); resetPatch!=patchList.end(); resetPatch++)
{
bool tmp = (*resetPatch)->ResetTextures(textureName, newTextureName);
if(tmp)
{
reset = TRUE;
}
}
}
return reset;
}
DEPair* DEntity::FindEPairByKey(const char* keyname)
{
for(list<DEPair *>::const_iterator ep=epairList.begin(); ep!=epairList.end(); ep++)
{
char* c = (*ep)->key;
if(!strcmp(c, keyname))
return *ep;
}
return NULL;
}
void DEntity::RemoveFromRadiant()
{
GlobalSceneGraph().root()->m_traverse->erase(QER_Entity);
QER_Entity = NULL;
}
void DEntity::SpawnString(const char* key, const char* defaultstring, const char** out)
{
DEPair* pEP = FindEPairByKey(key);
if(pEP) {
*out = pEP->value;
} else {
*out = defaultstring;
}
}
void DEntity::SpawnInt(const char* key, const char* defaultstring, int* out)
{
DEPair* pEP = FindEPairByKey(key);
if(pEP) {
*out = atoi(pEP->value);
} else {
*out = atoi(defaultstring);
}
}
void DEntity::SpawnFloat(const char* key, const char* defaultstring, float* out)
{
DEPair* pEP = FindEPairByKey(key);
if(pEP) {
*out = static_cast<float>(atof(pEP->value));
} else {
*out = static_cast<float>(atof(defaultstring));
}
}
void DEntity::SpawnVector(const char* key, const char* defaultstring, vec_t* out)
{
DEPair* pEP = FindEPairByKey(key);
if(pEP) {
sscanf(pEP->value, "%f %f %f", &out[0], &out[1], &out[2]);
} else {
sscanf(defaultstring, "%f %f %f", &out[0], &out[1], &out[2]);
}
}
int DEntity::GetBrushCount( void ) {
return brushList.size();
}
DBrush* DEntity::FindBrushByPointer( scene::Node* brush ) {
for(list<DBrush *>::const_iterator listBrush = brushList.begin(); listBrush != brushList.end(); listBrush++) {
DBrush* pBrush = (*listBrush);
if(pBrush->QER_brush == brush) {
return pBrush;
}
}
return NULL;
}

109
contrib/bobtoolz/DEntity.h Normal file
View File

@@ -0,0 +1,109 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DEntity.h: interface for the DEntity class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DENTITY_H__35B2C523_F0A7_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_DENTITY_H__35B2C523_F0A7_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class DEntity
{
public:
void RemoveFromRadiant();
scene::Node* QER_Entity;
int m_nID;
// Constrcution/Destruction
DEntity(const char* classname = "worldspawn", int ID = -1); // sets classname
virtual ~DEntity();
// ---------------------------------------------
// epair functions........
void LoadEPairList(Entity* epl);
void AddEPair(const char* key, const char* value);
void ClearEPairs();
DEPair* FindEPairByKey(const char* keyname);
// ---------------------------------------------
// random functions........
bool ResetTextures(const char* textureName, float fScale[2], float fShift[2], int rotation, const char* newTextureName, int bResetTextureName, int bResetScale[2], int bResetShift[2], int bResetRotation, bool rebuild);
void SaveToFile(FILE* pFile);
void SetClassname(const char* classname);
int GetIDMax();
void BuildInRadiant(bool allowDestruction);
void ResetChecks(list<Str>* exclusionList);
void RemoveNonCheckBrushes(list<Str>* exclusionList, bool useDetail);
DPlane* AddFaceToBrush(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* faceData, int ID); // slow, try not to use much
int GetBrushCount( void );
DBrush* FindBrushByPointer( scene::Node* brush );
// ---------------------------------------------
// bool list functions
void SelectBrushes(bool* selectList);
bool* BuildDuplicateList();
bool* BuildIntersectList();
// ---------------------------------------------
// brush operations
void ClearBrushes(); // clears brush list and frees memory for brushes
DBrush* GetBrushForID(int ID);
DBrush* NewBrush(int ID = -1);
// ---------------------------------------------
// patch operations
void ClearPatches();
DPatch* NewPatch();
// ---------------------------------------------
// vars
list<DEPair*> epairList;
list<DBrush*> brushList;
// new patches, wahey!!!
list<DPatch*> patchList;
Str m_Classname;
// ---------------------------------------------
int FixBrushes();
bool LoadFromEntity(scene::Node* ent, bool bLoadPatches = FALSE);
void LoadSelectedBrushes();
void LoadSelectedPatches();
bool LoadFromPrt(char* filename);
// ---------------------------------------------
void SpawnString(const char* key, const char* defaultstring, const char** out);
void SpawnInt(const char* key, const char* defaultstring, int* out);
void SpawnFloat(const char* key, const char* defaultstring, float* out);
void SpawnVector(const char* key, const char* defaultstring, vec_t* out);
};
#endif // !defined(AFX_DENTITY_H__35B2C523_F0A7_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,93 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DListener.cpp: implementation of the DListener class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "DListener.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DListener::DListener()
{
refCount = 1;
m_bHooked = FALSE;
}
DListener::~DListener()
{
UnRegister();
}
void DListener::Register()
{
g_MessageTable.m_pfnHookWindow( this );
m_bHooked = TRUE;
}
void DListener::UnRegister()
{
if(m_bHooked)
{
g_MessageTable.m_pfnUnHookWindow( this );
m_bHooked = FALSE;
}
}
bool DListener::OnMouseMove(unsigned int nFlags, double x, double y)
{
if(!parent->UpdatePath())
delete parent;
return FALSE;
}
bool DListener::OnLButtonDown(unsigned int nFlags, double x, double y)
{
return FALSE;
}
bool DListener::OnLButtonUp(unsigned int nFlags, double x, double y)
{
return FALSE;
}
bool DListener::OnRButtonDown(unsigned int nFlags, double x, double y)
{
return FALSE;
}
bool DListener::OnRButtonUp(unsigned int nFlags, double x, double y)
{
return FALSE;
}
bool DListener::OnMButtonDown(unsigned int nFlags, double x, double y)
{
return FALSE;
}
bool DListener::OnMButtonUp(unsigned int nFlags, double x, double y)
{
return FALSE;
}

View File

@@ -0,0 +1,62 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DListener.h: interface for the DListener class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DLISTENER_H__53EBE342_F0B2_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_DLISTENER_H__53EBE342_F0B2_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "DBobView.h"
class DListener : public IWindowListener
{
public:
DBobView* parent;
bool OnMouseMove(guint32 nFlags, gdouble x, gdouble y);
bool OnLButtonDown(guint32 nFlags, gdouble x, gdouble y);
bool OnMButtonDown(guint32 nFlags, gdouble x, gdouble y);
bool OnRButtonDown(guint32 nFlags, gdouble x, gdouble y);
bool OnLButtonUp(guint32 nFlags, gdouble x, gdouble y);
bool OnMButtonUp(guint32 nFlags, gdouble x, gdouble y);
bool OnRButtonUp(guint32 nFlags, gdouble x, gdouble y);
bool OnKeyPressed(char *s) { return false; }
bool Paint() { return true; }
void Close() { }
void UnRegister();
void Register();
DListener();
virtual ~DListener();
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
private:
bool m_bHooked;
int refCount;
};
#endif // !defined(AFX_DLISTENER_H__53EBE342_F0B2_11D4_ACF7_004095A18133__INCLUDED_)

182
contrib/bobtoolz/DMap.cpp Normal file
View File

@@ -0,0 +1,182 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DMap.cpp: implementation of the DMap class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "str.h"
#include "gtkr_list.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#include "DEPair.h"
#include "DPatch.h"
#include "DEntity.h"
#include "DMap.h"
#include "iundo.h"
#include "refcounted_ptr.h"
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include "scenelib.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DMap::DMap()
{
m_nNextEntity = 1;
AddEntity("worldspawn", 0);
}
DMap::~DMap()
{
ClearEntities();
}
DEntity* DMap::AddEntity(char *classname, int ID)
{
DEntity* newEntity;
if(ID == -1)
newEntity = new DEntity(classname, m_nNextEntity++);
else
newEntity = new DEntity(classname, ID);
entityList.push_back(newEntity);
return newEntity;
}
void DMap::ClearEntities()
{
m_nNextEntity = 1;
for(list<DEntity *>::const_iterator deadEntity=entityList.begin(); deadEntity!=entityList.end(); deadEntity++)
delete *deadEntity;
entityList.clear();
}
DEntity* DMap::GetEntityForID(int ID)
{
DEntity* findEntity = NULL;
for(list<DEntity *>::const_iterator chkEntity=entityList.begin(); chkEntity!=entityList.end(); chkEntity++)
{
if((*chkEntity)->m_nID == ID)
{
findEntity = (*chkEntity);
break;
}
}
if(!findEntity)
findEntity = AddEntity("worldspawn", ID);
return findEntity;
}
DEntity* DMap::GetWorldSpawn()
{
return GetEntityForID(0);
}
void DMap::BuildInRadiant(bool bAllowDestruction)
{
for(list<DEntity *>::const_iterator buildEntity=entityList.begin(); buildEntity!=entityList.end(); buildEntity++)
(*buildEntity)->BuildInRadiant(bAllowDestruction);
}
void DMap::LoadAll(bool bLoadPatches)
{
ClearEntities();
GlobalSelectionSystem().Select(false);
class load_entities_t : public scene::Traversable::Walker
{
DMap* m_map;
bool m_bLoadPatches;
public:
load_entities_t(DMap* map, bool bLoadPatches)
: m_map(map), m_bLoadPatches(bLoadPatches)
{
}
bool pre(scene::Node* node)
{
if(node->m_entity)
{
DEntity* loadEntity = m_map->AddEntity("", 0);
loadEntity->LoadFromEntity(node, m_bLoadPatches);
}
return false;
}
void post(scene::Node* node)
{
}
} load_entities(this, bLoadPatches);
GlobalSceneGraph().root()->m_traverse->traverse(load_entities);
}
int DMap::FixBrushes()
{
int count = 0;
for(list<DEntity *>::const_iterator fixEntity=entityList.begin(); fixEntity!=entityList.end(); fixEntity++)
{
count += (*fixEntity)->FixBrushes();
}
return count;
}
void DMap::ResetTextures( const char* textureName, float fScale[2], float fShift[2], int rotation, const char* newTextureName,
int bResetTextureName, int bResetScale[2], int bResetShift[2], int bResetRotation)
{
for(list<DEntity *>::const_iterator texEntity=entityList.begin(); texEntity!=entityList.end(); texEntity++)
{
if(!stricmp("worldspawn", (*texEntity)->m_Classname))
(*texEntity)->ResetTextures(textureName, fScale, fShift, rotation, newTextureName,
bResetTextureName, bResetScale, bResetShift, bResetRotation, TRUE);
else
{
if((*texEntity)->ResetTextures( textureName, fScale, fShift, rotation, newTextureName,
bResetTextureName, bResetScale, bResetShift, bResetRotation, FALSE))
RebuildEntity(*texEntity);
}
}
}
void DMap::RebuildEntity(DEntity *ent)
{
ent->RemoveFromRadiant();
ent->BuildInRadiant(FALSE);
}

54
contrib/bobtoolz/DMap.h Normal file
View File

@@ -0,0 +1,54 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DMap.h: interface for the DMap class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DMAP_H__ACAE597A_D26D_49AD_AA69_EDE743DB54FA__INCLUDED_)
#define AFX_DMAP_H__ACAE597A_D26D_49AD_AA69_EDE743DB54FA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class DMap
{
public:
static void RebuildEntity(DEntity* ent);
void ResetTextures( const char* textureName, float fScale[2], float fShift[2], int rotation, const char* newTextureName, int bResetTextureName, int bResetScale[2], int bResetShift[2], int bResetRotation);
void LoadAll(bool bLoadPatches = FALSE);
void BuildInRadiant(bool bAllowDestruction);
int m_nNextEntity;
DEntity* GetWorldSpawn();
void ClearEntities();
DEntity* DMap::GetEntityForID(int ID);
DEntity* AddEntity(char* classname = "worldspawn", int ID = -1);
list<DEntity*> entityList;
DMap();
virtual ~DMap();
int FixBrushes();
};
#endif // !defined(AFX_DMAP_H__ACAE597A_D26D_49AD_AA69_EDE743DB54FA__INCLUDED_)

458
contrib/bobtoolz/DPatch.cpp Normal file
View File

@@ -0,0 +1,458 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DPatch.cpp: implementation of the DPatch class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "gtkr_list.h"
#include "str.h"
//#include "DPoint.h"
//#include "DPlane.h"
//#include "DBrush.h"
//#include "DEPair.h"
#include "DPatch.h"
//#include "DEntity.h"
#include "misc.h"
#include "./dialogs/dialogs-gtk.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
// Added patch merging, wahey!
//
// problem is, you cant put patches into entities as yet :(
//
DPatch::DPatch()
{
width = MIN_PATCH_WIDTH;
height = MIN_PATCH_HEIGHT;
QER_brush = NULL;
}
DPatch::~DPatch()
{
}
void DPatch::SetTexture(const char *textureName)
{
strcpy(texture, textureName);
}
void CopyDrawVert(const drawVert_t* in, drawVert_t* out)
{
out->lightmap[0] = in->lightmap[0];
out->lightmap[1] = in->lightmap[1];
out->st[0] = in->st[0];
out->st[1] = in->st[1];
VectorCopy(in->normal, out->normal);
VectorCopy(in->xyz, out->xyz);
}
void DPatch::BuildInRadiant(void* entity)
{
#if 0
int nIndex = g_FuncTable.m_pfnCreatePatchHandle();
//$ FIXME: m_pfnGetPatchHandle
patchMesh_t* pm = g_FuncTable.m_pfnGetPatchData(nIndex);
b->patchBrush = true;
b->pPatch = Patch_Alloc();
b->pPatch->setDims(width,height);
for(int x = 0; x < height; x++)
{
for(int y = 0; y < width; y++)
{
float *p = b->pPatch->ctrlAt(ROW,x,y);
p[0] = points[x][y].xyz[0];
p[1] = points[x][y].xyz[1];
p[2] = points[x][y].xyz[2];
p[3] = points[x][y].st[0];
p[4] = points[x][y].st[1];
}
}
if(entity)
g_FuncTable.m_pfnCommitBrushHandleToEntity(QER_brush, entity);
else
g_FuncTable.m_pfnCommitBrushHandle(QER_brush);
for(int x = 0; x < width; x++)
for(int y = 0; y < height; y++)
CopyDrawVert(&points[x][y], &pm->ctrl[x][y]);
QER_patch = pm;
/* if(entity)
{
// strcpy(pm->d_texture->name, texture);
brush_t* brush = (brush_t*)g_FuncTable.m_pfnCreateBrushHandle();
brush->patchBrush = TRUE;
brush->pPatch = pm;
pm->pSymbiot = brush;
pm->bSelected = false;
pm->bOverlay = false; // bleh, f*cks up, just have to wait for a proper function
pm->bDirty = true; // or get my own patch out....
pm->nListID = -1;
g_FuncTable.m_pfnCommitBrushHandleToEntity(brush, entity);
}
else*/ // patch to entity just plain dont work atm
if(entity)
g_FuncTable.m_pfnCommitPatchHandleToEntity(nIndex, pm, texture, entity);
else
g_FuncTable.m_pfnCommitPatchHandleToMap(nIndex, pm, texture);
QER_brush = pm->pSymbiot;
#endif
}
void DPatch::LoadFromBrush(scene::Node* brush)
{
QER_brush = brush;
#if 0
SetTexture(brush->pPatch->GetShader());
width = brush->pPatch->getWidth();
height = brush->pPatch->getHeight();
for(int x = 0; x < height; x++)
{
for(int y = 0; y < width; y++)
{
float *p = brush->pPatch->ctrlAt(ROW,x,y);
p[0] = points[x][y].xyz[0];
p[1] = points[x][y].xyz[1];
p[2] = points[x][y].xyz[2];
p[3] = points[x][y].st[0];
p[4] = points[x][y].st[1];
}
}
#endif
}
void DPatch::RemoveFromRadiant()
{
if(QER_brush)
{
#if 0
g_FuncTable.m_pfnDeleteBrushHandle(QER_brush);
#endif
}
}
bool DPatch::ResetTextures(const char *oldTextureName, const char *newTextureName)
{
if( !oldTextureName || !strcmp(texture, oldTextureName))
{
strcpy(texture, newTextureName);
return TRUE;
}
return FALSE;
}
void Build1dArray(vec3_t* array, drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT],
int startX, int startY, int number, bool horizontal, bool inverse)
{
int x = startX, y = startY, i, step;
if(inverse)
step = -1;
else
step = 1;
for(i = 0; i < number; i++)
{
VectorCopy(points[x][y].xyz, array[i]);
if(horizontal)
x+=step;
else
y+=step;
}
}
void Print1dArray(vec3_t* array, int size)
{
for(int i = 0; i < size; i++)
Sys_Printf("(%.0f %.0f %.0f)\t", array[i][0], array[i][1], array[i][2]);
Sys_Printf("\n");
}
bool Compare1dArrays(vec3_t* a1, vec3_t* a2, int size)
{
int i;
bool equal = true;
for(i = 0; i < size; i++)
{
if(!VectorCompare(a1[i], a2[size-i-1]))
{
equal = false;
break;
}
}
return equal;
}
patch_merge_t DPatch::IsMergable(DPatch *other)
{
int i, j;
vec3_t p1Array[4][MAX_PATCH_HEIGHT];
vec3_t p2Array[4][MAX_PATCH_HEIGHT];
int p1ArraySizes[4];
int p2ArraySizes[4];
patch_merge_t merge_info;
Build1dArray(p1Array[0], this->points, 0, 0, this->width, true, false);
Build1dArray(p1Array[1], this->points, this->width-1, 0, this->height, false, false);
Build1dArray(p1Array[2], this->points, this->width-1, this->height-1, this->width, true, true);
Build1dArray(p1Array[3], this->points, 0, this->height-1, this->height, false, true);
Build1dArray(p2Array[0], other->points, 0, 0, other->width, true, false);
Build1dArray(p2Array[1], other->points, other->width-1, 0, other->height, false, false);
Build1dArray(p2Array[2], other->points, other->width-1, other->height-1, other->width, true, true);
Build1dArray(p2Array[3], other->points, 0, other->height-1, other->height, false, true);
p1ArraySizes[0] = this->width;
p1ArraySizes[1] = this->height;
p1ArraySizes[2] = this->width;
p1ArraySizes[3] = this->height;
p2ArraySizes[0] = other->width;
p2ArraySizes[1] = other->height;
p2ArraySizes[2] = other->width;
p2ArraySizes[3] = other->height;
for(i = 0; i < 4; i++)
{
for(j = 0; j < 4; j++)
{
if(p1ArraySizes[i] == p2ArraySizes[j])
{
if(Compare1dArrays(p1Array[i], p2Array[j], p1ArraySizes[i]))
{
merge_info.pos1 = i;
merge_info.pos2 = j;
merge_info.mergable = true;
return merge_info;
}
}
}
}
merge_info.mergable = false;
return merge_info;
}
DPatch* DPatch::MergePatches(patch_merge_t merge_info, DPatch *p1, DPatch *p2)
{
while(merge_info.pos1 != 2)
{
p1->Transpose();
merge_info.pos1--;
if(merge_info.pos1 < 0)
merge_info.pos1 += 4;
}
while(merge_info.pos2 != 0)
{
p2->Transpose();
merge_info.pos2--;
if(merge_info.pos2 < 0)
merge_info.pos2 += 3;
}
int newHeight = p1->height + p2->height - 1;
if(newHeight > MAX_PATCH_HEIGHT)
return NULL;
DPatch* newPatch = new DPatch();
newPatch->height = newHeight;
newPatch->width = p1->width;
newPatch->SetTexture(p1->texture);
int y = 0;
int i;
for(i = 0; i < p1->height; i++, y++)
for(int x = 0; x < p1->width; x++)
memcpy(&newPatch->points[x][y], &p1->points[x][i], sizeof(drawVert_t));
for(i = 1; i < p2->height; i++, y++)
for(int x = 0; x < p2->width; x++)
memcpy(&newPatch->points[x][y], &p2->points[x][i], sizeof(drawVert_t));
// newPatch->Invert();
return newPatch;
}
void DPatch::Invert()
{
drawVert_t vertTemp;
int i, j;
for(i = 0 ; i < width ; i++ )
{
for(j = 0; j < height / 2; j++)
{
memcpy(&vertTemp, &points[i][height - 1- j], sizeof (drawVert_t));
memcpy(&points[i][height - 1 - j], &points[i][j], sizeof(drawVert_t));
memcpy(&points[i][j], &vertTemp, sizeof(drawVert_t));
}
}
}
void DPatch::Transpose()
{
int i, j, w;
drawVert_t dv;
if ( width > height )
{
for ( i = 0 ; i < height ; i++ )
{
for ( j = i + 1 ; j < width ; j++ )
{
if ( j < height )
{
// swap the value
memcpy(&dv, &points[j][i], sizeof(drawVert_t));
memcpy(&points[j][i], &points[i][j], sizeof(drawVert_t));
memcpy(&points[i][j], &dv, sizeof(drawVert_t));
}
else
{
// just copy
memcpy(&points[i][j], &points[j][i], sizeof(drawVert_t));
}
}
}
}
else
{
for ( i = 0 ; i < width ; i++ )
{
for ( j = i + 1 ; j < height ; j++ )
{
if ( j < width )
{
// swap the value
memcpy(&dv, &points[i][j], sizeof(drawVert_t));
memcpy(&points[i][j], &points[j][i], sizeof(drawVert_t));
memcpy(&points[j][i], &dv, sizeof(drawVert_t));
}
else
{
// just copy
memcpy(&points[j][i], &points[i][j], sizeof(drawVert_t));
}
}
}
}
w = width;
width = height;
height = w;
Invert();
}
list<DPatch> DPatch::Split(bool rows, bool cols)
{
list<DPatch> patchList;
int i;
int x, y;
if(rows && height >= 5)
{
for(i = 0; i < (height-1)/2; i++)
{
DPatch p;
p.width = width;
p.height = 3;
p.SetTexture(texture);
for(y = 0; y < 3; y++)
{
for(x = 0; x < p.width; x++)
{
memcpy(&p.points[x][y], &points[x][(i*2)+y], sizeof(drawVert_t));
}
}
patchList.push_back(p);
}
if(cols && width >= 5)
{
list<DPatch> patchList2;
for(list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++)
{
list<DPatch> patchList3 = (*patches).Split(false, true);
for(list<DPatch>::iterator patches2 = patchList3.begin(); patches2 != patchList3.end(); patches2++)
patchList2.push_front(*patches2);
}
return patchList2;
}
}
else if(cols && width >= 5)
{
for(i = 0; i < (width-1)/2; i++)
{
DPatch p;
p.height = height;
p.width = 3;
p.SetTexture(texture);
for(x = 0; x < 3; x++)
{
for(y = 0; y < p.height; y++)
{
memcpy(&p.points[x][y], &points[(i*2)+x][y], sizeof(drawVert_t));
}
}
patchList.push_back(p);
}
}
return patchList;
}

75
contrib/bobtoolz/DPatch.h Normal file
View File

@@ -0,0 +1,75 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DPatch.h: interface for the DPatch class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DPATCH_H__26C6B083_CE5B_420B_836B_1DDA733C04CE__INCLUDED_)
#define AFX_DPATCH_H__26C6B083_CE5B_420B_836B_1DDA733C04CE__INCLUDED_
#include "StdAfx.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef struct
{
bool mergable;
int pos1;
int pos2;
} patch_merge_t;
typedef struct {
float xyz[3];
float st[2];
float normal[3];
float lightmap[2];
} drawVert_t;
class Patch;
#define MAX_PATCH_WIDTH 16
#define MAX_PATCH_HEIGHT 16
#define MIN_PATCH_WIDTH 3
#define MIN_PATCH_HEIGHT 3
class DPatch
{
public:
list<DPatch> Split(bool rows, bool cols);
void Transpose();
void Invert();
DPatch* MergePatches(patch_merge_t merge_info, DPatch* p1, DPatch* p2);
patch_merge_t IsMergable(DPatch* other);
bool ResetTextures(const char *oldTextureName, const char *newTextureName);
void RemoveFromRadiant(void);
scene::Node* QER_brush;
void LoadFromBrush(scene::Node* brush);
void BuildInRadiant(void* entity = NULL);
void SetTexture(const char* textureName);
char texture[256];
int width, height;
drawVert_t points[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
DPatch();
virtual ~DPatch();
};
#endif // !defined(AFX_DPATCH_H__26C6B083_CE5B_420B_836B_1DDA733C04CE__INCLUDED_)

264
contrib/bobtoolz/DPlane.cpp Normal file
View File

@@ -0,0 +1,264 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DPlane.cpp: implementation of the DPlane class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "gtkr_list.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DWinding.h"
#include "str.h"
#include "misc.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DPlane::DPlane(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData)
{
MakeNormal( va, vb, vc, normal );
if(VectorNormalize(normal, normal) == 0) // normalizes and returns length
Sys_ERROR("DPlane::DPlane: Bad Normal.\n");
_d = (normal[0]*va[0]) + (normal[1]*va[1]) + (normal[2]*va[2]);
VectorCopy(va, points[0]);
VectorCopy(vb, points[1]);
VectorCopy(vc, points[2]);
m_bChkOk = TRUE;
if(texData)
memcpy(&texInfo, texData, sizeof(_QERFaceData));
else
FillDefaultTexture(&texInfo, points[0], points[1], points[2], "textures/common/caulk");
}
DPlane::~DPlane()
{
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
vec_t DPlane::DistanceToPoint(vec3_t pnt)
{
vec3_t tmp;
VectorSubtract(pnt, points[0], tmp);
return DotProduct(tmp, normal);
}
bool DPlane::PlaneIntersection(DPlane *pl1, DPlane *pl2, vec3_t out)
{
float a1, a2, a3;
float b1, b2, b3;
float c1, c2, c3;
a1 = normal[0]; a2 = normal[1]; a3 = normal[2];
b1 = pl1->normal[0]; b2 = pl1->normal[1]; b3 = pl1->normal[2];
c1 = pl2->normal[0]; c2 = pl2->normal[1]; c3 = pl2->normal[2];
float d = Determinant3x3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
if(d == 0)
return FALSE;
float v1 = _d;
float v2 = pl1->_d;
float v3 = pl2->_d;
float d1 = Determinant3x3(v1, a2, a3, v2, b2, b3, v3, c2, c3);
float d2 = Determinant3x3(a1, v1, a3, b1, v2, b3, c1, v3, c3);
float d3 = Determinant3x3(a1, a2, v1, b1, b2, v2, c1, c2, v3);
out[0] = d1/d;
out[1] = d2/d;
out[2] = d3/d;
return TRUE;
}
bool DPlane::IsRedundant(list<DPoint*>& pointList)
{
int cnt = 0;
//list<DPoint *>::const_iterator point=pointList.begin();
for(list<DPoint *>::const_iterator point=pointList.begin(); point!=pointList.end(); point++)
{
if(fabs(DistanceToPoint((*point)->_pnt)) < MAX_ROUND_ERROR)
cnt++;
if(cnt == 3)
return FALSE;
}
return TRUE;
}
bool DPlane::operator == (DPlane& other)
{
vec3_t chk;
VectorSubtract(other.normal, normal, chk);
if(fabs(VectorLength(chk)) > MAX_ROUND_ERROR)
return FALSE;
if(fabs(other._d - _d) > MAX_ROUND_ERROR)
return FALSE;
return TRUE;
}
bool DPlane::operator != (DPlane& other)
{
vec3_t chk;
VectorAdd(other.normal, normal, chk);
if(fabs(VectorLength(chk)) > MAX_ROUND_ERROR)
return FALSE;
return TRUE;
}
DWinding* DPlane::BaseWindingForPlane()
{
int i, x;
vec_t max, v;
vec3_t org, vright, vup;
// find the major axis
max = -131072;
x = -1;
for (i=0 ; i<3; i++)
{
v = (float)fabs(normal[i]);
if (v > max)
{
x = i;
max = v;
}
}
if (x==-1)
Sys_Printf ("BaseWindingForPlane: no axis found");
VectorCopy (vec3_origin, vup);
switch (x)
{
case 0:
case 1:
vup[2] = 1;
break;
case 2:
vup[0] = 1;
break;
}
v = DotProduct (vup, normal);
VectorMA (vup, -v, normal, vup);
VectorNormalize (vup, vup);
VectorScale (normal, _d, org);
CrossProduct (vup, normal, vright);
VectorScale (vup, 131072, vup);
VectorScale (vright, 131072, vright);
// project a really big axis aligned box onto the plane
DWinding* w = new DWinding;
w->AllocWinding(4);
VectorSubtract (org, vright, w->p[0]);
VectorAdd (w->p[0], vup, w->p[0]);
VectorAdd (org, vright, w->p[1]);
VectorAdd (w->p[1], vup, w->p[1]);
VectorAdd (org, vright, w->p[2]);
VectorSubtract (w->p[2], vup, w->p[2]);
VectorSubtract (org, vright, w->p[3]);
VectorSubtract (w->p[3], vup, w->p[3]);
return w;
}
void DPlane::Rebuild()
{
vec3_t v1, v2;
VectorSubtract(points[0], points[1], v1);
VectorSubtract(points[2], points[1], v2);
CrossProduct(v1, v2, normal);
if(VectorNormalize(normal, normal) == 0) // normalizes and returns length
Sys_ERROR("DPlane::Rebuild: Bad Normal.\n");
_d = (normal[0]*points[0][0]) + (normal[1]*points[0][1]) + (normal[2]*points[0][2]);
VectorCopy(points[0], texInfo.m_p0);
VectorCopy(points[1], texInfo.m_p1);
VectorCopy(points[2], texInfo.m_p2);
}
bool DPlane::AddToBrush(Brush *brush)
{
#if 0
if(m_bChkOk || !strcmp(texInfo.m_TextureName, "textures/common/caulk"))
{
brush->addPlane(m_p0, m_p1, m_p2, m_texdef, false);
return FALSE;
}
strcpy(texInfo.m_TextureName, "textures/common/caulk");
brush->addPlane(m_p0, m_p1, m_p2, m_texdef, false);
#endif
return TRUE;
}
void DPlane::ScaleTexture()
{ }
DPlane::DPlane(vec3_t va, vec3_t vb, vec3_t vc, const char* textureName, bool bDetail)
{
vec3_t v1, v2;
VectorSubtract(va, vb, v1);
VectorSubtract(vc, vb, v2);
CrossProduct(v1, v2, normal);
if(VectorNormalize(normal, normal) == 0) // normalizes and returns length
Sys_ERROR("DPlane::DPlane: Bad Normal.\n");
_d = (normal[0]*va[0]) + (normal[1]*va[1]) + (normal[2]*va[2]);
VectorCopy(va, points[0]);
VectorCopy(vb, points[1]);
VectorCopy(vc, points[2]);
m_bChkOk = TRUE;
FillDefaultTexture(&texInfo, points[0], points[1], points[2], textureName);
if(bDetail)
texInfo.m_texdef.contents |= FACE_DETAIL;
}

67
contrib/bobtoolz/DPlane.h Normal file
View File

@@ -0,0 +1,67 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DPlane.h: interface for the DPlane class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DPLANE_H__FC37C021_F0A1_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_DPLANE_H__FC37C021_F0A1_11D4_ACF7_004095A18133__INCLUDED_
class Brush;
#define FACE_DETAIL 0x8000000
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class DWinding;
class DPlane
{
public:
DPlane(vec3_t va, vec3_t vb, vec3_t vc, const char* textureName, bool bDetail);
void ScaleTexture();
DWinding* BaseWindingForPlane();
void Rebuild();
bool AddToBrush(Brush *brush);
bool operator != (DPlane& other);
bool operator == (DPlane& other);
bool IsRedundant(list<DPoint*>& pointList);
bool PlaneIntersection(DPlane* pl1, DPlane* pl2, vec3_t out);;
vec_t DistanceToPoint(vec3_t pnt);
DPlane(vec3_t va, vec3_t vb, vec3_t vc, _QERFaceData* texData);
DPlane() { }
virtual ~DPlane();
bool m_bChkOk;
_QERFaceData texInfo;
vec3_t points[3]; // djbob:do we really need these any more?
vec3_t normal;
float _d;
};
//typedef CList<DPlane*, DPlane*> DPlaneList;
#endif // !defined(AFX_DPLANE_H__FC37C021_F0A1_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,52 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DPoint.cpp: implementation of the DPoint class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "DPoint.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DPoint::DPoint()
{
}
DPoint::~DPoint()
{
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
bool DPoint::operator ==(vec3_t other)
{
vec3_t test;
VectorSubtract(other, _pnt, test);
if(fabs(VectorLength(test)) > MAX_ROUND_ERROR)
return FALSE;
return TRUE;
}

45
contrib/bobtoolz/DPoint.h Normal file
View File

@@ -0,0 +1,45 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DPoint.h: interface for the DPoint class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DPOINT_H__FC37C022_F0A1_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_DPOINT_H__FC37C022_F0A1_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class DPoint
{
public:
DPoint();
virtual ~DPoint();
bool operator ==(vec3_t other);
vec3_t _pnt;
unsigned char m_uData;
};
//typedef CList<DPoint*, DPoint*> DPointList;
#endif // !defined(AFX_DPOINT_H__FC37C022_F0A1_11D4_ACF7_004095A18133__INCLUDED_)

469
contrib/bobtoolz/DShape.cpp Normal file
View File

@@ -0,0 +1,469 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DShape.cpp: implementation of the DShape class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "gtkr_list.h"
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#include "DEPair.h"
#include "DPatch.h"
#include "DEntity.h"
#include "DShape.h"
//#include "dialogs-gtk.h"
#include "misc.h"
#include "shapes.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
bool bFacesAll[6] = {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE};
DShape::DShape()
{
m_nNextBrush = 0;
}
DShape::~DShape()
{
}
void DShape::BuildRegularPrism(vec3_t min, vec3_t max, int nSides, bool bAlignTop)
{
vec3_t vc[MAX_POLYGON_FACES+2], vd[MAX_POLYGON_FACES+2];
vec3_t radius;
vec3_t origin;
VectorSubtract(max, min, radius);
VectorScale(radius, 0.5f, radius);
// calc 3d radius and origin
VectorAdd(max, min, origin);
VectorScale(origin, 0.5f, origin);
float phase = 0.0f;
if(bAlignTop)
{
phase = -(Q_PI/nSides);
VectorScale(radius, static_cast<float>(1.0 / cos(phase)), radius);
}
//----- Build Polygon Vertices -----
int i;
for(i = 0; i < nSides; i++)
{
VectorCopy(origin, vc[i]);
VectorCopy(origin, vd[i]);
vc[i][2] = min[2];
vd[i][2] = max[2];
vc[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
vc[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );
vd[i][0] = vc[i][0];
vd[i][1] = vc[i][1];
}
VectorCopy(vc[0], vc[nSides]);
VectorCopy(vd[0], vd[nSides]);
VectorCopy(vc[1], vc[nSides+1]);
VectorCopy(vd[1], vd[nSides+1]);
//----------------------------------
DBrush* pB = m_Container.GetWorldSpawn()->NewBrush(m_nNextBrush++);
for(i = 1; i <= nSides; i++)
pB->AddFace(vc[i-1], vc[i], vd[i], GetCurrentTexture(), FALSE);
pB->AddFace(vc[2], vc[1], vc[0], "textures/common/caulk", FALSE);
pB->AddFace(vd[0], vd[1], vd[2], "textures/common/caulk", FALSE);
}
void DShape::Commit()
{
m_Container.GetWorldSpawn()->FixBrushes();
m_Container.BuildInRadiant(TRUE);
}
void DShape::BuildInversePrism(vec3_t min, vec3_t max, int nSides, bool bAlignTop)
{
vec3_t va[MAX_POLYGON_FACES+1], vb[MAX_POLYGON_FACES+1];
vec3_t radius;
vec3_t origin;
VectorSubtract(max, min, radius);
VectorScale(radius, 0.5f, radius);
// calc 3d radius and origin
VectorAdd(max, min, origin);
VectorScale(origin, 0.5f, origin);
float phase = 0.0f;
if(bAlignTop)
{
phase = -(Q_PI/nSides);
VectorScale(radius, static_cast<float>(1.0 / cos(phase)), radius);
}
//----- Build Polygon Vertices -----
int i;
for(i = 0; i < nSides; i++)
{
VectorCopy(origin, va[i]);
VectorCopy(origin, vb[i]);
va[i][2] = min[2];
vb[i][2] = max[2];
va[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
va[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );
vb[i][0] = va[i][0];
vb[i][1] = va[i][1];
}
VectorCopy(va[0], va[nSides]);
VectorCopy(vb[0], vb[nSides]);
//----------------------------------
for(i = 1; i <= nSides; i++)
{
DBrush* pB = GetBoundingCube(min, max, "textures/common/caulk");
vec3_t top, bottom;
VectorCopy(va[i-1], top);
VectorCopy(va[i], bottom);
if(va[i-1][1] > va[i][1])
{
top[0] += 5;
bottom[0] += 5;
}
else // flip direction of plane on crossover
{
top[0] -= 5;
bottom[0] -= 5;
}
if(top[1] != bottom[1]) // internal line is flat already if true
{
pB->AddFace(va[i-1], top, vb[i-1], "textures/common/caulk", FALSE);
pB->AddFace(va[i], vb[i], bottom, "textures/common/caulk", FALSE);
} // add cut-off planes
pB->AddFace(va[i-1], vb[i-1], vb[i], GetCurrentTexture(), FALSE);
// add internal polygon plane
}
}
void DShape::BuildBorderedPrism(vec3_t min, vec3_t max, int nSides, int nBorder, bool bAlignTop)
{
vec3_t va[MAX_POLYGON_FACES+2], vb[MAX_POLYGON_FACES+2];
vec3_t vc[MAX_POLYGON_FACES+2], vd[MAX_POLYGON_FACES+2];
vec3_t radius;
vec3_t origin;
VectorSubtract(max, min, radius);
VectorScale(radius, 0.5f, radius);
// calc 3d radius and origin
VectorAdd(max, min, origin);
VectorScale(origin, 0.5f, origin);
if(nBorder >= Min(radius[0], radius[1]))
{
// DoMessageBox("Border is too large", "Error", MB_OK);
return;
}
float phase = 0.0f;
if(bAlignTop)
{
phase = -(Q_PI/nSides);
VectorScale(radius, static_cast<float>(1.0 / cos(phase)), radius);
}
//----- Build Polygon Vertices -----
int i;
for(i = 0; i < nSides; i++)
{
VectorCopy(origin, va[i]);
VectorCopy(origin, vb[i]);
VectorCopy(origin, vc[i]);
VectorCopy(origin, vd[i]);
va[i][2] = min[2];
vb[i][2] = max[2];
va[i][0] += (radius[0] - nBorder) * sinf( ( 2 * Q_PI * i / nSides ) + phase );
va[i][1] += (radius[1] - nBorder) * cosf( ( 2 * Q_PI * i / nSides ) + phase );
vb[i][0] = va[i][0];
vb[i][1] = va[i][1];
vc[i][2] = min[2];
vd[i][2] = max[2];
vc[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
vc[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );
vd[i][0] = vc[i][0];
vd[i][1] = vc[i][1];
}
VectorCopy(va[0], va[nSides]);
VectorCopy(vb[0], vb[nSides]);
VectorCopy(va[1], va[nSides+1]);
VectorCopy(vb[1], vb[nSides+1]);
VectorCopy(vc[0], vc[nSides]);
VectorCopy(vd[0], vd[nSides]);
VectorCopy(vc[1], vc[nSides+1]);
VectorCopy(vd[1], vd[nSides+1]);
//----------------------------------
for(i = 1; i <= nSides; i++)
{
DBrush* pB = GetBoundingCube(min, max, "textures/common/caulk");
pB->AddFace(origin, vc[i-1], vd[i-1], "textures/common/caulk", FALSE);
pB->AddFace(origin, vd[i], vc[i], "textures/common/caulk", FALSE);
pB->AddFace(vc[i-1], vc[i], vd[i], GetCurrentTexture(), FALSE);
pB->AddFace(vb[i], va[i], va[i-1], GetCurrentTexture(), FALSE);
}
}
DBrush* DShape::GetBoundingCube_Ext(vec3_t min, vec3_t max, const char *textureName, bool* bUseFaces, bool detail)
{
DBrush* pB = new DBrush;
//----- Build Outer Bounds ---------
vec3_t v1, v2, v3, v5, v6, v7;
VectorCopy(min, v1);
VectorCopy(min, v2);
VectorCopy(min, v3);
VectorCopy(max, v5);
VectorCopy(max, v6);
VectorCopy(max, v7);
v2[0] = max[0];
v3[1] = max[1];
v6[0] = min[0];
v7[1] = min[1];
//----------------------------------
//----- Add Six Cube Faces ---------
if(bUseFaces[0])
pB->AddFace(v1, v2, v3, textureName, detail);
if(bUseFaces[1])
pB->AddFace(v1, v3, v6, textureName, detail);
if(bUseFaces[2])
pB->AddFace(v1, v7, v2, textureName, detail);
if(bUseFaces[3])
pB->AddFace(v5, v6, v3, textureName, detail);
if(bUseFaces[4])
pB->AddFace(v5, v2, v7, textureName, detail);
if(bUseFaces[5])
pB->AddFace(v5, v7, v6, textureName, detail);
//----------------------------------
return pB;
}
DBrush* DShape::GetBoundingCube(vec3_t min, vec3_t max, const char *textureName, DEntity* ent, bool* bUseFaces)
{
DBrush* pB;
if(ent == NULL)
pB = m_Container.GetWorldSpawn()->NewBrush(m_nNextBrush++);
else
pB = ent->NewBrush(m_nNextBrush++);
//----- Build Outer Bounds ---------
vec3_t v1, v2, v3, v5, v6, v7;
VectorCopy(min, v1);
VectorCopy(min, v2);
VectorCopy(min, v3);
VectorCopy(max, v5);
VectorCopy(max, v6);
VectorCopy(max, v7);
v2[0] = max[0];
v3[1] = max[1];
v6[0] = min[0];
v7[1] = min[1];
//----------------------------------
//----- Add Six Cube Faces ---------
if(bUseFaces[0])
pB->AddFace(v1, v2, v3, textureName, FALSE);
if(bUseFaces[1])
pB->AddFace(v1, v3, v6, textureName, FALSE);
if(bUseFaces[2])
pB->AddFace(v1, v7, v2, textureName, FALSE);
if(bUseFaces[3])
pB->AddFace(v5, v6, v3, textureName, FALSE);
if(bUseFaces[4])
pB->AddFace(v5, v2, v7, textureName, FALSE);
if(bUseFaces[5])
pB->AddFace(v5, v7, v6, textureName, FALSE);
//----------------------------------
return pB;
}
bool DShape::BuildPit(vec3_t min, vec3_t max)
{
if((max[2] - min[2]) < 196)
return FALSE;
srand(time(NULL));
vec3_t centre;
VectorAdd(min, max, centre);
VectorScale(centre, 0.5f, centre);
char buffer[256];
int team = (rand()%10000)+5000;
// ************* SPEAKER ***************
sprintf(buffer, "t%i_1", team);
// trigger for speaker
vec3_t triggerVoiceBtm;
VectorCopy(min, triggerVoiceBtm);
triggerVoiceBtm[2] = max[2] - 16;
DEntity* triggerVoice = m_Container.AddEntity("trigger_multiple");
GetBoundingCube(triggerVoiceBtm, max, "textures/common/trigger", triggerVoice);
triggerVoice->AddEPair("target", buffer);
//--------------------
// target for speaker
vec3_t voiceOrigin;
VectorCopy(centre, voiceOrigin);
voiceOrigin[2] = max[2]+16;
DEntity* targetVoice = m_Container.AddEntity("target_speaker");
targetVoice->AddEPair("targetname", buffer);
sprintf(buffer, "%f %f %f", voiceOrigin[0], voiceOrigin[1], voiceOrigin[2]);
targetVoice->AddEPair("origin", buffer);
targetVoice->AddEPair("spawnflags", "8");
targetVoice->AddEPair("noise", "*falling1.wav");
//--------------------
// *********** END SPEAKER *************
// ********* POWERUP REMOVAL ***********
sprintf(buffer, "t%i_2", team);
// trigger for powerup removal
vec3_t triggerPwrRmvTop, triggerPwrRmvBtm;
VectorCopy(min, triggerPwrRmvBtm);
VectorCopy(max, triggerPwrRmvTop);
triggerPwrRmvTop[2] = triggerVoiceBtm[2] - 64;
triggerPwrRmvBtm[2] = triggerPwrRmvTop[2] - 16;
DEntity* triggerPwrRmv = m_Container.AddEntity("trigger_multiple");
GetBoundingCube(triggerPwrRmvBtm, triggerPwrRmvTop, "textures/common/trigger", triggerPwrRmv);
triggerPwrRmv->AddEPair("target", buffer);
//--------------------
// target for powerup removal
vec3_t pwrRmvOrigin;
VectorCopy(centre, pwrRmvOrigin);
pwrRmvOrigin[2] = triggerPwrRmvTop[2]+16;
DEntity* targetPwrRmv = m_Container.AddEntity("target_remove_powerups");
targetPwrRmv->AddEPair("targetname", buffer);
sprintf(buffer, "%f %f %f", pwrRmvOrigin[0], pwrRmvOrigin[1], pwrRmvOrigin[2]);
targetPwrRmv->AddEPair("origin", buffer);
//--------------------
// ****** END POWERUP REMOVAL ********
// ********* DAMAGE ***********
// trigger for damage
vec3_t triggerDmgTop, triggerDmgBtm;
VectorCopy(min, triggerDmgBtm);
VectorCopy(max, triggerDmgTop);
triggerDmgBtm[2] = min[2] + 64;
triggerDmgTop[2] = triggerDmgBtm[2] + 16;
DEntity* triggerDmg = m_Container.AddEntity("trigger_hurt");
GetBoundingCube(triggerDmgBtm, triggerDmgTop, "textures/common/trigger", triggerDmg);
triggerDmg->AddEPair("dmg", "9999");
triggerDmg->AddEPair("spawnflags", "12");
//--------------------
// ****** END DAMAGE ********
// ********* NODROP ***********
vec3_t nodropTop;
VectorCopy(max, nodropTop);
nodropTop[2] = min[2] + 64;
GetBoundingCube(min, nodropTop, "textures/common/nodrop");
// ****** END NODROP ********
return TRUE;
}

60
contrib/bobtoolz/DShape.h Normal file
View File

@@ -0,0 +1,60 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DShape.h: interface for the DShape class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DSHAPE_H__0B30B302_9D21_4C2D_836A_61F3C8D4244D__INCLUDED_)
#define AFX_DSHAPE_H__0B30B302_9D21_4C2D_836A_61F3C8D4244D__INCLUDED_
#include "DMap.h" // Added by ClassView
#include "StdAfx.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// defines for polygon stuff
#define MAX_POLYGON_FACES 128
extern bool bFacesAll[];
class DShape
{
public:
bool BuildPit(vec3_t min, vec3_t max);
void BuildBorderedPrism(vec3_t min, vec3_t max, int nSides, int nBorder, bool bAlignTop);
void BuildInversePrism(vec3_t min, vec3_t max, int nSides, bool bAlignTop);
void BuildRegularPrism(vec3_t min, vec3_t max, int nSides, bool bAlignTop);
int m_nNextBrush;
static DBrush* GetBoundingCube_Ext(vec3_t min, vec3_t max, const char* textureName, bool* bUseFaces = bFacesAll, bool detail = false);
DShape();
virtual ~DShape();
void Commit();
private:
DBrush* GetBoundingCube(vec3_t min, vec3_t max, const char* textureName, DEntity* ent = NULL, bool* bUseFaces = bFacesAll);
DMap m_Container;
};
#endif // !defined(AFX_DSHAPE_H__0B30B302_9D21_4C2D_836A_61F3C8D4244D__INCLUDED_)

View File

@@ -0,0 +1,366 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "gtkr_list.h"
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#include "DEPair.h"
#include "DPatch.h"
#include "DEntity.h"
#include "DTrainDrawer.h"
#include "misc.h"
#include "funchandlers.h"
#include "dialogs/dialogs-gtk.h"
DTrainDrawer::DTrainDrawer() {
refCount = 1;
m_bHooked = FALSE;
m_bDisplay = FALSE;
BuildPaths();
}
DTrainDrawer::~DTrainDrawer(void) {
if(m_bHooked)
UnRegister();
ClearPoints();
ClearSplines();
}
void DTrainDrawer::ClearSplines() {
for(list<splinePoint_t *>::const_iterator deadSpline = m_splineList.begin(); deadSpline != m_splineList.end(); deadSpline++) {
(*deadSpline)->m_pointList.clear();
(*deadSpline)->m_vertexList.clear();
delete (*deadSpline);
}
m_splineList.clear();
}
void DTrainDrawer::ClearPoints() {
for(list<controlPoint_t *>::const_iterator deadPoint = m_pointList.begin(); deadPoint != m_pointList.end(); deadPoint++) {
delete *deadPoint;
}
m_pointList.clear();
}
void DTrainDrawer::Register() {
__QGLTABLENAME.m_pfnHookGL2DWindow( this );
__QGLTABLENAME.m_pfnHookGL3DWindow( this );
m_bHooked = TRUE;
}
void DTrainDrawer::UnRegister() {
__QGLTABLENAME.m_pfnUnHookGL2DWindow( this );
__QGLTABLENAME.m_pfnUnHookGL3DWindow( this );
m_bHooked = FALSE;
}
void CalculateSpline_r(vec3_t* v, int count, vec3_t out, float tension) {
vec3_t dist;
if(count < 2) {
return;
}
if(count == 2) {
VectorSubtract( v[1], v[0], dist );
VectorMA(v[0], tension, dist, out);
return;
}
vec3_t* v2 = new vec3_t[count-1];
for( int i = 0; i < count-1; i++ ) {
VectorSubtract( v[i+1], v[i], dist );
VectorMA(v[i], tension, dist, v2[i]);
}
CalculateSpline_r( v2, count-1, out, tension);
delete[] v2;
}
void DTrainDrawer::Draw3D() {
if(!m_bDisplay) {
return;
}
__QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
__QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglDisable(GL_LINE_SMOOTH);
__QGLTABLENAME.m_pfn_qglPushMatrix();
__QGLTABLENAME.m_pfn_qglLineWidth(2.0f);
__QGLTABLENAME.m_pfn_qglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
__QGLTABLENAME.m_pfn_qglEnable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
__QGLTABLENAME.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
__QGLTABLENAME.m_pfn_qglDepthFunc(GL_ALWAYS);
for(list<splinePoint_t* >::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
splinePoint_t* pSP = (*sp);
__QGLTABLENAME.m_pfn_qglBegin(GL_LINE_STRIP);
for(list<DPoint >::const_iterator v = pSP->m_vertexList.begin(); v != pSP->m_vertexList.end(); v++) {
__QGLTABLENAME.m_pfn_qglVertex3fv((*v)._pnt);
}
__QGLTABLENAME.m_pfn_qglEnd();
}
__QGLTABLENAME.m_pfn_qglPopMatrix();
__QGLTABLENAME.m_pfn_qglPopAttrib();
}
void DTrainDrawer::Draw2D(VIEWTYPE vt) {
if(!m_bDisplay) {
return;
}
__QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
__QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglDisable(GL_LINE_SMOOTH);
__QGLTABLENAME.m_pfn_qglPushMatrix();
switch(vt)
{
case XY:
break;
case XZ:
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
break;
case YZ:
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
break;
}
__QGLTABLENAME.m_pfn_qglLineWidth(1.0f);
__QGLTABLENAME.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 0.5f);
__QGLTABLENAME.m_pfn_qglEnable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
__QGLTABLENAME.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
__QGLTABLENAME.m_pfn_qglDepthFunc(GL_ALWAYS);
__QGLTABLENAME.m_pfn_qglColor4f(1.f, 0.f, 0.f, 1.f);
for(list<splinePoint_t* >::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
splinePoint_t* pSP = (*sp);
__QGLTABLENAME.m_pfn_qglBegin(GL_LINE_STRIP);
for(list<DPoint >::const_iterator v = pSP->m_vertexList.begin(); v != pSP->m_vertexList.end(); v++) {
__QGLTABLENAME.m_pfn_qglVertex3fv((*v)._pnt);
}
__QGLTABLENAME.m_pfn_qglEnd();
}
__QGLTABLENAME.m_pfn_qglPopMatrix();
__QGLTABLENAME.m_pfn_qglPopAttrib();
}
void AddSplineControl(const char* control, splinePoint_t* pSP) {
controlPoint_t cp;
strncpy(cp.strName, control, 64);
pSP->m_pointList.push_front(cp);
}
void DTrainDrawer::BuildPaths() {
#if 0
int count = g_FuncTable.m_pfnGetEntityCount();
DEntity e;
for(int i = 0; i < count; i++) {
entity_s* ent = (entity_s*)g_FuncTable.m_pfnGetEntityHandle(i);
e.ClearEPairs();
e.LoadEPairList(*g_EntityTable.m_pfnGetEntityKeyValList(ent));
const char* classname = e.m_Classname.GetBuffer();
const char* target;
const char* control;
const char* targetname;
vec3_t vOrigin;
e.SpawnString("targetname", NULL, &targetname);
e.SpawnVector("origin", "0 0 0", vOrigin);
if(!strcmp(classname, "info_train_spline_main")) {
if(!targetname) {
Sys_Printf( "info_train_spline_main with no targetname" );
return;
}
e.SpawnString("target", NULL, &target);
if(!target) {
AddControlPoint( targetname, vOrigin );
} else {
splinePoint_t* pSP = AddSplinePoint( targetname, target, vOrigin );
e.SpawnString("control", NULL, &control);
if(control) {
AddSplineControl( control, pSP );
for(int j = 2;; j++) {
char buffer[16];
sprintf(buffer, "control%i", j);
e.SpawnString(buffer, NULL, &control);
if(!control) {
break;
}
AddSplineControl( control, pSP );
}
}
}
} else if(!strcmp(classname, "info_train_spline_control")) {
if(!targetname) {
Sys_Printf( "info_train_spline_control with no targetname" );
return;
}
AddControlPoint( targetname, vOrigin );
}
}
list<splinePoint_t* >::const_iterator sp;
for(sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
splinePoint_t* pSP = (*sp);
controlPoint_t* pTarget = FindControlPoint( pSP->strTarget );
if(!pTarget) {
Sys_Printf( "couldn't find target %s", pSP->strTarget );
return;
// continue;
}
pSP->pTarget = pTarget;
for(list<controlPoint_t >::iterator cp = pSP->m_pointList.begin(); cp != pSP->m_pointList.end(); cp++) {
controlPoint_t* pControl = FindControlPoint( (*cp).strName );
if(!pControl) {
Sys_Printf( "couldn't find control %s", (*cp).strName );
return;
}
VectorCopy(pControl->vOrigin, (*cp).vOrigin);
}
}
m_bDisplay = TRUE;
Register();
for(sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
splinePoint_t* pSP = (*sp);
DPoint out;
if(!pSP->pTarget) {
continue;
}
int count = pSP->m_pointList.size() + 2;
vec3_t* v = new vec3_t[count];
VectorCopy(pSP->point.vOrigin, v[0]);
int i = 1;
for(list<controlPoint_t>::reverse_iterator cp = pSP->m_pointList.rbegin(); cp != pSP->m_pointList.rend(); cp++) {
VectorCopy((*cp).vOrigin, v[i]);
i++;
}
VectorCopy(pSP->pTarget->vOrigin, v[i]);
for (float tension = 0.0f; tension <= 1.f; tension += 0.01f) {
CalculateSpline_r(v, count, out._pnt, tension);
pSP->m_vertexList.push_front(out);
}
delete[] v;
VectorCopy(pSP->pTarget->vOrigin, out._pnt);
pSP->m_vertexList.push_front(out);
}
#endif
}
void DTrainDrawer::AddControlPoint(const char* name, vec_t* origin)
{
controlPoint_t* pCP = new controlPoint_t;
strncpy(pCP->strName, name, 64);
VectorCopy( origin, pCP->vOrigin );
m_pointList.push_back( pCP );
}
splinePoint_t* DTrainDrawer::AddSplinePoint(const char* name, const char* target, vec_t* origin)
{
splinePoint_t* pSP = new splinePoint_t;
strncpy(pSP->point.strName, name, 64);
strncpy(pSP->strTarget, target, 64);
VectorCopy( origin, pSP->point.vOrigin );
m_splineList.push_back( pSP );
return pSP;
}
controlPoint_t* DTrainDrawer::FindControlPoint(const char* name)
{
for(list<controlPoint_t*>::const_iterator cp = m_pointList.begin(); cp != m_pointList.end(); cp++) {
if(!strcmp(name, (*cp)->strName)) {
return (*cp);
}
}
for(list<splinePoint_t*>::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
if(!strcmp(name, (*sp)->point.strName)) {
return &((*sp)->point);
}
}
return NULL;
}

View File

@@ -0,0 +1,80 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DTrainDrawer.h: interface for the DTrainDrawer class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TRAINDRAWER_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_TRAINDRAWER_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef struct {
char strName[64];
vec3_t vOrigin;
} controlPoint_t;
typedef struct {
controlPoint_t point;
char strControl[64];
char strTarget[64];
list<controlPoint_t> m_pointList;
list<DPoint> m_vertexList;
controlPoint_t* pTarget;
} splinePoint_t;
class DTrainDrawer :
public IGL2DWindow,
public IGL3DWindow
{
private:
list<splinePoint_t*> m_splineList;
list<controlPoint_t*> m_pointList;
int refCount;
bool m_bHooked;
bool m_bDisplay;
public:
void UnRegister();
void Register();
DTrainDrawer();
virtual ~DTrainDrawer(void);
void Draw3D();
void Draw2D(VIEWTYPE vt);
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
void ClearSplines();
void ClearPoints();
void BuildPaths();
void AddControlPoint(const char* name, vec_t* origin);
splinePoint_t* AddSplinePoint(const char* name, const char* target, vec_t* origin);
controlPoint_t* FindControlPoint(const char* name);
};
#endif // !defined(AFX_TRAINDRAWER_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,307 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "gtkr_list.h"
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#include "DEPair.h"
#include "DPatch.h"
#include "DEntity.h"
#include "ScriptParser.h"
#include "misc.h"
#include "DTreePlanter.h"
#include "funchandlers.h"
bool DTreePlanter::OnMouseMove(guint32 nFlags, gdouble x, gdouble y) {
return false;
}
bool DTreePlanter::OnLButtonDown(guint32 nFlags, gdouble x, gdouble y) {
VIEWTYPE vt = m_XYWrapper->GetViewType();
switch(vt) {
case XY:
break;
case YZ:
case XZ:
default:
return false;
}
vec3_t pt, vhit;
m_XYWrapper->SnapToGrid( static_cast<int>(x), static_cast<int>(y), pt );
if(FindDropPoint(pt, vhit)) {
vhit[2] += m_offset;
char buffer[128];
DEntity e(m_entType);
sprintf(buffer, "%i %i %i", (int)vhit[0], (int)vhit[1], (int)vhit[2]);
e.AddEPair("origin", buffer);
if(m_autoLink) {
#if 0
entity_t* pLastEntity = NULL;
entity_t* pThisEntity = NULL;
int entNum = -1, lastEntNum = -1, entpos;
for(int i = 0; i < 256; i++) {
sprintf(buffer, m_linkName, i);
pThisEntity = FindEntityFromTargetname( buffer, &entNum );
if(pThisEntity) {
entpos = i;
lastEntNum = entNum;
pLastEntity = pThisEntity;
}
}
if(!pLastEntity) {
sprintf(buffer, m_linkName, 0);
} else {
sprintf(buffer, m_linkName, entpos + 1);
}
e.AddEPair( "targetname", buffer );
if(pLastEntity) {
DEntity e2;
e2.LoadFromEntity(lastEntNum, TRUE);
e2.AddEPair("target", buffer);
e2.RemoveFromRadiant();
e2.BuildInRadiant(FALSE);
}
#endif
}
if(m_setAngles) {
int angleYaw = (rand() % (m_maxYaw - m_minYaw + 1)) + m_minYaw;
int anglePitch = (rand() % (m_maxPitch - m_minPitch + 1)) + m_minPitch;
sprintf(buffer, "%i %i 0", anglePitch, angleYaw);
e.AddEPair("angles", buffer);
}
if(m_numModels) {
int treetype = rand() % m_numModels;
e.AddEPair("model", m_trees[treetype].name);
}
if(m_useScale) {
float scale = (((rand()%1000)*0.001f) * (m_maxScale - m_minScale)) + m_minScale;
sprintf(buffer, "%f", scale );
e.AddEPair("modelscale", buffer);
}
e.BuildInRadiant( FALSE );
}
if(m_autoLink) {
DoTrainPathPlot();
}
return true;
}
bool DTreePlanter::OnLButtonUp(guint32 nFlags, gdouble x, gdouble y) {
return false;
}
bool DTreePlanter::OnRButtonDown(guint32 nFlags, gdouble x, gdouble y) {
return false;
}
bool DTreePlanter::OnRButtonUp(guint32 nFlags, gdouble x, gdouble y) {
return false;
}
bool DTreePlanter::OnMButtonDown(guint32 nFlags, gdouble x, gdouble y) {
return false;
}
bool DTreePlanter::OnMButtonUp(guint32 nFlags, gdouble x, gdouble y) {
return false;
}
bool DTreePlanter::FindDropPoint(vec3_t in, vec3_t out) {
DPlane p1;
DPlane p2;
vec3_t vUp = { 0, 0, 1 };
vec3_t vForward = { 0, 1, 0 };
vec3_t vLeft = { 1, 0, 0 };
in[2] = 65535;
VectorCopy(in, p1.points[0]);
VectorCopy(in, p1.points[1]);
VectorCopy(in, p1.points[2]);
VectorMA(p1.points[1], 20, vUp, p1.points[1]);
VectorMA(p1.points[1], 20, vLeft, p1.points[2]);
VectorCopy(in, p2.points[0]);
VectorCopy(in, p2.points[1]);
VectorCopy(in, p2.points[2]);
VectorMA(p1.points[1], 20, vUp, p2.points[1]);
VectorMA(p1.points[1], 20, vForward, p2.points[2]);
p1.Rebuild();
p2.Rebuild();
bool found = false;
vec3_t temp;
vec_t dist;
int cnt = m_world.GetIDMax();
for(int i = 0; i < cnt; i++) {
DBrush* pBrush = m_world.GetBrushForID( i );
if(pBrush->IntersectsWith( &p1, &p2, temp )) {
vec3_t diff;
vec_t tempdist;
VectorSubtract(in, temp, diff);
tempdist = VectorLength( diff );
if(!found || (tempdist < dist)) {
dist = tempdist;
VectorCopy( temp, out );
found = true;
}
}
}
return found;
}
void DTreePlanter::DropEntsToGround( void ) {
#if 0
// tell Radiant we want to access the selected brushes
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
DEntity ent;
int cnt = g_FuncTable.m_pfnSelectedBrushCount();
for(int i = 0; i < cnt; i++) {
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle(i);
ent.LoadFromEntity(brush->owner, TRUE);
DEPair* pEpair = ent.FindEPairByKey("origin");
if(!pEpair) {
continue;
}
vec3_t vec, out;
sscanf( pEpair->value.GetBuffer(), "%f %f %f", &vec[0], &vec[1], &vec[2]);
FindDropPoint( vec, out );
char buffer[256];
sprintf( buffer, "%f %f %f", out[0], out[1], out[2] );
ent.AddEPair( "origin", buffer );
ent.RemoveFromRadiant();
ent.BuildInRadiant(FALSE);
}
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
#endif
}
void DTreePlanter::MakeChain( void ) {
char buffer[256];
int i;
for(i = 0; i < m_linkNum; i++) {
DEntity e("info_train_spline_main");
sprintf( buffer, "%s_pt%i", m_linkName, i );
e.AddEPair( "targetname", buffer );
sprintf( buffer, "0 %i 0", i * 64 );
e.AddEPair( "origin", buffer );
if(i != m_linkNum-1) {
sprintf( buffer, "%s_pt%i", m_linkName, i+1 );
e.AddEPair( "target", buffer );
sprintf( buffer, "%s_ctl%i", m_linkName, i );
e.AddEPair( "control", buffer );
}
e.BuildInRadiant( FALSE );
}
for(i = 0; i < m_linkNum-1; i++) {
DEntity e("info_train_spline_control");
sprintf( buffer, "%s_ctl%i", m_linkName, i );
e.AddEPair( "targetname", buffer );
sprintf( buffer, "0 %i 0", (i * 64) + 32);
e.AddEPair( "origin", buffer );
e.BuildInRadiant( FALSE );
}
}
void DTreePlanter::SelectChain( void ) {
/* char buffer[256];
for(int i = 0; i < m_linkNum; i++) {
DEntity e("info_train_spline_main");
sprintf( buffer, "%s_pt%i", m_linkName, i );
e.AddEPair( "targetname", buffer );
sprintf( buffer, "0 %i 0", i * 64 );
e.AddEPair( "origin", buffer );
if(i != m_linkNum-1) {
sprintf( buffer, "%s_pt%i", m_linkName, i+1 );
e.AddEPair( "target", buffer );
sprintf( buffer, "%s_ctl%i", m_linkName, i );
e.AddEPair( "control", buffer );
}
e.BuildInRadiant( FALSE );
}
for(int i = 0; i < m_linkNum-1; i++) {
DEntity e("info_train_spline_control");
sprintf( buffer, "%s_ctl%i", m_linkName, i );
e.AddEPair( "targetname", buffer );
sprintf( buffer, "0 %i 0", (i * 64) + 32);
e.AddEPair( "origin", buffer );
e.BuildInRadiant( FALSE );
}*/
}

View File

@@ -0,0 +1,219 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __DTREE_H__
#define __DTREE_H__
#define MAX_QPATH 64
typedef struct treeModel_s {
char name[MAX_QPATH];
} treeModel_t;
#define MAX_TP_MODELS 256
class DTreePlanter : public IWindowListener {
public:
virtual bool OnMouseMove(guint32 nFlags, gdouble x, gdouble y);
virtual bool OnLButtonDown(guint32 nFlags, gdouble x, gdouble y);
virtual bool OnMButtonDown(guint32 nFlags, gdouble x, gdouble y);
virtual bool OnRButtonDown(guint32 nFlags, gdouble x, gdouble y);
virtual bool OnLButtonUp(guint32 nFlags, gdouble x, gdouble y);
virtual bool OnMButtonUp(guint32 nFlags, gdouble x, gdouble y);
virtual bool OnRButtonUp(guint32 nFlags, gdouble x, gdouble y);
virtual bool OnKeyPressed(char *s) { return false; }
virtual bool Paint() { return true; }
virtual void Close() { }
DTreePlanter() {
m_refCount = 1;
m_hooked = false;
m_XYWrapper = NULL;
m_numModels = 0;
m_offset = 0;
m_maxPitch = 0;
m_minPitch = 0;
m_maxYaw = 0;
m_minYaw = 0;
m_setAngles = false;
m_useScale = false;
m_autoLink = false;
m_linkNum = 0;
Register();
m_world.LoadSelectedBrushes();
char buffer[256];
GetFilename( buffer, "bt/tp_ent.txt" );
FILE* file = fopen( buffer, "rb" );
if(file) {
fseek( file, 0, SEEK_END );
int len = ftell( file );
fseek( file, 0, SEEK_SET );
if(len) {
char* buf = new char[len+1];
buf[len] = '\0';
// parser will do the cleanup, dont delete.
fread( buf, len, 1, file );
CScriptParser parser;
parser.SetScript( buf );
ReadConfig( &parser );
}
fclose( file );
}
}
#define MT(t) !stricmp( pToken, t )
#define GT pToken = pScriptParser->GetToken( true )
#define CT if(!*pToken) { return; }
void ReadConfig( CScriptParser* pScriptParser ) {
const char* GT;
CT;
do {
GT;
if(*pToken == '}') {
break;
}
if(MT("model")) {
if(m_numModels >= MAX_TP_MODELS) {
return;
}
GT; CT;
strncpy( m_trees[m_numModels++].name, pToken, MAX_QPATH );
} else if(MT("link")) {
GT; CT;
strncpy( m_linkName, pToken, MAX_QPATH );
m_autoLink = true;
} else if(MT("entity")) {
GT; CT;
strncpy( m_entType, pToken, MAX_QPATH );
} else if(MT("offset")) {
GT; CT;
m_offset = atoi(pToken);
} else if(MT("pitch")) {
GT; CT;
m_minPitch = atoi(pToken);
GT; CT;
m_maxPitch = atoi(pToken);
m_setAngles = true;
} else if(MT("yaw")) {
GT; CT;
m_minYaw = atoi(pToken);
GT; CT;
m_maxYaw = atoi(pToken);
m_setAngles = true;
} else if(MT("scale")) {
GT; CT;
m_minScale = static_cast<float>(atof(pToken));
GT; CT;
m_maxScale = static_cast<float>(atof(pToken));
m_useScale = true;
} else if(MT("numlinks")) {
GT; CT;
m_linkNum = atoi( pToken );
}
} while( true );
}
virtual ~DTreePlanter() {
UnRegister();
}
virtual void IncRef() { m_refCount++; }
virtual void DecRef() { m_refCount--; if (m_refCount <= 0) delete this; }
void Register() {
if(!m_hooked) {
g_MessageTable.m_pfnHookWindow( this );
m_XYWrapper = g_MessageTable.m_pfnGetXYWndWrapper();
m_hooked = true;
}
}
void UnRegister() {
if(m_hooked) {
g_MessageTable.m_pfnUnHookWindow( this );
m_XYWrapper = NULL;
m_hooked = false;
}
}
bool FindDropPoint(vec3_t in, vec3_t out);
void DropEntsToGround( void );
void MakeChain( void );
void SelectChain( void );
private:
IXYWndWrapper* m_XYWrapper;
DEntity m_world;
treeModel_t m_trees[MAX_TP_MODELS];
int m_refCount;
int m_numModels;
int m_offset;
int m_maxPitch;
int m_minPitch;
int m_maxYaw;
int m_minYaw;
char m_entType[MAX_QPATH];
char m_linkName[MAX_QPATH];
int m_linkNum;
float m_minScale;
float m_maxScale;
bool m_hooked;
bool m_useScale;
bool m_setAngles;
bool m_autoLink;
};
#endif

View File

@@ -0,0 +1,185 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// BobView.cpp: implementation of the DVisDrawer class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "gtkr_list.h"
#include "str.h"
#include "DPoint.h"
#include "DWinding.h"
#include "DVisDrawer.h"
#include "misc.h"
#include "funchandlers.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DVisDrawer::DVisDrawer()
{
refCount = 1;
m_bHooked = FALSE;
m_list = NULL;
}
DVisDrawer::~DVisDrawer()
{
if(m_bHooked)
UnRegister();
g_VisView = NULL;
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
void DVisDrawer::Draw2D(VIEWTYPE vt)
{
if(!m_list)
return;
__QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
__QGLTABLENAME.m_pfn_qglDisable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglDisable(GL_LINE_SMOOTH);
__QGLTABLENAME.m_pfn_qglPushMatrix();
switch(vt)
{
case XY:
break;
case XZ:
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
break;
case YZ:
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
__QGLTABLENAME.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
break;
}
__QGLTABLENAME.m_pfn_qglLineWidth(1.0f);
__QGLTABLENAME.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 0.5f);
__QGLTABLENAME.m_pfn_qglEnable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
__QGLTABLENAME.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
__QGLTABLENAME.m_pfn_qglDepthFunc(GL_ALWAYS);
//bleh
list<DWinding *>::const_iterator l=m_list->begin();
for(; l != m_list->end(); l++)
{
DWinding* w = *l;
__QGLTABLENAME.m_pfn_qglColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);
__QGLTABLENAME.m_pfn_qglBegin(GL_POLYGON);
for(int i = 0; i < w->numpoints; i++) {
__QGLTABLENAME.m_pfn_qglVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);
}
__QGLTABLENAME.m_pfn_qglEnd();
}
__QGLTABLENAME.m_pfn_qglPopMatrix();
__QGLTABLENAME.m_pfn_qglPopAttrib();
}
void DVisDrawer::Draw3D()
{
if(!m_list)
return;
__QGLTABLENAME.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
__QGLTABLENAME.m_pfn_qglColor4f(1.0, 0.0, 0.0, 0.5f);
// __QGLTABLENAME.m_pfn_qglHint(GL_FOG_HINT, GL_NICEST);
// __QGLTABLENAME.m_pfn_qglDisable(GL_CULL_FACE);
__QGLTABLENAME.m_pfn_qglDisable(GL_LINE_SMOOTH);
// __QGLTABLENAME.m_pfn_qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// __QGLTABLENAME.m_pfn_qglShadeModel(GL_SMOOTH);
__QGLTABLENAME.m_pfn_qglEnable(GL_BLEND);
__QGLTABLENAME.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
__QGLTABLENAME.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
__QGLTABLENAME.m_pfn_qglDepthFunc(GL_ALWAYS);
//bleh
list<DWinding *>::const_iterator l=m_list->begin();
for(; l != m_list->end(); l++)
{
DWinding* w = *l;
__QGLTABLENAME.m_pfn_qglColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);
__QGLTABLENAME.m_pfn_qglBegin(GL_POLYGON);
for(int i = 0; i < w->numpoints; i++) {
__QGLTABLENAME.m_pfn_qglVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);
}
__QGLTABLENAME.m_pfn_qglEnd();
}
__QGLTABLENAME.m_pfn_qglPopAttrib();
}
void DVisDrawer::Register()
{
__QGLTABLENAME.m_pfnHookGL2DWindow( this );
__QGLTABLENAME.m_pfnHookGL3DWindow( this );
m_bHooked = TRUE;
}
void DVisDrawer::UnRegister()
{
__QGLTABLENAME.m_pfnUnHookGL2DWindow( this );
__QGLTABLENAME.m_pfnUnHookGL3DWindow( this );
m_bHooked = FALSE;
}
void DVisDrawer::SetList(std::list<DWinding*> *pointList)
{
if(m_list)
ClearPoints();
m_list = pointList;
}
void DVisDrawer::ClearPoints()
{
list<DWinding *>::const_iterator deadPoint=m_list->begin();
for(; deadPoint!=m_list->end(); deadPoint++)
delete *deadPoint;
m_list->clear();
}

View File

@@ -0,0 +1,56 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DBobView.h: interface for the DBobView class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VISDRAWER_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_VISDRAWER_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class DVisDrawer :
public IGL2DWindow,
public IGL3DWindow
{
public:
DVisDrawer();
virtual ~DVisDrawer();
protected:
list<DWinding*>* m_list;
int refCount;
public:
void ClearPoints();
void SetList(list<DWinding*>* pointList);
void UnRegister();
void Register();
void Draw3D();
void Draw2D(VIEWTYPE vt);
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
bool m_bHooked;
};
#endif // !defined(AFX_VISDRAWER_H__6E36062A_EF0B_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,486 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DWinding.cpp: implementation of the DWinding class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "gtkr_list.h"
#include "DPoint.h"
#include "DWinding.h"
#include "DPlane.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DWinding::DWinding()
{
numpoints = 0;
p = NULL;
}
DWinding::~DWinding()
{
if(p)
delete[] p;
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
#define BOGUS_RANGE 4096
void DWinding::AllocWinding(int points)
{
numpoints = points;
if(p)
delete[] p;
p = new vec3_t[points];
}
vec_t DWinding::WindingArea()
{
vec3_t d1, d2, cross;
vec_t total;
total = 0;
for (int i = 2; i < numpoints ; i++)
{
VectorSubtract (p[i-1], p[0], d1);
VectorSubtract (p[i], p[0], d2);
CrossProduct (d1, d2, cross);
total += 0.5f * VectorLength ( cross );
}
return total;
}
void DWinding::RemoveColinearPoints()
{
vec3_t p2[MAX_POINTS_ON_WINDING];
int nump = 0;
for (int i = 0; i < numpoints; i++)
{
int j = (i+1)%numpoints;
int k = (i+numpoints-1)%numpoints;
vec3_t v1, v2;
VectorSubtract (p[j], p[i], v1);
VectorSubtract (p[i], p[k], v2);
VectorNormalize(v1, v1);
VectorNormalize(v2, v2);
if (DotProduct(v1, v2) < 0.999)
{
VectorCopy (p[i], p2[nump]);
nump++;
}
}
if (nump == numpoints)
return;
AllocWinding(nump);
memcpy (p, p2, nump*sizeof(vec3_t));
}
DPlane* DWinding::WindingPlane()
{
DPlane* newPlane = new DPlane(p[0], p[1], p[2], NULL);
return newPlane;
}
void DWinding::WindingBounds(vec3_t mins, vec3_t maxs)
{
if(numpoints == 0)
return;
VectorCopy(mins, p[0]);
VectorCopy(maxs, p[0]);
for (int i = 1; i < numpoints ;i++)
{
for (int j = 0; j < 3; j++)
{
vec_t v = p[i][j];
if (v < mins[j])
mins[j] = v;
if (v > maxs[j])
maxs[j] = v;
}
}
}
void DWinding::WindingCentre(vec3_t centre)
{
VectorCopy (vec3_origin, centre);
for (int i = 0; i < numpoints; i++)
VectorAdd (p[i], centre, centre);
float scale = 1.0f/numpoints;
VectorScale (centre, scale, centre);
}
DWinding* DWinding::CopyWinding()
{
DWinding* c = new DWinding;
c->AllocWinding(numpoints);
memcpy (c->p, p, numpoints*sizeof(vec3_t));
return c;
}
int DWinding::WindingOnPlaneSide(vec3_t normal, vec_t dist)
{
bool front = FALSE;
bool back = FALSE;
for (int i = 0; i < numpoints; i++)
{
vec_t d = DotProduct (p[i], normal) - dist;
if (d < -ON_EPSILON)
{
if (front)
return SIDE_CROSS;
back = TRUE;
continue;
}
if (d > ON_EPSILON)
{
if (back)
return SIDE_CROSS;
front = TRUE;
continue;
}
}
if (back)
return SIDE_BACK;
if (front)
return SIDE_FRONT;
return SIDE_ON;
}
void DWinding::CheckWinding()
{
vec_t *p1, *p2;
vec_t edgedist;
vec3_t dir, edgenormal;
if (numpoints < 3)
Sys_Printf ("CheckWinding: %i points", numpoints);
vec_t area = WindingArea();
if (area < 1)
Sys_Printf ("CheckWinding: %f area", area);
DPlane* wPlane = WindingPlane ();
int i;
for (i = 0; i < numpoints; i++)
{
p1 = p[i];
int j;
for (j = 0; j < 3; j++)
if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE)
Sys_Printf ("CheckFace: BUGUS_RANGE: %f", p1[j]);
j = i + 1 == numpoints ? 0 : i + 1;
// check the point is on the face plane
vec_t d = DotProduct (p1, wPlane->normal) - wPlane->_d;
if (d < -ON_EPSILON || d > ON_EPSILON)
Sys_Printf ("CheckWinding: point off plane");
// check the edge isnt degenerate
p2 = p[j];
VectorSubtract (p2, p1, dir);
if (VectorLength (dir) < ON_EPSILON)
Sys_Printf ("CheckWinding: degenerate edge");
CrossProduct (wPlane->normal, dir, edgenormal);
VectorNormalize (edgenormal, edgenormal);
edgedist = DotProduct (p1, edgenormal);
// all other points must be on front side
for (j = 0 ; j < numpoints ; j++)
{
if (j == i)
continue;
d = DotProduct (p[j], edgenormal);
if (d > (edgedist + ON_EPSILON))
Sys_Printf ("CheckWinding: non-convex");
}
}
delete wPlane;
}
DWinding* DWinding::ReverseWinding()
{
DWinding* c = new DWinding;
c->AllocWinding(numpoints);
for (int i = 0; i < numpoints ; i++)
VectorCopy (p[numpoints-1-i], c->p[i]);
return c;
}
bool DWinding::ChopWindingInPlace(DPlane* chopPlane, vec_t epsilon)
{
vec_t dists[MAX_POINTS_ON_WINDING+4];
int sides[MAX_POINTS_ON_WINDING+4];
int counts[3];
vec_t *p1, *p2;
vec3_t mid;
counts[0] = counts[1] = counts[2] = 0;
// determine sides for each point
int i;
for (i = 0; i < numpoints; i++)
{
vec_t dot = DotProduct (p[i], chopPlane->normal);
dot -= chopPlane->_d;
dists[i] = dot;
if (dot > epsilon)
sides[i] = SIDE_FRONT;
else if (dot < -epsilon)
sides[i] = SIDE_BACK;
else
sides[i] = SIDE_ON;
counts[sides[i]]++;
}
sides[i] = sides[0];
dists[i] = dists[0];
if (!counts[0])
{
delete this;
return FALSE;
}
if (!counts[1])
return TRUE;
int maxpts = numpoints+4; // cant use counts[0]+2 because
// of fp grouping errors
DWinding* f = new DWinding;
f->AllocWinding(maxpts);
f->numpoints = 0;
for (i = 0; i < numpoints; i++)
{
p1 = p[i];
if (sides[i] == SIDE_ON)
{
VectorCopy (p1, f->p[f->numpoints]);
f->numpoints++;
continue;
}
if (sides[i] == SIDE_FRONT)
{
VectorCopy (p1, f->p[f->numpoints]);
f->numpoints++;
}
if (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])
continue;
// generate a split point
p2 = p[(i+1)%numpoints];
vec_t dot = dists[i] / (dists[i]-dists[i+1]);
for (int j = 0; j < 3; j++)
{
if (chopPlane->normal[j] == 1)
mid[j] = chopPlane->_d;
else if (chopPlane->normal[j] == -1)
mid[j] = -chopPlane->_d;
else
mid[j] = p1[j] + dot*(p2[j]-p1[j]);
}
VectorCopy (mid, f->p[f->numpoints]);
f->numpoints++;
}
if (f->numpoints > maxpts)
Sys_Printf ("ClipWinding: points exceeded estimate");
if (f->numpoints > MAX_POINTS_ON_WINDING)
Sys_Printf ("ClipWinding: MAX_POINTS_ON_WINDING");
delete[] p;
p = f->p;
f->p = NULL;
delete f;
return TRUE;
}
void DWinding::ClipWindingEpsilon(DPlane* chopPlane, vec_t epsilon, DWinding **front, DWinding **back)
{
vec_t dists[MAX_POINTS_ON_WINDING+4];
int sides[MAX_POINTS_ON_WINDING+4];
int counts[3];
vec_t *p1, *p2;
vec3_t mid;
counts[0] = counts[1] = counts[2] = 0;
// determine sides for each point
int i;
for (i = 0; i < numpoints; i++)
{
vec_t dot = -chopPlane->DistanceToPoint(p[i]);
dists[i] = dot;
if (dot > epsilon)
sides[i] = SIDE_FRONT;
else if (dot < -epsilon)
sides[i] = SIDE_BACK;
else
sides[i] = SIDE_ON;
counts[sides[i]]++;
}
sides[i] = sides[0];
dists[i] = dists[0];
*front = *back = NULL;
if (!counts[0])
{
*back = CopyWinding();
return;
}
if (!counts[1])
{
*front = CopyWinding();
return;
}
int maxpts = numpoints+4; // cant use counts[0]+2 because
// of fp grouping errors
DWinding* f = new DWinding;
DWinding* b = new DWinding;
f->AllocWinding(maxpts);
f->numpoints = 0;
b->AllocWinding(maxpts);
b->numpoints = 0;
*front = f;
*back = b;
for (i = 0; i < numpoints ; i++)
{
p1 = p[i];
if (sides[i] == SIDE_ON)
{
VectorCopy (p1, f->p[f->numpoints]);
f->numpoints++;
VectorCopy (p1, b->p[b->numpoints]);
b->numpoints++;
continue;
}
if (sides[i] == SIDE_FRONT)
{
VectorCopy (p1, f->p[f->numpoints]);
f->numpoints++;
}
if (sides[i] == SIDE_BACK)
{
VectorCopy (p1, b->p[b->numpoints]);
b->numpoints++;
}
if (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])
continue;
// generate a split point
p2 = p[(i+1)%numpoints];
vec_t dot = dists[i] / (dists[i]-dists[i+1]);
for (int j = 0; j < 3; j++)
{
if (chopPlane->normal[j] == 1)
mid[j] = chopPlane->_d;
else if (chopPlane->normal[j] == -1)
mid[j] = -chopPlane->_d;
else
mid[j] = p1[j] + dot*(p2[j]-p1[j]);
}
VectorCopy (mid, f->p[f->numpoints]);
f->numpoints++;
VectorCopy (mid, b->p[b->numpoints]);
b->numpoints++;
}
if (f->numpoints > maxpts || b->numpoints > maxpts)
Sys_Printf ("ClipWinding: points exceeded estimate");
if (f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING)
Sys_Printf ("ClipWinding: MAX_POINTS_ON_WINDING");
}
bool DWinding::ChopWinding(DPlane* chopPlane)
{
DWinding *f, *b;
ClipWindingEpsilon (chopPlane, (float)ON_EPSILON, &f, &b);
if (b)
delete (b);
if(!f)
{
delete this;
return FALSE;
}
delete[] p;
p = f->p;
f->p = NULL;
numpoints = f->numpoints;
delete f;
return TRUE;
}

View File

@@ -0,0 +1,68 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DWinding.h: interface for the DWinding class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DWINDING_H__35B2C524_F0A7_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_DWINDING_H__35B2C524_F0A7_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class DPlane;
class DWinding
{
public:
DWinding();
virtual ~DWinding();
void AllocWinding(int points);
bool ChopWinding(DPlane* chopPlane);
bool ChopWindingInPlace(DPlane* chopPlane, vec_t ON_EPSILON);
void ClipWindingEpsilon(DPlane* chopPlane, vec_t epsilon, DWinding** front, DWinding** back);
void CheckWinding();
void WindingCentre(vec3_t centre);
void WindingBounds(vec3_t mins, vec3_t maxs);
void RemoveColinearPoints();
DWinding* ReverseWinding();
DWinding* CopyWinding();
DPlane* WindingPlane();
int WindingOnPlaneSide(vec3_t normal, vec_t dist);
vec_t WindingArea();
// members
int numpoints;
vec3_t* p;
vec3_t clr;
};
#define MAX_POINTS_ON_WINDING 64
#define ON_EPSILON 0.01
#endif // !defined(AFX_DWINDING_H__35B2C524_F0A7_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,286 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "ScriptParser.h"
CScriptParser::CScriptParser(void):
m_pScript(NULL),
m_pScriptSection(NULL),
m_pLastScriptSection(NULL),
m_pToken(NULL) {
ClearBuffer();
}
CScriptParser::~CScriptParser(void) {
ClearBuffer();
}
void CScriptParser::ClearBuffer(void) {
if(m_pScript) {
delete[] m_pScript;
m_pScript = NULL;
}
if(m_pToken) {
delete[] m_pToken;
m_pToken = NULL;
}
m_pScriptSection = NULL;
m_pLastScriptSection = NULL;
memset(m_breakChars, 0, sizeof(m_breakChars));
}
const char* CScriptParser::MakeToken(const char* pToken) {
if(m_pToken) {
delete[] m_pToken;
m_pToken = NULL;
}
if(!pToken) {
pToken = "";
}
int len = static_cast<int>(strlen(pToken));
m_pToken = new char[len + 1];
m_pToken[len] = '\0';
strcpy(m_pToken, pToken);
return m_pToken;
}
#define MAX_TOKEN_STRING 1024
// Should NEVER return NULL
const char* CScriptParser::GetToken(bool bAllowLinebreaks) {
int c = 0, len;
char token[MAX_TOKEN_STRING];
bool bNewLines = false;
m_pLastScriptSection = m_pScriptSection;
len = 0;
*token = '\0';
if(!m_pScript || !m_pScriptSection) {
return MakeToken(token);
}
while ( true ) {
SkipWhitespace( &bNewLines );
if ( !*m_pScriptSection ) {
return MakeToken(token);
}
if ( bNewLines && !bAllowLinebreaks ) {
return MakeToken(token);
}
c = *m_pScriptSection;
if ( c == '/' && m_pScriptSection[1] == '/' ) { // C style comments
m_pScriptSection += 2;
while (*m_pScriptSection && *m_pScriptSection != '\n') {
m_pScriptSection++;
}
} else if ( c=='/' && m_pScriptSection[1] == '*' ) { // C++ style comments
m_pScriptSection += 2;
while ( *m_pScriptSection && ( *m_pScriptSection != '*' || m_pScriptSection[1] != '/' ) ) {
m_pScriptSection++;
}
if ( *m_pScriptSection ) {
m_pScriptSection += 2;
}
} else {
break;
}
}
if (c == '\"') {
m_pScriptSection++;
while ( true ) {
c = *m_pScriptSection++;
if (c=='\"' || !c) {
token[len] = 0;
return MakeToken(token);
}
if (len < MAX_TOKEN_STRING) {
token[len] = c;
len++;
}
}
}
do {
if(len > 0 && IsBreakChar(*m_pScriptSection)) {
break;
}
if (len < MAX_TOKEN_STRING) {
token[len] = c;
len++;
}
m_pScriptSection++;
if(IsBreakChar(c)) {
break;
}
c = *m_pScriptSection;
} while (c > 32);
if (len == MAX_TOKEN_STRING) {
len = 0;
}
token[len] = 0;
return MakeToken(token);
}
void CScriptParser::SkipWhitespace(bool* pbNewLines) {
int c;
if(!m_pScript || !m_pScriptSection) {
return;
}
while( (c = *m_pScriptSection) <= ' ') {
if( !c ) {
return;
}
if( c == '\n' ) {
*pbNewLines = true;
}
m_pScriptSection++;
}
}
void CScriptParser::SkipBracedSection(void) {
const char *token;
int depth;
depth = 0;
do {
token = GetToken( true );
if( token[1] == 0 ) {
if( *token == '{' ) {
depth++;
} else if( *token == '}' ) {
depth--;
}
}
} while( depth && *m_pScriptSection );
}
void CScriptParser::SkipRestOfLine(void) {
char *p;
int c;
p = m_pScriptSection;
while ( (c = *p++) != 0 ) {
if ( c == '\n' ) {
break;
}
}
m_pScriptSection = p;
}
void CScriptParser::UndoGetToken(void) {
if(!m_pLastScriptSection) {
return;
}
m_pScriptSection = m_pLastScriptSection;
m_pLastScriptSection = NULL;
}
void CScriptParser::ResetParseSession(void) {
if(!m_pScript) {
return;
}
m_pScriptSection = m_pScript;
m_pLastScriptSection = NULL;
}
char* CScriptParser::GetBufferCopy(void) {
if(!m_pScript) {
return NULL;
}
int len = static_cast<int>(strlen(m_pScript));
char* pBuffer = new char[len + 1];
strcpy(pBuffer, m_pScript);
return pBuffer;
}
int CScriptParser::GetTokenOffset(void) {
if(!m_pScript || !m_pScriptSection) {
return 0;
}
return static_cast<int>(m_pScriptSection - m_pScript);
}
void CScriptParser::LoadScript(const char* pScript) {
ClearBuffer();
int len = static_cast<int>(strlen(pScript));
if(len <= 0) {
return;
}
m_pScript = new char[len + 1];
m_pScript[len] = '\0';
strcpy(m_pScript, pScript);
m_pScriptSection = m_pScript;
}
void CScriptParser::AddBreakChar(char c) {
for(int i = 0; i < SP_MAX_BREAKCHARS; i++) {
if(!m_breakChars[i]) {
m_breakChars[i] = c;
return;
}
}
// TODO: Error: max break chars hit
}
bool CScriptParser::IsBreakChar(char c) {
for(int i = 0; i < SP_MAX_BREAKCHARS; i++) {
if(!m_breakChars[i]) {
return false;
}
if(m_breakChars[i] == c) {
return true;
}
}
return false;
}
void CScriptParser::SetScript(char* pScript) {
ClearBuffer();
int len = static_cast<int>(strlen(pScript));
if(len <= 0) {
return;
}
m_pScript = pScript;
m_pScriptSection = m_pScript;
}

View File

@@ -0,0 +1,61 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _SCRIPTPARSER_H_
#define _SCRIPTPARSER_H_
//#include "interfaces/IScriptParser.h"
#define SP_MAX_BREAKCHARS 16
class CScriptParser //: public IScriptParser
{
public:
CScriptParser(void);
~CScriptParser(void);
private:
char m_breakChars[SP_MAX_BREAKCHARS];
char* m_pScript;
char* m_pScriptSection;
char* m_pLastScriptSection;
char* m_pToken;
void SkipWhitespace(bool* pbNewLines);
void ClearBuffer(void);
const char* MakeToken(const char* pToken);
bool IsBreakChar(char c);
public:
const char* GetToken(bool bAllowLinebreaks);
void SkipBracedSection(void);
void SkipRestOfLine(void);
void UndoGetToken(void);
void ResetParseSession(void);
char* GetBufferCopy(void);
int GetTokenOffset(void);
void LoadScript(const char* pScript);
void SetScript(char* pScript);
void AddBreakChar(char c);
private:
};
#endif

View File

@@ -0,0 +1,25 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// stdafx.cpp : source file that includes just the standard includes
// plugin.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "StdAfx.h"

141
contrib/bobtoolz/StdAfx.h Normal file
View File

@@ -0,0 +1,141 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __STDAFX_BOBTOOLZ__
#define __STDAFX_BOBTOOLZ__
#define BOBTOOLZ_MINOR "bobtoolz"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#define NAME_MAX 255
#if defined (__linux__) || defined (__APPLE__)
#include <GL/glx.h>
typedef void* HMODULE;
typedef void* LPVOID;
typedef char* LPCSTR;
//typedef int bool;
#define WINAPI
#define APIENTRY
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
#define stricmp strcasecmp
#endif
#if defined(__cplusplus)
#ifndef _REFGUID_DEFINED
#define _REFGUID_DEFINED
#define REFGUID const GUID &
#endif // !_REFGUID_DEFINED
#endif
typedef struct tagRECT
{
long left;
long top;
long right;
long bottom;
} RECT, *PRECT, *LPRECT;
typedef uint UINT;
#endif // __linux__
#include "mathlib.h"
#include <string.h>
#include "qertypes.h"
#include <stdio.h>
#define USE_SCENEGRAPHTABLE_DEFINE
#include "iscenegraph.h"
#define USE_QERTABLE_DEFINE
#include "qerplugin.h"
extern _QERFuncTable_1 __QERTABLENAME;
#define USE_ENTITYTABLE_DEFINE
#include "ientity.h"
extern _QEREntityTable __ENTITYTABLENAME;
#define USE_BRUSHTABLE_DEFINE
#include "ibrush.h"
extern _QERBrushTable __BRUSHTABLENAME;
#define USE_PATCHTABLE_DEFINE
#include "ipatch.h"
extern _QERPatchTable __PATCHTABLENAME;
#define USE_SHADERSTABLE_DEFINE
#include "ishaders.h"
extern _QERShadersTable __SHADERSTABLENAME;
#define USE_QGLTABLE_DEFINE
#include "igl.h"
extern _QERQglTable __QGLTABLENAME;
#include "ibspfrontend.h"
extern _QERAppBSPFrontendTable g_BSPTable;
#include "iui.h"
extern _QERUITable g_MessageTable;
#define USE_RENDERTABLE_DEFINE
#include "irender.h"
#define USE_SELECTIONTABLE_DEFINE
#include "iselection.h"
#include "itoolbar.h"
#include "iplugin.h"
#define MAX_ROUND_ERROR 0.05
#include "itexdef.h"
struct _QERFaceData
{
vec3_t m_p0;
vec3_t m_p1;
vec3_t m_p2;
texdef_t m_texdef;
};
#endif

View File

@@ -0,0 +1,298 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "libxml/parser.h"
#include "StdAfx.h"
#include "str.h"
//#include "gtkr_list.h"
#include "funchandlers.h"
//#include "misc.h"
#include "dialogs/dialogs-gtk.h"
#include "../../libs/cmdlib.h"
// Radiant function table
_QERFuncTable_1 __QERTABLENAME;
_QERShadersTable __SHADERSTABLENAME; // vvvvvvvvvvvvvvvvvvvv
_QERQglTable __QGLTABLENAME; // for path plotting (hooking to DBobView)
_QERUITable g_MessageTable; // for path plotting (listening for update)
_QEREntityTable __ENTITYTABLENAME;
_QERBrushTable __BRUSHTABLENAME;
_QERPatchTable __PATCHTABLENAME;
// plugin name
char* PLUGIN_NAME = "bobToolz";
// commands in the menu
static char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Turn edge";
// globals
GtkWidget *g_pRadiantWnd = NULL;
static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n"
"by digibob (digibob@splashdamage.com)\n"
"http://www.splashdamage.com\n\n"
"Additional Contributors:\n"
"MarsMattel, RR2DO2\n";
extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) {
g_pRadiantWnd = (GtkWidget*)pMainWidget;
return "bobToolz for GTKradiant";
}
extern "C" const char* QERPlug_GetName() {
return PLUGIN_NAME;
}
extern "C" const char* QERPlug_GetCommandList() {
return PLUGIN_COMMANDS;
}
extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush) {
LoadLists();
if( !stricmp( p, "brush cleanup" ) ) {
DoFixBrushes();
} else if( !stricmp( p, "polygon builder" ) ) {
DoPolygonsTB();
} else if( !stricmp( p, "caulk selection" ) ) {
DoCaulkSelection();
} else if( !stricmp( p, "tree planter" ) ) {
DoTreePlanter();
} else if( !stricmp( p, "plot splines" ) ) {
DoTrainPathPlot();
} else if( !stricmp( p, "drop entity" ) ) {
DoDropEnts();
} else if( !stricmp( p, "merge patches" ) ) {
DoMergePatches();
} else if( !stricmp( p, "split patches" ) ) {
DoSplitPatch();
} else if( !stricmp( p, "turn edge" ) ) {
DoFlipTerrain();
} else if( !stricmp(p, "reset textures...") ) {
DoResetTextures();
} else if( !stricmp(p, "pitomatic") ) {
DoPitBuilder();
} else if( !stricmp(p, "vis viewer") ) {
DoVisAnalyse();
} else if( !stricmp(p, "about...") ) {
DoMessageBox(PLUGIN_ABOUT, "About", eMB_OK);
}
}
#define NUM_TOOLBARBUTTONS 9
unsigned int ToolbarButtonCount( void ) {
return NUM_TOOLBARBUTTONS;
}
// Load a xpm file and return a pixmap widget.
GtkWidget* new_pixmap (char* filename) {
GdkPixmap *gdkpixmap;
GdkBitmap *mask;
GtkWidget *pixmap;
g_FuncTable.m_pfnLoadBitmap(filename, (void **)&gdkpixmap, (void **)&mask);
pixmap = gtk_pixmap_new (gdkpixmap, mask);
gdk_pixmap_unref (gdkpixmap);
gdk_pixmap_unref (mask);
return pixmap;
}
class CBobtoolzToolbarButton : public IToolbarButton
{
public:
virtual const char* getImage() const
{
switch( mIndex ) {
case 0: return "bobtoolz_cleanup.bmp";
case 1: return "bobtoolz_poly.bmp";
case 2: return "bobtoolz_caulk.bmp";
case 3: return "bobtoolz_treeplanter.bmp";
case 4: return "bobtoolz_trainpathplot.bmp";
case 5: return "bobtoolz_dropent.bmp";
case 6: return "bobtoolz_merge.bmp";
case 7: return "bobtoolz_split.bmp";
case 8: return "bobtoolz_turnedge.bmp";
}
return NULL;
}
virtual EType getType() const
{
switch( mIndex ) {
case 3: return eToggleButton;
default: return eButton;
}
}
virtual const char* getText() const
{
switch( mIndex ) {
case 0: return "Cleanup";
case 1: return "Polygons";
case 2: return "Caulk";
case 3: return "Tree Planter";
case 4: return "Plot Splines";
case 5: return "Drop Entity";
case 6: return "Merge Patches";
case 7: return "Split Patches";
case 8: return "Flip Terrain";
}
return NULL;
}
virtual const char* getTooltip() const
{
switch( mIndex ) {
case 0: return "Brush Cleanup";
case 1: return "Polygons";
case 2: return "Caulk selection";
case 3: return "Tree Planter";
case 4: return "Plot Splines";
case 5: return "Drop Entity";
case 6: return "Merge Patches";
case 7: return "Split Patches";
case 8: return "Flip Terrain";
}
return NULL;
}
virtual void activate() const
{
LoadLists();
switch( mIndex ) {
case 0: DoFixBrushes(); break;
case 1: DoPolygonsTB(); break;
case 2: DoCaulkSelection(); break;
case 3: DoTreePlanter(); break;
case 4: DoTrainPathPlot(); break;
case 5: DoDropEnts(); break;
case 6: DoMergePatches(); break;
case 7: DoSplitPatch(); break;
case 8: DoFlipTerrain(); break;
}
}
int mIndex;
};
CBobtoolzToolbarButton g_bobtoolzToolbarButtons[NUM_TOOLBARBUTTONS];
const IToolbarButton* GetToolbarButton(unsigned int index)
{
g_bobtoolzToolbarButtons[index].mIndex = index;
return &g_bobtoolzToolbarButtons[index];
}
// =============================================================================
// SYNAPSE
#include "synapse.h"
class CSynapseClientBobtoolz : public CSynapseClient
{
public:
// CSynapseClient API
bool RequestAPI(APIDescriptor_t *pAPI);
const char* GetInfo();
CSynapseClientBobtoolz() { }
virtual ~CSynapseClientBobtoolz() { }
};
CSynapseServer* g_pSynapseServer = NULL;
CSynapseClientBobtoolz g_SynapseClient;
extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
{
if (strcmp(version, SYNAPSE_VERSION))
{
Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
return NULL;
}
g_pSynapseServer = pServer;
g_pSynapseServer->IncRef();
Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
g_SynapseClient.AddAPI(TOOLBAR_MAJOR, BOBTOOLZ_MINOR, sizeof(_QERPlugToolbarTable));
g_SynapseClient.AddAPI(PLUGIN_MAJOR, BOBTOOLZ_MINOR, sizeof(_QERPluginTable));
g_SynapseClient.AddAPI(BRUSH_MAJOR, NULL, sizeof(__BRUSHTABLENAME), SYN_REQUIRE, &g_BrushTable);
g_SynapseClient.AddAPI(PATCH_MAJOR, NULL, sizeof(__PATCHTABLENAME), SYN_REQUIRE, &g_BrushTable);
g_SynapseClient.AddAPI(SHADERS_MAJOR, "*", sizeof(g_ShadersTable), SYN_REQUIRE, &g_ShadersTable);
g_SynapseClient.AddAPI(ENTITY_MAJOR, NULL, sizeof(g_EntityTable), SYN_REQUIRE, &g_EntityTable);
g_SynapseClient.AddAPI(SELECTEDFACE_MAJOR, NULL, sizeof(g_SelectedFaceTable), SYN_REQUIRE, &g_SelectedFaceTable);
g_SynapseClient.AddAPI(UI_MAJOR, NULL, sizeof(g_MessageTable), SYN_REQUIRE, &g_MessageTable);
g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(__QERTABLENAME), SYN_REQUIRE, &g_FuncTable);
g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
return &g_SynapseClient;
}
bool CSynapseClientBobtoolz::RequestAPI(APIDescriptor_t *pAPI)
{
if( !strcmp(pAPI->minor_name, BOBTOOLZ_MINOR) )
{
if( !strcmp(pAPI->major_name, PLUGIN_MAJOR) )
{
_QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
pTable->m_pfnQERPlug_Init = QERPlug_Init;
pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
return true;
}
else if( !strcmp(pAPI->major_name, TOOLBAR_MAJOR) )
{
_QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
pTable->m_pfnGetToolbarButton = &GetToolbarButton;
return true;
}
}
Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
return false;
}
#include "version.h"
const char* CSynapseClientBobtoolz::GetInfo()
{
return "bobToolz module built " __DATE__ " " RADIANT_VERSION;
}
char* GetFilename(char* buffer, const char* filename) {
strcpy(buffer, g_pSynapseServer->GetModuleFilename(&g_SynapseClient));
StripFilename( buffer );
strcat(buffer, "/");
strcat(buffer, filename);
//buffer = UnixToDosPath(buffer);
return buffer;
}

View File

@@ -0,0 +1,8 @@
; plugin.def : Declares the module parameters for the DLL.
LIBRARY "bobToolz"
; DESCRIPTION 'bobToolz Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
Synapse_EnumerateInterfaces @1

View File

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

View File

@@ -0,0 +1,64 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// plugin.h : main header file for the PLUGIN DLL
//
#if !defined(AFX_PLUGIN_H__3BA55F6A_1D27_11D3_BC7B_F7EFD9765E37__INCLUDED_)
#define AFX_PLUGIN_H__3BA55F6A_1D27_11D3_BC7B_F7EFD9765E37__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'StdAfx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CPluginApp
// See plugin.cpp for the implementation of this class
//
class CPluginApp : public CWinApp
{
public:
CPluginApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPluginApp)
//}}AFX_VIRTUAL
//{{AFX_MSG(CPluginApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PLUGIN_H__3BA55F6A_1D27_11D3_BC7B_F7EFD9765E37__INCLUDED_)

View File

@@ -0,0 +1,533 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "resource.h"
#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
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,1,0
PRODUCTVERSION 2,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "Comments", "by djbob :P and MarsMattel ~:]\0"
VALUE "CompanyName", "bobCo\0"
VALUE "FileDescription", "All your plugins are belong to us\0"
VALUE "FileVersion", "1, 1, 1, 0\0"
VALUE "InternalName", "bobToolz\0"
VALUE "LegalCopyright", "Copyright (C) y2k\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "bobToolz.DLL\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "\0"
VALUE "ProductVersion", "2, 0, 0, 0\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1200
END
END
#endif // !_MAC
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Neutral (Sys. Default) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 361, 118
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "Arial"
BEGIN
DEFPUSHBUTTON "OK",IDOK,305,100,50,14
CTEXT "BobToolz - Q3radiant version by djbob &&&& Mars Mattel",
IDC_STATIC,5,5,350,14,SS_CENTERIMAGE
CTEXT "Latest Version Can Be Found At http://djbob.fortefide.com",
IDC_STATIC,5,20,350,15,SS_CENTERIMAGE
LTEXT "Random bobToolz comments:",IDC_STATIC,5,35,355,10
CTEXT "Texture Alignments Are Irrelevant, You Will Be Caulked\n-QPSiren\nCaulk Me Baby One More Time\n-TTimo\nWe're Up The Creek Without A Penguin\n-Mars Mattel",
IDC_STATIC,5,45,355,50
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 354
TOPMARGIN, 7
BOTTOMMARGIN, 111
END
END
#endif // APSTUDIO_INVOKED
#endif // Neutral (Sys. Default) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_STAIR_DIALOG DIALOG DISCARDABLE 0, 0, 246, 118
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Stair Designer"
FONT 8, "Arial"
BEGIN
DEFPUSHBUTTON "OK",IDOK,189,83,50,12
PUSHBUTTON "Cancel",IDCANCEL,189,99,50,12
EDITTEXT IDC_EDIT1,5,5,86,12,ES_AUTOHSCROLL
LTEXT "Stair Height",IDC_STATIC,95,5,42,15,SS_CENTERIMAGE
GROUPBOX "Direction",IDC_STATIC,7,26,85,64
CONTROL "North",IDC_DIR_N_RADIO,"Button",BS_AUTORADIOBUTTON |
WS_GROUP,14,38,33,10
CONTROL "South",IDC_DIR_S_RADIO,"Button",BS_AUTORADIOBUTTON,14,
50,35,10
CONTROL "East",IDC_DIR_E_RADIO,"Button",BS_AUTORADIOBUTTON,14,62,
30,10
CONTROL "West",IDC_DIR_W_RADIO,"Button",BS_AUTORADIOBUTTON,14,74,
33,10
GROUPBOX "Style",IDC_STATIC,97,26,82,49
CONTROL "Original",IDC_STYLE_ORIG_RADIO,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,105,35,39,10
CONTROL "Bob's Style",IDC_STYLE_BOB_RADIO,"Button",
BS_AUTORADIOBUTTON,105,47,51,10
CONTROL "Corner",IDC_STYLE_CORNER_RADIO,"Button",
BS_AUTORADIOBUTTON | WS_DISABLED,105,59,51,10
EDITTEXT IDC_RISER_EDIT,7,99,85,12,ES_AUTOHSCROLL
LTEXT "Riser Texture",IDC_STATIC,95,100,60,11,SS_CENTERIMAGE
CONTROL "Use Detail Brushes",IDC_DETAIL_CHK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,100,80,75,10
END
IDD_POLYGON_DIALOG DIALOG DISCARDABLE 0, 0, 271, 68
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Polygon Builder"
FONT 8, "Arial"
BEGIN
PUSHBUTTON "OK",IDOK,150,50,50,14
PUSHBUTTON "Cancel",IDCANCEL,215,50,50,14
EDITTEXT IDC_EDIT1,7,7,76,13,ES_AUTOHSCROLL
LTEXT "Number Of Sides",IDC_STATIC,85,7,60,13,SS_CENTERIMAGE
CONTROL "Inverse Polygon",IDC_INVERSE_CHK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,149,21,75,10
CONTROL "Use Border",IDC_BORDER_CHK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,149,7,66,10
EDITTEXT IDC_BORDER_EDIT,7,28,76,13,ES_AUTOHSCROLL
LTEXT "Border Size",IDC_STATIC,86,28,60,13,SS_CENTERIMAGE
CONTROL "Align Top Edge",IDC_ALIGN_CHK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,149,35,75,10
END
IDD_DOOR_DIALOG DIALOG DISCARDABLE 0, 0, 327, 119
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Door Builder"
FONT 8, "Arial"
BEGIN
DEFPUSHBUTTON "OK",IDOK,270,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,270,24,50,14
EDITTEXT IDC_FBTEXTURE_EDIT,7,7,125,14,ES_AUTOHSCROLL
LTEXT "Door Front/Back Texture",IDC_STATIC,137,7,86,14,
SS_CENTERIMAGE
EDITTEXT IDC_TRIMTEXTURE_EDIT,7,26,125,14,ES_AUTOHSCROLL
LTEXT "Door Trim Texture",IDC_STATIC,137,26,86,14,
SS_CENTERIMAGE
CONTROL "Scale Main Texture Horizontally",IDC_TEXSCALE1_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,46,115,10
CONTROL "Scale Main Texture Vertically",IDC_TEXSCALE2_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,60,107,10
CONTROL "Scale Trim Texture Horizontally",IDC_TEXSCALE3_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,136,46,113,10
CONTROL "Scale Trim Texture Vertically",IDC_TEXSCALE4_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,136,60,105,10
COMBOBOX IDC_MAINTEX_COMBO,7,76,126,30,CBS_DROPDOWN | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_TRIMTEX_COMBO,7,99,126,30,CBS_DROPDOWN | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Set As Main Texture",IDC_SET_MAINTEX_BTN,139,76,82,14
PUSHBUTTON "Set As Trim Texture",IDC_SET_TRIMTEX_BTN,139,98,82,14
GROUPBOX "Orientation",IDC_DIR_GROUP,225,72,95,40
CONTROL "North - South",IDC_DIR_NS_RADIO,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,230,82,85,10
CONTROL "East - West",IDC_DIR_EW_RADIO,"Button",
BS_AUTORADIOBUTTON,230,97,85,10
END
IDD_INTERSECT_DIALOG DIALOG DISCARDABLE 0, 0, 245, 58
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Intersecting Brush Finder"
FONT 8, "Arial"
BEGIN
DEFPUSHBUTTON "OK",IDOK,130,40,50,14
PUSHBUTTON "Cancel",IDCANCEL,185,40,50,14
CONTROL "Include Detail Brushes",IDC_DETAIL_INCLUDE_CHECK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,130,10,111,10
GROUPBOX "Brush Options",IDC_STATIC,10,5,111,45
CONTROL "Use Whole Map",IDC_WHOLEMAP_RADIO,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,15,15,95,10
CONTROL "Use Selected Brushes",IDC_SELECTED_RADIO,"Button",
BS_AUTORADIOBUTTON,15,30,95,10
CONTROL "Only Select Duplicate Brushes",IDC_DUPLICATEONLY_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,25,113,10
END
IDD_INTERSECT_INFO_DIALOG DIALOG DISCARDABLE 0, 0, 187, 33
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH,
5,15,175,10
CTEXT "Brush Loading",IDC_STATIC,5,5,175,10,SS_CENTERIMAGE
END
IDD_BRUSHCHECKER_DIALOG DIALOG DISCARDABLE 0, 0, 182, 38
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH,
5,21,172,10
CTEXT "Checking Brushes",IDC_STATIC,5,5,170,15,SS_CENTERIMAGE
END
IDD_AUTOCAULK_DIALOG DIALOG DISCARDABLE 0, 0, 187, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH,
5,15,175,10
CTEXT "Loading Portal Data",IDC_STATIC,5,5,175,10,
SS_CENTERIMAGE
CONTROL "Progress1",IDC_PROGRESS2,"msctls_progress32",PBS_SMOOTH,
5,35,175,10
CTEXT "Auto Caulking",IDC_STATIC,5,25,175,10,SS_CENTERIMAGE
END
IDD_AUTOCAULKSTART_DIALOG DIALOG DISCARDABLE 0, 0, 237, 83
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Auto Caulk"
FONT 8, "Arial"
BEGIN
DEFPUSHBUTTON "OK",IDOK,125,10,50,14
PUSHBUTTON "Cancel",IDCANCEL,180,10,50,14
CONTROL "Destroy Invisible Brushes",IDC_KILLBRUSHES_CHECK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,125,50,95,10
LTEXT "",IDC_WARNING1_STATIC,5,65,223,11,NOT WS_GROUP
GROUPBOX "Static",IDC_STATIC,5,5,115,57
CONTROL "Autocaulk",IDC_AC_NORMAL_RADIO,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,10,15,48,10
CONTROL "Build Mini Prt",IDC_AC_BUILD_MINI_PRT_RADIO,"Button",
BS_AUTORADIOBUTTON,10,30,56,10
CONTROL "Autocaulk+ (Detail Brushes)",IDC_AC_SUPER_RADIO,"Button",
BS_AUTORADIOBUTTON,10,45,106,10
END
IDD_TEXTURE_RESET_DIALOG DIALOG DISCARDABLE 0, 0, 272, 107
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Texture Reset"
FONT 8, "Arial"
BEGIN
DEFPUSHBUTTON "OK",IDOK,160,85,50,14
PUSHBUTTON "Cancel",IDCANCEL,215,85,50,14
EDITTEXT IDC_RESET_TEXTURE_EDIT,5,5,118,14,ES_AUTOHSCROLL
EDITTEXT IDC_SCL_VERT_EDIT,85,45,40,14,ES_AUTOHSCROLL
EDITTEXT IDC_SCL_HOR_EDIT,85,65,40,14,ES_AUTOHSCROLL
EDITTEXT IDC_ROTATION_EDIT,85,85,40,14,ES_AUTOHSCROLL
EDITTEXT IDC_SHFT_VER_EDIT,225,45,40,14,ES_AUTOHSCROLL
EDITTEXT IDC_SHFT_HOR_EDIT,225,65,40,14,ES_AUTOHSCROLL
RTEXT "Scale::Vertical",IDC_STATIC,5,45,75,15,SS_CENTERIMAGE
RTEXT "Scale::Horizontal",IDC_STATIC,5,65,75,15,SS_CENTERIMAGE
RTEXT "Rotation",IDC_STATIC,5,85,75,15,SS_CENTERIMAGE
RTEXT "Shift::Horizontal",IDC_STATIC,160,65,60,15,
SS_CENTERIMAGE
RTEXT "Shift::Vertical",IDC_STATIC,160,45,60,15,SS_CENTERIMAGE
LTEXT "Texture To Reset",IDC_STATIC,128,5,62,15,SS_CENTERIMAGE
CONTROL "Reset All Textures",IDC_ALLTEXTURES_CHECK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,195,5,75,15
EDITTEXT IDC_RESET_NEW_TEXTURE_EDIT,5,25,118,14,ES_AUTOHSCROLL
LTEXT "New Texture Name",IDC_STATIC,128,25,62,15,
SS_CENTERIMAGE
CONTROL "Reset Texture Only",IDC_ONLYTEXTURE_CHECK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,195,25,75,15
END
IDD_PATHPLOTTER_DIALOG DIALOG DISCARDABLE 0, 0, 172, 113
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Path Plotter"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Enable",IDYES,5,92,50,14
PUSHBUTTON "Cancel",IDCANCEL,115,92,50,14
PUSHBUTTON "Disable",IDNO,60,92,50,14
EDITTEXT IDC_POINTCOUNT_EDIT,5,5,80,14,ES_AUTOHSCROLL
EDITTEXT IDC_MULTIPLIER_EDIT,5,25,80,14,ES_AUTOHSCROLL
EDITTEXT IDC_GRAVITY_EDIT,5,45,80,14,ES_AUTOHSCROLL
LTEXT "Number Of Points",IDC_STATIC,90,5,60,15,SS_CENTERIMAGE
CONTROL "No Dynamic Update",IDC_NOUPDATE_CHECK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,65,80,10
LTEXT "Multiplier",IDC_STATIC,90,25,60,15,SS_CENTERIMAGE
LTEXT "Gravity",IDC_STATIC,90,45,60,15,SS_CENTERIMAGE
CONTROL "Show Bounding Lines",IDC_SHOWEXTRA_CHECK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,79,85,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_STAIR_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 239
TOPMARGIN, 7
BOTTOMMARGIN, 111
END
IDD_POLYGON_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 264
TOPMARGIN, 7
BOTTOMMARGIN, 61
END
IDD_DOOR_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 320
TOPMARGIN, 7
BOTTOMMARGIN, 112
END
IDD_INTERSECT_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 238
TOPMARGIN, 7
BOTTOMMARGIN, 51
END
IDD_INTERSECT_INFO_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 180
TOPMARGIN, 7
BOTTOMMARGIN, 25
END
IDD_BRUSHCHECKER_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 175
TOPMARGIN, 7
BOTTOMMARGIN, 31
END
IDD_AUTOCAULK_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 180
TOPMARGIN, 7
BOTTOMMARGIN, 45
END
IDD_AUTOCAULKSTART_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 230
TOPMARGIN, 7
BOTTOMMARGIN, 76
END
IDD_TEXTURE_RESET_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 265
TOPMARGIN, 7
BOTTOMMARGIN, 100
END
IDD_PATHPLOTTER_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 165
TOPMARGIN, 7
BOTTOMMARGIN, 106
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//
IDD_DOOR_DIALOG DLGINIT
BEGIN
IDC_MAINTEX_COMBO, 0x403, 25, 0
0x6162, 0x6573, 0x645f, 0x6f6f, 0x2f72, 0x6873, 0x6e69, 0x6d79, 0x7465,
0x6c61, 0x6f64, 0x726f, "\000"
IDC_MAINTEX_COMBO, 0x403, 33, 0
0x6162, 0x6573, 0x645f, 0x6f6f, 0x2f72, 0x6873, 0x6e69, 0x6d79, 0x7465,
0x6c61, 0x6f64, 0x726f, 0x6f5f, 0x7475, 0x6973, 0x6564, "\000"
IDC_MAINTEX_COMBO, 0x403, 36, 0
0x6162, 0x6573, 0x645f, 0x6f6f, 0x2f72, 0x6873, 0x6e69, 0x6d79, 0x7465,
0x6c61, 0x6f64, 0x726f, 0x6f5f, 0x7475, 0x6973, 0x6564, 0x6133, 0x0032,
IDC_MAINTEX_COMBO, 0x403, 24, 0
0x6f67, 0x6874, 0x6369, 0x645f, 0x6f6f, 0x2f72, 0x6f64, 0x726f, 0x3230,
0x625f, 0x6572, 0x0064,
IDC_MAINTEX_COMBO, 0x403, 31, 0
0x6f67, 0x6874, 0x6369, 0x645f, 0x6f6f, 0x2f72, 0x6f64, 0x726f, 0x3230,
0x625f, 0x6572, 0x3264, 0x735f, 0x6968, 0x796e, "\000"
IDC_MAINTEX_COMBO, 0x403, 32, 0
0x6f67, 0x6874, 0x6369, 0x645f, 0x6f6f, 0x2f72, 0x6f64, 0x726f, 0x3230,
0x655f, 0x6c62, 0x6575, 0x5f32, 0x6873, 0x6e69, 0x0079,
IDC_MAINTEX_COMBO, 0x403, 33, 0
0x6f67, 0x6874, 0x6369, 0x645f, 0x6f6f, 0x2f72, 0x6f64, 0x726f, 0x3230,
0x695f, 0x6f5f, 0x6e72, 0x7461, 0x3565, 0x665f, 0x6e69, "\000"
IDC_MAINTEX_COMBO, 0x403, 21, 0
0x6f67, 0x6874, 0x6369, 0x645f, 0x6f6f, 0x2f72, 0x6f64, 0x726f, 0x3230,
0x6a5f, "\000"
IDC_MAINTEX_COMBO, 0x403, 22, 0
0x6f67, 0x6874, 0x6369, 0x645f, 0x6f6f, 0x2f72, 0x6f64, 0x726f, 0x3230,
0x6a5f, 0x0033,
IDC_MAINTEX_COMBO, 0x403, 22, 0
0x6f67, 0x6874, 0x6369, 0x645f, 0x6f6f, 0x2f72, 0x6f64, 0x726f, 0x3230,
0x6a5f, 0x0034,
IDC_MAINTEX_COMBO, 0x403, 23, 0
0x6f67, 0x6874, 0x6369, 0x645f, 0x6f6f, 0x2f72, 0x6f64, 0x726f, 0x3230,
0x6b5f, 0x6232, "\000"
IDC_TRIMTEX_COMBO, 0x403, 26, 0
0x6162, 0x6573, 0x735f, 0x7075, 0x6f70, 0x7472, 0x732f, 0x7075, 0x6f70,
0x7472, 0x7231, 0x7375, 0x0074,
IDC_TRIMTEX_COMBO, 0x403, 27, 0
0x6162, 0x6573, 0x735f, 0x7075, 0x6f70, 0x7472, 0x732f, 0x7075, 0x6f70,
0x7472, 0x7331, 0x6968, 0x796e, "\000"
IDC_TRIMTEX_COMBO, 0x403, 26, 0
0x6162, 0x6573, 0x735f, 0x7075, 0x6f70, 0x7472, 0x732f, 0x7075, 0x6f70,
0x7472, 0x7232, 0x7375, 0x0074,
IDC_TRIMTEX_COMBO, 0x403, 22, 0
0x6162, 0x6573, 0x735f, 0x7075, 0x6f70, 0x7472, 0x772f, 0x6c70, 0x7461,
0x5f31, 0x0031,
IDC_TRIMTEX_COMBO, 0x403, 22, 0
0x6162, 0x6573, 0x735f, 0x7075, 0x6f70, 0x7472, 0x702f, 0x616c, 0x6574,
0x5f32, 0x0035,
0
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""resource.h""\r\n"
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,344 @@
# Microsoft Developer Studio Project File - Name="bobToolz_gtk" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=bobToolz_gtk - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "bobToolz_gtk.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 "bobToolz_gtk.mak" CFG="bobToolz_gtk - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bobToolz_gtk - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "bobToolz_gtk - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "bobToolz_gtk"
# PROP Scc_LocalPath "..\.."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "bobToolz_gtk - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE F90 /include:"Release/"
# ADD F90 /include:"Release-GTK/"
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BOBTOOLZ_GTK_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /O2 /I "../../libs" /I "../../../STLport/stlport" /I "../../include" /I "..\..\..\gtk2-win32\include\glib-2.0" /I "..\..\..\gtk2-win32\lib\glib-2.0\include" /I "..\..\..\gtk2-win32\lib\gtk-2.0\include" /I "..\..\..\gtk2-win32\include\gtk-2.0" /I "..\..\..\gtk2-win32\include\gtk-2.0\gdk" /I "..\..\..\gtk2-win32\include\pango-1.0" /I "..\..\..\gtk2-win32\include\atk-1.0" /I "dialogs" /I "..\..\..\libxml2\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BOBTOOLZ_GTK_EXPORTS" /D "_BOBTOOLZGTK_" /D "_GTK_" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG" /d "_BOBTOOLZGTK_"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib mathlib.lib synapse.lib /nologo /dll /machine:I386 /def:".\bobToolz.def" /out:"Release/bobToolz.dll" /libpath:"..\src\glib" /libpath:"..\src\gtk+\gtk" /libpath:"..\src\gtk+\gdk" /libpath:"../../../src/glib" /libpath:"../../../src/gtk+/gtk" /libpath:"../../../src/gtk+/gdk" /libpath:"..\..\libs\mathlib\Release" /libpath:"../../libs/synapse/release" /libpath:"..\..\..\gtk2-win32\lib"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "bobToolz_gtk - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE F90 /include:"Debug/"
# ADD F90 /include:"Debug-GTK/"
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BOBTOOLZ_GTK_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "../../libs" /I "../../../STLport/stlport" /I "../../include" /I "..\..\..\gtk2-win32\include\glib-2.0" /I "..\..\..\gtk2-win32\lib\glib-2.0\include" /I "..\..\..\gtk2-win32\lib\gtk-2.0\include" /I "..\..\..\gtk2-win32\include\gtk-2.0" /I "..\..\..\gtk2-win32\include\gtk-2.0\gdk" /I "..\..\..\gtk2-win32\include\pango-1.0" /I "..\..\..\gtk2-win32\include\atk-1.0" /I "dialogs" /I "..\..\..\libxml2\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BOBTOOLZ_GTK_EXPORTS" /D "_BOBTOOLZGTK_" /D "_GTK_" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG" /d "_BOBTOOLZGTK_"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib mathlib.lib synapse.lib /nologo /dll /debug /machine:I386 /def:".\bobToolz.def" /out:"Debug/bobToolz.dll" /pdbtype:sept /libpath:"../../../src/glib" /libpath:"../../../src/gtk+/gtk" /libpath:"../../../src/gtk+/gdk" /libpath:"..\..\libs\mathlib\Debug" /libpath:"../../libs/synapse/debug" /libpath:"..\..\..\gtk2-win32\lib"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "bobToolz_gtk - Win32 Release"
# Name "bobToolz_gtk - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Group "dialogs"
# PROP Default_Filter ""
# Begin Source File
SOURCE=".\dialogs\dialogs-gtk.cpp"
# End Source File
# End Group
# Begin Source File
SOURCE=".\bobToolz-GTK.cpp"
# End Source File
# Begin Source File
SOURCE=".\bobtoolz-gtk.rc"
# End Source File
# Begin Source File
SOURCE=.\bobToolz.def
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\bsploader.cpp
# End Source File
# Begin Source File
SOURCE=.\cportals.cpp
# End Source File
# Begin Source File
SOURCE=.\DBobView.cpp
# End Source File
# Begin Source File
SOURCE=.\DBrush.cpp
# End Source File
# Begin Source File
SOURCE=.\DEntity.cpp
# End Source File
# Begin Source File
SOURCE=.\DEPair.cpp
# End Source File
# Begin Source File
SOURCE=.\DListener.cpp
# End Source File
# Begin Source File
SOURCE=.\DMap.cpp
# End Source File
# Begin Source File
SOURCE=.\DPatch.cpp
# End Source File
# Begin Source File
SOURCE=.\DPlane.cpp
# End Source File
# Begin Source File
SOURCE=.\DPoint.cpp
# End Source File
# Begin Source File
SOURCE=.\DShape.cpp
# End Source File
# Begin Source File
SOURCE=.\DTrainDrawer.cpp
# End Source File
# Begin Source File
SOURCE=.\DTreePlanter.cpp
# End Source File
# Begin Source File
SOURCE=.\DVisDrawer.cpp
# End Source File
# Begin Source File
SOURCE=.\DWinding.cpp
# End Source File
# Begin Source File
SOURCE=".\funchandlers-GTK.cpp"
# End Source File
# Begin Source File
SOURCE=.\lists.cpp
# End Source File
# Begin Source File
SOURCE=.\misc.cpp
# End Source File
# Begin Source File
SOURCE=.\ScriptParser.cpp
# End Source File
# Begin Source File
SOURCE=.\shapes.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# End Source File
# Begin Source File
SOURCE=.\visfind.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Group "dialog - headers"
# PROP Default_Filter ""
# Begin Source File
SOURCE=".\dialogs\dialogs-gtk.h"
# End Source File
# End Group
# Begin Group "interface"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\include\iUI.h
# End Source File
# Begin Source File
SOURCE=..\..\include\qerplugin.h
# End Source File
# Begin Source File
SOURCE=..\..\include\qertypes.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\bsploader.h
# End Source File
# Begin Source File
SOURCE=.\CPortals.h
# End Source File
# Begin Source File
SOURCE=.\DBobView.h
# End Source File
# Begin Source File
SOURCE=.\DBrush.h
# End Source File
# Begin Source File
SOURCE=.\DEntity.h
# End Source File
# Begin Source File
SOURCE=.\DEPair.h
# End Source File
# Begin Source File
SOURCE=.\DListener.h
# End Source File
# Begin Source File
SOURCE=.\DMap.h
# End Source File
# Begin Source File
SOURCE=.\DPatch.h
# End Source File
# Begin Source File
SOURCE=.\DPlane.h
# End Source File
# Begin Source File
SOURCE=.\DPoint.h
# End Source File
# Begin Source File
SOURCE=.\DShape.h
# End Source File
# Begin Source File
SOURCE=.\DTrainDrawer.h
# End Source File
# Begin Source File
SOURCE=.\DTreePlanter.h
# End Source File
# Begin Source File
SOURCE=.\DVisDrawer.h
# End Source File
# Begin Source File
SOURCE=.\DWinding.h
# End Source File
# Begin Source File
SOURCE=.\funchandlers.h
# End Source File
# Begin Source File
SOURCE=.\lists.h
# End Source File
# Begin Source File
SOURCE=.\misc.h
# End Source File
# Begin Source File
SOURCE=.\res\plugin.rc2
# End Source File
# Begin Source File
SOURCE=".\resource-GTK.h"
# End Source File
# Begin Source File
SOURCE=.\shapes.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\visfind.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,328 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="bobToolz_gtk">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../libs,../../../STLport/stlport,../../include,..\..\..\gtk2-win32\include\glib-2.0,..\..\..\gtk2-win32\lib\glib-2.0\include,..\..\..\gtk2-win32\lib\gtk-2.0\include,..\..\..\gtk2-win32\include\gtk-2.0,..\..\..\gtk2-win32\include\gtk-2.0\gdk,..\..\..\gtk2-win32\include\pango-1.0,..\..\..\gtk2-win32\include\atk-1.0,dialogs,..\..\..\libxml2\include"
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;BOBTOOLZ_GTK_EXPORTS;_BOBTOOLZGTK_;_GTK_"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/bobToolz_gtk.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="TRUE"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib"
OutputFile="Debug/bobToolz.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="../../../src/glib,../../../src/gtk+/gtk,../../../src/gtk+/gdk,..\..\libs\mathlib\Debug,../../libs/synapse/debug,..\..\..\gtk2-win32\lib"
ModuleDefinitionFile=".\bobToolz.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/bobToolz.pdb"
ImportLibrary=".\Debug/bobToolz.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/bobToolz_gtk.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG,_BOBTOOLZGTK_"
Culture="2057"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../../libs,../../../STLport/stlport,../../include,..\..\..\gtk2-win32\include\glib-2.0,..\..\..\gtk2-win32\lib\glib-2.0\include,..\..\..\gtk2-win32\lib\gtk-2.0\include,..\..\..\gtk2-win32\include\gtk-2.0,..\..\..\gtk2-win32\include\gtk-2.0\gdk,..\..\..\gtk2-win32\include\pango-1.0,..\..\..\gtk2-win32\include\atk-1.0,dialogs,..\..\..\libxml2\include"
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;BOBTOOLZ_GTK_EXPORTS;_BOBTOOLZGTK_;_GTK_"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/bobToolz_gtk.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="TRUE"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pango-1.0.lib"
OutputFile="Release/bobToolz.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\src\glib,..\src\gtk+\gtk,..\src\gtk+\gdk,../../../src/glib,../../../src/gtk+/gtk,../../../src/gtk+/gdk,..\..\libs\mathlib\Release,../../libs/synapse/release,..\..\..\gtk2-win32\lib"
ModuleDefinitionFile=".\bobToolz.def"
ProgramDatabaseFile=".\Release/bobToolz.pdb"
ImportLibrary=".\Release/bobToolz.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/bobToolz_gtk.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG,_BOBTOOLZGTK_"
Culture="2057"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath=".\DBobView.cpp">
</File>
<File
RelativePath=".\DBrush.cpp">
</File>
<File
RelativePath=".\DEPair.cpp">
</File>
<File
RelativePath=".\DEntity.cpp">
</File>
<File
RelativePath=".\DListener.cpp">
</File>
<File
RelativePath=".\DMap.cpp">
</File>
<File
RelativePath=".\DPatch.cpp">
</File>
<File
RelativePath=".\DPlane.cpp">
</File>
<File
RelativePath=".\DPoint.cpp">
</File>
<File
RelativePath=".\DShape.cpp">
</File>
<File
RelativePath=".\DTrainDrawer.cpp">
</File>
<File
RelativePath=".\DTreePlanter.cpp">
</File>
<File
RelativePath=".\DVisDrawer.cpp">
</File>
<File
RelativePath=".\DWinding.cpp">
</File>
<File
RelativePath=".\ScriptParser.cpp">
</File>
<File
RelativePath=".\StdAfx.cpp">
</File>
<File
RelativePath=".\bobToolz-GTK.cpp">
</File>
<File
RelativePath=".\bobToolz.def">
</File>
<File
RelativePath=".\bobtoolz-gtk.rc">
</File>
<File
RelativePath=".\bsploader.cpp">
</File>
<File
RelativePath=".\cportals.cpp">
</File>
<File
RelativePath=".\funchandlers-GTK.cpp">
</File>
<File
RelativePath=".\lists.cpp">
</File>
<File
RelativePath=".\misc.cpp">
</File>
<File
RelativePath=".\shapes.cpp">
</File>
<File
RelativePath=".\visfind.cpp">
</File>
<Filter
Name="dialogs"
Filter="">
<File
RelativePath=".\dialogs\dialogs-gtk.cpp">
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath=".\CPortals.h">
</File>
<File
RelativePath=".\DBobView.h">
</File>
<File
RelativePath=".\DBrush.h">
</File>
<File
RelativePath=".\DEPair.h">
</File>
<File
RelativePath=".\DEntity.h">
</File>
<File
RelativePath=".\DListener.h">
</File>
<File
RelativePath=".\DMap.h">
</File>
<File
RelativePath=".\DPatch.h">
</File>
<File
RelativePath=".\DPlane.h">
</File>
<File
RelativePath=".\DPoint.h">
</File>
<File
RelativePath=".\DShape.h">
</File>
<File
RelativePath=".\DTrainDrawer.h">
</File>
<File
RelativePath=".\DTreePlanter.h">
</File>
<File
RelativePath=".\DVisDrawer.h">
</File>
<File
RelativePath=".\DWinding.h">
</File>
<File
RelativePath=".\StdAfx.h">
</File>
<File
RelativePath=".\bsploader.h">
</File>
<File
RelativePath=".\funchandlers.h">
</File>
<File
RelativePath=".\lists.h">
</File>
<File
RelativePath=".\misc.h">
</File>
<File
RelativePath=".\res\plugin.rc2">
</File>
<File
RelativePath=".\resource-GTK.h">
</File>
<File
RelativePath=".\shapes.h">
</File>
<File
RelativePath=".\visfind.h">
</File>
<Filter
Name="dialog - headers"
Filter="">
<File
RelativePath=".\dialogs\dialogs-gtk.h">
</File>
</Filter>
<Filter
Name="interface"
Filter="">
<File
RelativePath="..\..\include\iUI.h">
</File>
<File
RelativePath="..\..\include\qerplugin.h">
</File>
<File
RelativePath="..\..\include\qertypes.h">
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,109 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource-gtk.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource-gtk.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
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,1,0
PRODUCTVERSION 2,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "Comments", "by djbob :P and MarsMattel ~:)\0"
VALUE "CompanyName", "bobCo\0"
VALUE "FileDescription", "All your plugins are belong to us\0"
VALUE "FileVersion", "1, 1, 1, 0\0"
VALUE "InternalName", "bobToolz GTK\0"
VALUE "LegalCopyright", "Copyright © 2001\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "bobToolz.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "bobCo bobToolz\0"
VALUE "ProductVersion", "2, 0, 0, 0\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1200
END
END
#endif // !_MAC
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,258 @@
#include "StdAfx.h"
#include "./dialogs/dialogs-gtk.h"
#include "bsploader.h"
#include "../../libs/cmdlib.h"
int numnodes;
int numplanes;
int numleafs;
int numleafsurfaces;
int numVisBytes;
int numDrawVerts;
int numDrawSurfaces;
int numbrushes;
int numbrushsides;
int numleafbrushes;
byte *visBytes = NULL;
dnode_t *dnodes = NULL;
dplane_t *dplanes = NULL;
dleaf_t *dleafs = NULL;
qdrawVert_t *drawVerts = NULL;
dsurface_t *drawSurfaces = NULL;
int *dleafsurfaces = NULL;
dbrush_t *dbrushes = NULL;
dbrushside_t *dbrushsides = NULL;
int *dleafbrushes = NULL;
#define BSP_IDENT (('P'<<24)+('S'<<16)+('B'<<8)+'I')
#define Q3_BSP_VERSION 46
#define WOLF_BSP_VERSION 47
/*
================
FileLength
================
*/
int 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;
}
/*
==============
LoadFile
==============
*/
bool LoadFile( const char *filename, byte **bufferptr)
{
FILE *f;
int length;
byte *buffer;
f = fopen(filename, "rb");
if(!f)
return false;
length = FileLength (f);
buffer = new byte[length+1];
buffer[length] = 0;
fread(buffer, 1, length, f);
fclose (f);
*bufferptr = buffer;
return true;
}
/*int LittleLong (int l)
{
return l;
}
float LittleFloat (float l)
{
return l;
}*/
/*
=============
SwapBlock
If all values are 32 bits, this can be used to swap everything
=============
*/
void SwapBlock( int *block, int sizeOfBlock ) {
int i;
sizeOfBlock >>= 2;
for ( i = 0 ; i < sizeOfBlock ; i++ ) {
block[i] = LittleLong( block[i] );
}
}
/*
=============
SwapBSPFile
Byte swaps all data in a bsp file.
=============
*/
void SwapBSPFile( void ) {
int i;
// models
// SwapBlock( (int *)dmodels, nummodels * sizeof( dmodels[0] ) );
// shaders (don't swap the name)
// for ( i = 0 ; i < numShaders ; i++ ) {
// dshaders[i].contentFlags = LittleLong( dshaders[i].contentFlags );
// dshaders[i].surfaceFlags = LittleLong( dshaders[i].surfaceFlags );
// }
// planes
SwapBlock( (int *)dplanes, numplanes * sizeof( dplanes[0] ) );
// nodes
SwapBlock( (int *)dnodes, numnodes * sizeof( dnodes[0] ) );
// leafs
SwapBlock( (int *)dleafs, numleafs * sizeof( dleafs[0] ) );
// leaffaces
SwapBlock( (int *)dleafsurfaces, numleafsurfaces * sizeof( dleafsurfaces[0] ) );
// leafbrushes
SwapBlock( (int *)dleafbrushes, numleafbrushes * sizeof( dleafbrushes[0] ) );
// brushes
SwapBlock( (int *)dbrushes, numbrushes * sizeof( dbrushes[0] ) );
// brushsides
SwapBlock( (int *)dbrushsides, numbrushsides * sizeof( dbrushsides[0] ) );
// vis
((int *)&visBytes)[0] = LittleLong( ((int *)&visBytes)[0] );
((int *)&visBytes)[1] = LittleLong( ((int *)&visBytes)[1] );
// drawverts (don't swap colors )
for ( i = 0 ; i < numDrawVerts ; i++ ) {
drawVerts[i].lightmap[0] = LittleFloat( drawVerts[i].lightmap[0] );
drawVerts[i].lightmap[1] = LittleFloat( drawVerts[i].lightmap[1] );
drawVerts[i].st[0] = LittleFloat( drawVerts[i].st[0] );
drawVerts[i].st[1] = LittleFloat( drawVerts[i].st[1] );
drawVerts[i].xyz[0] = LittleFloat( drawVerts[i].xyz[0] );
drawVerts[i].xyz[1] = LittleFloat( drawVerts[i].xyz[1] );
drawVerts[i].xyz[2] = LittleFloat( drawVerts[i].xyz[2] );
drawVerts[i].normal[0] = LittleFloat( drawVerts[i].normal[0] );
drawVerts[i].normal[1] = LittleFloat( drawVerts[i].normal[1] );
drawVerts[i].normal[2] = LittleFloat( drawVerts[i].normal[2] );
}
// drawindexes
// SwapBlock( (int *)drawIndexes, numDrawIndexes * sizeof( drawIndexes[0] ) );
// drawsurfs
SwapBlock( (int *)drawSurfaces, numDrawSurfaces * sizeof( drawSurfaces[0] ) );
// fogs
// for ( i = 0 ; i < numFogs ; i++ ) {
// dfogs[i].brushNum = LittleLong( dfogs[i].brushNum );
// dfogs[i].visibleSide = LittleLong( dfogs[i].visibleSide );
// }
}
/*
=============
CopyLump
=============
*/
int CopyLump( dheader_t *header, int lump, void **dest, int size ) {
int length, ofs;
length = header->lumps[lump].filelen;
ofs = header->lumps[lump].fileofs;
if(length == 0)
return 0;
*dest = new byte[length];
memcpy( *dest, (byte *)header + ofs, length );
return length / size;
}
/*
=============
LoadBSPFile
=============
*/
bool LoadBSPFile( const char *filename ) {
dheader_t *header;
// load the file header
if(!LoadFile (filename, (byte **)&header))
return false;
// swap the header
SwapBlock( (int *)header, sizeof(*header) );
if ( header->ident != BSP_IDENT ) {
DoMessageBox( "Cant find a valid IBSP file", "Error", eMB_OK);
return false;
}
if ( (header->version != Q3_BSP_VERSION) &&
(header->version != WOLF_BSP_VERSION) ) {
DoMessageBox( "File is incorrect version", "Error", eMB_OK);
return false;
}
numbrushsides = CopyLump( header, LUMP_BRUSHES, (void**)&dbrushsides, sizeof(dbrushside_t) );
numbrushes = CopyLump( header, LUMP_BRUSHES, (void**)&dbrushes, sizeof(dbrush_t) );
numplanes = CopyLump( header, LUMP_PLANES, (void**)&dplanes, sizeof(dplane_t) );
numleafs = CopyLump( header, LUMP_LEAFS, (void**)&dleafs, sizeof(dleaf_t) );
numnodes = CopyLump( header, LUMP_NODES, (void**)&dnodes, sizeof(dnode_t) );
numDrawVerts = CopyLump( header, LUMP_DRAWVERTS, (void**)&drawVerts, sizeof(qdrawVert_t) );
numDrawSurfaces = CopyLump( header, LUMP_SURFACES, (void**)&drawSurfaces, sizeof(dsurface_t) );
numleafsurfaces = CopyLump( header, LUMP_LEAFSURFACES, (void**)&dleafsurfaces, sizeof(int) );
numVisBytes = CopyLump( header, LUMP_VISIBILITY, (void**)&visBytes, 1 );
numleafbrushes = CopyLump( header, LUMP_LEAFBRUSHES, (void**)&dleafbrushes, sizeof(int) );
delete header; // everything has been copied out
// swap everything
SwapBSPFile();
return true;
}
void FreeBSPData()
{
if(visBytes)
delete visBytes;
if(dnodes)
delete dnodes;
if(dplanes)
delete dplanes;
if(dleafs)
delete dleafs;
if(drawVerts)
delete drawVerts;
if(drawSurfaces)
delete drawSurfaces;
if(dleafsurfaces)
delete dleafsurfaces;
if(dleafbrushes)
delete dleafbrushes;
if(dbrushes)
delete dbrushes;
if(dbrushsides)
delete dbrushsides;
}

View File

@@ -0,0 +1,134 @@
#define LUMP_ENTITIES 0
#define LUMP_SHADERS 1
#define LUMP_PLANES 2
#define LUMP_NODES 3
#define LUMP_LEAFS 4
#define LUMP_LEAFSURFACES 5
#define LUMP_LEAFBRUSHES 6
#define LUMP_MODELS 7
#define LUMP_BRUSHES 8
#define LUMP_BRUSHSIDES 9
#define LUMP_DRAWVERTS 10
#define LUMP_DRAWINDEXES 11
#define LUMP_FOGS 12
#define LUMP_SURFACES 13
#define LUMP_LIGHTMAPS 14
#define LUMP_LIGHTGRID 15
#define LUMP_VISIBILITY 16
#define HEADER_LUMPS 17
typedef struct {
int fileofs, filelen;
} lump_t;
typedef struct {
int ident;
int version;
lump_t lumps[HEADER_LUMPS];
} dheader_t;
typedef struct {
float normal[3];
float dist;
} dplane_t;
typedef struct {
int planeNum;
int children[2]; // negative numbers are -(leafs+1), not nodes
int mins[3]; // for frustom culling
int maxs[3];
} dnode_t;
typedef struct {
int cluster; // -1 = opaque cluster (do I still store these?)
int area;
int mins[3]; // for frustum culling
int maxs[3];
int firstLeafSurface;
int numLeafSurfaces;
int firstLeafBrush;
int numLeafBrushes;
} dleaf_t;
typedef struct {
vec3_t xyz;
float st[2];
float lightmap[2];
vec3_t normal;
byte color[4];
} qdrawVert_t;
typedef struct {
int shaderNum;
int fogNum;
int surfaceType;
int firstVert;
int numVerts;
int firstIndex;
int numIndexes;
int lightmapNum;
int lightmapX, lightmapY;
int lightmapWidth, lightmapHeight;
vec3_t lightmapOrigin;
vec3_t lightmapVecs[3]; // for patches, [0] and [1] are lodbounds
int patchWidth;
int patchHeight;
} dsurface_t;
typedef struct {
int planeNum; // positive plane side faces out of the leaf
int shaderNum;
} dbrushside_t;
typedef struct {
int firstSide;
int numSides;
int shaderNum; // the shader that determines the contents flags
} dbrush_t;
typedef enum {
MST_BAD,
MST_PLANAR,
MST_PATCH,
MST_TRIANGLE_SOUP,
MST_FLARE
} mapSurfaceType_t;
#define MAX_MAP_VISIBILITY 0x200000
#define MAX_MAP_NODES 0x20000
#define MAX_MAP_PLANES 0x20000
#define MAX_MAP_LEAFS 0x20000
extern int numVisBytes;
extern int numleafs;
extern int numplanes;
extern int numnodes;
extern int numDrawVerts;
extern int numDrawSurfaces;
extern int numleafsurfaces;
extern int numbrushes;
extern int numbrushsides;
extern int numleafbrushes;
extern dnode_t *dnodes;
extern dplane_t *dplanes;
extern dleaf_t *dleafs;
extern byte *visBytes;
extern qdrawVert_t *drawVerts;
extern dsurface_t *drawSurfaces;
extern int *dleafsurfaces;
extern dbrush_t *dbrushes;
extern dbrushside_t *dbrushsides;
extern int *dleafbrushes;
bool LoadBSPFile( const char *filename );
void FreeBSPData();

View File

@@ -0,0 +1,17 @@
common/areaportal
common/clip
common/clusterportal
common/cushion
common/donotenter
common/full_clip
common/hint
common/missileclip
common/nodraw
common/nodrawnonsolid
common/nodrop
common/noimpact
common/origin
common/trigger
common/weapclip
liquid
fog

View File

View File

@@ -0,0 +1,61 @@
base_light/light1blue_2000
base_light/light1blue_5000
ctf/blue_telep
ctf/ctf_blueflag
ctf/ctf_tower_bluefin_shiny
gothic_door/door02_eblue2_shiny
gothic_light/ironcrossltblue_10000
gothic_light/ironcrossltblue_2000
gothic_light/ironcrossltblue_20000
gothic_light/ironcrossltblue_3000
gothic_light/ironcrossltblue_30000
gothic_light/ironcrossltblue_4000
gothic_light/ironcrossltblue_5000
sfx/beam_blue
sfx/flameanim_blue
sfx/flameanim_blue_nolight
sfx/flameanim_blue_pj
sfx/mkc_fog_ctfblue
sfx/xbluefog
base_wall2/blue_metal
base_wall2/jumppad_blue_kc
base_wall2/blue_line
base_wall2/double_line_blue
base_wall2/blue_arrow_small
base_wall2/blue_circle
base_wall2/bluearrows
base_wall2/blue_solid
ctf2/blueteam01
ctf2/blueteam02
ctf2/xblueteam01
ctf2/blue_banner02
proto2/blueflag
proto2/blueob
proto2/marbledoor_blue
proto2/concrete_bluenfx
proto2/bluelight_on
proto2/bsbluelight_on
proto2/rsbluelight_off
proto2/bsbluelight_off
proto2/rsbluelight_on
proto2/bluetrim01
proto2/blue_zot
proto2/blue_zot2
proto2/bluea_dcl
proto2/concrete_blue
proto2/teamwerkz_blue1
proto2/blueflare2
proto2/blueflare
sfx2/flameanim_blue_lowlite
sfx2/blue_jumpad05
sfx2/blue_launchpad
sfx2/blue_jumpad
sfx2/blue_jumpad2
sfx2/blue_jumpad3
sfx2/bluegoal2
tim/blue_flagbase
team_icon/the fallen_blue
team_icon/intruders_blue
team_icon/crusaders_blue
team_icon/pagans_blue
team_icon/stroggs_blue

View File

@@ -0,0 +1,61 @@
base_light/light1red_2000
base_light/light1red_5000
ctf/red_telep
ctf/ctf_redflag
ctf/ctf_tower_redfin_shiny
gothic_door/door02_bred2_shiny
gothic_light/ironcrossltred_10000
gothic_light/ironcrossltred_2000
gothic_light/ironcrossltred_20000
gothic_light/ironcrossltred_3000
gothic_light/ironcrossltred_30000
gothic_light/ironcrossltred_4000
gothic_light/ironcrossltred_5000
sfx/beam_red
sfx/flameanim_red
sfx/flameanim_red_nolight
sfx/flameanim_red_pj
sfx/mkc_fog_ctfred
sfx/xredfog
base_wall2/red_metal
base_wall2/jumppad_red_kc
base_wall2/red_line
base_wall2/double_line_red
base_wall2/red_arrow_small
base_wall2/red_circle
base_wall2/redarrows
base_wall2/red_solid
ctf2/redteam01
ctf2/redteam02
ctf2/xredteam01x
ctf2/red_banner02
proto2/redflag
proto2/redob
proto2/marbledoor_red
proto2/concrete_rednfx
proto2/redlight_on
proto2/bsredlight_on
proto2/rsredlight_off
proto2/bsredlight_off
proto2/rsredlight_on
proto2/redtrim01
proto2/red_zot
proto2/red_zot2
proto2/reda_dcl
proto2/concrete_red
proto2/teamwerkz_red1
proto2/redflare2
proto2/redflare
sfx2/flameanim_red_lowlite
sfx2/red_jumpad05
sfx2/red_launchpad
sfx2/red_jumpad
sfx2/red_jumpad2
sfx2/red_jumpad3
sfx2/redgoal2
tim/red_flagbase
team_icon/the fallen_red
team_icon/intruders_red
team_icon/crusaders_red
team_icon/pagans_red
team_icon/stroggs_red

View File

@@ -0,0 +1,5 @@
base_support/support1rust
base_support/support1shiny
base_support/support2rust
base_support/wplat1_1
base_support/plate2_5

View File

@@ -0,0 +1,10 @@
base_door/shinymetaldoor
base_door/shinymetaldoor_outside
gothic_door/door02_bred
gothic_door/door02_bred2_shiny
gothic_door/door02_eblue2_shiny
gothic_door/door02_i_ornate5_fin
gothic_door/door02_j
gothic_door/door02_j3
gothic_door/door02_j4
gothic_door/door02_k2b

View File

@@ -0,0 +1,14 @@
{
"entity" "misc_model"
"offset" "-16"
"model" "models/mapobjects/trees_sd/tree_a.md3"
"model" "models/mapobjects/trees_sd/tree_b.md3"
"model" "models/mapobjects/trees_sd/tree_c.md3"
"model" "models/mapobjects/trees_sd/tree_d.md3"
"pitch" "-5" "5"
"yaw" "0" "360"
"scale" "1" "1.3"
}

View File

@@ -0,0 +1,340 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "CPortals.h"
//#include "misc.h"
#define LINE_BUF 1000
#define MSG_PREFIX "bobToolz plugin: "
// these classes are far less of a mess than my code was,
// thanq to G.DeWan 4 the prtview source on which it was based
CBspPortal::CBspPortal()
{
memset(this, 0, sizeof(CBspPortal));
}
CBspPortal::~CBspPortal()
{
delete[] point;
}
void ClampFloat(float* p)
{
double i;
double frac = modf(*p, &i);
if(!frac)
return;
if(fabs(*p - ceil(*p)) < MAX_ROUND_ERROR)
*p = static_cast<float>(ceil(*p));
if(fabs(*p - floor(*p)) < MAX_ROUND_ERROR)
*p = static_cast<float>(floor(*p));
}
bool CBspPortal::Build(char *def, unsigned int pointCnt, bool bInverse)
{
char *c = def;
unsigned int n;
point_count = pointCnt;
if(point_count < 3)
return FALSE;
point = new CBspPoint[point_count];
for(n = 0; n < point_count; n++)
{
for(; *c != 0 && *c != '('; c++);
if(*c == 0)
return FALSE;
c++;
int x;
if(bInverse)
x = point_count - n - 1;
else
x = n;
sscanf(c, "%f %f %f", &point[x].p[0], &point[x].p[1], &point[x].p[2]);
ClampFloat(&point[x].p[0]);
ClampFloat(&point[x].p[1]);
ClampFloat(&point[x].p[2]);
}
return TRUE;
}
CPortals::CPortals()
{
memset(this, 0, sizeof(CPortals));
}
CPortals::~CPortals()
{
Purge();
}
void CPortals::Purge()
{
if(node)
delete[] node;
node = NULL;
node_count = 0;
}
void CPortals::Load()
{
char buf[LINE_BUF+1];
memset(buf, 0, LINE_BUF + 1);
Purge();
Sys_Printf(MSG_PREFIX "Loading portal file %s.\n", fn);
FILE *in;
in = fopen(fn, "rt");
if(in == NULL)
{
Sys_Printf(" ERROR - could not open file.\n");
return;
}
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
if(strncmp("PRT1", buf, 4) != 0)
{
fclose(in);
Sys_Printf(" ERROR - File header indicates wrong file type (should be \"PRT1\").\n");
return;
}
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
sscanf(buf, "%u", &node_count);
if(node_count > 0xFFFF)
{
fclose(in);
node_count = 0;
Sys_Printf(" ERROR - Extreme number of nodes, aborting.\n");
return;
}
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
node_count = 0;
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
unsigned int p_count;
sscanf(buf, "%u", &p_count);
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
node_count = 0;
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
unsigned int p_count2;
sscanf(buf, "%u", &p_count2);
node = new CBspNode[node_count];
unsigned int i;
for(i = 0; i < p_count; i++)
{
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
node_count = 0;
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
unsigned int dummy, node1, node2;
sscanf(buf, "%u %u %u", &dummy, &node1, &node2);
node[node1].portal_count++;
node[node2].portal_count++;
}
for(i = 0; i < p_count2; i++)
{
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
node_count = 0;
Sys_Printf(" ERROR - File ended prematurely.\n");
return;
}
unsigned int dummy, node1;
sscanf(buf, "%u %u", &dummy, &node1);
node[node1].portal_count++;
}
for(i = 0; i < node_count; i++)
node[i].portal = new CBspPortal[node[i].portal_count];
fclose(in);
in = fopen(fn, "rt");
fgets(buf, LINE_BUF, in);
fgets(buf, LINE_BUF, in);
fgets(buf, LINE_BUF, in);
fgets(buf, LINE_BUF, in);
unsigned int n;
for(n = 0; n < p_count; n++)
{
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
Purge();
Sys_Printf(" ERROR - Could not find information for portal number %d of %d.\n", n + 1, p_count);
return;
}
unsigned int pCount, node1, node2;
sscanf(buf, "%u %u %u", &pCount, &node1, &node2);
if(!node[node1].AddPortal(buf, pCount, FALSE))
{
fclose(in);
Purge();
Sys_Printf(" ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count);
return;
}
if(!node[node2].AddPortal(buf, pCount, TRUE))
{
fclose(in);
Purge();
Sys_Printf(" ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count);
return;
}
}
for(n = 0; n < p_count2; n++)
{
if(!fgets(buf, LINE_BUF, in))
{
fclose(in);
Purge();
Sys_Printf(" ERROR - Could not find information for portal number %d of %d.\n", n + 1, p_count);
return;
}
unsigned int pCount, node1;
sscanf(buf, "%u %u", &pCount, &node1);
if(!node[node1].AddPortal(buf, pCount, FALSE))
{
fclose(in);
Purge();
Sys_Printf(" ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count);
return;
}
}
fclose(in);
}
CBspNode::CBspNode()
{
portal = NULL;
portal_count = 0;
portal_next = 0;
}
CBspNode::~CBspNode()
{
if(portal != NULL)
delete[] portal;
}
bool CBspNode::AddPortal(char *def, unsigned int pointCnt, bool bInverse)
{
return portal[portal_next++].Build(def, pointCnt, bInverse);
}

View File

@@ -0,0 +1,97 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "funchandlers.h"
#include "misc.h"
#include "dialogs/dialogs-gtk.h"
// Radiant function table
_QERFuncTable_1 g_FuncTable;
_QERAppBSPFrontendTable g_BSPTable; // for map name
BOOL g_bBSPInitDone = FALSE;
// plugin name
static const char *PLUGIN_NAME = "ctfToolz";
// commands in the menu
static const char *PLUGIN_COMMANDS = "About...,Colour Changer...,Swap Light Colours,Change Angles 180,Swap Spawn Points";
// globals
GtkWidget *g_pRadiantWnd=NULL;
static const char *PLUGIN_ABOUT = "ctfToolz for GtkRadiant\n"
"by djbob\n"
"http://www.planetquake.com/toolz\n\n";
extern "C" LPVOID WINAPI QERPlug_GetFuncTable()
{
return &g_FuncTable;
}
extern "C" LPCSTR WINAPI QERPlug_Init(HMODULE hApp, GtkWidget* pMainWidget)
{
g_pRadiantWnd = pMainWidget;
memset(&g_FuncTable, 0, sizeof(_QERFuncTable_1));
g_FuncTable.m_fVersion = QER_PLUG_VERSION;
g_FuncTable.m_nSize = sizeof(_QERFuncTable_1);
return "ctfToolz for GTKradiant";
}
extern "C" LPCSTR WINAPI QERPlug_GetName()
{
return (char*)PLUGIN_NAME;
}
extern "C" LPCSTR WINAPI QERPlug_GetCommandList()
{
return (char*)PLUGIN_COMMANDS;
}
extern "C" void WINAPI QERPlug_Dispatch (LPCSTR p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
{
LoadLists();
if (!g_bBSPInitDone)
{
g_BSPTable.m_nSize = sizeof(_QERAppBSPFrontendTable);
if ( g_FuncTable.m_pfnRequestInterface( QERAppBSPFrontendTable_GUID, static_cast<LPVOID>(&g_BSPTable) ) )
g_bBSPInitDone = TRUE;
else
{
Sys_ERROR("_QERAppBSPFrontendTable interface request failed\n");
return;
}
}
if(!strcmp(p, "About..."))
DoMessageBox(PLUGIN_ABOUT, "About", IDOK);
else if(!strcmp(p, "Colour Changer..."))
DoCTFColourChanger();
else if(!strcmp(p, "Swap Light Colours"))
DoSwapLights();
else if(!strcmp(p, "Change Angles 180"))
DoChangeAngles();
else if(!strcmp(p, "Swap Spawn Points"))
DoSwapSpawns();
}

View File

@@ -0,0 +1,34 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ctfresource_gtk.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,109 @@
//Microsoft Developer Studio generated resource script.
//
#include "ctfresource_gtk.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"ctfresource_gtk.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
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "bobCo\0"
VALUE "FileDescription", "All your plugins are belong to us\0"
VALUE "FileVersion", "1, 0, 0, 0\0"
VALUE "InternalName", "ctftoolz\0"
VALUE "LegalCopyright", "Copyright © 2001\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "ctftoolz.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "bobCo ctftoolz\0"
VALUE "ProductVersion", "1, 0, 0, 0\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1200
END
END
#endif // !_MAC
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,12 @@
; plugin.def : Declares the module parameters for the DLL.
LIBRARY "ctfToolz"
DESCRIPTION 'ctfToolz Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
QERPlug_Init @1
QERPlug_GetName @2
QERPlug_GetCommandList @3
QERPlug_Dispatch @4
QERPlug_GetFuncTable @5

View File

@@ -0,0 +1,62 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// AboutDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "AboutDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
//static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog dialog
CAboutDialog::CAboutDialog(CWnd* pParent /*=NULL*/)
: CDialog(CAboutDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CAboutDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CAboutDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDialog)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)
//{{AFX_MSG_MAP(CAboutDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog message handlers

View File

@@ -0,0 +1,64 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_ABOUTDIALOG_H__3BA55F71_1D27_11D3_BC7B_F7EFD9765E37__INCLUDED_)
#define AFX_ABOUTDIALOG_H__3BA55F71_1D27_11D3_BC7B_F7EFD9765E37__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// AboutDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog dialog
class CAboutDialog : public CDialog
{
// Construction
public:
CAboutDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAboutDialog)
enum { IDD = IDD_ABOUT };
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAboutDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ABOUTDIALOG_H__3BA55F71_1D27_11D3_BC7B_F7EFD9765E37__INCLUDED_)

View File

@@ -0,0 +1,63 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// AutoCaulkDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "../bobtoolz.h"
#include "AutoCaulkDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkDialog dialog
CAutoCaulkDialog::CAutoCaulkDialog(CWnd* pParent /*=NULL*/)
: CDialog(CAutoCaulkDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CAutoCaulkDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CAutoCaulkDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAutoCaulkDialog)
DDX_Control(pDX, IDC_PROGRESS2, m_prog2);
DDX_Control(pDX, IDC_PROGRESS1, m_prog1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAutoCaulkDialog, CDialog)
//{{AFX_MSG_MAP(CAutoCaulkDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkDialog message handlers

View File

@@ -0,0 +1,66 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_AUTOCAULKDIALOG_H__C2783D61_DDEB_11D4_ACF6_004095A18133__INCLUDED_)
#define AFX_AUTOCAULKDIALOG_H__C2783D61_DDEB_11D4_ACF6_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// AutoCaulkDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkDialog dialog
class CAutoCaulkDialog : public CDialog
{
// Construction
public:
CAutoCaulkDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAutoCaulkDialog)
enum { IDD = IDD_AUTOCAULK_DIALOG };
CProgressCtrl m_prog2;
CProgressCtrl m_prog1;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAutoCaulkDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAutoCaulkDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_AUTOCAULKDIALOG_H__C2783D61_DDEB_11D4_ACF6_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,66 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// AutoCaulkStartDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "../bobtoolz.h"
#include "AutoCaulkStartDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkStartDialog dialog
CAutoCaulkStartDialog::CAutoCaulkStartDialog(CWnd* pParent /*=NULL*/)
: CDialog(CAutoCaulkStartDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CAutoCaulkStartDialog)
m_bAllowDestruction = FALSE;
m_Warning1 = _T("");
m_nMode = 0;
//}}AFX_DATA_INIT
}
void CAutoCaulkStartDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAutoCaulkStartDialog)
DDX_Check(pDX, IDC_KILLBRUSHES_CHECK, m_bAllowDestruction);
DDX_Text(pDX, IDC_WARNING1_STATIC, m_Warning1);
DDX_Radio(pDX, IDC_AC_NORMAL_RADIO, m_nMode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAutoCaulkStartDialog, CDialog)
//{{AFX_MSG_MAP(CAutoCaulkStartDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkStartDialog message handlers

View File

@@ -0,0 +1,71 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_AUTOCAULKSTARTDIALOG_H__F3DE2E81_E73E_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_AUTOCAULKSTARTDIALOG_H__F3DE2E81_E73E_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// AutoCaulkStartDialog.h : header file
//
#define MODE_AC_NORMAL 0
#define MODE_AC_BUILD_MINI_PRT 1
#define MODE_AC_SUPER 2
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkStartDialog dialog
class CAutoCaulkStartDialog : public CDialog
{
// Construction
public:
CAutoCaulkStartDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAutoCaulkStartDialog)
enum { IDD = IDD_AUTOCAULKSTART_DIALOG };
BOOL m_bAllowDestruction;
CString m_Warning1;
int m_nMode;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAutoCaulkStartDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAutoCaulkStartDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_AUTOCAULKSTARTDIALOG_H__F3DE2E81_E73E_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,65 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_BRUSHCHECKDIALOG_H__4BF2C701_D9EF_11D4_ACF6_004095A18133__INCLUDED_)
#define AFX_BRUSHCHECKDIALOG_H__4BF2C701_D9EF_11D4_ACF6_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BrushCheckDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CBrushCheckDialog dialog
class CBrushCheckDialog : public CDialog
{
// Construction
public:
CBrushCheckDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CBrushCheckDialog)
enum { IDD = IDD_BRUSHCHECKER_DIALOG };
CProgressCtrl m_prog1;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrushCheckDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CBrushCheckDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BRUSHCHECKDIALOG_H__4BF2C701_D9EF_11D4_ACF6_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,92 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// DoorDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "DoorDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDoorDialog dialog
CDoorDialog::CDoorDialog(CWnd* pParent /*=NULL*/)
: CDialog(CDoorDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CDoorDialog)
m_fbTextureName = _T("");
m_bSclMainHor = TRUE;
m_bSclMainVert = TRUE;
m_bSclTrimHor = TRUE;
m_bSclTrimVert = FALSE;
m_trimTextureName = _T("");
m_trimTexSetBox = _T("");
m_mainTexSetBox = _T("");
m_doorDirection = -1;
//}}AFX_DATA_INIT
}
void CDoorDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDoorDialog)
DDX_Text(pDX, IDC_FBTEXTURE_EDIT, m_fbTextureName);
DDX_Check(pDX, IDC_TEXSCALE1_CHECK, m_bSclMainHor);
DDX_Check(pDX, IDC_TEXSCALE2_CHECK, m_bSclMainVert);
DDX_Check(pDX, IDC_TEXSCALE3_CHECK, m_bSclTrimHor);
DDX_Check(pDX, IDC_TEXSCALE4_CHECK, m_bSclTrimVert);
DDX_Text(pDX, IDC_TRIMTEXTURE_EDIT, m_trimTextureName);
DDX_CBString(pDX, IDC_TRIMTEX_COMBO, m_trimTexSetBox);
DDX_CBString(pDX, IDC_MAINTEX_COMBO, m_mainTexSetBox);
DDX_Radio(pDX, IDC_DIR_NS_RADIO, m_doorDirection);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDoorDialog, CDialog)
//{{AFX_MSG_MAP(CDoorDialog)
ON_BN_CLICKED(IDC_SET_MAINTEX_BTN, OnSetMaintexBtn)
ON_BN_CLICKED(IDC_SET_TRIMTEX_BTN, OnSetTrimtexBtn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDoorDialog message handlers
void CDoorDialog::OnSetMaintexBtn()
{
UpdateData(TRUE);
m_fbTextureName = m_mainTexSetBox;
UpdateData(FALSE);
}
void CDoorDialog::OnSetTrimtexBtn()
{
UpdateData(TRUE);
m_trimTextureName = m_trimTexSetBox;
UpdateData(FALSE);
}

View File

@@ -0,0 +1,74 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_DOORDIALOG_H__F36CBE01_D2C4_11D4_AE97_004095A18133__INCLUDED_)
#define AFX_DOORDIALOG_H__F36CBE01_D2C4_11D4_AE97_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DoorDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CDoorDialog dialog
class CDoorDialog : public CDialog
{
// Construction
public:
CDoorDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDoorDialog)
enum { IDD = IDD_DOOR_DIALOG };
CString m_fbTextureName;
BOOL m_bSclMainHor;
BOOL m_bSclMainVert;
BOOL m_bSclTrimHor;
BOOL m_bSclTrimVert;
CString m_trimTextureName;
CString m_trimTexSetBox;
CString m_mainTexSetBox;
int m_doorDirection;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDoorDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDoorDialog)
afx_msg void OnSetMaintexBtn();
afx_msg void OnSetTrimtexBtn();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DOORDIALOG_H__F36CBE01_D2C4_11D4_AE97_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,65 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// IntersectDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "IntersectDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIntersectDialog dialog
CIntersectDialog::CIntersectDialog(CWnd* pParent /*=NULL*/)
: CDialog(CIntersectDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CIntersectDialog)
m_nBrushOptions = 1;
m_bUseDetail = FALSE;
m_bDuplicateOnly = FALSE;
//}}AFX_DATA_INIT
}
void CIntersectDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CIntersectDialog)
DDX_Radio(pDX, IDC_WHOLEMAP_RADIO, m_nBrushOptions);
DDX_Check(pDX, IDC_DETAIL_INCLUDE_CHECK, m_bUseDetail);
DDX_Check(pDX, IDC_DUPLICATEONLY_CHECK, m_bDuplicateOnly);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CIntersectDialog, CDialog)
//{{AFX_MSG_MAP(CIntersectDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIntersectDialog message handlers

View File

@@ -0,0 +1,70 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_INTERSECTDIALOG_H__03507C01_D3B3_11D4_AE97_004095A18133__INCLUDED_)
#define AFX_INTERSECTDIALOG_H__03507C01_D3B3_11D4_AE97_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// IntersectDialog.h : header file
//
#define BRUSH_OPT_WHOLE_MAP 0
#define BRUSH_OPT_SELECTED 1
/////////////////////////////////////////////////////////////////////////////
// CIntersectDialog dialog
class CIntersectDialog : public CDialog
{
// Construction
public:
CIntersectDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CIntersectDialog)
enum { IDD = IDD_INTERSECT_DIALOG };
int m_nBrushOptions;
BOOL m_bUseDetail;
BOOL m_bDuplicateOnly;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIntersectDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CIntersectDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_INTERSECTDIALOG_H__03507C01_D3B3_11D4_AE97_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,61 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// IntersectInfoDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "../bobtoolz.h"
#include "IntersectInfoDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIntersectInfoDialog dialog
CIntersectInfoDialog::CIntersectInfoDialog(CWnd* pParent /*=NULL*/)
: CDialog(CIntersectInfoDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CIntersectInfoDialog)
//}}AFX_DATA_INIT
}
void CIntersectInfoDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CIntersectInfoDialog)
DDX_Control(pDX, IDC_PROGRESS1, m_prog1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CIntersectInfoDialog, CDialog)
//{{AFX_MSG_MAP(CIntersectInfoDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIntersectInfoDialog message handlers

View File

@@ -0,0 +1,65 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_INTERSECTINFODIALOG_H__62CDC8CD_D9D2_11D4_ACF6_004095A18133__INCLUDED_)
#define AFX_INTERSECTINFODIALOG_H__62CDC8CD_D9D2_11D4_ACF6_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// IntersectInfoDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CIntersectInfoDialog dialog
class CIntersectInfoDialog : public CDialog
{
// Construction
public:
CIntersectInfoDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CIntersectInfoDialog)
enum { IDD = IDD_INTERSECT_INFO_DIALOG };
CProgressCtrl m_prog1;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIntersectInfoDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CIntersectInfoDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_INTERSECTINFODIALOG_H__62CDC8CD_D9D2_11D4_ACF6_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,116 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// PolygonDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "PolygonDialog.h"
#include "../shapes.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPolygonDialog dialog
CPolygonDialog::CPolygonDialog(CWnd* pParent /*=NULL*/)
: CDialog(CPolygonDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPolygonDialog)
m_nSideCount = 3;
m_bInverse = FALSE;
m_bBorder = FALSE;
m_nBorderSize = 8;
m_bAlignTop = FALSE;
//}}AFX_DATA_INIT
}
void CPolygonDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPolygonDialog)
DDX_Text(pDX, IDC_EDIT1, m_nSideCount);
DDV_MinMaxUInt(pDX, m_nSideCount, 3, MAX_POLYGON_FACES);
DDX_Check(pDX, IDC_INVERSE_CHK, m_bInverse);
DDX_Check(pDX, IDC_BORDER_CHK, m_bBorder);
DDX_Text(pDX, IDC_BORDER_EDIT, m_nBorderSize);
DDV_MinMaxUInt(pDX, m_nBorderSize, 1, 1024);
DDX_Check(pDX, IDC_ALIGN_CHK, m_bAlignTop);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPolygonDialog, CDialog)
//{{AFX_MSG_MAP(CPolygonDialog)
ON_BN_CLICKED(IDC_BORDER_CHK, OnBorderChkClicked)
ON_BN_CLICKED(IDC_INVERSE_CHK, OnInverseChkClickrd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPolygonDialog message handlers
BOOL CPolygonDialog::OnInitDialog()
{
CDialog::OnInitDialog();
EnableBordered(!GetChkBool(IDC_INVERSE_CHK));
EnableBorderEdit(!GetChkBool(IDC_INVERSE_CHK) && GetChkBool(IDC_BORDER_CHK));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPolygonDialog::EnableBordered(BOOL bEnable)
{
CWnd* dtlChk = GetDlgItem(IDC_BORDER_CHK);
if(dtlChk)
dtlChk->EnableWindow(bEnable);
}
void CPolygonDialog::EnableBorderEdit(BOOL bEnable)
{
CWnd* dtlChk = GetDlgItem(IDC_BORDER_EDIT);
if(dtlChk)
dtlChk->EnableWindow(bEnable);
}
void CPolygonDialog::OnBorderChkClicked()
{
EnableBorderEdit(!GetChkBool(IDC_INVERSE_CHK) && GetChkBool(IDC_BORDER_CHK));
}
void CPolygonDialog::OnInverseChkClickrd()
{
EnableBordered(!GetChkBool(IDC_INVERSE_CHK));
EnableBorderEdit(!GetChkBool(IDC_INVERSE_CHK) && GetChkBool(IDC_BORDER_CHK));
}
BOOL CPolygonDialog::GetChkBool(int nID)
{
CButton* btn = (CButton*)GetDlgItem(nID);
if(btn)
return btn->GetCheck();
return FALSE;
}

View File

@@ -0,0 +1,74 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_POLYGONDIALOG_H__EF7FE400_628A_11D1_B66D_004095A18133__INCLUDED_)
#define AFX_POLYGONDIALOG_H__EF7FE400_628A_11D1_B66D_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PolygonDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CPolygonDialog dialog
class CPolygonDialog : public CDialog
{
// Construction
public:
BOOL GetChkBool(int nID);
void EnableBorderEdit(BOOL bEnable);
void EnableBordered(BOOL bEnable);
CPolygonDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CPolygonDialog)
enum { IDD = IDD_POLYGON_DIALOG };
UINT m_nSideCount;
BOOL m_bInverse;
BOOL m_bBorder;
UINT m_nBorderSize;
BOOL m_bAlignTop;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPolygonDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPolygonDialog)
virtual BOOL OnInitDialog();
afx_msg void OnBorderChkClicked();
afx_msg void OnInverseChkClickrd();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_POLYGONDIALOG_H__EF7FE400_628A_11D1_B66D_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,105 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// StairDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "StairDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStairDialog dialog
CStairDialog::CStairDialog(CWnd* pParent /*=NULL*/)
: CDialog(CStairDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CStairDialog)
m_nStairHeight = 8;
m_StairDir = 0;
m_StairStyle = 0;
m_riserTexture = _T("");
m_bDetail = TRUE;
//}}AFX_DATA_INIT
}
void CStairDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStairDialog)
DDX_Text(pDX, IDC_EDIT1, m_nStairHeight);
DDV_MinMaxUInt(pDX, m_nStairHeight, 1, 256);
DDX_Radio(pDX, IDC_DIR_N_RADIO, m_StairDir);
DDX_Radio(pDX, IDC_STYLE_ORIG_RADIO, m_StairStyle);
DDX_Text(pDX, IDC_RISER_EDIT, m_riserTexture);
DDV_MaxChars(pDX, m_riserTexture, 256);
DDX_Check(pDX, IDC_DETAIL_CHK, m_bDetail);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStairDialog, CDialog)
//{{AFX_MSG_MAP(CStairDialog)
ON_BN_CLICKED(IDC_STYLE_BOB_RADIO, OnStyleBobClicked)
ON_BN_CLICKED(IDC_STYLE_ORIG_RADIO, OnStyleOrigClicked)
ON_BN_CLICKED(IDC_STYLE_CORNER_RADIO, OnStyleCornerClicked)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStairDialog message handlers
void CStairDialog::OnStyleBobClicked()
{
EnableDetail(TRUE);
}
void CStairDialog::OnStyleOrigClicked()
{
EnableDetail(FALSE);
}
void CStairDialog::EnableDetail(BOOL bEnable)
{
CWnd* dtlChk = GetDlgItem(IDC_DETAIL_CHK);
if(dtlChk)
dtlChk->EnableWindow(bEnable);
}
BOOL CStairDialog::OnInitDialog()
{
CDialog::OnInitDialog();
EnableDetail(m_StairStyle == 1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CStairDialog::OnStyleCornerClicked()
{
EnableDetail(FALSE);
}

View File

@@ -0,0 +1,74 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_STAIRDIALOG_H__942FFF20_5F9E_11D1_B66D_004095A18133__INCLUDED_)
#define AFX_STAIRDIALOG_H__942FFF20_5F9E_11D1_B66D_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// StairDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CStairDialog dialog
class CStairDialog : public CDialog
{
// Construction
public:
CStairDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CStairDialog)
enum { IDD = IDD_STAIR_DIALOG };
UINT m_nStairHeight;
int m_StairDir;
int m_StairStyle;
CString m_riserTexture;
BOOL m_bDetail;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CStairDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CStairDialog)
afx_msg void OnStyleBobClicked();
afx_msg void OnStyleOrigClicked();
virtual BOOL OnInitDialog();
afx_msg void OnStyleCornerClicked();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void EnableDetail(BOOL bEnable);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STAIRDIALOG_H__942FFF20_5F9E_11D1_B66D_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,81 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// TextureResetDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "../bobtoolz.h"
#include "TextureResetDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTextureResetDialog dialog
CTextureResetDialog::CTextureResetDialog(CWnd* pParent /*=NULL*/)
: CDialog(CTextureResetDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CTextureResetDialog)
m_bAllTextures = FALSE;
m_TextureName = _T("");
m_nRotation = 0;
m_fScaleHorizontal = 0.5f;
m_fScaleVertical = 0.5f;
m_nShiftHorizontal = 0;
m_nShiftVertical = 0;
m_bOnlyTexture = FALSE;
m_NewTextureName = _T("");
//}}AFX_DATA_INIT
}
void CTextureResetDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTextureResetDialog)
DDX_Check(pDX, IDC_ALLTEXTURES_CHECK, m_bAllTextures);
DDX_Text(pDX, IDC_RESET_TEXTURE_EDIT, m_TextureName);
DDV_MaxChars(pDX, m_TextureName, 256);
DDX_Text(pDX, IDC_ROTATION_EDIT, m_nRotation);
DDV_MinMaxInt(pDX, m_nRotation, 0, 360);
DDX_Text(pDX, IDC_SCL_HOR_EDIT, m_fScaleHorizontal);
DDX_Text(pDX, IDC_SCL_VERT_EDIT, m_fScaleVertical);
DDX_Text(pDX, IDC_SHFT_HOR_EDIT, m_nShiftHorizontal);
DDX_Text(pDX, IDC_SHFT_VER_EDIT, m_nShiftVertical);
DDX_Check(pDX, IDC_ONLYTEXTURE_CHECK, m_bOnlyTexture);
DDX_Text(pDX, IDC_RESET_NEW_TEXTURE_EDIT, m_NewTextureName);
DDV_MaxChars(pDX, m_NewTextureName, 256);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTextureResetDialog, CDialog)
//{{AFX_MSG_MAP(CTextureResetDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTextureResetDialog message handlers

View File

@@ -0,0 +1,73 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_TEXTURERESETDIALOG_H__42D665C1_ED84_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_TEXTURERESETDIALOG_H__42D665C1_ED84_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TextureResetDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CTextureResetDialog dialog
class CTextureResetDialog : public CDialog
{
// Construction
public:
CTextureResetDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CTextureResetDialog)
enum { IDD = IDD_TEXTURE_RESET_DIALOG };
BOOL m_bAllTextures;
CString m_TextureName;
int m_nRotation;
float m_fScaleHorizontal;
float m_fScaleVertical;
int m_nShiftHorizontal;
int m_nShiftVertical;
BOOL m_bOnlyTexture;
CString m_NewTextureName;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTextureResetDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CTextureResetDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TEXTURERESETDIALOG_H__42D665C1_ED84_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,61 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// BrushCheckDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "../bobtoolz.h"
#include "BrushCheckDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrushCheckDialog dialog
CBrushCheckDialog::CBrushCheckDialog(CWnd* pParent /*=NULL*/)
: CDialog(CBrushCheckDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CBrushCheckDialog)
//}}AFX_DATA_INIT
}
void CBrushCheckDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBrushCheckDialog)
DDX_Control(pDX, IDC_PROGRESS1, m_prog1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBrushCheckDialog, CDialog)
//{{AFX_MSG_MAP(CBrushCheckDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBrushCheckDialog message handlers

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
struct BuildStairsRS{
char mainTexture[256];
char riserTexture[256];
int direction;
int style;
int stairHeight;
bool bUseDetail;
};
struct ResetTextureRS {
int bResetTextureName;
char textureName[256];
char newTextureName[256];
int bResetScale[2];
float fScale[2];
int bResetShift[2];
float fShift[2];
int bResetRotation;
int rotation;
};
struct TrainThingRS {
float fRadiusX, fRadiusY;
float fStartAngle, fEndAngle;
int iNumPoints;
float fStartHeight, fEndHeight;
};
struct IntersectRS{
int nBrushOptions;
bool bUseDetail;
bool bDuplicateOnly;
};
struct PolygonRS{
bool bUseBorder;
bool bInverse;
bool bAlignTop;
int nSides;
int nBorderWidth;
};
struct DoorRS{
char mainTexture[256];
char trimTexture[256];
bool bScaleMainH;
bool bScaleMainV;
bool bScaleTrimH;
bool bScaleTrimV;
int nOrientation;
};
struct PathPlotterRS{
int nPoints;
float fMultiplier;
float fGravity;
bool bNoUpdate;
bool bShowExtra;
};
struct TwinWidget{
GtkWidget* one;
GtkWidget* two;
};
EMessageBoxReturn DoMessageBox(const char* lpText, const char* lpCaption, EMessageBoxType type);
EMessageBoxReturn DoIntersectBox(IntersectRS* rs);
EMessageBoxReturn DoPolygonBox(PolygonRS* rs);
EMessageBoxReturn DoResetTextureBox (ResetTextureRS* rs);
EMessageBoxReturn DoBuildStairsBox(BuildStairsRS* rs);
EMessageBoxReturn DoDoorsBox(DoorRS* rs);
EMessageBoxReturn DoPathPlotterBox(PathPlotterRS* rs);
EMessageBoxReturn DoCTFColourChangeBox();
EMessageBoxReturn DoTrainThingBox (TrainThingRS* rs);
//GtkWidget* GetProgressWindow(char* title, GtkProgressBar* feedback);

View File

@@ -0,0 +1,85 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// PathPlotterDialog.cpp : implementation file
//
#include "../StdAfx.h"
#include "../bobtoolz.h"
#include "PathPlotterDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPathPlotterDialog dialog
CPathPlotterDialog::CPathPlotterDialog(CWnd* pParent /*=NULL*/)
: CDialog(CPathPlotterDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPathPlotterDialog)
m_fGravity = -800.0f;
m_fMultiplier = 3.0f;
m_bNoUpdate = FALSE;
m_nPoints = 25;
m_bShowExtra = FALSE;
//}}AFX_DATA_INIT
}
void CPathPlotterDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPathPlotterDialog)
DDX_Text(pDX, IDC_GRAVITY_EDIT, m_fGravity);
DDV_MinMaxFloat(pDX, m_fGravity, -10000.f, -1.f);
DDX_Text(pDX, IDC_MULTIPLIER_EDIT, m_fMultiplier);
DDV_MinMaxFloat(pDX, m_fMultiplier, 1.f, 10.f);
DDX_Check(pDX, IDC_NOUPDATE_CHECK, m_bNoUpdate);
DDX_Text(pDX, IDC_POINTCOUNT_EDIT, m_nPoints);
DDV_MinMaxInt(pDX, m_nPoints, 1, 1000);
DDX_Check(pDX, IDC_SHOWEXTRA_CHECK, m_bShowExtra);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPathPlotterDialog, CDialog)
//{{AFX_MSG_MAP(CPathPlotterDialog)
ON_BN_CLICKED(IDYES, OnYes)
ON_BN_CLICKED(IDNO, OnNo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPathPlotterDialog message handlers
void CPathPlotterDialog::OnYes()
{
if(UpdateData())
EndModalLoop(IDYES);
}
void CPathPlotterDialog::OnNo()
{
EndModalLoop(IDNO);
}

View File

@@ -0,0 +1,70 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(AFX_PATHPLOTTERDIALOG_H__A0516221_F19B_11D4_ACF7_004095A18133__INCLUDED_)
#define AFX_PATHPLOTTERDIALOG_H__A0516221_F19B_11D4_ACF7_004095A18133__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PathPlotterDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CPathPlotterDialog dialog
class CPathPlotterDialog : public CDialog
{
// Construction
public:
CPathPlotterDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CPathPlotterDialog)
enum { IDD = IDD_PATHPLOTTER_DIALOG };
float m_fGravity;
float m_fMultiplier;
BOOL m_bNoUpdate;
int m_nPoints;
BOOL m_bShowExtra;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPathPlotterDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPathPlotterDialog)
afx_msg void OnYes();
afx_msg void OnNo();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PATHPLOTTERDIALOG_H__A0516221_F19B_11D4_ACF7_004095A18133__INCLUDED_)

View File

@@ -0,0 +1,790 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#ifdef WIN32
#pragma warning(disable : 4786)
#endif
#include "dialogs/dialogs-gtk.h"
#include "gtkr_list.h"
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#include "DEPair.h"
#include "DPatch.h"
#include "DEntity.h"
#include "DShape.h"
#include "DBobView.h"
#include "DVisDrawer.h"
#include "DTrainDrawer.h"
#include "misc.h"
#include "scriptparser.h"
#include "DTreePlanter.h"
#include "shapes.h"
#include "lists.h"
#include "funchandlers.h"
#include "visfind.h"
#include "iundo.h"
#include "refcounted_ptr.h"
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include "scenelib.h"
// for autocaulk
list<Str> exclusionList; // whole brush exclusion
list<Str> exclusionList_Face; // single face exclusion
bool el1Loaded = FALSE;
bool el2Loaded = FALSE;
bool clrLst1Loaded = FALSE;
bool clrLst2Loaded = FALSE;
DBobView* g_PathView = NULL;
DVisDrawer* g_VisView = NULL;
DTrainDrawer* g_TrainView = NULL;
DTreePlanter* g_TreePlanter = NULL;
// -------------
//========================//
// Helper Functions //
//========================//
void LoadLists()
{
char buffer[256];
if(!el1Loaded)
el1Loaded = LoadExclusionList(GetFilename(buffer, "bt/bt-el1.txt"), &exclusionList);
if(!el2Loaded)
el2Loaded = LoadExclusionList(GetFilename(buffer, "bt/bt-el2.txt"), &exclusionList_Face);
}
//========================//
// Main Functions //
//========================//
void DoIntersect()
{
IntersectRS rs;
if(DoIntersectBox(&rs) == eIDCANCEL)
return;
if(rs.nBrushOptions == BRUSH_OPT_SELECTED)
{
if( GlobalSelectionSystem().countSelected() < 2 )
{
DoMessageBox("Invalid number of brushes selected, choose at least 2", "Error", eMB_OK);
return;
}
}
DEntity world;
switch(rs.nBrushOptions)
{
case BRUSH_OPT_SELECTED:
{
world.LoadSelectedBrushes();
break;
}
case BRUSH_OPT_WHOLE_MAP:
{
world.LoadFromEntity(0, FALSE);
break;
}
}
world.RemoveNonCheckBrushes(&exclusionList, rs.bUseDetail);
bool* pbSelectList;
if(rs.bDuplicateOnly)
pbSelectList = world.BuildDuplicateList();
else
pbSelectList = world.BuildIntersectList();
world.SelectBrushes(pbSelectList);
delete[] pbSelectList;
}
void DoPolygonsTB()
{
DoPolygons();
}
void DoPolygons()
{
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 1 )
{
DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
return;
}
PolygonRS rs;
// ask user for type, size, etc....
if(DoPolygonBox(&rs) == eIDOK)
{
DShape poly;
vec3_t vMin, vMax;
{
scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin);
VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax);
instance.path().parent()->m_traverse->erase(instance.path().top());
}
if(rs.bInverse)
poly.BuildInversePrism(vMin, vMax, rs.nSides, rs.bAlignTop);
else
{
if(rs.bUseBorder)
poly.BuildBorderedPrism(vMin, vMax, rs.nSides, rs.nBorderWidth, rs.bAlignTop);
else
poly.BuildRegularPrism(vMin, vMax, rs.nSides, rs.bAlignTop);
}
poly.Commit();
}
}
void DoFixBrushes()
{
DMap world;
world.LoadAll();
int count = world.FixBrushes();
Sys_Printf("%i invalid/duplicate planes removed\n", count);
}
void DoResetTextures()
{
static ResetTextureRS rs;
const char* texName;
if(1/*g_SelectedFaceTable.m_pfnGetSelectedFaceCount() != 1*/)
{
texName = NULL;
}
else
{
texName = GetCurrentTexture();
strcpy(rs.textureName, GetCurrentTexture());
}
EMessageBoxReturn ret;
if((ret = DoResetTextureBox(&rs)) == eIDCANCEL)
return;
if(rs.bResetTextureName)
texName = rs.textureName;
if(ret == eIDOK)
{
DEntity world;
world.LoadSelectedBrushes();
world.ResetTextures(texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName,
rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation, TRUE);
}
else
{
DMap world;
world.LoadAll(TRUE);
world.ResetTextures(texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName,
rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation);
}
}
void DoBuildStairs()
{
BuildStairsRS rs;
strcpy(rs.mainTexture, GetCurrentTexture());
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 1 )
{
DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
return;
}
// ask user for type, size, etc....
if(DoBuildStairsBox(&rs) == eIDOK)
{
vec3_t vMin, vMax;
{
scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin);
VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax);
}
// calc brush size
vec3_t size;
VectorSubtract(vMax, vMin, size);
if(((int)size[2] % rs.stairHeight) != 0)
{
// stairs must fit evenly into brush
DoMessageBox("Invalid stair height\nHeight of block must be divisable by stair height", "Error", eMB_OK);
}
else
{
{
scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
instance.path().parent()->m_traverse->erase(instance.path().top());
}
// Get Step Count
int numSteps = (int)size[2] / rs.stairHeight;
if(rs.style == STYLE_CORNER)
{
BuildCornerStairs(vMin, vMax, numSteps, rs.mainTexture, rs.riserTexture);
}
else
{
// Get Step Dimensions
float stairHeight = (float)rs.stairHeight;
float stairWidth;
if((rs.direction == MOVE_EAST) || (rs.direction == MOVE_WEST))
stairWidth = (size[0])/numSteps;
else
stairWidth = (size[1])/numSteps;
// Build Base For Stair (bob's style)
if(rs.style == STYLE_BOB)
Build_Wedge(rs.direction, vMin, vMax, TRUE);
// Set First Step Starting Position
vMax[2] = vMin[2] + stairHeight;
SetInitialStairPos(rs.direction, vMin, vMax, stairWidth);
// Build The Steps
for(int i = 0; i < numSteps; i++)
{
if(rs.style == STYLE_BOB)
Build_StairStep_Wedge(rs.direction, vMin, vMax, rs.mainTexture, rs.riserTexture, rs.bUseDetail);
else if(rs.style == STYLE_ORIGINAL)
Build_StairStep(vMin, vMax, rs.mainTexture, rs.riserTexture, rs.direction);
// get step into next position
MoveBlock(rs.direction, vMin, vMax, stairWidth);
vMax[2] += stairHeight;
if(rs.style == STYLE_BOB)
vMin[2] += stairHeight; // wedge bottom must be raised
}
}
}
}
}
void DoBuildDoors()
{
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 1 )
{
DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
return;
}
DoorRS rs;
strcpy(rs.mainTexture, GetCurrentTexture());
if(DoDoorsBox(&rs) == eIDOK)
{
vec3_t vMin, vMax;
{
scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin);
VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax);
instance.path().parent()->m_traverse->erase(instance.path().top());
}
BuildDoorsX2(vMin, vMax,
rs.bScaleMainH, rs.bScaleMainV,
rs.bScaleTrimH, rs.bScaleTrimV,
rs.mainTexture, rs.trimTexture,
rs.nOrientation); // shapes.cpp
}
}
void DoPathPlotter()
{
PathPlotterRS rs;
EMessageBoxReturn ret = DoPathPlotterBox(&rs);
if(ret == eIDCANCEL)
return;
if(ret == eIDNO)
{
if(g_PathView)
delete g_PathView;
return;
}
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 1 )
{
DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
return;
}
scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
DEntity world;
world.LoadEPairList(instance.path().top()->m_entity);
DEPair* trigger_ep = world.FindEPairByKey("targetname");
if(trigger_ep)
{
if(!strcmp(world.m_Classname, "trigger_push"))
{
DEPair* target_ep = world.FindEPairByKey("target");
if(target_ep)
{
scene::Path* entTarget = FindEntityFromTargetname(target_ep->value, NULL);
if(entTarget)
{
if(g_PathView)
delete g_PathView;
g_PathView = new DBobView;
g_PathView->Begin(trigger_ep->value, target_ep->value, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra);
}
else
DoMessageBox("trigger_push target could not be found.", "Error", eMB_OK);
}
else
DoMessageBox("trigger_push has no target.", "Error", eMB_OK);
}
else
DoMessageBox("You must select a 'trigger_push' entity.", "Error", eMB_OK);
}
else
DoMessageBox("Entity must have a targetname", "Error", eMB_OK);
}
void DoPitBuilder()
{
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 1 )
{
DoMessageBox("Invalid number of brushes selected, choose 1 only", "Error", eMB_OK);
return;
}
vec3_t vMin, vMax;
scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin);
VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax);
DShape pit;
if(pit.BuildPit(vMin, vMax))
{
pit.Commit();
instance.path().parent()->m_traverse->erase(instance.path().top());
}
else
DoMessageBox("Failed To Make Pit\nTry Making The Brush Bigger", "Error", eMB_OK);
}
void DoMergePatches()
{
patch_merge_t merge_info;
DPatch mrgPatches[2];
int i;
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 2 )
{
DoMessageBox("Invalid number of patches selected, choose 2 only", "Error", eMB_OK);
return;
}
scene::Node* patches[2];
patches[0] = GlobalSelectionSystem().ultimateSelected().path().top();
patches[1] = GlobalSelectionSystem().penultimateSelected().path().top();
for (i = 0; i < 2; i++)
{
if (!patches[i]->m_patch)
{
DoMessageBox("You must select ONLY patches", "Error", eMB_OK);
return;
}
mrgPatches[0].LoadFromBrush(patches[i]);
}
/* mrgPatches[0].Transpose();
mrgPatches[0].RemoveFromRadiant();
mrgPatches[0].BuildInRadiant();*/
merge_info = mrgPatches[0].IsMergable(&mrgPatches[1]);
if (merge_info.mergable)
{
Sys_Printf("%i %i", merge_info.pos1, merge_info.pos2);
Sys_Printf("Patches Mergable\n");
DPatch* newPatch = mrgPatches[0].MergePatches(merge_info, &mrgPatches[0], &mrgPatches[1]);
/* mrgPatches[0].RemoveFromRadiant();
mrgPatches[0].BuildInRadiant();
mrgPatches[1].RemoveFromRadiant();
mrgPatches[1].BuildInRadiant();
delete newPatch;*/
if (!newPatch)
{
} else
{
mrgPatches[0].RemoveFromRadiant();
mrgPatches[1].RemoveFromRadiant();
newPatch->BuildInRadiant();
delete newPatch;
}
}
}
void DoSplitPatch() {
DPatch patch;
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 1 )
{
DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
return;
}
scene::Node* node = GlobalSelectionSystem().ultimateSelected().path().top();
if( !node->m_patch ) {
DoMessageBox("You must select ONLY patches", "Error", eMB_OK);
return;
}
patch.LoadFromBrush(node);
list<DPatch> patchList = patch.Split( true, true );
for(list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++) {
(*patches).BuildInRadiant();
}
patch.RemoveFromRadiant();
}
void DoVisAnalyse()
{
char filename[1024];
if( GlobalSelectionSystem().countSelected() == 0 )
{
if(g_VisView)
{
delete g_VisView;
return;
}
}
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 1 )
{
DoMessageBox("Invalid number of objects selected, choose 1 only", "Error", eMB_OK);
return;
}
scene::Node* brush = GlobalSelectionSystem().ultimateSelected().path().top();
DBrush orgBrush;
orgBrush.LoadFromBrush(brush, false);
orgBrush.BuildBounds();
vec3_t origin;
origin[0] = (orgBrush.bbox_max[0] + orgBrush.bbox_min[0])/2.f;
origin[1] = (orgBrush.bbox_max[1] + orgBrush.bbox_min[1])/2.f;
origin[2] = (orgBrush.bbox_max[2] + orgBrush.bbox_min[2])/2.f;
const char* rad_filename = g_FuncTable.m_pfnGetMapName();
if(!rad_filename)
{
DoMessageBox("An Error Occurred While Trying\n To Get The Map Filename", "Error", eMB_OK);
return;
}
strcpy(filename, rad_filename);
char* ext = strrchr(filename, '.')+1;
strcpy(ext, "bsp");// rename the extension
list<DWinding*> *pointList = BuildTrace(filename, origin);
if(!g_VisView)
{
g_VisView = new DVisDrawer;
g_VisView->Register();
}
g_VisView->SetList(pointList);
}
void DoTrainPathPlot() {
if(g_TrainView) {
delete g_TrainView;
g_TrainView = NULL;
}
g_TrainView = new DTrainDrawer();
}
void DoCaulkSelection() {
DEntity world;
float fScale[2] = { 0.5f, 0.5f };
float fShift[2] = { 0.0f, 0.0f };
int bResetScale[2] = { false, false };
int bResetShift[2] = { false, false };
world.LoadSelectedBrushes();
world.LoadSelectedPatches();
world.ResetTextures( NULL, fScale, fShift, 0, "textures/common/caulk", true, bResetScale, bResetShift, false, true );
}
void DoTreePlanter() {
if(g_TreePlanter) {
delete g_TreePlanter;
g_TreePlanter = NULL;
return;
}
g_TreePlanter = new DTreePlanter();
}
void DoDropEnts() {
if(g_TreePlanter) {
g_TreePlanter->DropEntsToGround();
}
}
void DoMakeChain() {
DTreePlanter pl;
pl.MakeChain();
}
typedef DPoint* pntTripple[3];
bool bFacesNoTop[6] = {true, true, true, true, true, false};
void DoFlipTerrain() {
vec3_t vUp = { 0.f, 0.f, 1.f };
int i;
// ensure we have something selected
if( GlobalSelectionSystem().countSelected() != 2 )
{
DoMessageBox("Invalid number of objects selected, choose 2 only", "Error", eMB_OK);
return;
}
scene::Node* brushes[2];
brushes[0] = GlobalSelectionSystem().ultimateSelected().path().top();
brushes[1] = GlobalSelectionSystem().penultimateSelected().path().top();
DBrush Brushes[2];
DPlane* Planes[2];
pntTripple Points[2];
for( i = 0; i < 2; i++ ) {
Brushes[i].LoadFromBrush( brushes[i], false );
if(!(Planes[i] = Brushes[i].FindPlaneWithClosestNormal( vUp )) || Brushes[i].FindPointsForPlane( Planes[i], Points[i], 3 ) != 3) {
DoMessageBox("Error", "Error", eMB_OK);
return;
}
}
vec3_t mins1, mins2, maxs1, maxs2;
Brushes[0].GetBounds( mins1, maxs1 );
Brushes[1].GetBounds( mins2, maxs2 );
scene::Node* ents[2];
ents[0] = GlobalSelectionSystem().ultimateSelected().path().parent();
ents[1] = GlobalSelectionSystem().penultimateSelected().path().parent();
for( i = 0; i < 2; i++ ) {
Brushes[i].RemoveFromRadiant();
}
int dontmatch[2] = { -1, -1 };
bool found = false;
for( i = 0; i < 3; i++ ) {
for( int j = 0; j < 3 && !found; j++ ) {
if(VectorCompare( (Points[0])[i]->_pnt, (Points[1])[j]->_pnt )) {
found = true;
break;
}
}
if(!found) {
dontmatch[0] = i;
break;
}
found = false;
}
if(dontmatch[0] == -1) {
DoMessageBox("Error", "Error", eMB_OK);
return;
}
for( i = 0; i < 3; i++ ) {
for( int j = 0; j < 3 && !found; j++ ) {
if(VectorCompare( (Points[1])[i]->_pnt, (Points[0])[j]->_pnt )) {
found = true;
break;
}
}
if(!found) {
dontmatch[1] = i;
break;
}
found = false;
}
if(dontmatch[1] == -1) {
DoMessageBox("Error", "Error", eMB_OK);
return;
}
vec3_t plnpnts1[3];
vec3_t plnpnts2[3];
vec3_t plnpntsshr[3];
VectorCopy( (Points[0])[dontmatch[0]]->_pnt, plnpnts1[0] );
for( i = 0; i < 3; i++ ) {
if( dontmatch[0] != i ) {
VectorCopy( (Points[0])[i]->_pnt, plnpnts1[1] );
break;
}
}
VectorCopy( (Points[1])[dontmatch[1]]->_pnt, plnpnts1[2] );
VectorCopy( (Points[1])[dontmatch[1]]->_pnt, plnpnts2[0] );
for( i = 0; i < 3; i++ ) {
if( dontmatch[1] != i && !VectorCompare( (Points[1])[i]->_pnt, plnpnts1[1] )) {
VectorCopy( (Points[1])[i]->_pnt, plnpnts2[1] );
break;
}
}
VectorCopy( (Points[0])[dontmatch[0]]->_pnt, plnpnts2[2] );
VectorCopy( (Points[0])[dontmatch[0]]->_pnt, plnpntsshr[0] );
VectorCopy( (Points[1])[dontmatch[1]]->_pnt, plnpntsshr[1] );
if( (Points[1])[dontmatch[1]]->_pnt[2] < (Points[0])[dontmatch[0]]->_pnt[2] ) {
VectorCopy( (Points[1])[dontmatch[1]]->_pnt, plnpntsshr[2] );
} else {
VectorCopy( (Points[0])[dontmatch[0]]->_pnt, plnpntsshr[2] );
}
plnpntsshr[2][2] -= 16;
for( i = 0; i < 3; i++ ) {
if( mins2[i] < mins1[i] ) {
mins1[i] = mins2[i];
}
if( maxs2[i] > maxs1[i] ) {
maxs1[i] = maxs2[i];
}
}
DBrush* newBrushes[2];
newBrushes[0] = DShape::GetBoundingCube_Ext( mins1, maxs1, "textures/common/caulk", bFacesAll, true);
newBrushes[1] = DShape::GetBoundingCube_Ext( mins1, maxs1, "textures/common/caulk", bFacesAll, true);
vec3_t normal;
MakeNormal( plnpnts1[0], plnpnts1[1], plnpnts1[2], normal );
if( normal[2] >= 0 ) {
newBrushes[0]->AddFace( plnpnts1[0], plnpnts1[1], plnpnts1[2], "textures/common/terrain", true );
} else {
newBrushes[0]->AddFace( plnpnts1[2], plnpnts1[1], plnpnts1[0], "textures/common/terrain", true );
}
MakeNormal( plnpnts2[0], plnpnts2[1], plnpnts2[2], normal );
if( normal[2] >= 0 ) {
newBrushes[1]->AddFace( plnpnts2[0], plnpnts2[1], plnpnts2[2], "textures/common/terrain", true );
} else {
newBrushes[1]->AddFace( plnpnts2[2], plnpnts2[1], plnpnts2[0], "textures/common/terrain", true );
}
vec3_t vec;
MakeNormal( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], normal );
VectorSubtract( plnpnts1[2], plnpnts1[1], vec );
if( DotProduct( vec, normal ) >= 0 ) {
newBrushes[0]->AddFace( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], "textures/common/caulk", true );
} else {
newBrushes[0]->AddFace( plnpntsshr[2], plnpntsshr[1], plnpntsshr[0], "textures/common/caulk", true );
}
VectorSubtract( plnpnts2[2], plnpnts2[1], vec );
if( DotProduct( vec, normal ) >= 0 ) {
newBrushes[1]->AddFace( plnpntsshr[0], plnpntsshr[1], plnpntsshr[2], "textures/common/caulk", true );
} else {
newBrushes[1]->AddFace( plnpntsshr[2], plnpntsshr[1], plnpntsshr[0], "textures/common/caulk", true );
}
for( i = 0; i < 2; i++ ) {
newBrushes[i]->RemoveRedundantPlanes();
newBrushes[i]->BuildInRadiant( false, NULL, ents[i] );
delete newBrushes[i];
}
}

View File

@@ -0,0 +1,214 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "dialogs/dialogs-gtk.h"
#include "DEntity.h"
#include "DMap.h"
#include "misc.h"
#include "lists.h"
#include "funchandlers.h"
// for ctf texture changer
list<Str> clrList_Blue;
list<Str> clrList_Red;
BOOL clrLst1Loaded = FALSE;
BOOL clrLst2Loaded = FALSE;
// -------------
//========================//
// Helper Functions //
//========================//
void LoadLists()
{
char buffer[256];
if(!clrLst1Loaded)
{
clrLst1Loaded = LoadExclusionList(GetFilename(buffer, "plugins/bt/ctf-blue.txt"), &clrList_Blue);
LoadExclusionList(GetFilename(buffer, "plugins/bt/blue.txt"), &clrList_Blue);
}
if(!clrLst2Loaded)
{
clrLst2Loaded = LoadExclusionList(GetFilename(buffer, "plugins/bt/ctf-red.txt"), &clrList_Red);
LoadExclusionList(GetFilename(buffer, "plugins/bt/red.txt"), &clrList_Red);
}
}
//========================//
// Main Functions //
//========================//
void DoCTFColourChanger()
{
if(!clrLst1Loaded || !clrLst2Loaded)
{
DoMessageBox("CTF texture lists not found, this function will terminate.", "Error", MB_OK);
return;
}
int ret = DoCTFColourChangeBox();
if(ret == IDCANCEL)
return;
int cnt = Min(clrList_Blue.size(), clrList_Red.size());
list<Str>::const_iterator Texture_change;
list<Str>::const_iterator Texture_new;
float fDummy[2];
int eCnt = g_FuncTable.m_pfnGetEntityCount();
DMap world;
world.LoadAll(TRUE);
if(ret == IDYES)
{
Texture_change = clrList_Blue.begin();
Texture_new = clrList_Red.begin();
}
else
{
Texture_change = clrList_Red.begin();
Texture_new = clrList_Blue.begin();
}
for(int i = 0; i < cnt; i++)
{
world.ResetTextures((*Texture_change).c_str(), fDummy, fDummy, 0, (*Texture_new).c_str(), TRUE);
Texture_change++;
Texture_new++;
}
}
void DoSwapLights()
{
/* DMap world;
world.LoadAll();
for(list<DEntity*>::const_iterator loopEnt = world.entityList.begin(); loopEnt != world.entityList.end(); loopEnt++)
{
DEntity* e = (*loopEnt);
DEPair* epLightColour = e->FindEPairByKey("_color");
if(epLightColour)
{
float r, g, b;
sscanf(epLightColour->value, "%f %f %f", &r, &g, &b);
sprintf(epLightColour->value, "%f %f %f", b, g, r);
DMap::RebuildEntity(e);
}
}*/
int cnt = g_FuncTable.m_pfnGetEntityCount();
for(int i = 0; i < cnt; i++)
{
void* ent = g_FuncTable.m_pfnGetEntityHandle(i);
for(epair_t* epList = *g_FuncTable.m_pfnGetEntityKeyValList(ent); epList; epList= epList->next)
{
if(!stricmp("_color", epList->key))
{
float r, g, b;
sscanf(epList->value, "%f %f %f", &r, &g, &b);
sprintf(epList->value, "%f %f %f", b, g, r);
}
}
}
}
void DoChangeAngles()
{
int cnt = g_FuncTable.m_pfnGetEntityCount();
for(int i = 0; i < cnt; i++)
{
void* ent = g_FuncTable.m_pfnGetEntityHandle(i);
for(epair_t* epList = *g_FuncTable.m_pfnGetEntityKeyValList(ent); epList; epList= epList->next)
{
if(!stricmp("angle", epList->key))
{
float angle;
sscanf(epList->value, "%f", &angle);
angle += 180;
while(angle > 360)
angle -= 360;
sprintf(epList->value, "%f", angle);
}
}
}
}
void DoSwapSpawns()
{
int cnt = g_FuncTable.m_pfnGetEntityCount();
for(int i = 0; i < cnt; i++)
{
void* ent = g_FuncTable.m_pfnGetEntityHandle(i);
for(epair_t* epList = *g_FuncTable.m_pfnGetEntityKeyValList(ent); epList; epList= epList->next)
{
if(!stricmp("classname", epList->key))
{
if(!strcmp(epList->value, "team_CTF_redplayer"))
sprintf(epList->value, "team_CTF_blueplayer");
else if(!strcmp(epList->value, "team_CTF_blueplayer"))
sprintf(epList->value, "team_CTF_redplayer");
if(!strcmp(epList->value, "team_CTF_redspawn"))
sprintf(epList->value, "team_CTF_bluespawn");
else if(!strcmp(epList->value, "team_CTF_bluespawn"))
sprintf(epList->value, "team_CTF_redspawn");
if(!strcmp(epList->value, "team_CTF_redflag"))
sprintf(epList->value, "team_CTF_blueflag");
else if(!strcmp(epList->value, "team_CTF_blueflag"))
sprintf(epList->value, "team_CTF_redflag")
;
if(!strcmp(epList->value, "team_redobelisk"))
sprintf(epList->value, "team_blueobelisk");
else if(!strcmp(epList->value, "team_blueobelisk"))
sprintf(epList->value, "team_redobelisk");
}
}
}
}
/*void test()
{
DMap world;
world.LoadAll();
for(list<DEntity*>::const_iterator ents = world.entityList.begin(); ents != world.entityList.end(); ents++)
{
(*ents)->RemoveFromRadiant();
}
}*/

View File

@@ -0,0 +1,503 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "funchandlers.h"
#include "IntersectDialog.h"
#include "PolygonDialog.h"
#include "StairDialog.h"
#include "DoorDialog.h"
#include "IntersectInfoDialog.h"
#include "BrushCheckDialog.h"
#include "AutoCaulkDialog.h"
#include "AutoCaulkStartDialog.h"
#include "TextureResetDialog.h"
#include "pathplotterdialog.h"
#include "DEntity.h"
#include "shapes.h"
#include "lists.h"
#include "misc.h"
#include "DShape.h"
// for autocaulk
list<Str> exclusionList; // whole brush exclusion
list<Str> exclusionList_Face; // single face exclusion
BOOL el1Loaded;
BOOL el2Loaded;
DBobView* g_PathView = NULL;
// -------------
/************************
Global Variables
************************/
CPolygonDialog polygonDlg;
CIntersectDialog intrDlg;
CStairDialog stairDlg;
CDoorDialog doorDlg;
CAutoCaulkStartDialog autocaulkDlg;
CTextureResetDialog texRstDlg;
CPathPlotterDialog ppDlg;
/************************
--Main Functions--
************************/
void LoadLists()
{
char buffer[256];
if(!el1Loaded)
el1Loaded = LoadExclusionList(GetFilename(buffer, "bt\\bt-el1.txt"), &exclusionList);
if(!el2Loaded)
el2Loaded = LoadExclusionList(GetFilename(buffer, "bt\\bt-el2.txt"), &exclusionList);
}
void PolygonBuilder(vec3_t vMin, vec3_t vMax)
{
// ensure we have something selected
if( g_FuncTable.m_pfnSelectedBrushCount() != 1 )
{
MessageBox(NULL, "Invalid number of brushes selected, chose 1 only", "Error", MB_OK);
return;
}
// tell Radiant we want to access the selected brushes
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
// get handle to size definition brush
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle(0);
// cant release until we delete the brush, if we do...
// ask user for type, size, etc....
if(polygonDlg.DoModal() == IDOK)
{
DShape poly;
g_FuncTable.m_pfnDeleteBrushHandle(brush);
if(polygonDlg.m_bInverse)
poly.BuildInversePrism(vMin, vMax, polygonDlg.m_nSideCount, polygonDlg.m_bAlignTop);
else
{
if(polygonDlg.m_bBorder)
poly.BuildBorderedPrism(vMin, vMax, polygonDlg.m_nSideCount, polygonDlg.m_nBorderSize, polygonDlg.m_bAlignTop);
else
poly.BuildRegularPrism(vMin, vMax, polygonDlg.m_nSideCount, polygonDlg.m_bAlignTop);
}
poly.Commit();
}
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
}
void IntersectionFinder()
{
if(intrDlg.DoModal() == IDCANCEL)
return;
if(intrDlg.m_nBrushOptions == BRUSH_OPT_SELECTED)
{
// ensure we have enough brushes selected
if( g_FuncTable.m_pfnSelectedBrushCount() < 2 )
{
MessageBox(NULL, "Invalid number of brushes selected, choose at least 2", "Error", MB_OK);
return;
}
}
CIntersectInfoDialog* intrInfoDlg = new CIntersectInfoDialog();
intrInfoDlg->Create(IDD_INTERSECT_INFO_DIALOG);
DEntity world;
switch(intrDlg.m_nBrushOptions)
{
case BRUSH_OPT_SELECTED:
{
world.LoadSelectedBrushes(&intrInfoDlg->m_prog1);
break;
}
case BRUSH_OPT_WHOLE_MAP:
{
world.LoadFromEntity(0, &intrInfoDlg->m_prog1);
break;
}
}
world.RemoveNonCheckBrushes(&exclusionList, intrDlg.m_bUseDetail);
BOOL* pbSelectList;
if(intrDlg.m_bDuplicateOnly)
pbSelectList = world.BuildDuplicateList();
else
pbSelectList = world.BuildIntersectList();
world.SelectBrushes(pbSelectList);
intrInfoDlg->DestroyWindow();
delete[] pbSelectList;
}
void StairBuilder(vec3_t vMin, vec3_t vMax)
{
// ensure we have something selected
if( g_FuncTable.m_pfnSelectedBrushCount() != 1 )
{
MessageBox(NULL, "Invalid number of brushes selected, chose 1 only", "Error", MB_OK);
return;
}
// tell Radiant we want to access the selected brushes
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
// get handle to size definition brush
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle(0);
// cant release until we delete the brush, if we do...
// ask user for type, size, etc....
if(stairDlg.DoModal() == IDOK)
{
// calc brush size
vec3_t size;
_VectorSubtract(vMax, vMin, size);
if(((int)size[2] % stairDlg.m_nStairHeight) != 0)
{
// stairs must fit evenly into brush
MessageBox(NULL, "Invalid stair height\nHeight of block must be divisable by stair height", "Error", MB_OK);
}
else
{
// Remove Size Brush
g_FuncTable.m_pfnDeleteBrushHandle(brush);
// Get Step Count, Direction of Stairs, Stair Style
int numSteps = (int)size[2] / stairDlg.m_nStairHeight;
int direction = stairDlg.m_StairDir;
int style = stairDlg.m_StairStyle;
if(stairDlg.m_StairStyle == STYLE_CORNER)
{
BuildCornerStairs(vMin, vMax, numSteps, "textures/common/caulk", (LPCTSTR)stairDlg.m_riserTexture);
}
else
{
// Get Step Dimensions
float stairHeight = (float)stairDlg.m_nStairHeight;
float stairWidth;
if((direction == MOVE_EAST) || (direction == MOVE_WEST))
stairWidth = (size[0])/numSteps;
else
stairWidth = (size[1])/numSteps;
// Build Base For Stair (bob's style)
if(style == STYLE_BOB)
Build_Wedge(direction, vMin, vMax, TRUE);
// Set First Step Starting Position
vMax[2] = vMin[2] + stairHeight;
SetInitialStairPos(direction, vMin, vMax, stairWidth);
// Build The Steps
for(int i = 0; i < numSteps; i++)
{
if(style == STYLE_BOB)
Build_StairStep_Wedge(direction, vMin, vMax, "textures/common/caulk", (LPCTSTR)stairDlg.m_riserTexture, stairDlg.m_bDetail);
else if(style == STYLE_ORIGINAL)
Build_StairStep(vMin, vMax, "textures/common/caulk", (LPCTSTR)stairDlg.m_riserTexture, direction);
// get step into next position
MoveBlock(direction, vMin, vMax, stairWidth);
vMax[2] += stairHeight;
if(style == STYLE_BOB)
vMin[2] += stairHeight; // wedge bottom must be raised
}
}
}
}
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
}
void DoorBuilder(vec3_t vMin, vec3_t vMax)
{
// ensure we have something selected
if( g_FuncTable.m_pfnSelectedBrushCount() != 1 )
{
MessageBox(NULL, "Invalid number of brushes selected, chose 1 only", "Error", MB_OK);
return;
}
// tell Radiant we want to access the selected brushes
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
// get handle to size definition brush
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle(0);
// cant release until we delete the brush, if we do...
strcpy(doorDlg.m_fbTextureName.GetBuffer(256), g_FuncTable.m_pfnGetCurrentTexture());
if(doorDlg.DoModal() == IDOK)
{
g_FuncTable.m_pfnDeleteBrushHandle(brush);
BuildDoorsX2(vMin, vMax,
doorDlg.m_bSclMainHor, doorDlg.m_bSclMainVert,
doorDlg.m_bSclTrimHor, doorDlg.m_bSclTrimVert,
(LPCTSTR)doorDlg.m_fbTextureName,
(LPCTSTR)doorDlg.m_trimTextureName,
doorDlg.m_doorDirection);
}
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
}
void FixBrushes()
{
DEntity world;
CIntersectInfoDialog* intrInfoDlg = new CIntersectInfoDialog();
intrInfoDlg->Create(IDD_INTERSECT_INFO_DIALOG);
world.LoadFromEntity(0, &intrInfoDlg->m_prog1);
intrInfoDlg->DestroyWindow();
CBrushCheckDialog* chkDlg = new CBrushCheckDialog();
chkDlg->Create(IDD_BRUSHCHECKER_DIALOG);
int count = world.FixBrushes(TRUE, &chkDlg->m_prog1);
chkDlg->DestroyWindow();
Sys_Printf("%i invalid/duplicate planes removed\n", count);
}
void AutoCaulk()
{
if(!el1Loaded)
autocaulkDlg.m_Warning1 = "WARNING: Brush exclusion list not found\n, ALL BRUSHES WILL BE USED";
if(autocaulkDlg.DoModal() == IDCANCEL)
return;
if(autocaulkDlg.m_nMode == MODE_AC_BUILD_MINI_PRT)
{
BuildMiniPrt(&exclusionList);
return;
}
CAutoCaulkDialog* acDlg = new CAutoCaulkDialog;
acDlg->Create(IDD_AUTOCAULK_DIALOG);
char filename[1204];
if(autocaulkDlg.m_nMode == MODE_AC_NORMAL)
{
char* rad_filename = g_BSPTable.m_pfnGetMapName();
if(!rad_filename)
{
MessageBox(NULL, "An Error Occurred While Trying To Get The Map Filename", "Error", MB_OK);
acDlg->DestroyWindow();
return;
}
strcpy(filename, rad_filename);
char* ext = strrchr(filename, '.')+1;
strcpy(ext, "prt");// rename the extension
}
else
{
IEpair* pEp = g_EpairTable.m_pfnIEpairForProjectKeys();
char *pn = pEp->ValueForKey("mapspath");
pEp->DecRef();
strcpy( filename, pn );
strcat( filename, "/ac_prt.prt" );
}
DEntity portals;
if(!portals.LoadFromPrt(filename, &acDlg->m_prog1))
{
MessageBox(NULL, "Failed To Load Portal File", "Error", MB_OK);
acDlg->DestroyWindow();
return;
}
// load portal file
CIntersectInfoDialog* intrInfoDlg = new CIntersectInfoDialog();
intrInfoDlg->Create(IDD_INTERSECT_INFO_DIALOG);
DEntity world;
world.LoadFromEntity(0, &intrInfoDlg->m_prog1);
intrInfoDlg->DestroyWindow();
if(autocaulkDlg.m_nMode == MODE_AC_NORMAL)
world.RemoveNonCheckBrushes(&exclusionList, FALSE);
else
world.RemoveNonCheckBrushes(&exclusionList, TRUE);
world.ResetChecks(&exclusionList_Face);
int caulkedCount = 0;
int killCnt = world.AutoCaulk(&portals, autocaulkDlg.m_bAllowDestruction, &caulkedCount, &acDlg->m_prog2);
if(autocaulkDlg.m_bAllowDestruction)
Sys_Printf("%i unrequired brush(es) killed\n", killCnt);
Sys_Printf("%i face(s) caulked\n", caulkedCount);
acDlg->DestroyWindow();
}
void ResetTextures()
{
texRstDlg.m_TextureName = GetCurrentTexture();
texRstDlg.m_NewTextureName = GetCurrentTexture();
if(texRstDlg.DoModal() == IDCANCEL)
return;
float fScale[2];
float fShift[2];
fScale[1] = texRstDlg.m_fScaleVertical;
fScale[0] = texRstDlg.m_fScaleHorizontal;
fShift[1] = (float)texRstDlg.m_nShiftVertical;
fShift[0] = (float)texRstDlg.m_nShiftHorizontal;
DEntity world;
world.LoadFromEntity(0, NULL);
if(texRstDlg.m_bAllTextures)
world.ResetTextures(NULL, fScale, fShift, texRstDlg.m_nRotation, texRstDlg.m_NewTextureName, texRstDlg.m_bOnlyTexture);
else
world.ResetTextures(texRstDlg.m_TextureName, fScale, fShift, texRstDlg.m_nRotation, texRstDlg.m_NewTextureName, texRstDlg.m_bOnlyTexture);
}
void PathPlotter()
{
int ret = ppDlg.DoModal();
if(ret == IDCANCEL)
return;
if(ret == IDNO)
{
if(g_PathView)
delete g_PathView;
return;
}
if( g_FuncTable.m_pfnSelectedBrushCount() != 1)
{
MessageBox(NULL, "Invalid number of brushes selected, chose 1 only", "Error", MB_OK);
return;
}
// tell Radiant we want to access the selected brushes
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
// get handle to size definition brush
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle(0);
// cant release until we delete the brush, if we do...
DEntity world;
world.LoadEPairList(*g_FuncTable.m_pfnGetEntityKeyValList(brush->owner));
DEPair* trigger_ep = world.FindEPairByKey("targetname");
if(trigger_ep)
{
if(!strcmp(world.m_Classname, "trigger_push"))
{
DEPair* target_ep = world.FindEPairByKey("target");
if(target_ep)
{
entity_s* entTarget = FindEntityFromTargetname(target_ep->value);
if(entTarget)
{
if(g_PathView)
delete g_PathView;
g_PathView = new DBobView;
g_PathView->Begin(trigger_ep->value, target_ep->value, ppDlg.m_fMultiplier, ppDlg.m_nPoints, ppDlg.m_fGravity, ppDlg.m_bNoUpdate, ppDlg.m_bShowExtra);
}
else
MessageBox(NULL, "trigger_push target could not be found.", "Error", MB_OK);
}
else
MessageBox(NULL, "trigger_push has no target.", "Error", MB_OK);
}
else
MessageBox(NULL, "You must select a 'trigger_push' entity.", "Error", MB_OK);
}
else
MessageBox(NULL, "Entity must have a targetname", "Error", MB_OK);
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
}
void PitBuilder(vec3_t vMin, vec3_t vMax)
{
// ensure we have something selected
if( g_FuncTable.m_pfnSelectedBrushCount() != 1 )
{
MessageBox(NULL, "Invalid number of brushes selected, chose 1 only", "Error", MB_OK);
return;
}
// tell Radiant we want to access the selected brushes
g_FuncTable.m_pfnAllocateSelectedBrushHandles();
// get handle to size definition brush
brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle(0);
// cant release until we delete the brush, if we do...
DShape pit;
if(pit.BuildPit(vMin, vMax))
{
pit.Commit();
g_FuncTable.m_pfnDeleteBrushHandle(brush);
}
else
MessageBox(NULL, "Failed To Make Pit\nTry Making The Brush Bigger", "Error", MB_OK);
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
}

View File

@@ -0,0 +1,72 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
class DBobView;
class DVisDrawer;
class DTrainDrawer;
class DTreePlanter;
extern DBobView* g_PathView;
extern DVisDrawer* g_VisView;
extern DTrainDrawer* g_TrainView;
extern DTreePlanter* g_TreePlanter;
// intersect stuff
#define BRUSH_OPT_WHOLE_MAP 0
#define BRUSH_OPT_SELECTED 1
// defines for stairs
#define MOVE_NORTH 0
#define MOVE_SOUTH 1
#define MOVE_EAST 2
#define MOVE_WEST 3
#define STYLE_ORIGINAL 0
#define STYLE_BOB 1
#define STYLE_CORNER 2
// defines for doors
#define DIRECTION_NS 0
#define DIRECTION_EW 1
// help
void LoadLists();
// djbob
void DoIntersect();
void DoPolygonsTB();
void DoPolygons();
void DoFixBrushes();
void DoResetTextures();
void DoBuildStairs();
void DoBuildDoors();
void DoPathPlotter();
void DoPitBuilder();
void DoCTFColourChanger();
void DoMergePatches();
void DoSplitPatch();
void DoVisAnalyse();
void DoTrainThing();
void DoTrainPathPlot();
void DoCaulkSelection();
void DoTreePlanter();
void DoDropEnts();
void DoMakeChain();
void DoFlipTerrain();

View File

@@ -0,0 +1,88 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#ifdef WIN32
#pragma warning(disable : 4786)
#endif
#include "gtkr_list.h"
#include "str.h"
#include "lists.h"
#include "misc.h"
bool LoadExclusionList(char* filename, list<Str>* exclusionList)
{
FILE* eFile = fopen(filename, "r");
if(eFile)
{
char buffer[256];
int cnt = 0;
while(!feof(eFile))
{
memset(buffer, 0, 256);
fscanf(eFile, "%s\n", buffer);
if(strlen(buffer) > 0)
exclusionList->push_back(buffer);
else
cnt++;
}
fclose(eFile);
return TRUE;
}
Sys_ERROR("Failed To Load Exclusion List: %s\n", filename);
return FALSE;
}
bool LoadGList(char* filename, GList** loadlist)
{
FILE* eFile = fopen(filename, "r");
if(eFile)
{
char buffer[256];
int cnt = 0;
while(!feof(eFile))
{
memset(buffer, 0, 256);
fscanf(eFile, "%s\n", buffer);
if(strlen(buffer) > 0)
{
char* buffer2 = new char[strlen(buffer) + 1];
strcpy(buffer2, buffer);
*loadlist = g_list_append(*loadlist, buffer2);
}
else
cnt++;
}
fclose(eFile);
return TRUE;
}
Sys_ERROR("Failed To Load GList: %s\n", filename);
return FALSE;
}

21
contrib/bobtoolz/lists.h Normal file
View File

@@ -0,0 +1,21 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
bool LoadExclusionList(char* filename, list<Str>* exclusionList);
bool LoadGList(char* filename, GList** loadlist);

430
contrib/bobtoolz/misc.cpp Normal file
View File

@@ -0,0 +1,430 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#include "gtkr_list.h"
#include "str.h"
#include "misc.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#include "DEPair.h"
#include "DPatch.h"
#include "DEntity.h"
#include "funchandlers.h"
#ifdef __linux__
#include <sys/types.h>
#include <unistd.h>
#endif
#include "iundo.h"
#include "refcounted_ptr.h"
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include "scenelib.h"
/*==========================
Global Vars
==========================*/
//HANDLE bsp_process;
char g_CurrentTexture[256] = "";
//=============================================================
//=============================================================
void ReadCurrentTexture()
{
const char* textureName = g_FuncTable.m_pfnGetCurrentTexture();
strcpy(g_CurrentTexture, textureName);
}
const char* GetCurrentTexture()
{
ReadCurrentTexture();
return g_CurrentTexture;
}
void MoveBlock(int dir, vec3_t min, vec3_t max, float dist)
{
switch(dir)
{
case MOVE_EAST:
{
min[0]+=dist;
max[0]+=dist;
break;
}
case MOVE_WEST:
{
min[0]-=dist;
max[0]-=dist;
break;
}
case MOVE_NORTH:
{
min[1]+=dist;
max[1]+=dist;
break;
}
case MOVE_SOUTH:
{
min[1]-=dist;
max[1]-=dist;
break;
}
}
}
void SetInitialStairPos(int dir, vec3_t min, vec3_t max, float width)
{
switch(dir)
{
case MOVE_EAST:
{
max[0] = min[0] + width;
break;
}
case MOVE_WEST:
{
min[0] = max[0] - width;
break;
}
case MOVE_NORTH:
{
max[1] = min[1] + width;
break;
}
case MOVE_SOUTH:
{
min[1] = max[1] - width;
break;
}
}
}
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_ERROR (char* text, ...)
{
va_list argptr;
char buf[32768];
va_start (argptr,text);
vsprintf (buf, text,argptr);
va_end (argptr);
Sys_Printf("BobToolz::ERROR->%s", buf);
}
/*void Sys_Printf (char *text, ...)
{
va_list argptr;
char buf[32768];
va_start (argptr,text);
vsprintf (buf, text,argptr);
va_end (argptr);
g_FuncTable.m_pfnSysMsg ( buf );
}*/
char* UnixToDosPath(char* path)
{
#ifndef WIN32
return path;
#else
for(char* p = path; *p; p++)
{
if(*p == '/')
*p = '\\';
}
return path;
#endif
}
const char* ExtractFilename(const char* path)
{
char* p = strrchr(path, '/');
if(!p)
{
p = strrchr(path, '\\');
if(!p)
return path;
}
return ++p;
}
extern char* PLUGIN_NAME;
/*char* GetGameFilename(char* buffer, const char* filename)
{
strcpy(buffer, g_FuncTable.m_pfnGetGamePath());
char* p = strrchr(buffer, '/');
*++p = '\0';
strcat(buffer, filename);
buffer = UnixToDosPath(buffer);
return buffer;
}*/
#if defined (__linux__) || defined (__APPLE__)
// the bCreateConsole parameter is ignored on linux ..
bool Q_Exec( const char *pCmd, bool bCreateConsole )
{
switch (fork())
{
case -1:
return false;
// Error ("CreateProcess failed");
break;
case 0:
#ifdef _DEBUG
printf("Running system...\n");
printf("Command: %s\n", pCmd);
#endif
// NOTE: we could use that to detect when a step finishes. But then it
// would not work for remote compiling stuff.
// execlp (pCmd, pCmd, NULL);
system( pCmd );
printf ("system() returned");
_exit (0);
break;
}
return true;
}
#endif
#include <windows.h>
#ifdef WIN32
#include <windows.h>
bool Q_Exec( const char *pCmd, bool bCreateConsole )
{
// G_DeWan: Don't know if this is needed for linux version
PROCESS_INFORMATION pi;
STARTUPINFO si = {0}; // Initialize all members to zero
si.cb = sizeof(STARTUPINFO); // Set byte count
DWORD dwCreationFlags;
if (bCreateConsole)
dwCreationFlags = CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS;
else
dwCreationFlags = DETACHED_PROCESS | NORMAL_PRIORITY_CLASS;
for(; *pCmd == ' '; pCmd++);
if(!CreateProcess(NULL, (char *)pCmd, NULL, NULL, FALSE, dwCreationFlags, NULL, NULL, &si, &pi))
return false;
return true;
}
#endif
void StartBSP()
{
char exename[256];
GetFilename(exename, "q3map");
UnixToDosPath(exename); // do we want this done in linux version?
char mapname[256];
const char *pn = g_FuncTable.m_pfnReadProjectKey("mapspath");
strcpy( mapname, pn );
strcat( mapname, "/ac_prt.map" );
UnixToDosPath(mapname);
char command[1024];
sprintf(command, "%s -nowater -fulldetail %s", exename, mapname);
Q_Exec( command, TRUE );
}
void BuildMiniPrt(list<Str>* exclusionList)
{
// yes, we could just use -fulldetail option, but, as SPOG said
// it'd be faster without all the hint, donotenter etc textures and
// doors, etc
DEntity world;
char buffer[128];
const char *pn = g_FuncTable.m_pfnReadProjectKey("mapspath");
strcpy( buffer, pn );
strcat( buffer, "/ac_prt.map" );
FILE* pFile = fopen(buffer, "w");
// ahem, thx rr2
if(!pFile)
return;
#if 0
int count = g_FuncTable.m_pfnGetEntityCount();
for(int i = 0; i < count; i++)
{
entity_t* ent = (entity_t*)g_FuncTable.m_pfnGetEntityHandle(i);
epair_t* epl = *g_EntityTable.m_pfnGetEntityKeyValList(ent);
epair_t* ep = epl;
while(ep)
{
if(!strcmp(ep->key, "classname"))
{
if(!strcmp(ep->value, "worldspawn"))
{
world.LoadFromEntity(i, FALSE);
world.RemoveNonCheckBrushes(exclusionList, TRUE);
world.SaveToFile(pFile);
}
else if(strstr(ep->value, "info_"))
{
world.ClearBrushes();
world.ClearEPairs();
world.LoadEPairList(epl);
world.SaveToFile(pFile);
}
break;
}
ep = ep->next;
}
}
#endif
fclose(pFile);
StartBSP();
}
scene::Path* FindEntityFromTargetname(const char* targetname, int* entNum)
{
#if 0
DEntity world;
int count = g_FuncTable.m_pfnGetEntityCount();
for(int i = 0; i < count; i++)
{
world.ClearEPairs();
entity_s* ent = (entity_s*)g_FuncTable.m_pfnGetEntityHandle(i);
world.LoadEPairList(*g_EntityTable.m_pfnGetEntityKeyValList(ent));
DEPair* tn = world.FindEPairByKey("targetname");
if(tn)
{
if(!stricmp(tn->value, targetname)) {
if(entNum) {
*entNum = i;
}
return ent;
}
}
}
#endif
return NULL;
}
void FillDefaultTexture(_QERFaceData* faceData, vec3_t va, vec3_t vb, vec3_t vc, const char* texture)
{
faceData->m_texdef.rotate = 0;
faceData->m_texdef.scale[0] = 0.5;
faceData->m_texdef.scale[1] = 0.5;
faceData->m_texdef.shift[0] = 0;
faceData->m_texdef.shift[1] = 0;
faceData->m_texdef.contents = 0;
faceData->m_texdef.flags = 0;
faceData->m_texdef.value = 0;
if(*texture)
faceData->m_texdef.SetName(texture);
else
faceData->m_texdef.SetName("textures/common/caulk");
VectorCopy(va, faceData->m_p0);
VectorCopy(vb, faceData->m_p1);
VectorCopy(vc, faceData->m_p2);
}
float Determinant3x3(float a1, float a2, float a3,
float b1, float b2, float b3,
float c1, float c2, float c3)
{
return a1*(b2*c3-b3*c2) - a2*(b1*c3-b3*c1) + a3*(b1*c2-b2*c1);
}
bool GetEntityCentre(const char* entity, vec3_t centre)
{
const scene::Path* ent = FindEntityFromTargetname(entity, NULL);
if(!ent)
return FALSE;
scene::Instance& instance = *GlobalSceneGraph().find(*ent);
VectorCopy(instance.aabb_world().origin, centre);
return TRUE;
}
vec_t Min(vec_t a, vec_t b)
{
if(a < b)
return a;
return b;
}
void MakeNormal( vec_t* va, vec_t* vb, vec_t* vc, vec_t* out ) {
vec3_t v1, v2;
VectorSubtract(va, vb, v1);
VectorSubtract(vc, vb, v2);
CrossProduct(v1, v2, out);
}

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