advanced example
This commit is contained in:
1 parent
8c0a639fba
commit
6fe57915e8
99 files changed
+1329
-56
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import math
|
||||
|
||||
import unreal
|
||||
|
||||
|
||||
@@ -6,11 +8,17 @@ def look_at(actor, target):
|
||||
actor.get_actor_location(), unreal.Vector(*target)), False)
|
||||
|
||||
|
||||
def create(scene, location=(450, -550, 300), target=(0, 0, 100), focal_length=45):
|
||||
def create(scene, location=(450, -550, 300), target=(0, 0, 100), fov=43.6):
|
||||
"""Create a camera with a horizontal field of view in degrees (0 < fov < 180)."""
|
||||
fov = float(fov)
|
||||
if not 0 < fov < 180:
|
||||
raise ValueError("fov must be between 0 and 180 degrees (exclusive)")
|
||||
sensor_width = 36.0
|
||||
focal_length = sensor_width / (2 * math.tan(math.radians(fov) / 2))
|
||||
actor = scene.spawn(unreal.CineCameraActor, "Camera", location)
|
||||
component = actor.get_cine_camera_component()
|
||||
filmback = component.get_editor_property("filmback")
|
||||
filmback.set_editor_property("sensor_width", 36.0)
|
||||
filmback.set_editor_property("sensor_width", sensor_width)
|
||||
filmback.set_editor_property("sensor_height", 20.25)
|
||||
component.set_editor_property("filmback", filmback)
|
||||
component.set_editor_property("current_focal_length", float(focal_length))
|
||||
|
||||
Reference in new issue
Block a user