If we use the camera and fix they aspect ratio by script or checkbox in the camera properties panel we are having correct camera’s zoom only if screen.width>screen.height (0:00-0:20)
So we need correct the camera zoom for portrait screens, where screen.width<screen.height:
in video: 0:45-1:10
My code for this (see windowevent function):
local campos = vmath.vector3()
local nearz = .1
local farz = 2000
local initial_z = 680
function init(self)
msg.post("#camera", "acquire_camera_focus")
campos=go.get_position()
campos.z=initial_z
go.set_position(campos)
msg.post("#camera", "set_camera", {aspect_ratio = 1.0, fov = 45, near_z = nearz, far_z = farz})
window.set_listener(windowevent)
windowevent(self,window.WINDOW_EVENT_RESIZED, {width=render_helper.window_res.x,height=render_helper.window_res.y})
end
function final(self)
msg.post("#camera", "release_camera_focus")
end
--######################################## Window Event ########################################
function windowevent(self, event, data)
if event == window.WINDOW_EVENT_RESIZED then
print("Window resized: ", data.width, data.height)
msg.post("#camera", "set_camera", {aspect_ratio = data.width/data.height, fov = 45, near_z = nearz, far_z = farz})
if data.width<data.height then
campos.z=initial_z*data.height/data.width
go.set_position(campos)
else
campos.z=initial_z
go.set_position(campos)
end
end
end
Is it right or I’m missing something in camera initialization, project settings, etc?