# Quake II texture positioning from brush primitives .MAP format

This topic is 4869 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi folks, As an academic exercise that may or may not bear fruit, I'm trying to work out how I can make a Quake II BSP tool that doesn't bork rotated and scaled textures on faces at funny angles. I've been looking at stuff, and it appears that using the Brush Primitives map format might give me the answer. However, the mathematics involved is poorly documented, so I hope someone here can give me an answer... Let n be a unit vector normal to the textured plane. Let s be a unit vector orthogonal to n and lying in the xy plane. Let t = n ^ s. Let s and t be the axis vectors of a 2-dimensional coordinate system lying in the textured plane. Let u and v be the axis vectors of a 2-dimensional coordinate system describing a position on the texture. Now, the brush primitives format provides me with a homogenous matrix P that will transform a point a in (s,t) space into a point b in (u,v) space, right? b = Pa But how do I use this transform to generate the u- and v- axes & offsets needed for compiling a QII BSP file? Am I wrong about what the matrix P represents? What I need to generate... abandoning the variables declared above, it seems that I need to generate a matrix A and vector t0 so that if I have a point r somewhere in space, the texture coordinates corresponding to that point are given by the equation: t - t0 = Pr Now, since t must be such that tz = 0 (because a texture is two-dimensional) so that means that t0x = 0 and that the bottom row of A has to be [0,0,0]. That means that A can't be the same as the matrix P that the brush primitives format gives me, because the bottom row of P = [0,0,1]... Please help me out here...

##### Share on other sites
Quote:
 Original post by peter-bNow, the brush primitives format provides me with a homogenous matrix P that will transform a point a in (s,t) space into a point b in (u,v) space, right?b = PaBut how do I use this transform to generate the u- and v- axes & offsets needed for compiling a QII BSP file? Am I wrong about what the matrix P represents?

From what I can tell you are correct about the matrix P. Keep in mind that whenever you have a transformation from one space to another, the transformation matrix will contain the axis defining the destination space relative to the source space. So in this case, P contains the u-axis and v-axis relative to (s,t) space. The important thing about (s,t) space is that it's defined the same way in both the map editor and the BSP compiler, or else texture mapping won't be consistent. Other than that, just extract the u-axis, v-axis, and shift/offset amounts:
( ( Ux Vx Sx ) ( Uy Vy Sy ) )

##### Share on other sites
Quote:
 Original post by ZipsterThe important thing about (s,t) space is that it's defined the same way in both the map editor and the BSP compiler, or else texture mapping won't be consistent.

Aren't n, s & t just a right-handed set where s is normal to the z-axis?

##### Share on other sites
Quote:
 Original post by peter-bAren't n, s & t just a right-handed set where s is normal to the z-axis?

From what I've read here, s and t are created by rotating the world Y and Z axis until they are oriented to the face plane. Then u and t are relative to this system (what they refer to as "Axis Base").

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 14
• 12
• 29
• 11
• 44
• ### Forum Statistics

• Total Topics
634856
• Total Posts
3019661
×