2
// Copyright ļæ½ 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation; either
9
// version 2 of the License, or (at your option) any later version.
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this library; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
\brief Declares the standard RenderMan quadric primitive classes.
23
\author Paul C. Gregory (pgregory@aqsis.com)
26
//? Is .h included already?
27
#ifndef QUADRICS_H_INCLUDED
28
#define QUADRICS_H_INCLUDED 1
33
#include "micropolygon.h"
35
START_NAMESPACE( Aqsis )
38
#define ESTIMATEGRIDSIZE 8
40
//----------------------------------------------------------------------
42
* Abstract base class from which all quadric primitives are defined.
45
class CqQuadric : public CqSurface
53
CqBound MotionBound(CqBound& B) const;
54
virtual void Transform( const CqMatrix& matTx, const CqMatrix& matITTx, const CqMatrix& matRTx, TqInt iTime = 0 );
55
/** Get the number of uniform values for this GPrim.
57
virtual TqUint cUniform() const
61
virtual TqUint cVarying() const
65
virtual TqUint cVertex() const
69
virtual TqUint cFaceVarying() const
71
/// \todo Must work out what this value should be.
76
// Overrides from CqSurface
77
virtual TqBool Diceable();
79
/** Determine whether the passed surface is valid to be used as a
80
* frame in motion blur for this surface.
82
virtual TqBool IsMotionBlurMatch( CqBasicSurface* pSurf )
87
TqUlong EstimateGridSize();
88
void Circle( const CqVector3D& O, const CqVector3D& X, const CqVector3D& Y, TqFloat r, TqFloat as, TqFloat ae, std::vector<CqVector3D>& points ) const;
89
CqBound RevolveForBound( const std::vector<CqVector3D>& profile, const CqVector3D& S, const CqVector3D& Tvec, TqFloat theta ) const;
91
virtual TqInt DiceAll( CqMicroPolyGrid* pGrid );
93
/** Pure virtual, get a surface point.
94
* \param u Surface u coordinate.
95
* \param v Surface v coordinate.
96
* \return 3D vector representing the surface point at the specified u,v coordniates.
98
virtual CqVector3D DicePoint( TqInt u, TqInt v ) = 0;
99
/** Pure virtual, get a surface point and normal.
100
* \param u Surface u coordinate.
101
* \param v Surface v coordinate.
102
* \param Normal Storage for the surface normal.
103
* \return 3D vector representing the surface point at the specified u,v coordniates.
105
virtual CqVector3D DicePoint( TqInt u, TqInt v, CqVector3D& Normal ) = 0;
107
CqQuadric& operator=( const CqQuadric& From );
109
// Derived from CqSurface
110
virtual void NaturalDice( CqParameter* pParameter, TqInt uDiceSize, TqInt vDiceSize, IqShaderData* pData );
111
virtual void GenerateGeometricNormals( TqInt uDiceSize, TqInt vDiceSize, IqShaderData* pNormals );
114
CqString className() const { return CqString("CqQuadric"); }
118
CqMatrix m_matTx; ///< Transformation matrix from object to camera.
119
CqMatrix m_matITTx; ///< Inverse transpose transformation matrix, for transforming normals.
126
//----------------------------------------------------------------------
128
* Sphere quadric GPrim.
131
class CqSphere : public CqQuadric
134
CqSphere( TqFloat radius = 1.0f, TqFloat zmin = -1.0f, TqFloat zmax = 1.0f, TqFloat thetamin = 0.0f, TqFloat thetamax = 360.0f );
135
CqSphere( const CqSphere& From )
142
virtual CqBound Bound() const;
144
virtual CqVector3D DicePoint( TqInt u, TqInt v );
145
virtual CqVector3D DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
146
virtual TqBool CanGenerateNormals() const
151
virtual TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
153
CqSphere& operator=( const CqSphere& From );
156
CqString className() const { return CqString("CqSphere"); }
160
TqFloat m_Radius; ///< Radius.
161
TqFloat m_ZMin; ///< Min value on z axis.
162
TqFloat m_ZMax; ///< Max value on z axis.
163
TqFloat m_ThetaMin; ///< Min angle about z axis.
164
TqFloat m_ThetaMax; ///< Max angle about z axis.
169
//----------------------------------------------------------------------
171
* Cone quadric GPrim.
174
class CqCone : public CqQuadric
177
CqCone( TqFloat height = 1.0f, TqFloat radius = 1.0f, TqFloat thetamin = 0.0f, TqFloat thetamax = 360.0f, TqFloat zmin = 0.0f, TqFloat zmax = 1.0f );
178
CqCone( const CqCone& From )
185
virtual CqBound Bound() const;
187
virtual CqVector3D DicePoint( TqInt u, TqInt v );
188
virtual CqVector3D DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
190
virtual TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
192
CqCone& operator=( const CqCone& From );
195
CqString className() const { return CqString("CqCone"); }
199
TqFloat m_Height; ///< Height..
200
TqFloat m_Radius; ///< Radius.
201
TqFloat m_vMin; ///< Min value on z axis.
202
TqFloat m_vMax; ///< Max value on z axis.
203
TqFloat m_ThetaMin; ///< Min angle about z axis.
204
TqFloat m_ThetaMax; ///< Max angle about z axis.
209
//----------------------------------------------------------------------
210
/** \class CqCylinder
211
* Cylinder quadric GPrim.
214
class CqCylinder : public CqQuadric
217
CqCylinder( TqFloat radius = 1.0f, TqFloat zmin = -1.0f, TqFloat zmax = 1.0f, TqFloat thetamin = 0.0f, TqFloat thetamax = 360.0f );
218
CqCylinder( const CqCylinder& From )
222
virtual ~CqCylinder()
225
virtual CqBound Bound() const;
227
virtual CqVector3D DicePoint( TqInt u, TqInt v );
228
virtual CqVector3D DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
229
virtual TqBool CanGenerateNormals() const
234
virtual TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
236
CqCylinder& operator=( const CqCylinder& From );
239
CqString className() const { return CqString("CqCylinder"); }
243
TqFloat m_Radius; ///< Radius
244
TqFloat m_ZMin; ///< Min value on zaxis.
245
TqFloat m_ZMax; ///< Max value on z axis.
246
TqFloat m_ThetaMin; ///< Min angle about z axis.
247
TqFloat m_ThetaMax; ///< Max angle about z axis.
252
//----------------------------------------------------------------------
253
/** \class CqHyperboloid
254
* Hyperboloid quadric GPrim.
257
class CqHyperboloid : public CqQuadric
261
CqHyperboloid( CqVector3D& point1, CqVector3D& point2, TqFloat thetamin, TqFloat thetamax );
262
CqHyperboloid( const CqHyperboloid& From )
266
virtual ~CqHyperboloid()
269
virtual CqBound Bound() const;
271
virtual CqVector3D DicePoint( TqInt u, TqInt v );
272
virtual CqVector3D DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
274
virtual TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
276
CqHyperboloid& operator=( const CqHyperboloid& From );
279
CqString className() const { return CqString("CqHyperboloid"); }
283
CqVector3D m_Point1; ///< Start point of line to revolve.
284
CqVector3D m_Point2; ///< End point of line to revolve.
285
TqFloat m_ThetaMin; ///< Min angle about z axis.
286
TqFloat m_ThetaMax; ///< Max angle about z axis.
291
//----------------------------------------------------------------------
292
/** \class CqParaboloid
293
* Paraboloid quadric GPrim.
296
class CqParaboloid : public CqQuadric
299
CqParaboloid( TqFloat rmax = 1.0f, TqFloat zmin = -1.0f, TqFloat zmax = 1.0f, TqFloat thetamin = 0.0f, TqFloat thetamax = 360.0f );
300
CqParaboloid( const CqParaboloid& From )
304
virtual ~CqParaboloid()
307
virtual CqBound Bound() const;
309
virtual CqVector3D DicePoint( TqInt u, TqInt v );
310
virtual CqVector3D DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
312
virtual TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
314
CqParaboloid& operator=( const CqParaboloid& From );
317
CqString className() const { return CqString("CqParaboloid"); }
321
TqFloat m_RMax; ///< Radius at zmax.
322
TqFloat m_ZMin; ///< Min value on z axis.
323
TqFloat m_ZMax; ///< Max value on z axis.
324
TqFloat m_ThetaMin; ///< Min angle about z axis.
325
TqFloat m_ThetaMax; ///< Max angle about z axis.
330
//----------------------------------------------------------------------
332
* Torus quadric GPrim.
335
class CqTorus : public CqQuadric
338
CqTorus( TqFloat majorradius = 1.0f, TqFloat minorradius = 0.2f, TqFloat phimin = 0.0f, TqFloat phimax = 360.0f, TqFloat thetamin = 0.0f, TqFloat thetamax = 360.0f );
339
CqTorus( const CqTorus& From )
346
virtual CqBound Bound() const;
348
virtual CqVector3D DicePoint( TqInt u, TqInt v );
349
virtual CqVector3D DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
351
virtual TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
353
CqTorus& operator=( const CqTorus& From );
356
CqString className() const { return CqString("CqTorus"); }
360
TqFloat m_MajorRadius; ///< Major radius.
361
TqFloat m_MinorRadius; ///< Minor radius.
362
TqFloat m_PhiMin; ///< Min angle about ring.
363
TqFloat m_PhiMax; ///< Max angle about ring.
364
TqFloat m_ThetaMin; ///< Min andle about z axis.
365
TqFloat m_ThetaMax; ///< Max angle about z axis.
370
//----------------------------------------------------------------------
372
* Disk quadric primitive.
375
class CqDisk : public CqQuadric
378
CqDisk( TqFloat height = 0.0f, TqFloat minorradius = 0.0f, TqFloat majorradius = 1.0f, TqFloat thetamin = 0.0f, TqFloat thetamax = 360.0f );
379
CqDisk( const CqDisk& From )
386
virtual CqBound Bound() const;
388
virtual CqVector3D DicePoint( TqInt u, TqInt v );
389
virtual CqVector3D DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
390
virtual TqBool CanGenerateNormals() const
395
virtual TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
397
CqDisk& operator=( const CqDisk& From );
400
CqString className() const { return CqString("CqDisk"); }
404
TqFloat m_Height; ///< Position on z axis.
405
TqFloat m_MajorRadius; ///< Outer radius of disk.
406
TqFloat m_MinorRadius; ///< Inner radius of disk.
407
TqFloat m_ThetaMin; ///< Min angle about z axis.
408
TqFloat m_ThetaMax; ///< Max angle about z axis.
413
//-----------------------------------------------------------------------
415
END_NAMESPACE( Aqsis )
417
#endif // !QUADRICS_H_INCLUDED