Try to translate code

Hi,

I have the following opengl c++ code:



glBegin(GL_QUADS);

   float beta = tan((fov*M_PI/180.0f)/2.0f);  //find height
   float alpha = beta*aspect;                 //find width

   glTexCoord4f(eye[0], eye[1], eye[2], 0);

     // upper left corner
   glColor4f(-alpha*T[0] - beta*B[0] + N[0],
             -alpha*T[1] - beta*B[1] + N[1],
             -alpha*T[2] - beta*B[2] + N[2], 0);
   glVertex2f(-1, -1);

   // upper right corner
   glColor4f( alpha*T[0] - beta*B[0] + N[0],
              alpha*T[1] - beta*B[1] + N[1],
              alpha*T[2] - beta*B[2] + N[2], 0);
   glVertex2f( 1, -1);

   // lower right corner
   glColor4f( alpha*T[0] + beta*B[0] + N[0],
              alpha*T[1] + beta*B[1] + N[1],
              alpha*T[2] + beta*B[2] + N[2], 0);
   glVertex2f( 1,  1);

   // lower left corner
   glColor4f(-alpha*T[0] + beta*B[0] + N[0],
             -alpha*T[1] + beta*B[1] + N[1],
             -alpha*T[2] + beta*B[2] + N[2], 0);
   glVertex2f(-1,  1);

   glEnd();



This is a full screen quad and I know how to implement it with jME. The colors I can set with Quad.setColorBuffer. But, I don't understand how to translate glTexCoord4f(eye[0], eye[1], eye[2], 0); to jME. There is a cg vertex shader with this code:


void main(float4 position :      POSITION,
          float4 rayOrigin :     TEXCOORD0,
          float4 rayDirection :  COLOR,

          out float4 pos : POSITION,
          out float4 rO :  TEXCOORD0,
          out float4 rD :  TEXCOORD1,
         
          uniform float4x4 modelViewProj)
{
   // compute screen space position of quad corners
   pos = mul( glstate.matrix.mvp, position);

   // pass ray origins and directions to fragment shader
   rO = rayOrigin;
   rD = rayDirection;
}

which I translated to glsl as


 void main()
{
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = ftransform();
    gl_TexCoord[1] = gl_Color;
}


Could you help me with glTexCoord4f(eye[0], eye[1], eye[2], 0);, please? The full code, you can find at http://graphics.cs.uiuc.edu/svn/kcrane/web/src/qjuliagpu_src.zip.

Best,
Andreas

jME only support two-component texture coordinates. You can pass your 4-component vector as two texture coordinates, and reconstruct the vector in the shader. Or you can use a single 3-component shader attribute.

?  Are you using jME 2.0?  (which should support 1, 2, 3 and 4 component tex coords fine)

Hi,

now, I use jME 2.0. Here is the code:


TexCoords oTexCoords=TexCoords.makeNew(new float[]{0,0,1,0});
oQuad.setTextureCoords(oTexCoords);


With that, I got no exception. If I get a working program, I will post it under "user showcase" or else ask again  :).

Thx,
Andreas

Great, looking forward to it.