M0lD Posted January 17, 2018 Share Posted January 17, 2018 how do i collect input from the mouse scroll? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 17, 2018 Share Posted January 17, 2018 The Z index from MousePosition stores the mouse wheel. https://www.leadwerks.com/learn?page=API-Reference_Object_Window_GetMousePosition Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted January 17, 2018 Share Posted January 17, 2018 FYI the z index of mouseposition is cumulative. To get proper values you could do something like: local oldWheelPos = 0.0 if self.currentMousePos ~= nil then oldWheelPos = self.currentMousePos.z end self.currentMousePos = window:GetMousePosition() self.currentMousePos.x = Math:Round(self.currentMousePos.x) self.currentMousePos.y = Math:Round(self.currentMousePos.y) local newWheelPos = (self.currentMousePos.z - oldWheelPos) * 0.1 if newWheelPos > 0.0 or newWheelPos < 0.0 then self.curZoom = self.curZoom + newWheelPos if self.curZoom < self.maxZoom then self.curZoom = self.maxZoom elseif self.curZoom > self.minZoom then self.curZoom = self.minZoom end end 2 Quote Link to comment Share on other sites More sharing options...
M0lD Posted January 17, 2018 Author Share Posted January 17, 2018 Thk Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 18, 2018 Share Posted January 18, 2018 Nice script GorzenDev. That would be a nice addition to the documentation samples. Little side note: if self.curZoom < self.maxZoom then self.curZoom = self.maxZoom elseif self.curZoom > self.minZoom then self.curZoom = self.minZoom end could be shortened to self.curZoom = Math:Clamp(self.curZoom, self.maxZoom, self.minZoom) 1 Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted January 18, 2018 Share Posted January 18, 2018 Does clamp get a proper result when negative values are used? Since in that case the self.maxZoom would be the smallest value of the 2. maiby flip them around ? During optimisation i did at one point use clamp but got a bad result so reverted it back and never looked at it again. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 18, 2018 Share Posted January 18, 2018 I have a similar situation with camera min/max angles where this works fine. For camera rotation the max angle is actually negative (although the name would suggest otherwise). Based on your if statements and the inversed use of max/min zoom, I figured that for the zooming something similar would be happening. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.