Thread: Model tilting
View Single Post
10-27-13, 11:05 AM   #33
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Vrul View Post
Yeah, cos(pi / 2) is 0 so any changes don't show while at that point. I have a similar change in the code I'm playing with. Basically the same thing:
Code:
local PITCH_LIMIT = PI / 2 - 0.05

local function OnUpdate(self, elapsed)
    local x, y = GetCursorPosition()
    local yaw = self.yaw + (x - self.x) * INCREMENT_RATIO
    local pitch = self.pitch + (y - self.y) * INCREMENT_RATIO
    if pitch > PITCH_LIMIT then
        pitch = PITCH_LIMIT
    elseif pitch < -PITCH_LIMIT then
        pitch = -PITCH_LIMIT
    end
    self:SetOrientation(self.distance, yaw, pitch)
    self.x, self.y = x, y
end
Edit: Updated initial code to reflect the changes so far.
My other tought to fix it was when "pitch >= math.pi / 2" or "pitch <= math.pi / 2" then rotate the model instead of changing the camera's location, i had no time to test it yet tho.

Last edited by Resike : 10-27-13 at 02:06 PM.
  Reply With Quote