How to render pod file in SDK

I generated a very simple pod file – there is only one green cube, one light(sun) and one camera.
This file is built by exporting from Blender(2.49b) or exporting as DAE file then pod file by collada2POD tool. It can be display in PVRShaman.

I used the project IntroducingPOD(from OpenGL ES 2.0 SDK V2.8 release 1) to render it – changed the variable “c_szSceneFile” point to my own pod file.

However the project always stop the codes from the function “void OGLES2IntroducingPOD::DrawMesh(int i32NodeIndex)”:

    glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, pMesh->sVertex.nStride, pMesh->sVertex.pData);
    glVertexAttribPointer(NORMAL_ARRAY, 3, GL_FLOAT, GL_FALSE, pMesh->sNormals.nStride, pMesh->sNormals.pData);
    glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, pMesh->psUVW[0].nStride, pMesh->psUVW[0].pData);

The pointer sVertex.pData and sNormals.pData are NULL!

I did a search in Forum, but it seems others didn’t meet such issueOuch Who can give me kind hand? Thanks.

BTW I would like to know whether I can upload the pod/dae file for check.

Hi.


IntroducingPOD uses Vertex Buffer Objects and interleaved arrays to render geometry. The pointer sVertex.pData is not actually a pointer to data but is an offset in to memory where the vertex data is stored. If you take a look at the function LoadVbos() you can see that the geometry data is uploaded and a buffer handle is generated to reference the data at render time. If sNormals.pData is also NULL this may be because you have not exported normals with your geometry. Please make sure it doesn’t equal something similar to 0x0000000c (which is 12 bytes in to the interleaved buffer: 3 x 4byte floats for vertex data). You should find that psUVW[x].pData is again, something similar.





Unfortunately I can’t say exactly why your model isn’t displaying, and you can’t attach files to the forum but please feel free to email us the attached file to: devtech@imgtec.com , or alternatively upload your POD file to a file hosting website and link to it here.

Hi Arron:

  Many thanks for your prompt reply!

  Yes you’re right – the normal is not exported in my pod file. Now sNormals.pData is 



0x0000000c and I think it is correct as the offset in Vertex structure.

  However I met another issue about UVW, there is no UVW in my so simple scene, therefore pMesh->psUVW equals to NULL, so produce will be blocked at the code:

glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, pMesh->psUVW[0].nStride, pMesh->psUVW[0].pData);

  I have to append the adjustment as and I can see the cube in application!Clap

    if(pMesh->nNumUVW){
        glEnableVertexAttribArray(TEXCOORD_ARRAY);
        glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, pMesh->psUVW[0].nStride, pMesh->psUVW[0].pData);
    }

  The final issue I foundWink – the light in scene is open/enable, however there is no such problem in PVRShama. I would like to send the pod file to the mail address you mentioned for check. Thank you again.


Hi Yiwen.





The reason your model doesn’t display properly is that the fragment shader is expecting a texture and associated UVs to sample from to calculate the fragment colour. If no texture and/or UVs are supplied then the function call to texture2D() within the fragment shader will return vec4(0,0,0,0) thus your cube will be displayed black.





You can easily resolve this by modifying the fragment shader to look like this:





Code:

gl_FragColor = vec4(LightIntensity, LightIntensity, LightIntensity, 1.0);



This will display a lit cube however you'll have to modify the shader and pass the relevant attribute data for vertex colours to have it display in green.



Hope this helps.Arron2011-08-16 10:11:12

Hi Arron:

  Yes you are totally correct! After taking your suggestions about the modification for fragment shader, I can see the right cube in application.

  I think we can close this discussion. Thank you again.