Sophie

Sophie

distrib > * > cooker > x86_64 > by-pkgid > 0243c8b7bca94179c78b9bd6ac76c033 > files > 243

cg-examples-3.0.0018-0.1.x86_64.rpm

// This is C3E4v_twist from "The Cg Tutorial" (Addison-Wesley, ISBN
// 0321194969) by Randima Fernando and Mark J. Kilgard.  See page 79.

struct C3E4v_Output {
  float4 position : POSITION;
  float4 color    : COLOR;
};

C3E4v_Output C3E4v_twist(float2 position : POSITION,
                         float4 color    : COLOR,

                         uniform float twisting)
{	
  C3E4v_Output OUT;
  float angle = twisting * length(position);
  float cosLength, sinLength;
  sincos(angle, sinLength, cosLength);
  OUT.position[0] = cosLength * position[0] +
                   -sinLength * position[1];
  OUT.position[1] = sinLength * position[0] +
                    cosLength * position[1];
  OUT.position[2] = 0;
  OUT.position[3] = 1;
  OUT.color = color;
  return OUT;	
}