View Full Version : Help - Planar Texture maping

Brent Fogarty
07-06-2001, 08:52 PM
I have a scene full of triangles that I want to generate TexCoords for and I thought of using Planar texture maping but I'm unsure how to generate the u_axis and v_axis vectors.
Below is the equations for generating TexCoords for Quake2 maps (from flipcode).

u = x * u_axis.x + y * u_axis.y + z * u_axis.z + u_offset
v = x * v_axis.x + y * v_axis.y + z * v_axis.z + v_offset

If the above equations work all I need to know is how to get u_axis and v_axis.

Any help would be greatly appreciated

07-07-2001, 03:57 AM
Well, in Quake 2 those vectors are hand selected by the level makers as they apply the textures to surfaces. Granted, its usually done through a GUI so the level maker normally never sees those vectors as vectors, but rather as the position and rotation of the texture. Now there is one thing the level editor (the actual code, not the person) does automatically, and that is choose an initial (u,v) for a texture. The Level maker, then normally only scales, translates or rotates the texture about the normal vector N. To get that kind of initial (u,v), you very simply use the normal of the polygon to determine the orientation of the texture (technically you form a 2D basis that is perpendicular to the normal and consistent to some general alignment rules). Next, you use that basis to convert the space coordinates of the vertices into texture coordinates letting u_offset=v_offset=0. And you are done.

[This message has been edited by DFrey (edited 07-07-2001).]

Brent Fogarty
07-07-2001, 10:35 PM
Thanks DFrey