Jump to content
RygtY

SetMousePosition not setting z value

Recommended Posts

I'm not sure if this is a bug but the SetMousePosition function that takes in three parameters, the x value, y value, and z value, does not properly set the z value of the mouse position.

 

One can test this using this code snippet.

 

self.window = Window:GetCurrent()
self.window:SetMousePosition(50.0,50.0,10.0)
System:Print(self.window:GetMousePosition():ToString())

 

The z value still remains 0.0

Share this post


Link to post

Thanks for clearing it up. I guess I'll have to go with an alternative way to perform zooming.

Share this post


Link to post

function App:Start()

self.window = Window:Create()

self.context = Context:Create(self.window)

self.world = World:Create()

self.camera = Camera:Create()

self.camera:Move(0,0,-3)

local light = DirectionalLight:Create()

light:SetRotation(35,35,0)

 

self.model = Model:Box()

self.model:SetColor(0.0,0.0,1.0)

 

self.prevZ = self.camera:GetPosition(true).z

self.posZ = 0

 

return true

end

 

function App:Loop()

if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

 

self.model:Turn(0,Time:GetSpeed(),0)

 

local div = 5

self.posZ = Math:Curve(self.prevZ + (self.window:GetMousePosition().z/div), self.posZ, div/Time:GetSpeed())

self.camera:SetPosition(0,0, self.posZ)

 

Time:Update()

self.world:Update()

self.world:Render()

 

self.context:SetBlendMode(Blend.Alpha)

self.context:DrawText("Mouse Wheel Position: "..self.window:GetMousePosition().z, 2, 2)

self.context:DrawText(string.format("Camera Z Position: %.2f",self.posZ), 2, 22)

self.context:SetBlendMode(Blend.Solid)

 

self.context:Sync()

 

return true

end

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...