WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Portrait:SetModelScale(number) (https://www.wowinterface.com/forums/showthread.php?t=40298)

leizeQ 05-27-11 01:34 AM

Portrait:SetModelScale(number)
 
Hi.

I am trying to change the model scale of the player portrait.
i've tried to use the Portrait:PostUpdate() function but without success.

Code:

self.Portrait.PostUpdate = function(self, unit) self:SetModelScale(0.5) end
is it overwritten somewhere else?, is the SetModelScale not the right function to use? or am I missing some other stuff.

thanks.

edit: already answered, please disregard. i can post the solution if anyone has interest

haste 05-27-11 07:50 AM

Quote:

Originally Posted by leizeQ (Post 238166)
edit: already answered, please disregard. i can post the solution if anyone has interest

Posting the solution is always a good idea. It potentially prevents the same question in the future and allows potentially better solutions to be posted.

leizeQ 05-28-11 04:46 AM

so my intention was to use a portrait for the player without any border or background and placed on the bottom of the screen. but it was zoomed in too much so it was visible where are the borders of portrait frame.

so here are 2 solutions i've found/been told:

1. use Model:SetCamera(1) - this changes the whole portrait to something similar as in character screen (whole body seen), and it should be zoom-able

2. use PlayerModel:SetPortraitZoom(number)

zork 06-11-11 07:56 AM

Regarding models. It got me thinking because I refreshed my model viewer today.



To get the camera zoom to the face of a model you have to use

Code:

SetPortraitZoom = 1
To zoom out but stay focus on the face area you can then use

Code:

SetCamDistanceScale = x
The other important values are SetPosition and SetRotation. Both are pretty obvious.

I still have the worgen male problem. Gonna try sth.

zork 06-11-11 08:00 AM

*edit*

IT WORKED...lol on first try.

@haste the "SetCamera 0" settings seems to be deprecated. Try this:

I changed the portrait.lua and male worgen portraits are now fixed.

Seems like: SetPortraitZoom is the new SetCamera.

lua Code:
  1. local Update = function(self, event, unit)
  2.     if(not unit or not UnitIsUnit(self.unit, unit)) then return end
  3.  
  4.     local portrait = self.Portrait
  5.     if(portrait.PreUpdate) then portrait:PreUpdate(unit) end
  6.  
  7.     if(portrait:IsObjectType'Model') then
  8.         local guid = UnitGUID(unit)
  9.         if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
  10.             portrait:SetModelScale(4.25)
  11.             portrait:SetPosition(0, 0, -1.5)
  12.             portrait:SetModel"Interface\\Buttons\\talktomequestionmark.mdx"
  13.         elseif(portrait.guid ~= guid or event == 'UNIT_MODEL_CHANGED') then
  14.             portrait:SetUnit(unit)
  15.             --portrait:SetCamera(0)
  16.             portrait:SetPortraitZoom(1)
  17.             portrait.guid = guid
  18.         else
  19.             --portrait:SetCamera(0)
  20.             portrait:SetPortraitZoom(1)
  21.         end
  22.     else
  23.         SetPortraitTexture(portrait, unit)
  24.     end
  25.  
  26.     if(portrait.PostUpdate) then
  27.         return portrait:PostUpdate(unit)
  28.     end
  29. end

First worgen male portrait working correctly :p

Dawn 06-11-11 09:09 AM

Delete your post, ASAP! Otherwise, I predict even more of those hairy beasts flooding the game, soon! NOooooO! :p

Aftermathhqt 06-11-11 10:11 AM

Not need for so much code! this works perfect.

LUA Code:
  1. local function WorgenFix(self, unit)
  2.     if self:GetModel() and self:GetModel().find and self:GetModel():find("worgenmale") then
  3.         self:SetCamera(1)
  4.     end
  5. end

And add to your portraits.

LUA Code:
  1. Portrait.PostUpdate = WorgenFix

zork 06-11-11 10:47 AM

@Game
Sorry but my post is a bugfix for the oUF/elements/portrait.lua that haste is hopefully going to implement. I have no Github account otherwise I would post it there. Maybe someone else can.

Aftermathhqt 06-11-11 05:48 PM

Quote:

Originally Posted by zork (Post 239192)
@Game
Sorry but my post is a bugfix for the oUF/elements/portrait.lua that haste is hopefully going to implement. I have no Github account otherwise I would post it there. Maybe someone else can.

Oh, i through it was an OnUpdate one :P

haste 06-12-11 11:44 AM

zork, are you able to post your changes as a git format-patch (or diff)? That would allow me to commit the changes in your name. If it's too much hassle, let me know and I'll merge the changes in manually.

zork 06-12-11 12:33 PM

I registered and tried to pull a change request. No sure if I made that correct.

Aftermathhqt 06-12-11 12:35 PM

Quote:

Originally Posted by zork (Post 239260)
I registered and tried to pull a change request. No sure if I made that correct.

I did it for you :3

@ Haste did a pull request.

zork 06-12-11 12:41 PM

Thank you. :)

haste 06-12-11 01:03 PM

You both did it actually. With one minute between :P. The change is "merged" onto the API-6 branch now.

zork 06-14-11 01:51 PM

I spent some time now testing. Doing dungeon in the dungeonfinder. I have to push another fix my first post was OK, but incomplete. Swapping between questionmark and model bugs so I had to fix it.

This works for me currently in any situation (going from mark to model or from model to mark or model to model)

lua Code:
  1. local Update = function(self, event, unit)
  2.     if(not unit or not UnitIsUnit(self.unit, unit)) then return end
  3.  
  4.     local portrait = self.Portrait
  5.     if(portrait.PreUpdate) then portrait:PreUpdate(unit) end
  6.  
  7.     if(portrait:IsObjectType'Model') then
  8.         local guid = UnitGUID(unit)
  9.         if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
  10.             portrait:ClearModel()
  11.             portrait:SetModel('interface\\buttons\\talktomequestionmark.m2')
  12.             portrait:SetCamDistanceScale(0.25)
  13.             portrait:SetPortraitZoom(0)
  14.             portrait:SetPosition(0,0,0.5)          
  15.             portrait.guid = nil
  16.         elseif(portrait.guid ~= guid or event == 'UNIT_MODEL_CHANGED') then
  17.             portrait:ClearModel()
  18.             portrait:SetUnit(unit)
  19.             portrait:SetCamDistanceScale(1)
  20.             portrait:SetPortraitZoom(1)
  21.             portrait:SetPosition(0,0,0)
  22.             portrait.guid = guid
  23.         end
  24.     else
  25.         SetPortraitTexture(portrait, unit)
  26.     end

The else condition can be removed entirely.
What was important is to reset the GUID on questionmark (because it would not change back if you had the GUI, got mark later. It would stuck in mark)
To make the model values apply the model must be cleared. Doesn't work otherwise.

zork 06-17-11 08:04 AM

To bad so many of the model api functions are not documented.

But there is a function that sounds interesting.

# PlayerModel:RefreshCamera() - This function is not yet documented
# PlayerModel:RefreshUnit() - Updates the model's appearance to match that of its unit. Used in the default UI's inspect window when the player's target changes (changing the model to match the "new appearance" of the unit "target") or when the UNIT_MODEL_CHANGED event fires for the inspected unit (updating the model's appearance to reflect changes in the unit's equipment or shapeshift form).

More:
http://wowprogramming.com/docs/widgets/PlayerModel

zork 10-17-11 02:51 PM

I revised my code and found the final bug.

Reseting the camdistancescale vales etc is needed before reseting the model otherwise it will not reload properly if you change from a gnome to a dwarf etc.

I originally thought that clearing the model would wipe the model attributes but that is not the case. The attributes have to be set before the model rendering.

lua Code:
  1. local Update = function(self, event, unit)
  2.     if(not unit or not UnitIsUnit(self.unit, unit)) then return end
  3.  
  4.     local portrait = self.Portrait
  5.     if(portrait.PreUpdate) then portrait:PreUpdate(unit) end
  6.  
  7.     if(portrait:IsObjectType'Model') then
  8.         local guid = UnitGUID(unit)
  9.         if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
  10.             portrait:SetCamDistanceScale(0.25)
  11.             portrait:SetPortraitZoom(0)
  12.             portrait:SetPosition(0,0,0.5)
  13.             portrait:ClearModel()
  14.             portrait:SetModel('interface\\buttons\\talktomequestionmark.m2')
  15.             portrait.guid = nil
  16.         elseif(portrait.guid ~= guid or event == 'UNIT_MODEL_CHANGED') then
  17.             portrait:SetCamDistanceScale(1)
  18.             portrait:SetPortraitZoom(1)
  19.             portrait:SetPosition(0,0,0)
  20.             portrait:ClearModel()
  21.             portrait:SetUnit(unit)
  22.             portrait.guid = guid
  23.         end
  24.     else
  25.         SetPortraitTexture(portrait, unit)
  26.     end
  27.  
  28.     if(portrait.PostUpdate) then
  29.         return portrait:PostUpdate(unit)
  30.     end
  31. end


All times are GMT -6. The time now is 08:52 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI