All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AtlasPinViewFactory.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "IPinViewFactory.h"
7 #include "LayerIds.h"
8 #include "Pin.h"
9 #include "Bounds.h"
10 #include "PinView.h"
11 #include "AtlasTexturePageLayout.h"
12 #include "MathFunc.h"
13 
14 namespace Eegeo
15 {
16  namespace Pins
17  {
18 
20  {
21  public:
23  : m_pageLayout(pageLayout)
24  {
25 
26  }
27 
29  {
30  const Geometry::Bounds2D& uvBounds = m_pageLayout.GetTileUVBounds(pinModel.GetCategoryId());
31  float width=Math::Abs(uvBounds.max.x-uvBounds.min.x)*m_pageLayout.GetPageWidth();
32  float height=Math::Abs(uvBounds.max.y-uvBounds.min.y)*m_pageLayout.GetPageHeight();
33  v3 vertices[3];
34 
35  vertices[0].x = -width/2.0f;
36  vertices[0].y = 0;
37  vertices[0].z = 0;
38 
39  vertices[1].x = -width/2.0f;
40  vertices[1].y = height;
41  vertices[1].z = 0;
42 
43  vertices[2].x = width/2.0f;
44  vertices[2].y = height;
45  vertices[2].z = 0;
46 
47  Geometry::Bounds3D modelBounds = Geometry::Bounds3D::Degenerate();
48  modelBounds.Encapsulate(vertices[0]);
49  modelBounds.Encapsulate(vertices[1]);
50  modelBounds.Encapsulate(vertices[2]);
51 
52  return Eegeo_NEW(PinView)(pinModel, modelBounds);
53  }
54 
55  private:
56  const Rendering::AtlasTexturePageLayout& m_pageLayout;
57  };
58  }
59 }