mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-24 12:50:53 +00:00
feat(Blender tools): some minor fixed for Bevy 0.14 & version bump
This commit is contained in:
parent
f4dd0e59a5
commit
93ef2a7808
@ -1,7 +1,7 @@
|
||||
bl_info = {
|
||||
"name": "bevy_components",
|
||||
"author": "kaosigh",
|
||||
"version": (0, 4, 1),
|
||||
"version": (0, 4, 2),
|
||||
"blender": (3, 4, 0),
|
||||
"location": "VIEW_3D",
|
||||
"description": "UI to help create Bevy blueprints and components",
|
||||
|
@ -22,7 +22,9 @@ conversion_tables = {
|
||||
|
||||
"glam::Quat": lambda value: "Quat(x:"+str(value[0])+ ", y:"+str(value[1])+ ", z:"+str(value[2])+ ", w:"+str(value[3])+")",
|
||||
|
||||
"bevy_render::color::Color": lambda value: "Rgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
|
||||
"bevy_color::srgba::Srgba": lambda value: "Srgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
|
||||
"bevy_color::linear_rgba::LinearRgba": lambda value: "LinearRgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
|
||||
"bevy_color::hsva::Hsva": lambda value: "Hsva(hue:"+str(value[0])+ ", saturation:"+str(value[1])+ ", value:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
|
||||
}
|
||||
|
||||
#converts the value of a property group(no matter its complexity) into a single custom property value
|
||||
|
@ -118,10 +118,14 @@ def parse_vec4(value, caster, typeName):
|
||||
parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") )
|
||||
return [caster(parsed['x']), caster(parsed['y']), caster(parsed['z']), caster(parsed['w'])]
|
||||
|
||||
def parse_color(value, caster, typeName):
|
||||
def parse_color_rgba(value, caster, typeName):
|
||||
parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") )
|
||||
return [caster(parsed['red']), caster(parsed['green']), caster(parsed['blue']), caster(parsed['alpha'])]
|
||||
|
||||
def parse_color_hsva(value, caster, typeName):
|
||||
parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") )
|
||||
return [caster(parsed['hue']), caster(parsed['saturation']), caster(parsed['value']), caster(parsed['alpha'])]
|
||||
|
||||
def to_int(input):
|
||||
return int(float(input))
|
||||
|
||||
@ -163,7 +167,10 @@ type_mappings = {
|
||||
'alloc::string::String': lambda value: str(value.replace('"', "")),
|
||||
'alloc::borrow::Cow<str>': lambda value: str(value.replace('"', "")),
|
||||
|
||||
'bevy_render::color::Color': lambda value: parse_color(value, float, "Rgba"),
|
||||
"bevy_color::srgba::Srgba": lambda value: parse_color_rgba(value, float, "Srgba"),
|
||||
"bevy_color::linear_rgba::LinearRgba": lambda value: parse_color_rgba(value, float, "LinearRgba"),
|
||||
"bevy_color::hsva::Hsva": lambda value: parse_color_hsva(value, float, "Hsva"),
|
||||
|
||||
'bevy_ecs::entity::Entity': lambda value: int(value),
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,9 @@ class ComponentsRegistry(PropertyGroup):
|
||||
|
||||
"glam::Quat": {"type": FloatVectorProperty, "presets": {"size":4} },
|
||||
|
||||
"bevy_render::color::Color": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)),
|
||||
"bevy_color::srgba::Srgba": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)),
|
||||
"bevy_color::linear_rgba::LinearRgba": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)),
|
||||
"bevy_color::hsva::Hsva": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)),
|
||||
|
||||
"char": dict(type=StringProperty, presets=dict()),
|
||||
"str": dict(type=StringProperty, presets=dict()),
|
||||
@ -202,7 +204,9 @@ class ComponentsRegistry(PropertyGroup):
|
||||
|
||||
"glam::Quat": [0.0, 0.0, 0.0, 0.0],
|
||||
|
||||
"bevy_render::color::Color": [1.0, 1.0, 0.0, 1.0],
|
||||
"bevy_color::srgba::Srgba": [1.0, 1.0, 0.0, 1.0],
|
||||
"bevy_color::linear_rgba::LinearRgba": [1.0, 1.0, 0.0, 1.0],
|
||||
"bevy_color::hsva::Hsva": [1.0, 1.0, 0.0, 1.0],
|
||||
|
||||
'bevy_ecs::entity::Entity': 0,#4294967295, # this is the same as Bevy's Entity::Placeholder, too big for Blender..sigh
|
||||
'bevy_utils::Uuid': '"'+str(uuid.uuid4())+'"'
|
||||
|
@ -61,7 +61,10 @@ type_mappings = {
|
||||
|
||||
"glam::Quat": lambda : random_vec(4, 'float'),
|
||||
|
||||
'bevy_render::color::Color': lambda : random_vec(4, 'float'),
|
||||
'bevy_color::srgba::Srgba': lambda : random_vec(4, 'float'),
|
||||
'bevy_color::linear_rgba::LinearRgba': lambda : random_vec(4, 'float'),
|
||||
'bevy_color::hsva::Hsva': lambda : random_vec(4, 'float'),
|
||||
|
||||
'alloc::string::String': lambda : random_word(8),
|
||||
'alloc::borrow::Cow<str>': lambda : random_word(8),
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
bl_info = {
|
||||
"name": "gltf_auto_export",
|
||||
"author": "kaosigh",
|
||||
"version": (0, 16, 0),
|
||||
"version": (0, 16, 1),
|
||||
"blender": (3, 4, 0),
|
||||
"location": "File > Import-Export",
|
||||
"description": "glTF/glb auto-export",
|
||||
|
@ -44,7 +44,7 @@ def ambient_color_to_component(world):
|
||||
|
||||
|
||||
if color is not None and strength is not None:
|
||||
colorRgba = f"Rgba(red: {color[0]}, green: {color[1]}, blue: {color[2]}, alpha: {color[3]})"
|
||||
colorRgba = f"LinearRgba((red: {color[0]}, green: {color[1]}, blue: {color[2]}, alpha: {color[3]}))"
|
||||
component = f"( color: {colorRgba}, strength: {strength})"
|
||||
return component
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user