Thread Tools Display Modes
01-14-15, 09:06 PM   #1
RobolaVirus
A Defias Bandit
Join Date: Jan 2015
Posts: 3
Model Frames - Resizing Units and Aligning them to Bottom

I'm fighting through a bit of frustrating behaviour that I hope somebody has some tips on.

I have two PlayerModels displayed on screen. Default behaviour is for the unit to fill the size of the frame it sits inside, which makes sense for the most part. But I'm looking to retain some sense of scale when displaying the two models, so goblins don't appear as big as Tauren.

Anybody have any ideas on how I can display two models on the screen and have their size appear somewhat relative to how they appear in game? The models will change, so I'll need to dynamically recalculate it based on the unit.

An additional issue I've noticed is the model is always centered inside the frame, so if I just resize the frame, the 'feet' of the models don't line up anymore. I'd like to make it look almost like they're standing on a plane.

Thoughts?!?!

Last edited by RobolaVirus : 01-14-15 at 09:10 PM. Reason: addition
  Reply With Quote
01-14-15, 09:26 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Code for your PlayerModel frames? (creation, anchoring, etc.)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-14-15, 09:37 PM   #3
RobolaVirus
A Defias Bandit
Join Date: Jan 2015
Posts: 3
Basically:

local DialogueMode = CreateFrame("Frame", "DialogueFrame")
DialogueMode:SetScale(UIParent:GetScale())
DialogueMode:SetAllPoints(UIParent)

DialogueMode.Backdrop = CreateFrame("Frame", "Backdrop", DialogueMode)
DialogueMode.Backdrop:SetFrameLevel(90)
DialogueMode.Backdrop:SetPoint("BOTTOM", DialogueMode, "BOTTOM", 0, 0)
DialogueMode.Backdrop:SetWidth(DialogueMode:GetWidth())
DialogueMode.Backdrop:SetHeight(DialogueMode:GetHeight())
DialogueMode.Backdrop.texture = DialogueMode.Backdrop:CreateTexture(nil, "BACKGROUND")
DialogueMode.Backdrop.texture:SetAllPoints(true)
DialogueMode.Backdrop.texture:SetTexture(0, 0, 0, .9)

--Create and Load the Player Frame
DialogueMode.Backdrop.ThePlayerModel = CreateFrame("PlayerModel", "ThePlayer", DialogueMode.Backdrop)
DialogueMode.Backdrop.ThePlayerModel:SetFrameLevel(99)
DialogueMode.Backdrop.ThePlayerModel:SetPoint("BOTTOM", DialogueMode.Backdrop, "BOTTOM", -(DialogueMode.Backdrop:GetWidth()/4), 0) --(DialogueMode:GetWidth()/4)
DialogueMode.Backdrop.ThePlayerModel:SetSize(600, 600)
DialogueMode.Backdrop.ThePlayerModel:SetCamDistanceScale(1.25)
DialogueMode.Backdrop.ThePlayerModel:SetFacing(.8)
DialogueMode.Backdrop.ThePlayerModel:SetUnit("player")

--Create the Target Frame
DialogueMode.Backdrop.TheTargetModel = CreateFrame("PlayerModel", "TheTarget", DialogueMode.Backdrop)
DialogueMode.Backdrop.TheTargetModel:SetFrameLevel(99)
DialogueMode.Backdrop.TheTargetModel:SetPoint("BOTTOM", DialogueMode.Backdrop, "BOTTOM", DialogueMode.Backdrop:GetWidth()/4, 0)
DialogueMode.Backdrop.TheTargetModel:SetSize(600, 600)
DialogueMode.Backdrop.TheTargetModel:SetCamDistanceScale(1)
DialogueMode.Backdrop.TheTargetModel:SetFacing(6)
DialogueMode.Backdrop.TheTargetModel:SetUnit("npc")

Last edited by RobolaVirus : 01-14-15 at 10:10 PM.
  Reply With Quote
01-14-15, 09:41 PM   #4
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
You can always reset a model to it's base camera position and base camera target position like this:

Lua Code:
  1. function model:GetBaseCameraTarget()
  2.     local modelfile = self:GetModel()
  3.     if modelfile and modelfile ~= "" then
  4.         local tempmodel = CreateFrame("PlayerModel", nil, UIParent)
  5.         tempmodel:SetModel(modelfile)
  6.         tempmodel:SetCustomCamera(1)
  7.         local x, y, z = tempmodel:GetCameraTarget()
  8.         tempmodel:ClearModel()
  9.         return x, y, z
  10.     end
  11. end
  12.  
  13. function model:SetOrientation(distance, yaw, pitch)
  14.     if self:HasCustomCamera() then
  15.         --self.distance, self.yaw, self.pitch = distance, yaw, pitch
  16.         local x = distance * math.cos(yaw) * math.cos(pitch)
  17.         local y = distance * math.sin(- yaw) * math.cos(pitch)
  18.         local z = (distance * math.sin(- pitch))
  19.         self:SetCameraPosition(x, y, z)
  20.     end
  21. end
  22.  
  23. function model:Reset()
  24.     local modelfile = self:GetModel()
  25.     self:ClearModel()
  26.     self:SetModel(modelfile)
  27.     -- With model id
  28.     --self:SetDisplayInfo(modelid)
  29.     self:SetRotation(0)
  30.     self:SetPosition(0, 0, 0)
  31.     self:RefreshCamera()
  32.     self:SetCustomCamera(1)
  33.     if self:HasCustomCamera() then
  34.         local x, y, z = self:GetCameraPosition()
  35.         local tx, ty, tz = self:GetCameraTarget()
  36.         -- Here you can use tx instead of 0
  37.         self:SetCameraTarget(0, ty, tz)
  38.         self:SetOrientation(math.sqrt(x * x + y * y + z * z), - math.atan(y / x), - math.atan(z / x))
  39.     end
  40. end

You can read more about it here:
http://www.wowinterface.com/forums/s...t=model+rotate
http://www.wowinterface.com/forums/s...t=ingame+model

And you explore what you can do with models here:
http://www.youtube.com/watch?v=egzorLE4h8E

Last edited by Resike : 01-14-15 at 10:00 PM.
  Reply With Quote
01-14-15, 09:53 PM   #5
RobolaVirus
A Defias Bandit
Join Date: Jan 2015
Posts: 3
Smile

That great! I'll have a look. Much appreciated.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Model Frames - Resizing Units and Aligning them to Bottom

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