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

Update 1.3.3 - Issue #252 Rainbow pattern - Vertex Color fix #318

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions addons/io_scene_gltf2_msfs/io/msfs_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@ def gather_asset_hook(self, gltf2_asset, export_settings):

gltf2_asset.generator += " and Asobo Studio MSFS Blender I/O v" + get_version_string()

# for the vetex color rainbow
# asset hook is called first before the nodes and objects and mesh, so we make changes to the meshes here
# possible caching of blender data may result in changes not takeng at the point of hook function running
# does not work in:
# def gather_mesh_hook(self, gltf2_mesh, blender_mesh, blender_object, vertex_groups, modifiers, skip_filter, materials, export_settings):

#print("gather_asset_hook - Started with ", gltf2_asset)
selected_objects = bpy.context.selected_objects
active_object = bpy.context.active_object
for o in selected_objects:
#for o in bpy.context.scene.objects:
#print("gather_asset_hook - Scene Object",o)
# only for meshes
if o.type == 'MESH':
obj = o
#print("gather_asset_hook - obj", obj, obj.data)
for ca in obj.data.color_attributes:
if ca.data_type != 'FLOAT_COLOR':
#print("gather_asset_hook - col before", obj, ca.domain, ca.data_type)
bpy.context.view_layer.objects.active = obj
#print("gather_asset_hook - col view_layer", obj, ca.domain, ca.data_type)
bpy.ops.geometry.attribute_convert(mode='GENERIC', domain='CORNER', data_type='FLOAT_COLOR')
#print("gather_asset_hook - After", obj, obj.data)
for ca in obj.data.color_attributes:
#print("gather_asset_hook - col after", obj, ca.data_type)
pass
#print("gather_asset_hook - Done")

def gather_gltf_extensions_hook(self, gltf2_plan, export_settings):
if self.properties.enable_msfs_extension:
for i, image in enumerate(gltf2_plan.images):
Expand Down