Thread: Model tilting
View Single Post
10-22-13, 04:41 PM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Okay, thanks for you help i managed to do it, however the tilting seems kinda weird, also the model sometimes radnomly flips 180 degrees when its tilted 0 or 90 degrees. Not sure whats causing this.

Here is my code:

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, frame)
  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.  
  16. local degree = 90
  17.  
  18. local slider = CreateFrame("Slider", nil, UIParent, "OptionsSliderTemplate")
  19. slider:ClearAllPoints()
  20. slider:SetPoint("Center", UIParent, "Center", 0, 300)
  21. slider:SetMinMaxValues(90, 180)
  22. slider:SetValue(90)
  23. slider:SetValueStep(1)
  24. slider:SetScript("OnValueChanged", function(slider, value)
  25.     degree = value
  26.     ModelBasics_UpdateModel2()
  27. end)
  28.  
  29. function ModelBasics_UpdateModel2()
  30.     --model2:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
  31.     --model2:SetRotation(math.rad(0))
  32.     model2:SetCustomCamera(1)
  33.     local xx = math.pow(math.sin(math.rad(degree)), 2) * r
  34.     local zz = math.pow(math.cos(math.rad(degree)), 2) * r
  35.     model2:SetCameraPosition(xx, y, zz)
  36.     --model2:SetAllPoints(frame2)
  37. end
  38.  
  39. ModelBasics_UpdateModel2()

Last edited by Resike : 10-22-13 at 04:47 PM.
  Reply With Quote