Renderware

clapton541
Unregistered
 
Post: #1
I am making a renderware 3d loader and I have a problem where everything works right except the cube is not really a cube. I need to know how the face arrangements work if anyone could help me with that.
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #2
What is a "renderware 3d loader"? The only thing called Renderware, it EA's in house engine...
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #3
...and "the cube is not really a cube" is an almost metaphysical error description.

My guess is that we're actually talking RenderMan, and that your problem is that your face normals are smoothed?
Quote this message in a reply
clapton541
Unregistered
 
Post: #4
Here is something better. I'm making an obj file loader and when I display the model the faces are all messed up in some sort of weird cube that looks like it got tangled up in itself. I know I am loading the file correctly because I made it print out the results and it matches to the file. Here is the code for the part that makes the display list. (these aren't the actually variables i used)
Code:
void loadlist(int num)
{    
    models[num]=glGenLists(1);
    glNewList(models[num], GL_COMPILE);
    int l=0;
    
    
    while(l<numoffaces)
    {
        int g=0;
        glBegin(GL_POLYGON);
        float normal[3]={0,0,0};
        while(g<numofpointsperface[numfaces])
        {
            int j=face[l][g][0];
            
            
            normal[0]+=v[j][0];
            normal[1]+=v[j][1];
            normal[2]+= v[j][2];
            g++;
        }
        g=0;
        
        while(g<numpointsperface[numfaces])
        {
            int j=faces[l][g][0];
            
            glNormal3f(normal[0]/numpointsperface[numfaces], normal[1]/numpointsperface[numfaces], normal[2]/numpointsperface[numfaces]);
            glVertex3f(v[j][0], v[j][1], v[j][2]);
            g++;
        }
        glEnd();
        l++;
        
    }
    
    glEndList();
}
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #5
I swear to you (without even reading your code) that you're missing that OBJ files start counting at 1 instead of 0 when defining the vertex/normal/tex indicies in the faces. ^^
Quote this message in a reply
clapton541
Unregistered
 
Post: #6
Crap, hundreds of people have told me that and I still forgot to do that. All I did was add little -1's to my code and I could load spiral torus's. THanks a lot.
Quote this message in a reply
Post Reply