Cafu Engine
Renderer3D.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_MODEL_EDITOR_RENDERER_3D_HPP_INCLUDED
8 #define CAFU_MODEL_EDITOR_RENDERER_3D_HPP_INCLUDED
9 
10 #include "Math3D/BoundingBox.hpp"
11 #include "Math3D/Matrix3x3.hpp"
12 #include "wx/gdicmn.h"
13 
14 
15 namespace MatSys { class RenderMaterialT; }
16 
17 
18 namespace ModelEditor
19 {
20  /// This class provides auxiliary means for rendering a 3D scene view of the model editor.
21  /// It is similar to but much simpler than the 3D renderer of the map editor.
22  /// In the future, we might split the Renderer3DT of the map editor into a GenericRenderer3DT base class and
23  /// Renderer3DT derived classes for the map and model editor, for re-using the code of the shared functionality...
25  {
26  public:
27 
28  /// The constructor.
29  Renderer3DT();
30 
31  /// The destructor.
32  ~Renderer3DT();
33 
34  // Materials query methods.
35  MatSys::RenderMaterialT* GetRMatWireframe() const { return m_RMatWireframe; }
36  MatSys::RenderMaterialT* GetRMatWireframe_OffsetZ() const { return m_RMatWireframeOZ; }
37  MatSys::RenderMaterialT* GetRMatFlatShaded() const { return m_RMatFlatShaded; }
38  MatSys::RenderMaterialT* GetRMatFlatShaded_OffsetZ() const { return m_RMatFlatShadedOZ; }
39  MatSys::RenderMaterialT* GetRMatOverlay() const { return m_RMatOverlay; }
40  MatSys::RenderMaterialT* GetRMatOverlay_OffsetZ() const { return m_RMatOverlayOZ; }
41  MatSys::RenderMaterialT* GetRMatTerrainEditorTool() const { return m_RMatTerrainEdit; }
42  MatSys::RenderMaterialT* GetRMatTerrainEyeDropper() const { return m_RMatTerrainEyeDropper; }
43  MatSys::RenderMaterialT* GetRMatWhite() const { return m_RMatWhite; }
44  MatSys::RenderMaterialT* GetRMatTexturedWireframe() const { return m_RMatTexturedWireframe; }
45 
46  /// Returns a "shade" according to the direction of the given normal vector.
47  float GetConstShade(const Vector3T<float>& Normal) const;
48 
49  /// Renders a box from the given bounding-box in the given color, with solid faces or in wireframe.
50  void RenderBox(const BoundingBox3fT& BB, const wxColour& Color, bool Solid) const;
51 
52  /// Renders a box from the given eight vertices in the given color, with solid faces or in wireframe.
53  /// The vertices are expected in the same order as given by the BoundingBox3T<T>::GetCornerVertices() method,
54  /// and the box can be arbitrarily trans- or even deformed.
55  void RenderBox(const Vector3fT Vertices[], const wxColour& Color, bool Solid) const;
56 
57  /// Renders a line from A to B in the given color.
58  void RenderLine(const Vector3fT& A, const Vector3fT& B, const wxColour& Color) const;
59 
60  /// Renders the basis vectors (the "axes") of the given matrix at the given position with the given length.
61  void BasisVectors(const Vector3fT& Pos, const cf::math::Matrix3x3fT& Mat, float Length=100.0f) const;
62 
63  /// Renders a cross-hair at the given point. Assumes that orthogonal rendering mode is active.
64  void RenderCrossHair(const wxPoint& Center) const;
65 
66 
67  private:
68 
69  Renderer3DT(const Renderer3DT&); ///< Use of the Copy Constructor is not allowed.
70  void operator = (const Renderer3DT&); ///< Use of the Assignment Operator is not allowed.
71 
72  MatSys::RenderMaterialT* m_RMatWireframe; ///< The render material for wire-frame rendering.
73  MatSys::RenderMaterialT* m_RMatWireframeOZ; ///< The render material for wire-frame rendering (with polygon z-offset, e.g. for outlines).
74  MatSys::RenderMaterialT* m_RMatFlatShaded; ///< The render material for flat shaded (single solid color) rendering.
75  MatSys::RenderMaterialT* m_RMatFlatShadedOZ; ///< The render material for flat shaded (single solid color) rendering (with polygon z-offset, e.g. for decals).
76  MatSys::RenderMaterialT* m_RMatOverlay; ///< The render material for selection overlays (added in a second pass).
77  MatSys::RenderMaterialT* m_RMatOverlayOZ; ///< The render material for selection overlays (added in a second pass) (with polygon z-offset, e.g. for decals).
78  MatSys::RenderMaterialT* m_RMatTerrainEdit; ///< The render material overlay that is used to render the tool position in a terrain if the terrain edit tool is active.
79  MatSys::RenderMaterialT* m_RMatTerrainEyeDropper; ///< The render material overlay that is used to render the eyedropper tool position on a terrain.
80  MatSys::RenderMaterialT* m_RMatWhite; ///< This render material is intended as "debug" material for models in the Model Editor, so that the user can better inspect the surface lighting of the model.
81  MatSys::RenderMaterialT* m_RMatTexturedWireframe; ///< This render material is intended as "debug" material for models in the Model Editor, so that the user can better inspect the surface details of the model, e.g. at what vertex exactly are the GUI fixture points, etc.
82  };
83 }
84 
85 #endif
This class represents a surface render material.
Definition: RenderMaterial.hpp:25
void RenderBox(const BoundingBox3fT &BB, const wxColour &Color, bool Solid) const
Renders a box from the given bounding-box in the given color, with solid faces or in wireframe...
Definition: Renderer3D.cpp:61
Renderer3DT()
The constructor.
Definition: Renderer3D.cpp:18
void BasisVectors(const Vector3fT &Pos, const cf::math::Matrix3x3fT &Mat, float Length=100.0f) const
Renders the basis vectors (the "axes") of the given matrix at the given position with the given lengt...
Definition: Renderer3D.cpp:169
void RenderCrossHair(const wxPoint &Center) const
Renders a cross-hair at the given point. Assumes that orthogonal rendering mode is active...
Definition: Renderer3D.cpp:198
float GetConstShade(const Vector3T< float > &Normal) const
Returns a "shade" according to the direction of the given normal vector.
Definition: Renderer3D.cpp:52
This class provides auxiliary means for rendering a 3D scene view of the model editor.
Definition: Renderer3D.hpp:24
void RenderLine(const Vector3fT &A, const Vector3fT &B, const wxColour &Color) const
Renders a line from A to B in the given color.
Definition: Renderer3D.cpp:152
~Renderer3DT()
The destructor.
Definition: Renderer3D.cpp:37
This class represents a generic 3x3 matrix.
Definition: Angles.hpp:17