27     init(points, controlPoints);
 
   44     assert(points.size() > 1);
 
   51     _controls.resize(2 * (points.size() - 1));
 
   55     for (i = 0; i < 
_points.size(); ++i)
 
   60     if (controlPoints.empty())
 
   62         if (points.size() > 2)
 
   65             for (i = 0; i < 
_points.size() - 1; ++i)
 
   86         for (i = 0; i < 2 * (
_points.size() - 1); ++i)
 
  169 #ifndef APP_USES_GLES 
  198                             (
SLuint)numTangentPoints);
 
  220     else if (t >= 
_points.back().w)
 
  225     for (i = 0; i < 
_points.size() - 1; ++i)
 
  231     SLfloat u  = (t - t0) / (t1 - t0);
 
  244     return _points[i].vec3() + u * (C + u * (B + u * A));
 
  259     else if (t >= 
_points.back().w)
 
  264     for (i = 0; i < 
_points.size() - 1; ++i)
 
  270     SLfloat u  = (t - t0) / (t1 - t0);
 
  283     return C + u * (B + 3.0f * u * A);
 
  297     else if (t >= 
_points.back().w)
 
  302     for (i = 0; i < 
_points.size() - 1; ++i)
 
  303         if (t < 
_points[i + 1].w) 
break;
 
  307     SLfloat u  = (t - t0) / (t1 - t0);
 
  318     return B + 6.0f * u * A;
 
  333     for (
SLuint i = 0; i < 32; ++i)
 
  354     if (t2 <= t1) 
return 0.0f;
 
  360     for (seg1 = 0; seg1 < 
_points.size() - 1; ++seg1)
 
  368     for (seg2 = 0; seg2 < 
_points.size() - 1; ++seg2)
 
  383         for (
SLuint i = seg1 + 1; i < seg2; ++i)
 
  397     assert(i >= 0 && i < 
_points.size() - 1);
 
  399     if (u2 <= u1) 
return 0.0f;
 
  400     if (u1 < 0.0f) u1 = 0.0f;
 
  401     if (u2 > 1.0f) u2 = 1.0f;
 
  410     SLfloat minus_u2 = (1.0f - u2);
 
  411     SLVec3f L1       = minus_u2 * P0 + u2 * P1;
 
  412     SLVec3f H        = minus_u2 * P1 + u2 * P2;
 
  413     SLVec3f L2       = minus_u2 * L1 + u2 * H;
 
  414     SLVec3f L3       = minus_u2 * L2 + u2 * (minus_u2 * H + u2 * (minus_u2 * P2 + u2 * P3));
 
  417     SLfloat minus_u1 = (1.0f - u1);
 
  418     H                = minus_u1 * L1 + u1 * L2;
 
  420     SLVec3f R2       = minus_u1 * L2 + u1 * L3;
 
  421     SLVec3f R1       = minus_u1 * H + u1 * R2;
 
  422     SLVec3f R0       = minus_u1 * (minus_u1 * (minus_u1 * P0 + u1 * L1) + u1 * H) + u1 * R1;
 
  442     if (diff * diff < 1.0e-3f)
 
  443         return 0.5f * (Lmin + Lmax);
 
  451     SLVec3f mid = (L2 + R1) * 0.5f;
 
  470     if (renderPoints.empty())
 
  471         renderPoints.push_back(wm.
multVec(P0));
 
  472     else if (P0 != renderPoints.back())
 
  473         renderPoints.push_back(wm.
multVec(P0));
 
  479     if (diff * diff < epsilon) 
return;
 
  487     SLVec3f mid = (L2 + R1) * 0.5f;
 
Singleton class for global render state.
 
vector< SLVec3f > SLVVec3f
 
vector< SLVec4f > SLVVec4f
 
SLVec4< SLfloat > SLVec4f
 
void subdivideRender(SLVVec3f &points, const SLMat4f &wm, SLfloat epsilon, const SLVec3f &P0, const SLVec3f &P1, const SLVec3f &P2, const SLVec3f &P3)
 
SLVVec3f _controls
Control points of Bezier curve.
 
void init(const SLVVec4f &points, const SLVVec3f &controlPoints)
 
SLVec3f velocity(SLfloat t)
 
SLVec3f acceleration(SLfloat t)
 
SLGLVertexArrayExt _vao
Vertex array object for rendering.
 
SLfloat arcLength(SLfloat t1, SLfloat t2)
 
SLCurveBezier(const SLVVec4f &points)
 
SLVec3f evaluate(const SLfloat t)
 
SLfloat segmentArcLength(SLuint i, SLfloat u1, SLfloat u2)
 
void draw(const SLMat4f &wm)
 
void dispose()
Deletes all curve arrays.
 
SLfloat subdivideLength(const SLVec3f &P0, const SLVec3f &P1, const SLVec3f &P2, const SLVec3f &P3)
 
SLfloat findParamByDist(SLfloat t1, SLfloat s)
 
SLVVec4f _points
Sample points (x,y,z) and time (w) of curve.
 
SLVfloat _lengths
Length of each curve segment.
 
SLfloat _totalLength
Total length of curve.
 
Singleton class holding all OpenGL states.
 
SLMat4f modelMatrix
Init all states.
 
static SLGLState * instance()
Public static instance getter for singleton pattern.
 
void generateVertexPos(SLVVec2f *p)
Adds or updates & generates a position vertex attribute for colored line or point drawing.
 
void drawArrayAsColored(SLGLPrimitiveType primitiveType, SLCol4f color, SLfloat lineOrPointSize=1.0f, SLuint indexFirstVertex=0, SLuint countVertices=0)
Draws the array as the specified primitive with the color.
 
SLuint numVertices() const
 
SLuint vaoID() const
Returns either the VAO id or the VBO id.
 
SLVec3< T > multVec(SLVec3< T > v) const
 
void identity()
Sets the identity matrix.
 
The SLScene class represents the top level instance holding the scene structure.
 
T distance(const SLVec3 &p) const
Calculate the distance to point p.