chiahsien / iphonewavefrontloader

Automatically exported from code.google.com/p/iphonewavefrontloader
1 stars 0 forks source link

Enhancement - help? #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
<I've removed the problem description framework - it doesn't apply here>

Jeff... i'm trying to make an enhancement to the wavefrontloader and as such 
trying to put the 
objects loaded into a squash court (for want of a better description). So I've 
created a sheet or flat 
plane. It can be positioned with translate and rotate. That's fine, but I can't 
color it. I'm completely 
befuddled as to what's going on. I suspect someone with real opengl knowledge 
will see the issue 
quickly. 

I'll past here the code from drawView that I have (it's not the complete 
drawView). I'll also attach a 
zipped project.

    glPushMatrix();
    glLoadIdentity(); 

    glTranslatef(0.0, -1.0, -3.25);                     // Translate to the current position
    glRotatef(rotation, 0.0, 1.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    //Configure OpenGL arrays
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    //  glEnableClientState(GL_TEXTURE_COORD_ARRAY);        // makes glDrawElements crash 
with EXE_BAD_ACCESS

    glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

    // set the scene
    glVertexPointer(3 ,GL_FLOAT, 0, cube_vertices); // create a pointer to the Verticies ? steps by 
3 ?
    glNormalPointer(GL_FLOAT, 0, cube_normals);     // create a pointer to the normals ? 
    glColorPointer(4, GL_FLOAT, 0, cube_colors);    // this code is a bit of a test - and seems 
over the top for the requirements

    const GLfloat           matAmbient[] = {1.0, 1.0, 1.0, 1.0};
    const GLfloat           matDiffuse[] = {1.0, 0.0, 1.0, 1.0};    // changing this will affect the 
colour of the surface
    const GLfloat           matSpecular[] = {1.0, 1.0, 1.0, 1.0};
    const GLfloat           lightShininess = 128.0;
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, matAmbient);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiffuse);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matSpecular);
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, lightShininess);

    for(int i = 0; i < num_cube_indices; i += cube_indicies[i] + 1)
    {
        glDrawElements(GL_TRIANGLE_STRIP, cube_indicies[i], GL_UNSIGNED_BYTE, 
&cube_indicies[i+1]);
    };

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    //  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glPopMatrix();

Original issue reported on code.google.com by dgwilson65@gmail.com on 1 Aug 2009 at 3:58

Attachments:

GoogleCodeExporter commented 9 years ago
the project (wavefrontloader from trunk, contains fixes to issues reported from 
earlier defects, and other objects 
to load as well...) Load of 3 out of 4 object is currently commented out. Other 
enhancements include positioning 
of objects and the ability to easily move an object around the screen (one 
object in particular at the moment).

Original comment by dgwilson65@gmail.com on 1 Aug 2009 at 4:01