Pseudo-instancing: help needed with some code part

I’m trying to implement the glsl_pseudo_instancing nvidia example in my terrain engine project.

I’ve already setup the proper initialization routines (loading the shaders etc.) but I’d like to ask some explanations about the render() routine.
Here is the upper part of the original nVidia code:

[b]void renderScene(void)
{
assert(gCurrentMesh != NULL);
int i;
int count;
matrix4f view;
vec3f light;
vec3f lightWorldSpace(0.0f, 100.0f, 0.0f);
vec3f lightPositionView;

// Set state for rendering the mesh
gCurrentMesh->setState();

// Get the view transform from the mouse interactor
view = gMouseInteractor.get_transform(); // HERE IS WHERE I NEED HELP

// Compute the light’s position in view space
view.mult_matrix_vec(lightWorldSpace, lightPositionView);
lightPositionView = vec3f(0.0f, 0.0f, 0.0f);


// Download the view matrix
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 4, view(0, 0), view(0, 1), view(0, 2), view(0, 3));
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 5, view(1, 0), view(1, 1), view(1, 2), view(1, 3));
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 6, view(2, 0), view(2, 1), view(2, 2), view(2, 3));
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 7, view(3, 0), view(3, 1), view(3, 2), view(3, 3));
// Download the light position
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 11, lightPositionView[0], lightPositionView[1], lightPositionView[2], 1.0f); [/b]

From what I understood, I need to retrieve the current view transform and pass the matrix parameters to the vertex program using the glProgramLocalParameter4fARB calls beow.
I have a very simple camera routine that just set pitch,yaw,roll and xyz positions.
How could I calculate the matrix4f view (the view transform matrix) using my camera information?

Thanks for any help!

For just the glModelView matrix the vertex program already has built in state you can access. The nVidia code was computing a light modelview matrix for per pixel calculations.

Sorry but I don’t understand: in the above example, it seems to me that the gMouseInteractor function rotates the camera and so the view matrix has to be recalculated.
That’s what I don’t understand: if I have a camera that setup rotations and position, how would I pass those parameters to the shader? Via those glProgramLocalParameter4fARB calls?

Same thing.
gMouseInteractor presumably sets the camera view for the scene.
This is usually stored in the OpenGl ModelView matrix - otherwise no fixed function rendering would work.
This modelview matrix is available in your shaders as a built-in parameter. Alternatively, you can get at it from your code with:

glgetFloatv (GL_MODELVIEW_MATRIX, &modelviewmatrix)

Thanks BionicBytes, I’m going to do some experiments!