~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to render/quadrics.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Aqsis
 
2
// Copyright ļæ½ 1997 - 2001, Paul C. Gregory
 
3
//
 
4
// Contact: pgregory@aqsis.com
 
5
//
 
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.
 
10
//
 
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.
 
15
//
 
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
 
19
 
 
20
 
 
21
/** \file
 
22
                \brief Declares the standard RenderMan quadric primitive classes.
 
23
                \author Paul C. Gregory (pgregory@aqsis.com)
 
24
*/
 
25
 
 
26
//? Is .h included already?
 
27
#ifndef QUADRICS_H_INCLUDED
 
28
#define QUADRICS_H_INCLUDED 1
 
29
 
 
30
#include        "aqsis.h"
 
31
 
 
32
#include        "surface.h"
 
33
#include        "micropolygon.h"
 
34
 
 
35
START_NAMESPACE( Aqsis )
 
36
 
 
37
 
 
38
#define ESTIMATEGRIDSIZE    8
 
39
 
 
40
//----------------------------------------------------------------------
 
41
/** \class CqQuadric
 
42
 * Abstract base class from which all quadric primitives are defined.
 
43
 */
 
44
 
 
45
class CqQuadric : public CqSurface
 
46
{
 
47
public:
 
48
 
 
49
    CqQuadric();
 
50
    virtual     ~CqQuadric()
 
51
    {}
 
52
 
 
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.
 
56
     */
 
57
    virtual     TqUint  cUniform() const
 
58
    {
 
59
        return ( 1 );
 
60
    }
 
61
    virtual     TqUint  cVarying() const
 
62
    {
 
63
        return ( 4 );
 
64
    }
 
65
    virtual     TqUint  cVertex() const
 
66
    {
 
67
        return ( 4 );
 
68
    }
 
69
    virtual     TqUint  cFaceVarying() const
 
70
    {
 
71
        /// \todo Must work out what this value should be.
 
72
        return ( 1 );
 
73
    }
 
74
 
 
75
 
 
76
    // Overrides from CqSurface
 
77
    virtual TqBool      Diceable();
 
78
 
 
79
    /** Determine whether the passed surface is valid to be used as a
 
80
     *  frame in motion blur for this surface.
 
81
     */
 
82
    virtual TqBool      IsMotionBlurMatch( CqBasicSurface* pSurf )
 
83
    {
 
84
        return( TqFalse );
 
85
    }
 
86
 
 
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;
 
90
 
 
91
    virtual TqInt       DiceAll( CqMicroPolyGrid* pGrid );
 
92
 
 
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.
 
97
     */
 
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.
 
104
     */
 
105
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v, CqVector3D& Normal ) = 0;
 
106
 
 
107
    CqQuadric&  operator=( const CqQuadric& From );
 
108
 
 
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 );
 
112
 
 
113
#ifdef _DEBUG
 
114
    CqString className() const { return CqString("CqQuadric"); }
 
115
#endif
 
116
 
 
117
protected:
 
118
    CqMatrix    m_matTx;                ///< Transformation matrix from object to camera.
 
119
    CqMatrix    m_matITTx;              ///< Inverse transpose transformation matrix, for transforming normals.
 
120
 
 
121
}
 
122
;
 
123
 
 
124
 
 
125
 
 
126
//----------------------------------------------------------------------
 
127
/** \class CqSphere
 
128
 * Sphere quadric GPrim.
 
129
 */
 
130
 
 
131
class CqSphere : public CqQuadric
 
132
{
 
133
public:
 
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 )
 
136
    {
 
137
        *this = From;
 
138
    }
 
139
    virtual     ~CqSphere()
 
140
    {}
 
141
 
 
142
    virtual     CqBound Bound() const;
 
143
 
 
144
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v );
 
145
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
 
146
    virtual TqBool      CanGenerateNormals() const
 
147
    {
 
148
        return ( TqTrue );
 
149
    }
 
150
 
 
151
    virtual     TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
 
152
 
 
153
    CqSphere&   operator=( const CqSphere& From );
 
154
 
 
155
#ifdef _DEBUG
 
156
    CqString className() const { return CqString("CqSphere"); }
 
157
#endif
 
158
 
 
159
private:
 
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.
 
165
}
 
166
;
 
167
 
 
168
 
 
169
//----------------------------------------------------------------------
 
170
/** \class CqCone
 
171
 * Cone quadric GPrim.
 
172
 */
 
173
 
 
174
class CqCone : public CqQuadric
 
175
{
 
176
public:
 
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 )
 
179
    {
 
180
        *this = From;
 
181
    }
 
182
    virtual     ~CqCone()
 
183
    {}
 
184
 
 
185
    virtual     CqBound Bound() const;
 
186
 
 
187
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v );
 
188
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
 
189
 
 
190
    virtual     TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
 
191
 
 
192
    CqCone&     operator=( const CqCone& From );
 
193
 
 
194
#ifdef _DEBUG
 
195
    CqString className() const { return CqString("CqCone"); }
 
196
#endif
 
197
 
 
198
private:
 
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.
 
205
}
 
206
;
 
207
 
 
208
 
 
209
//----------------------------------------------------------------------
 
210
/** \class CqCylinder
 
211
 * Cylinder quadric GPrim.
 
212
 */
 
213
 
 
214
class CqCylinder : public CqQuadric
 
215
{
 
216
public:
 
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 )
 
219
    {
 
220
        *this = From;
 
221
    }
 
222
    virtual     ~CqCylinder()
 
223
    {}
 
224
 
 
225
    virtual     CqBound Bound() const;
 
226
 
 
227
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v );
 
228
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
 
229
    virtual TqBool      CanGenerateNormals() const
 
230
    {
 
231
        return ( TqTrue );
 
232
    }
 
233
 
 
234
    virtual     TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
 
235
 
 
236
    CqCylinder& operator=( const CqCylinder& From );
 
237
 
 
238
#ifdef _DEBUG
 
239
    CqString className() const { return CqString("CqCylinder"); }
 
240
#endif
 
241
 
 
242
private:
 
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.
 
248
}
 
249
;
 
250
 
 
251
 
 
252
//----------------------------------------------------------------------
 
253
/** \class CqHyperboloid
 
254
 * Hyperboloid quadric GPrim.
 
255
 */
 
256
 
 
257
class CqHyperboloid : public CqQuadric
 
258
{
 
259
public:
 
260
    CqHyperboloid( );
 
261
    CqHyperboloid( CqVector3D& point1, CqVector3D& point2, TqFloat thetamin, TqFloat thetamax );
 
262
    CqHyperboloid( const CqHyperboloid& From )
 
263
    {
 
264
        *this = From;
 
265
    }
 
266
    virtual     ~CqHyperboloid()
 
267
    {}
 
268
 
 
269
    virtual     CqBound Bound() const;
 
270
 
 
271
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v );
 
272
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
 
273
 
 
274
    virtual     TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
 
275
 
 
276
    CqHyperboloid&      operator=( const CqHyperboloid& From );
 
277
 
 
278
#ifdef _DEBUG
 
279
    CqString className() const { return CqString("CqHyperboloid"); }
 
280
#endif
 
281
 
 
282
private:
 
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.
 
287
}
 
288
;
 
289
 
 
290
 
 
291
//----------------------------------------------------------------------
 
292
/** \class CqParaboloid
 
293
 * Paraboloid quadric GPrim.
 
294
 */
 
295
 
 
296
class CqParaboloid : public CqQuadric
 
297
{
 
298
public:
 
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 )
 
301
    {
 
302
        *this = From;
 
303
    }
 
304
    virtual     ~CqParaboloid()
 
305
    {}
 
306
 
 
307
    virtual     CqBound Bound() const;
 
308
 
 
309
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v );
 
310
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
 
311
 
 
312
    virtual     TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
 
313
 
 
314
    CqParaboloid&       operator=( const CqParaboloid& From );
 
315
 
 
316
#ifdef _DEBUG
 
317
    CqString className() const { return CqString("CqParaboloid"); }
 
318
#endif
 
319
 
 
320
private:
 
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.
 
326
}
 
327
;
 
328
 
 
329
 
 
330
//----------------------------------------------------------------------
 
331
/** \class CqTorus
 
332
 * Torus quadric GPrim.
 
333
 */
 
334
 
 
335
class CqTorus : public CqQuadric
 
336
{
 
337
public:
 
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 )
 
340
    {
 
341
        *this = From;
 
342
    }
 
343
    virtual     ~CqTorus()
 
344
    {}
 
345
 
 
346
    virtual     CqBound Bound() const;
 
347
 
 
348
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v );
 
349
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
 
350
 
 
351
    virtual     TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
 
352
 
 
353
    CqTorus&    operator=( const CqTorus& From );
 
354
 
 
355
#ifdef _DEBUG
 
356
    CqString className() const { return CqString("CqTorus"); }
 
357
#endif
 
358
 
 
359
private:
 
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.
 
366
}
 
367
;
 
368
 
 
369
 
 
370
//----------------------------------------------------------------------
 
371
/** \class CqDisk
 
372
 * Disk quadric primitive.
 
373
 */
 
374
 
 
375
class CqDisk : public CqQuadric
 
376
{
 
377
public:
 
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 )
 
380
    {
 
381
        *this = From;
 
382
    }
 
383
    virtual     ~CqDisk()
 
384
    {}
 
385
 
 
386
    virtual     CqBound Bound() const;
 
387
 
 
388
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v );
 
389
    virtual     CqVector3D      DicePoint( TqInt u, TqInt v, CqVector3D& Normal );
 
390
    virtual TqBool      CanGenerateNormals() const
 
391
    {
 
392
        return ( TqTrue );
 
393
    }
 
394
 
 
395
    virtual     TqInt PreSubdivide( std::vector<boost::shared_ptr<CqBasicSurface> >& aSplits, TqBool u );
 
396
 
 
397
    CqDisk&     operator=( const CqDisk& From );
 
398
 
 
399
#ifdef _DEBUG
 
400
    CqString className() const { return CqString("CqDisk"); }
 
401
#endif
 
402
 
 
403
private:
 
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.
 
409
}
 
410
;
 
411
 
 
412
 
 
413
//-----------------------------------------------------------------------
 
414
 
 
415
END_NAMESPACE( Aqsis )
 
416
 
 
417
#endif  // !QUADRICS_H_INCLUDED