View Single Post
Old 1st March 2005, 12:06 PM   #7
fractile
Junior Member
Member
 
Join Date: Sep 2004
Location: Tampere, Finland
Posts: 14
Default

The problem isn't in the triangulation anymore. It seems that the vertex normals are bad, even if I triagulate the model manually before exporting. AC3D shows the model correctly smoothed.

I added a printf() in the code below to see, where the normals go bad. All I get is lots of "SVertex normal: (0.000000, 0.000000, 0.000000)" messages..

Code:
static void fmesh_export_triangle_surface(Surface* surface, FMeshBuilder& builder, int materialindex)
{
   printf("exporting surface..\n");

   int vertexindex = -1;
   for(List* v = surface->vertlist; v != NULL; v = v->next)
   {
      SVertex* vertex = (SVertex*)v->data;

      FMeshVector3 pos(vertex->v->x, vertex->v->y, vertex->v->z);
      //FMeshVector3 n(vertex->v->normal.x, vertex->v->normal.y, vertex->v->normal.z);      
      printf("SVertex normal: (%f, %f, %f)\n", vertex->v->normal.x, vertex->v->normal.y, vertex->v->normal.z);
      FMeshVector3 n(surface->normal.x, surface->normal.y, surface->normal.z);
      FMeshVector3 tc(vertex->tx, vertex->ty, 0);
      vertexindex = builder.addVertex(pos, &n, &tc);
   }   

   builder.addFace(materialindex, vertexindex - 2, vertexindex - 1, vertexindex);
}
Rest of the code is unchanged from what I posted earlier.
fractile is offline   Reply With Quote