Fix RC glass cube and revert temp text support

This commit is contained in:
Norbi Peti 2020-09-28 02:52:51 +02:00
parent a0ab2ec9e7
commit 16f833ceda
4 changed files with 25 additions and 82 deletions

View file

@ -160,21 +160,12 @@ namespace Pixi.Common
for (int i = 0; i < optVONsArr.Length; i++) for (int i = 0; i < optVONsArr.Length; i++)
{ {
ProcessedVoxelObjectNotation desc = optVONsArr[i]; ProcessedVoxelObjectNotation desc = optVONsArr[i];
Block b;
if (desc.block != BlockIDs.Invalid) if (desc.block != BlockIDs.Invalid)
{ {
b = Block.PlaceNew(desc.block, desc.position, desc.rotation, desc.color.Color, Block b = Block.PlaceNew(desc.block, desc.position, desc.rotation, desc.color.Color,
desc.color.Darkness, 1, desc.scale); desc.color.Darkness, 1, desc.scale);
blocks[i] = b;
} }
else
{
TextBlock tb = Block.PlaceNew<TextBlock>(BlockIDs.TextBlock, desc.position, desc.rotation,
desc.color.Color, desc.color.Darkness, 1, desc.scale);
tb.Text = desc.metadata;
b = tb;
}
blocks[i] = b;
} }
magicImporter.PostProcess(name, ref blocks); magicImporter.PostProcess(name, ref blocks);
if (magicImporter.Optimisable && blockCountPreOptimisation > blocks.Length) if (magicImporter.Optimisable && blockCountPreOptimisation > blocks.Length)

View file

@ -44,7 +44,7 @@ namespace Pixi.Common
if (origin == null) origin = origin_base; if (origin == null) origin = origin_base;
return new BlockJsonInfo return new BlockJsonInfo
{ {
name = block.Type == BlockIDs.TextBlock ? block.Label : block.Type.ToString(), name = block.Type.ToString(),
position = new float[3] { block.Position.x - origin[0], block.Position.y - origin[1], block.Position.z - origin[2]}, position = new float[3] { block.Position.x - origin[0], block.Position.y - origin[1], block.Position.z - origin[2]},
rotation = new float[3] { block.Rotation.x, block.Rotation.y, block.Rotation.z }, rotation = new float[3] { block.Rotation.x, block.Rotation.y, block.Rotation.z },
color = ColorSpaceUtility.UnquantizeToArray(block.Color), color = ColorSpaceUtility.UnquantizeToArray(block.Color),

View file

@ -215,10 +215,10 @@ namespace Pixi.Robots
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void TranslateBlockId(uint cubeId, ref CubeInfo result) private static void TranslateBlockId(uint cubeId, ref CubeInfo result)
{ {
if (map == null) if (map == null)
{ {
StreamReader cubemap = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Pixi.cubes-id.json")); StreamReader cubemap = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Pixi.cubes-id.json"));
map = JsonConvert.DeserializeObject<Dictionary<uint, string>>(cubemap.ReadToEnd()); map = JsonConvert.DeserializeObject<Dictionary<uint, string>>(cubemap.ReadToEnd());
} }
if (!map.ContainsKey(cubeId)) if (!map.ContainsKey(cubeId))
@ -231,81 +231,34 @@ namespace Pixi.Robots
#endif #endif
} }
string cubeName = map[cubeId]; string cubeName = map[cubeId];
string gcName = cubeName.Contains("glass") || cubeName.Contains("windshield")
? "Glass"
: "Aluminium";
if (cubeName.Contains("round"))
gcName += "Rounded";
if (cubeName.Contains("cube")) if (cubeName.Contains("cube"))
{ gcName += "Cube";
result.block = BlockIDs.AluminiumCube;
result.rotation = float3.zero;
}
else if (cubeName.Contains("prism") || cubeName.Contains("edge")) else if (cubeName.Contains("prism") || cubeName.Contains("edge"))
{ gcName += "Slope";
if (cubeName.Contains("round"))
{
if (cubeName.Contains("glass") || cubeName.Contains("windshield"))
{
result.block = BlockIDs.GlassRoundedSlope;
} else
result.block = BlockIDs.AluminiumRoundedSlope;
}
else
{
if (cubeName.Contains("glass") || cubeName.Contains("windshield"))
{
result.block = BlockIDs.GlassSlope;
} else
result.block = BlockIDs.AluminiumSlope;
}
}
else if (cubeName.Contains("inner")) else if (cubeName.Contains("inner"))
{ gcName += "SlicedCube";
if (cubeName.Contains("round"))
{
if (cubeName.Contains("glass") || cubeName.Contains("windshield"))
{
result.block = BlockIDs.GlassRoundedSlicedCube;
} else
result.block = BlockIDs.AluminiumRoundedSlicedCube;
}
else
{
if (cubeName.Contains("glass") || cubeName.Contains("windshield"))
{
result.block = BlockIDs.GlassSlicedCube;
} else
result.block = BlockIDs.AluminiumSlicedCube;
}
}
else if (cubeName.Contains("tetra") || cubeName.Contains("corner")) else if (cubeName.Contains("tetra") || cubeName.Contains("corner"))
{ gcName += "Corner";
if (cubeName.Contains("round"))
{
if (cubeName.Contains("glass") || cubeName.Contains("windshield"))
{
result.block = BlockIDs.GlassRoundedCorner;
} else
result.block = BlockIDs.AluminiumRoundedCorner;
}
else
{
if (cubeName.Contains("glass") || cubeName.Contains("windshield"))
{
result.block = BlockIDs.GlassCorner;
} else
result.block = BlockIDs.AluminiumCorner;
}
}
else if (cubeName.Contains("pyramid")) else if (cubeName.Contains("pyramid"))
{ gcName += "PyramidSegment";
result.block = BlockIDs.AluminiumPyramidSegment;
}
else if (cubeName.Contains("cone")) else if (cubeName.Contains("cone"))
{ gcName += "ConeSegment";
result.block = BlockIDs.AluminiumConeSegment;
}
else else
{ {
result.block = BlockIDs.TextBlock; result.block = BlockIDs.TextBlock;
result.name = cubeName; result.name = cubeName;
return;
} }
BlockIDs id = VoxelObjectNotationUtility.NameToEnum(gcName);
result.block = id;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]

View file

@ -134,11 +134,10 @@ namespace Pixi.Robots
{ {
Block block = blocks[c]; Block block = blocks[c];
// the goal is for this to never evaluate to true (ie all cubes are translated correctly) // the goal is for this to never evaluate to true (ie all cubes are translated correctly)
if (block.Type == BlockIDs.TextBlock && if (block.Type == BlockIDs.TextBlock)
(string.IsNullOrEmpty(block.Label) || block.Label == "Text Block"))
{ {
block.Specialise<TextBlock>().Text = textBlockInfo[name][textBlockInfoIndex]; block.Specialise<TextBlock>().Text = textBlockInfo[name][textBlockInfoIndex];
textBlockInfoIndex++; textBlockInfoIndex++;
} }
} }