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

feat: changed setting to boolean for vertex colors and alpha blending… #211

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion addon/i3dio/node_classes/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _write_emission(self, emission_color):

def _write_properties(self):
# Alpha blending
if self.blender_material.blend_method in ['CLIP', 'HASHED', 'BLEND']:
if self.blender_material.i3d_attributes.alpha_blending:
self._write_attribute('alphaBlending', True)

def _export_shader_settings(self):
Expand Down
9 changes: 5 additions & 4 deletions addon/i3dio/node_classes/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ def process_subset(self, mesh, subset: SubSet, triangle_offset: int = 0) -> tupl

# Add vertex color
vertex_color = None
if len(mesh.vertex_colors):
# Get the color from the active layer or first layer, since only one vertex color layer is supported in GE
color_layer = mesh.vertex_colors.active if mesh.vertex_colors.active is not None else mesh.vertex_colors[0]
vertex_color = color_layer.data[loop_index].color
if mesh.i3d_attributes.use_vertex_color:
if len(mesh.vertex_colors):
# Get the color from the active layer or first layer, since only one vertex color layer is supported in GE
color_layer = mesh.vertex_colors.active if mesh.vertex_colors.active is not None else mesh.vertex_colors[0]
vertex_color = color_layer.data[loop_index].color

# Add uvs
uvs = []
Expand Down
7 changes: 7 additions & 0 deletions addon/i3dio/ui/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ class I3DNodeShapeAttributes(bpy.types.PropertyGroup):
type=bpy.types.Object,
)

use_vertex_color: BoolProperty(
name="Use Vertex Color",
default=False,
description="If enabled, vertex color will be exported"
)


@register
class I3D_IO_PT_shape_attributes(Panel):
Expand Down Expand Up @@ -133,6 +139,7 @@ def draw(self, context):
layout.prop(obj.i3d_attributes, "nav_mesh_mask")
layout.prop(obj.i3d_attributes, "decal_layer")
layout.prop(obj.i3d_attributes, 'fill_volume')
layout.prop(obj.i3d_attributes, "use_vertex_color")


@register
Expand Down
4 changes: 4 additions & 0 deletions addon/i3dio/ui/shader_picker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import bpy
from bpy.types import (Panel)
from bpy.props import (
BoolProperty,
StringProperty,
PointerProperty,
EnumProperty,
Expand Down Expand Up @@ -269,6 +270,7 @@ def variation_getter(self):
set=variation_setter
)

alpha_blending: BoolProperty(name='Alpha Blending', default=False, description='Enable alpha blending for this material')
variations: CollectionProperty(type=I3DShaderVariation)
shader_parameters: CollectionProperty(type=I3DShaderParameter)
shader_textures: CollectionProperty(type=I3DShaderTexture)
Expand All @@ -291,6 +293,8 @@ def draw(self, context):
layout.use_property_decorate = False
material = bpy.context.active_object.active_material

layout.prop(material.i3d_attributes, 'alpha_blending')

layout.prop(material.i3d_attributes, 'source')
if material.i3d_attributes.variations:
layout.prop(material.i3d_attributes, 'variation')
Expand Down