nurb surface with texture (basics)


    May 28 2008 | 12:21 pm
    I am trying to create a fullscreen image (texturized nurb) that I can "dent" inwards where clicking and dragging the mouse. After poking around a bit it looks like jit.nurb would be the way to go. But I am having trouble with a couple basics.
    can anyone point me to examples doing something similar? I have looked at the nurb help patch and the manipulator patch example from Jitter Recipes 2 but have not been able to make the leap.
    Also, how do I grab the mouse click and drag from the jit GL window without rotating the nurb surface. I would like it to stay still and only manipulate the control matrix in the Z direction using the mouse drag coordinates.

    • Aug 25 2008 | 3:46 pm
      I was recently working on something similar to this. I was unable to find much detail in the documentation about what the control matrix format is, but with a little experimentation I got the results I was looking for.
      For cubic NURBS, the matrix is a 4x4 array of control points with 3 planes for the X,Y and Z coordinates.
      To do the "dent" effect you want, you can make the base control matrix a plane at Z=0, then push the Z in the negative direction for the middle 4 points (indicated with X).
      Something like this:
      (-1, 1, 0) (-0.333, 1, 0) (0.333, 1, 0) (1, 1, 0)
      (-1, 0.333, 0) (-0.333, 0.333, 0) (0.333, 0.333, 0) (1, 0.333, 0)
      (-1, -0.333, 0) (-0.333, -0.333, 0) (0.333, -0.333, 0) (1, -0.333, 0)
      (-1, -1, 0) (-0.333, -1, 0) (0.333, -1, 0) (1, -1, 0)
      I stored the control matrix in a [jit.matrix 3 float32 4 4] then used four setcell messages, like [setcell 1 1 plane 2 val $f1] to modify the Z coordinates of the middle 4 points.
      Hope this helps!