static inline void setGenFunc(      GLenum   coord, 
                                    GLenum   gen, 
                                    GLenum   func, 
                              const Vec4f   &plane, 
                                    Node    *beacon, 
                                    Matrix  &cameraMat,
                                    UInt32   eyeMode,
                                    Matrix  &eyeMatrix)
{
#ifndef OSG_EMBEDDED
	if(beacon != NULL)
    {
        Matrixr beaconMat;
        beacon->getToWorld(beaconMat);
        beaconMat.multLeft(cameraMat);
        glPushMatrix();
        glLoadMatrixf(beaconMat.getValues());
        glTexGenfv(coord, 
                   GL_EYE_PLANE, 
                   const_cast<GLfloat *>(plane.getValues()));
        glTexGeni(coord, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
        glPopMatrix();
        glEnable(gen);
    }        
    else if(func == GL_EYE_LINEAR)
    {
        glPushMatrix();
  
        switch(eyeMode)
        {
            case TexGenChunk::EyeModelViewIdentity:
                glLoadIdentity();
                break;
                
            case TexGenChunk::EyeModelViewStored:
                glLoadMatrixf(eyeMatrix.getValues());
                break;

            case TexGenChunk::EyeModelViewCamera:
                glLoadMatrixf(cameraMat.getValues());
                break;

            default:
                break;
        }

        glTexGenfv(coord, 
                   GL_EYE_PLANE, 
                   const_cast<GLfloat *>(plane.getValues()));

        glTexGeni(coord, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);

        glPopMatrix();

        glEnable(gen);
    }        
    else if(func != GL_NONE)                                         
    {                                                                   
        glTexGeni(coord, GL_TEXTURE_GEN_MODE, func);
        
        if(func == GL_OBJECT_LINEAR)
        {
            glTexGenfv(coord, 
                       GL_OBJECT_PLANE, 
                       const_cast<GLfloat *>(plane.getValues()));
        }

        glEnable(gen);
    }
#endif
}