Drawing Bezier Curves
Code
orxVECTOR drawPoint1 = orxVECTOR_0;
orxVECTOR drawPoint2 = orxVECTOR_0;
orxFLOAT steps = 0.01;
orxRGBA lineColour;
lineColour.u8R = 255;
lineColour.u8G = 128;
lineColour.u8B = 90;
lineColour.u8A = 255;
...
orxSTATUS orxFASTCALL RenderEventHandler(const orxEVENT *_pstEvent) {
if (_pstEvent->eType == orxEVENT_TYPE_RENDER){
if(_pstEvent->eID == orxRENDER_EVENT_STOP){
orxVECTOR drawPoint = orxVECTOR_0;
orxVECTOR point1 = {10, 10, 0};
orxVECTOR controlPoint1 = {0, 100, 0};
orxVECTOR controlPoint2 = {150, -150, 0};
orxVECTOR point2 = {150, 100, 0};
for (float x=0; x<1; x+=steps){
if (x+steps <= 1){
orxVector_Bezier (&drawPoint,
&p1,
&cp1,
&cp2,
&p2,
x
);
const orxVECTOR vv = drawPoint1;
if (orxVector_AreEqual(&vv, orxVECTOR_0) == orxTRUE){
drawPoint.fZ = 0;
drawPoint1 = drawPoint;
}
drawPoint.fZ = 0;
drawPoint2 = drawPoint;
orxDisplay_DrawLine ( &drawPoint1, &drawPoint2, lineColour);
}
}
}
return orxSTATUS_SUCCESS;
}
orxSTATUS orxFASTCALL Init()
{
...
orxEvent_AddHandler(orxEVENT_TYPE_RENDER, RenderEventHandler);
...