1
// DRGNURBSSurface.h: interface for the CDRGNURBSSurface class.
2
// ------------------------------------------------------------------------------------
3
// Copyright � 1999 Intel Corporation
6
// Permission is granted to use, copy, distribute and prepare derivative works of this
7
// software for any purpose and without fee, provided, that the above copyright notice
8
// and this statement appear in all copies. Intel makes no representations about the
9
// suitability of this software for any purpose. This software is provided "AS IS."
11
// Intel specifically disclaims all warranties, express or implied, and all liability,
12
// including consequential and other indirect damages, for the use of this software,
13
// including liability for infringement of any proprietary rights, and including the
14
// warranties of merchantability and fitness for a particular purpose. Intel does not
15
// assume any responsibility for any errors which may appear in this software nor any
16
// responsibility to update it.
17
// ------------------------------------------------------------------------------------
21
// Declaration of the CDRGNURBSSurface class for rendering NURBS surfaces.
22
// Accompanies the article "Rendering NURBS Surfaces in Real-Time". Please refer
23
// to the article for an understanding of the methods in this class.
24
// ------------------------------------------------------------------------------------
26
// Author: Dean Macri - Intel Developer Relations Divison -- Tools and Technology Group
28
////////////////////////////////////////////////////////////////////////////////////////
30
// Yoinked from http://www.gamasutra.com/features/19991117/macri_pfv.htm
31
// Hacked into an unholy mess for use with OGRE by Chris "Antiarc" Heald (antiarc@captionthis.com)
34
////////////////////////////////////////////////////////////////////////////////////////
37
#if !defined(AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_)
38
#define AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_
46
#define ALIGNED_NEW(s, t) new t[s];
47
#define ALIGNED_DELETE(x) do { if((x)) { delete x; x = NULL; } } while (0)
48
#define SAFE_RELEASE(x) do { if((x)) { x->Release(); x = NULL; } } while (0)
49
#define SAFE_DELETE(x) do { if((x)) { delete x; x = NULL;} } while (0)
51
// Some handy-dandy macros
53
#define CLAMP_UPPER(x) if (x>1.0f) { x = 1.0f; }
54
#define CLAMP_LOWER(x) if (x<0.0f) { x = 0.0f; }
71
class CDRGNURBSSurface
74
Point4D* m_pControlPoints;
75
float* m_UBasisCoefficients;
76
float* m_VBasisCoefficients;
88
int m_iUDegree, m_iVDegree;
89
int m_iUOrder, m_iVOrder;
90
int m_iUKnots, m_iVKnots;
91
int m_iUControlPoints, m_iVControlPoints;
93
int m_iUBasisSpans, m_iVBasisSpans;
95
int m_iUTessellations, m_iVTessellations;
97
splinePoint* m_pVertices;
100
float ComputeCoefficient(float* fKnots, int iInterval, int i, int p, int k);
101
void ComputeBasisCoefficients(void);
102
void EvaluateBasisFunctions(void);
105
CDRGNURBSSurface(void);
106
virtual ~CDRGNURBSSurface(void);
108
bool Init(int uDegree, int vDegree, int uControlPoints, int vControlPoints,
109
Point4D* pControlPoints, float* pUKnots, float* pVKnots,
110
int iDefaultUTessellations = 10, int iDefaultVTessellations = 10);
112
void UpdateControlPoints(Point4D* pControlPoints);
114
splinePoint getData(int index);
115
virtual void SetTessellations(int iUTessellations, int iVTessellations);
116
virtual void TessellateSurface(void);
117
virtual int GetTriangleCount(void);
121
#endif // !defined(AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_)