HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimSphere.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GT_PrimSphere.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimSphere__
12 #define __GT_PrimSphere__
13 
14 #include "GT_API.h"
15 #include "GT_PrimQuadric.h"
16 #include "GT_Parametric.h"
17 #include "GT_Transform.h"
18 
19 /// @brief A sphere primitive
20 ///
21 /// The sphere primitive represents a parametric patch of a sphere primitive
22 /// The sphere is parametrized so @c u (0 to 1) represents longitude, while
23 /// @c v (0 to 1) is goes from pole to pole.
24 /// That is: @code
25 /// theta = u * 2*PI
26 /// phi = v * PI
27 /// x = cos(theta)*cos(phi)
28 /// y = sin(theta)*cos(phi)
29 /// z = sin(phi)
30 /// @endcode
32 {
33 public:
34  /// Default constructor (full unit sphere, no attributes)
36  : GT_PrimQuadric()
37  {}
38  /// Useful constructor
42  : GT_PrimQuadric(attribs, transform, uv)
43  { }
44  /// Copy constructor with different parametric range
46  : GT_PrimQuadric(src, uv)
47  {
48  }
49  /// Copy constructor
51  : GT_PrimQuadric(src)
52  {
53  }
54  /// Destructor
55  ~GT_PrimSphere() override;
56 
57  const char *className() const override { return "GT_PrimSphere"; }
58  bool save(UT_JSONWriter &w) const override
59  { return saveQuadric(w, "Sphere"); }
60 
61  /// @{
62  /// Methods defined on GT_Primitive
63  int getPrimitiveType() const override;
64  GT_PrimitiveHandle doSoftCopy() const override
65  { return new GT_PrimSphere(*this); }
66  GT_PrimitiveHandle doHarden() const override;
67  /// @}
68 
69  /// Initialize a sphere with
70  /// @param attribs @n
71  /// Attributes defined on the sphere
72  /// @param transform @n
73  /// The transform attribute list should contain a single transform
74  /// representing the 4x4 transform of the sphere.
75  /// @param uv @n
76  /// The parametric range for the sphere. The sphere is parametrized so
77  /// @c u (0 to 1) represents longitude, while @c v (0 to 1) is goes from
78  /// pole to pole.
79  bool init(const GT_AttributeListHandle &attribs,
80  const GT_TransformHandle &transform,
81  const GT_Parametric &uv)
82  {
83  if (!GT_PrimQuadric::init(attribs, transform, uv))
84  return false;
85  return true;
86  }
87 
88  /// Static method to compute bounds for a sphere
89  static void computeSphereBounds(UT_BoundingBox &box,
90  const GT_Parametric &uv);
91 
92  /// Get a tesselation of a full sphere with a given set of refinement
93  /// parameters.
94  static GT_PrimitiveHandle makePolygonMesh(const GT_RefineParms *parms);
95 
96 protected:
97  GT_PrimQuadric *clone(const GT_Parametric &uv) const override
98  {
99  return new GT_PrimSphere(*this, uv);
100  }
101  /// @{
102  /// Methods defined on GT_PrimQuadric
103  void getQBounds(UT_BoundingBox &box) const override;
104  void fillQP(UT_Vector3F *P, GT_Size n,
105  const fpreal *u, fpreal v) const override;
106  void fillQP(UT_Vector3D *P, GT_Size n,
107  const fpreal *u, fpreal v) const override;
108  void fillQN(UT_Vector3F *P, GT_Size n,
109  const fpreal *u, fpreal v) const override;
110  void fillQN(UT_Vector3D *P, GT_Size n,
111  const fpreal *u, fpreal v) const override;
112  /// @}
113 };
114 
115 #endif
A sphere primitive.
Definition: GT_PrimSphere.h:31
virtual void fillQN(UT_Vector3F *P, GT_Size n, const fpreal *u, fpreal v) const =0
virtual int getPrimitiveType() const
GA_API const UT_StringHolder uv
const GLdouble * v
Definition: glcorearb.h:837
Class to keep track for a 2D parametric interval.
Definition: GT_Parametric.h:20
#define GT_API
Definition: GT_API.h:13
GT_PrimSphere(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv=GT_Parametric())
Useful constructor.
Definition: GT_PrimSphere.h:39
GT_PrimQuadric * clone(const GT_Parametric &uv) const override
Create a split primitive.
Definition: GT_PrimSphere.h:97
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
bool init(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv)
GLdouble n
Definition: glcorearb.h:2008
GT_PrimSphere(const GT_PrimSphere &src)
Copy constructor.
Definition: GT_PrimSphere.h:50
GA_API const UT_StringHolder transform
virtual void fillQP(UT_Vector3F *P, GT_Size n, const fpreal *u, fpreal v) const =0
virtual GT_PrimitiveHandle doHarden() const
bool saveQuadric(UT_JSONWriter &w, const char *name) const
GT_PrimitiveHandle doSoftCopy() const override
Definition: GT_PrimSphere.h:64
int64 GT_Size
Definition: GT_Types.h:128
const char * className() const override
Definition: GT_PrimSphere.h:57
bool init(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv)
Definition: GT_PrimSphere.h:79
GT_PrimSphere()
Default constructor (full unit sphere, no attributes)
Definition: GT_PrimSphere.h:35
GT_PrimSphere(const GT_PrimSphere &src, const GT_Parametric &uv)
Copy constructor with different parametric range.
Definition: GT_PrimSphere.h:45
fpreal64 fpreal
Definition: SYS_Types.h:277
bool save(UT_JSONWriter &w) const override
Definition: GT_PrimSphere.h:58
virtual void getQBounds(UT_BoundingBox &box) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GLenum src
Definition: glcorearb.h:1793