JSpline Class Reference

#include <JSpline.h>

List of all members.

Public Member Functions

 JSpline ()
bool Load (const char *filename, float xscale=1.0f, float yscale=1.0f)
void AddControlPoint (const Point &pt)
void GetControlPoint (Point &point, int index)
void GeneratePixels ()
void PointOnCurve (Point &out, float t, const Point &p0, const Point &p1, const Point &p2, const Point &p3)
int GetPixelCount ()
void GetPixel (Point &point, int index)
void Render (float x, float y, PIXEL_TYPE color=ARGB(255, 255, 255, 255), PIXEL_TYPE controlColor=ARGB(192, 0, 192, 0))


Detailed Description

Catmull Rom spline.

Constructor & Destructor Documentation

JSpline::JSpline (  ) 

Constructor.


Member Function Documentation

bool JSpline::Load ( const char *  filename,
float  xscale = 1.0f,
float  yscale = 1.0f 
)

Load spline from a file.

Here is a sample spline definition file:

 <?xml version="1.0" standalone="no" ?>
 <path>
 <contro_point x="89" y="270" />
 <contro_point x="113" y="154" />
 <contro_point x="227" y="94" />
 <contro_point x="347" y="154" />
 <contro_point x="367" y="278" />
 </path>

Parameters:
filename - Name of spline definition file.
xscale - Scaling factor for X of all control points.
yscale - Scaling factor for Y of all control points.
Returns:
True if loaded.

void JSpline::AddControlPoint ( const Point pt  ) 

Add a control point to the spline.

Parameters:
pt - Control point.

void JSpline::GetControlPoint ( Point point,
int  index 
)

Get a control point of the spline.

Parameters:
index - Control point index.
Returns:
Control point.

void JSpline::GeneratePixels (  ) 

Work out all pixels of the spline.

Note:
Have to call this function before calling GetPixel, GetPixelCount and Render.

void JSpline::PointOnCurve ( Point out,
float  t,
const Point p0,
const Point p1,
const Point p2,
const Point p3 
)

Get a point between 2nd and 3rd control point.

Parameters:
t - Fraction of the curve between 2nd and 3rd control point. (0.0f ~ 1.0f)
p0 - 1st control point.
p1 - 2nd control point.
p2 - 3rd control point.
p3 - 4th control point.
Returns:
Position of the desire point.

int JSpline::GetPixelCount (  ) 

Get a number of pixels for this spline.

Returns:
Number of pixels for this spline.

void JSpline::GetPixel ( Point point,
int  index 
)

Get a pixel on the spline.

Parameters:
index - Pixel index.
Returns:
Position of the desire point.

void JSpline::Render ( float  x,
float  y,
PIXEL_TYPE  color = ARGB(255, 255, 255, 255),
PIXEL_TYPE  controlColor = ARGB(192, 0, 192, 0) 
)

Render the spline to screen.


Generated on Mon Oct 22 00:28:23 2007 for JGE++ by  doxygen 1.5.3