Skip to content

Commit 297862b

Browse files
Initial airplane support
1 parent f7647f0 commit 297862b

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

loco-graphics-helper/builders/scene_builder.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ def build(self, context):
9090
light_settings.distance = 0
9191
light_settings.samples = 1
9292

93-
bpy.ops.mesh.primitive_plane_add(location=(0,0,0), radius=20)
94-
shadow_catcher = bpy.context.active_object
93+
if not "ShadowCatcher" in context.scene.objects:
94+
bpy.ops.mesh.primitive_plane_add(location=(0,0,0), radius=20)
95+
shadow_catcher = bpy.context.active_object
96+
else:
97+
shadow_catcher = context.scene.objects["ShadowCatcher"]
9598
shadow_catcher.name = "ShadowCatcher"
9699
shadow_catcher.layers[2] = True
97100
shadow_catcher.layers[0] = False

loco-graphics-helper/operators/vehicle_render_operator.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def create_task(self, context):
4444
if cars[0].loco_graphics_helper_vehicle_properties.is_airplane:
4545
self.task_builder.set_cast_shadows(
4646
True)
47+
self.task_builder.set_palette(self.palette_manager.get_shadow_palette())
4748
self.add_airplane_shadow_render_angles(cars[0])
4849
else:
4950
bogies = [x for x in context.scene.objects if x.loco_graphics_helper_object_properties.object_type == "BOGIE"]
@@ -74,6 +75,7 @@ def should_render_feature(self, key, props):
7475
def add_render_angles(self, car_object):
7576
props = car_object.loco_graphics_helper_vehicle_properties
7677
is_bogie = car_object.loco_graphics_helper_object_properties.object_type == "BOGIE"
78+
target_object = car_object
7779
animation_frames = props.number_of_animation_frames
7880
roll_frames = 1 if props.roll_angle == 0 else 3
7981

@@ -107,6 +109,14 @@ def add_render_angles(self, car_object):
107109

108110
start_output_index = self.task_builder.output_index
109111

112+
113+
if track_section[2] < 0 and props.is_airplane:
114+
# We don't want to render anything so we are setting the target
115+
# to the rig (could use anything though that can't render)
116+
target_object = bpy.data.objects['Rig']
117+
else:
118+
target_object = car_object
119+
110120
for i in range(num_viewing_angles):
111121
if roll_frames != 1:
112122
roll_angles = [0, props.roll_angle, -props.roll_angle]
@@ -115,19 +125,19 @@ def add_render_angles(self, car_object):
115125
self.task_builder.set_rotation(
116126
base_view_angle, roll_angle, vertical_angle=track_section[2])
117127
self.task_builder.add_frame(
118-
frame_index, num_viewing_angles, i, j, rotation_range, car_object)
128+
frame_index, num_viewing_angles, i, j, rotation_range, target_object)
119129
else:
120130
number_of_animated_and_other_frames = animation_frames + props.braking_lights
121131
for j in range(animation_frames):
122132
frame_index = start_output_index + i * number_of_animated_and_other_frames + j
123133
self.task_builder.add_frame(
124-
frame_index, num_viewing_angles, i, j, rotation_range, car_object)
134+
frame_index, num_viewing_angles, i, j, rotation_range, target_object)
125135

126136
if props.braking_lights:
127137
self.task_builder.set_layer("Braking Lights")
128138
frame_index = start_output_index + i * number_of_animated_and_other_frames + animation_frames
129139
self.task_builder.add_frame(
130-
frame_index, num_viewing_angles, i, 0, rotation_range, car_object)
140+
frame_index, num_viewing_angles, i, 0, rotation_range, target_object)
131141
self.task_builder.set_layer("Editor")
132142

133143
def add_airplane_shadow_render_angles(self, car_object):
@@ -140,7 +150,7 @@ def add_airplane_shadow_render_angles(self, car_object):
140150
self.task_builder.set_rotation(
141151
base_view_angle, 0, vertical_angle=track_section[2])
142152

143-
num_viewing_angles = int(props.flat_viewing_angles)
153+
num_viewing_angles = int(int(props.flat_viewing_angles) / 2)
144154

145155
rotational_symmetry = props.rotational_symmetry
146156

loco-graphics-helper/palette_manager.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
"transparent"
5454
])
5555

56+
shadow_palette = Palette(os.path.join(
57+
palette_base_path, "shadow_palette.png"), [
58+
"shadowGrey",
59+
"transparent"
60+
])
61+
5662
custom_palette = Palette(os.path.join(
5763
palette_base_path, "custom_palette.bmp"), [
5864
"yellow",
@@ -98,3 +104,6 @@ def get_recolor_palette(self, recolor_index):
98104
def set_custom_palette(self, colors):
99105
custom_palette.clear()
100106
custom_palette.add_colors(colors)
107+
108+
def get_shadow_palette(self):
109+
return shadow_palette

loco-graphics-helper/rct_graphics_helper_panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def get_number_of_sprites(object):
234234
num_sprites = num_sprites + (int(props.sloped_viewing_angles) * 2 + num_transition_sprites) * multiplier
235235

236236
if props.is_airplane:
237-
num_sprites = num_sprites + int(props.flat_viewing_angles) * multiplier
237+
num_sprites = num_sprites + int(props.flat_viewing_angles) * multiplier / 2
238238
return int(num_sprites)
239239

240240
def draw_vehicle_panel(self, scene, layout):
120 Bytes
Loading

0 commit comments

Comments
 (0)