Thread Tools Display Modes
07-01-18, 11:22 AM   #1
d87
A Chromatic Dragonspawn
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 163
<PlayerModel>:SetTransform across different resolutions

Models using SetTransform appear differently depending on game aspect ratio

sample code:
Code:
local Redraw = function(self)
        if not self.model_path then return end
    
        if type(self.model_path) == "number" then
            self:SetDisplayInfo(self.model_path)
        else
            self:SetModel(self.model_path)
        end
        self:SetTransform(unpack(self.transformations))
    end
    
    local ResetTransformations = function(self)
        self:ClearTransform()
    end
    
    local MakeModelRegion = function(self,w,h,model_path, ...)
        local pmf = CreateFrame("PlayerModel", nil, self )
        pmf:SetSize(w,h)
    
        pmf.transformations = { ... }
        pmf.model_path = model_path
    
        -- before 8.0 this was a required workaround for a bug
        -- that made models disappear after opening fullscreen map or entering cutscene
        pmf:SetScript("OnHide", ResetTransformations)
        pmf:SetScript("OnShow", Redraw)
        pmf.Redraw = Redraw
        pmf.ResetTransformations = ResetTransformations
        pmf:Redraw()
    
        return pmf
    end


    local f = MakeModelRegion(UIParent, 100, 100, "spells/blessingoffreedom_state.m2", 0.0255,0.0255,0, rad(90), rad(270), rad(270), 0.006)
    f:SetPoint("CENTER")
    f:SetBackdrop({
        bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 0,
        insets = {left = -2, right = -2, top = -2, bottom = -2},
    })
    f:SetBackdropColor(0,0,0,0.5)

    local rect = f:CreateTexture(nil, "BACKGROUND", nil, -2)
    rect:SetTexture("Interface\\BUTTONS\\WHITE8X8")
    rect:SetVertexColor(0,0,0)
    rect:SetSize(40, 40)
    rect:SetPoint("CENTER")
    local vline = f:CreateLine(nil, "BACKGROUND")
    vline:SetTexture("Interface\\BUTTONS\\WHITE8X8")
    vline:SetStartPoint("TOP", f, 0,0)
    vline:SetEndPoint("BOTTOM", f, 0,0)
    vline:SetThickness(1)
    vline:SetVertexColor(1,1,1)
    local hline = f:CreateLine(nil, "BACKGROUND")
    hline:SetTexture("Interface\\BUTTONS\\WHITE8X8")
    hline:SetStartPoint("LEFT", f, 0,0)
    hline:SetEndPoint("RIGHT", f, 0,0)
    hline:SetThickness(1)
    hline:SetVertexColor(1,1,1)


    TransformTestModel = f
    TransformTestModel:Redraw()

    -- TransformTestModel:SetScale(2)
    -- frame scales, model doesnt, but if you manually multiply
    -- offsets and model scale by frame scale it'll catch up
with these values effect will be centered on 16:9 (1920x1080).
But if you switch to 4:3 or 16:10 it'll shift and become smaller relative to black square (or larger for bigger resolutions)
  Reply With Quote

WoWInterface » PTR » PTR UI Bugs » <PlayerModel>:SetTransform across different resolutions

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off