[Blender Options] Moved the point of view options to Render Options
- So we can have more than one
This commit is contained in:
parent
bf5ae1a3fd
commit
f860b7eb11
16
README.md
16
README.md
|
|
@ -1590,17 +1590,24 @@ Notes:
|
|||
A short-cut to use for simple cases where a variant is an overkill.
|
||||
- `variant`: [string=''] Board variant to apply.
|
||||
- `version`: [string='2.1'] [2.1,2.1_haschtl] Variant of the format used.
|
||||
- **`render_options`**: [dict] How the render is done for the `render` output type.
|
||||
- **`render_options`**: [dict] Render and point of view options.
|
||||
Controls how the render is done for the `render` output type,
|
||||
and how the object is viewed by the camera.
|
||||
* Valid keys:
|
||||
- **`samples`**: [number=10] How many samples we create. Each sample is a raytracing render.
|
||||
Use 1 for a raw preview, 10 for a draft and 100 or more for the final render.
|
||||
- **`transparent_background`**: [boolean=false] Make the background transparent.
|
||||
- **`view`**: [string='top'] [top,bottom,front,rear,right,left,z,Z,y,Y,x,X] Point of view.
|
||||
Compatible with `render_3d`.
|
||||
- `background1`: [string='#66667F'] First color for the background gradient.
|
||||
- `background2`: [string='#CCCCE5'] Second color for the background gradient.
|
||||
- `file_id`: [string=''] String to diferentiate the name of this view.
|
||||
When empty we use the `view`.
|
||||
- `resolution_x`: [number=1280] Width of the image.
|
||||
- `resolution_y`: [number=720] Height of the image.
|
||||
- **`view`**: [string='top'] [top,bottom,front,rear,right,left,z,Z,y,Y,x,X] Point of view.
|
||||
Compatible with `render_3d`.
|
||||
- `rotate_x`: [number=0] Angle to rotate the board in the X axis, positive is clockwise [degrees].
|
||||
- `rotate_y`: [number=0] Angle to rotate the board in the Y axis, positive is clockwise [degrees].
|
||||
- `rotate_z`: [number=0] Angle to rotate the board in the Z axis, positive is clockwise [degrees].
|
||||
- `add_default_light`: [boolean=true] Add a default light when none specified.
|
||||
The default light is located at (-size*3.33, size*3.33, size*5) where size is max(width, height) of the PCB.
|
||||
- `camera`: [dict] Options for the camera.
|
||||
|
|
@ -1639,9 +1646,6 @@ Notes:
|
|||
This option controls if we add it for none, all or only for THT/SMD pads with solder paste.
|
||||
- `stack_boards`: [boolean=true] Move the sub-PCBs to their relative position.
|
||||
- `texture_dpi`: [number=1016.0] [508-2032] Texture density in dots per inch.
|
||||
- `rotate_x`: [number=0] Angle to rotate the board in the X axis, positive is clockwise [degrees].
|
||||
- `rotate_y`: [number=0] Angle to rotate the board in the Y axis, positive is clockwise [degrees].
|
||||
- `rotate_z`: [number=0] Angle to rotate the board in the Z axis, positive is clockwise [degrees].
|
||||
- `category`: [string|list(string)=''] The category for this output. If not specified an internally defined category is used.
|
||||
Categories looks like file system paths, i.e. **PCB/fabrication/gerber**.
|
||||
The categories are currently used for `navigate_results`.
|
||||
|
|
|
|||
|
|
@ -193,30 +193,35 @@ outputs:
|
|||
stack_boards: true
|
||||
# [number=1016.0] [508-2032] Texture density in dots per inch
|
||||
texture_dpi: 1016.0
|
||||
# [dict] How the render is done for the `render` output type
|
||||
# [dict] Render and point of view options.
|
||||
# Controls how the render is done for the `render` output type,
|
||||
# and how the object is viewed by the camera
|
||||
render_options:
|
||||
# [string='#66667F'] First color for the background gradient
|
||||
background1: '#66667F'
|
||||
# [string='#CCCCE5'] Second color for the background gradient
|
||||
background2: '#CCCCE5'
|
||||
# [string=''] String to diferentiate the name of this view.
|
||||
# When empty we use the `view`
|
||||
file_id: ''
|
||||
# [number=1280] Width of the image
|
||||
resolution_x: 1280
|
||||
# [number=720] Height of the image
|
||||
resolution_y: 720
|
||||
# [number=0] Angle to rotate the board in the X axis, positive is clockwise [degrees]
|
||||
rotate_x: 0
|
||||
# [number=0] Angle to rotate the board in the Y axis, positive is clockwise [degrees]
|
||||
rotate_y: 0
|
||||
# [number=0] Angle to rotate the board in the Z axis, positive is clockwise [degrees]
|
||||
rotate_z: 0
|
||||
# [number=10] How many samples we create. Each sample is a raytracing render.
|
||||
# Use 1 for a raw preview, 10 for a draft and 100 or more for the final render
|
||||
samples: 10
|
||||
# [boolean=false] Make the background transparent
|
||||
transparent_background: false
|
||||
# [number=0] Angle to rotate the board in the X axis, positive is clockwise [degrees]
|
||||
rotate_x: 0
|
||||
# [number=0] Angle to rotate the board in the Y axis, positive is clockwise [degrees]
|
||||
rotate_y: 0
|
||||
# [number=0] Angle to rotate the board in the Z axis, positive is clockwise [degrees]
|
||||
rotate_z: 0
|
||||
# [string='top'] [top,bottom,front,rear,right,left,z,Z,y,Y,x,X] Point of view.
|
||||
# Compatible with `render_3d`
|
||||
view: 'top'
|
||||
# [string='top'] [top,bottom,front,rear,right,left,z,Z,y,Y,x,X] Point of view.
|
||||
# Compatible with `render_3d`
|
||||
view: 'top'
|
||||
# BoardView:
|
||||
# This format allows simple pads and connections navigation, mainly for circuit debug.
|
||||
# The output can be loaded using Open Board View (https://openboardview.org/)
|
||||
|
|
|
|||
|
|
@ -201,12 +201,14 @@ def apply_scene(file):
|
|||
# Select the board
|
||||
print('- Select all')
|
||||
bpy.ops.object.select_all(action='SELECT')
|
||||
# Apply point of view
|
||||
do_point_of_view(jscene, 'view')
|
||||
# Apply extra rotations
|
||||
do_rotate(jscene, 'rotate_x', 0)
|
||||
do_rotate(jscene, 'rotate_y', 1)
|
||||
do_rotate(jscene, 'rotate_z', 2)
|
||||
render = jscene.get('render')
|
||||
if render:
|
||||
# Apply point of view
|
||||
do_point_of_view(render, 'view')
|
||||
# Apply extra rotations
|
||||
do_rotate(render, 'rotate_x', 0)
|
||||
do_rotate(render, 'rotate_y', 1)
|
||||
do_rotate(render, 'rotate_z', 2)
|
||||
|
||||
# Add a camera
|
||||
auto_camera = False
|
||||
|
|
@ -242,7 +244,6 @@ def apply_scene(file):
|
|||
bpy.context.view_layer.update()
|
||||
|
||||
# Setup render options
|
||||
render = jscene.get('render')
|
||||
if render:
|
||||
scene.cycles.samples = render.get('samples', 10)
|
||||
r = scene.render
|
||||
|
|
|
|||
|
|
@ -115,6 +115,9 @@ class BlenderLightOptions(Optionable):
|
|||
|
||||
class BlenderRenderOptions(Optionable):
|
||||
""" Render parameters """
|
||||
_views = {'top': 'z', 'bottom': 'Z', 'front': 'y', 'rear': 'Y', 'right': 'x', 'left': 'X'}
|
||||
_rviews = {v: k for k, v in _views.items()}
|
||||
|
||||
def __init__(self, field=None):
|
||||
super().__init__()
|
||||
with document:
|
||||
|
|
@ -131,8 +134,31 @@ class BlenderRenderOptions(Optionable):
|
|||
""" First color for the background gradient """
|
||||
self.background2 = "#CCCCE5"
|
||||
""" Second color for the background gradient """
|
||||
self.rotate_x = 0
|
||||
""" Angle to rotate the board in the X axis, positive is clockwise [degrees] """
|
||||
self.rotate_y = 0
|
||||
""" Angle to rotate the board in the Y axis, positive is clockwise [degrees] """
|
||||
self.rotate_z = 0
|
||||
""" Angle to rotate the board in the Z axis, positive is clockwise [degrees] """
|
||||
self.view = 'top'
|
||||
""" *[top,bottom,front,rear,right,left,z,Z,y,Y,x,X] Point of view.
|
||||
Compatible with `render_3d` """
|
||||
self.file_id = ''
|
||||
""" String to diferentiate the name of this view.
|
||||
When empty we use the `view` """
|
||||
self._unkown_is_error = True
|
||||
|
||||
def config(self, parent):
|
||||
super().config(parent)
|
||||
# View point
|
||||
view = self._views.get(self.view, None)
|
||||
if view is not None:
|
||||
self.view = view
|
||||
self._file_id = self.file_id
|
||||
if not self._file_id:
|
||||
self._file_id = '_'+self._rviews.get(self.view)
|
||||
self._parent._expand_id += self._file_id
|
||||
|
||||
|
||||
class PCB3DExportOptions(Base3DOptionsWithHL):
|
||||
""" Options to generate the PCB3D file """
|
||||
|
|
@ -149,9 +175,6 @@ class PCB3DExportOptions(Base3DOptionsWithHL):
|
|||
|
||||
|
||||
class Blender_ExportOptions(BaseOptions):
|
||||
_views = {'top': 'z', 'bottom': 'Z', 'front': 'y', 'rear': 'Y', 'right': 'x', 'left': 'X'}
|
||||
_rviews = {v: k for k, v in _views.items()}
|
||||
|
||||
def __init__(self):
|
||||
with document:
|
||||
self.pcb3d = PCB3DExportOptions
|
||||
|
|
@ -172,16 +195,9 @@ class Blender_ExportOptions(BaseOptions):
|
|||
""" [dict] Options for the camera.
|
||||
If none specified KiBot will create a suitable camera """
|
||||
self.render_options = BlenderRenderOptions
|
||||
""" *[dict] How the render is done for the `render` output type """
|
||||
self.rotate_x = 0
|
||||
""" Angle to rotate the board in the X axis, positive is clockwise [degrees] """
|
||||
self.rotate_y = 0
|
||||
""" Angle to rotate the board in the Y axis, positive is clockwise [degrees] """
|
||||
self.rotate_z = 0
|
||||
""" Angle to rotate the board in the Z axis, positive is clockwise [degrees] """
|
||||
self.view = 'top'
|
||||
""" *[top,bottom,front,rear,right,left,z,Z,y,Y,x,X] Point of view.
|
||||
Compatible with `render_3d` """
|
||||
""" *[dict] Render and point of view options.
|
||||
Controls how the render is done for the `render` output type,
|
||||
and how the object is viewed by the camera """
|
||||
super().__init__()
|
||||
self._expand_id = '3D_blender'
|
||||
self._unkown_is_error = True
|
||||
|
|
@ -237,11 +253,6 @@ class Blender_ExportOptions(BaseOptions):
|
|||
# Ensure we have some render options
|
||||
if isinstance(self.render_options, type):
|
||||
self.render_options = BlenderRenderOptions()
|
||||
# View point
|
||||
view = self._views.get(self.view, None)
|
||||
if view is not None:
|
||||
self.view = view
|
||||
self._expand_id += '_'+self._rviews.get(self.view)
|
||||
|
||||
def get_output_filename(self, o, output_dir):
|
||||
if o.type == 'render':
|
||||
|
|
@ -382,20 +393,21 @@ class Blender_ExportOptions(BaseOptions):
|
|||
scene['camera'] = {'name': self.camera.name,
|
||||
'position': (self.camera.pos_x, self.camera.pos_y, self.camera.pos_z)}
|
||||
ro = self.render_options
|
||||
scene['render'] = {'samples': ro.samples,
|
||||
'resolution_x': ro.resolution_x,
|
||||
'resolution_y': ro.resolution_y,
|
||||
'transparent_background': ro.transparent_background,
|
||||
'background1': ro.background1,
|
||||
'background2': ro.background2}
|
||||
if self.rotate_x:
|
||||
scene['rotate_x'] = -self.rotate_x
|
||||
if self.rotate_y:
|
||||
scene['rotate_y'] = -self.rotate_y
|
||||
if self.rotate_z:
|
||||
scene['rotate_z'] = -self.rotate_z
|
||||
if self.view:
|
||||
scene['view'] = self.view
|
||||
scr = {'samples': ro.samples,
|
||||
'resolution_x': ro.resolution_x,
|
||||
'resolution_y': ro.resolution_y,
|
||||
'transparent_background': ro.transparent_background,
|
||||
'background1': ro.background1,
|
||||
'background2': ro.background2}
|
||||
scene['render'] = scr
|
||||
if ro.rotate_x:
|
||||
scr['rotate_x'] = -ro.rotate_x
|
||||
if ro.rotate_y:
|
||||
scr['rotate_y'] = -ro.rotate_y
|
||||
if ro.rotate_z:
|
||||
scr['rotate_z'] = -ro.rotate_z
|
||||
if ro.view:
|
||||
scr['view'] = ro.view
|
||||
text = json.dumps(scene, sort_keys=True, indent=2)
|
||||
logger.debug('Scene:\n'+text)
|
||||
f.write(text)
|
||||
|
|
@ -480,7 +492,7 @@ class Blender_Export(Base3D):
|
|||
gb['dir'] = '3D'
|
||||
gb['output_id'] = '_30deg'
|
||||
gb['options'] = copy(out_ops)
|
||||
gb['options'].update({'rotate_x': 30, 'rotate_z': -20})
|
||||
gb['options']['render_options'] = {'rotate_x': 30, 'rotate_z': -20}
|
||||
outs.append(gb)
|
||||
if has_bottom:
|
||||
gb = {}
|
||||
|
|
@ -489,6 +501,6 @@ class Blender_Export(Base3D):
|
|||
gb['type'] = name
|
||||
gb['dir'] = '3D'
|
||||
gb['options'] = copy(out_ops)
|
||||
gb['options'].update({'view': 'bottom'})
|
||||
gb['options']['render_options'] = {'view': 'bottom'}
|
||||
outs.append(gb)
|
||||
return outs
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ outputs:
|
|||
disable_run_by_default: _PCB2Blender_2_1
|
||||
options:
|
||||
pcb3d: _PCB2Blender_2_1
|
||||
rotate_x: 30
|
||||
rotate_z: -20
|
||||
# view: bottom
|
||||
# camera:
|
||||
# name: MyCamera
|
||||
# pos_x: 0.3
|
||||
|
|
@ -25,6 +22,9 @@ outputs:
|
|||
samples: 10
|
||||
#resolution_x: 1920
|
||||
#resolution_y: 1080
|
||||
rotate_x: 30
|
||||
rotate_z: -20
|
||||
# view: bottom
|
||||
outputs:
|
||||
- type: blender
|
||||
- type: render
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ outputs:
|
|||
pcb3d:
|
||||
show_components: ["RV1", "RV2", "U1", "U2", "U3"]
|
||||
highlight: ["RV1"]
|
||||
rotate_x: 30
|
||||
rotate_z: -20
|
||||
# view: bottom
|
||||
render_options:
|
||||
transparent_background: true
|
||||
samples: 10
|
||||
#resolution_x: 1920
|
||||
#resolution_y: 1080
|
||||
rotate_x: 30
|
||||
rotate_z: -20
|
||||
# view: bottom
|
||||
outputs:
|
||||
- type: blender
|
||||
- type: render
|
||||
|
|
|
|||
Loading…
Reference in New Issue