You can always reset a model to it's base camera position and base camera target position like this:
Lua Code:
function model:GetBaseCameraTarget()
local modelfile = self:GetModel()
if modelfile and modelfile ~= "" then
local tempmodel = CreateFrame("PlayerModel", nil, UIParent)
tempmodel:SetModel(modelfile)
tempmodel:SetCustomCamera(1)
local x, y, z = tempmodel:GetCameraTarget()
tempmodel:ClearModel()
return x, y, z
end
end
function model:SetOrientation(distance, yaw, pitch)
if self:HasCustomCamera() then
--self.distance, self.yaw, self.pitch = distance, yaw, pitch
local x = distance * math.cos(yaw) * math.cos(pitch)
local y = distance * math.sin(- yaw) * math.cos(pitch)
local z = (distance * math.sin(- pitch))
self:SetCameraPosition(x, y, z)
end
end
function model:Reset()
local modelfile = self:GetModel()
self:ClearModel()
self:SetModel(modelfile)
-- With model id
--self:SetDisplayInfo(modelid)
self:SetRotation(0)
self:SetPosition(0, 0, 0)
self:RefreshCamera()
self:SetCustomCamera(1)
if self:HasCustomCamera() then
local x, y, z = self:GetCameraPosition()
local tx, ty, tz = self:GetCameraTarget()
-- Here you can use tx instead of 0
self:SetCameraTarget(0, ty, tz)
self:SetOrientation(math.sqrt(x * x + y * y + z * z), - math.atan(y / x), - math.atan(z / x))
end
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