]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/ibrush.h
f7a58f5597a5ba15b416d168b87f713f9344658c
[xonotic/netradiant.git] / include / ibrush.h
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
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.
11
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.
16
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
20 */
21
22 #if !defined(INCLUDED_IBRUSH_H)
23 #define INCLUDED_IBRUSH_H
24
25 #include "generic/constant.h"
26 #include "generic/callback.h"
27 #include "math/vector.h"
28 #include "itexdef.h"
29
30 namespace scene
31 {
32   class Node;
33 }
34
35 #if 0
36 class IBrushFace
37 {
38 public:
39   virtual const char* GetShader() const = 0;
40   virtual void SetShader(const char* name) = 0;
41   virtual const TextureProjection& GetTexdef() const = 0;
42   virtual void GetTexdef(TextureProjection& projection) const = 0;
43   virtual void SetTexdef(const TextureProjection& projection) = 0;
44   virtual void GetFlags(ContentsFlagsValue& flags) const = 0;
45   virtual void SetFlags(const ContentsFlagsValue& flags) = 0;
46   virtual void ShiftTexdef(float s, float t) = 0;
47   virtual void ScaleTexdef(float s, float t) = 0;
48   virtual void RotateTexdef(float angle) = 0;
49   virtual void FitTexture(float s_repeat, float t_repeat) = 0;
50   virtual bool isDetail() const = 0;
51   virtual void setDetail(bool detail) = 0;
52 };
53
54 class IBrush
55 {
56 public:
57   STRING_CONSTANT(Name, "IBrush");
58   virtual void reserve(std::size_t count) = 0;
59   virtual void clear() = 0;
60   virtual void copy(const IBrush& other) = 0;
61   virtual IBrushFace* addPlane(const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, const TextureProjection& projection) = 0;
62   virtual const AABB& localAABB() const = 0;
63   virtual void removeEmptyFaces() = 0;
64 };
65
66 class IBrushFaceInstance
67 {
68 public:
69   virtual IBrushFace& getFace() = 0;
70   virtual const IBrushFace& getFace() const = 0;
71   virtual bool isSelected() const = 0;
72   virtual void setSelected(SelectionSystem::EComponentMode mode, bool select) const = 0;
73 };
74
75 class IBrushInstance
76 {
77 public:
78   STRING_CONSTANT(Name, "IBrushInstance");
79   virtual void forEachFaceInstance(const BrushInstanceVisitor& visitor) = 0;
80 };
81 #endif
82
83 class _QERFaceData
84 {
85 public:
86   _QERFaceData() : contents(0), flags(0), value(0), m_shader("")
87   {
88   }
89   Vector3 m_p0;
90   Vector3 m_p1;
91   Vector3 m_p2;
92   texdef_t m_texdef;
93   const char* m_shader;
94   int contents;
95   int flags;
96   int value;
97 };
98
99 typedef Callback1<const _QERFaceData&> BrushFaceDataCallback;
100
101 class BrushCreator
102 {
103 public:
104   INTEGER_CONSTANT(Version, 1);
105   STRING_CONSTANT(Name, "brush");
106   virtual scene::Node& createBrush() = 0;
107   virtual bool useAlternativeTextureProjection() const = 0;
108   virtual void Brush_forEachFace(scene::Node& brush, const BrushFaceDataCallback& callback) = 0;
109   virtual bool Brush_addFace(scene::Node& brush, const _QERFaceData& faceData) = 0;
110 };
111
112 #include "modulesystem.h"
113
114 template<typename Type>
115 class GlobalModule;
116 typedef GlobalModule<BrushCreator> GlobalBrushModule;
117
118 template<typename Type>
119 class GlobalModuleRef;
120 typedef GlobalModuleRef<BrushCreator> GlobalBrushModuleRef;
121
122 inline BrushCreator& GlobalBrushCreator()
123 {
124   return GlobalBrushModule::getTable();
125 }
126
127 #endif