Thread: Surface normals
View Single Post
Old 17th November 2004, 03:57 AM   #5
Gernot
Member
Expert member
 
Gernot's Avatar
 
Join Date: Mar 2004
Location: Germany
Posts: 75
Default

Ah. Thank you. I didn't know that. I think it is what I've been searching for. However it's not working still. I seperated all into triangles, and I think each triangle is a unique surface now. How can i "merge" the triangles of an object, so AC3D knows that these surfaces belong to one and should be smoothed?

BTW: Here's the code for exporting, maybe it's wrong?
Code:
// Triangles of surface
static void ddd_output_triangle(POLY_FRAME *pframe, List *vertices, Surface *s)
{
SVertex *p1;
POLY_NODE	node, node_new_tri;
node_new_tri.col = COL_NEW_TRI;
	pframe->nodes.Push(node_new_tri);
	node.col = ddd_get_material_color_rgb(s->col);
	for (long n=0; n<3; n++)
	{
		switch(n)
		{
		case 1: p1 = (SVertex*)(s->vertlist->data); break;
		case 0: p1 = (SVertex*)(s->vertlist->next->data); break;
		case 2: p1 = (SVertex*)(s->vertlist->next->next->data); break;
		}
		node.normal[0] = p1->normal.x;
		node.normal[1] = p1->normal.y;
		node.normal[2] = p1->normal.z;
		node.pos[0] = p1->v->x;
		node.pos[1] = p1->v->y;
		node.pos[2] = p1->v->z;
		node.tex[0] = p1->tx;
		node.tex[1] = - p1->ty;
		pframe->nodes.Push(node);
	}
}
Gernot is offline   Reply With Quote