Skip to content

Commit

Permalink
Update version number to 1.7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlorean committed Aug 31, 2023
1 parent b4ec4e0 commit 79417f8
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 11 deletions.
10 changes: 9 additions & 1 deletion Voxels.CommandLine/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Program {
[Option(Description = "Convert PNG file to VOX.")]
public bool VOX { get; set; }

[Option(Description = "Output a 3D Texture for Unity.", LongName = "3D")]
public bool Texture3D { get; set; }

[Option(Description = "The number of frames for the animated GIF.")]
public int Frames { get; set; } = 30;

Expand Down Expand Up @@ -69,7 +72,7 @@ void OnExecute() {
}
else {
// If none of PNG, SVG or GIF is specified, output PNG and SVG (previous default)
if (!PNG && !SVG && !GIF) {
if (!PNG && !SVG && !GIF && !Texture3D) {
PNG = SVG = true;
}

Expand Down Expand Up @@ -126,6 +129,11 @@ void RenderFiles(string[] filenames, RenderSettings renderSettings) {
if (SVG) {
WriteOutput(filename, "svg", Renderer.RenderSvg(voxelData, renderSettings));
}
if (Texture3D) {
Slicer.MakeSquare(voxelData.Size, out var rows, out var columns);

WriteOutput(filename, $"({columns}x{rows}).png", Slicer.RenderTexture3D(voxelData, columns, rows));
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Voxels.CommandLine/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.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
63 changes: 63 additions & 0 deletions Voxels.CommandLine/Slicer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SkiaSharp;

namespace Voxels.CommandLine {
public class Slicer {
/// <summary>
/// Render each slice of the voxel data into a long single PNG file for use as a 3D texture in Unity.
/// Unity 3D textures are sliced along the Unity Z axis, which is the Voxel Y axis (front to back).
/// </summary>
/// <param name="voxels"></param>
/// <returns>A byte array of the voxel slices in PNG format.</returns>
public static byte[] RenderTexture3D(VoxelData voxels, int columns, int rows) {
using (var bitmap = new SKBitmap(voxels.Size.X*columns, voxels.Size.Z*rows)) {
if (bitmap == null) return null;

for (var y = 0; y < voxels.Size.Y; y++) {
var dx = (y%columns) * voxels.Size.X;
var dz = (y/columns) * voxels.Size.Z;
for (var x = 0; x < voxels.Size.X; x++) {
for (var z = 0; z < voxels.Size.Z; z++) {
var c = voxels.ColorOf(new XYZ(x, y, (voxels.Size.Z-z-1)));
bitmap.SetPixel(x + dx, z + dz, new SKColor(c.R, c.G, c.B, c.A));
}
}
}

using (var image = SKImage.FromBitmap(bitmap)) {
using (var data = image.Encode()) {
var ms = new MemoryStream();
data.SaveTo(ms);
return ms.ToArray();
}
}
}
}

/// <summary>
/// Unity does not like really wide textures so we have to create the most square texture we can.
/// </summary>
/// <param name="size"></param>
/// <param name="rows"></param>
/// <param name="columns"></param>
public static void MakeSquare(XYZ size, out int rows, out int columns) {
rows = 1;
columns = size.Y;

while (columns % 2 == 0) {
columns /= 2;
rows *= 2;

// Closest we can get to a square
if (columns <= rows) {
return;
}
}
}
}
}
1 change: 1 addition & 0 deletions Voxels.CommandLine/Voxels.CommandLine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Compile Include="ImageToVoxel.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Slicer.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="3x3x3.vox">
Expand Down
2 changes: 1 addition & 1 deletion Voxels.Installer/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Voxels.Installer" Language="1033" Version="1.6.0.0" Manufacturer="Arlorean" UpgradeCode="70e5c55f-1a55-4856-a0fc-a82ece384a74">
<Product Id="*" Name="Voxels.Installer" Language="1033" Version="1.7.0.0" Manufacturer="Arlorean" UpgradeCode="70e5c55f-1a55-4856-a0fc-a82ece384a74">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
Expand Down
2 changes: 1 addition & 1 deletion Voxels.Setup/Bundle.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

<!-- Source: https://gist.github.com/nathancorvussolis/6852ba282647aeb0c5c00e742e28eb48 -->
<Bundle Name="Voxels Shell Extensions" Version="1.6.0.0" Manufacturer="Arlorean"
<Bundle Name="Voxels Shell Extensions" Version="1.7.0.0" Manufacturer="Arlorean"
Copyright="© 2023 Adam Davidson" AboutUrl="https://github.com/Arlorean/Voxels"
UpgradeCode="{1823F323-C07E-4502-A4BA-CA8EDCA46161}" Condition="VersionNT &gt;= v5.1"
IconSourceFile="Voxels.ico">
Expand Down
4 changes: 2 additions & 2 deletions Voxels.ShellExtensions/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.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
4 changes: 2 additions & 2 deletions Voxels.SkiaSharp/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.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
4 changes: 2 additions & 2 deletions Voxels.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
[assembly: Guid("44fd680f-9699-49d0-926c-e392b8cf521c")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]

0 comments on commit 79417f8

Please sign in to comment.