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 "generic/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:
_QERFaceData()86 _QERFaceData() : m_shader( "" ), contents( 0 ), flags( 0 ), value( 0 ){
87 }
88 Vector3 m_p0;
89 Vector3 m_p1;
90 Vector3 m_p2;
91 texdef_t m_texdef;
92 const char* m_shader;
93 int contents;
94 int flags;
95 int value;
96 };
97
98 typedef Callback1<const _QERFaceData&> BrushFaceDataCallback;
99
100 class BrushCreator
101 {
102 public:
103 INTEGER_CONSTANT( Version, 1 );
104 STRING_CONSTANT( Name, "brush" );
105 virtual scene::Node& createBrush() = 0;
106 virtual bool useAlternativeTextureProjection() const = 0;
107 virtual void Brush_forEachFace( scene::Node& brush, const BrushFaceDataCallback& callback ) = 0;
108 virtual bool Brush_addFace( scene::Node& brush, const _QERFaceData& faceData ) = 0;
109 };
110
111 #include "modulesystem.h"
112
113 template<typename Type>
114 class GlobalModule;
115 typedef GlobalModule<BrushCreator> GlobalBrushModule;
116
117 template<typename Type>
118 class GlobalModuleRef;
119 typedef GlobalModuleRef<BrushCreator> GlobalBrushModuleRef;
120
GlobalBrushCreator()121 inline BrushCreator& GlobalBrushCreator(){
122 return GlobalBrushModule::getTable();
123 }
124
125 #endif
126