Game Development Community

MAP file format and textures offsets

by Paulo Egidio · in Torque Game Engine · 09/05/2005 (11:07 am) · 8 replies

Hi everyone...

I'm getting really angry with myself....I cant get this right!
I wnated to know the realtion between a texture offsetu and offsetv when texture mapping and the same fields in the map file format....

How does one achieve the required coordinates?

I keep getting my textures all wrong...

please, help ; )

#1
09/05/2005 (12:14 pm)
This may help.
#2
09/05/2005 (12:17 pm)
@Dirk
thanks, but ive already read that document... still I cant figure out the realtionship with Gs uv offsets and the map offsets... thanks anyway.
#3
09/05/2005 (12:49 pm)
There are two sets of values for each face.
One corresponds to the X axis, the other the Y.

Lets see : 4 values for each axis.
First 3 are an axis (for a 1:1 relationship, you'd use the normal of the face).
Last one is an offset (will move the image).

(I think the axis orient the texture, so you'd probably want them parralel to the face)

So you essentially have to calculate an axis and offset for each axis, if you know what i mean.
If you look on google, there is a very useful document on the half-life .map format which describes how to get a set of U,V coordinates for a face using these values. However, there isn't an example of the reverse, which seems to be what you're looking for :(
#4
09/05/2005 (1:03 pm)
@James : Thanks.. I'll look into it. another thing.. how does the size of the texture(512x256, 512x512...) alter this? I mean, how can I make it fit the face?
I mean, I know theres the scalex and scaley factors in the file format, but it seems like map to dif is ignoring this....
#5
09/05/2005 (5:37 pm)
Because the texture equations are in terms of texels, iirc, so the actual size of the texture has to be known for them to work properly (ie, it gets a number from 0-256, or from 0-512, or whatever instead of from 0-1). I think. :)
#6
09/06/2005 (10:35 am)
@Ben: Thanks for taking the time to look this over. Assuming I know the size of the texture, is the math used the same as the calculation of a plane? I mean, I simply calculate a coincident plane to the plane I want to texture? How would I make a bigger than face texture fit into the face I want to texture?
Sorry for the questions, but any help would be greatly appreciated Ben ; ) Btw, if there's any sourcecode in TGE that explains this, I would happly look it over and try to understand....thanks again!
#7
09/06/2005 (10:50 pm)
It's actually very simple. You take the 4d S and T vectors from the file and multiply them by the position of the point you want to texture to get the texture co-ordinates, ie

Point2F texCoord;
texCoord.x = s.x * pos.x + s.y * pos.y + s.z * pos.z + s.w;
texCoord.y = t.x * pos.x + t.y * pos.y + t.z * pos.z + t.w;
#8
09/08/2005 (7:40 am)
@Ben : Thanks! I'll see what I can get done with this info....