brush_primit.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
00003 For a list of contributors, see the accompanying CONTRIBUTORS file.
00004 
00005 This file is part of GtkRadiant.
00006 
00007 GtkRadiant is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 GtkRadiant is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with GtkRadiant; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 */
00021 
00022 #if !defined(INCLUDED_BRUSH_PRIMIT_H)
00023 #define INCLUDED_BRUSH_PRIMIT_H
00024 
00025 #include "math/Vector3.h"
00026 #include "itexdef.h"
00027 #include "debugging/debugging.h"
00028 // Timo
00029 // new brush primitive texdef
00030 struct brushprimit_texdef_t {
00031     brushprimit_texdef_t() {
00032         coords[0][0] = 2.0f;
00033         coords[0][1] = 0.f;
00034         coords[0][2] = 0.f;
00035         coords[1][0] = 0.f;
00036         coords[1][1] = 2.0f;
00037         coords[1][2] = 0.f;
00038     }
00039     void removeScale(std::size_t width, std::size_t height) {
00040         coords[0][0] *= width;
00041         coords[0][1] *= width;
00042         coords[0][2] *= width;
00043         coords[1][0] *= height;
00044         coords[1][1] *= height;
00045         coords[1][2] *= height;
00046     }
00047     void addScale(std::size_t width, std::size_t height) {
00048         ASSERT_MESSAGE(width > 0, "shader-width is 0");
00049         ASSERT_MESSAGE(height > 0, "shader-height is 0");
00050         coords[0][0] /= width;
00051         coords[0][1] /= width;
00052         coords[0][2] /= width;
00053         coords[1][0] /= height;
00054         coords[1][1] /= height;
00055         coords[1][2] /= height;
00056     }
00057     float coords[2][3];
00058 };
00059 
00060 class TextureProjection {
00061 public:
00062     texdef_t m_texdef;
00063     brushprimit_texdef_t m_brushprimit_texdef;
00064     Vector3 m_basis_s;
00065     Vector3 m_basis_t;
00066 
00067     TextureProjection() {
00068     }
00069     TextureProjection(
00070         const texdef_t& texdef,
00071         const brushprimit_texdef_t& brushprimit_texdef,
00072         const Vector3& basis_s,
00073         const Vector3& basis_t
00074     ) :
00075             m_texdef(texdef),
00076             m_brushprimit_texdef(brushprimit_texdef),
00077             m_basis_s(basis_s),
00078             m_basis_t(basis_t) {
00079     }
00080 };
00081 
00082 float Texdef_getDefaultTextureScale();
00083 
00084 class texdef_t;
00085 struct Winding;
00086 template<typename Element> class BasicVector3;
00087 typedef BasicVector3<float> Vector3;
00088 template<typename Element> class BasicVector4;
00089 typedef BasicVector4<float> Vector4;
00090 typedef Vector4 Quaternion;
00091 class Matrix4;
00092 class Plane3;
00093 
00094 void Normal_GetTransform(const Vector3& normal, Matrix4& transform);
00095 
00096 void TexDef_Construct_Default(TextureProjection& projection);
00097 
00098 void Texdef_Assign(TextureProjection& projection, const TextureProjection& other);
00099 void Texdef_Shift(TextureProjection& projection, float s, float t);
00100 void Texdef_Scale(TextureProjection& projection, float s, float t);
00101 void Texdef_Rotate(TextureProjection& projection, float angle);
00102 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);
00103 void Texdef_EmitTextureCoordinates(const TextureProjection& projection, std::size_t width, std::size_t height, Winding& w, const Vector3& normal, const Matrix4& localToWorld);
00104 
00105 void ShiftScaleRotate_fromFace(texdef_t& shiftScaleRotate, const TextureProjection& projection);
00106 void ShiftScaleRotate_toFace(const texdef_t& shiftScaleRotate, TextureProjection& projection);
00107 
00108 void Texdef_transformLocked(TextureProjection& projection, std::size_t width, std::size_t height, const Plane3& plane, const Matrix4& transform);
00109 void Texdef_normalise(TextureProjection& projection, float width, float height);
00110 
00111 extern float g_texdef_default_scale;
00112 
00113 void ComputeAxisBase(const Vector3& normal, Vector3& texS, Vector3& texT);
00114 
00115 #endif

Generated by  doxygen 1.6.2