Initial commit.
This commit is contained in:
231
code/bspthing/bsp.h
Normal file
231
code/bspthing/bsp.h
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
Common stuff
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#define MAX_QPATH 64 // max length of a quake game pathname
|
||||
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4];
|
||||
typedef vec_t vec5_t[5];
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
#define LIGHTMAP_SIZE 128
|
||||
|
||||
#define LIGHTMAP_BY_VERTEX -3 // pre-lit triangle models
|
||||
|
||||
#define POINTS_ST_SCALE 128.0f
|
||||
#define POINTS_LIGHT_SCALE 65536.0f
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
.BSP file format
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
|
||||
#define BSP_IDENT (('P'<<24)+('S'<<16)+('B'<<8)+'R')
|
||||
#define BSP_VERSION 1
|
||||
|
||||
// there shouldn't be any problem with increasing these values at the
|
||||
// expense of more memory allocation in the utilities
|
||||
#define MAX_MAP_MODELS 0x400
|
||||
#define MAX_MAP_BRUSHES 0x8000
|
||||
#define MAX_MAP_ENTITIES 0x800
|
||||
#define MAX_MAP_ENTSTRING 0x40000
|
||||
#define MAX_MAP_SHADERS 0x400
|
||||
|
||||
#define MAX_MAP_AREAS 0x100 // MAX_MAP_AREA_BYTES in q_shared must match!
|
||||
#define MAX_MAP_FOGS 0x100
|
||||
#define MAX_MAP_PLANES 0x20000
|
||||
#define MAX_MAP_NODES 0x20000
|
||||
#define MAX_MAP_BRUSHSIDES 0x20000
|
||||
#define MAX_MAP_LEAFS 0x20000
|
||||
#define MAX_MAP_LEAFFACES 0x20000
|
||||
#define MAX_MAP_LEAFBRUSHES 0x40000
|
||||
#define MAX_MAP_PORTALS 0x20000
|
||||
#define MAX_MAP_LIGHTING 0x800000
|
||||
#define MAX_MAP_LIGHTGRID 65535
|
||||
#define MAX_MAP_LIGHTGRID_ARRAY 0x100000
|
||||
|
||||
#define MAX_MAP_VISIBILITY 0x400000
|
||||
|
||||
#define MAX_MAP_DRAW_SURFS 0x20000
|
||||
#define MAX_MAP_DRAW_VERTS 0x80000
|
||||
#define MAX_MAP_DRAW_INDEXES 0x80000
|
||||
|
||||
|
||||
// key / value pair sizes in the entities lump
|
||||
#define MAX_KEY 32
|
||||
#define MAX_VALUE 1024
|
||||
|
||||
// the editor uses these predefined yaw angles to orient entities up or down
|
||||
#define ANGLE_UP -1
|
||||
#define ANGLE_DOWN -2
|
||||
|
||||
#define LIGHTMAP_WIDTH 128
|
||||
#define LIGHTMAP_HEIGHT 128
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
||||
typedef struct {
|
||||
int fileofs, filelen;
|
||||
} lump_t;
|
||||
|
||||
#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 LUMP_LIGHTARRAY 17
|
||||
#define HEADER_LUMPS 18
|
||||
|
||||
typedef struct {
|
||||
int ident;
|
||||
int version;
|
||||
|
||||
lump_t lumps[HEADER_LUMPS];
|
||||
} dheader_t;
|
||||
|
||||
typedef struct {
|
||||
float mins[3], maxs[3];
|
||||
int firstSurface, numSurfaces;
|
||||
int firstBrush, numBrushes;
|
||||
} dmodel_t;
|
||||
|
||||
typedef struct {
|
||||
char shader[MAX_QPATH];
|
||||
int surfaceFlags;
|
||||
int contentFlags;
|
||||
} dshader_t;
|
||||
|
||||
// planes x^1 is allways the opposite of plane x
|
||||
|
||||
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 {
|
||||
int planeNum; // positive plane side faces out of the leaf
|
||||
int shaderNum;
|
||||
int drawSurfNum;
|
||||
} dbrushside_t;
|
||||
|
||||
typedef struct {
|
||||
int firstSide;
|
||||
int numSides;
|
||||
int shaderNum; // the shader that determines the contents flags
|
||||
} dbrush_t;
|
||||
|
||||
typedef struct {
|
||||
char shader[MAX_QPATH];
|
||||
int brushNum;
|
||||
int visibleSide; // the brush side that ray tests need to clip against (-1 == none)
|
||||
} dfog_t;
|
||||
|
||||
// Light Style Constants
|
||||
#define MAXLIGHTMAPS 4
|
||||
#define LS_NORMAL 0x00
|
||||
#define LS_UNUSED 0xfe
|
||||
#define LS_NONE 0xff
|
||||
#define MAX_LIGHT_STYLES 64
|
||||
|
||||
typedef struct {
|
||||
vec3_t xyz;
|
||||
float st[2];
|
||||
float lightmap[MAXLIGHTMAPS][2];
|
||||
vec3_t normal;
|
||||
byte color[MAXLIGHTMAPS][4];
|
||||
} mapVert_t;
|
||||
|
||||
#define DRAWVERT_LIGHTMAP_SCALE 32768.0f
|
||||
#define DRAWVERT_ST_SCALE 16.0f
|
||||
typedef struct {
|
||||
vec3_t xyz;
|
||||
short dvst[2];
|
||||
short dvlightmap[MAXLIGHTMAPS][2];
|
||||
vec3_t normal;
|
||||
byte dvcolor[MAXLIGHTMAPS][2];
|
||||
} drawVert_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte ambientLight[MAXLIGHTMAPS][3];
|
||||
byte directLight[MAXLIGHTMAPS][3];
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
byte latLong[2];
|
||||
} dgrid_t;
|
||||
|
||||
typedef enum {
|
||||
MST_BAD,
|
||||
MST_PLANAR,
|
||||
MST_PATCH,
|
||||
MST_TRIANGLE_SOUP,
|
||||
MST_FLARE
|
||||
} mapSurfaceType_t;
|
||||
|
||||
typedef struct {
|
||||
int shaderNum;
|
||||
int fogNum;
|
||||
int surfaceType;
|
||||
|
||||
int firstVert;
|
||||
int numVerts;
|
||||
|
||||
int firstIndex;
|
||||
int numIndexes;
|
||||
|
||||
byte lightmapStyles[MAXLIGHTMAPS], vertexStyles[MAXLIGHTMAPS];
|
||||
int lightmapNum[MAXLIGHTMAPS];
|
||||
int lightmapX[MAXLIGHTMAPS], lightmapY[MAXLIGHTMAPS];
|
||||
int lightmapWidth, lightmapHeight;
|
||||
|
||||
vec3_t lightmapOrigin;
|
||||
vec3_t lightmapVecs[3]; // for patches, [0] and [1] are lodbounds
|
||||
|
||||
int patchWidth;
|
||||
int patchHeight;
|
||||
} dsurface_t;
|
||||
21
code/bspthing/bspthing.sln
Normal file
21
code/bspthing/bspthing.sln
Normal file
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bspthing", "bspthing.vcproj", "{613ECD87-EBE1-47D9-A23D-68F52218AEB6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
ConfigName.0 = Debug
|
||||
ConfigName.1 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectDependencies) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{613ECD87-EBE1-47D9-A23D-68F52218AEB6}.Debug.ActiveCfg = Debug|Win32
|
||||
{613ECD87-EBE1-47D9-A23D-68F52218AEB6}.Debug.Build.0 = Debug|Win32
|
||||
{613ECD87-EBE1-47D9-A23D-68F52218AEB6}.Release.ActiveCfg = Release|Win32
|
||||
{613ECD87-EBE1-47D9-A23D-68F52218AEB6}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
113
code/bspthing/bspthing.vcproj
Normal file
113
code/bspthing/bspthing.vcproj
Normal file
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="bspthing"
|
||||
ProjectGUID="{613ECD87-EBE1-47D9-A23D-68F52218AEB6}"
|
||||
Keyword="ManagedCProj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
ManagedExtensions="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG"
|
||||
MinimalRebuild="FALSE"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="1"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/bspthing.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
ManagedExtensions="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG"
|
||||
MinimalRebuild="FALSE"
|
||||
WarningLevel="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/bspthing.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
||||
<File
|
||||
RelativePath="main.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc">
|
||||
<File
|
||||
RelativePath="bsp.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pbsp.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;r">
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
1111
code/bspthing/main.cpp
Normal file
1111
code/bspthing/main.cpp
Normal file
File diff suppressed because it is too large
Load Diff
132
code/bspthing/pbsp.h
Normal file
132
code/bspthing/pbsp.h
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
Packed .BSP structures
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct {
|
||||
char shader[MAX_QPATH];
|
||||
int brushNum;
|
||||
int visibleSide; // the brush side that ray tests need to clip against (-1 == none)
|
||||
} pdfog_t;
|
||||
|
||||
typedef struct {
|
||||
int firstSide;
|
||||
byte numSides;
|
||||
unsigned short shaderNum; // the shader that determines the contents flags
|
||||
} pdbrush_t;
|
||||
|
||||
typedef struct {
|
||||
int planeNum; // positive plane side faces out of the leaf
|
||||
byte shaderNum;
|
||||
} pdbrushside_t;
|
||||
|
||||
typedef struct {
|
||||
int planeNum;
|
||||
short children[2]; // negative numbers are -(leafs+1), not nodes
|
||||
short mins[3]; // for frustom culling
|
||||
short maxs[3];
|
||||
} pdnode_t;
|
||||
|
||||
typedef struct {
|
||||
short cluster; // -1 = opaque cluster (do I still store these?)
|
||||
signed char area;
|
||||
|
||||
short mins[3]; // for frustum culling
|
||||
short maxs[3];
|
||||
|
||||
unsigned short firstLeafSurface;
|
||||
unsigned short numLeafSurfaces;
|
||||
|
||||
unsigned short firstLeafBrush;
|
||||
unsigned short numLeafBrushes;
|
||||
} pdleaf_t;
|
||||
|
||||
typedef struct {
|
||||
float mins[3], maxs[3];
|
||||
int firstSurface;
|
||||
unsigned short numSurfaces;
|
||||
int firstBrush;
|
||||
unsigned short numBrushes;
|
||||
} pdmodel_t;
|
||||
|
||||
typedef struct {
|
||||
byte flags;
|
||||
byte latLong[2];
|
||||
int data;
|
||||
} pdgrid_t;
|
||||
|
||||
typedef struct {
|
||||
char shader[MAX_QPATH];
|
||||
int surfaceFlags;
|
||||
int contentFlags;
|
||||
} pdshader_t;
|
||||
|
||||
typedef struct {
|
||||
float normal[3];
|
||||
float dist;
|
||||
} pdplane_t;
|
||||
|
||||
typedef struct {
|
||||
float lightmap[MAXLIGHTMAPS][2];
|
||||
float st[2];
|
||||
short xyz[3];
|
||||
short normal[3];
|
||||
byte color[MAXLIGHTMAPS][4];
|
||||
} pmapVert_t;
|
||||
|
||||
typedef struct {
|
||||
int code;
|
||||
byte shaderNum;
|
||||
signed char fogNum;
|
||||
|
||||
unsigned int verts; // high 20 bits are first vert, low 12 are num verts
|
||||
|
||||
byte lightmapStyles[MAXLIGHTMAPS];
|
||||
byte lightmapNum[MAXLIGHTMAPS];
|
||||
|
||||
short lightmapVecs[2][3]; // for patches, [0] and [1] are lodbounds
|
||||
|
||||
byte patchWidth;
|
||||
byte patchHeight;
|
||||
} pdpatch_t;
|
||||
|
||||
typedef struct {
|
||||
int code;
|
||||
byte shaderNum;
|
||||
signed char fogNum;
|
||||
|
||||
unsigned int verts; // high 20 bits are first vert, low 12 are num verts
|
||||
unsigned int indexes; // high 20 bits are first index, low 12 are num indices
|
||||
|
||||
byte lightmapStyles[MAXLIGHTMAPS];
|
||||
byte lightmapNum[MAXLIGHTMAPS];
|
||||
|
||||
short lightmapVecs[3];
|
||||
} pdface_t;
|
||||
|
||||
typedef struct {
|
||||
int code;
|
||||
byte shaderNum;
|
||||
signed char fogNum;
|
||||
|
||||
unsigned int verts; // high 20 bits are first vert, low 12 are num verts
|
||||
unsigned int indexes; // high 20 bits are first index, low 12 are num indices
|
||||
|
||||
byte lightmapStyles[MAXLIGHTMAPS];
|
||||
} pdtrisurf_t;
|
||||
|
||||
typedef struct {
|
||||
int code;
|
||||
byte shaderNum;
|
||||
signed char fogNum;
|
||||
|
||||
short origin[3];
|
||||
short normal[3];
|
||||
byte color[3];
|
||||
} pdflare_t;
|
||||
|
||||
#pragma pack(pop)
|
||||
Reference in New Issue
Block a user