HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  virtual ~GT_PrimSphere();
56 
57  virtual const char *className() const { return "GT_PrimSphere"; }
58  virtual bool save(UT_JSONWriter &w) const
59  { return saveQuadric(w, "Sphere"); }
60 
61  /// @{
62  /// Methods defined on GT_Primitive
63  virtual int getPrimitiveType() const;
65  { return new GT_PrimSphere(*this); }
66  virtual GT_PrimitiveHandle doHarden() const;
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  virtual GT_PrimQuadric *clone(const GT_Parametric &uv) const
98  {
99  return new GT_PrimSphere(*this, uv);
100  }
101  /// @{
102  /// Methods defined on GT_PrimQuadric
103  virtual void getQBounds(UT_BoundingBox &box) const;
104  virtual void fillQP(UT_Vector3F *P, GT_Size n,
105  const fpreal *u, fpreal v) const;
106  virtual void fillQP(UT_Vector3D *P, GT_Size n,
107  const fpreal *u, fpreal v) const;
108  virtual void fillQN(UT_Vector3F *P, GT_Size n,
109  const fpreal *u, fpreal v) const;
110  virtual void fillQN(UT_Vector3D *P, GT_Size n,
111  const fpreal *u, fpreal v) const;
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:836
Class to keep track for a 2D parametric interval.
Definition: GT_Parametric.h:20
#define GT_API
Definition: GT_API.h:11
virtual GT_PrimQuadric * clone(const GT_Parametric &uv) const
Create a split primitive.
Definition: GT_PrimSphere.h:97
GT_PrimSphere(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv=GT_Parametric())
Useful constructor.
Definition: GT_PrimSphere.h:39
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
virtual bool save(UT_JSONWriter &w) const
Definition: GT_PrimSphere.h:58
bool init(const GT_AttributeListHandle &attribs, const GT_TransformHandle &transform, const GT_Parametric &uv)
virtual GT_PrimitiveHandle doSoftCopy() const
Definition: GT_PrimSphere.h:64
GLdouble n
Definition: glcorearb.h:2007
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
double fpreal
Definition: SYS_Types.h:269
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
virtual void getQBounds(UT_BoundingBox &box) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
int64 GT_Size
Definition: GT_Types.h:109
virtual const char * className() const
Definition: GT_PrimSphere.h:57
GLenum src
Definition: glcorearb.h:1792