Thread Tools Display Modes
05-22-13, 03:37 PM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Models

I'm trying to setup a model based by unit, and from file path like this:

Code:
model:SetUnit("player")
model:ClearModel()
model:RefreshUnit()
model:SetModel(whatevermodelfilehere)
However if i set the model by unit, and then try to overwrite it by a model file, the player model doesn't disappear, and there is no way i could get rid of it.
Any ideas why?
  Reply With Quote
05-22-13, 08:12 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Calling RefreshUnit after ClearModel is just setting it back to what it was.
  Reply With Quote
05-23-13, 02:31 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
What semlar wrote. Do not use RefreshUnit after ClearModel.

This is from https://github.com/haste/oUF/blob/ma.../portraits.lua
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

That does work properly.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
05-23-13, 03:55 AM   #4
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by semlar View Post
Calling RefreshUnit after ClearModel is just setting it back to what it was.
Oh yeah i was a rtard. I was only trying to use RefreshUnit beasause the only way i can make the unit disappear if i set it to target while i has no target.
  Reply With Quote
05-23-13, 03:56 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
But still now working properly. Here is my code snippet:
Code:
        if (aura.model == true) then
		texture:Hide()
		model:ClearModel()
		model:SetModel(PowaAurasModels[aura.texture])
	elseif (aura.modelcustom == true) then
		texture:Hide()
		if (aura.modelcustom ~= nil and aura.modelcustom ~= "") then
			if (string.find(aura.modelcustompath, "%.m2")) then
				model:ClearModel()
				model:SetModel(aura.modelcustompath)
			elseif (string.lower(aura.modelcustompath) == "player" or string.lower(aura.modelcustompath) == "target" or string.lower(aura.modelcustompath) == "focus") then
				model:ClearModel()
				model:SetUnit(string.lower(aura.modelcustompath))
			end
	        end
        end
PowaAurasModels[aura.texture] is a table with predefinied models.

aura.modelcustompath holds a model file or units like "player", "target", "focus".

EDIT: Okay i was derping around, and it seems like if i use model:SetUnit("none") instead or model:ClearModel() that does the trick. I'm not sure thats a proper API or not tho. :P

Last edited by Resike : 05-23-13 at 04:07 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Models


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