Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //O is the texture origin.
- uv.u = U.Dot(pos - O) / tex.width;
- uv.v = V.Dot(pos - O) / tex.height;
- //Source Map (LTA file):
- O = XYZ(61.142525, -66.681351, -2.681343);
- tex.width = 128;
- tex.height = 128;
- scale.u = 64; //U *= tex.width / scale.u
- scale.v = 128; //V *= tex.height / scale.v
- U = XYZ(0.551275, -1.359429, -1.359429);
- V = XYZ(0.679715, -0.362181, 0.637819);
- //Compiled Map (DAT file):
- center = XYZ(69.746429, -57.017303, -5.2882347)
- planes[0].normal = XYZ(0.456155, -0.690651, -0.561181);
- tris[0].pos[0] = XYZ(69.962921, -88.432220, -24.432213);
- tris[0].pos[1] = XYZ(82.267418, -75.580544, -30.247208);
- tris[0].pos[2] = XYZ(109.21921, -85.164658, 3.4558060);
- tris[0].uvs[0] = UV(0.49999994, -8.0748791e-008);
- tris[0].uvs[1] = UV(0.47826001, -5.4909982e-008);
- tris[0].uvs[2] = UV(0.33818126, 0.33818075);
- //Project UV coordinates into 3D space.
- //uv.v is negated for... reasons?
- a = XYZ(uv1.u, -uv1.v, 0.0f);
- b = XYZ(uv2.u, -uv2.v, 0.0f);
- c = XYZ(uv3.u, -uv3.v, 0.0f);
- //Find the barycentric coordinates for O, U, and V in UV space.
- //Barycentric coordinates are not clamped between 1 and -1.
- //That said, if the triangle area is nearly zero,
- //XYZ(1.0f, 0.0f, 0.0f) is returned.
- bcO = GetBaryCoords(a, b, c, XYZ(0.0f, 0.0f, 0.0f));
- bcU = GetBaryCoords(a, b, c, XYZ(1.0f, 0.0f, 0.0f));
- bcV = GetBaryCoords(a, b, c, XYZ(0.0f, 1.0f, 0.0f));
- //Convert O, U, V to world space.
- O = bcO.x * pos1 + bcO.y * pos2 + bcO.z * pos3;
- U = (bcU.x * pos1 + bcU.y * pos2 + bcU.z * pos3) - O;
- V = (bcV.x * pos1 + bcV.y * pos2 + bcV.z * pos3) - O;
- //Find the scale of U and V.
- scale.u = texwidth / U.Mag();
- scale.v = texheight / V.Mag();
Add Comment
Please, Sign In to add comment