Advertisement

Bezier Curves,Help

Started by November 16, 2004 02:24 AM
-1 comments, last by dawidjoubert 20 years ago
hi could sum1 help figure out how to do this bezier stuff?
[SOURCE]
int	GetID(int	x,	int y,int	RowSize)
{
	return x + (y * RowSize);
};

void CBSPWorld::CreateBezier(int index)
{

	// Grab Bezier
	CBezier *b = &bezier[index];

	{
		// First we find the Detail we want Per Row of Y
		b->ThisDetail = int(CurveDetail * (b->Size[0]));
		// Now We Generate Verts using X(Detail Points on X) * Rows(On y)
		b->Point = new CVertex[b->ThisDetail * b->Size[1]];

		for (int y = 0;y	<  b->Size[1];	y++)
			for(int x = 0;x  <  b->ThisDetail;	x++)
			{
				// Get the Starting Vert in World.Verts array
				int start = b->startIndex + GetID(0,y,b->ThisDetail);

				// Get the current vPoly on the curve, depending on the time.
				b->Point[GetID(x,y,b->ThisDetail)] = PointOnCurve(start,b->ThisDetail,x/(b->ThisDetail));
			};
		// All Verts Should be generated by now!
	};

};

void CBSPWorld::RenderBezier(int FaceIndex)
{
	// Get Bezier ID
	int i = bezierLookUp[FaceIndex];

	// Grab Bezier
	CBezier *b = &bezier;
	{
		// Now We Need To Do The Creation of the Triangles/Quads(Quads Are Easier
		glBegin(GL_QUADS);
		for (int y = 0;y	<	b->Size[1]-1;y++)
			for (int x=0;x	<	b->ThisDetail-1;x++)
			{
				RenderVertex(b->Point[GetID(x,y,b->ThisDetail)]);
				RenderVertex(b->Point[GetID(x+1,y,b->ThisDetail)]);
				RenderVertex(b->Point[GetID(x+1,y+1,b->ThisDetail)]);
				RenderVertex(b->Point[GetID(x,y+1,b->ThisDetail)]);
			};
		glEnd();
	};
	return;
	
};


[/SOURCE]
It doesnt crash but it doesnt draw anything either
----------------------------

http://djoubert.co.uk

This topic is closed to new replies.

Advertisement