Thread: Model tilting
View Single Post
10-24-13, 07:59 AM   #15
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Bad news, seems like you can only set custom camera for the model if Model:HasCustomCamera() returns true.

Also managed to fix the flipping issue like this:

Lua Code:
  1. local frame2 = CreateFrame("Frame", nil, UIParent)
  2. frame2:SetPoint("Center", - 128, 0)
  3. frame2:SetWidth(512)
  4. frame2:SetHeight(512)
  5. frame2:SetAlpha(1)
  6.  
  7. local model2 = CreateFrame("PlayerModel", nil, frame2)
  8. model2:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
  9. model2:SetAlpha(1)
  10. model2:SetAllPoints(frame2)
  11. model2:SetCustomCamera(1)
  12. local x, y, z = model2:GetCameraPosition()
  13. local r = math.sqrt((x * x) + (z * z))
  14. print(x, y, z, r)
  15. print(model2:HasCustomCamera())
  16.  
  17. --model2:SetLight(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
  18.  
  19. local degree = 90
  20.  
  21. local slider = CreateFrame("Slider", nil, UIParent, "OptionsSliderTemplate")
  22. slider:ClearAllPoints()
  23. slider:SetPoint("Center", UIParent, "Center", 0, 300)
  24. slider:SetMinMaxValues(0, 90)
  25. slider:SetValue(0)
  26. slider:SetValueStep(1)
  27. slider:SetScript("OnValueChanged", function(slider, value)
  28.     degree = value
  29.     ModelBasics_UpdateModel2()
  30. end)
  31.  
  32. function ModelBasics_UpdateModel2()
  33.     --model2:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
  34.     --model2:SetRotation(math.rad(0))
  35.     model2:SetCustomCamera(1)
  36.     local xx = math.sin(math.rad(degree)) * r
  37.     local zz = math.cos(math.rad(degree)) * r
  38.     if xx > 0.1 then
  39.         model2:SetCameraPosition(xx, y, zz)
  40.     else
  41.         model2:SetCameraPosition(0.1, y, zz)
  42.     end
  43.     --model2:SetCameraTarget(0, y, 0)
  44.     --model2:SetAllPoints(frame2)
  45. end
  46.  
  47. --model2:SetCamera(2)
  48. ModelBasics_UpdateModel2()

Last edited by Resike : 10-24-13 at 08:30 AM.
  Reply With Quote