3es  0.7
3esplane.h
1 //
2 // author: Kazys Stepanas
3 //
4 #ifndef _3ESPLANE_H_
5 #define _3ESPLANE_H_
6 
7 #include "3es-core.h"
8 #include "3esshape.h"
9 
10 #include <3esrotation.h>
11 
12 namespace tes
13 {
22  class _3es_coreAPI Plane : public Shape
23  {
24  public:
30  static const Vector3f DefaultNormal;
31 
33  Plane(uint32_t id = 0u, const V3Arg &position = V3Arg(0, 0, 0), const V3Arg &normal = DefaultNormal, float scale = 1.0f, float normalLength = 1.0f);
41  Plane(uint32_t id, uint16_t category, const V3Arg &position = V3Arg(0, 0, 0), const V3Arg &normal = DefaultNormal, float scale = 1.0f, float normalLength = 1.0f);
42 
46  Plane &setNormal(const V3Arg &normal);
51  Vector3f normal() const;
52 
60  Plane &setScale(float scale);
63  float scale() const;
64 
68  Plane &setNormalLength(float length);
69 
72  float normalLength() const;
73  };
74 
75 
76  inline Plane::Plane(uint32_t id, const V3Arg &position, const V3Arg &normal, float scale, float normalLength)
77  : Shape(SIdPlane, id)
78  {
79  setPosition(position);
80  setNormal(normal);
81  Shape::setScale(Vector3f(scale, normalLength, scale));
82  }
83 
84 
85  inline Plane::Plane(uint32_t id, uint16_t category, const V3Arg &position, const V3Arg &normal, float scale, float normalLength)
86  : Shape(SIdPlane, id, category)
87  {
88  setPosition(position);
89  setNormal(normal);
90  Shape::setScale(Vector3f(scale, normalLength, scale));
91  }
92 
93 
95  {
96  Quaternionf rot(DefaultNormal, normal);
97  setRotation(rot);
98  return *this;
99  }
100 
101 
102  inline Vector3f Plane::normal() const
103  {
104  Quaternionf rot = rotation();
105  return rot * DefaultNormal;
106  }
107 
108 
109  inline Plane &Plane::setScale(float scale)
110  {
111  Vector3f s = Shape::scale();
112  s.x = s.z = scale;
113  Shape::setScale(s);
114  return *this;
115  }
116 
117 
118  inline float Plane::scale() const
119  {
120  return Shape::scale().x;
121  }
122 
123 
124  inline Plane &Plane::setNormalLength(float len)
125  {
126  Vector3f s = Shape::scale();
127  s.y = len;
128  Shape::setScale(s);
129  return *this;
130  }
131 
132 
133  inline float Plane::normalLength() const
134  {
135  return Shape::scale().y;
136  }
137 }
138 
139 #endif // _3ESPLANE_H_
A base class for encapsulating a shape which is to be represented remotely.
Definition: 3esshape.h:39
float normalLength() const
Get the plane normal display length.
Definition: 3esplane.h:133
float scale() const
Get the plane scaling values.
Definition: 3esplane.h:118
static const Vector3f DefaultNormal
Defines the default plane normal orientation.
Definition: 3esplane.h:30
Definition: 3esbounds.h:13
Defines a rectangular planar section to display.
Definition: 3esplane.h:22
Vector3< float > Vector3f
Defines a single precision vector.
Definition: 3esvector3.h:14
Vector3f normal() const
Get the plane normal.
Definition: 3esplane.h:102
Represents a vector in R3.
Definition: 3esvector3.h:14
A helper structure used to convert from float or double pointers to Vector3f arguments.
Definition: 3esv3arg.h:14
T x
Direct data member access.
Definition: 3esvector3.h:30
Plane(uint32_t id=0u, const V3Arg &position=V3Arg(0, 0, 0), const V3Arg &normal=DefaultNormal, float scale=1.0f, float normalLength=1.0f)
Definition: 3esplane.h:76
Plane & setScale(float scale)
Set the plane "scale", which controls the render size.
Definition: 3esplane.h:109
Plane & setNormal(const V3Arg &normal)
Set the plane normal.
Definition: 3esplane.h:94
Plane & setNormalLength(float length)
Set the plane normal&#39;s display length.
Definition: 3esplane.h:124