1 /* 2 Copyright (C) 2010-2014 Kristian Duske 3 4 This file is part of TrenchBroom. 5 6 TrenchBroom is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 TrenchBroom is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef TrenchBroom_ParaxialTexCoordSystem 21 #define TrenchBroom_ParaxialTexCoordSystem 22 23 #include "TrenchBroom.h" 24 #include "VecMath.h" 25 #include "Model/TexCoordSystem.h" 26 27 namespace TrenchBroom { 28 namespace Model { 29 class BrushFaceAttributes; 30 31 class ParaxialTexCoordSystem : public TexCoordSystem { 32 private: 33 static const Vec3 BaseAxes[]; 34 35 size_t m_index; 36 Vec3 m_xAxis; 37 Vec3 m_yAxis; 38 public: 39 ParaxialTexCoordSystem(const Vec3& point0, const Vec3& point1, const Vec3& point2, const BrushFaceAttributes& attribs); 40 ParaxialTexCoordSystem(const Vec3& normal, const BrushFaceAttributes& attribs); 41 42 static size_t planeNormalIndex(const Vec3& normal); 43 static void axes(size_t index, Vec3& xAxis, Vec3& yAxis); 44 static void axes(size_t index, Vec3& xAxis, Vec3& yAxis, Vec3& projectionAxis); 45 private: 46 TexCoordSystem* doClone() const; 47 TexCoordSystemSnapshot* doTakeSnapshot(); 48 49 Vec3 getXAxis() const; 50 Vec3 getYAxis() const; 51 Vec3 getZAxis() const; 52 53 void doResetTextureAxes(const Vec3& normal); 54 void doResetTextureAxesToParaxial(const Vec3& normal, float angle); 55 void doResetTextureAxesToParallel(const Vec3& normal, float angle); 56 57 bool isRotationInverted(const Vec3& normal) const; 58 Vec2f doGetTexCoords(const Vec3& point, const BrushFaceAttributes& attribs) const; 59 60 void doSetRotation(const Vec3& normal, float oldAngle, float newAngle); 61 void doTransform(const Plane3& oldBoundary, const Mat4x4& transformation, BrushFaceAttributes& attribs, bool lockTexture, const Vec3& invariant); 62 63 void doUpdateNormal(const Vec3& oldNormal, const Vec3& newNormal, const BrushFaceAttributes& attribs); 64 65 void doShearTexture(const Vec3& normal, const Vec2f& factors); 66 67 float doMeasureAngle(float currentAngle, const Vec2f& center, const Vec2f& point) const; 68 private: 69 void rotateAxes(Vec3& xAxis, Vec3& yAxis, FloatType angleInRadians, size_t planeNormIndex) const; 70 }; 71 } 72 } 73 74 #endif /* defined(TrenchBroom_QuakeTexCoordPolicy) */ 75