Applying the Transforms
There are 5 main steps that are done to apply the correct transforms to the template in order to have it sampling the correct area of the texture. Each image will show the template after the transform for that step has been applied.
All images are showing the computed transforms for the Karambit Case Hardened, Seed 387. The values required to compute the transforms are...
Name | Value |
---|---|
Offset X | 0.07 |
Offset Y | 0.73 |
Rotation | 264.53 |
Scale | 0.44 |
1. Initial Translation
The template is translated using the offset x and offset y values. 0.5 is subtracted from each offset in order to center the origin point on the template.
translate x,y (offsetX - 0.5, offsetY - 0.5)
Displayed Value: translate(-0.43, 0.23)
2. Scale
The scale value is applied to the template. This scale value changes based on the weapon and skin.
Displayed Value: scale(0.44)
3. Rotation
The template is rotated around the top left corner of the template.
Displayed Value: rotate(264.53)
4. Extra offset translation
The extra offset x and y are applied to the template. This extra offset is computed by rotating a point (0.5/scale, 0.5/scale) around the origin (0, 0) by the negative rotation. The resulting rotated point coordinates are then used as the extra offset. The code used to generate the extra offset values can be found at the bottom of this page.
translate x,y (extra offset X, extra offset y)
Displayed Value: translate(-1.2395, -1.3421)
Generating the Extra Offset Values
// Modify the scale value
double invScale = 0.5f / scale; // Result: 1.136363625
// Convert the negative rotation value from degrees to radians
double rotationRad = (-rotation * (Math.PI / 180.0f)); // Result: -4.6169194
// Get cosine and sine values for the rotation
double cos = Math.cos(rotationRad); // Result: -0.09532457
double sin = Math.sin(rotationRad); // Result: 0.995446
// Rotate the scale value coordinate (invScale, invScale) and use the resulting point as our offset
double extraOffsetX = (invScale * cos) - (invScale * sin); // Result: -1.2395122
double extraOffsetY = (extraOffsetX * sin) + (invScale * cos); // Result: -1.342191