zynek
2005.01.21, 11:36 AM
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:
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:
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:
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
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:
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:
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:
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