Jump to content

Control camera FOV with keys [LE2] [Solved]


omid3098
 Share

Recommended Posts

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 smile.png

thanks before

Omid Saadat

OD Arts Blog

 

AMD Phenom II X4 940 - Geforce 8800GTS - 4GB RAM - XP x86

AMD 6000+ - Geforce 9800 GT - 2GB RAM - XP x86 (Home pc)

Intel Core i7 - Geforce 310M - 4GB Ram - Win7 x64 (Laptop)

Link to comment
Share on other sites

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

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 by omid3098

Omid Saadat

OD Arts Blog

 

AMD Phenom II X4 940 - Geforce 8800GTS - 4GB RAM - XP x86

AMD 6000+ - Geforce 9800 GT - 2GB RAM - XP x86 (Home pc)

Intel Core i7 - Geforce 310M - 4GB Ram - Win7 x64 (Laptop)

Link to comment
Share on other sites

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.

Omid Saadat

OD Arts Blog

 

AMD Phenom II X4 940 - Geforce 8800GTS - 4GB RAM - XP x86

AMD 6000+ - Geforce 9800 GT - 2GB RAM - XP x86 (Home pc)

Intel Core i7 - Geforce 310M - 4GB Ram - Win7 x64 (Laptop)

Link to comment
Share on other sites

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

  • Upvote 1

Omid Saadat

OD Arts Blog

 

AMD Phenom II X4 940 - Geforce 8800GTS - 4GB RAM - XP x86

AMD 6000+ - Geforce 9800 GT - 2GB RAM - XP x86 (Home pc)

Intel Core i7 - Geforce 310M - 4GB Ram - Win7 x64 (Laptop)

Link to comment
Share on other sites

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.

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.

 Share

×
×
  • Create New...