Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preset system #168

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open

Conversation

NMC-TBone
Copy link
Contributor

@NMC-TBone NMC-TBone commented Apr 15, 2023

Preset system for properties based on discussion #109
Includes same predefiend presets as Giants Maya & Blender exporter, in addition you can also create your own presets.

The custom presets will be stored in:
%appdata%\Blender Foundation\Blender\4.3\presets\i3dio

image

The only thing thats a bit annoying is that we cannot have the delete operator on the same row as the execute operator (for each individual user preset). Because in a menu this will for some reason either scale the menu width across your entire monitor or misalign the operators.
So I did it like this for now:
image

When you click on Delete Preset this new popup menu will appear with a enum of all the user made presets:
image

Since we need custom logic to properly save the the user presets we cannot use the "standard" preset menu that blender use. If a user make a preset on e.g. a mesh object, we need to write to add obj type checks in the preset file to prevent setting e.g. something with rigid body properties to a empty or joint properties to a mesh etc etc.

import bpy
obj = bpy.context.object

obj.i3d_attributes.visibility = True
obj.i3d_attributes.clip_distance = 1000000.0
obj.i3d_attributes.min_clip_distance = 0.0
obj.i3d_attributes.object_mask = '0'
obj.i3d_attributes.exclude_from_export = False

if obj.type == 'MESH':
    obj.i3d_attributes.rigid_body_type = 'none'
    obj.i3d_attributes.collision = True
    obj.i3d_attributes.collision_mask = 'ff'
    obj.i3d_attributes.compound = False
    obj.i3d_attributes.trigger = False
    obj.i3d_attributes.restitution = 0.0
    obj.i3d_attributes.static_friction = 0.5
    obj.i3d_attributes.dynamic_friction = 0.5
    obj.i3d_attributes.linear_damping = 0.0
    obj.i3d_attributes.angular_damping = 0.009999999776482582
    obj.i3d_attributes.density = 1.0
    obj.i3d_attributes.solver_iteration_count = 4
    obj.i3d_attributes.split_type = 0
    obj.i3d_attributes.split_uvs = [0.0, 0.0, 1.0, 1.0, 1.0]
    obj.data.i3d_attributes.casts_shadows = False
    obj.data.i3d_attributes.receive_shadows = False
    obj.data.i3d_attributes.non_renderable = False
    obj.data.i3d_attributes.distance_blending = True
    obj.data.i3d_attributes.rendered_in_viewports = True
    obj.data.i3d_attributes.is_occluder = False
    obj.data.i3d_attributes.cpu_mesh = '0'
    obj.data.i3d_attributes.nav_mesh_mask = '0'
    obj.data.i3d_attributes.decal_layer = 0
    obj.data.i3d_attributes.fill_volume = False
    obj.data.i3d_attributes.use_vertex_colors = False
import bpy
obj = bpy.context.object

obj.i3d_attributes.visibility = True
obj.i3d_attributes.clip_distance = 1000000.0
obj.i3d_attributes.min_clip_distance = 0.0
obj.i3d_attributes.object_mask = '0'
obj.i3d_attributes.exclude_from_export = False

if obj.type == 'EMPTY':
    obj.i3d_attributes.lod_distances = [0.0, 0.0, 0.0, 0.0]
    obj.i3d_attributes.lod_blending = True
    obj.i3d_attributes.use_parent = True
    obj.i3d_attributes.minute_of_day_start = 0
    obj.i3d_attributes.minute_of_day_end = 0
    obj.i3d_attributes.day_of_year_start = 0
    obj.i3d_attributes.day_of_year_end = 0
    obj.i3d_attributes.weather_required_mask = '0'
    obj.i3d_attributes.weather_prevent_mask = '0'
    obj.i3d_attributes.viewer_spaciality_required_mask = '0'
    obj.i3d_attributes.viewer_spaciality_prevent_mask = '0'
    obj.i3d_attributes.render_invisible = False
    obj.i3d_attributes.visible_shader_parameter = 1.0
    obj.i3d_attributes.joint = False
    obj.i3d_attributes.projection = False
    obj.i3d_attributes.projection_distance = 0.009999999776482582
    obj.i3d_attributes.projection_angle = 0.009999999776482582
    obj.i3d_attributes.x_axis_drive = False
    obj.i3d_attributes.y_axis_drive = False
    obj.i3d_attributes.z_axis_drive = False
    obj.i3d_attributes.drive_position = False
    obj.i3d_attributes.drive_force_limit = 100000.0
    obj.i3d_attributes.drive_spring = 1.0
    obj.i3d_attributes.drive_damping = 0.009999999776482582
    obj.i3d_attributes.breakable_joint = False
    obj.i3d_attributes.joint_break_force = 0.0
    obj.i3d_attributes.joint_break_torque = 0.0

Settings to export mirrors with mirrorShader.xml applied in the shader:

Base Color (RGB): 0 0 0
Metallic: 1
Roughness: 1
Specular: 1
When there is no path set for the any emissiveTexture it will write the emissiveColor to i3d file if value is not 0, 0, 0, 1. Also works with ShaderNodeRGB node connected.
Adds attribute for Nav Mesh Mask, used for building the nav mesh in Giants Editor
Preset system with lots of predefined presets to choose from, if you want a custom preset you can create one directly inside blender. Set custom values for the properties you want in your custom preset, click on the + symbol and write a good name for your custom preset. (Custom presets can be found across all your blender projects)
@StjerneIdioten
Copy link
Owner

I am not entirely sold on this feature being a persistent drop-down menu with a selected value in the UI, since changing any of the parameters technically makes that drop-down wrong in stating that you are on a given preset.

Would it be possible to do something more similar to how Blender itself utilises and shows the presets? An example can be seen in Output Properties --> Format

image
image

PR to keep up to date with new attributes
@NMC-TBone NMC-TBone marked this pull request as draft December 16, 2024 10:41
@NMC-TBone NMC-TBone marked this pull request as ready for review January 17, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants