# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

bezier_patch.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_BEZIER_PATCH_H
00027 #define NL_BEZIER_PATCH_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/vector.h"
00031 #include "nel/misc/vectord.h"
00032 #include "nel/misc/matrix.h"
00033 
00034 
00035 namespace NL3D 
00036 {
00037 
00038 
00039 using NLMISC::CVector;
00040 using NLMISC::CVectorD;
00041 using NLMISC::CMatrix;
00042 
00043 
00044 // ***************************************************************************
00073 class CBezierPatch
00074 {
00075 public:
00077         CVector         Vertices[4];            
00079         CVector         Tangents[8];            
00081         CVector         Interiors[4];           
00082 
00083 
00084 public:
00086         CBezierPatch() {}
00087 
00089         void            make(CVector vertices[4], CVector       normals[4]);
00091         void            makeInteriors();
00093         void            applyMatrix(const CMatrix &m);
00094 
00096         CVector         eval(float s, float t) const;                   // s,t coordinates for quad.
00098         CVectorD        evalDouble(double s, double t) const;   // s,t coordinates for quad.
00100         CVector         evalNormal(float s, float t) const;             // s,t coordinates for quad.
00102         CVector         evalTangentS(float s, float t) const;   // s,t coordinates for quad.
00104         CVector         evalTangentT(float s, float t) const;   // s,t coordinates for quad.
00105 
00106 
00108         // @{
00112         void            subdivideS(CBezierPatch &left, CBezierPatch &right, float s=0.5f) const;
00116         void            subdivideT(CBezierPatch &top, CBezierPatch &bottom, float t=0.5f) const;
00117         // @}
00118 
00119 
00120 // **********************************
00121 private:
00122         struct  CBezierCurve
00123         {
00124                 CVector P0, P1, P2, P3;
00125                 void    subdivide(CBezierCurve &left, CBezierCurve &right, float t);
00126                 void    set(const CVector &a, const CVector &b, const CVector &c, const CVector &d)
00127                 {
00128                         P0= a; P1= b; P2= c; P3= d;
00129                 }
00130                 void    get(CVector &a, CVector &b, CVector &c, CVector &d)
00131                 {
00132                         a= P0; b= P1; c= P2; d= P3;
00133                 }
00134         };
00135 
00136 };
00137 
00138 
00139 
00140 } // NL3D
00141 
00142 
00143 #endif // NL_BEZIER_PATCH_H
00144 
00145 /* End of bezier_patch.h */