Guest User

Untitled

a guest
Jul 20th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. //O is the texture origin.
  2.  
  3. uv.u = U.Dot(pos - O) / tex.width;
  4. uv.v = V.Dot(pos - O) / tex.height;
  5.  
  6. //Source Map (LTA file):
  7.  
  8. O = XYZ(61.142525, -66.681351, -2.681343);
  9.  
  10. tex.width = 128;
  11. tex.height = 128;
  12.  
  13. scale.u = 64; //U *= tex.width / scale.u
  14. scale.v = 128; //V *= tex.height / scale.v
  15.  
  16. U = XYZ(0.551275, -1.359429, -1.359429);
  17. V = XYZ(0.679715, -0.362181, 0.637819);
  18.  
  19. //Compiled Map (DAT file):
  20.  
  21. center = XYZ(69.746429, -57.017303, -5.2882347)
  22.  
  23. planes[0].normal = XYZ(0.456155, -0.690651, -0.561181);
  24.  
  25. tris[0].pos[0] = XYZ(69.962921, -88.432220, -24.432213);
  26. tris[0].pos[1] = XYZ(82.267418, -75.580544, -30.247208);
  27. tris[0].pos[2] = XYZ(109.21921, -85.164658, 3.4558060);
  28.  
  29. tris[0].uvs[0] = UV(0.49999994, -8.0748791e-008);
  30. tris[0].uvs[1] = UV(0.47826001, -5.4909982e-008);
  31. tris[0].uvs[2] = UV(0.33818126, 0.33818075);
  32.  
  33. //Project UV coordinates into 3D space.
  34.  
  35. //uv.v is negated for... reasons?
  36.  
  37. a = XYZ(uv1.u, -uv1.v, 0.0f);
  38. b = XYZ(uv2.u, -uv2.v, 0.0f);
  39. c = XYZ(uv3.u, -uv3.v, 0.0f);
  40.  
  41. //Find the barycentric coordinates for O, U, and V in UV space.
  42.  
  43. //Barycentric coordinates are not clamped between 1 and -1.
  44.  
  45. //That said, if the triangle area is nearly zero,
  46. //XYZ(1.0f, 0.0f, 0.0f) is returned.
  47.  
  48. bcO = GetBaryCoords(a, b, c, XYZ(0.0f, 0.0f, 0.0f));
  49. bcU = GetBaryCoords(a, b, c, XYZ(1.0f, 0.0f, 0.0f));
  50. bcV = GetBaryCoords(a, b, c, XYZ(0.0f, 1.0f, 0.0f));
  51.  
  52. //Convert O, U, V to world space.
  53.  
  54. O = bcO.x * pos1 + bcO.y * pos2 + bcO.z * pos3;
  55. U = (bcU.x * pos1 + bcU.y * pos2 + bcU.z * pos3) - O;
  56. V = (bcV.x * pos1 + bcV.y * pos2 + bcV.z * pos3) - O;
  57.  
  58. //Find the scale of U and V.
  59.  
  60. scale.u = texwidth / U.Mag();
  61. scale.v = texheight / V.Mag();
Add Comment
Please, Sign In to add comment