3es  0.7
3essphere.h
1 //
2 // author: Kazys Stepanas
3 //
4 #ifndef _3ESSPHERE_H_
5 #define _3ESSPHERE_H_
6 
7 #include "3es-core.h"
8 #include "3esshape.h"
9 
10 namespace tes
11 {
19  class _3es_coreAPI Sphere : public Shape
20  {
21  public:
23  Sphere(uint32_t id = 0u, const V3Arg &centre = V3Arg(0, 0, 0), float radius = 1.0f);
29  Sphere(uint32_t id, uint16_t category, const V3Arg &centre = V3Arg(0, 0, 0), float radius = 1.0f);
30 
34  Sphere &setRadius(float radius);
37  float radius() const;
38 
42  Sphere &setCentre(const V3Arg &centre);
45  Vector3f centre() const;
46  };
47 
48 
49  inline Sphere::Sphere(uint32_t id, const V3Arg &centre, float radius)
50  : Shape(SIdSphere, id)
51  {
52  setPosition(centre);
53  setScale(Vector3f(radius));
54  }
55 
56 
57  inline Sphere::Sphere(uint32_t id, uint16_t category, const V3Arg &centre, float radius)
58  : Shape(SIdSphere, id, category)
59  {
60  setPosition(centre);
61  setScale(Vector3f(radius));
62  }
63 
64 
66  {
67  setScale(Vector3f(radius));
68  return *this;
69  }
70 
71 
72  inline float Sphere::radius() const
73  {
74  return scale().x;
75  }
76 
77 
79  {
80  setPosition(centre);
81  return *this;
82  }
83 
84 
85  inline Vector3f Sphere::centre() const
86  {
87  return position();
88  }
89 }
90 
91 #endif // _3ESSPHERE_H_
A base class for encapsulating a shape which is to be represented remotely.
Definition: 3esshape.h:39
Definition: 3esbounds.h:13
Sphere & setCentre(const V3Arg &centre)
Set the sphere centre coordinate.
Definition: 3essphere.h:78
Vector3< float > Vector3f
Defines a single precision vector.
Definition: 3esvector3.h:14
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
Vector3f centre() const
Get the sphere centre coordinate.
Definition: 3essphere.h:85
T x
Direct data member access.
Definition: 3esvector3.h:30
Sphere(uint32_t id=0u, const V3Arg &centre=V3Arg(0, 0, 0), float radius=1.0f)
Definition: 3essphere.h:49
Sphere & setRadius(float radius)
Set the sphere radius.
Definition: 3essphere.h:65
float radius() const
Get the sphere radius.
Definition: 3essphere.h:72
Defines a sphere to display.
Definition: 3essphere.h:19