2 fegdk: FE Game Development Kit
3 Copyright (C) 2001-2008 Alexey "waker" Yakovenko
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 waker@users.sourceforge.net
29 #include "f_helpers.h"
30 #include "f_material.h"
32 #include "f_basetexture.h"
39 friend class brushFace
;
43 std::vector
< vector3
> mPoints
;
44 std::vector
< vector2
> mTexCoords
;
49 brushWinding (const brushWinding
&w
);
53 vector3
& point (int iPoint
) { return mPoints
[iPoint
]; }
54 const vector3
& point (int iPoint
) const { return mPoints
[iPoint
]; }
55 int numPoints (void) const { return (int)mPoints
.size (); }
56 vector2
& texCoord (int iPoint
) { return mTexCoords
[iPoint
]; }
57 const vector2
& texCoord (int iPoint
) const { return mTexCoords
[iPoint
]; }
58 void baseForPlane (const plane
&p
);
59 bool clip (const plane
&split
, bool keepon
);
80 cStr
& name (void) { return mName
; }
81 const cStr
& name (void) const { return mName
; }
82 int* shift (void) { return mShift
; }
83 const int* shift (void) const { return mShift
; }
84 int& rotate (void) { return mRotate
; }
85 const int& rotate (void) const { return mRotate
; }
86 float* scale (void) { return mScale
; }
87 const float* scale (void) const { return mScale
; }
88 long& contents (void) { return mContents
; }
89 const long& contents (void) const { return mContents
; }
90 long& flags (void) { return mFlags
; }
91 const long& flags (void) const { return mFlags
; }
92 long& value (void) { return mValue
; }
93 const long& value (void) const { return mValue
; }
102 vector3 mPlanePts
[3];
103 brushWinding mWinding
;
104 brushFaceTexdef mTexdef
;
110 brushFace (const brushFace
&f
);
113 plane
& plane () { return mPlane
; }
114 const plane
& plane () const { return mPlane
; }
115 vector3
& planePt (uint iPoint
) { assert (iPoint
< 3); return mPlanePts
[iPoint
]; }
116 const vector3
& planePt (uint iPoint
) const { assert (iPoint
< 3); return mPlanePts
[iPoint
]; }
117 brushWinding
& winding () { return mWinding
; }
118 const brushWinding
& winding () const { return mWinding
; }
119 materialPtr
material () const { return mpMtl
; }
120 void setMaterial (const materialPtr
&mtl
);
121 brushFaceTexdef
& texdef () { return mTexdef
; }
122 void textureVectors (float stFromXYZ
[2][4]);
123 vector2
emitTexCoords (const vector3
&pt
);
124 void applyTexdef (void);
133 std::vector
< brushFace
> mFaces
;
137 bool makeFaceWinding (int face
);
138 bool makeFacePlane (int face
);
143 brush (const vector3
&mins
, const vector3
&maxs
);
144 void create (const vector3
&mins
, const vector3
&maxs
);
145 brush (const brush
&b
);
147 void clear (void) { mFaces
.clear (); }
150 void buildWindings (bool snap
= true);
151 void move (const vector3
&moveVec
, bool snap
= true);
152 void splitByFace (const brushFace
&f
, brush
*&front
, brush
*&back
);
154 void snapPlanePts ();
155 void rotate (const vector3
&angle
, const vector3
&origin
, bool build
= true);
156 void flip (const vector3
&axis
, const vector3
&origin
);
157 void removeEmptyFaces ();
158 virtual void build (bool bSnap
= true);
159 void buildTexturing (void);
162 void makeSided (int sides
, int axis
= 2); // default axis is z
163 void makeSidedCone (int sides
);
164 void makeSidedSphere (int sides
);
167 brushFace
& faces (int iFace
) { return mFaces
[iFace
]; }
168 const brushFace
& faces (int iFace
) const { return mFaces
[iFace
]; }
169 int numFaces (void) const { return (int)mFaces
.size (); }
170 vector3
& mins () { return mMins
; }
171 vector3
& maxs () { return mMaxs
; }
172 void addFace (const brushFace
& f
) { mFaces
.push_back (f
); }
175 // void csgAdd (std::vector<brush *> &outBrushList, brush *b);
176 void csgSubtract (std::vector
<brush
*> &outBrushList
, brush
*b
);
177 // void csgIntersection (std::vector<brush *> &outBrushList, brush *b);
178 // void csgDifference (std::vector<brush *> &outBrushList, brush *b);
183 #endif // __F_BRUSH_H