| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef _PORTALS_H_ |
| 21 |
#define _PORTALS_H_ |
| 22 |
|
| 23 |
#include <glib.h> |
| 24 |
#include "irender.h" |
| 25 |
#include "renderable.h" |
| 26 |
#include "math/vector.h" |
| 27 |
|
| 28 |
|
| 29 |
class CBspPoint { |
| 30 |
public: |
| 31 |
float p[3]; |
| 32 |
}; |
| 33 |
|
| 34 |
class CBspPortal { |
| 35 |
public: |
| 36 |
CBspPortal(); |
| 37 |
~CBspPortal(); |
| 38 |
|
| 39 |
protected: |
| 40 |
|
| 41 |
public: |
| 42 |
CBspPoint center; |
| 43 |
unsigned point_count; |
| 44 |
CBspPoint *point; |
| 45 |
CBspPoint *inner_point; |
| 46 |
float fp_color_random[4]; |
| 47 |
float min[3]; |
| 48 |
float max[3]; |
| 49 |
float dist; |
| 50 |
bool hint; |
| 51 |
|
| 52 |
bool Build( char *def ); |
| 53 |
}; |
| 54 |
|
| 55 |
#ifdef PATH_MAX |
| 56 |
const int PRTVIEW_PATH_MAX = PATH_MAX; |
| 57 |
#else |
| 58 |
const int PRTVIEW_PATH_MAX = 260; |
| 59 |
#endif |
| 60 |
typedef guint32 PackedColour; |
| 61 |
#define RGB( r, g, b ) ( (guint32)( ( (guint8) ( r ) | ( (guint16) ( g ) << 8 ) ) | ( ( (guint32) (guint8) ( b ) ) << 16 ) ) ) |
| 62 |
#define GetRValue( rgb ) ( (guint8)( rgb ) ) |
| 63 |
#define GetGValue( rgb ) ( (guint8)( ( (guint16)( rgb ) ) >> 8 ) ) |
| 64 |
#define GetBValue( rgb ) ( (guint8)( ( rgb ) >> 16 ) ) |
| 65 |
|
| 66 |
|
| 67 |
class CPortals { |
| 68 |
public: |
| 69 |
|
| 70 |
CPortals(); |
| 71 |
~CPortals(); |
| 72 |
|
| 73 |
protected: |
| 74 |
|
| 75 |
|
| 76 |
public: |
| 77 |
|
| 78 |
void Load(); |
| 79 |
void Purge(); |
| 80 |
|
| 81 |
void FixColors(); |
| 82 |
|
| 83 |
char fn[PRTVIEW_PATH_MAX]; |
| 84 |
|
| 85 |
int zbuffer; |
| 86 |
int polygons; |
| 87 |
int lines; |
| 88 |
bool show_3d; |
| 89 |
bool aa_3d; |
| 90 |
bool fog; |
| 91 |
PackedColour color_3d; |
| 92 |
float width_3d; |
| 93 |
float fp_color_3d[4]; |
| 94 |
PackedColour color_fog; |
| 95 |
float fp_color_fog[4]; |
| 96 |
float trans_3d; |
| 97 |
float clip_range; |
| 98 |
bool clip; |
| 99 |
|
| 100 |
bool show_2d; |
| 101 |
bool aa_2d; |
| 102 |
PackedColour color_2d; |
| 103 |
float width_2d; |
| 104 |
float fp_color_2d[4]; |
| 105 |
|
| 106 |
CBspPortal *portal; |
| 107 |
int *portal_sort; |
| 108 |
bool hint_flags; |
| 109 |
|
| 110 |
|
| 111 |
unsigned int node_count; |
| 112 |
unsigned int portal_count; |
| 113 |
}; |
| 114 |
|
| 115 |
class CubicClipVolume |
| 116 |
{ |
| 117 |
public: |
| 118 |
Vector3 cam, min, max; |
| 119 |
}; |
| 120 |
|
| 121 |
class CPortalsDrawSolid : public OpenGLRenderable |
| 122 |
{ |
| 123 |
public: |
| 124 |
mutable CubicClipVolume clip; |
| 125 |
void render( RenderStateFlags state ) const; |
| 126 |
}; |
| 127 |
|
| 128 |
class CPortalsDrawSolidOutline : public OpenGLRenderable |
| 129 |
{ |
| 130 |
public: |
| 131 |
mutable CubicClipVolume clip; |
| 132 |
void render( RenderStateFlags state ) const; |
| 133 |
}; |
| 134 |
|
| 135 |
class CPortalsDrawWireframe : public OpenGLRenderable |
| 136 |
{ |
| 137 |
public: |
| 138 |
void render( RenderStateFlags state ) const; |
| 139 |
}; |
| 140 |
|
| 141 |
class CPortalsRender : public Renderable |
| 142 |
{ |
| 143 |
public: |
| 144 |
CPortalsDrawSolid m_drawSolid; |
| 145 |
CPortalsDrawSolidOutline m_drawSolidOutline; |
| 146 |
CPortalsDrawWireframe m_drawWireframe; |
| 147 |
|
| 148 |
void renderSolid( Renderer& renderer, const VolumeTest& volume ) const; |
| 149 |
void renderWireframe( Renderer& renderer, const VolumeTest& volume ) const; |
| 150 |
}; |
| 151 |
|
| 152 |
extern CPortals portals; |
| 153 |
extern CPortalsRender render; |
| 154 |
|
| 155 |
void Portals_constructShaders(); |
| 156 |
void Portals_destroyShaders(); |
| 157 |
|
| 158 |
void Portals_shadersChanged(); |
| 159 |
|
| 160 |
|
| 161 |
#endif |