All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TextMeshGenerator.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Fonts.h"
7 #include "VectorMathDecl.h"
8 #include "Rendering.h"
9 #include "Space.h"
10 #include "ScratchGeometry.h"
11 #include "Bounds.h"
12 #include "FontCharacter.h"
13 #include "StringEntry.h"
14 #include "CharacterEntry.h"
15 #include <vector>
16 #include <deque>
17 #include <string>
18 
19 namespace Eegeo
20 {
21  namespace TextMeshes
22  {
23  struct TextMeshBuilderResult;
24 
25  namespace Internal
26  {
27  struct CharacterEntry;
28  struct StringEntry;
29 
30 
32  {
33  public:
35 
36  virtual ~TextMeshGenerator() {}
37 
38  virtual void Begin(const Fonts::FontInstance* pFont, size_t initialCharacterCapacity);
39 
40  virtual void Reserve(size_t characterCount);
41 
42  virtual bool HasValidGeometry() const
43  {
44  return !m_characterEntries.empty();
45  }
46 
47  virtual void AddText(const std::vector<u32>& textUtf32, const Eegeo::m44& transform, float fontSize, float xOffset, float yOffset, float altitudeOffset, float& out_endX);
48 
49 
50  virtual void AddCustomQuads(const std::vector<Rendering::VertexTypes::TextVertex>& vertices,
51  int quadCount,
52  int customGeometryPageIndex);
53 
54  virtual void GenerateMeshes(bool shadowed, bool doubleSided, float shadowOffsetMeters, const v3& up, Rendering::MeshFactories::TextMeshFactory& textMeshFactory, const std::string& debugName, const Space::CubeMap::CubeMapCellInfo& cellInfo, TextMeshBuilderResult& out_result);
55 
56  protected:
57  virtual void AddTextGeometry(std::vector<Internal::CharacterEntry>::const_iterator characterRangeBegin,
58  int characterCount,
59  const v3& up,
60  const m44& reverseSideTransform,
61  float shadowParam,
62  float z) = 0;
63 
64  private:
65  void ValidateFont();
66 
67  void BuildGeometryForPage(
68  std::vector<Internal::CharacterEntry>::const_iterator characterRangeBegin,
69  int characterCount,
70  bool shadowed, bool doubleSided, float shadowOffsetMeters,
71  const v3& up);
72 
73 
74 
75  Rendering::Mesh* GenerateMesh(int quadCount,
77  const std::string& debugName);
78  protected:
79  std::deque<Internal::StringEntry> m_stringEntries;
80  std::vector<Internal::CharacterEntry> m_characterEntries;
81  std::vector<int> m_pageCharacterCounts;
82 
83  Internal::ScratchGeometry m_scratchGeometry;
84  std::vector<Geometry::Bounds2D> m_scratchBounds;
85 
86  std::vector<Rendering::VertexTypes::TextVertex> m_customVertices;
87  int m_customGeometryPageIndex;
88 
89  const Fonts::FontInstance* m_pFont;
90 
91  float m_oneOverFontHeight;
92  float m_oneOverScaleW;
93  float m_oneOverScaleH;
94  };
95 
96  }
97  }
98 }