Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Движение луча света по поверхности Безье / bezier / Curves
.h/*
This is the header file for the CCubicCurve
and CCubicPatch classes.
Author: Thomas Mшlhave (thoooms)
check http://home10.inet.tele.dk/moelhave for more info
*/
#ifndef CURVES_H__
#define CURVES_H__
#include "matrix.h"
#define TM_NOTHING 0
#define TM_BEZIER 1
#define TM_HERMITE 2
#define TM_S_EVALS 1
#define TM_CURVE_EVALS 2
typedef struct Point
{
float x,y,z;
} Point;
typedef struct Triangle
{
Point verts[3];
} Triangle;
class CCubicCurve
{
private:
int type;
Matrix4x1 Gx; //geometry matrix
Matrix4x1 Gy; // ----- "" -----
Matrix4x1 Gz; // ----- "" -----
float color[4]; //color
int steps; //number of steps used to draw curve
float coef[12];
public:
CCubicCurve();
~CCubicCurve();
void Draw();
void DrawControlPoints();
void GenerateBezierCoefficients(Matrix4x1 p1, Matrix4x1 p2, Matrix4x1 p3, Matrix4x1 p4);
void GenerateBezierCoefficients(Point _p1, Point _p2, Point _p3, Point _p4);
void GenerateHermiteCoefficients(Matrix4x1 _p1, Matrix4x1 _p2, Matrix4x1 r1, Matrix4x1 r2);
void SubdivideBezierCurve(CCubicCurve* L, CCubicCurve* R);
void SetGeometryMatrixGx(Matrix4x1 a);
void SetGeometryMatrixGy(Matrix4x1 a);
void SetGeometryMatrixGz(Matrix4x1 a);
void RecalculateBezier();
Point GetPoint(float t);
void SetColor(float r,float g, float b, float a);
};
class CCubicPatch
{
private:
CCubicCurve Curve[8]; //the coefficients of the four curves
unsigned int s_evals;
unsigned int curve_evals;
Point ControlPoints[16];
bool recompute;
bool calc_normals; //normals calculated
Triangle *tris; //stores all triangles
Point *normals; //stores all normals, one for each triangle
public:
~CCubicPatch();
CCubicPatch();
void ToggleNormals(); //toggles normal calculation on or off
void GeneratePatch(Point* p);
void ChangeEval(int eval, int factor);
void Draw();
};
#endif CURVES_H__
Соседние файлы в папке bezier