omid3098 10 Posted May 6, 2013 Share Posted May 6, 2013 Hi. I am trying to control camera FOV using two keys in Lua (to increase and decrese) but I cant access to main Camera FOV. I have a CameraManager node in the scene and the code is something like this: require("Scripts/class") require("Scripts/constants/keycodes") require("Scripts/hooks") local class=CreateClass(...) function class:CreateObject(model) function object:DHook() if KeyDown(KEY_U)==1 then CameraZoom(45.0) -- or what? how should I use CameraZoom? end end AddHook("Flip" , object.DHook ) function object:Free() RemoveHook("Flip" , object.DHook ) self.super:Free() end end there were CameraZoom(cam,value) in the forum but I dont know what is cam or how I can create that to use Camera zoom. actually tried cam=fw.main.camera but that is for framework I think. I did not write other parts of this code and also I don't have access to our programmer. and I'm not dump thanks before Quote Link to post Share on other sites
Josh 9,826 Posted May 6, 2013 Share Posted May 6, 2013 I'm assuming you guys are using the framework class: http://www.leadwerks.com/werkspace/page/Documentation/le2/_/command-reference/framework/getlayercamera-r222 http://www.leadwerks.com/werkspace/page/Documentation/le2/_/command-reference/framework/getframeworklayer-r221 Quote Link to post Share on other sites
omid3098 10 Posted May 6, 2013 Author Share Posted May 6, 2013 (edited) Ok. I'm a dump. would you please describe more? CameraZoom is only for C and C++ and there is nothing for LUA. I just have to open Editor and edit some LUA codes to play with camera and do some trailer. Edit: this code gives "Malformed number near 0.5f" error. CameraZoom(camera, 0.5f) Edited May 6, 2013 by omid3098 Quote Link to post Share on other sites
Josh 9,826 Posted May 6, 2013 Share Posted May 6, 2013 You do not need to include the 'f' in the float value. Quote Link to post Share on other sites
omid3098 10 Posted May 6, 2013 Author Share Posted May 6, 2013 it says value at index (1) is not an object Quote Link to post Share on other sites
Josh 9,826 Posted May 6, 2013 Share Posted May 6, 2013 Your programmer is going to have to do this. I can't debug a program with one line of code. Quote Link to post Share on other sites
omid3098 10 Posted May 7, 2013 Author Share Posted May 7, 2013 Programmer is doing bugfix since more than 2 months and I don't have permission to access him. this is my CameraManager.lua: require("Scripts/class") require("Scripts/constants/keycodes") require("Scripts/hooks") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) --object.cameraFOV = CameraZoom(camera,1.0) SetFarDOFRange(2,5) SetFarDOFStrength(1) SetFarDOF(1) function object:DHook() -- Test if keys are working if KeyDown(KEY_U)==1 then SetFarDOF(1) end if KeyDown(KEY_Y)==1 then SetFarDOF(0) end end AddHook("Flip" , object.DHook ) function object:Free() RemoveHook("Flip" , object.DHook ) self.super:Free() end end I can enable/Disable DOF with keys but I have no Ideas how to access camera FOV. Quote Link to post Share on other sites
omid3098 10 Posted May 7, 2013 Author Share Posted May 7, 2013 now it works using this code: require("Scripts/class") require("Scripts/constants/keycodes") require("Scripts/hooks") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) function object:Update() if KeyDown(KEY_UP)==1 then CameraZoom(fw.main.camera,0.5) end if KeyDown(KEY_DOWN)==1 then CameraZoom(fw.main.camera,1.0) end end function object:Free() self.super:Free() end end Quote Link to post Share on other sites
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.