Texture Mapping(Planar mapping)
Please help me, this is doing my head in!!
Below is an extract from an Unreal T3D file i am trying to convert to AC3D.
The geometry looks fine, but i am having touble with calculating the Texture coords for each poly.
Begin Polygon Item=Cap Texture=Terminal_A01
Origin +00212.077362,+00512.000000,-00128.000000
Normal +00000.000000,+00000.000000,-00001.000000
TextureU -00000.707107,-00000.707107,+00000.000000
TextureV -00000.707107,+00000.707107,+00000.000000
Vertex +00212.077362,+00512.000000,-00128.000000
Vertex +00512.000000,+00212.077347,-00128.000000
Vertex +00512.000000,-00212.077393,-00128.000000
Vertex +00212.077255,-00512.000061,-00128.000000
Vertex -00212.077347,-00512.000000,-00128.000000
Vertex -00512.000061,-00212.077179,-00128.000000
Vertex -00511.999969,+00212.077438,-00128.000000
Vertex -00212.077347,+00512.000000,-00128.000000
End Polygon
Origin is the first vertex in the poly.
TextureU and V are the Vectors describing the cordinate system(Normalized)
Here's my code(it doesn't work)
//temp is the vertex - the origin
temp.x = (vertex.x - origin.x);
temp.y = (vertex.y - origin.y);
temp.z = (vertex.z - origin.z);
U = Dot(temp,textureU)/128;//128 is the Bitmap Width
V = Dot(temp,textureV)/128;//128 is the Bitmap Height
Any ideas? The internet is hopeless!
Thanx Mark
|