All pastes #448733 Raw Edit

Anonymous

public cpp v1 · immutable
·published 2007-04-19 21:03 UTC
rendered paste body
lib3ds_mesh_calculate_normals(mesh, normalL);		ngVector3 tempa;		//zero out normals		for(int q=0;q<numVertices;q++) {			normalL2[q].pos[0] = 0.0f;			normalL2[q].pos[1] = 0.0f;			normalL2[q].pos[2] = 0.0f;		}		for(unsigned int p=0; p< mesh->faces;p++) {			Lib3dsFace *f=&mesh->faceL[p];			for(unsigned int i=0;i<3;i++) {				tempa.x = normalL[f->points[i]][0] + f->normal[0];					tempa.y = normalL[f->points[i]][1] + f->normal[1];					tempa.z = normalL[f->points[i]][2] + f->normal[2];				normalL2[f->points[i]].pos[0] = tempa.x;				normalL2[f->points[i]].pos[1] = tempa.y;				normalL2[f->points[i]].pos[2] = tempa.z;			}			//normalize normals			for(int q=0;q<numVertices;q++) {				tempa.x = normalL2[q].pos[0];				tempa.y = normalL2[q].pos[1];				tempa.z = normalL2[q].pos[2];				//assert(!(tempa.x == 0.0f && tempa.y == 0.0f && tempa.z == 0.0f));				if(tempa.x != 0.0f && tempa.y != 0.0f && tempa.z != 0.0f) {				ngVectorNormalize(&tempa, &tempa);				}				normalL2[q].pos[0] = tempa.x;				normalL2[q].pos[1] = tempa.y;				normalL2[q].pos[2] = tempa.z;			}		}