Skip to content
Snippets Groups Projects
Commit 6369d5ab authored by Luise Odenthal's avatar Luise Odenthal
Browse files

setter in rendering updated

parent bfb0bbe2
No related branches found
No related tags found
No related merge requests found
......@@ -159,6 +159,6 @@ if __name__ == "__main__":
grid_pos = bee_samp.grid_posorients
condition = (grid_pos.x**2 + grid_pos.y**2) < ((bee_samp.world_dim / 2)**2)
bee_samp.set_gridindeces2nan(condition[condition == 0].index)
bee_samp.set_cycle_samples(samples=5)
bee_samp.cycle_samples(samples=5)
with tempfile.TemporaryDirectory() as folder:
bee_samp.render(folder + '/database.db')
......@@ -48,9 +48,9 @@ class Cyberbee():
bpy.context.scene.cycles.filter_type = 'GAUSSIAN'
# Call all set function with default values
self.camera_rotation_mode = 'XYZ'
self.camera_fov()
self.camera_fov = [[-90, 90], [-180, 180]]
self.camera_gaussian_width = 1.5
self.camera_resolution()
self.camera_resolution = [360, 180]
self.cycle_samples = 30
# switch on nodes
# Create render link to OutputFile with Image and Z buffer
......@@ -183,19 +183,14 @@ class Cyberbee():
self.camera.data.cycles.longitude_max)
return fov
# @camera_fov.setter
def set_camera_fov(self, latmin=-90, latmax=+90,
longmin=-180, longmax=+180):
@camera_fov.setter
def camera_fov(self, resolution=[[-90, 90], [-180, 180]]):
"""change the field of view of the panoramic camera
:param latmin: minimum latitude (in deg)
:type latmin: float
:param latmax: maximum latitude (in deg)
:type latmax: float
:param longmin: minimum longitude (in deg)
:type longmin: float
:param longmin: maximum longitude (in deg)
:type longmin: float
:param resolution: [[minimum latitude, maximum latitude],
[minimum longitude, maximum longitude]]
(in deg)
:type latmin: 2x2 float array or list
..todo use @property.setter
def camera_fov(self, latlongrange)
......@@ -204,22 +199,17 @@ class Cyberbee():
..todo Change assert to if -> raise TypeError()/KeyError()
"""
if not (isinstance(latmin, int) or isinstance(latmin, float)):
raise TypeError('latmin must be of type integer or float')
if not (isinstance(latmax, int) or isinstance(latmax, float)):
raise TypeError('latmin must be of type integer or float')
if not (isinstance(longmin, int) or isinstance(longmin, float)):
raise TypeError('latmin must be of type integer or float')
if not (isinstance(longmax, int) or isinstance(longmax, float)):
raise TypeError('latmin must be of type integer or float')
if not (isinstance(resolution, list) or
isinstance(resolution, np.ndarray)):
raise TypeError('resolution must be list or array')
if not self.camera.data.type == 'PANO':
raise Exception('Camera is not panoramic')
if not self.camera.data.cycles.panorama_type == 'EQUIRECTANGULAR':
raise Exception('Camera is not equirectangular')
self.camera.data.cycles.latitude_min = np.deg2rad(latmin)
self.camera.data.cycles.latitude_max = np.deg2rad(latmax)
self.camera.data.cycles.longitude_min = np.deg2rad(longmin)
self.camera.data.cycles.longitude_max = np.deg2rad(longmax)
self.camera.data.cycles.latitude_min = np.deg2rad(resolution[0, 0])
self.camera.data.cycles.latitude_max = np.deg2rad(resolution[0, 1])
self.camera.data.cycles.longitude_min = np.deg2rad(resolution[1, 0])
self.camera.data.cycles.longitude_max = np.deg2rad(resolution[1, 1])
@property
def camera_gaussian_width(self, gauss_w=1.5):
......@@ -269,8 +259,8 @@ class Cyberbee():
resolution_y = bpy.context.scene.render.resolution_y
return resolution_x, resolution_y
# @camera_resolution.setter
def set_camera_resolution(self, resolution_x=360, resolution_y=180):
@camera_resolution.setter
def set_camera_resolution(self, resolution=[360, 180]):
"""change the camera resolution (nb of pixels)
......@@ -293,18 +283,17 @@ class Cyberbee():
..todo check type and raise TypeError
"""
if not isinstance(resolution_x, int):
raise TypeError('resolution must be integer')
if not isinstance(resolution_y, int):
raise TypeError('resolution must be integer')
bpy.context.scene.render.resolution_x = resolution_x
bpy.context.scene.render.resolution_y = resolution_y
if not (isinstance(resolution, list) or
isinstance(resolution, np.ndarray)):
raise TypeError('resolution list or array')
bpy.context.scene.render.resolution_x = resolution[0]
bpy.context.scene.render.resolution_y = resolution[1]
bpy.context.scene.render.resolution_percentage = 100
def update(self, posorient):
"""assign the position and the orientation of the camera.
:param posorient: is a 1x6 vector continaing:
:param posorient: is a 1x6 vector containing:
x,y,z, angle_1, angle_2, angle_3,
here the angles are euler rotation around the axis
specified by scene.camera.rotation_mode
......
......@@ -48,9 +48,9 @@ class Cyberbee():
bpy.context.scene.cycles.filter_type = 'GAUSSIAN'
# Call all set function with default values
self.camera_rotation_mode = 'XYZ'
self.camera_fov()
self.camera_fov = [[-90, 90], [-180, 180]]
self.camera_gaussian_width = 1.5
self.camera_resolution()
self.camera_resolution = [360, 180]
self.cycle_samples = 30
# switch on nodes
# Create render link to OutputFile with Image and Z buffer
......@@ -183,19 +183,14 @@ class Cyberbee():
self.camera.data.cycles.longitude_max)
return fov
# @camera_fov.setter
def set_camera_fov(self, latmin=-90, latmax=+90,
longmin=-180, longmax=+180):
@camera_fov.setter
def camera_fov(self, resolution=[[-90, 90], [-180, 180]]):
"""change the field of view of the panoramic camera
:param latmin: minimum latitude (in deg)
:type latmin: float
:param latmax: maximum latitude (in deg)
:type latmax: float
:param longmin: minimum longitude (in deg)
:type longmin: float
:param longmin: maximum longitude (in deg)
:type longmin: float
:param resolution: [[minimum latitude, maximum latitude],
[minimum longitude, maximum longitude]]
(in deg)
:type latmin: 2x2 float array or list
..todo use @property.setter
def camera_fov(self, latlongrange)
......@@ -204,22 +199,17 @@ class Cyberbee():
..todo Change assert to if -> raise TypeError()/KeyError()
"""
if not (isinstance(latmin, int) or isinstance(latmin, float)):
raise TypeError('latmin must be of type integer or float')
if not (isinstance(latmax, int) or isinstance(latmax, float)):
raise TypeError('latmin must be of type integer or float')
if not (isinstance(longmin, int) or isinstance(longmin, float)):
raise TypeError('latmin must be of type integer or float')
if not (isinstance(longmax, int) or isinstance(longmax, float)):
raise TypeError('latmin must be of type integer or float')
if not (isinstance(resolution, list) or
isinstance(resolution, np.ndarray)):
raise TypeError('resolution must be list or array')
if not self.camera.data.type == 'PANO':
raise Exception('Camera is not panoramic')
if not self.camera.data.cycles.panorama_type == 'EQUIRECTANGULAR':
raise Exception('Camera is not equirectangular')
self.camera.data.cycles.latitude_min = np.deg2rad(latmin)
self.camera.data.cycles.latitude_max = np.deg2rad(latmax)
self.camera.data.cycles.longitude_min = np.deg2rad(longmin)
self.camera.data.cycles.longitude_max = np.deg2rad(longmax)
self.camera.data.cycles.latitude_min = np.deg2rad(resolution[0, 0])
self.camera.data.cycles.latitude_max = np.deg2rad(resolution[0, 1])
self.camera.data.cycles.longitude_min = np.deg2rad(resolution[1, 0])
self.camera.data.cycles.longitude_max = np.deg2rad(resolution[1, 1])
@property
def camera_gaussian_width(self, gauss_w=1.5):
......@@ -269,8 +259,8 @@ class Cyberbee():
resolution_y = bpy.context.scene.render.resolution_y
return resolution_x, resolution_y
# @camera_resolution.setter
def set_camera_resolution(self, resolution_x=360, resolution_y=180):
@camera_resolution.setter
def set_camera_resolution(self, resolution=[360, 180]):
"""change the camera resolution (nb of pixels)
......@@ -293,18 +283,16 @@ class Cyberbee():
..todo check type and raise TypeError
"""
if not isinstance(resolution_x, int):
raise TypeError('resolution must be integer')
if not isinstance(resolution_y, int):
raise TypeError('resolution must be integer')
bpy.context.scene.render.resolution_x = resolution_x
bpy.context.scene.render.resolution_y = resolution_y
if not (isinstance(resolution, list) or isinstance(resolution, np.ndarray)):
raise TypeError('resolution list or array')
bpy.context.scene.render.resolution_x = resolution[0]
bpy.context.scene.render.resolution_y = resolution[1]
bpy.context.scene.render.resolution_percentage = 100
def update(self, posorient):
"""assign the position and the orientation of the camera.
:param posorient: is a 1x6 vector continaing:
:param posorient: is a 1x6 vector containing:
x,y,z, angle_1, angle_2, angle_3,
here the angles are euler rotation around the axis
specified by scene.camera.rotation_mode
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment