swipis Posted April 11, 2016 Share Posted April 11, 2016 Hello, I trying to make zoom in/out 3rd person camera, here is the code: if mouseWheelPos > 0 then if self.camDist < self.camMaxDist then self.camDist = mouseWheelPos * 1 if self.camDist > self.camMaxDist then self.camDist = self.camMaxDist numer = self.camMacDist end end elseif mouseWheelPos < 0 then if self.camDist > self.camMinDist then self.camDist = mouseWheelPos * 1 if self.camDist < self.camMinDist then self.camDist = self.camMinDist number = self.camMinDist end end end System:Print(tostring(self.camDist)) self.cam:SetPosition(Vec3(0, -self.camDist, 0)) I can say its kinda working, but need make more smoother, any tips? Quote Link to comment Share on other sites More sharing options...
cassius Posted April 11, 2016 Share Posted April 11, 2016 I don't know lua but in c++ this works // ----------------------camera zoom float deltazoom = (window->KeyDown(Key::Up) - window->KeyDown(Key::Down))*Time::GetSpeed()*0.05; float zoom = camera->GetZoom() + deltazoom; zoom = Math::Clamp(zoom, 0.2, 10.0); camera->SetZoom(zoom); Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
swipis Posted April 11, 2016 Author Share Posted April 11, 2016 Yes its working but how to make working on mouse wheel scroll? Quote Link to comment Share on other sites More sharing options...
cassius Posted April 11, 2016 Share Posted April 11, 2016 window->MouseDown(3) Something like above. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
swipis Posted April 11, 2016 Author Share Posted April 11, 2016 MouseDown(3) working same as button when I hit and hold middle mouse button is working but for scrolling not. Quote Link to comment Share on other sites More sharing options...
macklebee Posted April 11, 2016 Share Posted April 11, 2016 http://www.leadwerks.com/werkspace/topic/10444-setmouseposition-not-setting-z-value/#entry76828 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted April 11, 2016 Share Posted April 11, 2016 So how does one clamp zooming then as I suppose that's the next question when zooming with a 3rd person camera. I notice the z value keeps going so simply doing a max/min on the position used creates a stickiness. I suppose maybe reset each frame or keep an offset. Although window:SetMousePosition(x, y, 0) doesn't seem to actually reset z to 0. Quote Link to comment Share on other sites More sharing options...
macklebee Posted April 12, 2016 Share Posted April 12, 2016 see this post: http://www.leadwerks.com/werkspace/topic/14414-flush-mouse/#entry98680 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel 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.