2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined(INCLUDED_BRUSH_PRIMIT_H)
23 #define INCLUDED_BRUSH_PRIMIT_H
25 #include "math/vector.h"
27 #include "debugging/debugging.h"
29 // new brush primitive texdef
30 struct brushprimit_texdef_t
32 brushprimit_texdef_t()
41 void removeScale(std::size_t width, std::size_t height)
44 coords[0][0] *= width;
45 coords[0][1] *= width;
46 coords[0][2] *= width;
47 coords[1][0] *= height;
48 coords[1][1] *= height;
49 coords[1][2] *= height;
52 void addScale(std::size_t width, std::size_t height)
55 ASSERT_MESSAGE(width > 0, "shader-width is 0");
56 ASSERT_MESSAGE(height > 0, "shader-height is 0");
57 coords[0][0] /= width;
58 coords[0][1] /= width;
59 coords[0][2] /= width;
60 coords[1][0] /= height;
61 coords[1][1] /= height;
62 coords[1][2] /= height;
68 class TextureProjection
72 brushprimit_texdef_t m_brushprimit_texdef;
80 const texdef_t& texdef,
81 const brushprimit_texdef_t& brushprimit_texdef,
82 const Vector3& basis_s,
83 const Vector3& basis_t
86 m_brushprimit_texdef(brushprimit_texdef),
93 float Texdef_getDefaultTextureScale();
97 template<typename Element> class BasicVector3;
98 typedef BasicVector3<float> Vector3;
99 template<typename Element> class BasicVector4;
100 typedef BasicVector4<float> Vector4;
101 typedef Vector4 Quaternion;
105 void Normal_GetTransform(const Vector3& normal, Matrix4& transform);
107 void TexDef_Construct_Default(TextureProjection& projection);
109 void Texdef_Assign(TextureProjection& projection, const TextureProjection& other);
110 void Texdef_Shift(TextureProjection& projection, float s, float t);
111 void Texdef_Scale(TextureProjection& projection, float s, float t);
112 void Texdef_Rotate(TextureProjection& projection, float angle);
113 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);
114 void Texdef_EmitTextureCoordinates(const TextureProjection& projection, std::size_t width, std::size_t height, Winding& w, const Vector3& normal, const Matrix4& localToWorld);
116 void ShiftScaleRotate_fromFace(texdef_t& shiftScaleRotate, const TextureProjection& projection);
117 void ShiftScaleRotate_toFace(const texdef_t& shiftScaleRotate, TextureProjection& projection);
119 void Texdef_transformLocked(TextureProjection& projection, std::size_t width, std::size_t height, const Plane3& plane, const Matrix4& transform);
120 void Texdef_normalise(TextureProjection& projection, float width, float height);
125 TEXDEFTYPEID_BRUSHPRIMITIVES,
126 TEXDEFTYPEID_HALFLIFE,
131 // tells if we are internally using brush primitive (texture coordinates and map format)
132 // this is a shortcut for IntForKey( g_qeglobals.d_project_entity, "brush_primit" )
133 // NOTE: must keep the two ones in sync
134 TexdefTypeId m_texdefTypeId;
137 extern bp_globals_t g_bp_globals;
138 extern float g_texdef_default_scale;