Cafu Engine
1 /*
2 Cafu Engine,
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
10 #include "SurfaceInfo.hpp"
12 #include "Math3D/BoundingBox.hpp"
13 #include "Math3D/Plane3.hpp"
15 #include <ostream>
18 class EditorMatManT;
19 class EditorMaterialI;
20 class MapBrushT;
21 class Renderer3DT;
22 namespace MatSys { class RenderMaterialT; }
23 class wxColour;
26 class MapFaceT
27 {
28  public:
30  MapFaceT(EditorMaterialI* Material=NULL);
31  MapFaceT(EditorMaterialI* Material, const Plane3fT& Plane, const Vector3fT* PlanePoints, bool FaceAligned);
33  // Named constructors for loading faces from map files.
34  static MapFaceT Create_cmap(TextParserT& TP, EditorMatManT& MatMan);
35  static MapFaceT Create_D3_map(TextParserT& TP, const Vector3fT& Origin, EditorMatManT& MatMan);
36  static MapFaceT Create_HL1_map(TextParserT& TP, EditorMatManT& MatMan);
37  static MapFaceT Create_HL2_vmf(TextParserT& TP, EditorMatManT& MatMan);
40  void Save_cmap(std::ostream& OutFile) const;
41  void Render3DBasic(MatSys::RenderMaterialT* RenderMat, const wxColour& MeshColor, const int MeshAlpha) const;
42  void Render3D(Renderer3DT& Renderer, const MapBrushT* ParentBrush) const;
44  void SetMaterial(EditorMaterialI* Material);
45  EditorMaterialI* GetMaterial() const { return m_Material; }
47  void SetSurfaceInfo(const SurfaceInfoT& SI);
48  const SurfaceInfoT& GetSurfaceInfo() const { return m_SurfaceInfo; }
50  const Plane3T<float>& GetPlane () const { return m_Plane; }
51  const ArrayT<Vector3fT>& GetPlanePoints () const { return m_PlanePoints; }
52  const ArrayT<Vector3fT>& GetVertices () const { return m_Vertices; }
53  // const ArrayT<TexCoordT>& GetTextureCoords () const { return m_TextureCoords; } // Currently unused.
54  // const ArrayT<TexCoordT>& GetLightmapCoords() const { return m_LightmapCoords; } // Currently unused.
56  // "Advanced" query methods, all constant.
57  bool IsUVSpaceFaceAligned() const; ///< Determines whether the uv-space of this face is face-aligned. The uv-space of this face is face-aligned when both UAxis and VAxis are orthogonal to m_Plane.Normal.
58  bool IsUVSpaceWorldAligned() const; ///< Determines whether the uv-space of this face is world-aligned. The uv-space of this face is world-aligned when both UAxis and VAxis are in the same principal plane.
61  private:
63  friend class MapBrushT;
64  friend class EditSurfacePropsDialogT; // The EditSurfacePropsDialogT is granted access, among others, to our m_IsSelected member (which is for use by the EditSurfacePropsDialogT only).
66  void UpdateTextureSpace(); ///< Uses the m_SurfaceInfo to re-calculate, for each vertex, the texture coords, the lightmap coords, the tangents and the bi-tangents.
67  Vector3fT GetCenter() const;
69  EditorMaterialI* m_Material; ///< The material that is applied to this face as specified in m_SurfaceInfo.
70  SurfaceInfoT m_SurfaceInfo; ///< The surface info that specifies how the m_Material is applied to this face.
71  Plane3T<float> m_Plane;
72  ArrayT<Vector3fT> m_PlanePoints; ///< The three points that define the m_Plane.
73  ArrayT<Vector3fT> m_Vertices; ///< The vertices of the polygon that this face contributes to its brush.
74  ArrayT<TexCoordT> m_TextureCoords; ///< An array of texture coordinates, one per face point.
75  ArrayT<TexCoordT> m_LightmapCoords; ///< An array of lightmap coordinates, one per face point.
76  ArrayT<Vector3fT> m_Tangents;
77  ArrayT<Vector3fT> m_BiTangents;
78  bool m_IsSelected; ///< Is this face selected? (For use by the "Edit Surface Properties" dialog only!)
79 };
81 #endif
This class provides auxiliary means for rendering a 3D view.
Definition: Renderer3D.hpp:30
This class represents a surface render material.
Definition: RenderMaterial.hpp:25
This class holds all information that is needed in order to compute the UV texture-space coordinates ...
Definition: SurfaceInfo.hpp:51
bool IsUVSpaceWorldAligned() const
Determines whether the uv-space of this face is world-aligned. The uv-space of this face is world-ali...
Definition: MapFace.cpp:130
This class manages the editor materials for a game configuration.
Definition: EditorMaterialManager.hpp:20
This class represents a polymorphic 3-dimensional vector.
Definition: Misc.hpp:11
Definition: MapBrush.hpp:15
bool IsUVSpaceFaceAligned() const
Determines whether the uv-space of this face is face-aligned. The uv-space of this face is face-align...
Definition: MapFace.cpp:119
Definition: EditorMaterial.hpp:21
The "Edit Surface Properties" dialog is the counterpart of the ToolEditSurfaceT tool.
Definition: DialogEditSurfaceProps.hpp:33
Definition: Renderer.hpp:16
This is a class for parsing text.
Definition: TextParser.hpp:21
Definition: MapFace.hpp:26