Thread Tools Display Modes
09-22-19, 04:46 AM   #1
Alaror
A Murloc Raider
Join Date: Mar 2019
Posts: 6
Question PlayerModel:SetTransform bug

Alright, I've come across a really bizarre bug. Hoping someone can provide some insight cause I'm at a loss lol.

I'm trying to display some spell effects on the screen using the PlayerModel frame. I'd also like to adjust how it's displayed using SetTransform. What's going wrong is that when I initially enter the game (from the character select screen) the model won't display if I'm calling SetTransform. If I reload the UI using /reload it will display. Whenever I exit and reenter the game the same problem happens. If I don't use SetTransform the model displays perfectly fine immediately after entering the game without requiring a /reload.

To reproduce it I put together a test addon that has nothing but a single file with the code below. I also went ahead and disabled all the other addons in case one of them was causing a problem. It's still happening, but I figured it's worth having someone else try it out to see if it works for them. You should see a fire animation play in the middle of your screen.


Code:
local frame = CreateFrame("PlayerModel", nil, UIParent, nil)
frame:SetSize(500, 500)
frame:SetPoint("CENTER", UIParent, "CENTER")
frame:SetModel(1087046)
frame:SetTransform(0.1025, 0.1025, 0, 0, 0, 0, 0.1)
Thanks in advance for any help you can provide!
  Reply With Quote
09-22-19, 08:54 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,857
Have you tried to delay the set so the game has time to "get ready". Something like:

Lua Code:
  1. local frame = CreateFrame("PlayerModel", nil, UIParent, nil)
  2. frame:SetSize(500, 500)
  3. frame:SetPoint("CENTER", UIParent, "CENTER")
  4. frame:SetScript("OnEvent", function(self)
  5.     self:UnregisterAllEvents()
  6.     self:SetModel(1087046)
  7.     self:SetTransform(0.1025, 0.1025, 0, 0, 0, 0, 0.1)
  8. end)
  9. frame:RegisterEvent("PLAYER_ENTERING_WORLD")
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-22-19, 08:56 AM   #3
d87
A Chromatic Dragonspawn
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 163
Models and SetTransform especially are riddled with bugs, so don't use it if you can.
Try calling SetTransform a little later than SetModel, like in the next render frame or just after 30ms
Also don't use SetTransform on anything you're going to publish, because it gives different results depending on client resolution

Last edited by d87 : 09-22-19 at 08:59 AM.
  Reply With Quote
09-22-19, 09:01 AM   #4
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
I am currently struggeling with the PlayerModel frame myself.
(See https://www.wowinterface.com/forums/...ad.php?t=57514)

Where did you even find a documentation of SetTransform()?
  Reply With Quote
09-22-19, 11:47 AM   #5
Alaror
A Murloc Raider
Join Date: Mar 2019
Posts: 6
Thanks for the responses, was a huge help. You were both right about needing to delay calling SetTransform after setting the model. Went with a timer with a duration of 0.01, did the trick just fine. I also discovered that SetTransform needs to be called whenever the model is changed with SetModel. The transform values seem to get reset. Something else I noticed is that there might be an issue with using frame:Show() and frame:SetTransform() at the same time. Didn't test it further since a timer of 0.01 updates faster than anyone would notice, but I thought I'd still mention it in case someone comes across this thread in the future.

d87: could you provide some more insight about it being different based on the client resolution? What kind of differences are there? If you know of a thread or something where SetTransform's quirks are discussed that'd be awesome.

LudiusMaximus: I feel your pain. Not sure why SetTransform isn't on the wiki yet. I discovered it while digging around WeakAura's files to figure out what they were doing since I was having so many problems myself. I don't see them doing any of the timing stuff that I ended up having to do, but maybe they're just doing it in a different part of the code I didn't look at. Here's the actual SetTransform implementation I'm using; might give you some insight:

Code:
local offset = (0.205 * size) / 1000

self:ClearTransform()
self:SetTransform(
    offset, offset, 0,
    rad(rotation.X), rad(rotation.Y), rad(rotation.Z),
    scale / 1000)
The reason I'm setting offset the way I am is that the models seem to appear in the bottom left corner by default. Through testing I found that 0.205 * size puts the model in the center (or really close to it). If the frame's width and height is different then you'd need to calculate each individually. I'm still testing though, so I'm not sure it'll work for every model. Also, scale is a value between 1-1000. Just feel it's more convenient to work with whole numbers instead of decimals.

Last edited by Alaror : 09-22-19 at 12:04 PM.
  Reply With Quote
09-22-19, 09:28 PM   #6
d87
A Chromatic Dragonspawn
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 163
could you provide some more insight about it being different based on the client resolution? What kind of differences are there? If you know of a thread or something where SetTransform's quirks are discussed that'd be awesome.
It's different not exactly for resolution, but aspect ratio. You can see for yourself if you switch to 4:3 or something that's not your usual. Model will be offset a little from the usual spot
Also if you scale SetTransform model's frame, model won't scale with it. Normal PlayerModel is doing that

I don't know any threads, it's just something i found when i wanted to use it in my addon
  Reply With Quote
09-23-19, 01:11 AM   #7
Alaror
A Murloc Raider
Join Date: Mar 2019
Posts: 6
Hmmm interesting, wouldn't have thought of that so I'm glad you brought it up. I'm wondering if it'd be possible to adjust the offset based on the player's aspect ratio? Might give that a shot cause I'd really prefer using SetTransform.

Good to know about the scaling issue too. Thanks again!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » PlayerModel:SetTransform bug

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