Thread: Model tilting
View Single Post
10-22-13, 06:22 AM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Model tilting

I managed to tilt ingame models in the x axis like this:



However my code only works with ~45 degree tilt yet.

Lua Code:
  1. local frame = CreateFrame("Frame", nil, UIParent)
  2. frame:SetPoint("Center", 128, 0)
  3. frame:SetWidth(512 / (2 * math.sqrt(2)))
  4. frame:SetHeight(512 / (2 * math.sqrt(2)))
  5. frame:SetAlpha(1)
  6.  
  7. local model = CreateFrame("PlayerModel", nil, frame)
  8. model:SetAllPoints(frame)
  9.  
  10. local zz = 2
  11.  
  12. function ModelBasics_UpdateModel()
  13.     model:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
  14.     model:SetRotation(math.rad(0))
  15.     model:SetAlpha(1)
  16.     model:SetCustomCamera(1)
  17.     model:SetCameraDistance(1)
  18.     local x, y, z = model:GetCameraPosition()
  19.     model:SetCameraPosition(x, y, zz)
  20.     model:SetPosition(0, 0, - (zz * zz))
  21. end
  22.  
  23. ModelBasics_UpdateModel()
  24.  
  25. local frame2 = CreateFrame("Frame", nil, UIParent)
  26. frame2:SetPoint("Center", - 128, 0)
  27. frame2:SetWidth(512)
  28. frame2:SetHeight(512)
  29. frame2:SetAlpha(1)
  30.  
  31. local model2 = CreateFrame("PlayerModel", nil, frame)
  32. model2:SetAllPoints(frame2)
  33.  
  34. function ModelBasics_UpdateModel2()
  35.     model2:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
  36.     model2:SetRotation(math.rad(0))
  37.     model2:SetAlpha(1)
  38. end
  39.  
  40. ModelBasics_UpdateModel2()

Also i'm unable to create a slider for this zz (aka the tilt value) to work properly with every value from 0-90 (0-180 would be the best) degrees. Maybe someone with more experience can help me with this?

I think this would be an awsome feature for addons.

Last edited by Resike : 10-22-13 at 06:27 AM.
  Reply With Quote