include/bezier.h

Go to the documentation of this file.
00001 /*
00002  *  This program is free software; you can redistribute it and/or modify
00003  *  it under the terms of the GNU General Public License as published by
00004  *  the Free Software Foundation; either version 2 of the License, or
00005  *  (at your option) any later version.
00006  *
00007  *  This program is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  *  GNU Library General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU General Public License
00013  *  along with this program; if not, write to the Free Software
00014  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00015  */
00016 
00017 #ifndef _BEZIER_H
00018 
00019 #include <iostream>
00020 #include <fstream>
00021 //#include "settings.h"
00022 #include "utility.h"
00023 #include "quat.h"
00024 
00025 #include "globals.h"
00026 
00027 #define COLLISION_DIVS 1
00028 
00029 #define COLLISION_QUAD_DIVS 8
00030 #define QUAD_DIV_FAST_DISCARD true
00031 
00032 #define SURFDRAW_VIS 2
00033 
00034 #define INTERSECT_FUNCTION utility.IntersectTriangleF
00035 #define INTERSECT_QUAD_FUNCTION utility.IntersectQuadrilateralF
00036 
00037 using namespace std;
00038 
00039 class BEZIER
00040 {
00041 private:
00042         void DrawSurf(int div, float trans);
00043         void DrawControlPoints();
00044         VERTEX Bernstein(float u, VERTEX *p);
00045         VERTEX BernsteinTangent(float u, VERTEX *p);
00046         VERTEX SurfCoord(float px, float py);
00047         VERTEX SurfNorm(float px, float py);
00048 
00049 public:
00050         BEZIER();
00051         ~BEZIER();
00052         void SetFromCorners(VERTEX fl, VERTEX fr, VERTEX bl, VERTEX br);
00053         void Visualize(bool wireframe, bool fill, VERTEX color);
00054         void Attach(BEZIER & other);
00055 
00056         int NumTris(int divs) {return divs*divs*2;}
00057         void GetTri(int divs, int num, VERTEX outtri[3]);
00058         
00059         bool CollideSubDiv(VERTEX origin, VERTEX direction, VERTEX &outtri);
00060         bool CollideNewton(VERTEX origin, VERTEX direction, VERTEX &outtri);
00061         bool CollideSingleQuad(VERTEX origin, VERTEX direction, VERTEX &outtri);
00062         bool CollideSubDivQuad(VERTEX origin, VERTEX direction, VERTEX &outtri);
00063         bool CollideSubDivQuadSimple(VERTEX origin, VERTEX direction, VERTEX &outtri);
00064         bool CollideSubDivQuadSimpleNorm(VERTEX origin, VERTEX direction, VERTEX &outtri, VERTEX & normal);
00065         bool CollideQuadNewton(VERTEX origin, VERTEX direction, VERTEX &outtri);
00066         
00067         void CopyFrom(BEZIER &other);
00068         
00069         bool ReadFrom(ifstream &openfile);
00070         bool WriteTo(ofstream &openfile);
00071 
00072         VERTEX points[4][4];
00073         VERTEX center;
00074         float radius;
00075 };
00076 
00077 #define _BEZIER_H
00078 #endif

Generated on Thu Oct 19 04:05:47 2006 by  doxygen 1.4.6