From 4a6769cb0459294a9918584fbee388ac66285ef8 Mon Sep 17 00:00:00 2001 From: Zhincore Date: Fri, 9 Sep 2022 19:02:40 +0200 Subject: [PATCH 1/2] Improve scaleform transformation --- {stream => _stream}/pmms_texture_renderer.gfx | Bin client.lua | 13 ++++++++----- dui.lua | 4 ++-- ui/index.html | 3 +-- ui/script.js | 9 +-------- 5 files changed, 12 insertions(+), 17 deletions(-) rename {stream => _stream}/pmms_texture_renderer.gfx (100%) diff --git a/stream/pmms_texture_renderer.gfx b/_stream/pmms_texture_renderer.gfx similarity index 100% rename from stream/pmms_texture_renderer.gfx rename to _stream/pmms_texture_renderer.gfx diff --git a/client.lua b/client.lua index a0a6501..c993ac3 100644 --- a/client.lua +++ b/client.lua @@ -1557,19 +1557,22 @@ Citizen.CreateThread(function() if info.scaleform and info.scaleform.attached then if entityExists and NetworkGetEntityIsNetworked(entity) then local mediaRot = GetEntityRotation(entity, 0) + local forwardVector, rightVector, upVector = GetEntityMatrix(entity) local r = math.rad(mediaRot.z) local cosr = math.cos(r) local sinr = math.sin(r) - local posX = (info.scaleform.position.x * cosr - info.scaleform.position.y * sinr) + mediaPos.x - local posY = (info.scaleform.position.y * cosr + info.scaleform.position.x * sinr) + mediaPos.y - local posZ = info.scaleform.position.z + mediaPos.z + local offsetX = info.scaleform.position.x - info.scaleform.scale.x * 10 + local offsetY = info.scaleform.position.y + local offsetZ = info.scaleform.position.z + info.scaleform.scale.y * 10 + local pos = mediaPos + (rightVector * offsetX) + (forwardVector * offsetY) + (upVector * offsetZ) - info.scaleform.finalPosition = vector3(posX, posY, posZ) + info.scaleform.finalPosition = pos -- FIXME: This really only works for the Z rotation (yaw) - info.scaleform.finalRotation = -(mediaRot + info.scaleform.rotation) + info.scaleform.finalRotation = mediaRot + info.scaleform.rotation + elseif info.scaleform.finalPosition and info.scaleform.finalRotation then info.scaleform.finalPosition = nil info.scaleform.finalRotation = nil diff --git a/dui.lua b/dui.lua index d44a67e..7db44b9 100644 --- a/dui.lua +++ b/dui.lua @@ -256,8 +256,8 @@ function DuiBrowser:renderFrame(drawSprite) DrawScaleformMovie_3dSolid(self.sfHandle, self.scaleform.finalPosition or self.scaleform.position, self.scaleform.finalRotation or self.scaleform.rotation, - 2.0, 2.0, 1.0, - self.scaleform.scale, + 2.0, 2.0, 2.0, + self.scaleform.scale.x, self.scaleform.scale.y * (Config.dui.screenHeight / Config.dui.screenWidth), 1, 2) end end diff --git a/ui/index.html b/ui/index.html index 59926e8..529c731 100644 --- a/ui/index.html +++ b/ui/index.html @@ -294,8 +294,7 @@ - - +