playing with the new GLLua class

Creating Bezier curves with lua and displaying them with OpenGL (GLLua object):

splines

And here is the code that evaluates the curves and color transitions along the paths:

for t = 0,1.0,(1.0/resolution) do
  ta = (1-t)^3
  tb = 3 * t * (1-t)^2
  tc = 3 * (1-t) * t^2
  td = t^3

  gl.Color(
    c1.r * (1-t) + c4.r * t,
    c1.v * (1-t) + c4.v * t,
    c1.b * (1-t) + c4.b * t
  )
  gl.Vertex(
    ta * p1[1] + tb * p2[1] + tc * p3[1] + td * p4[1],
    ta * p1[2] + tb * p2[2] + tc * p3[2] + td * p4[2],
    ta * p1[3] + tb * p2[3] + tc * p3[3] + td * p4[3]
  )
end
Gaspard Bucher

comments

  1. leave a comment