Skip to content

Commit

Permalink
Honor Spot/Wash/None beam types
Browse files Browse the repository at this point in the history
  • Loading branch information
vanous committed Dec 14, 2023
1 parent 70aad3a commit f9ef7d1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,8 @@ def getFixture(self, collection):

def findFixture(self, object):
for fixture in self.fixtures:
if fixture is None:
return None
if (object.name in fixture.collection.objects):
return fixture
return None
Expand Down
18 changes: 16 additions & 2 deletions gdtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,16 @@ def create_camera(geometry):
collection.objects.link(camera_object)

def create_beam(geometry):
if (not sanitize_obj_name(geometry) in objs): return
if (sanitize_obj_name(geometry) not in objs):
return
obj_child = objs[sanitize_obj_name(geometry)]
if "beam" not in obj_child.name.lower():
obj_child.name=f"Beam {obj_child.name}"

if not display_beams: # Don't even create beam objects to save resources
return
if any(geometry.beam_type.value == x for x in ["None", "Glow"]):
return

obj_child.visible_shadow = False
light_data = bpy.data.lights.new(name=f"Spot {obj_child.name}", type='SPOT')
Expand All @@ -342,16 +345,27 @@ def create_beam(geometry):
light_data['shutter_dimmer_value'] = 0
light_data['shutter_counter'] = 0
light_data.energy = light_data['flux'] #set by default to full brightness for devices without dimmer

light_data.spot_blend = calculate_spot_blend(geometry)
light_data.spot_size = geometry.beam_angle
light_data.spot_size = geometry.beam_angle*3.1415/180.0
light_data.shadow_soft_size = geometry.beam_radius
light_object = bpy.data.objects.new(name=f"Spot", object_data=light_data)
light_object = bpy.data.objects.new(name="Spot", object_data=light_data)
light_object.location = obj_child.location
light_object.hide_select = True
constraint = light_object.constraints.new('CHILD_OF')
constraint.target = obj_child
collection.objects.link(light_object)

def calculate_spot_blend(geometry):
"""Return spot_blend value based on beam_type, maybe in the future
we can calculate different value based on beam/field angle...?"""

beam_type = geometry.beam_type.value
if any(beam_type == x for x in ["Wash", "Fresnel", "PC"]):
return 1.0
return 0.0

def add_child_position(geometry, invertX = False):
"""Add a child, create a light source and emitter material for beams"""

Expand Down
2 changes: 1 addition & 1 deletion pygdtf/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ComponentType(Enum):


class BeamType(Enum):
permitted = ["Wash", "Spot", "None"]
permitted = ["Wash", "Spot", "None", "Rectangle", "PC", "Fresnel", "Glow"]
_default = "Wash"


Expand Down

0 comments on commit f9ef7d1

Please sign in to comment.