shading on 3ds model

hey
we’re building a pool game.i’m using a 3ds model and lib3ds as the importer.But when i load the 3ds file, it seems really ugly.i cant apply smoothing even i wrote smooth enable code.what do you suggest for me??should i use another file format/importer?
or is it the same?

it seems really ugly

The ugliness is a subjective notion… what do you mean exactly, is it about smooth shading?

If I remember correctly, in the 3ds file you can find two types of normals: face normals and vertex normals.

You have to use vertex normals to get smooth shading (Assuming it is in 3dsmax).
If you only get face normals, each face vertex will use the same normal and you will obtain a flat shaded surface. To prevent this, you may interpolate face normals to vertices then pass them to Opengl.

thanks for your quick reply:)

i mean it seems quite different than it seems in 3ds max.here is how it looks in the program with opengl:
http://img35.imageshack.us/img35/8236/pool1g.jpg
and here is in 3ds Max:
http://img34.imageshack.us/img34/1580/pool2w.jpg

i use smooth shading.and normal coordinates per vertex also.
actually i couldnt figure out where the problem is.lighting, shading or model format?

thanks in advance…

here is my code for drawing Lib3ds node:

void PoolGame::drawModel(Lib3dsNode *node){
Lib3dsNode *p;
Lib3dsMesh *mesh;
Lib3dsFace *face;
Lib3dsMaterial *mat;
Lib3dsMeshInstanceNode *meshData;

float	(*norm_verts)[3];
float	(*norm_faces)[3];

int         i;
unsigned	fi;
float		M[4][4];

for (p=node->childs; p!=0; p=p->next){
	drawModel(p);
}

if (node->type==LIB3DS_NODE_MESH_INSTANCE)
{
	if (strcmp(node->name,"$$$DUMMY")==0) {
		return;
	}

	if (!node->user_id) 
	{
		mesh = lib3ds_file_mesh_for_node(model, node);

		if (!mesh) {
			return;
		}

		node->user_id = glGenLists(1);
		glNewList(node->user_id, GL_COMPILE);
		
		norm_verts = (float (*)[3])malloc(sizeof(float) * 9 * mesh->nfaces);;
		norm_faces = (float (*)[3])malloc(sizeof(float) * 3 * mesh->nfaces);				

		lib3ds_matrix_copy(M, mesh->matrix);
		lib3ds_matrix_inv(M);
	//	glMultMatrixf(&M[0][0]);
		
		lib3ds_mesh_calculate_face_normals(mesh, norm_faces);
		lib3ds_mesh_calculate_vertex_normals(mesh, norm_verts);
		
		for (fi=0; fi<mesh->nfaces; ++fi) {
			face = &(mesh->faces[fi]);
			mat = 0;
			
			if (face->material>=0 && face->material<model->nmaterials)
				mat=model->materials[face->material];
			
			if (mat) 
			{
				float s = pow(2, 10.0*mat->shininess);
				if (s>128.0) s = 128.0f;

				glMaterialfv(GL_FRONT, GL_AMBIENT, mat->ambient);
				glMaterialfv(GL_FRONT, GL_DIFFUSE, mat->diffuse);
				glMaterialfv(GL_FRONT, GL_SPECULAR, mat->specular);
				glMaterialf(GL_FRONT, GL_SHININESS, s);
			}
			else {
				float a[]={0.2, 0.2, 0.2, 1.0};
				float d[]={0.8, 0.8, 0.8, 1.0};
				float s[]={0.0, 0.0, 0.0, 1.0};
				glMaterialfv(GL_FRONT, GL_AMBIENT, a);
				glMaterialfv(GL_FRONT, GL_DIFFUSE, d);
				glMaterialfv(GL_FRONT, GL_SPECULAR, s);
			}
			cout << face->material << endl;
			glBindTexture(GL_TEXTURE_2D, textures[face->material].TextureID);		
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
			// Draw tri-face
			glBegin(GL_TRIANGLES);
			
		//	glNormal3fv(norm_faces[fi]);	// face normal

			for (i=0; i<3; ++i) {
				glNormal3fv(norm_verts[3*fi+i]);	// vertex normal
				glTexCoord2fv(mesh->texcos[i]);
				glVertex3fv(mesh->vertices[face->index[i]]);
			}

			glEnd();
		}

		free(norm_faces);
		free(norm_verts);
		
		glEndList();
	}

	if (node->user_id) {
		glPushMatrix();
		meshData = (Lib3dsMeshInstanceNode*) node;
		
		glMultMatrixf(&node->matrix[0][0]);
		glTranslatef(-meshData->pivot[0], -meshData->pivot[1], -meshData->pivot[2]);
		glCallList(node->user_id);

		// glutSolidSphere(50.0, 20,20);
		glPopMatrix();
	}
}

}

First of all, it looks like that you do not parse correctly texture coordinates. Comparing your program screenshot and the 3ds max one textures are not mapped the same way.

I advise you to export a very simple mesh like a plane with a texture mapped on it and see if there is still a texture mapping problem.

Do you require a depth buffer ? It looks like the holes are inside-out, as can happen if there is no depth testing.

It can also be the face winding order (CW or CCW). Disable GL_CULL_FACE to check if it is better.

i tried disabling culling but it didnt work.
the problem is when i execute it normally it’s like that:

http://img194.imageshack.us/img194/4316/pool3.jpg

but when i remove the woods from the edge there is no problem as you see.it’s the same as in 3dsmax.

http://img188.imageshack.us/img188/187/pool4.jpg