| 3883 | |
| 3884 | |
| 3885 | void PixelGameEngine::DrawPartialRotatedDecal(const olc::vf2d& pos, olc::Decal* decal, const float fAngle, const olc::vf2d& center, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::vf2d& scale, const olc::Pixel& tint) |
| 3886 | { |
| 3887 | DecalInstance di; |
| 3888 | di.decal = decal; |
| 3889 | di.points = 4; |
| 3890 | di.tint = { tint, tint, tint, tint }; |
| 3891 | di.w = { 1, 1, 1, 1 }; |
| 3892 | di.pos.resize(4); |
| 3893 | di.pos[0] = (olc::vf2d(0.0f, 0.0f) - center) * scale; |
| 3894 | di.pos[1] = (olc::vf2d(0.0f, source_size.y) - center) * scale; |
| 3895 | di.pos[2] = (olc::vf2d(source_size.x, source_size.y) - center) * scale; |
| 3896 | di.pos[3] = (olc::vf2d(source_size.x, 0.0f) - center) * scale; |
| 3897 | float c = cos(fAngle), s = sin(fAngle); |
| 3898 | for (int i = 0; i < 4; i++) |
| 3899 | { |
| 3900 | di.pos[i] = pos + olc::vf2d(di.pos[i].x * c - di.pos[i].y * s, di.pos[i].x * s + di.pos[i].y * c); |
| 3901 | di.pos[i] = di.pos[i] * vInvScreenSize * 2.0f - olc::vf2d(1.0f, 1.0f); |
| 3902 | di.pos[i].y *= -1.0f; |
| 3903 | } |
| 3904 | |
| 3905 | olc::vf2d uvtl = source_pos * decal->vUVScale; |
| 3906 | olc::vf2d uvbr = uvtl + (source_size * decal->vUVScale); |
| 3907 | di.uv = { { uvtl.x, uvtl.y }, { uvtl.x, uvbr.y }, { uvbr.x, uvbr.y }, { uvbr.x, uvtl.y } }; |
| 3908 | di.mode = nDecalMode; |
| 3909 | di.structure = nDecalStructure; |
| 3910 | vLayers[nTargetLayer].vecDecalInstance.push_back(di); |
| 3911 | } |
| 3912 | |
| 3913 | void PixelGameEngine::DrawPartialWarpedDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint) |
| 3914 | { |