Beispiel #1
0
void Q3BSPRep::createSurfs(){
	int k;
	for( k=0;k<t_surfs.size();++k ){
		Surf *s=t_surfs[k];
		gxMesh *mesh=gx_graphics->createMesh( s->verts.size(),s->tris.size()/3,0 );

		mesh->lock( true );
		int j;
		for( j=0;j<s->verts.size();++j ){
			q3_vertex *t;
			int n=s->verts[j];
			if( n>=0 ){
				t=(q3_vertex*)header.dir[10].lump+n;
			}else{
				t=&p_verts[-n-1];
			}
			float tex_coords[2][2]={ {t->tex_coords[2],t->tex_coords[3]},{t->tex_coords[0],t->tex_coords[1]}};
			unsigned argb=0xff000000|(t->color[0]<<16)|(t->color[1]<<8)|t->color[2];
			mesh->setVertex( j,tf(t->coords),tf(t->normal),argb,tex_coords );
		}
		for( j=0;j<s->tris.size();j+=3 ){
#ifdef SWAPTRIS
			mesh->setTriangle( j/3,s->tris[j],s->tris[j+2],s->tris[j+1] );
#else
			mesh->setTriangle( j/3,s->tris[j],s->tris[j+1],s->tris[j+2] );
#endif
		}
		mesh->unlock();

		Q3BSPSurf *surf=d_new Q3BSPSurf;
		surf->texture=s->texture;
		surf->lm_index=s->lm_index;
		surf->mesh=mesh;
		surfs.push_back( surf );
		s->surf=surf;
	}
	for( k=0;k<faces.size();++k ){
		Q3BSPFace *f=faces[k];
		f->surf=f->t_surf->surf;
		f->tri/=3;f->n_tris/=3;
	}
	for( k=0;k<t_surfs.size();++k ){
		delete t_surfs[k];
	}
	face_map.clear();
	t_surfs.clear();
	p_verts.clear();
}