forked from blender/blender-addons
Add possibility to render USD file for testing purposes #14
@ -7,6 +7,11 @@ from pathlib import Path
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import bpy_hydra
|
import bpy_hydra
|
||||||
|
import _bpy_hydra
|
||||||
|
|
||||||
|
from pxr import Usd
|
||||||
|
|
||||||
|
from .preferences import addon_preferences
|
||||||
|
|
||||||
|
|
||||||
class StormHydraRenderEngine(bpy_hydra.HydraRenderEngine):
|
class StormHydraRenderEngine(bpy_hydra.HydraRenderEngine):
|
||||||
@ -19,10 +24,22 @@ class StormHydraRenderEngine(bpy_hydra.HydraRenderEngine):
|
|||||||
|
|
||||||
delegate_id = 'HdStormRendererPlugin'
|
delegate_id = 'HdStormRendererPlugin'
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._usd_stage = None
|
||||||
|
|
||||||
|
def _sync_usd_stage(self):
|
||||||
|
preferences = addon_preferences()
|
||||||
|
dev = bpy.context.scene.hydra_storm.dev
|
||||||
|
if preferences.dev_tools and dev.render_usd and dev.usd_file:
|
||||||
|
if not self._usd_stage:
|
||||||
|
self._usd_stage = Usd.Stage.Open(dev.usd_file)
|
||||||
|
|
||||||
|
if self._usd_stage:
|
||||||
|
_bpy_hydra.engine_sync_usd(self.engine_ptr, self._usd_stage)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register(cls):
|
def register(cls):
|
||||||
super().register()
|
super().register()
|
||||||
|
|
||||||
bpy_hydra.register_plugins([str(Path(__file__).parent / "plugin")])
|
bpy_hydra.register_plugins([str(Path(__file__).parent / "plugin")])
|
||||||
|
|
||||||
def get_render_settings(self, engine_type):
|
def get_render_settings(self, engine_type):
|
||||||
@ -35,6 +52,16 @@ class StormHydraRenderEngine(bpy_hydra.HydraRenderEngine):
|
|||||||
'maxLights': settings.max_lights,
|
'maxLights': settings.max_lights,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def update(self, data, depsgraph):
|
||||||
|
super().update(data, depsgraph)
|
||||||
|
self._sync_usd_stage()
|
||||||
|
|
||||||
|
def view_update(self, context, depsgraph):
|
||||||
|
super().view_update(context, depsgraph)
|
||||||
|
self._sync_usd_stage()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
register, unregister = bpy.utils.register_classes_factory((
|
register, unregister = bpy.utils.register_classes_factory((
|
||||||
StormHydraRenderEngine,
|
StormHydraRenderEngine,
|
||||||
|
@ -19,9 +19,6 @@ class AddonPreferences(bpy.types.AddonPreferences):
|
|||||||
|
|
||||||
|
|
||||||
def addon_preferences():
|
def addon_preferences():
|
||||||
if 'hydra_storm' not in bpy.context.preferences.addons:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return bpy.context.preferences.addons['hydra_storm'].preferences
|
return bpy.context.preferences.addons['hydra_storm'].preferences
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,18 +23,15 @@ class Properties(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
class DevProperties(bpy.types.PropertyGroup):
|
class DevProperties(bpy.types.PropertyGroup):
|
||||||
render_data: bpy.props.EnumProperty(
|
render_usd: bpy.props.BoolProperty(
|
||||||
name="Render Data",
|
name="Render USD",
|
||||||
description="Select data to render",
|
description="Render USD file with Blender scene",
|
||||||
items=(('BLENDER', "Blender", "Render Blender scene"),
|
default=False,
|
||||||
('USD', "USD", "Render USD file"),
|
|
||||||
('ALL', "All", "Render Blender scene and USD file")),
|
|
||||||
default='BLENDER',
|
|
||||||
)
|
)
|
||||||
usd_file: bpy.props.StringProperty(
|
usd_file: bpy.props.StringProperty(
|
||||||
name="USD File",
|
name="USD File",
|
||||||
description="Select data to render",
|
description="Select USD file to render",
|
||||||
subtype='DIR_PATH',
|
subtype='FILE_PATH',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,10 +103,12 @@ class STORM_HYDRA_PT_dev(Panel):
|
|||||||
layout.use_property_split = True
|
layout.use_property_split = True
|
||||||
layout.use_property_decorate = False
|
layout.use_property_decorate = False
|
||||||
|
|
||||||
settings = context.scene.hydra_storm.dev
|
dev = context.scene.hydra_storm.dev
|
||||||
layout.prop(settings, 'render_data')
|
col = layout.column()
|
||||||
if settings.render_data in ('USD', 'ALL'):
|
col.prop(dev, 'render_usd')
|
||||||
layout.prop(settings, 'usd_file')
|
row = col.row()
|
||||||
|
row.enabled = dev.render_usd
|
||||||
|
row.prop(dev, 'usd_file')
|
||||||
|
|
||||||
|
|
||||||
register_classes, unregister_classes = bpy.utils.register_classes_factory((
|
register_classes, unregister_classes = bpy.utils.register_classes_factory((
|
||||||
|
Loading…
Reference in New Issue
Block a user