~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/components/ogre/SceneManagers/EmberPagingSceneManager/include/DRGNURBSSurface.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
Import upstream version 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// DRGNURBSSurface.h: interface for the CDRGNURBSSurface class.
 
2
// ------------------------------------------------------------------------------------
 
3
// Copyright � 1999 Intel Corporation
 
4
// All Rights Reserved
 
5
// 
 
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." 
 
10
//
 
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
// ------------------------------------------------------------------------------------
 
18
//
 
19
// PURPOSE:
 
20
//    
 
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
// ------------------------------------------------------------------------------------
 
25
//
 
26
// Author: Dean Macri - Intel Developer Relations Divison -- Tools and Technology Group
 
27
//
 
28
////////////////////////////////////////////////////////////////////////////////////////
 
29
//
 
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)
 
32
// Date: 11/9/2003
 
33
//
 
34
////////////////////////////////////////////////////////////////////////////////////////
 
35
 
 
36
 
 
37
#if !defined(AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_)
 
38
#define AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_
 
39
 
 
40
#if _MSC_VER > 1000
 
41
#pragma once
 
42
#endif
 
43
 
 
44
#define SIMD_SIZE 1
 
45
 
 
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)
 
50
 
 
51
// Some handy-dandy macros
 
52
//
 
53
#define CLAMP_UPPER(x) if (x>1.0f) { x = 1.0f; }
 
54
#define CLAMP_LOWER(x) if (x<0.0f) { x = 0.0f; }
 
55
 
 
56
struct Point4D
 
57
{
 
58
        float x;
 
59
        float y;
 
60
        float z;
 
61
        float w;
 
62
};
 
63
 
 
64
struct splinePoint
 
65
{
 
66
        float x;
 
67
        float y;
 
68
        float z;
 
69
};
 
70
 
 
71
class CDRGNURBSSurface
 
72
{
 
73
private:
 
74
        Point4D* m_pControlPoints;
 
75
        float* m_UBasisCoefficients;
 
76
        float* m_VBasisCoefficients;
 
77
        float* m_UKnots;
 
78
        float* m_VKnots;
 
79
        float* m_UBasis;
 
80
        float* m_dUBasis;
 
81
        float* m_VBasis;
 
82
        float* m_dVBasis;
 
83
        Point4D* m_UTemp;
 
84
        Point4D* m_dUTemp;
 
85
        int* m_TessUKnotSpan;
 
86
        int* m_TessVKnotSpan;
 
87
 
 
88
        int m_iUDegree, m_iVDegree;
 
89
        int m_iUOrder, m_iVOrder;
 
90
        int m_iUKnots, m_iVKnots;
 
91
        int m_iUControlPoints, m_iVControlPoints;
 
92
 
 
93
        int m_iUBasisSpans, m_iVBasisSpans;
 
94
 
 
95
        int m_iUTessellations, m_iVTessellations;
 
96
 
 
97
        splinePoint* m_pVertices;
 
98
 
 
99
        void Cleanup(void);
 
100
        float ComputeCoefficient(float* fKnots, int iInterval, int i, int p, int k);
 
101
        void ComputeBasisCoefficients(void);
 
102
        void EvaluateBasisFunctions(void);
 
103
 
 
104
public:
 
105
        CDRGNURBSSurface(void);
 
106
        virtual ~CDRGNURBSSurface(void);
 
107
 
 
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);
 
111
                                
 
112
        void UpdateControlPoints(Point4D* pControlPoints);
 
113
 
 
114
        splinePoint getData(int index);
 
115
        virtual void SetTessellations(int iUTessellations, int iVTessellations);
 
116
        virtual void TessellateSurface(void);
 
117
        virtual int GetTriangleCount(void);
 
118
 
 
119
};
 
120
 
 
121
#endif // !defined(AFX_DRGNURBSSURFACE_H__0D6D594B_6F3B_11D3_BE36_00902752C5DF__INCLUDED_)