Quake: (x1 y1 z1) (x2 y2 z2) (x3 y3 z3) texture x-shift y-shift angle x-scale y-scale
Map 220 (Valve) : (x1 y1 z1) (x2 y2 z2) (x3 y3 z3) texture [x-texvector x-shift] [y-texvector y-shift] angle x-scale y-scale
http://www.gamers.org/dEngine/quake/spe ... index0.htm
See Ben Jardup's txqbsp source:
Code: Select all
map.c ParseBrush in txqbsp ...
void ParseBrush (void)
{
Valve220 = false;
tx.miptex = FindMiptex (token);
GetToken (false);
if (!strcmp (token, "["))
{
// Valve 220 map import
Valve220 = true;
GetValveTex (VAxis[0]);
}
shift[0] = atoi(token);
GetToken (false);
if (Valve220)
{
// Skip ]
GetToken (false);
GetValveTex (VAxis[1]);
}
shift[1] = atoi(token);
GetToken (false);
if (Valve220)
GetToken (false); // Skip ]
rotate = atoi(token);
GetToken (false);
scale[0] = atof(token);
GetToken (false);
scale[1] = atof(token);
Code: Select all
static void GetValveTex (vec3_t VAxis)
{
int i;
// Skip [
GetToken (false);
for (i = 0; i < 3; i++)
{
VAxis[i] = atof(token);
GetToken (false);
}
}
Code: Select all
if (txcommand=='1' || txcommand=='2')
{ // from QuArK, the texture vectors are given directly from the three points
vec3_t TexPt[2];
int k;
vec_t dot22, dot23, dot33, mdet, aa, bb, dd;
k = txcommand-'0';
for (j=0; j<3; j++)
TexPt[1][j] = (planepts[k][j] - planepts[0][j]) * ScaleCorrection;
k = 3-k;
for (j=0; j<3; j++)
TexPt[0][j] = (planepts[k][j] - planepts[0][j]) * ScaleCorrection;
dot22 = DotProduct (TexPt[0], TexPt[0]);
dot23 = DotProduct (TexPt[0], TexPt[1]);
dot33 = DotProduct (TexPt[1], TexPt[1]);
mdet = dot22*dot33-dot23*dot23;
if (mdet<1E-6 && mdet>-1E-6)
{
aa = bb = dd = 0;
Message (MSGWARN, "Degenerate QuArK-style brush texture on line %d", scriptline - 1);
}
else
{
mdet = 1.0/mdet;
aa = dot33*mdet;
bb = -dot23*mdet;
//cc = -dot23*mdet; // cc = bb
dd = dot22*mdet;
}
for (j=0; j<3; j++)
{
tx.vecs[0][j] = aa * TexPt[0][j] + bb * TexPt[1][j];
tx.vecs[1][j] = -(/*cc*/ bb * TexPt[0][j] + dd * TexPt[1][j]);
}
tx.vecs[0][3] = -DotProduct(tx.vecs[0], planepts[0]);
tx.vecs[1][3] = -DotProduct(tx.vecs[1], planepts[0]);
}
else if (Valve220)
{
// Valve 220 texturedef
vec3_t vec;
vec_t tscale;
// Prevent division by zero
if (!scale[0])
scale[0] = 1;
if (!scale[1])
scale[1] = 1;
// FIXME: If origin brushes are in use, this is where to fix their tex alignment!!!
for (i = 0; i < 2; ++i)
{
tscale = 1 / scale[i];
VectorScale(VAxis[i], tscale, vec);
for (j = 0; j < 3; ++j)
tx.vecs[i][j] = (float)vec[j];
tx.vecs[i][3] = (float)shift[i] + DotProduct(vec3_origin, vec);
}
}
else
//
// fake proper texture vectors from QuakeEd style
//
{
vec3_t vecs[2];
int sv, tv;
vec_t ang, sinv, cosv;
vec_t ns, nt;
TextureAxisFromPlane(&f->plane, vecs[0], vecs[1]);
if (!scale[0])
scale[0] = 1;
if (!scale[1])
scale[1] = 1;
// rotate axis
if (rotate == 0)
{ sinv = 0 ; cosv = 1; }
else if (rotate == 90)
{ sinv = 1 ; cosv = 0; }
else if (rotate == 180)
{ sinv = 0 ; cosv = -1; }
else if (rotate == 270)
{ sinv = -1 ; cosv = 0; }
else
{
ang = rotate / 180 * Q_PI;
sinv = sin(ang);
cosv = cos(ang);
}
if (vecs[0][0])
sv = 0;
else if (vecs[0][1])
sv = 1;
else
sv = 2;
if (vecs[1][0])
tv = 0;
else if (vecs[1][1])
tv = 1;
else
tv = 2;
for (i=0 ; i<2 ; i++)
{
ns = cosv * vecs[i][sv] - sinv * vecs[i][tv];
nt = sinv * vecs[i][sv] + cosv * vecs[i][tv];
vecs[i][sv] = ns;
vecs[i][tv] = nt;
}
for (i=0 ; i<2 ; i++)
for (j=0 ; j<3 ; j++)
tx.vecs[i][j] = vecs[i][j] / scale[i];
tx.vecs[0][3] = shift[0];
tx.vecs[1][3] = shift[1];
}
// unique the texinfo
f->texinfo = FindTexinfo (&tx);
nummapfaces++;
};