/* ======================================================================================================================= ======================================================================================================================= */ void FaceToBrushPrimitFace(face_t *f) { idVec3D texX, texY; idVec3D proj; // ST of (0,0) (1,0) (0,1) idVec5 ST[3]; // [ point index ] [ xyz ST ] // // ++timo not used as long as brushprimit_texdef and texdef are static // f->brushprimit_texdef.contents=f->texdef.contents; // f->brushprimit_texdef.flags=f->texdef.flags; // f->brushprimit_texdef.value=f->texdef.value; // strcpy(f->brushprimit_texdef.name,f->texdef.name); // #ifdef _DEBUG if (f->plane[0] == 0.0f && f->plane[1] == 0.0f && f->plane[2] == 0.0f) { common->Printf("Warning : f->plane.normal is (0,0,0) in FaceToBrushPrimitFace\n"); } // check d_texture if (!f->d_texture) { common->Printf("Warning : f.d_texture is NULL in FaceToBrushPrimitFace\n"); return; } #endif // compute axis base ComputeAxisBase(f->plane.Normal(), texX, texY); // compute projection vector VectorCopy( f->plane, proj ); VectorScale(proj, -f->plane[3], proj); // // (0,0) in plane axis base is (0,0,0) in world coordinates + projection on the // affine plane (1,0) in plane axis base is texX in world coordinates + projection // on the affine plane (0,1) in plane axis base is texY in world coordinates + // projection on the affine plane use old texture code to compute the ST coords of // these points // VectorCopy(proj, ST[0]); EmitTextureCoordinates(ST[0], f->d_texture, f); VectorCopy(texX, ST[1]); VectorAdd(ST[1], proj, ST[1]); EmitTextureCoordinates(ST[1], f->d_texture, f); VectorCopy(texY, ST[2]); VectorAdd(ST[2], proj, ST[2]); EmitTextureCoordinates(ST[2], f->d_texture, f); // compute texture matrix f->brushprimit_texdef.coords[0][2] = ST[0][3]; f->brushprimit_texdef.coords[1][2] = ST[0][4]; f->brushprimit_texdef.coords[0][0] = ST[1][3] - f->brushprimit_texdef.coords[0][2]; f->brushprimit_texdef.coords[1][0] = ST[1][4] - f->brushprimit_texdef.coords[1][2]; f->brushprimit_texdef.coords[0][1] = ST[2][3] - f->brushprimit_texdef.coords[0][2]; f->brushprimit_texdef.coords[1][1] = ST[2][4] - f->brushprimit_texdef.coords[1][2]; }
void Brush_BuildWindings( brush_t *b ) { winding_t *w; face_t *face; vec_t v; Brush_SnapPlanepts( b ); // clear the mins/maxs bounds b->mins[0] = b->mins[1] = b->mins[2] = 99999; b->maxs[0] = b->maxs[1] = b->maxs[2] = -99999; Brush_MakeFacePlanes (b); face = b->brush_faces; for ( ; face ; face=face->next) { int i, j; w = face->face_winding = MakeFaceWinding (b, face); face->d_texture = Texture_ForName( face->texdef.name ); if (!w) { continue; } for (i=0 ; i<w->numpoints ; i++) { // add to bounding box for (j=0 ; j<3 ; j++) { v = w->points[i][j]; if (v > b->maxs[j]) b->maxs[j] = v; if (v < b->mins[j]) b->mins[j] = v; } } // setup s and t vectors, and set color BeginTexturingFace( b, face, face->d_texture); for(i = 0; i < w->numpoints; i++) EmitTextureCoordinates(w->points[i],face->d_texture,face); } }