porting linux glut code to mac os x

zynek
Unregistered
 
Post: #1
Hi,
I am porting a linux program to Mac OS X and I am realtivley new to OpenGl. The program is a talking head application that uses Glut for displaying the graphics. The mouth, teeth, and the eyes are all saved as obj files. Except for the eyes everything is displayed. I found that the way the eyes are displayed is different from the other objects. I was wondering if there might be something mac specific that I don't know about that causes the eyes to be invisible?

Here is the code for diplaying the eyes:

Code:
void ObjModel::DrawObjModel()
{
    for(int i = 0; i < m_number_f; i++){
        glBegin(GL_POLYGON);
        for(int j = 0; j < m_number_f_ele[i]; j++){
            if( m_texture_ver )
                //glTexCoord3dv((GLdouble *)&m_texture_ver[m_link[i].element[j].v]);  
                glTexCoord2d(m_texture_ver[m_link[i].element[j].v].x, m_texture_ver[m_link[i].element[j].v].y);
            if( m_normal )
                glNormal3dv((GLdouble *)&m_normal[m_link[i].element[j].n]);
                glVertex3dv((GLdouble *)&m_vertex[m_link[i].element[j].v]);                
        }
        glEnd();
    }
}

this routine gets called from here:

Code:
void FaceEditView::DrawEyeModel(FaceModel *model)
{
    ObjModel *obj = model->GetEyeObject();
    glPushMatrix();
    glTranslated(model->GetEyeRTrans()[0], model->GetEyeRTrans()[1], model->GetEyeRTrans()[2]);
    glScaled(model->GetEyeRScale(), model->GetEyeRScale(), model->GetEyeRScale());
    glRotated(model->GetEyeRLocalRot()[0] + model->GetAppEyeRotR()[0], 1.0, 0.0, 0.0);
    glRotated(model->GetEyeRLocalRot()[1] + model->GetAppEyeRotR()[1], 0.0, 1.0, 0.0);
    glRotated(model->GetEyeRLocalRot()[2], 0.0, 0.0, 1.0);
    obj->DrawObjModel();
    glPopMatrix();
    
    
    glPushMatrix();
    glTranslated(model->GetEyeLTrans()[0], model->GetEyeLTrans()[1], model->GetEyeLTrans()[2]);
    glScaled(model->GetEyeLScale(), model->GetEyeLScale(), model->GetEyeLScale());
    glRotated(model->GetEyeLLocalRot()[0] + model->GetAppEyeRotL()[0], 1.0, 0.0, 0.0);
    glRotated(model->GetEyeLLocalRot()[1] + model->GetAppEyeRotL()[1], 0.0, 1.0, 0.0);
    glRotated(model->GetEyeLLocalRot()[2], 0.0, 0.0, 1.0);
    obj->DrawObjModel();
    glPopMatrix();
}




The teeth get displayed using this routine, which apparently works:

Code:
void ObjectModel::drawTeethModel(int mode)
{
    TRACE("ObjectModel::drawTeethModel()");
    
    int i;
    int pointNum = getPointNum();
    int polygonNum = getPolygonNum();
    int pointVectorNum = getPointVectorNum();
    double x,y,z,y1,z1,xmax,ymax,zmax,xmin,ymin,zmin,xcenter;
    double calc = moveTeeth(mode);
    double jawAngle = getJawAngle();
    Point3f tmp[600];
    Point3f *pointPtr = getPoint();
    Polygon3 *polygonPtr = getPolygon();
    Vector3f *polygonVectorPtr = getPolygonVector();
    Vector3f *pointVectorPtr = getPointVector();
    glPushMatrix();
    
    switch(mode){
    case TEETH_UPPER:
        for(i = 0 ; i < pointNum ; i++){
            tmp[i].x = pointPtr->x;
            tmp[i].y = pointPtr->y;
            tmp[i].z = pointPtr->z;
            pointPtr++;
        }
        pointPtr = getPoint();
        break;
    case TEETH_LOWER:
        xmin = ymin = zmin = MAXDOUBLE;
        xmax = ymax = zmax = -MAXDOUBLE;
        for(i = 0 ; i < pointNum ; i++){
            x = pointPtr->x;
            y = pointPtr->y;
            z = pointPtr->z;
            if(x < xmin) xmin = x;
            if(y < ymin) ymin = y;
            if(z < zmin) zmin = z;
            
            if(x > xmax) xmax = x;
            if(y > ymax) ymax = y;
            if(z > zmax) zmax = z;
            pointPtr++;
        }
        pointPtr = getPoint();
        for(i = 0 ; i < pointNum ; i++){
            tmp[i].x = pointPtr->x;
            tmp[i].y = pointPtr->y;
            tmp[i].z = pointPtr->z;
            pointPtr++;
        }
        pointPtr = getPoint();
        xcenter =(xmax + xmin) / 2.0;
        y1 = 0.00;
        z1 = zmin;
        glTranslated(-xcenter, -y1, -z1);
        glRotated(jawAngle / 2.0, 1.0, 0.0, 0.0);
        glTranslated(xcenter, y1, z1);
        break;
    }
    glBegin(GL_TRIANGLES);
    for(i = 0; i < polygonNum; i++){
        glNormal3dv((GLdouble *)(pointVectorPtr + polygonPtr->tp0));
        glVertex3d(tmp[polygonPtr->p0].x,tmp[polygonPtr->p0].y, tmp[polygonPtr->p0].z);
        
        glNormal3dv((GLdouble *)(pointVectorPtr + polygonPtr->tp1));
        glVertex3d(tmp[polygonPtr->p1].x,tmp[polygonPtr->p1].y, tmp[polygonPtr->p1].z);
        
        glNormal3dv((GLdouble *)(pointVectorPtr + polygonPtr->tp2));
        glVertex3d(tmp[polygonPtr->p2].x,tmp[polygonPtr->p2].y, tmp[polygonPtr->p2].z);
        polygonPtr++;
    }
    glEnd();
    glPopMatrix();
    
}



I hope someone here can help.
thanks,
Gregor
Quote this message in a reply
Member
Posts: 86
Joined: 2005.01
Post: #2
Is it possible you have endian issues when loading the model file in?
Quote this message in a reply
zynek
Unregistered
 
Post: #3
well I had endian issues with the texture fiels but I got those resolved. If I do have endian issues here I don't see why they would only apply to the eye.obj and not to the other obj files. I checked with a debugger and sees like the obj files are loading fine. I believe that the problem is in the code.

thanks anyway,
Gregor
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #4
So, the eyes are textured, and the teeth aren't. Are any other parts of the model textured? Are you sure the textures are complete?
Quote this message in a reply
zynek
Unregistered
 
Post: #5
thanks for pointing that out. Iif the textures are incomplete and if I just display the wireframe this should not make a difference, right? Even in the wireframe the eyes are missing....

Gregor
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
Wireframes can be textured, too Wink Try disabling texturing to be sure.
Quote this message in a reply
zynek
Unregistered
 
Post: #7
The eyes do not display when I disable texturing but I found another part of the model that is textured as well, which is displayed fine. Blink

Code:
void ObjectModel::drawMouthwallModel()
{
    TRACE("ObjectModel::drawMouthwallModel()");
    
    int polygonNum = getPolygonNum();
    int pointVectorNum = getPointVectorNum();
    Point3f *pointPtr = getPoint();
    Polygon3 *polygonPtr = getPolygon();
    Vector3f *pointVectorPtr = getPointVector();
    Point2f *texturePointPtr = getTexturePoint();
    
    moveMouthwall();
    
    glBegin(GL_TRIANGLES);
    for(int i = 0; i < polygonNum; i++){
        glTexCoord2d(texturePointPtr[polygonPtr->p0].x, texturePointPtr[polygonPtr->p0].y);
        glVertex3dv((GLdouble *)(pointPtr + polygonPtr->p0));
        
        glTexCoord2d(texturePointPtr[polygonPtr->p1].x, texturePointPtr[polygonPtr->p1].y);
        glVertex3dv((GLdouble *)(pointPtr + polygonPtr->p1));
        
        glTexCoord2d(texturePointPtr[polygonPtr->p2].x, texturePointPtr[polygonPtr->p2].y);
        glVertex3dv((GLdouble *)(pointPtr + polygonPtr->p2));
        polygonPtr++;
    }
    glEnd();
}

thanks,
Gregor
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #8
Hmm... well, I don't see anything else special about the eyes.

Do you have backface culling turned on? Is the eye geometry correctly wound?
Quote this message in a reply
zynek
Unregistered
 
Post: #9
backface culling is turned on. I am not sure how to check if the geomerty is correctly wound?

thanks,
Gregor
Quote this message in a reply
Member
Posts: 70
Joined: 2004.06
Post: #10
Read the man page on glFrontFace() for information on winding. Try both GL_CW and GL_CCW, and see if the eyes show up in either mode.
Quote this message in a reply
zynek
Unregistered
 
Post: #11
I just tried it. The geometry was correctly wound. The model was turned inside out after I changed the orientation. I also just applied it to the part where the eyes are drawn but nothing happend. :frown:

thanks,
Gregor
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #12
try posting the project, it's easier to look at that way.

It's not magic, it's Ruby.
Quote this message in a reply
zynek
Unregistered
 
Post: #13
sorry I can't do that. First of all I am not allowed to post attachments and second the project is not open source. Sad -its not my call- maybe it will be in the future. But are there any particular parts of the code that could be helpful?

cheers,
Gregor
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Unholy method to link Linux library? Cochrane 3 3,198 Jun 30, 2008 06:37 AM
Last Post: OptimisticMonkey
  Linux geek wanting to get into Mac games programming supenguin 8 5,178 Nov 16, 2005 09:49 PM
Last Post: EvolPenguin
  Help porting Puyo Puyo from Code warrior 8 to xcode unknown 7 4,943 Nov 14, 2005 05:04 AM
Last Post: unknown
  Linux Games/Tibia Kris 3 4,560 Sep 27, 2004 04:08 PM
Last Post: ERaZer
  Linux IDE's wadesworld 5 4,926 Jul 20, 2004 08:17 AM
Last Post: Iron Wallaby