| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#if !defined( INCLUDED_BRUSH_PRIMIT_H ) |
| 23 |
#define INCLUDED_BRUSH_PRIMIT_H |
| 24 |
|
| 25 |
#include "math/vector.h" |
| 26 |
#include "itexdef.h" |
| 27 |
#include "debugging/debugging.h" |
| 28 |
|
| 29 |
|
| 30 |
struct brushprimit_texdef_t |
| 31 |
{ |
| 32 |
brushprimit_texdef_t(){ |
| 33 |
coords[0][0] = 2.0f; |
| 34 |
coords[0][1] = 0.f; |
| 35 |
coords[0][2] = 0.f; |
| 36 |
coords[1][0] = 0.f; |
| 37 |
coords[1][1] = 2.0f; |
| 38 |
coords[1][2] = 0.f; |
| 39 |
} |
| 40 |
void removeScale( std::size_t width, std::size_t height ){ |
| 41 |
#if 1 |
| 42 |
coords[0][0] *= width; |
| 43 |
coords[0][1] *= width; |
| 44 |
coords[0][2] *= width; |
| 45 |
coords[1][0] *= height; |
| 46 |
coords[1][1] *= height; |
| 47 |
coords[1][2] *= height; |
| 48 |
#endif |
| 49 |
} |
| 50 |
void addScale( std::size_t width, std::size_t height ){ |
| 51 |
#if 1 |
| 52 |
ASSERT_MESSAGE( width > 0, "shader-width is 0" ); |
| 53 |
ASSERT_MESSAGE( height > 0, "shader-height is 0" ); |
| 54 |
coords[0][0] /= width; |
| 55 |
coords[0][1] /= width; |
| 56 |
coords[0][2] /= width; |
| 57 |
coords[1][0] /= height; |
| 58 |
coords[1][1] /= height; |
| 59 |
coords[1][2] /= height; |
| 60 |
#endif |
| 61 |
} |
| 62 |
float coords[2][3]; |
| 63 |
}; |
| 64 |
|
| 65 |
class TextureProjection |
| 66 |
{ |
| 67 |
public: |
| 68 |
texdef_t m_texdef; |
| 69 |
brushprimit_texdef_t m_brushprimit_texdef; |
| 70 |
Vector3 m_basis_s; |
| 71 |
Vector3 m_basis_t; |
| 72 |
|
| 73 |
TextureProjection(){ |
| 74 |
} |
| 75 |
TextureProjection( |
| 76 |
const texdef_t& texdef, |
| 77 |
const brushprimit_texdef_t& brushprimit_texdef, |
| 78 |
const Vector3& basis_s, |
| 79 |
const Vector3& basis_t |
| 80 |
) : |
| 81 |
m_texdef( texdef ), |
| 82 |
m_brushprimit_texdef( brushprimit_texdef ), |
| 83 |
m_basis_s( basis_s ), |
| 84 |
m_basis_t( basis_t ){ |
| 85 |
} |
| 86 |
}; |
| 87 |
|
| 88 |
float Texdef_getDefaultTextureScale(); |
| 89 |
|
| 90 |
class texdef_t; |
| 91 |
struct Winding; |
| 92 |
template<typename Element> class BasicVector3; |
| 93 |
typedef BasicVector3<float> Vector3; |
| 94 |
template<typename Element> class BasicVector4; |
| 95 |
typedef BasicVector4<float> Vector4; |
| 96 |
typedef Vector4 Quaternion; |
| 97 |
class Matrix4; |
| 98 |
class Plane3; |
| 99 |
|
| 100 |
void Normal_GetTransform( const Vector3& normal, Matrix4& transform ); |
| 101 |
|
| 102 |
void TexDef_Construct_Default( TextureProjection& projection ); |
| 103 |
|
| 104 |
void Texdef_Assign( TextureProjection& projection, const TextureProjection& other ); |
| 105 |
void Texdef_Shift( TextureProjection& projection, float s, float t ); |
| 106 |
void Texdef_Scale( TextureProjection& projection, float s, float t ); |
| 107 |
void Texdef_Rotate( TextureProjection& projection, float angle ); |
| 108 |
void Texdef_FitTexture( TextureProjection& projection, std::size_t width, std::size_t height, const Vector3& normal, const Winding& w, float s_repeat, float t_repeat ); |
| 109 |
void Texdef_EmitTextureCoordinates( const TextureProjection& projection, std::size_t width, std::size_t height, Winding& w, const Vector3& normal, const Matrix4& localToWorld ); |
| 110 |
|
| 111 |
void ShiftScaleRotate_fromFace( texdef_t& shiftScaleRotate, const TextureProjection& projection ); |
| 112 |
void ShiftScaleRotate_toFace( const texdef_t& shiftScaleRotate, TextureProjection& projection ); |
| 113 |
|
| 114 |
void Texdef_transformLocked( TextureProjection& projection, std::size_t width, std::size_t height, const Plane3& plane, const Matrix4& transform ); |
| 115 |
void Texdef_normalise( TextureProjection& projection, float width, float height ); |
| 116 |
|
| 117 |
enum TexdefTypeId |
| 118 |
{ |
| 119 |
TEXDEFTYPEID_QUAKE, |
| 120 |
TEXDEFTYPEID_BRUSHPRIMITIVES, |
| 121 |
TEXDEFTYPEID_HALFLIFE, |
| 122 |
}; |
| 123 |
|
| 124 |
struct bp_globals_t |
| 125 |
{ |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
TexdefTypeId m_texdefTypeId; |
| 130 |
}; |
| 131 |
|
| 132 |
extern bp_globals_t g_bp_globals; |
| 133 |
extern float g_texdef_default_scale; |
| 134 |
|
| 135 |
void ComputeAxisBase( const Vector3& normal, Vector3& texS, Vector3& texT ); |
| 136 |
|
| 137 |
#endif |