Skip to content

Commit

Permalink
Fixed bug with non-English locales and Blender not using BSDF sometimes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxic-Cookie committed Jan 29, 2022
1 parent 2e4ecec commit 222c6dd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
27 changes: 15 additions & 12 deletions NeosBakery/Core/Bakery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Bakery : NeosMod
{
public override string Name => "NeosBakery";
public override string Author => "Toxic_Cookie";
public override string Version => "1.0.0";
public override string Version => "1.0.2";
public override string Link => "https://github.com/Toxic-Cookie/NeosBakery";

public override void OnEngineInit()
Expand Down Expand Up @@ -47,20 +47,23 @@ static void RectTransform_OnTargetChange(SyncRef<RectTransform> reference)
await Task.Delay(TimeSpan.FromSeconds(Engine.Current.WorldManager.FocusedWorld.Time.Delta + 0.01f)).ConfigureAwait(continueOnCapturedContext: false);
await default(ToWorld);

foreach (Text text in reference.Target.Slot.GetComponentsInChildren<Text>())
List<Text> texts = reference.Target.Slot.GetComponentsInChildren<Text>();

if (texts[0] == null)
{
return;
}
if (!texts[0].Content.Value.Contains("3D"))
{
if (text.Content.Value.Contains("Empty"))
{
Slot buttonSlot = text.Slot.Parent.Duplicate();
buttonSlot.GetComponentInChildren<Text>().Content.Value = "Light Baker Wizard";
buttonSlot.GetComponent<ButtonRelay<string>>().Destroy();
return;
}

Button button = buttonSlot.GetComponent<Button>();
button.LocalPressed += Button_LocalPressed;
Slot buttonSlot = texts[8].Slot.Parent.Duplicate();
buttonSlot.GetComponentInChildren<Text>().Content.Value = "Light Baker Wizard";
buttonSlot.GetComponent<ButtonRelay<string>>().Destroy();

break;
}
}
Button button = buttonSlot.GetComponent<Button>();
button.LocalPressed += Button_LocalPressed;
});
}
static void Button_LocalPressed(IButton button, ButtonEventData eventData)
Expand Down
4 changes: 1 addition & 3 deletions NeosBakery/Core/Defs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace NeosBakery.Core
{
//TODO: More documentation.
static class Defs
{
public enum ViewType
Expand Down Expand Up @@ -172,7 +171,6 @@ public BakeObjectDefinition(TransformDefinition transform, RendererDefinition me
public struct LightDefinition
{
public readonly TransformDefinition Transform;
//Point, Directional(Sun), Spot
public readonly int LightType;
public readonly float[] Color;
public readonly float Watts;
Expand All @@ -185,7 +183,7 @@ public LightDefinition(Light light)
Color = new float[4] { light.Color.Value.r, light.Color.Value.g, light.Color.Value.b, light.Color.Value.a };

float rgb = Math.Max(Math.Max(light.Color.Value.r, light.Color.Value.g), light.Color.Value.b);
//Convert from Intensity and Range to Watts. Might need more tweaking.

switch (light.LightType.Value)
{
case FrooxEngine.LightType.Point:
Expand Down
4 changes: 2 additions & 2 deletions NeosBakery/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
6 changes: 4 additions & 2 deletions NeosBakery/Python/bake.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

_scene = bpy.context.scene

_scene.tool_settings.transform_pivot_point = 'ACTIVE_ELEMENT'
_scene.tool_settings.transform_pivot_point = "ACTIVE_ELEMENT"
_scene.render.image_settings.file_format = "PNG"
_scene.render.image_settings.color_mode = "RGBA"
_scene.world.use_nodes = True
Expand Down Expand Up @@ -164,7 +164,9 @@ def clamp(Val, Min, Max):
currentMaterial.use_nodes = True
nodetree = currentMaterial.node_tree
nodes = currentMaterial.node_tree.nodes
inputs = nodes["Principled BSDF"].inputs
bsdfNode = nodes.new(type="ShaderNodeBsdfPrincipled")
nodetree.links.new(bsdfNode.outputs["BSDF"], nodes["Material Output"].inputs["Surface"])
inputs = bsdfNode.inputs
inputs["Base Color"].default_value[0] = _material["AlbedoColor"][0]
inputs["Base Color"].default_value[1] = _material["AlbedoColor"][1]
inputs["Base Color"].default_value[2] = _material["AlbedoColor"][2]
Expand Down

0 comments on commit 222c6dd

Please sign in to comment.