Скачиваний:
25
Добавлен:
01.05.2014
Размер:
1.93 Кб
Скачать
/*
	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
  • #
    01.05.20145.02 Кб25CubicCurves.dsp
  • #
    01.05.2014547 б25CubicCurves.dsw
  • #
    01.05.201441.98 Кб25CubicCurves.ncb
  • #
    01.05.201448.64 Кб26CubicCurves.opt
  • #
    01.05.201414.38 Кб26Curves.cpp
  • #
    01.05.20141.93 Кб25Curves.h
  • #
    01.05.20147.76 Кб25main.cpp
  • #
    01.05.20143.38 Кб25main.dsp
  • #
    01.05.2014533 б25main.dsw
  • #
    01.05.201450.18 Кб25main.ncb
  • #
    01.05.201448.64 Кб25main.opt