All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PinViewFactory.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 
12 namespace Eegeo
13 {
14  namespace Pins
15  {
25  {
26  public:
27  PinViewFactory(float spriteWidth, float spriteHeight)
28  : m_spriteDimensions(Geometry::Bounds2D(
29  v2(-(spriteWidth / 2), 0),
30  v2((spriteWidth / 2), spriteHeight)))
31  {
32 
33  }
34 
36  {
37  // since we're constructing a local bounds from the dimensions, we don't need to add all four points
38  v3 vertices[3];
39 
40  vertices[0].x = m_spriteDimensions.min.GetX();
41  vertices[0].y = m_spriteDimensions.min.GetY();
42  vertices[0].z = 0;
43 
44  vertices[1].x = m_spriteDimensions.min.GetX();
45  vertices[1].y = m_spriteDimensions.max.GetY();
46  vertices[1].z = 0;
47 
48  vertices[2].x = m_spriteDimensions.max.GetX();
49  vertices[2].y = m_spriteDimensions.max.GetY();
50  vertices[2].z = 0;
51 
52  Geometry::Bounds3D modelBounds = Geometry::Bounds3D::Degenerate();
53  modelBounds.Encapsulate(vertices[0]);
54  modelBounds.Encapsulate(vertices[1]);
55  modelBounds.Encapsulate(vertices[2]);
56 
57  return Eegeo_NEW(PinView)(pinModel, modelBounds);
58  }
59 
60  private:
61  Eegeo::Geometry::Bounds2D m_spriteDimensions;
62  };
63  }
64 }