[ Converted text/html to text/plain ] When you have a polygonal face, what you usually do is take one vertex on the face and subtract it from another vertex on the face, to a get a coplanar vector (U). When you take the crossproduct between this coplanar vector and the polygon normal, you get another mutually orthogonal vector, that is also coplanar to the face (V). The first vector you created, plus this last one, make up the UV texture axis.
It doesn't really matter what the initial values for the axis are, because most of the time you have your editor application set up to allow the user to modify the texture alignment (meaning they can indirectly modify the UV axis using rotation). The only important part is that they're both coplanar to the face, and perpendicular to each other. As far as scaling is concerned, the scale of each direction (U and V) is stored implicitly in the UV axis themselves, determined by the length of these vectors. The way texture-space transformations work, the length of the UV vectors is the inverse of the scale you want. So if you want a 2X texture scale in both directions, the UV lengths will be 1/2, or 0.5. If you want a 4X scale, then UV lengths will be 0.25, etc. The same is true for smaller scales. A 0.5X scale would mean UV lengths of 2. The UV transformations work separately from one another, so it's also completely possible to have independent scaling in both directions. Offsets are stored separately from the UV axis info, but are still an integral part of the texture-space transformation. But if you're just outputting to MAP file format for compilation, you don't need to worry at all about doing the actual transformations, because the engine does that internally to compute texture coordinates. All you need to do is provide the right UV axis and offsets, and the engine will do the rest. >Can anyone explain what the math is behind if you want the texture to be perfect scale on the >face on a brush, the axes need to define a plane that is parallel to the face's plane, otherwise >you'll get stretching. Using the above method of UV axis creation, your texture will already be aligned along one of the polygon edges. What you want to do is create a copy of your UV axis, and normalize the copies. You can then compute the face extents (bounding box) in normalized texture-space, using these axis. Once you know the width and height of the box, you can divide by the texture width and height, respectively, to get U and V scaling values, respectively. Now, to get the correct offset values, take the lower-left bound of the box (values will be in texture-space still), and invert them to get your offets. So if the coordinate for this point is (3,4), then your U offset will be -3, and your V offset will be -4. The important thing about this algorithm is that you use the normalized texture axis to define your coordinate space - i.e. "lower-left" might not be what we consider the lower-left in the traditional sense, as the V axis is likely to be inverted (pointing downward in this case) to allow proper calculation of texture coordinates later, which also follow a convention of increasing downward. >Reply-To: [EMAIL PROTECTED] >To: <[EMAIL PROTECTED]> >Subject: [hlcoders] Map file format questions >Date: Thu, 17 Jun 2004 23:26:09 -0400 > >Can anyone explain what the math is behind if you want the texture to be perfect scale on the face on a brush, the axes need to define a plane that is parallel to the face's plane, otherwise you'll get stretching. > >As I have read on the VERC it states: >These axes are defined by tx1/y1/z1 and tx2/y2/z2, giving two vectors which define what's "right" and what's "up" relative to the texture - so if you wanted to go "right" 1 unit, you'd go along the first axis for 1 unit. Going "down" 2 units would be going backwards along the second axis for 2 units. How much the texture is offset along these axes is defined by toffs1 and toffs2, measured in HL units. > >I am trying to work up a way to export a polygonal soup into MAP brushes for a simple editor I am working to understand the MAP format better. I have searched the web for days, and havent come close to any sensible solution to figuring out how these axis number come to be. I know that it has to do with Normals and can sort of figure out one set but not the 2nd set needed. > >Thanks _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

