| 3842 | } |
| 3843 | |
| 3844 | void PixelGameEngine::DrawRotatedDecal(const olc::vf2d& pos, olc::Decal* decal, const float fAngle, const olc::vf2d& center, const olc::vf2d& scale, const olc::Pixel& tint) |
| 3845 | { |
| 3846 | DecalInstance di; |
| 3847 | di.decal = decal; |
| 3848 | di.pos.resize(4); |
| 3849 | di.uv = { { 0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f} }; |
| 3850 | di.w = { 1, 1, 1, 1 }; |
| 3851 | di.tint = { tint, tint, tint, tint }; |
| 3852 | di.points = 4; |
| 3853 | di.pos[0] = (olc::vf2d(0.0f, 0.0f) - center) * scale; |
| 3854 | di.pos[1] = (olc::vf2d(0.0f, float(decal->sprite->height)) - center) * scale; |
| 3855 | di.pos[2] = (olc::vf2d(float(decal->sprite->width), float(decal->sprite->height)) - center) * scale; |
| 3856 | di.pos[3] = (olc::vf2d(float(decal->sprite->width), 0.0f) - center) * scale; |
| 3857 | float c = cos(fAngle), s = sin(fAngle); |
| 3858 | for (int i = 0; i < 4; i++) |
| 3859 | { |
| 3860 | 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); |
| 3861 | di.pos[i] = di.pos[i] * vInvScreenSize * 2.0f - olc::vf2d(1.0f, 1.0f); |
| 3862 | di.pos[i].y *= -1.0f; |
| 3863 | di.w[i] = 1; |
| 3864 | } |
| 3865 | di.mode = nDecalMode; |
| 3866 | di.structure = nDecalStructure; |
| 3867 | //vLayers[nTargetLayer].vecDecalInstance.push_back(di); |
| 3868 | |
| 3869 | |
| 3870 | GPUTask task; |
| 3871 | task.decal = decal; |
| 3872 | task.mode = nDecalMode; |
| 3873 | task.structure = nDecalStructure; |
| 3874 | task.depth = false; |
| 3875 | task.vb = { |
| 3876 | {di.pos[0].x, di.pos[0].y, 0.0f, 1.0f, 0.0f, 0.0f, tint.n}, |
| 3877 | {di.pos[1].x, di.pos[1].y, 0.0f, 1.0f, 0.0f, 1.0f, tint.n}, |
| 3878 | {di.pos[2].x, di.pos[2].y, 0.0f, 1.0f, 1.0f, 1.0f, tint.n}, |
| 3879 | {di.pos[3].x, di.pos[3].y, 0.0f, 1.0f, 1.0f, 0.0f, tint.n}, |
| 3880 | }; |
| 3881 | vLayers[nTargetLayer].vecGPUTasks.push_back(task); |
| 3882 | } |
| 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) |