diff --git a/rct-graphics-helper/angle_sections/track.py b/rct-graphics-helper/angle_sections/track.py index 38f13b7..29272eb 100644 --- a/rct-graphics-helper/angle_sections/track.py +++ b/rct-graphics-helper/angle_sections/track.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2022 RCT Graphics Helper developers +Copyright (c) 2023 RCT Graphics Helper developers For a complete list of all authors, please refer to the addon's meta info. Interested in contributing? Visit https://github.com/oli414/Blender-RCT-Graphics @@ -7,45 +7,50 @@ RCT Graphics Helper is licensed under the GNU General Public License version 3. ''' -track_angle_sections_names = [ - "VEHICLE_SPRITE_FLAG_FLAT", - "VEHICLE_SPRITE_FLAG_GENTLE_SLOPES", - "VEHICLE_SPRITE_FLAG_STEEP_SLOPES", - "VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES", - "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES", - "VEHICLE_SPRITE_FLAG_FLAT_BANKED", - "VEHICLE_SPRITE_FLAG_INLINE_TWISTS", - "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS", - "VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS", - "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS", - "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS", - "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS", - "VEHICLE_SPRITE_FLAG_CORKSCREWS", - "VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION", - "VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL" +# This is the order sprite groups are rendered in +sprite_group_names = [ + "slopeFlat", "slopes12", "slopes25", "slopes42", + "slopes60", "slopes75", "slopes90", "slopesLoop", + "slopeInverted", "slopes8", "slopes16", "slopes50", + "flatBanked22", "flatBanked45", "flatBanked67", "flatBanked90", + "inlineTwists", "slopes12Banked22", "slopes8Banked22", "slopes25Banked22", + "slopes8Banked45", "slopes16Banked22", "slopes16Banked45", "slopes25Banked45", + "slopes12Banked45", "slopes25Banked67", "slopes25Banked90", "slopes25InlineTwists", + "slopes42Banked22", "slopes42Banked45", "slopes42Banked67", "slopes42Banked90", + "slopes60Banked22", "corkscrews", "restraintAnimation", "curvedLiftHillUp", + "curvedLiftHillDown" ] -track_angle_sections = { - "VEHICLE_SPRITE_FLAG_FLAT": [ +# The sprites to render in each sprite group. The given rotation values are unused +sprite_group_manifest = { + 'slopeFlat': [ [False, 32, 0, 0, 0] ], - "VEHICLE_SPRITE_FLAG_GENTLE_SLOPES": [ + 'slopes12': [ [False, 4, 11.1026, 0, 0], - [False, 4, -11.1026, 0, 0], + [False, 4, -11.1026, 0, 0] + ], + 'slopes25': [ [False, 32, 22.2052, 0, 0], [False, 32, -22.2052, 0, 0] ], - "VEHICLE_SPRITE_FLAG_STEEP_SLOPES": [ + 'slopes42': [ [False, 8, 40.36, 0, 0], - [False, 8, -40.36, 0, 0], + [False, 8, -40.36, 0, 0] + ], + 'slopes60': [ [False, 32, 58.5148, 0, 0], [False, 32, -58.5148, 0, 0] ], - "VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES": [ + 'slopes75': [ [False, 4, 75, 0, 0], - [False, 4, -75, 0, 0], + [False, 4, -75, 0, 0] + ], + 'slopes90': [ [False, 32, 90, 0, 0], - [False, 32, -90, 0, 0], + [False, 32, -90, 0, 0] + ], + 'slopesLoop': [ [False, 4, 105, 0, 0], [False, 4, -105, 0, 0], [False, 4, 120, 0, 0], @@ -55,29 +60,40 @@ [False, 4, 150, 0, 0], [False, 4, -150, 0, 0], [False, 4, 165, 0, 0], - [False, 4, -165, 0, 0], + [False, 4, -165, 0, 0] + ], + 'slopeInverted': [ [False, 4, 180, 0, 0] ], - "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES": [ + 'slopes8': [ [True, 4, 8.0503, 0, 0], - [True, 4, -8.0503, 0, 0], + [True, 4, -8.0503, 0, 0] + ], + 'slopes16': [ [True, 4, 16.1005, 0, 0], - [True, 4, -16.1005, 0, 0], + [True, 4, -16.1005, 0, 0] + ], + 'slopes50': [ [True, 4, 49.1035, 0, 0], [True, 4, -49.1035, 0, 0] ], - "VEHICLE_SPRITE_FLAG_FLAT_BANKED": [ + 'flatBanked22': [ [False, 8, 0, -22.5, 0], - [False, 8, 0, 22.5, 0], + [False, 8, 0, 22.5, 0] + ], + 'flatBanked45': [ [False, 32, 0, -45, 0], [False, 32, 0, 45, 0] ], - "VEHICLE_SPRITE_FLAG_INLINE_TWISTS": [ - # The banking sprites are used at the start of a twist ((180-MAX_BANK)/6*FRAME)+MAX_BANK + 'flatBanked67': [ [False, 4, 0, -67.5, 0], - [False, 4, 0, 67.5, 0], + [False, 4, 0, 67.5, 0] + ], + 'flatBanked90': [ [False, 4, 0, -90, 0], - [False, 4, 0, 90, 0], + [False, 4, 0, 90, 0] + ], + 'inlineTwists': [ [False, 4, 0, -112.5, 0], [False, 4, 0, 112.5, 0], [False, 4, 0, -135, 0], @@ -85,37 +101,111 @@ [False, 4, 0, -157.5, 0], [False, 4, 0, 157.5, 0] ], - "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS": [ + 'slopes12Banked22': [ [False, 32, 11.1026, -22.5, 0], [False, 32, 11.1026, 22.5, 0], [False, 32, -11.1026, -22.5, 0], [False, 32, -11.1026, 22.5, 0] ], - "VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS": [ + 'slopes8Banked22': [ [True, 4, 8.0503, -22.5, 0], [True, 4, 8.0503, 22.5, 0], [True, 4, -8.0503, -22.5, 0], [True, 4, -8.0503, 22.5, 0] ], - "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS": [ + 'slopes25Banked22': [ [False, 4, 22.2052, -22.5, 0], [False, 4, 22.2052, 22.5, 0], [False, 4, -22.2052, -22.5, 0], [False, 4, -22.2052, 22.5, 0] ], - "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS": [ + 'slopes8Banked45': [ + [True, 4, 8.0503, -45, 0], + [True, 4, 8.0503, 45, 0], + [True, 4, -8.0503, -45, 0], + [True, 4, -8.0503, 45, 0] + ], + 'slopes16Banked22': [ + [True, 4, 16.1005, -22.5, 0], + [True, 4, 16.1005, 22.5, 0], + [True, 4, -16.1005, -22.5, 0], + [True, 4, -16.1005, 22.5, 0] + ], + 'slopes16Banked45': [ + [True, 4, 16.1005, -45, 0], + [True, 4, 16.1005, 45, 0], + [True, 4, -16.1005, -45, 0], + [True, 4, -16.1005, 45, 0] + ], + 'slopes25Banked45': [ [False, 32, 22.2052, -45, 0], [False, 32, 22.2052, 45, 0], [False, 32, -22.2052, -45, 0], [False, 32, -22.2052, 45, 0] ], - "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS": [ + 'slopes12Banked45': [ [False, 4, 11.1026, -45, 0], [False, 4, 11.1026, 45, 0], [False, 4, -11.1026, -45, 0], [False, 4, -11.1026, 45, 0] ], - "VEHICLE_SPRITE_FLAG_CORKSCREWS": [ + 'slopes25Banked67': [ + [False, 4, 22.2052, -67.5, 0], + [False, 4, 22.2052, 67.5, 0], + [False, 4, -22.2052, -67.5, 0], + [False, 4, -22.2052, 67.5, 0] + ], + 'slopes25Banked90': [ + [False, 4, 22.2052, -90, 0], + [False, 4, 22.2052, 90, 0], + [False, 4, -22.2052, -90, 0], + [False, 4, -22.2052, 90, 0] + ], + 'slopes25InlineTwists': [ + [False, 4, 22.2052, -112.5, 0], + [False, 4, 22.2052, 112.5, 0], + [False, 4, 22.2052, -135, 0], + [False, 4, 22.2052, 135, 0], + [False, 4, 22.2052, -157.5, 0], + [False, 4, 22.2052, 157.5, 0], + [False, 4, -22.2052, -112.5, 0], + [False, 4, -22.2052, 112.5, 0], + [False, 4, -22.2052, -135, 0], + [False, 4, -22.2052, 135, 0], + [False, 4, -22.2052, -157.5, 0], + [False, 4, -22.2052, 157.5, 0] + ], + 'slopes42Banked22': [ + [False, 8, 40.36, -22.5, 0], + [False, 8, 40.36, 22.5, 0], + [False, 8, -40.36, -22.5, 0], + [False, 8, -40.36, 22.5, 0] + ], + 'slopes42Banked45': [ + [False, 8, 40.36, -45, 0], + [False, 8, 40.36, 45, 0], + [False, 8, -40.36, -45, 0], + [False, 8, -40.36, 45, 0] + ], + 'slopes42Banked67': [ + [False, 8, 40.36, -67.5, 0], + [False, 8, 40.36, 67.5, 0], + [False, 8, -40.36,-67.5, 0], + [False, 8, -40.36, 67.5, 0] + ], + 'slopes42Banked90': [ + [False, 8, 40.36, -90, 0], + [False, 8, 40.36, 90, 0], + [False, 8, -40.36, -90, 0], + [False, 8, -40.36, 90, 0] + ], + 'slopes60Banked22': [ + [False, 32, 58.5148, -22.5, 0], + [False, 32, 58.5148, 22.5, 0], + [False, 32, -58.5148, -22.5, 0], + [False, 32, -58.5148, 22.5, 0] + ], + 'corkscrews': [ [False, 4, 22.21, 20.7, 4.11], [False, 4, 50.77, 37.76, 18.43], [False, 4, 90, 45, 45], @@ -140,10 +230,143 @@ [False, 4, -129.23, 37.76, -71.57], [False, 4, -157.79, 20.7, -85.89], ], - "VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION": [ + 'restraintAnimation': [ [False, 4, 0, 0, 0] ], - "VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL": [ + 'curvedLiftHillUp': [ + [False, 32, 9.8287, 0, 0] + ], + 'curvedLiftHillDown': [ [False, 32, 9.8287, 0, 0] ] } + +# Default sprite precision for full mode, the tooltip for the sprite group, and if the sprite group should be hidden from the list of sprite groups +sprite_group_metadata = { + "slopeFlat": [32, "Flat track"], + "slopes12": [4, "Orthogonal flat-to-gentle slope track"], + "slopes25": [32, "Orthogonal gentle slope track"], + "slopes42": [8, "Gentle-to-steep slope track"], + "slopes60": [32, "Orthogonal steep slope track"], + "slopes75": [4, "Steep-to-vertical slope track"], + "slopes90": [4, "Vertical track"], + "slopesLoop": [4,"Loop track"], + "slopeInverted": [4, "Fully inverted track"], + "slopes8": [4, "Diagonal flat-to-gentle slope track"], + "slopes16": [4, "Diagonal gentle slope track"], + "slopes50": [4, "Diagonal steep track"], + "flatBanked22": [8, "Flat-to-bank transition track"], + "flatBanked45": [32, "Flat banked track"], + "flatBanked67": [4, "Flat steep banked track"], + "flatBanked90": [4, "Flat vertically-banked track"], + "inlineTwists": [4, "Flat inline twists"], + "slopes12Banked22": [32, "Orthogonal flat-to-gentle-and-flat-to-banked transition track"], + "slopes8Banked22": [4, "Diagonal flat-to-gentle-and-flat-to-banked transition track"], + "slopes25Banked22": [4, "Orthogonal gentle slope flat-to-bank transition track"], + "slopes25Banked45": [32, "Gentle sloped banked turns"], + "slopes8Banked45": [4, "Diagonal flat-to-gentle slope banked transition track"], + "slopes16Banked22": [4, "Diagonal gentle slope flat-to-banked transition track"], + "slopes16Banked45": [4, "Diagonal gentle slope banked track"], + "slopes12Banked45": [4, "Orthogonal flat-to-gentle-slope banked transition track"], + "slopes25Banked67": [4, "Part of small zero-G rolls"], + "slopes25Banked90": [4, "Part of small zero-G rolls"], + "slopes25InlineTwists": [4, "Part of large zero-G roll"], + "slopes42Banked22": [4, "Part of large zero-G roll"], + "slopes42Banked45": [4, "Part of large zero-G roll"], + "slopes42Banked67": [4, "Part of large zero-G roll"], + "slopes42Banked90": [4, "Part of large zero-G roll"], + "slopes60Banked22": [4, "Part of large zero-G roll"], + "corkscrews": [4, "Corkscrew track"], + "restraintAnimation": [4, "Animated restraints"], + "curvedLiftHillUp": [32, "Sprial lifthill up track"], + "curvedLiftHillDown": [32, "Spiral lifthill down track"] +} + +# All legacy groups. See list in rct_graphics_helper_panel.py for which ones are displayed +legacy_group_names = [ + "VEHICLE_SPRITE_FLAG_FLAT", + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPES", + "VEHICLE_SPRITE_FLAG_STEEP_SLOPES", + "VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES", + "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES", + "VEHICLE_SPRITE_FLAG_FLAT_BANKED", + "VEHICLE_SPRITE_FLAG_INLINE_TWISTS", + "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS", + "VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS", + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS", + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS", + "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS", + "VEHICLE_SPRITE_FLAG_CORKSCREWS", + "VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION", + "VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL", + "VEHICLE_SPRITE_FLAG_ZERO_G_ROLLS", + "VEHICLE_SPRITE_FLAG_INVERTED", + "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPE_BANKED" +] + +# Legacy sprite groups that are reset every time the user makes a selection +legacy_groups_implied = [ + "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS", + "VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS", + "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS", + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS", + "VEHICLE_SPRITE_FLAG_INVERTED" +] + +# Display name of each sprite group, tooltip for each sprite group, default state of each sprite group +legacy_group_metadata = { + "VEHICLE_SPRITE_FLAG_FLAT": ["Flat", "Render sprites for flat track", True], + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPES": ["Gentle Slopes", "Render sprites for gentle sloped track", True], + "VEHICLE_SPRITE_FLAG_STEEP_SLOPES": ["Steep Slopes", "Render sprites for steep sloped track", False], + "VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES": ["Vertical Loops", "Render sprites for vertical slopes and loops", False], + "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES": ["Diagonal Slopes", "Render sprites for diagonal slopes", True], + "VEHICLE_SPRITE_FLAG_FLAT_BANKED": ["Flat Banked","Render sprites for flat banked track", False], + "VEHICLE_SPRITE_FLAG_INLINE_TWISTS": ["Inline Twist", "Render sprites for the inline twist element", False], + "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS": ["", "", False], + "VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS": ["", "", False], + "VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS": ["", "", False], + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS": ["", "", False], + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS": ["Sloped Banked Turns","Render sprites for sloped banked turns", False], + "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS": ["", "", False], + "VEHICLE_SPRITE_FLAG_CORKSCREWS": ["Corkscrew", "Render sprites for corkscrews", False], + "VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION": ["Animated Restraints", "Render animated restraints", False], + "VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL": ["Spiral Lifthill", "Render sprites for spiral lifthills", False], + "VEHICLE_SPRITE_FLAG_ZERO_G_ROLLS": ["Zero-G Rolls", "Render sprites for zero-G rolls", False], + "VEHICLE_SPRITE_FLAG_INVERTED": ["", "", False], + "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPE_BANKED": ["Diagonal Sloped Banked", "Render sprites for diagonal sloped banked track", False], +} + +# What full sprite groups each legacy group maps to +legacy_group_map = { + 'VEHICLE_SPRITE_FLAG_FLAT': [ 'slopeFlat' ], + 'VEHICLE_SPRITE_FLAG_GENTLE_SLOPES': ['slopes12', 'slopes25'], + 'VEHICLE_SPRITE_FLAG_STEEP_SLOPES': ['slopes42', 'slopes60'], + 'VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES': ['slopes75', 'slopes90', 'slopesLoop'], + 'VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES': ['slopes8', 'slopes16','slopes50'], + 'VEHICLE_SPRITE_FLAG_FLAT_BANKED': ['flatBanked22','flatBanked45'], + 'VEHICLE_SPRITE_FLAG_INLINE_TWISTS': ['flatBanked67', 'flatBanked90', 'inlineTwists'], + 'VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS': ['slopes12Banked22'], + 'VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS': ['slopes8Banked22'], + 'VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS': ['slopes25Banked22'], + 'VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS': ['slopes25Banked45'], + 'VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS': ['slopes12Banked45'], + 'VEHICLE_SPRITE_FLAG_CORKSCREWS': ['corkscrews'], + 'VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION': ['restraintAnimation'], + 'VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL': ['curvedLiftHillUp', 'curvedLiftHillDown'], + 'VEHICLE_SPRITE_FLAG_ZERO_G_ROLLS': ["slopes60Banked22", "slopes42Banked22","slopes42Banked45","slopes42Banked67","slopes42Banked90", "slopes25InlineTwists", "slopes25Banked67","slopes25Banked90"], + 'VEHICLE_SPRITE_FLAG_INVERTED': ['slopeInverted'], + 'VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPE_BANKED': ['slopes8Banked45', 'slopes16Banked22', 'slopes16Banked45'] +} + +# What legacy groups are implied by combinations of other legacy sprite groups +legacy_group_dependencies = { + frozenset({'VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS'}): frozenset({'VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS','VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS','VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS'}), + frozenset({'VEHICLE_SPRITE_FLAG_FLAT_BANKED','VEHICLE_SPRITE_FLAG_GENTLE_SLOPES'}): frozenset({'VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS'}), + frozenset({'VEHICLE_SPRITE_FLAG_FLAT_BANKED','VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES'}): frozenset({'VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS'}), + frozenset({'VEHICLE_SPRITE_FLAG_INLINE_TWISTS'}): frozenset({'VEHICLE_SPRITE_FLAG_FLAT_BANKED', 'VEHICLE_SPRITE_FLAG_INVERTED'}), + frozenset({'VEHICLE_SPRITE_FLAG_CORKSCREWS'}): frozenset({'VEHICLE_SPRITE_FLAG_INVERTED'}), + frozenset({'VEHICLE_SPRITE_FLAG_ZERO_G_ROLLS'}): frozenset({'VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS', 'VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS', 'VEHICLE_SPRITE_FLAG_GENTLE_SLOPES', 'VEHICLE_SPRITE_FLAG_INVERTED'}), + frozenset({'VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPE_BANKED'}): frozenset({'VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS'}) +} + + diff --git a/rct-graphics-helper/operators/vehicle_render_operator.py b/rct-graphics-helper/operators/vehicle_render_operator.py index ffea7c0..7865f4a 100644 --- a/rct-graphics-helper/operators/vehicle_render_operator.py +++ b/rct-graphics-helper/operators/vehicle_render_operator.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2022 RCT Graphics Helper developers +Copyright (c) 2023 RCT Graphics Helper developers For a complete list of all authors, please refer to the addon's meta info. Interested in contributing? Visit https://github.com/oli414/Blender-RCT-Graphics @@ -12,7 +12,7 @@ import os from ..operators.render_operator import RCTRender -from ..angle_sections.track import track_angle_sections, track_angle_sections_names +from ..angle_sections.track import sprite_group_names, sprite_group_manifest class RenderVehicle(RCTRender, bpy.types.Operator): @@ -57,67 +57,38 @@ def create_task(self, context): return self.task_builder.create_task(context) - def key_is_property(self, key, props): - for sprite_track_flagset in props.sprite_track_flags_list: - if sprite_track_flagset.section_id == key: - return True - - def property_value(self, key, props): - i = 0 - for sprite_track_flagset in props.sprite_track_flags_list: - if sprite_track_flagset.section_id == key: - return props.sprite_track_flags[i] - i += 1 - - def should_render_feature(self, key, context): - props = context.scene.rct_graphics_helper_vehicle_properties - - inverted = False - if self.key_is_property(key, props): - if self.property_value(key, props): - return True - elif key == "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS" or key == "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS": - if self.property_value("SLOPED_TURNS", props): - return True - elif key == "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS": - if self.property_value("SLOPED_TURNS", props) and self.property_value("VEHICLE_SPRITE_FLAG_FLAT_BANKED", props): - return True - elif key == "VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS": - if self.property_value("VEHICLE_SPRITE_FLAG_FLAT_BANKED", props) and self.property_value("VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES", props): - return True - elif key == "VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS": - if self.property_value("VEHICLE_SPRITE_FLAG_FLAT_BANKED", props) and self.property_value("VEHICLE_SPRITE_FLAG_GENTLE_SLOPES", props): - return True - elif key == "VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION" and inverted == False: - if props.restraint_animation: - return True - return False - def add_render_angles(self, context, is_inverted=False, animation_frames=1): + properties = context.scene.rct_graphics_helper_vehicle_properties extra_roll = 0 if is_inverted: extra_roll = 180 - for i in range(len(track_angle_sections_names)): - key = track_angle_sections_names[i] - if self.should_render_feature(key, context): - track_sections = track_angle_sections[key] - for track_section in track_sections: - - base_view_angle = 0 - if track_section[0]: - base_view_angle = 45 - self.task_builder.set_rotation( - base_view_angle, -track_section[3] + extra_roll, track_section[2], track_section[4]) - - if key == "VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION": - for j in range(3): - for k in range(track_section[1]): - for l in range(animation_frames): - self.task_builder.set_rotation( - base_view_angle + k / track_section[1] * 360, -track_section[3] + extra_roll, track_section[2], track_section[4]) - self.task_builder.add_viewing_angles( - 1, animation_frames + j, 1) - else: - self.task_builder.add_viewing_angles( - track_section[1], 0, animation_frames) + for sprite_group_name in sprite_group_names: + track_sections = sprite_group_manifest[sprite_group_name] + + if sprite_group_name not in properties: + continue + precision = int(properties[sprite_group_name]) + if precision == 0: + continue + + for track_section in track_sections: + # If the sprite angle is intended to be diagonal, offset by 45 degrees unless diagonal sprites will be present + base_view_angle = 0 + if track_section[0] and precision < 8: + base_view_angle = 45 + + self.task_builder.set_rotation( + base_view_angle, -track_section[3] + extra_roll, track_section[2], track_section[4]) + + if sprite_group_name == "restraintAnimation": + for j in range(3): + for k in range(precision): + for l in range(animation_frames): + self.task_builder.set_rotation( + base_view_angle + k / precision * 360, -track_section[3] + extra_roll, track_section[2], track_section[4]) + self.task_builder.add_viewing_angles( + 1, animation_frames + j, 1) + else: + self.task_builder.add_viewing_angles( + precision, 0, animation_frames) diff --git a/rct-graphics-helper/properties/vehicle_properties.py b/rct-graphics-helper/properties/vehicle_properties.py index 9668a1f..310fa03 100644 --- a/rct-graphics-helper/properties/vehicle_properties.py +++ b/rct-graphics-helper/properties/vehicle_properties.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2022 RCT Graphics Helper developers +Copyright (c) 2023 RCT Graphics Helper developers For a complete list of all authors, please refer to the addon's meta info. Interested in contributing? Visit https://github.com/oli414/Blender-RCT-Graphics @@ -12,7 +12,7 @@ import os from ..operators.render_operator import RCTRender - +from ..angle_sections.track import sprite_group_metadata, legacy_group_names, legacy_group_metadata, legacy_groups_implied, legacy_group_dependencies, legacy_group_map class SpriteTrackFlag(object): name = "" @@ -27,80 +27,100 @@ def __init__(self, section_id, name, description, default_value): self.default_value = default_value +def CreateSpriteEnum(defaultValue): + return ( + ("0", "None" + (defaultValue == 0 and " (Default)" or ""), "No sprites rendered", 0), + ("1", "1" + (defaultValue == 1 and " (Default)" or ""), "1 sprite", 1), + ("2", "2" + (defaultValue == 2 and " (Default)" or ""), "2 sprites", 2), + ("4", "4" + (defaultValue == 4 and " (Default)" or ""), "4 sprites (recommended minimum)", 4), + ("8", "8" + (defaultValue == 8 and " (Default)" or ""), "8 sprites", 8), + ("16", "16" + (defaultValue == 16 and " (Default)" or ""), "16 sprites", 16), + ("32", "32" + (defaultValue == 32 and " (Default)" or ""), "32 sprites (RCT2 default)", 32), + ("64", "64" + (defaultValue == 64 and " (Default)" or ""), "64 sprites ", 64) + ) + +def set_groups_by_legacy_set(self, set): + for groupname, newgroups in legacy_group_map.items(): + for group in newgroups: + self[group] = sprite_group_metadata[group][0] * (groupname in set) + +# this is called with self as VehicleProperties +def legacy_groups_set(self, value): + new_with_implied = { legacy_group_names[i] for i in range(len(value)) if value[i] or (legacy_group_names[i] in legacy_groups_implied) } + new = { legacy_group_names[i] for i in range(len(value)) if value[i] and not legacy_group_names[i] in legacy_groups_implied } + for implied, dependencies in legacy_group_dependencies.items(): + if implied.issubset(new_with_implied): + for group in dependencies: + new.add(group) + if not implied.issubset(new_with_implied) and len(implied) == 1: + for group in implied: + new.discard(group) + set_groups_by_legacy_set(self, new) + value = [group in new for group in legacy_group_names] + for i in range(len(value)): + self.sprite_track_flags[i] = value[i] + +def legacy_flags_get(self): + return [x for x in self.sprite_track_flags] + +# When the user switches from full to simple mode, force the groups to match the simple mode +def sprite_group_mode_updated(self, context): + if self.sprite_group_mode == "SIMPLE": + set_groups_by_legacy_set(self, self.get_legacy_set()) + class VehicleProperties(bpy.types.PropertyGroup): - sprite_track_flags_list = [] - - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_FLAT", - "Flat", - "Render sprites for flat track", - True)) - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_GENTLE_SLOPES", - "Gentle Slopes", - "Render sprites for gentle sloped track", - True)) - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_STEEP_SLOPES", - "Steep Slopes", - "Render sprites for steep sloped track", - False)) - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES", - "Vertical Slopes And Invert", - "Render sprites for vertically sloped track and inverts", - False)) - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES", - "Diagonal Slopes", - "Render sprites for diagonal slopes", - False)) - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_FLAT_BANKED", - "Flat Banked", - "Render sprites for flat banked track", - False)) - sprite_track_flags_list.append(SpriteTrackFlag( - "SLOPED_TURNS", - "Gentle Sloped Banked", - "Render sprites for gently sloped banked track and turns", - False)) - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_INLINE_TWISTS", - "Inline twist", - "Render sprites for the inline twist element", - False)) - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_CORKSCREWS", - "Corkscrew", - "Render sprites for corkscrews", - False)) - sprite_track_flags_list.append(SpriteTrackFlag( - "VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL", - "Curved Lift Hill", - "Render sprites for a curved lift hill", - False)) - - defaults = [] - for sprite_track_flag in sprite_track_flags_list: - defaults.append(sprite_track_flag.default_value) + # Create legacy sprite groups + legacy_defaults = [] + legacy_spritegroups = {} + for legacy_group_name in legacy_group_names: + config = legacy_group_metadata[legacy_group_name] + legacy_spritegroups[legacy_group_name] = SpriteTrackFlag(legacy_group_name, *config) + legacy_defaults.append(config[2]) sprite_track_flags = bpy.props.BoolVectorProperty( name="Track Pieces", - default=defaults, + default=legacy_defaults, description="Which track pieces to render sprites for", - size=len(sprite_track_flags_list)) - - restraint_animation = bpy.props.BoolProperty( - name="Restraint Animation", - description="Render with restraint animation. The restrain animation is 3 frames long and starts at frame 1", - default=False) + size=len(legacy_spritegroups) + ) + + legacy_flags = bpy.props.BoolVectorProperty( + name="Track Pieces", + default=legacy_defaults, + description="Which track pieces to render sprites for", + size=len(legacy_spritegroups), + set = legacy_groups_set, + get = legacy_flags_get + ) + + # Create modern sprite groups + for key, config in sprite_group_metadata.items(): + locals()[key] = bpy.props.EnumProperty( + name = key, + description = config[1], + items = CreateSpriteEnum(config[0]) + ) inverted_set = bpy.props.BoolProperty( name="Inverted Set", description="Used for rides which can invert for an extended amount of time like the flying and lay-down rollercoasters", default=False) + sprite_group_mode = bpy.props.EnumProperty( + name="Sprite group mode", + items=( + ("SIMPLE", "Simple sprite groups", + "Combines several sprite groups and sets their sprite precisions automatically", 1), + ("FULL", "Full sprite groups", + "Set all sprite group precisions manually", 2), + ), + update = sprite_group_mode_updated + ) + + def get_legacy_set(self): + return { legacy_group_names[i] for i in range(len(self.sprite_track_flags)) if self.sprite_track_flags[i] } + + def register_vehicles_properties(): bpy.types.Scene.rct_graphics_helper_vehicle_properties = bpy.props.PointerProperty( diff --git a/rct-graphics-helper/rct_graphics_helper_panel.py b/rct-graphics-helper/rct_graphics_helper_panel.py index ce2e703..a66ce8f 100644 --- a/rct-graphics-helper/rct_graphics_helper_panel.py +++ b/rct-graphics-helper/rct_graphics_helper_panel.py @@ -1,5 +1,5 @@ ''' -Copyright (c) 2022 RCT Graphics Helper developers +Copyright (c) 2023 RCT Graphics Helper developers For a complete list of all authors, please refer to the addon's meta info. Interested in contributing? Visit https://github.com/oli414/Blender-RCT-Graphics @@ -20,6 +20,7 @@ from .operators.render_tiles_operator import RenderTiles from .models.palette import palette_colors, palette_colors_details +from .angle_sections.track import sprite_group_names, legacy_group_names class GraphicsHelperPanel(bpy.types.Panel): @@ -170,25 +171,48 @@ def draw_walls_panel(self, scene, layout): text = "Failed" row.operator("render.rct_walls", text=text) + legacy_group_display_order = [ + "VEHICLE_SPRITE_FLAG_FLAT", + "VEHICLE_SPRITE_FLAG_FLAT_BANKED", + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPES", + "VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS", + "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES", + "VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPE_BANKED", + "VEHICLE_SPRITE_FLAG_STEEP_SLOPES", + "VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES", + "VEHICLE_SPRITE_FLAG_INLINE_TWISTS", + "VEHICLE_SPRITE_FLAG_CORKSCREWS", + "VEHICLE_SPRITE_FLAG_ZERO_G_ROLLS", + "VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL", + "VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION" + ] + def draw_vehicle_panel(self, scene, layout): properties = scene.rct_graphics_helper_vehicle_properties general_properties = scene.rct_graphics_helper_general_properties - box = layout.box() - - row = box.row() - row.label("Ride Vehicle Track Properties:") + row = layout.row() + row.prop(properties,"sprite_group_mode") - split = box.split(.50) + box = layout.box() + split = box.split(0.5) columns = [split.column(), split.column()] i = 0 - for sprite_track_flagset in properties.sprite_track_flags_list: - columns[i % 2].row().prop(properties, "sprite_track_flags", - index=i, text=sprite_track_flagset.name) - i += 1 - - row = layout.row() - row.prop(properties, "restraint_animation") + if properties.sprite_group_mode == "SIMPLE": + for legacy_group_name in self.legacy_group_display_order: + sprite_track_flagset = properties.legacy_spritegroups[legacy_group_name] + index = legacy_group_names.index(legacy_group_name) + columns[i % 2].row().prop(properties, "legacy_flags", + index=index, text=sprite_track_flagset.name) + i += 1 + else: + columns = [column.split(0.667) for column in columns] + subcolumns = [columns[0].column(), columns[0].column(),columns[1].column(), columns[1].column()] + splitpoint = len(sprite_group_names) // 2 + for sprite_group_name in sprite_group_names: + subcolumns[(i > splitpoint) * 2].row().label(sprite_group_name+":") + subcolumns[(i > splitpoint) * 2 + 1].row().prop(properties, sprite_group_name, text = "") + i += 1 row = layout.row() row.prop(properties, "inverted_set")