toneddu2000 It means that
divVerent has told me where to look for the texture reference frame definition in
NetRadiant source code. To be precise in it's part that is built into
q3map2 tool.
I couldn't find it myself because of I didn't know where to look in it (NetRadiant source). And I would spend quite a lot of time looking for that. Initially I have written the exporter using my own guess on how it works. It usually worked but not always. My mistake was I supposed that reference frame origin moves to brush plane and axes are initial axes projection on it made perpendicular. I was wrong as usual
Actually it appeared to be very simple: If initially we have
Oxyz (O - point (0, 0, 0), and
x,
y,
z axes of World unmodified reference frame (
RF)), then target texture reference frame is
x and
y axes of initial
RF with two rotations applied:
1) around
z axis,
2) around new
y axis.
These transformations are such as new
RF z axis coincides with brush plane normal.
So my task to map a texture is reduced to:
1) Make transformation matrix that transforms texture
u,
v to
x and
y of brush face
RF,
2) Make transformation matrix that transforms x, y, z to x and y of brush RF,
2) According to that matrix find
X,
Y,
scaleX,
scaleY and
angle using u, v and x, y, z of each vertex of initial Blender mesh when converting it to NetRadiant brush.
Of course not any affine transformation might be split into such 5 sequential transforms. But if we assume that it does it could be gained form the matrix. I don't want explaining it here, because it is a bit complex. It's better to look at that in the exporter's source. To be brief, it's done by applying transformation to convenient unit vectors.
Also I've found out it works well when
u and
v are between 0 and 1 (inside texture square in
Blender). I've not found out why yet

.
I'm not sure I've explained it in understandable way, sorry for that!